442 @{thm (rhs) permute_fun_app_eq[where p="\<pi>", no_vars]} |
450 @{thm (rhs) permute_fun_app_eq[where p="\<pi>", no_vars]} |
443 \hfill\numbered{permutefunapp} |
451 \hfill\numbered{permutefunapp} |
444 \end{isabelle} |
452 \end{isabelle} |
445 |
453 |
446 \noindent |
454 \noindent |
447 whenever the permutation properties hold for @{text x}. This equation can |
455 provided the permutation properties hold for @{text x}. This equation can |
448 be easily shown by unfolding the permutation operation for functions on |
456 be easily shown by unfolding the permutation operation for functions on |
449 the right-hand side, simplifying the beta-redex and eliminating the permutations |
457 the right-hand side of the equation, simplifying the resulting beta-redex |
450 in front of @{text x} using \eqref{cancel}. |
458 and eliminating the permutations in front of @{text x} using \eqref{cancel}. |
451 |
459 |
452 The main benefit of the use of type classes is that it allows us to delegate |
460 The main benefit of the use of type classes is that it allows us to delegate |
453 much of the routine resoning involved in determining whether the permutation properties |
461 much of the routine resoning involved in determining whether the permutation properties |
454 are satisfied to Isabelle/HOL's type system: we only have to |
462 are satisfied to Isabelle/HOL's type system: we only have to |
455 establish that base types satisfy them and that type-constructors |
463 establish that base types satisfy them and that type-constructors |
456 preserve them. Isabelle/HOL will use this information and determine |
464 preserve them. Then Isabelle/HOL will use this information and determine |
457 whether an object @{text x} with a compound type, like @{typ "atom \<Rightarrow> (atom set * nat)"}, satisfies the |
465 whether an object @{text x} with a compound type, like @{typ "atom \<Rightarrow> (atom set * nat)"}, satisfies the |
458 permutation properties. For this we define the notion of a |
466 permutation properties. For this we define the notion of a |
459 \emph{permutation type}: |
467 \emph{permutation type}: |
460 |
468 |
461 \begin{definition}[Permutation type] |
469 \begin{definition}[Permutation Type] |
462 A type @{text "\<beta>"} is a \emph{permutation type} if the permutation |
470 A type @{text "\<beta>"} is a \emph{permutation type} if the permutation |
463 properties in \eqref{newpermprops} are satisfied for every @{text |
471 properties in \eqref{newpermprops} are satisfied for every @{text |
464 "x"} of type @{text "\<beta>"}. |
472 "x"} of type @{text "\<beta>"}. |
465 \end{definition} |
473 \end{definition} |
466 |
474 |
492 *} |
500 *} |
493 |
501 |
494 section {* Equivariance *} |
502 section {* Equivariance *} |
495 |
503 |
496 text {* |
504 text {* |
497 An important notion in the nominal logic work is |
505 Two important notions in the nominal logic work are what Pitts calls |
498 \emph{equivariance}. This notion allows us to characterise how |
506 \emph{equivariance} and the \emph{equivariance principle}. These |
499 permutations act upon compound statements in HOL by analysing how |
507 notions allows us to characterise how permutations act upon compound |
500 these statements are constructed. To do so, let us first define |
508 statements in HOL by analysing how these statements are constructed. |
501 \emph{HOL-terms}. They are given by the grammar |
509 The notion of equivariance can defined as follows: |
502 |
|
503 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
504 @{text "t ::= c | x | t\<^isub>1 t\<^isub>2 | \<lambda>x. t"} |
|
505 \hfill\numbered{holterms} |
|
506 \end{isabelle} |
|
507 |
|
508 \noindent |
|
509 where @{text c} stands for constants and @{text x} for variables. |
|
510 We assume HOL-terms are fully typed, but for the sake of greater |
|
511 legibility we leave the typing information implicit. We also assume |
|
512 the usual notions for free and bound variables of a HOL-term. |
|
513 Furthermore, HOL-terms are regarded as equal modulo alpha-, beta- |
|
514 and eta-equivalence. Statements in HOL are HOL-terms of type @{text |
|
515 "bool"}. |
|
516 |
|
517 An \emph{equivariant} HOL-term is one that is invariant under the |
|
518 permutation operation. This can be defined in Isabelle/HOL |
|
519 as follows: |
|
520 |
510 |
521 \begin{definition}[Equivariance]\label{equivariance} |
511 \begin{definition}[Equivariance]\label{equivariance} |
522 A HOL-term @{text t} is \emph{equivariant} provided |
512 An object @{text "x"} of permutation type is \emph{equivariant} provided |
523 @{term "\<pi> \<bullet> t = t"} holds for all permutations @{text "\<pi>"}. |
513 for all permutations @{text "\<pi>"}, \mbox{@{term "\<pi> \<bullet> x = x"}} holds. |
524 \end{definition} |
514 \end{definition} |
525 |
515 |
526 \noindent |
516 \noindent |
527 In what follows we will primarily be interested in the cases where @{text t} |
517 In what follows we will primarily be interested in the cases where |
528 is a constant, but of course there is no way in Isabelle/HOL to restrict |
518 @{text x} is a constant, but of course there is no way in |
529 this definition to just these cases. |
519 Isabelle/HOL to restrict this definition to just these cases. |
530 |
520 |
531 There are a number of equivalent formulations for the equivariance |
521 There are a number of equivalent formulations for the equivariance |
532 property. For example, assuming @{text t} is of permutation type @{text "\<alpha> \<Rightarrow> |
522 property. For example, assuming @{text f} is a function of permutation |
533 \<beta>"}, then equivariance can also be stated as |
523 type @{text "\<alpha> \<Rightarrow> \<beta>"}, then equivariance can also be stated as |
534 |
524 |
535 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
525 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
536 \begin{tabular}{@ {}l} |
526 \begin{tabular}{@ {}l} |
537 @{text "\<forall>\<pi> x. \<pi> \<bullet> (t x) = t (\<pi> \<bullet> x)"} |
527 @{text "\<forall>\<pi> x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"} |
538 \end{tabular}\hfill\numbered{altequivariance} |
528 \end{tabular}\hfill\numbered{altequivariance} |
539 \end{isabelle} |
529 \end{isabelle} |
540 |
530 |
541 \noindent |
531 \noindent |
542 We will call this formulation of equivariance in \emph{fully applied form}. |
532 We will call this formulation of equivariance in \emph{fully applied form}. |
543 To see that this formulation implies the definition, we just unfold |
533 To see that this formulation implies the definition, we just unfold |
544 the definition of the permutation operation for functions and |
534 the definition of the permutation operation for functions and |
545 simplify with the equation and the cancellation property shown in |
535 simplify with the equation and the cancellation property shown in |
546 \eqref{cancel}. To see the other direction, we use |
536 \eqref{cancel}. To see the other direction, we use |
547 \eqref{permutefunapp}. Similarly for HOL-terms that take more than |
537 \eqref{permutefunapp}. Similarly for functions that take more than |
548 one argument. The point to note is that equivariance and equivariance in fully |
538 one argument. The point to note is that equivariance and equivariance in fully |
549 applied form are always interderivable (for permutation types). |
539 applied form are always interderivable (for permutation types). |
550 |
540 |
551 Both formulations of equivariance have their advantages and |
541 Both formulations of equivariance have their advantages and |
552 disadvantages: \eqref{altequivariance} is usually more convenient to |
542 disadvantages: \eqref{altequivariance} is usually more convenient to |
591 @{text "\<pi> \<bullet> (\<not>A) = \<not>(\<pi> \<bullet> A)"}\\ |
581 @{text "\<pi> \<bullet> (\<not>A) = \<not>(\<pi> \<bullet> A)"}\\ |
592 \end{tabular} |
582 \end{tabular} |
593 \end{isabelle} |
583 \end{isabelle} |
594 |
584 |
595 In contrast, the advantage of Definition \ref{equivariance} is that |
585 In contrast, the advantage of Definition \ref{equivariance} is that |
596 it leads to rewrite system that allows us to |
586 it allows us to state a general principle how permutations act on |
597 `push' a permutation towards the leaves of a HOL-term |
587 statements in HOL. For this we will define a rewrite system that |
598 (i.e.~constants and variables). Then the permutation disappears in |
588 `pushes' a permutation towards the leaves of statements (i.e.~constants |
599 cases where the constants are equivariant. This can be stated more |
589 and variables). Then the permutations disappear in cases where the |
600 formally as the following \emph{equivariance principle}: |
590 constants are equivariant. To do so, let us first define |
|
591 \emph{HOL-terms}, which are the building blocks of statements in HOL. |
|
592 They are given by the grammar |
|
593 |
|
594 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
595 @{text "t ::= c | x | t\<^isub>1 t\<^isub>2 | \<lambda>x. t"} |
|
596 \hfill\numbered{holterms} |
|
597 \end{isabelle} |
|
598 |
|
599 \noindent |
|
600 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 legibility we leave the typing information implicit. We also assume |
|
603 the usual notions for free and bound variables of a HOL-term. |
|
604 Furthermore, HOL-terms are regarded as equal modulo alpha-, beta- |
|
605 and eta-equivalence. The equivariance principle can now be stated |
|
606 formally as follows: |
601 |
607 |
602 \begin{theorem}[Equivariance Principle]\label{eqvtprin} |
608 \begin{theorem}[Equivariance Principle]\label{eqvtprin} |
603 Suppose a HOL-term @{text t} whose constants are all equivariant. For any |
609 Suppose a HOL-term @{text t} whose constants are all equivariant. For any |
604 permutation @{text \<pi>}, let @{text t'} be the HOL-term @{text t} except every |
610 permutation @{text \<pi>}, let @{text t'} be @{text t} except every |
605 free variable @{text x} in @{term t} is replaced by @{text "\<pi> \<bullet> x"}, then |
611 free variable @{text x} in @{term t} is replaced by @{text "\<pi> \<bullet> x"}, then |
606 @{text "\<pi> \<bullet> t = t'"}. |
612 @{text "\<pi> \<bullet> t = t'"}. |
607 \end{theorem} |
613 \end{theorem} |
608 |
614 |
609 \noindent |
615 \noindent |
610 The significance of this principle is that we can automatically establish |
616 The significance of this principle is that we can automatically establish |
611 the equivariance of a constant for which equivariance is not yet |
617 the equivariance of a constant for which equivariance is not yet |
612 known. For this we only have to make sure that the definiens of this |
618 known. For this we only have to make sure that the definiens of this |
613 constant is a HOL-term whose constants are all equivariant. For example |
619 constant is a HOL-term whose constants are all equivariant. For example |
614 the universal quantifier @{text "All"}, also written @{text "\<forall>"}, is |
620 the universal quantifier @{text "\<forall>"} is definied in HOL as |
615 of type @{text "(\<alpha> \<Rightarrow> bool) \<Rightarrow> bool"} and in HOL is definied as |
621 |
616 |
622 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
617 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
623 @{text "\<forall>x. P x \<equiv> "}~@{thm (rhs) All_def[no_vars]} |
618 @{thm All_def[no_vars]} |
|
619 \end{isabelle} |
624 \end{isabelle} |
620 |
625 |
621 \noindent |
626 \noindent |
622 Now @{text All} must be equivariant, because by the equivariance |
627 The constants in the definiens @{thm (rhs) All_def[no_vars]}, namely @{text "="} |
623 principle we only have to test whether the contants in the HOL-term |
628 and @{text "True"}, are equivariant (we shown this above). Therefore |
624 @{thm (rhs) All_def[no_vars]}, namely @{text "="} and @{text |
629 the equivariance principle gives us |
625 "True"}, are equivariant. We shown this above. Taking all equations |
630 |
626 together, we can establish |
631 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
627 |
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"} |
628 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
629 @{text "\<pi> \<bullet> (All P) \<equiv> \<pi> \<bullet> (P = (\<lambda>x. True)) = ((\<pi> \<bullet> P) = (\<lambda>x. True)) \<equiv> All (\<pi> \<bullet> P)"} |
|
630 \end{isabelle} |
633 \end{isabelle} |
631 |
634 |
632 \noindent |
635 \noindent |
633 where the equation in the `middle' is given by Theorem~\ref{eqvtprin}. |
636 and consequently, the constant @{text "\<forall>"} must be equivariant. From this |
634 As a consequence, the constant @{text "All"} is equivariant. Given this |
637 we can deduce that the existential quantifier @{text "\<exists>"} is equivariant. |
635 fact we can further show that the existential quantifier @{text Ex}, |
638 Its definition in HOL is |
636 written also as @{text "\<exists>"}, is equivariant, since it is defined as |
639 |
637 |
640 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
638 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
641 @{text "\<exists>x. P x \<equiv> "}~@{thm (rhs) Ex_def[no_vars]} |
639 @{thm Ex_def[no_vars]} |
|
640 \end{isabelle} |
642 \end{isabelle} |
641 |
643 |
642 \noindent |
644 \noindent |
643 and the HOL-term on the right-hand side contains equivariant constants only |
645 where again the HOL-term on the right-hand side only contains equivariant constants |
644 (namely @{text "\<forall>"} and @{text "\<longrightarrow>"}). In this way we can establish step by step |
646 (namely @{text "\<forall>"} and @{text "\<longrightarrow>"}). Taking both facts together, we can deduce that |
645 equivariance for constants in HOL. |
647 the unique existential quantifier @{text "\<exists>!"} is equivariant. Its definition |
646 |
648 is |
647 In order to establish Theorem~\ref{eqvtprin}, we use a rewrite system |
649 |
648 consisting of a series of equalities |
650 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
649 |
651 @{text "\<exists>!x. P x \<equiv> "}~@{thm (rhs) Ex1_def[no_vars]} |
650 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
652 \end{isabelle} |
651 @{text "\<pi> \<cdot> t = ... = t'"} |
653 |
652 \end{isabelle} |
654 \noindent |
653 |
655 with all constants on the right-hand side being equivariant. With this kind |
654 \noindent |
656 of reasoning we can build up a database of equivariant constants. |
655 that establish the equality between @{term "\<pi> \<bullet> t"} and @{text |
657 |
656 "t'"}. We have implemented this rewrite system as a conversion |
658 Before we proceed, let us give a justification for the equivariance principle. |
657 tactic on the ML-level of Isabelle/HOL. |
659 For this we will use a rewrite system consisting of a series of equalities |
658 We shall next specify this tactic and show that it terminates and is |
660 |
659 correct (in the sense of pushing a permutation @{text "\<pi>"} inside a |
661 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
660 term and the only remaining instances of @{text "\<pi>"} are in front of |
662 @{text "\<pi> \<cdot> t = ... = t'"} |
661 the term's free variables). The tactic applies four `oriented' |
663 \end{isabelle} |
662 equations. We will first give a naive version of this tactic, which |
664 |
663 however in some cornercases produces incorrect resolts or does not |
665 \noindent |
664 terminate. We then give a modification it in order to obtain the |
666 that establish the equality between @{term "\<pi> \<bullet> t"} and |
665 desired properties. A permutation @{text \<pi>} can be pushed into |
667 @{text "t'"}. The idea of the rewrite system is to push the |
666 applications and abstractions as follows |
668 permutation inside the term @{text t}. We have implemented this as a |
667 |
669 conversion tactic on the ML-level of Isabelle/HOL. In what follows, |
|
670 we will show that this tactic produces only finitely many equations |
|
671 and also show that is correct (in the sense of pushing a permutation |
|
672 @{text "\<pi>"} inside a term and the only remaining instances of @{text |
|
673 "\<pi>"} are in front of the term's free variables). The tactic applies |
|
674 four `oriented' equations. We will first give a naive version of |
|
675 this tactic, which however in some cornercases produces incorrect |
|
676 results or does not terminate. We then give a modification in order |
|
677 to obtain the desired properties. |
|
678 |
|
679 Consider the following oriented equations |
|
680 |
668 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
681 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
669 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
682 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
670 i) & @{text "\<pi> \<bullet> (t\<^isub>1 t\<^isub>2)"} & \rrh & @{term "(\<pi> \<bullet> t\<^isub>1) (\<pi> \<bullet> t\<^isub>2)"}\\ |
683 i) & @{text "\<pi> \<bullet> (t\<^isub>1 t\<^isub>2)"} & \rrh & @{term "(\<pi> \<bullet> t\<^isub>1) (\<pi> \<bullet> t\<^isub>2)"}\\ |
671 ii) & @{text "\<pi> \<bullet> (\<lambda>x. t)"} & \rrh & @{text "\<lambda>x. \<pi> \<bullet> (t[x := (-\<pi>) \<bullet> x])"}\\ |
684 ii) & @{text "\<pi> \<bullet> (\<lambda>x. t)"} & \rrh & @{text "\<lambda>x. \<pi> \<bullet> (t[x := (-\<pi>) \<bullet> x])"}\\ |
|
685 iii) & @{term "\<pi> \<bullet> (- \<pi>) \<bullet> x"} & \rrh & @{term "x"}\\ |
|
686 iv) & @{term "\<pi> \<bullet> c"} & \rrh & |
|
687 {\rm @{term "c"}\hspace{6mm}provided @{text c} is equivariant}\\ |
672 \end{tabular}\hfill\numbered{rewriteapplam} |
688 \end{tabular}\hfill\numbered{rewriteapplam} |
673 \end{isabelle} |
689 \end{isabelle} |
674 |
690 |
675 \noindent |
691 \noindent |
|
692 A permutation @{text \<pi>} can be pushed into applications and abstractions as follows |
|
693 |
676 The first equation we established in \eqref{permutefunapp}; |
694 The first equation we established in \eqref{permutefunapp}; |
677 the second follows from the definition of permutations acting on functions |
695 the second follows from the definition of permutations acting on functions |
678 and the fact that HOL-terms are equal modulo beta-equivalence. |
696 and the fact that HOL-terms are equal modulo beta-equivalence. |
679 Once the permutations are pushed towards the leaves we need the |
697 Once the permutations are pushed towards the leaves, we need the |
680 following two equations |
698 following two equations |
681 |
699 |
682 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
700 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
683 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
701 \begin{tabular}{@ {}lr@ {\hspace{3mm}}c@ {\hspace{3mm}}l} |
684 iii) & @{term "\<pi> \<bullet> (- \<pi>) \<bullet> x"} & \rrh & @{term "x"}\\ |
702 |
685 iv) & @{term "\<pi> \<bullet> c"} & \rrh & |
|
686 {\rm @{term "c"}\hspace{6mm}provided @{text c} is equivariant}\\ |
|
687 \end{tabular}\hfill\numbered{rewriteother} |
703 \end{tabular}\hfill\numbered{rewriteother} |
688 \end{isabelle} |
704 \end{isabelle} |
689 |
705 |
690 \noindent |
706 \noindent |
691 in order to remove permuations in front of bound variables and |
707 in order to remove permuations in front of bound variables and |
692 equivariant constants. Unfortunately, we have to be careful with |
708 equivariant constants. Unfortunately, we have to be careful with |
693 the rules {\it i)} and {\it iv}): they can lead to a loop whenever |
709 the rules {\it i)} and {\it iv}): they can lead to a loop whenever |
694 \mbox{@{text "t\<^isub>1 t\<^isub>2"}} is of the form @{text "((op \<bullet>) \<pi>') t"}. Note |
710 \mbox{@{text "t\<^isub>1 t\<^isub>2"}} is of the form @{text "((op \<bullet>) \<pi>') t"}, where |
695 that we usually write this application using infix notation as |
711 we do not write the permutation operation infix, as usual, but |
696 @{text "\<pi> \<bullet> t"} and recall that by Lemma \ref{permutecompose} the |
712 as an application. Recall that we established in Lemma \ref{permutecompose} that the |
697 constant @{text "(op \<bullet>)"} is equivariant. Now consider the infinite |
713 constant @{text "(op \<bullet>)"} is equivariant and consider the infinite |
698 reduction sequence |
714 reduction sequence |
699 |
715 |
700 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
716 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
701 \begin{tabular}{@ {}l} |
717 \begin{tabular}{@ {}l} |
702 @{text "\<pi> \<bullet> (\<pi>' \<bullet> t)"} |
718 @{text "\<pi> \<bullet> (\<pi>' \<bullet> t)"} |
707 |
723 |
708 \end{tabular} |
724 \end{tabular} |
709 \end{isabelle} |
725 \end{isabelle} |
710 |
726 |
711 \noindent |
727 \noindent |
712 where the last step is again an instance of the first term, but it |
728 The last term is again an instance of rewrite rule {\it i}), but the term |
713 is bigger. To avoid this loop we need to apply our rewrite rule |
729 is bigger. To avoid this loop we need to apply our rewrite rule |
714 using an `outside to inside' strategy. This strategy is sufficient |
730 using an `outside to inside' strategy. This strategy is sufficient |
715 since we are only interested of rewriting terms of the form @{term |
731 since we are only interested of rewriting terms of the form @{term |
716 "\<pi> \<bullet> t"}, where an outermost permutation needs to pushed inside a term. |
732 "\<pi> \<bullet> t"}, where an outermost permutation needs to pushed inside a term. |
717 |
733 |
718 Another problem we have to avoid is that the rules {\it i)} and |
734 Another problem we have to avoid is that the rules {\it i)} and {\it |
719 {\it iii)} can `overlap'. For this note that |
735 iii)} can `overlap'. For this note that the term @{term "\<pi> |
720 the term @{term "\<pi> \<bullet>(\<lambda>x. x)"} reduces by {\it ii)} to |
736 \<bullet>(\<lambda>x. x)"} reduces by {\it ii)} to @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet> x"}, to |
721 @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet> x"}, to which we can apply rule {\it iii)} |
737 which we can apply rule {\it iii)} in order to obtain @{term |
722 in order to obtain @{term "\<lambda>x. x"}, as is desired---there is no |
738 "\<lambda>x. x"}, as is desired---there is no free variable in the original |
723 free variable in the original term and so the permutation should completely |
739 term and so the permutation should completely vanish. However, the |
724 vanish. However, the subterm @{text |
740 subterm @{text "(- \<pi>) \<bullet> x"} is also an application. Consequently, |
725 "(- \<pi>) \<bullet> x"} is also an application. Consequently, the term |
741 the term @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet>x"} can reduce to @{text "\<lambda>x. (- (\<pi> |
726 @{term "\<lambda>x. \<pi> \<bullet> (- \<pi>) \<bullet>x"} can reduce to @{text "\<lambda>x. (- (\<pi> \<bullet> \<pi>)) \<bullet> (\<pi> \<bullet> x)"} using |
742 \<bullet> \<pi>)) \<bullet> (\<pi> \<bullet> x)"} using {\it i)}. Given our strategy we cannot |
727 {\it i)}. Given our strategy we cannot apply rule {\it iii)} anymore and |
743 apply rule {\it iii)} anymore and even worse the measure we will |
728 even worse the measure we will introduce shortly increased. On the |
744 introduce shortly increased. On the other hand, if we had started |
729 other hand, if we had started with the term @{text "\<pi> \<bullet> ((- \<pi>) \<bullet> x)"} |
745 with the term @{text "\<pi> \<bullet> ((- \<pi>) \<bullet> x)"} where @{text \<pi>} and @{text |
730 where @{text \<pi>} and @{text x} are free variables, then we \emph{do} |
746 x} are free variables, then we \emph{do} want to apply rule {\it i)} |
731 want to apply rule {\it i)} and not rule {\it iii)}. The latter |
747 and not rule {\it iii)}. The latter would eliminate @{text \<pi>} |
732 would eliminate @{text \<pi>} completely. The problem is that rule {\it iii)} |
748 completely. The problem is that rule {\it iii)} should only apply to |
733 should only apply to instances where the variable is to bound; for free variables |
749 instances where the variable is to bound; for free variables we want |
734 we want to use {\it ii)}. |
750 to use {\it ii)}. In order to distinguish these cases we have to |
735 |
751 maintain the information which variable is bound when inductively |
736 The problem is that in order to distinguish both cases when |
752 taking a term `apart'. This, unfortunately, does not mesh well with |
737 inductively taking a term `apart', we have to maintain the |
753 the way how conversion tactics are implemented in Isabelle/HOL. |
738 information which variable is bound. This, unfortunately, does not |
754 |
739 mesh well with the way how simplification tactics are implemented in |
755 Our remedy is to use a standard trick in HOL: we introduce a |
740 Isabelle/HOL. Our remedy is to use a standard trick in HOL: we |
756 separate definition for terms of the form @{text "(- \<pi>) \<bullet> x"}, |
741 introduce a separate definition for terms of the form @{text "(- \<pi>) |
757 namely as |
742 \<bullet> x"}, namely as |
|
743 |
758 |
744 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
759 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
745 @{term "unpermute \<pi> x \<equiv> (- \<pi>) \<bullet> x"} |
760 @{term "unpermute \<pi> x \<equiv> (- \<pi>) \<bullet> x"} |
746 \end{isabelle} |
761 \end{isabelle} |
747 |
762 |
769 of lexicographically ordered pairs whose first component is the size |
784 of lexicographically ordered pairs whose first component is the size |
770 of a term (counting terms of the form @{text "unpermute \<pi> x"} as |
785 of a term (counting terms of the form @{text "unpermute \<pi> x"} as |
771 leaves) and the second is the number of occurences of @{text |
786 leaves) and the second is the number of occurences of @{text |
772 "unpermute \<pi> x"} and @{text "\<pi> \<bullet> c"}. |
787 "unpermute \<pi> x"} and @{text "\<pi> \<bullet> c"}. |
773 |
788 |
774 With the definition of the simplification tactic in place, we can |
789 With the rules of the conversions tactic in place, we can |
775 establish its correctness. The property we are after is that for for |
790 establish its correctness. The property we are after is that |
776 a HOL-term @{text t} whose constants are all equivariant, the |
791 for a HOL-term @{text t} whose constants are all equivariant the |
777 HOL-term @{text "\<pi> \<bullet> t"} is equal to @{text "t'"} with @{text "t'"} |
792 term \mbox{@{text "\<pi> \<bullet> t"}} is equal to @{text "t'"} with @{text "t'"} |
778 being equal to @{text t} except that every free variable @{text x} |
793 being equal to @{text t} except that every free variable @{text x} |
779 in @{text t} is replaced by @{text "\<pi> \<bullet> x"}. Pitts calls this |
794 in @{text t} is replaced by \mbox{@{text "\<pi> \<bullet> x"}}. Let us call |
780 property \emph{equivariance principle} (book ref ???). In our |
795 a variable @{text x} \emph{really free}, if it is free and not occuring |
781 setting the precise statement of this property is a slightly more |
796 in an unpermute, such as @{text "unpermute _ x"} and @{text "unpermute x _"}. |
782 involved because of the fact that @{text unpermutes} needs to be |
797 We need the following technical notion characterising a \emph{@{text "\<pi>"}-proper} HOL-term |
783 treated specially. |
798 |
784 |
799 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
785 |
800 \begin{tabular}{@ {}ll} |
786 |
801 $\bullet$ & variables and constants are @{text \<pi>}-proper,\\ |
787 |
802 $\bullet$ & @{term "unpermute \<pi> x"} is @{text \<pi>}-proper,\\ |
788 With these definitions in place we can define the notion of an \emph{equivariant} |
803 $\bullet$ & @{term "\<lambda>x. t"} is @{text \<pi>}-proper, if @{text t} is @{text \<pi>}-proper and @{text x} is |
789 HOL-term |
804 really free in @{text t}, and\\ |
790 |
805 $\bullet$ & @{term "t\<^isub>1 t\<^isub>2"} is @{text \<pi>}-proper, if @{text "t\<^isub>1"} and @{text "t\<^isub>2"} are |
791 \begin{definition}[Equivariant HOL-term] |
806 @{text \<pi>}-proper. |
792 A HOL-term is \emph{equivariant}, provided it is closed and composed of applications, |
807 \end{tabular} |
793 abstractions and equivariant constants only. |
808 \end{isabelle} |
794 \end{definition} |
809 |
795 |
810 \begin{proof}[Theorem~\ref{eqvtprin}] We establish the property if @{text t} |
796 \noindent |
811 is @{text \<pi>}-proper and only contains equivaraint constants, then |
797 For equivariant terms we have |
812 @{text "\<pi> \<bullet> t = t'"} where @{text "t'"} is equal to @{text "t"} except all really |
798 |
813 free variables @{text x} are replaced by @{text "\<pi> \<bullet> x"}, and all semi-free variables |
799 \begin{lemma} |
814 @{text "unpermute \<pi> x"} by @{text "x"}. We establish this property by induction |
800 For an equivariant HOL-term @{text "t"}, @{term "\<pi> \<bullet> t = t"} for all permutations @{term "\<pi>"}. |
815 on the size of HOL-terms, counting terms like @{text "unpermuting \<pi> x"} as leafes, |
801 \end{lemma} |
816 like variables and constants. The cases for variables, constants and @{text unpermutes} |
802 |
817 are routine. In the case of abstractions we have by induction hypothesis that |
803 Let us now see how to use the equivariance principle. We have |
818 @{text "\<pi> \<bullet> (t[x := unpermute \<pi> x]) = t'"} with @{text "t'"} satisfying our |
804 |
819 correctness property. This implies that @{text "\<lambda>x. \<pi> \<bullet> (t[x := unpermute \<pi> x]) = \<lambda>x. t'"} |
|
820 and hence @{text "\<pi> \<bullet> (\<lambda>x. t) = \<lambda>x. t'"} as needed.\hfill\qed |
|
821 \end{proof} |
|
822 |
|
823 Pitts calls this property \emph{equivariance principle} (book ref ???). |
|
824 |
|
825 Problems with @{text undefined} |
|
826 |
|
827 Lines of code |
805 *} |
828 *} |
806 |
829 |
807 |
830 |
808 section {* Support and Freshness *} |
831 section {* Support and Freshness *} |
809 |
832 |
831 We also use the notation @{thm (lhs) fresh_star_def[no_vars]} for sets ot atoms |
855 We also use the notation @{thm (lhs) fresh_star_def[no_vars]} for sets ot atoms |
832 defined as follows |
856 defined as follows |
833 |
857 |
834 @{thm [display,indent=10] fresh_star_def[no_vars]} |
858 @{thm [display,indent=10] fresh_star_def[no_vars]} |
835 |
859 |
836 |
860 \noindent |
837 \noindent |
861 Using the equivariance principle, it can be easily checked that all three notions |
838 A striking consequence of these definitions is that we can prove |
862 are equivariant. A simple consequence of the definition of support and equivariance |
839 without knowing anything about the structure of @{term x} that |
863 is that if @{text x} is equivariant then we have |
840 swapping two fresh atoms, say @{text a} and @{text b}, leave |
864 |
841 @{text x} unchanged. For the proof we use the following lemma |
865 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
842 about swappings applied to an @{text x}: |
866 \begin{tabular}{@ {}l} |
|
867 @{thm (concl) supp_fun_eqvt[where f="x", no_vars]} |
|
868 \end{tabular}\hfill\numbered{suppeqvtfun} |
|
869 \end{isabelle} |
|
870 |
|
871 \noindent |
|
872 For function applications we can establish the following two properties. |
|
873 |
|
874 \begin{lemma}\label{suppfunapp} Let @{text f} and @{text x} be of permutation type, then |
|
875 \begin{isabelle} |
|
876 \begin{tabular}{r@ {\hspace{4mm}}p{10cm}} |
|
877 {\it i)} & @{thm[mode=IfThen] fresh_fun_app[no_vars]}\\ |
|
878 {\it ii)} & @{thm supp_fun_app[no_vars]}\\ |
|
879 \end{tabular} |
|
880 \end{isabelle} |
|
881 \end{lemma} |
|
882 |
|
883 \begin{proof} |
|
884 For the first property, we know from the assumption that @{term |
|
885 "finite {b. (a \<rightleftharpoons> b) \<bullet> f \<noteq> f}"} and @{term "finite {b . (a \<rightleftharpoons> b) \<bullet> x \<noteq> |
|
886 x}"} hold. That means for all, but finitely many @{text b} we have |
|
887 @{term "(a \<rightleftharpoons> b) \<bullet> f = f"} and @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. Similarly, |
|
888 we have to show that for but, but finitely @{text b} the equation |
|
889 @{term "(a \<rightleftharpoons> b) \<bullet> f x = f x"} holds. The left-hand side of this |
|
890 equation is equal to @{term "((a \<rightleftharpoons> b) \<bullet> f) ((a \<rightleftharpoons> b) \<bullet> x)"} by |
|
891 \eqref{permutefunapp}, which we know by the previous two facts for |
|
892 @{text f} and @{text x} is equal to the right-hand side for all, |
|
893 but finitely many @{text b}. This establishes the first |
|
894 property. The second is a simple corollary of {\it i)} by |
|
895 unfolding the definition of freshness.\qed |
|
896 \end{proof} |
|
897 |
|
898 A striking consequence of the definitions for support and freshness |
|
899 is that we can prove without knowing anything about the structure of |
|
900 @{term x} that swapping two fresh atoms, say @{text a} and @{text |
|
901 b}, leave @{text x} unchanged. For the proof we use the following |
|
902 lemma about swappings applied to an @{text x}: |
843 |
903 |
844 \begin{lemma}\label{swaptriple} |
904 \begin{lemma}\label{swaptriple} |
845 Assuming @{text x} is of permutation type, and @{text a}, @{text b} and @{text c} |
905 Assuming @{text x} is of permutation type, and @{text a}, @{text b} and @{text c} |
846 have the same sort, then \mbox{@{thm (prem 3) swap_rel_trans[no_vars]}} and |
906 have the same sort, then \mbox{@{thm (prem 3) swap_rel_trans[no_vars]}} and |
847 @{thm (prem 4) swap_rel_trans[no_vars]} imply @{thm (concl) swap_rel_trans[no_vars]}. |
907 @{thm (prem 4) swap_rel_trans[no_vars]} imply @{thm (concl) swap_rel_trans[no_vars]}. |
872 that there is an atom @{term c}, with the same sort as @{term a} and @{term b}, |
932 that there is an atom @{term c}, with the same sort as @{term a} and @{term b}, |
873 that satisfies \mbox{@{term "(a \<rightleftharpoons> c) \<bullet> x = x"}} and @{term "(b \<rightleftharpoons> c) \<bullet> x = x"}. |
933 that satisfies \mbox{@{term "(a \<rightleftharpoons> c) \<bullet> x = x"}} and @{term "(b \<rightleftharpoons> c) \<bullet> x = x"}. |
874 Now the theorem follows from Lemma~\ref{swaptriple}.\hfill\qed |
934 Now the theorem follows from Lemma~\ref{swaptriple}.\hfill\qed |
875 \end{proof} |
935 \end{proof} |
876 |
936 |
877 \noindent |
|
878 Two important properties that need to be established for later calculations is |
|
879 that @{text "supp"} and freshness are equivariant. For this we first show that: |
|
880 |
|
881 \begin{lemma}\label{half} |
|
882 If @{term x} is a permutation type, then @{thm (lhs) fresh_permute_iff[where p="\<pi>",no_vars]} |
|
883 if and only if @{thm (rhs) fresh_permute_iff[where p="\<pi>",no_vars]}. |
|
884 \end{lemma} |
|
885 |
|
886 \begin{proof} |
|
887 \begin{isabelle} |
|
888 \begin{tabular}[t]{c@ {\hspace{2mm}}l@ {\hspace{5mm}}l} |
|
889 & @{thm (lhs) fresh_permute_iff[where p="\<pi>",no_vars]}\\ |
|
890 @{text "\<equiv>"} & |
|
891 @{term "finite {b. (\<pi> \<bullet> a \<rightleftharpoons> b) \<bullet> \<pi> \<bullet> x \<noteq> \<pi> \<bullet> x}"}\\ |
|
892 @{text "\<Leftrightarrow>"} |
|
893 & @{term "finite {b. (\<pi> \<bullet> a \<rightleftharpoons> \<pi> \<bullet> b) \<bullet> \<pi> \<bullet> x \<noteq> \<pi> \<bullet> x}"} |
|
894 & since @{text "\<pi> \<bullet> _"} is bijective\\ |
|
895 @{text "\<Leftrightarrow>"} |
|
896 & @{term "finite {b. \<pi> \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> \<pi> \<bullet> x}"} |
|
897 & by Lemma~\ref{permutecompose} and \eqref{swapeqvt}\\ |
|
898 @{text "\<Leftrightarrow>"} |
|
899 & @{term "finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}"} |
|
900 & by \eqref{permuteequ}\\ |
|
901 @{text "\<equiv>"} |
|
902 & @{thm (rhs) fresh_permute_iff[where p="\<pi>",no_vars]} |
|
903 \end{tabular} |
|
904 \end{isabelle}\hfill\qed |
|
905 \end{proof} |
|
906 |
|
907 \noindent |
|
908 Together with the definition of the permutation operation on booleans, |
|
909 we can immediately infer equivariance of freshness: |
|
910 |
|
911 @{thm [display,indent=10] fresh_eqvt[where p="\<pi>",no_vars]} |
|
912 |
|
913 \noindent |
|
914 Now equivariance of @{text "supp"}, namely |
|
915 |
|
916 @{thm [display,indent=10] supp_eqvt[where p="\<pi>",no_vars]} |
|
917 |
|
918 \noindent |
|
919 is by noting that @{thm supp_conv_fresh[no_vars]} and that freshness and |
|
920 the logical connectives are equivariant. ??? Equivariance |
|
921 |
|
922 A simple consequence of the definition of support and equivariance is that |
|
923 if a function @{text f} is equivariant then we have |
|
924 |
|
925 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
926 \begin{tabular}{@ {}l} |
|
927 @{thm (concl) supp_fun_eqvt[no_vars]} |
|
928 \end{tabular}\hfill\numbered{suppeqvtfun} |
|
929 \end{isabelle} |
|
930 |
|
931 \noindent |
|
932 For function applications we can establish the two following properties. |
|
933 |
|
934 \begin{lemma} Let @{text f} and @{text x} be of permutation type, then |
|
935 \begin{isabelle} |
|
936 \begin{tabular}{r@ {\hspace{4mm}}p{10cm}} |
|
937 @{text "i)"} & @{thm[mode=IfThen] fresh_fun_app[no_vars]}\\ |
|
938 @{text "ii)"} & @{thm supp_fun_app[no_vars]}\\ |
|
939 \end{tabular} |
|
940 \end{isabelle} |
|
941 \end{lemma} |
|
942 |
|
943 \begin{proof} |
|
944 ??? |
|
945 \end{proof} |
|
946 |
|
947 |
|
948 While the abstract properties of support and freshness, particularly |
937 While the abstract properties of support and freshness, particularly |
949 Theorem~\ref{swapfreshfresh}, are useful for developing Nominal Isabelle, |
938 Theorem~\ref{swapfreshfresh}, are useful for developing Nominal Isabelle, |
950 one often has to calculate the support of some concrete object. This is |
939 one often has to calculate the support of concrete objects. |
951 straightforward for example for booleans, nats, products and lists: |
940 For booleans, nats, products and lists it is easy to check that |
952 |
941 |
953 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
942 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
954 \begin{tabular}{@ {}l@ {\hspace{4mm}}l@ {}} |
943 \begin{tabular}{@ {}l@ {\hspace{4mm}}l@ {}} |
955 @{text "booleans"}: & @{term "supp b = {}"}\\ |
944 @{text "booleans"}: & @{term "supp b = {}"}\\ |
956 @{text "nats"}: & @{term "supp n = {}"}\\ |
945 @{text "nats"}: & @{term "supp n = {}"}\\ |
1077 The proof-obligation can then be discharged by analysing the inequality |
1066 The proof-obligation can then be discharged by analysing the inequality |
1078 between the permutations @{term "(\<pi> \<bullet> a \<rightleftharpoons> b)"} and @{term "(a \<rightleftharpoons> b)"}. |
1067 between the permutations @{term "(\<pi> \<bullet> a \<rightleftharpoons> b)"} and @{term "(a \<rightleftharpoons> b)"}. |
1079 |
1068 |
1080 The main point about support is that whenever an object @{text x} has finite |
1069 The main point about support is that whenever an object @{text x} has finite |
1081 support, then Proposition~\ref{choosefresh} allows us to choose for @{text x} a |
1070 support, then Proposition~\ref{choosefresh} allows us to choose for @{text x} a |
1082 fresh atom with arbitrary sort. This is an important operation in Nominal |
1071 fresh atom with arbitrary sort. This is a crucial operation in Nominal |
1083 Isabelle in situations where, for example, a bound variable needs to be |
1072 Isabelle in situations where, for example, a bound variable needs to be |
1084 renamed. To allow such a choice, we only have to assume that |
1073 renamed. To allow such a choice, we only have to assume that |
1085 @{text "finite (supp x)"} holds. For more convenience we |
1074 @{text "finite (supp x)"} holds. For more convenience we |
1086 can define a type class for types where every element has finite support, and |
1075 can define a type class in Isabelle/HOL corresponding to the |
1087 prove that the types @{term "atom"}, @{term "perm"}, lists, products and |
1076 property: |
1088 booleans are instances of this type class. |
1077 |
1089 |
1078 \begin{definition}[Finitely Supported Type] |
1090 Unfortunately, this does not work for sets or Isabelle/HOL's function |
1079 A type @{text "\<beta>"} is \emph{finitely supported} if @{term "finite (supp x)"} |
1091 type. There are functions and sets definable in Isabelle/HOL for which the |
1080 holds for all @{text x} of type @{text "\<beta>"}. |
1092 finite support property does not hold. A simple example of a function with |
1081 \end{definition} |
1093 infinite support is @{const nat_of} shown in \eqref{sortnatof}. This |
1082 |
1094 function's support is the set of \emph{all} atoms @{term "UNIV::atom set"}. |
1083 \noindent |
1095 To establish this we show |
1084 By the calculations above we can easily establish |
1096 @{term "\<not> a \<sharp> nat_of"}. This is equivalent to assuming the set @{term |
1085 |
1097 "{b. (a \<rightleftharpoons> b) \<bullet> nat_of \<noteq> nat_of}"} is finite and deriving a |
1086 \begin{theorem}\label{finsuptype} |
1098 contradiction. From the assumption we also know that @{term "{a} \<union> {b. (a \<rightleftharpoons> |
1087 The types @{type atom}, @{type perm}, @{type bool} and @{type nat} |
1099 b) \<bullet> nat_of \<noteq> nat_of}"} is finite. Then we can use |
1088 are fintitely supported, and assuming @{text \<beta>}, @{text "\<beta>\<^isub>1"} and |
1100 Proposition~\ref{choosefresh} to choose an atom @{text c} such that @{term |
1089 @{text "\<beta>\<^isub>2"} are finitely supported types, then @{text "\<beta> list"} and |
1101 "c \<noteq> a"}, @{term "sort_of c = sort_of a"} and @{term "(a \<rightleftharpoons> c) \<bullet> nat_of = |
1090 @{text "\<beta>\<^isub>1 \<times> \<beta>\<^isub>2"} are finitely supported. |
1102 nat_of"}. Now we can reason as follows: |
1091 \end{theorem} |
|
1092 |
|
1093 \noindent |
|
1094 The main benefit of using the finite support property for choosing a |
|
1095 fresh atom is that the reasoning is `compositional'. To see this, |
|
1096 assume we have a list of atoms and a method of choosing a fresh atom |
|
1097 that is not a member in this list---for example the maximum plus |
|
1098 one. Then if we enlarge this list \emph{after} the choice, then |
|
1099 obviously the fresh atom might not be fresh anymore. In contrast, by |
|
1100 the classical reasoning of Proposition~\ref{choosefresh} we know a |
|
1101 fresh atom exists for every list of atoms and no matter how we |
|
1102 extend this list of atoms, we always preserve the property of being |
|
1103 finitely supported. Consequently the existence of a fresh atom is |
|
1104 still guarantied by Proposition~\ref{choosefresh}. Using the method |
|
1105 of `maximum plus one' we might have to adapt the choice of a fresh |
|
1106 atom. |
|
1107 |
|
1108 Unfortunately, Theorem~\ref{finsuptype} does not work in general for the |
|
1109 types of sets and functions. There are functions definable in HOL |
|
1110 for which the finite support property does not hold. A simple |
|
1111 example of a function with infinite support is @{const nat_of} shown |
|
1112 in \eqref{sortnatof}. This function's support is the set of |
|
1113 \emph{all} atoms @{term "UNIV::atom set"}. To establish this we |
|
1114 show @{term "\<not> a \<sharp> nat_of"}. This is equivalent to assuming the set |
|
1115 @{term "{b. (a \<rightleftharpoons> b) \<bullet> nat_of \<noteq> nat_of}"} is finite and deriving a |
|
1116 contradiction. From the assumption we also know that @{term "{a} \<union> |
|
1117 {b. (a \<rightleftharpoons> b) \<bullet> nat_of \<noteq> nat_of}"} is finite. Then we can use |
|
1118 Proposition~\ref{choosefresh} to choose an atom @{text c} such that |
|
1119 @{term "c \<noteq> a"}, @{term "sort_of c = sort_of a"} and @{term "(a \<rightleftharpoons> c) |
|
1120 \<bullet> nat_of = nat_of"}. Now we can reason as follows: |
1103 |
1121 |
1104 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1122 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1105 \begin{tabular}[b]{@ {}rcl@ {\hspace{5mm}}l} |
1123 \begin{tabular}[b]{@ {}rcl@ {\hspace{5mm}}l} |
1106 @{text "nat_of a"} & @{text "="} & @{text "(a \<rightleftharpoons> c) \<bullet> (nat_of a)"} & by def.~of permutations on nats\\ |
1124 @{text "nat_of a"} & @{text "="} & @{text "(a \<rightleftharpoons> c) \<bullet> (nat_of a)"} & by def.~of permutations on nats\\ |
1107 & @{text "="} & @{term "((a \<rightleftharpoons> c) \<bullet> nat_of) ((a \<rightleftharpoons> c) \<bullet> a)"} & by \eqref{permutefunapp}\\ |
1125 & @{text "="} & @{term "((a \<rightleftharpoons> c) \<bullet> nat_of) ((a \<rightleftharpoons> c) \<bullet> a)"} & by \eqref{permutefunapp}\\ |
1142 \noindent |
1164 \noindent |
1143 Note that a consequence of the second part of this lemma is that |
1165 Note that a consequence of the second part of this lemma is that |
1144 @{term "supp (UNIV::atom set) = {}"}. |
1166 @{term "supp (UNIV::atom set) = {}"}. |
1145 More difficult, however, is it to establish that finite sets of finitely |
1167 More difficult, however, is it to establish that finite sets of finitely |
1146 supported objects are finitely supported. For this we first show that |
1168 supported objects are finitely supported. For this we first show that |
1147 the union of the suports of finitely many and finitely supported objects |
1169 the union of the supports of finitely many and finitely supported objects |
1148 is finite, namely |
1170 is finite, namely |
1149 |
1171 |
1150 \begin{lemma}\label{unionsupp} |
1172 \begin{lemma}\label{unionsupp} |
1151 If @{text S} is a finite set whose elements are all finitely supported, then\\ |
1173 If @{text S} is a finite set whose elements are all finitely supported, then |
1152 @{text "i)"} @{thm (concl) Union_of_finite_supp_sets[no_vars]} and\\ |
1174 % |
1153 @{text "ii)"} @{thm (concl) Union_included_in_supp[no_vars]}. |
1175 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
1176 \begin{tabular}[b]{@ {}rl} |
|
1177 {\it i)} & @{thm (concl) Union_of_finite_supp_sets[no_vars]} and\\ |
|
1178 {\it ii)} & @{thm (concl) Union_included_in_supp[no_vars]}. |
|
1179 \end{tabular} |
|
1180 \end{isabelle} |
1154 \end{lemma} |
1181 \end{lemma} |
1155 |
1182 |
1156 \begin{proof} |
1183 \begin{proof} |
1157 The first part is by a straightforward induction on the finiteness of @{text S}. |
1184 The first part is by a straightforward induction on the finiteness |
1158 For the second part, we know that @{term "\<Union>x\<in>S. supp x"} is a set of atoms, which |
1185 of @{text S}. For the second part, we know that @{term "\<Union>x\<in>S. supp |
1159 by the first part is finite. Therefore we know by Lemma~\ref{finatomsets}.@{text "i)"} |
1186 x"} is a set of atoms, which by the first part is finite. Therefore |
1160 that @{term "(\<Union>x\<in>S. supp x) = supp (\<Union>x\<in>S. supp x)"}. Taking @{text "f"} to be |
1187 we know by Lemma~\ref{finatomsets}.{\it i)} that @{term "(\<Union>x\<in>S. supp |
1161 \mbox{@{text "\<lambda>S. \<Union> (supp ` S)"}}, we can write the right hand side as @{text "supp (f S)"}. |
1188 x) = supp (\<Union>x\<in>S. supp x)"}. Taking @{text "f"} to be the function |
1162 Since @{text "f"} is an equivariant function, we have that |
1189 \mbox{@{text "\<lambda>S. \<Union> (supp ` S)"}}, we can write the right-hand side |
1163 @{text "supp (f S) \<subseteq> supp S"} by ??? This completes the second part.\hfill\qed |
1190 as @{text "supp (f S)"}. Since @{text "f"} is an equivariant |
|
1191 function (can be easily checked by the equivariance principle), we |
|
1192 have that @{text "supp (f S) \<subseteq> supp S"} by |
|
1193 Lemma~\ref{suppfunapp}.{\it ii)}. This completes the second |
|
1194 part.\hfill\qed |
1164 \end{proof} |
1195 \end{proof} |
1165 |
1196 |
1166 \noindent |
1197 \noindent |
1167 With this lemma in place we can establish that |
1198 With this lemma in place we can establish that |
1168 |
1199 |
1169 \begin{lemma} |
1200 \begin{lemma} |
1170 @{thm[mode=IfThen] supp_of_finite_sets[no_vars]} |
1201 @{thm[mode=IfThen] supp_of_finite_sets[no_vars]} |
1171 \end{lemma} |
1202 \end{lemma} |
1172 |
1203 |
1173 \begin{proof} |
1204 \begin{proof} |
1174 The right-to-left inclusion is proved in Lemma~\ref{unionsupp}.@{text "ii)"}. To show the inclusion |
1205 The right-to-left inclusion is proved in Lemma~\ref{unionsupp}.{\it ii)}. To show the inclusion |
1175 in the other direction we have to show Lemma~\ref{supports}.@{text "i)"} |
1206 in the other direction we can use Lemma~\ref{supports}.{\it i)}. This means |
|
1207 for all @{text a} and @{text b} that are not in @{text S} we have to show that |
|
1208 @{term "(a \<rightleftharpoons> b) \<bullet> (\<Union>x \<in> S. supp x) = (\<Union>x \<in> S. supp x)"} holds. By the equivariance |
|
1209 principle, the left-hand side is equal to @{term "\<Union>x \<in> ((a \<rightleftharpoons> b) \<bullet> S). supp x"}. Now |
|
1210 the swapping in front of @{text S} disappears, since @{term "a \<sharp> S"} and @{term "b \<sharp> S"} |
|
1211 whenever @{text "a, b \<notin> S"}. Thus we are done.\hfill\qed |
1176 \end{proof} |
1212 \end{proof} |
|
1213 |
|
1214 \noindent |
|
1215 To sum up, every finite set of finitely supported elements has |
|
1216 finite support. Unfortunately, we cannot use |
|
1217 Theorem~\ref{finsuptype} to let Isabelle/HOL find this out |
|
1218 automatically. This would require to introduce a separate type of |
|
1219 finite sets, which however is not so convenient to reason about as |
|
1220 Isabelle's standard set type. |
1177 *} |
1221 *} |
1178 |
1222 |
1179 |
1223 |
1180 section {* Induction Principles *} |
1224 section {* Induction Principles for Permutations *} |
1181 |
1225 |
1182 text {* |
1226 text {* |
1183 While the use of functions as permutation provides us with a unique |
1227 While the use of functions as permutation provides us with a unique |
1184 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
1228 representation for permutations (for example @{term "(a \<rightleftharpoons> b)"} and |
1185 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation has |
1229 @{term "(b \<rightleftharpoons> a)"} are equal permutations), this representation does |
1186 one draw back: it does not come readily with an induction principle. |
1230 not come automatically with an induction principle. Such an |
1187 Such an induction principle is handy for deriving properties like |
1231 induction principle is however handy for generalising |
1188 |
1232 Lemma~\ref{swapfreshfresh} from swappings to permutations |
1189 @{thm [display, indent=10] supp_perm_eq[no_vars]} |
1233 |
1190 |
1234 \begin{lemma} |
1191 \noindent |
1235 @{thm [mode=IfThen] perm_supp_eq[no_vars]} |
1192 However, it is not too difficult to derive an induction principle, |
1236 \end{lemma} |
1193 given the fact that we allow only permutations with a finite domain. |
1237 |
|
1238 \noindent |
|
1239 In this section we will establish an induction principle for permutations |
|
1240 with which this lemma can be easily proved. It is not too difficult to derive |
|
1241 an induction principle for permutations, given the fact that we allow only |
|
1242 permutations having a finite support. |
|
1243 |
|
1244 Using a the property from \cite{???} |
|
1245 |
|
1246 \begin{lemma}\label{smallersupp} |
|
1247 @{thm [mode=IfThen] smaller_supp[no_vars]} |
|
1248 \end{lemma} |
1194 *} |
1249 *} |
1195 |
1250 |
1196 |
1251 |
1197 section {* An Abstraction Type *} |
1252 section {* An Abstraction Type *} |
1198 |
1253 |
1475 generic atom type, which we will write @{text "|_|"}. For each class |
1529 generic atom type, which we will write @{text "|_|"}. For each class |
1476 instance, this function must be injective and equivariant, and its outputs |
1530 instance, this function must be injective and equivariant, and its outputs |
1477 must all have the same sort, that is |
1531 must all have the same sort, that is |
1478 |
1532 |
1479 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1533 \begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
1480 \begin{tabular}{r@ {\hspace{3mm}}l} |
1534 \begin{tabular}{@ {}r@ {\hspace{3mm}}l} |
1481 i) if @{thm (lhs) atom_eq_iff [no_vars]} then @{thm (rhs) atom_eq_iff [no_vars]}\\ |
1535 i) & if @{thm (lhs) atom_eq_iff [no_vars]} then @{thm (rhs) atom_eq_iff [no_vars]}\\ |
1482 ii) @{thm atom_eqvt[where p="\<pi>", no_vars]}\\ |
1536 ii) & @{thm atom_eqvt[where p="\<pi>", no_vars]}\\ |
1483 iii) @{thm sort_of_atom_eq [no_vars]} |
1537 iii) & @{thm sort_of_atom_eq [no_vars]} |
1484 \end{tabular}\hfill\numbered{atomprops} |
1538 \end{tabular}\hfill\numbered{atomprops} |
1485 \end{isabelle} |
1539 \end{isabelle} |
1486 |
1540 |
1487 \noindent |
1541 \noindent |
1488 With the definition @{thm atom_name_def [THEN eq_reflection, no_vars]} we can |
1542 With the definition @{thm atom_name_def [THEN eq_reflection, no_vars]} we can |
1489 show that @{typ name} satisfies all the above requirements of a concrete atom |
1543 show that @{typ name} satisfies all the above requirements of a concrete atom |
1490 type. |
1544 type. |
1491 |
1545 |
1492 The whole point of defining the concrete atom type class was to let users |
1546 The whole point of defining the concrete atom type class is to let users |
1493 avoid explicit reasoning about sorts. This benefit is realised by defining a |
1547 avoid explicit reasoning about sorts. This benefit is realised by defining a |
1494 special swapping operation of type @{text "\<alpha> \<Rightarrow> \<alpha> |
1548 special swapping operation of type @{text "\<alpha> \<Rightarrow> \<alpha> |
1495 \<Rightarrow> perm"}, where @{text "\<alpha>"} is a concrete atom type: |
1549 \<Rightarrow> perm"}, where @{text "\<alpha>"} is a concrete atom type: |
1496 |
1550 |
1497 @{thm [display,indent=10] flip_def [THEN eq_reflection, no_vars]} |
1551 @{thm [display,indent=10] flip_def [THEN eq_reflection, no_vars]} |