78 many proofs. There are a two main design choices to be made. One is |
78 many proofs. There are a two main design choices to be made. One is |
79 how to represent sorted atoms. We opt here for a single unified atom |
79 how to represent sorted atoms. We opt here for a single unified atom |
80 type to represent atoms of different sorts. The other is how to |
80 type to represent atoms of different sorts. The other is how to |
81 present sort-respecting permutations. For them we use the standard |
81 present sort-respecting permutations. For them we use the standard |
82 technique of HOL-formalisations of introducing an appropriate |
82 technique of HOL-formalisations of introducing an appropriate |
83 substype of functions from atoms to atoms. |
83 subtype of functions from atoms to atoms. |
84 |
84 |
85 The nominal logic work has been the starting point for a number of proving |
85 The nominal logic work has been the starting point for a number of proving |
86 infrastructures, most notable by Norrish \cite{norrish04} in HOL4, by |
86 infrastructures, most notable by Norrish \cite{norrish04} in HOL4, by |
87 Aydemir et al \cite{AydemirBohannonWeirich07} in Coq and the work by Urban |
87 Aydemir et al \cite{AydemirBohannonWeirich07} in Coq and the work by Urban |
88 and Berghofer in Isabelle/HOL \cite{Urban08}. Its key attraction is a very |
88 and Berghofer in Isabelle/HOL \cite{Urban08}. Its key attraction is a very |
321 \noindent |
321 \noindent |
322 and verify the four simple properties |
322 and verify the four simple properties |
323 |
323 |
324 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
324 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
325 \begin{tabular}{@ {}l} |
325 \begin{tabular}{@ {}l} |
326 i)~~@{thm add_assoc[where a="\<pi>\<^isub>1" and b="\<pi>\<^isub>2" and c="\<pi>\<^isub>3"]}\\ |
326 i)~~@{thm add_assoc[where a="\<pi>\<^isub>1" and b="\<pi>\<^isub>2" and c="\<pi>\<^isub>3"]}\smallskip\\ |
327 ii)~~@{thm monoid_add_class.add_0_left[where a="\<pi>::perm"]} \hspace{9mm} |
327 ii)~~@{thm monoid_add_class.add_0_left[where a="\<pi>::perm"]} \hspace{9mm} |
328 iii)~~@{thm monoid_add_class.add_0_right[where a="\<pi>::perm"]} \hspace{9mm} |
328 iii)~~@{thm monoid_add_class.add_0_right[where a="\<pi>::perm"]} \hspace{9mm} |
329 iv)~~@{thm group_add_class.left_minus[where a="\<pi>::perm"]} |
329 iv)~~@{thm group_add_class.left_minus[where a="\<pi>::perm"]} |
330 \end{tabular}\hfill\numbered{grouplaws} |
330 \end{tabular}\hfill\numbered{grouplaws} |
331 \end{isabelle} |
331 \end{isabelle} |
355 @{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
355 @{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
356 \end{isabelle} |
356 \end{isabelle} |
357 |
357 |
358 \noindent |
358 \noindent |
359 whereby @{text "\<beta>"} is a generic type for the object @{text |
359 whereby @{text "\<beta>"} is a generic type for the object @{text |
360 x}.\footnote{We will use the standard notation @{text "((op \<bullet>) \<pi>) |
360 x}.\footnote{We will write @{text "((op \<bullet>) \<pi>) |
361 x"} for this operation in the few cases where we need to indicate |
361 x"} for this operation in the few cases where we need to indicate |
362 that it is a function applied with two arguments.} The definition |
362 that it is a function applied with two arguments.} The definition |
363 of this operation will be given by in terms of `induction' over this |
363 of this operation will be given by in terms of `induction' over this |
364 generic type. The type-class mechanism of Isabelle/HOL |
364 generic type. The type-class mechanism of Isabelle/HOL |
365 \cite{Wenzel04} allows us to give a definition for `base' types, |
365 \cite{Wenzel04} allows us to give a definition for `base' types, |
504 text {* |
504 text {* |
505 Two important notions in the nominal logic work are what Pitts calls |
505 Two important notions in the nominal logic work are what Pitts calls |
506 \emph{equivariance} and the \emph{equivariance principle}. These |
506 \emph{equivariance} and the \emph{equivariance principle}. These |
507 notions allows us to characterise how permutations act upon compound |
507 notions allows us to characterise how permutations act upon compound |
508 statements in HOL by analysing how these statements are constructed. |
508 statements in HOL by analysing how these statements are constructed. |
509 The notion of equivariance can defined as follows: |
509 The notion of equivariance means that an object is invariant under |
|
510 any permutations. This can be defined as follows: |
510 |
511 |
511 \begin{definition}[Equivariance]\label{equivariance} |
512 \begin{definition}[Equivariance]\label{equivariance} |
512 An object @{text "x"} of permutation type is \emph{equivariant} provided |
513 An object @{text "x"} of permutation type is \emph{equivariant} provided |
513 for all permutations @{text "\<pi>"}, \mbox{@{term "\<pi> \<bullet> x = x"}} holds. |
514 for all permutations @{text "\<pi>"}, \mbox{@{term "\<pi> \<bullet> x = x"}} holds. |
514 \end{definition} |
515 \end{definition} |
516 \noindent |
517 \noindent |
517 In what follows we will primarily be interested in the cases where |
518 In what follows we will primarily be interested in the cases where |
518 @{text x} is a constant, but of course there is no way in |
519 @{text x} is a constant, but of course there is no way in |
519 Isabelle/HOL to restrict this definition to just these cases. |
520 Isabelle/HOL to restrict this definition to just these cases. |
520 |
521 |
521 There are a number of equivalent formulations for the equivariance |
522 There are a number of equivalent formulations for equivariance. |
522 property. For example, assuming @{text f} is a function of permutation |
523 For example, assuming @{text f} is a function of permutation |
523 type @{text "\<alpha> \<Rightarrow> \<beta>"}, then equivariance of @{text f} can also be stated as |
524 type @{text "\<alpha> \<Rightarrow> \<beta>"}, then equivariance of @{text f} can also be stated as |
524 |
525 |
525 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
526 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
526 \begin{tabular}{@ {}l} |
527 \begin{tabular}{@ {}l} |
527 @{text "\<forall>\<pi> x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"} |
528 @{text "\<forall>\<pi> x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"} |
528 \end{tabular}\hfill\numbered{altequivariance} |
529 \end{tabular}\hfill\numbered{altequivariance} |
529 \end{isabelle} |
530 \end{isabelle} |
530 |
531 |
531 \noindent |
532 \noindent |
532 We will call this formulation of equivariance in \emph{fully applied form}. |
533 We will say this formulation of equivariance is in \emph{fully applied form}. |
533 To see that this formulation implies the definition, we just unfold |
534 To see that this formulation implies the definition, we just unfold |
534 the definition of the permutation operation for functions and |
535 the definition of the permutation operation for functions and |
535 simplify with the equation and the cancellation property shown in |
536 simplify with the equation and the cancellation property shown in |
536 \eqref{cancel}. To see the other direction, we use |
537 \eqref{cancel}. To see the other direction, we use |
537 \eqref{permutefunapp}. Similarly for functions that take more than |
538 \eqref{permutefunapp}. Similarly for functions that take more than |
600 where @{text c} stands for constants and @{text x} for variables. |
601 where @{text c} stands for constants and @{text x} for variables. |
601 We assume HOL-terms are fully typed, but for the sake of better |
602 We assume HOL-terms are fully typed, but for the sake of better |
602 legibility we leave the typing information implicit. We also assume |
603 legibility we leave the typing information implicit. We also assume |
603 the usual notions for free and bound variables of a HOL-term. |
604 the usual notions for free and bound variables of a HOL-term. |
604 Furthermore, HOL-terms are regarded as equal modulo alpha-, beta- |
605 Furthermore, HOL-terms are regarded as equal modulo alpha-, beta- |
605 and eta-equivalence. The equivariance principle can now be stated |
606 and eta-equivalence. The equivariance principle can now |
606 formally as follows: |
607 be stated formally as follows: |
607 |
608 |
608 \begin{theorem}[Equivariance Principle]\label{eqvtprin} |
609 \begin{theorem}[Equivariance Principle]\label{eqvtprin} |
609 Suppose a HOL-term @{text t} whose constants are all equivariant. For any |
610 Suppose a HOL-term @{text t} whose constants are all equivariant. For any |
610 permutation @{text \<pi>}, let @{text t'} be @{text t} except every |
611 permutation @{text \<pi>}, let @{text t'} be @{text t} except every |
611 free variable @{text x} in @{term t} is replaced by @{text "\<pi> \<bullet> x"}, then |
612 free variable @{text x} in @{term t} is replaced by @{text "\<pi> \<bullet> x"}, then |
613 \end{theorem} |
614 \end{theorem} |
614 |
615 |
615 \noindent |
616 \noindent |
616 The significance of this principle is that we can automatically establish |
617 The significance of this principle is that we can automatically establish |
617 the equivariance of a constant for which equivariance is not yet |
618 the equivariance of a constant for which equivariance is not yet |
618 known. For this we only have to make sure that the definiens of this |
619 known. For this we only have to establish that the definiens of this |
619 constant is a HOL-term whose constants are all equivariant. For example |
620 constant is a HOL-term whose constants are all equivariant. |
620 the universal quantifier @{text "\<forall>"} is definied in HOL as |
621 This meshes well with how HOL is designed: except for a few axioms, every constant |
|
622 is defined in terms of existing constants. For example an alternative way |
|
623 to deduce that @{term True} is equivariant is to look at its |
|
624 definition |
|
625 |
|
626 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
627 @{thm True_def} |
|
628 \end{isabelle} |
|
629 |
|
630 \noindent |
|
631 and observing that the only constant in the definiens, namely @{text "="}, is |
|
632 equivariant. Similarly, the universal quantifier @{text "\<forall>"} is definied in HOL as |
621 |
633 |
622 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
634 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
623 @{text "\<forall>x. P x \<equiv> "}~@{thm (rhs) All_def[no_vars]} |
635 @{text "\<forall>x. P x \<equiv> "}~@{thm (rhs) All_def[no_vars]} |
624 \end{isabelle} |
636 \end{isabelle} |
625 |
637 |
627 The constants in the definiens @{thm (rhs) All_def[no_vars]}, namely @{text "="} |
639 The constants in the definiens @{thm (rhs) All_def[no_vars]}, namely @{text "="} |
628 and @{text "True"}, are equivariant (we shown this above). Therefore |
640 and @{text "True"}, are equivariant (we shown this above). Therefore |
629 the equivariance principle gives us |
641 the equivariance principle gives us |
630 |
642 |
631 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
643 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
632 @{text "\<pi> \<bullet> (\<forall>x. P x) \<equiv> \<pi> \<bullet> (P = (\<lambda>x. True)) = ((\<pi> \<bullet> P) = (\<lambda>x. True)) \<equiv> \<forall>x. (\<pi> \<bullet> P) x"} |
644 \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
645 @{text "\<pi> \<bullet> (\<forall>x. P x)"} & @{text "\<equiv>"} & @{text "\<pi> \<bullet> (P = (\<lambda>x. True))"}\\ |
|
646 & @{text "="} & @{text "(\<pi> \<bullet> P) = (\<lambda>x. True)"}\\ |
|
647 & @{text "\<equiv>"} & @{text "\<forall>x. (\<pi> \<bullet> P) x"} |
|
648 \end{tabular} |
633 \end{isabelle} |
649 \end{isabelle} |
634 |
650 |
635 \noindent |
651 \noindent |
636 which means the constant @{text "\<forall>"} must be equivariant. From this |
652 which means the constant @{text "\<forall>"} must be equivariant. From this |
637 we can deduce that the existential quantifier @{text "\<exists>"} is equivariant. |
653 we can deduce that the existential quantifier @{text "\<exists>"} is equivariant. |
651 @{text "\<exists>!x. P x \<equiv> "}~@{thm (rhs) Ex1_def[no_vars]} |
667 @{text "\<exists>!x. P x \<equiv> "}~@{thm (rhs) Ex1_def[no_vars]} |
652 \end{isabelle} |
668 \end{isabelle} |
653 |
669 |
654 \noindent |
670 \noindent |
655 with all constants on the right-hand side being equivariant. With this kind |
671 with all constants on the right-hand side being equivariant. With this kind |
656 of reasoning we can build up a database of equivariant constants. |
672 of reasoning we can build up a database of equivariant constants, which will |
|
673 be handy for more complex calculations later on. |
657 |
674 |
658 Before we proceed, let us give a justification for the equivariance principle. |
675 Before we proceed, let us give a justification for the equivariance principle. |
659 This justification cannot be given directly inside Isabelle/HOL since we cannot |
676 This justification cannot be given directly inside Isabelle/HOL since we cannot |
660 prove any statement about HOL-terms. Instead, we will use a rewrite |
677 prove any statement about HOL-terms. Instead, we will use a rewrite |
661 system consisting of a series of equalities |
678 system consisting of a series of equalities |
668 that establish the equality between @{term "\<pi> \<bullet> t"} and |
685 that establish the equality between @{term "\<pi> \<bullet> t"} and |
669 @{text "t'"}. The idea of the rewrite system is to push the |
686 @{text "t'"}. The idea of the rewrite system is to push the |
670 permutation inside the term @{text t}. We have implemented this as a |
687 permutation inside the term @{text t}. We have implemented this as a |
671 conversion tactic on the ML-level of Isabelle/HOL. In what follows, |
688 conversion tactic on the ML-level of Isabelle/HOL. In what follows, |
672 we will show that this tactic produces only finitely many equations |
689 we will show that this tactic produces only finitely many equations |
673 and also show that is correct (in the sense of pushing a permutation |
690 and also show that it is correct (in the sense of pushing a permutation |
674 @{text "\<pi>"} inside a term and the only remaining instances of @{text |
691 @{text "\<pi>"} inside a term and the only remaining instances of @{text |
675 "\<pi>"} are in front of the term's free variables). The tactic applies |
692 "\<pi>"} are in front of the term's free variables). |
676 four `oriented' equations. We will first give a naive version of |
693 |
677 this tactic, which however in some cornercases produces incorrect |
694 The tactic applies four `oriented' equations. |
|
695 We will first give a naive version of |
|
696 our tactic, which however in some corner cases produces incorrect |
678 results or does not terminate. We then give a modification in order |
697 results or does not terminate. We then give a modification in order |
679 to obtain the desired properties. |
698 to obtain the desired properties. |
680 |
|
681 Consider the following for oriented equations |
699 Consider the following for oriented equations |
682 |
700 |
683 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
701 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
684 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
702 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
685 i) & @{text "\<pi> \<bullet> (t\<^isub>1 t\<^isub>2)"} & \rrh & @{term "(\<pi> \<bullet> t\<^isub>1) (\<pi> \<bullet> t\<^isub>2)"}\\ |
703 i) & @{text "\<pi> \<bullet> (t\<^isub>1 t\<^isub>2)"} & \rrh & @{term "(\<pi> \<bullet> t\<^isub>1) (\<pi> \<bullet> t\<^isub>2)"}\\ |
695 direction. The first equation we established in \eqref{permutefunapp}; |
713 direction. The first equation we established in \eqref{permutefunapp}; |
696 the second follows from the definition of permutations acting on functions |
714 the second follows from the definition of permutations acting on functions |
697 and the fact that HOL-terms are equal modulo beta-equivalence. |
715 and the fact that HOL-terms are equal modulo beta-equivalence. |
698 The third is a consequence of \eqref{cancel} and the fourth from |
716 The third is a consequence of \eqref{cancel} and the fourth from |
699 Definition~\ref{equivariance}. Unfortunately, we have to be careful with |
717 Definition~\ref{equivariance}. Unfortunately, we have to be careful with |
700 the rules {\it i)} and {\it iv}) since they can lead to a loop whenever |
718 the rules {\it i)} and {\it iv}) since they can lead to loops whenever |
701 \mbox{@{text "t\<^isub>1 t\<^isub>2"}} is of the form @{text "((op \<bullet>) \<pi>') t"}.\footnote{Note we |
719 \mbox{@{text "t\<^isub>1 t\<^isub>2"}} is of the form @{text "((op \<bullet>) \<pi>') t"}. |
702 deviate here from our usual convention of writing the permutation operation infix, |
720 Recall that we established in Lemma \ref{permutecompose} that the |
703 instead as an application.} Recall that we established in Lemma \ref{permutecompose} that the |
|
704 constant @{text "(op \<bullet>)"} is equivariant and consider the infinite |
721 constant @{text "(op \<bullet>)"} is equivariant and consider the infinite |
705 reduction sequence |
722 reduction sequence |
706 |
723 |
707 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
724 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
708 \begin{tabular}{@ {}l} |
725 \begin{tabular}{@ {}l} |
714 |
731 |
715 \end{tabular} |
732 \end{tabular} |
716 \end{isabelle} |
733 \end{isabelle} |
717 |
734 |
718 \noindent |
735 \noindent |
719 where the last term is again an instance of rewrite rule {\it i}), but bigger. |
736 where the last term is again an instance of rewrite rule {\it i}), but larger. |
720 To avoid this loop we will apply the rewrite rule |
737 To avoid this loop we will apply the rewrite rule |
721 using an `outside to inside' strategy. This strategy is sufficient |
738 using an `outside to inside' strategy. This strategy is sufficient |
722 since we are only interested of rewriting terms of the form @{term |
739 since we are only interested of rewriting terms of the form @{term |
723 "\<pi> \<bullet> t"}, where an outermost permutation needs to pushed inside a term. |
740 "\<pi> \<bullet> t"}, where an outermost permutation needs to pushed inside a term. |
724 |
741 |
725 Another problem we have to avoid is that the rules {\it i)} and {\it |
742 Another problem we have to avoid is that the rules {\it i)} and {\it |
726 iii)} can `overlap'. For this note that the term @{term "\<pi> |
743 iii)} can `overlap'. For this note that the term @{term "\<pi> |
727 \<bullet>(\<lambda>x. x)"} reduces by {\it ii)} to @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet> x"}, to |
744 \<bullet>(\<lambda>x. x)"} reduces by {\it ii)} to @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet> x"}, to |
728 which we can apply rule {\it iii)} in order to obtain @{term |
745 which we can apply rule {\it iii)} in order to obtain @{term |
729 "\<lambda>x. x"}, as is desired---since there is no free variable in the original |
746 "\<lambda>x. x"}, as is desired: since there is no free variable in the original |
730 term. the permutation should completely vanish. However, the |
747 term, the permutation should completely vanish. However, the |
731 subterm @{text "(- \<pi>) \<bullet> x"} is also an application. Consequently, |
748 subterm @{text "(- \<pi>) \<bullet> x"} is also an application. Consequently, |
732 the term @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet>x"} can also reduce to @{text "\<lambda>x. (- (\<pi> |
749 the term @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet>x"} can also reduce to @{text "\<lambda>x. (- (\<pi> |
733 \<bullet> \<pi>)) \<bullet> (\<pi> \<bullet> x)"} using {\it i)}. Given our strategy, we cannot |
750 \<bullet> \<pi>)) \<bullet> (\<pi> \<bullet> x)"} using {\it i)}. Given our strategy, we cannot |
734 apply rule {\it iii)} anymore in order to eliminate the permutation. |
751 apply rule {\it iii)} anymore in order to eliminate the permutation. |
735 In contrast, if we start |
752 In contrast, if we start |
1220 text {* |
1237 text {* |
1221 While the use of functions as permutation provides us with a unique |
1238 While the use of functions as permutation provides us with a unique |
1222 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
1239 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
1223 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation does |
1240 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation does |
1224 not come automatically with an induction principle. Such an |
1241 not come automatically with an induction principle. Such an |
1225 induction principle is however handy for generalising |
1242 induction principle is however useful for generalising |
1226 Lemma~\ref{swapfreshfresh} from swappings to permutations |
1243 Lemma~\ref{swapfreshfresh} from swappings to permutations, namely |
1227 |
1244 |
1228 \begin{lemma} |
1245 \begin{lemma} |
1229 @{thm [mode=IfThen] perm_supp_eq[no_vars]} |
1246 @{thm [mode=IfThen] perm_supp_eq[where p="\<pi>", no_vars]} |
1230 \end{lemma} |
1247 \end{lemma} |
1231 |
1248 |
1232 \noindent |
1249 \noindent |
1233 In this section we will establish an induction principle for permutations |
1250 In this section we will establish an induction principle for permutations |
1234 with which this lemma can be easily proved. It is not too difficult to derive |
1251 with which this lemma can be easily proved. It is not too difficult to derive |
1236 permutations having a finite support. |
1253 permutations having a finite support. |
1237 |
1254 |
1238 Using a the property from \cite{???} |
1255 Using a the property from \cite{???} |
1239 |
1256 |
1240 \begin{lemma}\label{smallersupp} |
1257 \begin{lemma}\label{smallersupp} |
1241 @{thm [mode=IfThen] smaller_supp[no_vars]} |
1258 @{thm [mode=IfThen] smaller_supp[where p="\<pi>", no_vars]} |
1242 \end{lemma} |
1259 \end{lemma} |
1243 *} |
1260 *} |
1244 |
1261 |
1245 |
1262 |
1246 section {* An Abstraction Type *} |
1263 section {* An Abstraction Type *} |