326 \end{center} |
326 \end{center} |
327 |
327 |
328 \noindent |
328 \noindent |
329 (Note that this means also the term-constructors for variables, applications |
329 (Note that this means also the term-constructors for variables, applications |
330 and lambda are lifted to the quotient level.) This construction, of course, |
330 and lambda are lifted to the quotient level.) This construction, of course, |
331 only works if alpha-equivalence is indeed an equivalence relation, and the lifted |
331 only works if alpha-equivalence is indeed an equivalence relation, and the |
332 definitions and theorems are respectful w.r.t.~alpha-equivalence. For example, we |
332 lifted definitions and theorems are respectful w.r.t.~alpha-equivalence. |
333 will not be able to lift a bound-variable function, which can be defined for |
333 For example, we will not be able to lift a bound-variable function. Although |
334 raw terms. The reason is that this function does not respect alpha-equivalence. |
334 this function can be defined for raw terms, it does not respect |
335 To sum up, every lifting of |
335 alpha-equivalence and therefore cannot be lifted. To sum up, every lifting |
336 theorems to the quotient level needs proofs of some respectfulness |
336 of theorems to the quotient level needs proofs of some respectfulness |
337 properties (see \cite{Homeier05}). In the paper we show that we are able to |
337 properties (see \cite{Homeier05}). In the paper we show that we are able to |
338 automate these |
338 automate these proofs and therefore can establish a reasoning infrastructure |
339 proofs and therefore can establish a reasoning infrastructure for |
339 for alpha-equated terms. |
340 alpha-equated terms. |
|
341 |
340 |
342 The examples we have in mind where our reasoning infrastructure will be |
341 The examples we have in mind where our reasoning infrastructure will be |
343 helpful includes the term language of System @{text "F\<^isub>C"}, also known as |
342 helpful includes the term language of System @{text "F\<^isub>C"}, also |
344 Core-Haskell (see Figure~\ref{corehas}). This term language involves patterns |
343 known as Core-Haskell (see Figure~\ref{corehas}). This term language |
345 that include lists of |
344 involves patterns that have lists of type- and term-variables (the |
346 type- and term- variables (the arguments of constructors) all of which are |
345 arguments of constructors) all of which are bound in case expressions. One |
347 bound in case expressions. One difficulty is that each of these variables |
346 difficulty is that each of these variables come with a kind or type |
348 come with a kind or type annotation. Representing such binders with single |
347 annotation. Representing such binders with single binders and reasoning |
349 binders and reasoning about them in a theorem prover would be a major pain. |
348 about them in a theorem prover would be a major pain. \medskip |
350 \medskip |
|
351 |
|
352 |
349 |
353 \noindent |
350 \noindent |
354 {\bf Contributions:} We provide new definitions for when terms |
351 {\bf Contributions:} We provide new definitions for when terms |
355 involving multiple binders are alpha-equivalent. These definitions are |
352 involving multiple binders are alpha-equivalent. These definitions are |
356 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
353 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
367 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
364 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
368 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\medskip\\ |
365 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\medskip\\ |
369 \multicolumn{3}{@ {}l}{Coercion Kinds}\\ |
366 \multicolumn{3}{@ {}l}{Coercion Kinds}\\ |
370 @{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\medskip\\ |
367 @{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\medskip\\ |
371 \multicolumn{3}{@ {}l}{Types}\\ |
368 \multicolumn{3}{@ {}l}{Types}\\ |
372 @{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"}\\ |
369 @{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"} |
373 & & @{text "| \<forall>a:\<kappa>. \<sigma> "}\\ |
370 @{text "| \<forall>a:\<kappa>. \<sigma> | \<iota> \<Rightarrow> \<sigma>"}\medskip\\ |
374 & & ??? Type equality\medskip\\ |
|
375 \multicolumn{3}{@ {}l}{Coercion Types}\\ |
371 \multicolumn{3}{@ {}l}{Coercion Types}\\ |
376 @{text "\<gamma>"} & @{text "::="} & @{text "a | C | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"}\\ |
372 @{text "\<gamma>"} & @{text "::="} & @{text "c | C | \<gamma>\<^isub>1 \<gamma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"} |
377 & & @{text "| \<forall>a:\<iota>. \<gamma>"}\\ |
373 @{text "| \<forall>c:\<iota>. \<gamma> | \<iota> \<Rightarrow> \<gamma> |"}\\ |
378 & & ??? Coercion Type equality\\ |
374 & & @{text "refl \<sigma> | sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2 | \<gamma> @ \<sigma> |"}\\ |
379 & & @{text "| sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2 | left \<gamma> | right \<gamma> | \<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 "}\\ |
375 & & @{text "left \<gamma> | right \<gamma> | \<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 |"}\\ |
380 & & @{text "| rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\medskip\\ |
376 & & @{text "rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\medskip\\ |
381 \multicolumn{3}{@ {}l}{Terms}\\ |
377 \multicolumn{3}{@ {}l}{Terms}\\ |
382 @{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>a:\<iota>. e | e \<sigma> | e \<gamma> |"}\\ |
378 @{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>c:\<iota>. e | e \<sigma> | e \<gamma> |"}\\ |
383 & & @{text "\<lambda>x:\<sigma>.e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2 |"}\\ |
379 & & @{text "\<lambda>x:\<sigma>. e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2 |"}\\ |
384 & & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\medskip\\ |
380 & & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\medskip\\ |
385 \multicolumn{3}{@ {}l}{Patterns}\\ |
381 \multicolumn{3}{@ {}l}{Patterns}\\ |
386 @{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "a:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\medskip\\ |
382 @{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "c:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\medskip\\ |
387 \multicolumn{3}{@ {}l}{Constants}\\ |
383 \multicolumn{3}{@ {}l}{Constants}\\ |
388 @{text C} & & coercion constant\\ |
384 @{text C} & & coercion constants\\ |
389 @{text T} & & value type constructor\\ |
385 @{text T} & & value type constructors\\ |
390 @{text "S\<^isub>n"} & & n-ary type function\\ |
386 @{text "S\<^isub>n"} & & n-ary type functions\\ |
391 @{text K} & & data constructor\medskip\\ |
387 @{text K} & & data constructors\medskip\\ |
392 \multicolumn{3}{@ {}l}{Variables}\\ |
388 \multicolumn{3}{@ {}l}{Variables}\\ |
393 @{text a} & & type variable\\ |
389 @{text a} & & type variables\\ |
394 @{text x} & & term variable\\ |
390 @{text c} & & coercion variables\\ |
|
391 @{text x} & & term variables\\ |
395 \end{tabular} |
392 \end{tabular} |
396 \end{center} |
393 \end{center} |
397 \end{boxedminipage} |
394 \end{boxedminipage} |
398 \caption{The term-language of System @{text "F\<^isub>C"}, also often referred to as Core-Haskell, |
395 \caption{The term-language of System @{text "F\<^isub>C"}, also often referred to as \emph{Core-Haskell} |
399 according to \cite{CoreHaskell}. We only made an inessential modification by |
396 \cite{CoreHaskell}. In this version of Core-Haskell we made a modification by |
400 separating the grammars for type kinds and coercion types.\label{corehas}} |
397 separating completely the grammars for type kinds and coercion types.\label{corehas}} |
401 \end{figure} |
398 \end{figure} |
402 *} |
399 *} |
403 |
400 |
404 section {* A Short Review of the Nominal Logic Work *} |
401 section {* A Short Review of the Nominal Logic Work *} |
405 |
402 |
406 text {* |
403 text {* |
407 At its core, Nominal Isabelle is an adaption of the nominal logic work by |
404 At its core, Nominal Isabelle is an adaption of the nominal logic work by |
408 Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in |
405 Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in |
409 \cite{HuffmanUrban10} (including proofs), which we review here briefly to aid the description |
406 \cite{HuffmanUrban10} (including proofs). We shall briefly review this work |
410 of what follows. Two central notions in the nominal logic work are sorted |
407 to aid the description of what follows. |
411 atoms and sort-respecting permutations of atoms. The sorts can be used to |
408 |
412 represent different kinds of variables, such as the term- and type-variables in |
409 Two central notions in the nominal |
413 Core-Haskell, and it is assumed that there is an infinite supply of atoms |
410 logic work are sorted atoms and sort-respecting permutations of atoms. The |
414 for each sort. However, in order to simplify the description, we shall |
411 sorts can be used to represent different kinds of variables, such as the |
415 assume in what follows that there is only one sort of atoms. |
412 term- and type-variables in Core-Haskell, and it is assumed that there is an |
|
413 infinite supply of atoms for each sort. However, in order to simplify the |
|
414 description, we shall assume in what follows that there is only one sort of |
|
415 atoms. |
416 |
416 |
417 Permutations are bijective functions from atoms to atoms that are |
417 Permutations are bijective functions from atoms to atoms that are |
418 the identity everywhere except on a finite number of atoms. There is a |
418 the identity everywhere except on a finite number of atoms. There is a |
419 two-place permutation operation written |
419 two-place permutation operation written |
420 % |
420 % |
421 @{text[display,indent=5] "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
421 @{text[display,indent=5] "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
422 |
422 |
423 \noindent |
423 \noindent |
424 in which the generic type @{text "\<beta>"} stands for the type of the object |
424 in which the generic type @{text "\<beta>"} stands for the type of the object |
425 on which the permutation |
425 over which the permutation |
426 acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
426 acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
427 the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, |
427 the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, |
428 and the inverse permutation of @{term p} as @{text "- p"}. The permutation |
428 and the inverse permutation of @{term p} as @{text "- p"}. The permutation |
429 operation is defined for products, lists, sets, functions, booleans etc (see \cite{HuffmanUrban10}) |
429 operation is defined by induction over the type-hierarchy, for example as follows |
430 |
430 for products, lists, sets, functions and booleans (see \cite{HuffmanUrban10}): |
431 \begin{center} |
431 |
432 \begin{tabular}{@ {}cc@ {}} |
432 \begin{equation} |
|
433 \mbox{\begin{tabular}{@ {}cc@ {}} |
433 \begin{tabular}{@ {}l@ {}} |
434 \begin{tabular}{@ {}l@ {}} |
434 @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm] |
435 @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm] |
435 @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\ |
436 @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\ |
436 @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\ |
437 @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\ |
437 \end{tabular} & |
438 \end{tabular} & |
438 \begin{tabular}{@ {}l@ {}} |
439 \begin{tabular}{@ {}l@ {}} |
439 @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\ |
440 @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\ |
440 @{text "p \<bullet> (f x) \<equiv> (p \<bullet> f) (p \<bullet> x)"}\\ |
441 @{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\ |
441 @{thm permute_bool_def[no_vars, THEN eq_reflection]}\\ |
442 @{thm permute_bool_def[no_vars, THEN eq_reflection]}\\ |
442 \end{tabular} |
443 \end{tabular} |
443 \end{tabular} |
444 \end{tabular}} |
444 \end{center} |
445 \end{equation} |
445 |
446 |
446 \noindent |
447 \noindent |
447 Concrete permutations are build up from |
448 Concrete permutations are build up from swappings, written as @{text "(a |
448 swappings, written as @{text "(a b)"}, |
449 b)"}, which are permutations that behave as follows: |
449 which are permutations that behave as follows: |
|
450 % |
450 % |
451 @{text[display,indent=5] "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
451 @{text[display,indent=5] "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
452 |
452 |
453 The most original aspect of the nominal logic work of Pitts is a general |
453 The most original aspect of the nominal logic work of Pitts is a general |
454 definition for the notion of ``the set of free variables of an object @{text |
454 definition for the notion of ``the set of free variables of an object @{text |