99 because also there one would like to bind multiple variables at once. |
99 because also there one would like to bind multiple variables at once. |
100 |
100 |
101 Binding multiple variables has interesting properties that cannot be captured |
101 Binding multiple variables has interesting properties that cannot be captured |
102 easily by iterating single binders. For example in the case of type-schemes we do not |
102 easily by iterating single binders. For example in the case of type-schemes we do not |
103 want to make a distinction about the order of the bound variables. Therefore |
103 want to make a distinction about the order of the bound variables. Therefore |
104 we would like to regard the first pair of type-schemes as alpha-equivalent, |
104 we would like to regard below the first pair of type-schemes as alpha-equivalent, |
105 but assuming that @{text x}, @{text y} and @{text z} are distinct variables, |
105 but assuming that @{text x}, @{text y} and @{text z} are distinct variables, |
106 the second pair should \emph{not} be alpha-equivalent: |
106 the second pair should \emph{not} be alpha-equivalent: |
107 |
107 |
108 \begin{equation}\label{ex1} |
108 \begin{equation}\label{ex1} |
109 @{text "\<forall>{x, y}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm} |
109 @{text "\<forall>{x, y}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm} |
224 clause states that all the names the function @{text "bn(as)"} returns |
224 clause states that all the names the function @{text "bn(as)"} returns |
225 should be bound in @{text s}. This style of specifying terms and bindings |
225 should be bound in @{text s}. This style of specifying terms and bindings |
226 is heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. Our work |
226 is heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. Our work |
227 extends Ott in several aspects: one is that we support three binding |
227 extends Ott in several aspects: one is that we support three binding |
228 modes---Ott has only one, namely the one where the order of binders matters. |
228 modes---Ott has only one, namely the one where the order of binders matters. |
229 Another is that our reasoning infrastructure, like the notion of support and |
229 Another is that our reasoning infrastructure, like strong induction principles |
230 strong induction principles, is derived from first principles within the |
230 and the notion of free variables, is derived from first principles within |
231 Isabelle/HOL theorem prover. |
231 the Isabelle/HOL theorem prover. |
232 |
232 |
233 However, we will not be able to cope with all specifications that are |
233 However, we will not be able to cope with all specifications that are |
234 allowed by Ott. One reason is that Ott lets the user specify ``empty'' types |
234 allowed by Ott. One reason is that Ott lets the user specify ``empty'' types |
235 like \mbox{@{text "t ::= t t | \<lambda>x. t"}} where no clause for variables is |
235 like \mbox{@{text "t ::= t t | \<lambda>x. t"}} where no clause for variables is |
236 given. Arguably, such specifications make some sense in the context of Coq's |
236 given. Arguably, such specifications make some sense in the context of Coq's |
359 The examples we have in mind where our reasoning infrastructure will be |
359 The examples we have in mind where our reasoning infrastructure will be |
360 helpful includes the term language of Core-Haskell (see |
360 helpful includes the term language of Core-Haskell (see |
361 Figure~\ref{corehas}). This term language involves patterns that have lists |
361 Figure~\ref{corehas}). This term language involves patterns that have lists |
362 of type-, coercion- and term-variables, all of which are bound in @{text |
362 of type-, coercion- and term-variables, all of which are bound in @{text |
363 "\<CASE>"}-expressions. In these patterns we do not know in advance how many |
363 "\<CASE>"}-expressions. In these patterns we do not know in advance how many |
364 variables need to be bound. Another example is the specification of SML, |
364 variables need to be bound. Another example is the algorithm W |
365 which includes includes bindings as in type-schemes.\medskip |
365 which includes multiple binders in type-schemes.\medskip |
366 |
366 |
367 \noindent |
367 \noindent |
368 {\bf Contributions:} We provide three new definitions for when terms |
368 {\bf Contributions:} We provide three new definitions for when terms |
369 involving general binders are alpha-equivalent. These definitions are |
369 involving general binders are alpha-equivalent. These definitions are |
370 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
370 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
430 \cite{HuffmanUrban10} (including proofs). We shall briefly review this work |
430 \cite{HuffmanUrban10} (including proofs). We shall briefly review this work |
431 to aid the description of what follows. |
431 to aid the description of what follows. |
432 |
432 |
433 Two central notions in the nominal logic work are sorted atoms and |
433 Two central notions in the nominal logic work are sorted atoms and |
434 sort-respecting permutations of atoms. We will use the letters @{text "a, |
434 sort-respecting permutations of atoms. We will use the letters @{text "a, |
435 b, c, \<dots>"} to stand for atoms and @{text "p, q, \<dots>"} to stand for |
435 b, c, \<dots>"} to stand for atoms and @{text "\<pi>, \<dots>"} to stand for |
436 permutations. The purpose of atoms is to represent variables, be they bound or free. |
436 permutations. The purpose of atoms is to represent variables, be they bound or free. |
437 The sorts of atoms can be used to represent different kinds of |
437 The sorts of atoms can be used to represent different kinds of |
438 variables, such as the term-, coercion- and type-variables in Core-Haskell. |
438 variables, such as the term-, coercion- and type-variables in Core-Haskell. |
439 It is assumed that there is an infinite supply of atoms for each |
439 It is assumed that there is an infinite supply of atoms for each |
440 sort. In the interest of brevity, we shall restrict ourselves |
440 sort. In the interest of brevity, we shall restrict ourselves |
445 two-place permutation operation written |
445 two-place permutation operation written |
446 @{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
446 @{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
447 where the generic type @{text "\<beta>"} is the type of the object |
447 where the generic type @{text "\<beta>"} is the type of the object |
448 over which the permutation |
448 over which the permutation |
449 acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
449 acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
450 the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, |
450 the composition of two permutations @{term "\<pi>\<^isub>1"} and @{term "\<pi>\<^isub>2"} as \mbox{@{term "\<pi>\<^isub>1 + \<pi>\<^isub>2"}}, |
451 and the inverse permutation of @{term p} as @{text "- p"}. The permutation |
451 and the inverse permutation of @{term "\<pi>"} as @{text "- \<pi>"}. The permutation |
452 operation is defined over the type-hierarchy \cite{HuffmanUrban10}; |
452 operation is defined over the type-hierarchy \cite{HuffmanUrban10}; |
453 for example permutations acting on products, lists, sets, functions and booleans are |
453 for example permutations acting on products, lists, sets, functions and booleans are |
454 given by: |
454 given by: |
455 |
455 |
456 \begin{equation}\label{permute} |
456 \begin{equation}\label{permute} |
457 \mbox{\begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}} |
457 \mbox{\begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}} |
458 \begin{tabular}{@ {}l@ {}} |
458 \begin{tabular}{@ {}l@ {}} |
459 @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm] |
459 @{thm permute_prod.simps[where p="\<pi>", no_vars, THEN eq_reflection]}\\[2mm] |
460 @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\ |
460 @{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
461 @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\ |
461 @{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
462 \end{tabular} & |
462 \end{tabular} & |
463 \begin{tabular}{@ {}l@ {}} |
463 \begin{tabular}{@ {}l@ {}} |
464 @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\ |
464 @{thm permute_set_eq[where p="\<pi>", no_vars, THEN eq_reflection]}\\ |
465 @{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\ |
465 @{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f (- \<pi> \<bullet> x))"}\\ |
466 @{thm permute_bool_def[no_vars, THEN eq_reflection]} |
466 @{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]} |
467 \end{tabular} |
467 \end{tabular} |
468 \end{tabular}} |
468 \end{tabular}} |
469 \end{equation} |
469 \end{equation}\smallskip |
470 |
470 |
471 \begin{center} |
|
472 \mbox{\begin{tabular}{@ {}c@ {\hspace{4mm}}c@ {\hspace{4mm}}c@ {}} |
|
473 \begin{tabular}{@ {}l@ {}} |
|
474 @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\ |
|
475 @{thm permute_bool_def[no_vars, THEN eq_reflection]} |
|
476 \end{tabular} & |
|
477 \begin{tabular}{@ {}l@ {}} |
|
478 @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\ |
|
479 @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\ |
|
480 \end{tabular} & |
|
481 \begin{tabular}{@ {}l@ {}} |
|
482 @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\ |
|
483 @{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\ |
|
484 \end{tabular} |
|
485 \end{tabular}} |
|
486 \end{center} |
|
487 |
|
488 \noindent |
471 \noindent |
489 Concrete permutations in Nominal Isabelle are built up from swappings, |
472 Concrete permutations in Nominal Isabelle are built up from swappings, |
490 written as \mbox{@{text "(a b)"}}, which are permutations that behave |
473 written as \mbox{@{text "(a b)"}}, which are permutations that behave |
491 as follows: |
474 as follows: |
492 |
475 |
493 \begin{center} |
476 \[ |
494 @{text "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
477 @{text "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
495 \end{center} |
478 \]\smallskip |
496 |
479 |
497 The most original aspect of the nominal logic work of Pitts is a general |
480 The most original aspect of the nominal logic work of Pitts is a general |
498 definition for the notion of the ``set of free variables of an object @{text |
481 definition for the notion of the ``set of free variables of an object @{text |
499 "x"}''. This notion, written @{term "supp x"}, is general in the sense that |
482 "x"}''. This notion, written @{term "supp x"}, is general in the sense that |
500 it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
483 it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
506 @{thm supp_def[no_vars, THEN eq_reflection]} |
489 @{thm supp_def[no_vars, THEN eq_reflection]} |
507 \end{equation} |
490 \end{equation} |
508 |
491 |
509 \noindent |
492 \noindent |
510 There is also the derived notion for when an atom @{text a} is \emph{fresh} |
493 There is also the derived notion for when an atom @{text a} is \emph{fresh} |
511 for an @{text x}, defined as @{thm fresh_def[no_vars]}. |
494 for an @{text x}, defined as |
|
495 |
|
496 \[ |
|
497 @{thm fresh_def[no_vars]} |
|
498 \]\smallskip |
|
499 |
|
500 \noindent |
512 We use for sets of atoms the abbreviation |
501 We use for sets of atoms the abbreviation |
513 @{thm (lhs) fresh_star_def[no_vars]}, defined as |
502 @{thm (lhs) fresh_star_def[no_vars]}, defined as |
514 @{thm (rhs) fresh_star_def[no_vars]}. |
503 @{thm (rhs) fresh_star_def[no_vars]}. |
515 A striking consequence of these definitions is that we can prove |
504 A striking consequence of these definitions is that we can prove |
516 without knowing anything about the structure of @{term x} that |
505 without knowing anything about the structure of @{term x} that |
517 swapping two fresh atoms, say @{text a} and @{text b}, leaves |
506 swapping two fresh atoms, say @{text a} and @{text b}, leaves |
518 @{text x} unchanged, namely if @{text "a \<FRESH> x"} and @{text "b \<FRESH> x"} |
507 @{text x} unchanged, namely |
519 then @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
|
520 |
508 |
521 \begin{prop}\label{swapfreshfresh} |
509 \begin{prop}\label{swapfreshfresh} |
522 @{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
510 If @{thm (prem 1) swap_fresh_fresh[no_vars]} and @{thm (prem 2) swap_fresh_fresh[no_vars]} |
|
511 then @{thm (concl) swap_fresh_fresh[no_vars]} |
523 \end{prop} |
512 \end{prop} |
524 |
513 |
525 While often the support of an object can be relatively easily |
514 While often the support of an object can be relatively easily |
526 described, for example for atoms, products, lists, function applications, |
515 described, for example for atoms, products, lists, function applications, |
527 booleans and permutations as follows |
516 booleans and permutations as follows |
528 |
517 |
529 \begin{center} |
518 \[\mbox{ |
530 \begin{tabular}{c@ {\hspace{10mm}}c} |
519 \begin{tabular}{c@ {\hspace{10mm}}c} |
531 \begin{tabular}{rcl} |
520 \begin{tabular}{rcl} |
532 @{term "supp a"} & $=$ & @{term "{a}"}\\ |
521 @{term "supp a"} & $=$ & @{term "{a}"}\\ |
533 @{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\ |
522 @{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\ |
534 @{term "supp []"} & $=$ & @{term "{}"}\\ |
523 @{term "supp []"} & $=$ & @{term "{}"}\\ |
536 \end{tabular} |
525 \end{tabular} |
537 & |
526 & |
538 \begin{tabular}{rcl} |
527 \begin{tabular}{rcl} |
539 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\ |
528 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\ |
540 @{term "supp b"} & $=$ & @{term "{}"}\\ |
529 @{term "supp b"} & $=$ & @{term "{}"}\\ |
541 @{term "supp p"} & $=$ & @{term "{a. p \<bullet> a \<noteq> a}"} |
530 @{term "supp \<pi>"} & $=$ & @{term "{a. \<pi> \<bullet> a \<noteq> a}"} |
542 \end{tabular} |
531 \end{tabular} |
543 \end{tabular} |
532 \end{tabular}} |
544 \end{center} |
533 \]\smallskip |
545 |
534 |
546 \noindent |
535 \noindent |
547 in some cases it can be difficult to characterise the support precisely, and |
536 in some cases it can be difficult to characterise the support precisely, and |
548 only an approximation can be established (as for functions above). |
537 only an approximation can be established (as for function applications |
549 |
538 above). Reasoning about such approximations can be simplified with the |
550 Reasoning about |
539 notion \emph{supports}, defined as follows: |
551 such approximations can be simplified with the notion \emph{supports}, defined |
|
552 as follows: |
|
553 |
540 |
554 \begin{defi} |
541 \begin{defi} |
555 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
542 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
556 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
543 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
557 \end{defi} |
544 \end{defi} |