111 \end{equation}\smallskip |
111 \end{equation}\smallskip |
112 |
112 |
113 \noindent |
113 \noindent |
114 and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of |
114 and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of |
115 type-variables. While it is possible to implement this kind of more general |
115 type-variables. While it is possible to implement this kind of more general |
116 binders by iterating single binders, this leads to a rather clumsy |
116 binders by iterating single binders, like @{text "\<forall>x\<^isub>1.\<forall>x\<^isub>2...\<forall>x\<^isub>n.T"}, this leads to a rather clumsy |
117 formalisation of W. |
117 formalisation of W. For example, the usual definition when a |
118 |
118 type is an instance of a type-scheme requires the following auxiliary \emph{unbinding relation} |
119 {\bf add example about W} |
119 |
120 |
120 \[ |
|
121 \infer{@{text T} \hookrightarrow ([], @{text T})}{}\qquad |
|
122 \infer{\forall @{text x.S} \hookrightarrow (@{text x}\!::\!@{text xs}, @{text T})} |
|
123 {@{text S} \hookrightarrow (@{text xs}, @{text T})} |
|
124 \]\smallskip |
|
125 |
|
126 \noindent |
|
127 which relates a type-scheme with a list of variables and a type. The point of this |
|
128 definition is to get access to the bound variables and the type-part of a type-scheme |
|
129 @{text S}, though in general |
|
130 we will only get access to some variables and some type @{text T} that are |
|
131 ``alpha-equivalent'' to @{text S}---it is an unbinding \emph{relation}. Still, with this |
|
132 definition in place we can formally define when a type is an instance of a type-scheme as |
|
133 |
|
134 \[ |
|
135 @{text "T \<prec> S \<equiv> \<exists>xs T' \<sigma>. S \<hookrightarrow> (xs, T') \<and> dom \<sigma> = set xs \<and> \<sigma>(T') = T"} |
|
136 \]\smallskip |
|
137 |
|
138 \noindent |
|
139 meaning there exists a list of variables @{text xs} and a type @{text T'} to which |
|
140 the type-scheme @{text S} unbinds, and there exists a substitution whose domain is |
|
141 @{text xs} (seen as set) such that @{text "\<sigma>(T') = T"}. |
|
142 The pain with this definition is that we cannot follow the usual proofs |
|
143 that are by induction on the type-part of the type-scheme (since it is under |
|
144 an existential quantifier). The representation of type-schemes by iterating single binders |
|
145 prevents us from directly ``unbinding'' the bound variables and the type-part of |
|
146 a type-scheme. The purpose of this paper is to introduce general binders, which |
|
147 allow us to represent type-schemes following closely informal practice and as |
|
148 a result solve this problem. |
121 The need of iterating single binders is also one reason |
149 The need of iterating single binders is also one reason |
122 why Nominal Isabelle and similar theorem provers that only provide |
150 why Nominal Isabelle and similar theorem provers that only provide |
123 mechanisms for binding single variables have not fared extremely well with |
151 mechanisms for binding single variables have not fared extremely well with |
124 the more advanced tasks in the POPLmark challenge \cite{challenge05}, |
152 the more advanced tasks in the POPLmark challenge \cite{challenge05}, |
125 because also there one would like to bind multiple variables at once. |
153 because also there one would like to bind multiple variables at once. |
391 which includes multiple binders in type-schemes.\medskip |
419 which includes multiple binders in type-schemes.\medskip |
392 |
420 |
393 \noindent |
421 \noindent |
394 {\bf Contributions:} We provide three new definitions for when terms |
422 {\bf Contributions:} We provide three new definitions for when terms |
395 involving general binders are alpha-equivalent. These definitions are |
423 involving general binders are alpha-equivalent. These definitions are |
396 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
424 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatically-generated |
397 proofs, we establish a reasoning infrastructure for alpha-equated terms, |
425 proofs, we establish a reasoning infrastructure for alpha-equated terms, |
398 including properties about support, freshness and equality conditions for |
426 including properties about support, freshness and equality conditions for |
399 alpha-equated terms. We are also able to automatically derive strong |
427 alpha-equated terms. We are also able to automatically derive strong |
400 induction principles that have the variable convention already built in. |
428 induction principles that have the variable convention already built in. |
401 For this we simplify the earlier automated proofs by using the proving tools |
429 For this we simplify the earlier automated proofs by using the proving tools |
576 \noindent |
604 \noindent |
577 The main point of @{text supports} is that we can establish the following |
605 The main point of @{text supports} is that we can establish the following |
578 two properties. |
606 two properties. |
579 |
607 |
580 \begin{prop}\label{supportsprop} |
608 \begin{prop}\label{supportsprop} |
581 Given a set @{text "as"} of atoms.\\ |
609 Given a set @{text "bs"} of atoms.\\ |
582 {\it (i)} If @{thm (prem 1) supp_is_subset[where S="as", no_vars]} |
610 {\it (i)} If @{thm (prem 1) supp_is_subset[where S="bs", no_vars]} |
583 and @{thm (prem 2) supp_is_subset[where S="as", no_vars]} then |
611 and @{thm (prem 2) supp_is_subset[where S="bs", no_vars]} then |
584 @{thm (concl) supp_is_subset[where S="as", no_vars]}.\\ |
612 @{thm (concl) supp_is_subset[where S="bs", no_vars]}.\\ |
585 {\it (ii)} @{thm supp_supports[no_vars]}. |
613 {\it (ii)} @{thm supp_supports[no_vars]}. |
586 \end{prop} |
614 \end{prop} |
587 |
615 |
588 Another important notion in the nominal logic work is \emph{equivariance}. |
616 Another important notion in the nominal logic work is \emph{equivariance}. |
589 For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant |
617 For a function @{text f} to be equivariant |
590 it is required that every permutation leaves @{text f} unchanged, that is |
618 it is required that every permutation leaves @{text f} unchanged, that is |
591 |
619 |
592 \begin{equation}\label{equivariancedef} |
620 \begin{equation}\label{equivariancedef} |
593 @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"} |
621 @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"} |
594 \end{equation}\smallskip |
622 \end{equation}\smallskip |
595 |
623 |
596 \noindent or equivalently that a permutation applied to the application |
624 \noindent |
597 @{text "f x"} can be moved to the argument @{text x}. That means for equivariant |
625 If a function is of type @{text "\<alpha> \<Rightarrow> \<beta>"}, this definition is equivalent to |
598 functions @{text f}, we have for all permutations @{text "\<pi>"}: |
626 the fact that a permutation applied to the application |
|
627 @{text "f x"} can be moved to the argument @{text x}. That means for |
|
628 functions @{text f} of type @{text "\<alpha> \<Rightarrow> \<beta>"}, we have for all permutations @{text "\<pi>"}: |
599 |
629 |
600 \begin{equation}\label{equivariance} |
630 \begin{equation}\label{equivariance} |
601 @{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\; |
631 @{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\; |
602 @{text "\<forall>x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"} |
632 @{text "\<forall>x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"} |
603 \end{equation}\smallskip |
633 \end{equation}\smallskip |
604 |
634 |
605 \noindent |
635 \noindent |
606 From property \eqref{equivariancedef} and the definition of @{text supp}, we |
636 There is |
607 can easily deduce that equivariant functions have empty support. There is |
637 also a similar property for relations, which are in HOL functions of type @{text "\<alpha> \<Rightarrow> \<beta> \<Rightarrow> bool"}. |
608 also a similar notion for equivariant relations, say @{text R}, namely the property |
638 Suppose a relation @{text R}, then |
609 that |
639 that for all permutations @{text \<pi>}: |
610 |
640 |
611 \[ |
641 \[ |
612 @{text "x R y"} \;\;\textit{implies}\;\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"} |
642 @{text "\<pi> \<bullet> R = R"} \;\;\;\;\textit{if and only if}\;\;\;\; |
613 \]\smallskip |
643 @{text "\<forall>x y."}~~@{text "x R y"} \;\textit{implies}\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"} |
614 |
644 \]\smallskip |
|
645 |
|
646 \noindent |
|
647 Note that from property \eqref{equivariancedef} and the definition of @{text supp}, we |
|
648 can easily deduce that equivariant functions have empty support. |
|
649 |
615 Using freshness, the nominal logic work provides us with general means for renaming |
650 Using freshness, the nominal logic work provides us with general means for renaming |
616 binders. |
651 binders. |
617 |
652 |
618 \noindent |
653 \noindent |
619 While in the older version of Nominal Isabelle, we used extensively |
654 While in the older version of Nominal Isabelle, we used extensively |
620 Property~\ref{swapfreshfresh} to rename single binders, this property |
655 Proposition~\ref{swapfreshfresh} to rename single binders, this property |
621 proved too unwieldy for dealing with multiple binders. For such binders the |
656 proved too unwieldy for dealing with multiple binders. For such binders the |
622 following generalisations turned out to be easier to use. |
657 following generalisations turned out to be easier to use. |
623 |
658 |
624 \begin{prop}\label{supppermeq} |
659 \begin{prop}\label{supppermeq} |
625 @{thm[mode=IfThen] supp_perm_eq[where p="\<pi>", no_vars]} |
660 @{thm[mode=IfThen] supp_perm_eq[where p="\<pi>", no_vars]} |
675 The first question we have to answer is when two pairs @{text "(as, x)"} and |
710 The first question we have to answer is when two pairs @{text "(as, x)"} and |
676 @{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in |
711 @{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in |
677 the notion of alpha-equivalence that is \emph{not} preserved by adding |
712 the notion of alpha-equivalence that is \emph{not} preserved by adding |
678 vacuous binders.) To answer this question, we identify four conditions: {\it (i)} |
713 vacuous binders.) To answer this question, we identify four conditions: {\it (i)} |
679 given a free-atom function @{text "fa"} of type \mbox{@{text "\<beta> \<Rightarrow> atom |
714 given a free-atom function @{text "fa"} of type \mbox{@{text "\<beta> \<Rightarrow> atom |
680 set"}}, then @{text x} and @{text y} need to have the same set of free |
715 set"}}, then @{text "(as, x)"} and @{text "(bs, y)"} need to have the same set of free |
681 atoms; moreover there must be a permutation @{text \<pi>} such that {\it |
716 atoms; moreover there must be a permutation @{text \<pi>} such that {\it |
682 (ii)} @{text \<pi>} leaves the free atoms of @{text x} and @{text y} unchanged, but |
717 (ii)} @{text \<pi>} leaves the free atoms of @{text "(as, x)"} and @{text "(bs, y)"} unchanged, but |
683 {\it (iii)} `moves' their bound names so that we obtain modulo a relation, |
718 {\it (iii)} `moves' their bound names so that we obtain modulo a relation, |
684 say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)} |
719 say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)} |
685 @{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The |
720 @{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The |
686 requirements {\it (i)} to {\it (iv)} can be stated formally as: |
721 requirements {\it (i)} to {\it (iv)} can be stated formally as: |
687 |
722 |
753 \]\smallskip |
788 \]\smallskip |
754 |
789 |
755 \noindent |
790 \noindent |
756 Now recall the examples shown in \eqref{ex1} and |
791 Now recall the examples shown in \eqref{ex1} and |
757 \eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and |
792 \eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and |
758 @{text "({y, x}, y \<rightarrow> x)"} are alpha-equivalent according to |
793 @{text "({x, y}, y \<rightarrow> x)"} are alpha-equivalent according to |
759 $\approx_{\,\textit{set}}$ and $\approx_{\,\textit{set+}}$ by taking @{text "\<pi>"} to |
794 $\approx_{\,\textit{set}}$ and $\approx_{\,\textit{set+}}$ by taking @{text "\<pi>"} to |
760 be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then @{text |
795 be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then @{text |
761 "([x, y], x \<rightarrow> y)"} $\not\approx_{\,\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"} |
796 "([x, y], x \<rightarrow> y)"} $\not\approx_{\,\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"} |
762 since there is no permutation that makes the lists @{text "[x, y]"} and |
797 since there is no permutation that makes the lists @{text "[x, y]"} and |
763 @{text "[y, x]"} equal, and also leaves the type \mbox{@{text "x \<rightarrow> y"}} |
798 @{text "[y, x]"} equal, and also leaves the type \mbox{@{text "x \<rightarrow> y"}} |
889 (supp x - as)"}. We therefore can use the swapping @{term "(a \<rightleftharpoons> b)"} as |
924 (supp x - as)"}. We therefore can use the swapping @{term "(a \<rightleftharpoons> b)"} as |
890 the permutation for the proof obligation. |
925 the permutation for the proof obligation. |
891 \end{proof} |
926 \end{proof} |
892 |
927 |
893 \noindent |
928 \noindent |
894 Assuming that @{text "x"} has finite support, this lemma together |
929 This lemma together |
895 with \eqref{absperm} allows us to show |
930 with \eqref{absperm} allows us to show |
896 |
931 |
897 \begin{equation}\label{halfone} |
932 \begin{equation}\label{halfone} |
898 @{thm Abs_supports(1)[no_vars]} |
933 @{thm Abs_supports(1)[no_vars]} |
899 \end{equation}\smallskip |
934 \end{equation}\smallskip |
900 |
935 |
901 \noindent |
936 \noindent |
902 which by Property~\ref{supportsprop} gives us `one half' of |
937 which by Property~\ref{supportsprop} gives us `one half' of |
903 Theorem~\ref{suppabs}. The `other half' is a bit more involved. To establish |
938 Theorem~\ref{suppabs}. To establish the `other half', we |
904 it, we use a trick from \cite{Pitts04} and first define an auxiliary |
939 use a trick from \cite{Pitts04} and first define an auxiliary |
905 function @{text aux}, taking an abstraction as argument |
940 function @{text aux}, taking an abstraction as argument |
906 |
941 |
907 \[ |
942 \[ |
908 @{thm supp_set.simps[THEN eq_reflection, no_vars]} |
943 @{thm supp_set.simps[THEN eq_reflection, no_vars]} |
909 \]\smallskip |
944 \]\smallskip |
1005 contained in the collection of @{text ty}$^\alpha_{1..n}$ declared in |
1040 contained in the collection of @{text ty}$^\alpha_{1..n}$ declared in |
1006 \eqref{scheme}. In this case we will call the corresponding argument a |
1041 \eqref{scheme}. In this case we will call the corresponding argument a |
1007 \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such |
1042 \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such |
1008 recursive arguments need to satisfy a `positivity' restriction, which |
1043 recursive arguments need to satisfy a `positivity' restriction, which |
1009 ensures that the type has a set-theoretic semantics (see |
1044 ensures that the type has a set-theoretic semantics (see |
1010 \cite{Berghofer99}). The labels annotated on the types are optional. Their |
1045 \cite{Berghofer99}). If the types are polymorphic, we require the |
|
1046 type variables are of finitely supported type. |
|
1047 The labels annotated on the types are optional. Their |
1011 purpose is to be used in the (possibly empty) list of \emph{binding |
1048 purpose is to be used in the (possibly empty) list of \emph{binding |
1012 clauses}, which indicate the binders and their scope in a term-constructor. |
1049 clauses}, which indicate the binders and their scope in a term-constructor. |
1013 They come in three \emph{modes}: |
1050 They come in three \emph{modes}: |
1014 |
1051 |
1015 |
1052 |
2466 Although we were heavily inspired by the syntax of Ott, its definition of |
2503 Although we were heavily inspired by the syntax of Ott, its definition of |
2467 alpha-equi\-valence is unsuitable for our extension of Nominal |
2504 alpha-equi\-valence is unsuitable for our extension of Nominal |
2468 Isabelle. First, it is far too complicated to be a basis for automated |
2505 Isabelle. First, it is far too complicated to be a basis for automated |
2469 proofs implemented on the ML-level of Isabelle/HOL. Second, it covers cases |
2506 proofs implemented on the ML-level of Isabelle/HOL. Second, it covers cases |
2470 of binders depending on other binders, which just do not make sense for our |
2507 of binders depending on other binders, which just do not make sense for our |
2471 alpha-equated terms. Third, it allows empty types that have no meaning in a |
2508 alpha-equated terms (the corresponding @{text "fa"}-functions would not lift). |
|
2509 Third, it allows empty types that have no meaning in a |
2472 HOL-based theorem prover. We also had to generalise slightly Ott's binding |
2510 HOL-based theorem prover. We also had to generalise slightly Ott's binding |
2473 clauses. In Ott one specifies binding clauses with a single body; we allow |
2511 clauses. In Ott one specifies binding clauses with a single body; we allow |
2474 more than one. We have to do this, because this makes a difference for our |
2512 more than one. We have to do this, because this makes a difference for our |
2475 notion of alpha-equivalence in case of \isacommand{binds (set)} and |
2513 notion of alpha-equivalence in case of \isacommand{binds (set)} and |
2476 \isacommand{binds (set+)}. Consider the examples |
2514 \isacommand{binds (set+)}. Consider the examples |