494 \begin{property}\label{swapfreshfresh} |
495 \begin{property}\label{swapfreshfresh} |
495 @{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
496 @{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
496 \end{property} |
497 \end{property} |
497 |
498 |
498 While often the support of an object can be relatively easily |
499 While often the support of an object can be relatively easily |
499 described, for example\\[-6mm] |
500 described, for example for atoms, products, lists, function applications, |
|
501 booleans and permutations\\[-6mm] |
500 % |
502 % |
501 \begin{eqnarray} |
503 \begin{eqnarray} |
502 @{term "supp a"} & = & @{term "{a}"}\\ |
504 @{term "supp a"} & = & @{term "{a}"}\\ |
503 @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\ |
505 @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\ |
504 @{term "supp []"} & = & @{term "{}"}\\ |
506 @{term "supp []"} & = & @{term "{}"}\\ |
505 @{term "supp (x#xs)"} & = & @{term "supp x \<union> supp xs"}\\ |
507 @{term "supp (x#xs)"} & = & @{term "supp x \<union> supp xs"}\\ |
506 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp (f, x)"}\label{suppfun}\\ |
508 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\label{suppfun}\\ |
507 @{term "supp b"} & = & @{term "{}"}\\ |
509 @{term "supp b"} & = & @{term "{}"}\\ |
508 @{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"} |
510 @{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"} |
509 \end{eqnarray} |
511 \end{eqnarray} |
510 |
512 |
511 \noindent |
513 \noindent |
512 in some cases it can be difficult to establish the support precisely, and |
514 in some cases it can be difficult to characterise the support precisely, and |
513 only give an approximation (see \eqref{suppfun} above). Reasoning about |
515 only an approximation can be established (see \eqref{suppfun} above). Reasoning about |
514 such approximations can be made precise with the notion \emph{supports}, defined |
516 such approximations can be simplified with the notion \emph{supports}, defined |
515 as follows: |
517 as follows: |
516 |
518 |
517 \begin{defn} |
519 \begin{defn} |
518 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
520 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
519 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
521 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
535 \begin{equation}\label{equivariancedef} |
537 \begin{equation}\label{equivariancedef} |
536 @{term "\<forall>p. p \<bullet> f = f"} |
538 @{term "\<forall>p. p \<bullet> f = f"} |
537 \end{equation} |
539 \end{equation} |
538 |
540 |
539 \noindent or equivalently that a permutation applied to the application |
541 \noindent or equivalently that a permutation applied to the application |
540 @{text "f x"} can be moved to the argument @{text x}. That means we have for |
542 @{text "f x"} can be moved to the argument @{text x}. That means for equivariant |
541 all permutations @{text p} |
543 functions @{text f} we have for all permutations @{text p} |
542 % |
544 % |
543 \begin{equation}\label{equivariance} |
545 \begin{equation}\label{equivariance} |
544 @{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\; |
546 @{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\; |
545 @{text "p \<bullet> (f x) = f (p \<bullet> x)"} |
547 @{text "p \<bullet> (f x) = f (p \<bullet> x)"} |
546 \end{equation} |
548 \end{equation} |
569 \noindent |
571 \noindent |
570 The idea behind the second property is that given a finite set @{text as} |
572 The idea behind the second property is that given a finite set @{text as} |
571 of binders (being bound, or fresh, in @{text x} is ensured by the |
573 of binders (being bound, or fresh, in @{text x} is ensured by the |
572 assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text p} such that |
574 assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text p} such that |
573 the renamed binders @{term "p \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen |
575 the renamed binders @{term "p \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen |
574 as long as it is finitely supported) and also it does not affect anything |
576 as long as it is finitely supported) and also @{text "p"} does not affect anything |
575 in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last |
577 in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last |
576 fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
578 fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
577 @{text as} in @{text x}, because @{term "p \<bullet> x = x"}. |
579 @{text as} in @{text x}, because @{term "p \<bullet> x = x"}. |
578 |
580 |
579 All properties given in this section are formalised in Isabelle/HOL and also |
581 All properties given in this section are formalised in Isabelle/HOL and |
580 most of proofs are described in \cite{HuffmanUrban10} to which we refer the |
582 most of proofs are described in \cite{HuffmanUrban10} to which we refer the |
581 reader. In the next sections we will make extensively use of these |
583 reader. In the next sections we will make extensively use of these |
582 properties in order to define alpha-equivalence in the presence of multiple |
584 properties in order to define alpha-equivalence in the presence of multiple |
583 binders. |
585 binders. |
584 *} |
586 *} |
761 @{term "Abs_lst as x"} \hspace{5mm} |
763 @{term "Abs_lst as x"} \hspace{5mm} |
762 @{term "Abs_res as x"} |
764 @{term "Abs_res as x"} |
763 \end{center} |
765 \end{center} |
764 |
766 |
765 \noindent |
767 \noindent |
766 indicating that a set or list @{text as} is abstracted in @{text x}. We will |
768 indicating that a set (or list) @{text as} is abstracted in @{text x}. We will |
767 call the types \emph{abstraction types} and their elements |
769 call the types \emph{abstraction types} and their elements |
768 \emph{abstractions}. The important property we need to know is what the |
770 \emph{abstractions}. The important property we need to derive is what the |
769 support of abstractions is, namely: |
771 support of abstractions is, namely: |
770 |
772 |
771 \begin{thm}[Support of Abstractions]\label{suppabs} |
773 \begin{thm}[Support of Abstractions]\label{suppabs} |
772 Assuming @{text x} has finite support, then\\[-6mm] |
774 Assuming @{text x} has finite support, then\\[-6mm] |
773 \begin{center} |
775 \begin{center} |
849 |
851 |
850 \noindent |
852 \noindent |
851 since for finite sets, @{text "S"}, we have @{thm (concl) supp_finite_atom_set[no_vars]}. |
853 since for finite sets, @{text "S"}, we have @{thm (concl) supp_finite_atom_set[no_vars]}. |
852 |
854 |
853 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes of |
855 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes of |
854 Theorem~\ref{suppabs}. This theorem gives us confidence that our |
856 Theorem~\ref{suppabs}. The method of first considering abstractions of the |
855 abstractions behave as one expects. To consider first abstractions of the |
857 form @{term "Abs as x"} etc is motivated by the fact that properties about them |
856 form @{term "Abs as x"} is motivated by the fact that properties about them |
858 can be conveninetly established at the Isabelle/HOL level. It would be |
857 can be conveninetly established at the Isabelle/HOL level. But we can also |
859 difficult to write custom ML-code that derives automatically such properties |
858 use when we deal with binding in our term-calculi specifications. |
860 for every term-constructor that binds some atoms. Also the generality of |
|
861 the definitions for alpha-equivalence will also help us in the next section. |
859 *} |
862 *} |
860 |
863 |
861 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *} |
864 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *} |
862 |
865 |
863 text {* |
866 text {* |
901 \begin{center} |
904 \begin{center} |
902 @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$ @{text "binding_clauses"} |
905 @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$ @{text "binding_clauses"} |
903 \end{center} |
906 \end{center} |
904 |
907 |
905 \noindent |
908 \noindent |
906 whereby some of the @{text ty}$'_{1..l}$ (or their components) are contained in the collection |
909 whereby some of the @{text ty}$'_{1..l}$ (or their components) are contained |
907 of @{text ty}$^\alpha_{1..n}$ declared in \eqref{scheme}. In this case we will call the |
910 in the collection of @{text ty}$^\alpha_{1..n}$ declared in |
908 corresponding argument a \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The labels annotated on |
911 \eqref{scheme}. In this case we will call the corresponding argument a |
909 the types are optional. Their purpose is to be used in the (possibly empty) list of |
912 \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. There are ``positivity'' |
910 \emph{binding clauses}, which indicate the binders and their scope |
913 restrictions imposed in the type of such recursive arguments, which ensure |
911 in a term-constructor. They come in three \emph{modes}: |
914 that the type has a set-theoretic semantics \cite{Berghofer99}. The labels |
912 |
915 annotated on the types are optional. Their purpose is to be used in the |
|
916 (possibly empty) list of \emph{binding clauses}, which indicate the binders |
|
917 and their scope in a term-constructor. They come in three \emph{modes}: |
913 |
918 |
914 \begin{center} |
919 \begin{center} |
915 \begin{tabular}{l} |
920 \begin{tabular}{l} |
916 \isacommand{bind}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
921 \isacommand{bind}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
917 \isacommand{bind\_set}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
922 \isacommand{bind\_set}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
918 \isacommand{bind\_res}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
923 \isacommand{bind\_res}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
919 \end{tabular} |
924 \end{tabular} |
920 \end{center} |
925 \end{center} |
921 |
926 |
922 \noindent |
927 \noindent |
923 The first mode is for binding lists of atoms (the order of binders matters); the second is for sets |
928 The first mode is for binding lists of atoms (the order of binders matters); |
924 of binders (the order does not matter, but the cardinality does) and the last is for |
929 the second is for sets of binders (the order does not matter, but the |
925 sets of binders (with vacuous binders preserving alpha-equivalence). |
930 cardinality does) and the last is for sets of binders (with vacuous binders |
|
931 preserving alpha-equivalence). The ``\isacommand{in}-part'' of a binding |
|
932 clause will be called the \emph{body} of the abstraction; the |
|
933 ``\isacommand{bind}-part'' will be the \emph{binder} of the binding clause. |
926 |
934 |
927 In addition we distinguish between \emph{shallow} and \emph{deep} |
935 In addition we distinguish between \emph{shallow} and \emph{deep} |
928 binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; |
936 binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; |
929 \isacommand{in}\; {\it label'} (similar for the other two modes). The |
937 \isacommand{in}\; {\it label'} (similar for the other two modes). The |
930 restriction we impose on shallow binders is that the {\it label} must either |
938 restriction we impose on shallow binders is that the {\it label} must either |
1032 |
1040 |
1033 \end{tabular} |
1041 \end{tabular} |
1034 \end{center} |
1042 \end{center} |
1035 |
1043 |
1036 \noindent |
1044 \noindent |
1037 In the first case we bind all atoms from the pattern @{text p} in @{text t} |
1045 In the first case we might bind all atoms from the pattern @{text p} in @{text t} |
1038 and also all atoms from @{text q} in @{text t}. As a result we have no way |
1046 and also all atoms from @{text q} in @{text t}. As a result we have no way |
1039 to determine whether the binder came from the binding function @{text |
1047 to determine whether the binder came from the binding function @{text |
1040 "bn(p)"} or @{text "bn(q)"}. Similarly in the second case. The reason why |
1048 "bn(p)"} or @{text "bn(q)"}. Similarly in the second case. The reason why |
1041 we must exclude such specifications is that they cannot be represent by |
1049 we must exclude such specifications is that they cannot be represent by |
1042 the general binders described in Section \ref{sec:binders}. However |
1050 the general binders described in Section \ref{sec:binders}. However |
1079 \end{tabular}} |
1087 \end{tabular}} |
1080 \end{equation} |
1088 \end{equation} |
1081 |
1089 |
1082 \noindent |
1090 \noindent |
1083 The difference is that with @{text Let} we only want to bind the atoms @{text |
1091 The difference is that with @{text Let} we only want to bind the atoms @{text |
1084 "bn(a)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms |
1092 "bn(as)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms |
1085 inside the assignment. This difference has consequences for the free-variable |
1093 inside the assignment. This difference has consequences for the free-variable |
1086 function and alpha-equivalence relation, which we are going to describe in the |
1094 function and alpha-equivalence relation, which we are going to describe in the |
1087 rest of this section. |
1095 rest of this section. |
1088 |
1096 |
1089 Having dealt with all syntax matters, the problem now is how we can turn |
1097 Having dealt with all syntax matters, the problem now is how we can turn |
1098 |
1106 |
1099 |
1107 |
1100 The datatype definition can be obtained by stripping off the |
1108 The datatype definition can be obtained by stripping off the |
1101 binding clauses and the labels on the types. We also have to invent |
1109 binding clauses and the labels on the types. We also have to invent |
1102 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
1110 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
1103 given by user. In our implementation we just use the affix @{text "_raw"}. |
1111 given by user. In our implementation we just use the affix ``@{text "_raw"}''. |
1104 But for the purpose of this paper, we just use the superscript @{text "_\<^sup>\<alpha>"} to indicate |
1112 But for the purpose of this paper, we just use the superscript @{text "_\<^sup>\<alpha>"} to indicate |
1105 that a notion is defined over alpha-equivalence classes and leave it out |
1113 that a notion is defined over alpha-equivalence classes and leave it out |
1106 for the corresponding notion defined on the ``raw'' level. So for example |
1114 for the corresponding notion defined on the ``raw'' level. So for example |
1107 we have |
1115 we have |
1108 |
1116 |
1109 \begin{center} |
1117 \begin{center} |
1110 @{text "ty\<^sup>\<alpha> \<mapsto> ty"} \hspace{2mm}and\hspace{2mm} @{text "C\<^sup>\<alpha> \<mapsto> C"} |
1118 @{text "ty\<^sup>\<alpha> \<mapsto> ty"} \hspace{2mm}and\hspace{2mm} @{text "C\<^sup>\<alpha> \<mapsto> C"} |
1111 \end{center} |
1119 \end{center} |
1112 |
1120 |
1113 \noindent |
1121 \noindent |
1114 where the type @{term ty} is the type used in the quotient construction for |
1122 where @{term ty} is the type used in the quotient construction for |
1115 @{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor on the ``raw'' type @{text "ty"}. |
1123 @{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor on the ``raw'' type @{text "ty"}. |
1116 |
1124 |
1117 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1125 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1118 non-empty and the types in the constructors only occur in positive |
1126 non-empty and the types in the constructors only occur in positive |
1119 position (see \cite{Berghofer99} for an indepth description of the datatype package |
1127 position (see \cite{Berghofer99} for an indepth description of the datatype package |
1120 in Isabelle/HOL). We then define the user-specified binding |
1128 in Isabelle/HOL). We then define the user-specified binding |
1121 functions, called @{term "bn_ty"}, by primitive recursion over the corresponding |
1129 functions, called @{term "bn"}, by primitive recursion over the corresponding |
1122 raw datatype @{text ty}. We can also easily define permutation operations by |
1130 raw datatype. We can also easily define permutation operations by |
1123 primitive recursion so that for each term constructor @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"} |
1131 primitive recursion so that for each term constructor @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"} |
1124 we have that |
1132 we have that |
1125 |
1133 |
1126 \begin{center} |
1134 \begin{center} |
1127 @{text "p \<bullet> (C x\<^isub>1 \<dots> x\<^isub>n) = C (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"} |
1135 @{text "p \<bullet> (C x\<^isub>1 \<dots> x\<^isub>n) = C (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"} |
1142 \end{center} |
1150 \end{center} |
1143 |
1151 |
1144 \noindent |
1152 \noindent |
1145 We define them together with auxiliary free-variable functions for |
1153 We define them together with auxiliary free-variable functions for |
1146 the binding functions. Given binding functions |
1154 the binding functions. Given binding functions |
1147 @{text "bn_ty\<^isub>1 \<dots> bn_ty\<^isub>m"} we need to define |
1155 @{text "bn\<^isub>1 \<dots> bn\<^isub>m"} we need to define |
1148 % |
1156 % |
1149 \begin{center} |
1157 \begin{center} |
1150 @{text "fv_bn_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_bn_ty\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"} |
1158 @{text "fv_bn\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_bn\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"} |
1151 \end{center} |
1159 \end{center} |
1152 |
1160 |
1153 \noindent |
1161 \noindent |
1154 The reason for this setup is that in a deep binder not all atoms have to be |
1162 The reason for this setup is that in a deep binder not all atoms have to be |
1155 bound, as we shall see in an example below. While the idea behind these |
1163 bound, as we shall see in an example below. We need therefore the function |
|
1164 that returns us those unbound atoms. |
|
1165 |
|
1166 While the idea behind these |
1156 free-variable functions is clear (they just collect all atoms that are not bound), |
1167 free-variable functions is clear (they just collect all atoms that are not bound), |
1157 because of the rather complicated binding mechanisms their definitions are |
1168 because of the rather complicated binding mechanisms their definitions are |
1158 somewhat involved. |
1169 somewhat involved. |
1159 |
|
1160 Given a term-constructor @{text "C"} of type @{text ty} with argument types |
1170 Given a term-constructor @{text "C"} of type @{text ty} with argument types |
1161 \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function |
1171 \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function |
1162 @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values |
1172 @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values |
1163 calculated next for each argument. |
1173 calculated next for each argument. |
1164 First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, |
1174 First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, |
1167 non-recursive binder. |
1177 non-recursive binder. |
1168 |
1178 |
1169 \begin{center} |
1179 \begin{center} |
1170 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1180 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1171 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1181 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1172 $\bullet$ & @{text "fv_bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
1182 $\bullet$ & @{text "fv_bn x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
1173 non-recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"}\\ |
1183 non-recursive binder with the auxiliary binding function @{text "bn"}\\ |
1174 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is |
1184 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn x\<^isub>i"} provided @{text "x\<^isub>i"} is |
1175 a deep recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"} |
1185 a deep recursive binder with the auxiliary binding function @{text "bn"} |
1176 \end{tabular} |
1186 \end{tabular} |
1177 \end{center} |
1187 \end{center} |
1178 |
1188 |
1179 \noindent |
1189 \noindent |
1180 The first clause states that shallow binders do not contribute to the |
1190 The first clause states that shallow binders do not contribute to the |
1181 free variables; in the second clause, we have to collect all |
1191 free variables; in the second clause, we have to collect all |
1182 variables that are left unbound by the binding function @{text "bn_ty\<^isub>i"}---this |
1192 variables that are left unbound by the binding function @{text "bn"}---this |
1183 is done with function @{text "fv_bn_ty\<^isub>i"}; in the third clause, since the |
1193 is done with function @{text "fv_bn"}; in the third clause, since the |
1184 binder is recursive, we need to bind all variables specified by |
1194 binder is recursive, we need to bind all variables specified by |
1185 @{text "bn_ty\<^isub>i"}---therefore we subtract @{text "bn_ty\<^isub>i x\<^isub>i"} from the free |
1195 @{text "bn"}---therefore we subtract @{text "bn x\<^isub>i"} from the free |
1186 variables of @{text "x\<^isub>i"}. |
1196 variables of @{text "x\<^isub>i"}. |
1187 |
1197 |
1188 In case the argument is \emph{not} a binder, we need to consider |
1198 In case the argument is \emph{not} a binder, we need to consider |
1189 whether the @{text "x\<^isub>i"} is the body of one or more binding clauses. |
1199 whether the @{text "x\<^isub>i"} is the body of one or more binding clauses. |
1190 In this case we first calculate the set @{text "bnds"} as follows: |
1200 In this case we first calculate the set @{text "bnds"} as follows: |
1215 The last case we need to consider is when @{text "x\<^isub>i"} is neither |
1225 The last case we need to consider is when @{text "x\<^isub>i"} is neither |
1216 a binder nor a body of an abstraction. In this case it is defined |
1226 a binder nor a body of an abstraction. In this case it is defined |
1217 as in \eqref{deepbody}, except that we do not need to subtract the |
1227 as in \eqref{deepbody}, except that we do not need to subtract the |
1218 set @{text bnds}. |
1228 set @{text bnds}. |
1219 |
1229 |
1220 Next, we need to define a free-variable function @{text "fv_bn_ty\<^isub>i"} for |
1230 Next, we need to define a free-variable function @{text "fv_bn\<^isub>j"} for |
1221 each binding function @{text "bn_ty\<^isub>i"}. The idea behind this |
1231 each binding function @{text "bn\<^isub>j"}. The idea behind this |
1222 function is to compute the set of free atoms that are not bound by |
1232 function is to compute the set of free atoms that are not bound by |
1223 @{text "bn_ty\<^isub>i"}. Because of the restrictions we imposed on the |
1233 @{text "bn\<^isub>j"}. Because of the restrictions we imposed on the |
1224 form of binding functions, this can be done automatically by recursively |
1234 form of binding functions, this can be done automatically by recursively |
1225 building up the the set of free variables from the arguments that are |
1235 building up the the set of free variables from the arguments that are |
1226 not bound. Let us assume one clause of the binding function is |
1236 not bound. Let us assume one clause of the binding function is |
1227 @{text "bn_ty\<^isub>i (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn_ty\<^isub>i"} is the |
1237 @{text "bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn\<^isub>j"} is the |
1228 union of the values calculated for @{text "x\<^isub>j"} of type @{text "ty\<^isub>j"} |
1238 union of the values calculated for @{text "x\<^isub>i"} of type @{text "ty\<^isub>i"} |
1229 as follows: |
1239 as follows: |
1230 |
1240 |
1231 \begin{center} |
1241 \begin{center} |
1232 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1242 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1233 \multicolumn{2}{l}{@{text "x\<^isub>j"} occurs in @{text "rhs"}:}\\ |
1243 \multicolumn{2}{l}{@{text "x\<^isub>i"} occurs in @{text "rhs"}:}\\ |
1234 $\bullet$ & @{term "{}"} provided @{term "x\<^isub>j"} is a single atom, |
1244 $\bullet$ & @{term "{}"} provided @{term "x\<^isub>i"} is a single atom, |
1235 atom list or atom set\\ |
1245 atom list or atom set\\ |
1236 $\bullet$ & @{text "fv_bn_ty\<^isub>j x\<^isub>j"} in case @{text "rhs"} contains the |
1246 $\bullet$ & @{text "fv_bn x\<^isub>i"} in case @{text "rhs"} contains the |
1237 recursive call @{text "bn_ty\<^isub>j x\<^isub>j"}\\[1mm] |
1247 recursive call @{text "bn x\<^isub>i"}\\[1mm] |
1238 % |
1248 % |
1239 \multicolumn{2}{l}{@{text "x\<^isub>j"} does not occur in @{text "rhs"}:}\\ |
1249 \multicolumn{2}{l}{@{text "x\<^isub>i"} does not occur in @{text "rhs"}:}\\ |
1240 $\bullet$ & @{text "atoms x\<^isub>j"} provided @{term "x\<^isub>j"} is a set of atoms\\ |
1250 $\bullet$ & @{text "atoms x\<^isub>i"} provided @{term "x\<^isub>i"} is a set of atoms\\ |
1241 $\bullet$ & @{term "atoms (set x\<^isub>j)"} provided @{term "x\<^isub>j"} is a list of atoms\\ |
1251 $\bullet$ & @{term "atoms (set x\<^isub>i)"} provided @{term "x\<^isub>i"} is a list of atoms\\ |
1242 $\bullet$ & @{text "fv_ty\<^isub>j x\<^isub>j"} provided @{term "ty\<^isub>j"} is one of the raw |
1252 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i"} provided @{term "ty\<^isub>i"} is one of the raw |
1243 types corresponding to the types specified by the user\\ |
1253 types corresponding to the types specified by the user\\ |
1244 % $\bullet$ & @{text "fv_ty\<^isup>\<alpha> x\<^isub>j - bnds"} provided @{term "x\<^isub>j"} is not in @{text "rhs"} |
1254 % $\bullet$ & @{text "fv_ty\<^isup>\<alpha> x\<^isub>i - bnds"} provided @{term "x\<^isub>i"} is not in @{text "rhs"} |
1245 % and is an existing nominal datatype with the free-variable function @{text "fv\<^isup>\<alpha>"}\\ |
1255 % and is an existing nominal datatype with the free-variable function @{text "fv\<^isup>\<alpha>"}\\ |
1246 $\bullet$ & @{term "{}"} otherwise |
1256 $\bullet$ & @{term "{}"} otherwise |
1247 \end{tabular} |
1257 \end{tabular} |
1248 \end{center} |
1258 \end{center} |
1249 |
1259 |
1575 section {* Adequacy *} |
1585 section {* Adequacy *} |
1576 |
1586 |
1577 section {* Related Work *} |
1587 section {* Related Work *} |
1578 |
1588 |
1579 text {* |
1589 text {* |
1580 The earliest usage we know of general binders in a theorem prover setting is |
1590 To our knowledge the earliest usage of general binders in a theorem prover setting is |
1581 in the paper \cite{NaraschewskiNipkow99}, which describes a formalisation of |
1591 in the paper \cite{NaraschewskiNipkow99}, which describes a formalisation of |
1582 the algorithm W. This formalisation implements binding in type schemes using a |
1592 the algorithm W. This formalisation implements binding in type schemes using a |
1583 a de-Bruijn indices representation. Also recently an extension for general binders |
1593 a de-Bruijn indices representation. Also recently an extension for general binders |
1584 has been proposed for the locally nameless approach to binding \cite{chargueraud09}. . |
1594 has been proposed for the locally nameless approach to binding \cite{chargueraud09}. . |
1585 But we have not yet seen it to be employed in a non-trivial formal verification. |
1595 But we have not yet seen it to be employed in a non-trivial formal verification. |