| changeset 1737 | 8b6a285ad480 | 
| parent 1736 | ba66fa116e05 | 
| child 1739 | 468c3c1adcba | 
| 1736:ba66fa116e05 | 1737:8b6a285ad480 | 
|---|---|
| 576 as long as it is finitely supported) and also @{text "p"} does not affect anything | 576 as long as it is finitely supported) and also @{text "p"} does not affect anything | 
| 577 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 | 
| 578 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 | 
| 579 @{text as} in @{text x}, because @{term "p \<bullet> x = x"}. | 579 @{text as} in @{text x}, because @{term "p \<bullet> x = x"}. | 
| 580 | 580 | 
| 581 All properties given in this section are formalised in Isabelle/HOL and | 581 Most properties given in this section are described in \cite{HuffmanUrban10} | 
| 582 most of proofs are described in \cite{HuffmanUrban10} to which we refer the | 582 and of course all are formalised in Isabelle/HOL. In the next sections we will make | 
| 583 reader. In the next sections we will make extensively use of these | 583 extensively use of these properties in order to define alpha-equivalence in | 
| 584 properties in order to define alpha-equivalence in the presence of multiple | 584 the presence of multiple binders. | 
| 585 binders. | |
| 586 *} | 585 *} | 
| 587 | 586 | 
| 588 | 587 | 
| 589 section {* General Binders\label{sec:binders} *} | 588 section {* General Binders\label{sec:binders} *} | 
| 590 | 589 | 
| 765 \end{center} | 764 \end{center} | 
| 766 | 765 | 
| 767 \noindent | 766 \noindent | 
| 768 indicating that a set (or list) @{text as} is abstracted in @{text x}. We will | 767 indicating that a set (or list) @{text as} is abstracted in @{text x}. We will | 
| 769 call the types \emph{abstraction types} and their elements | 768 call the types \emph{abstraction types} and their elements | 
| 770 \emph{abstractions}. The important property we need to derive is what the | 769 \emph{abstractions}. The important property we need to derive the support of | 
| 771 support of abstractions is, namely: | 770 abstractions, namely: | 
| 772 | 771 | 
| 773 \begin{thm}[Support of Abstractions]\label{suppabs} | 772 \begin{thm}[Support of Abstractions]\label{suppabs} | 
| 774 Assuming @{text x} has finite support, then\\[-6mm] | 773 Assuming @{text x} has finite support, then\\[-6mm] | 
| 775 \begin{center} | 774 \begin{center} | 
| 776 \begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l} | 775 \begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l} | 
| 823 | 822 | 
| 824 \noindent | 823 \noindent | 
| 825 which by Property~\ref{supportsprop} gives us ``one half'' of | 824 which by Property~\ref{supportsprop} gives us ``one half'' of | 
| 826 Thm~\ref{suppabs}. The ``other half'' is a bit more involved. To establish | 825 Thm~\ref{suppabs}. The ``other half'' is a bit more involved. To establish | 
| 827 it, we use a trick from \cite{Pitts04} and first define an auxiliary | 826 it, we use a trick from \cite{Pitts04} and first define an auxiliary | 
| 828 function taking an abstraction as argument: | 827 function @{text aux}, taking an abstraction as argument: | 
| 829 % | 828 % | 
| 830 \begin{center} | 829 \begin{center} | 
| 831 @{thm supp_gen.simps[THEN eq_reflection, no_vars]} | 830 @{thm supp_gen.simps[THEN eq_reflection, no_vars]} | 
| 832 \end{center} | 831 \end{center} | 
| 833 | 832 | 
| 848 \begin{equation}\label{halftwo} | 847 \begin{equation}\label{halftwo} | 
| 849 @{thm (concl) supp_abs_subset1(1)[no_vars]} | 848 @{thm (concl) supp_abs_subset1(1)[no_vars]} | 
| 850 \end{equation} | 849 \end{equation} | 
| 851 | 850 | 
| 852 \noindent | 851 \noindent | 
| 853 since for finite sets, @{text "S"}, we have @{thm (concl) supp_finite_atom_set[no_vars]}. | 852 since for finite sets of atoms, @{text "bs"}, we have | 
| 854 | 853 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. | 
| 855 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes of | 854 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes | 
| 856 Theorem~\ref{suppabs}. The method of first considering abstractions of the | 855 Theorem~\ref{suppabs}. | 
| 856 | |
| 857 The method of first considering abstractions of the | |
| 857 form @{term "Abs as x"} etc is motivated by the fact that properties about them | 858 form @{term "Abs as x"} etc is motivated by the fact that properties about them | 
| 858 can be conveninetly established at the Isabelle/HOL level. It would be | 859 can be conveninetly established at the Isabelle/HOL level. It would be | 
| 859 difficult to write custom ML-code that derives automatically such properties | 860 difficult to write custom ML-code that derives automatically such properties | 
| 860 for every term-constructor that binds some atoms. Also the generality of | 861 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. | 862 the definitions for alpha-equivalence will help us in the next section. | 
| 862 *} | 863 *} | 
| 863 | 864 | 
| 864 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *} | 865 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *} | 
| 865 | 866 | 
| 866 text {* | 867 text {* | 
| 904 \begin{center} | 905 \begin{center} | 
| 905 @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$ @{text "binding_clauses"} | 906 @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$ @{text "binding_clauses"} | 
| 906 \end{center} | 907 \end{center} | 
| 907 | 908 | 
| 908 \noindent | 909 \noindent | 
| 909 whereby some of the @{text ty}$'_{1..l}$ (or their components) are contained | 910 whereby some of the @{text ty}$'_{1..l}$ (or their components) might be contained | 
| 910 in the collection of @{text ty}$^\alpha_{1..n}$ declared in | 911 in the collection of @{text ty}$^\alpha_{1..n}$ declared in | 
| 911 \eqref{scheme}. In this case we will call the corresponding argument a | 912 \eqref{scheme}. | 
| 912 \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. There are ``positivity'' | 913 %In this case we will call the corresponding argument a | 
| 913 restrictions imposed in the type of such recursive arguments, which ensure | 914 %\emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such recursive | 
| 914 that the type has a set-theoretic semantics \cite{Berghofer99}. The labels | 915 %arguments need to satisfy a ``positivity'' | 
| 916 %restriction, which ensures that the type has a set-theoretic semantics | |
| 917 %\cite{Berghofer99}. | |
| 918 The labels | |
| 915 annotated on the types are optional. Their purpose is to be used in the | 919 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 | 920 (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}: | 921 and their scope in a term-constructor. They come in three \emph{modes}: | 
| 918 | 922 | 
| 919 \begin{center} | 923 \begin{center} | 
| 927 \noindent | 931 \noindent | 
| 928 The first mode is for binding lists of atoms (the order of binders matters); | 932 The first mode is for binding lists of atoms (the order of binders matters); | 
| 929 the second is for sets of binders (the order does not matter, but the | 933 the second is for sets of binders (the order does not matter, but the | 
| 930 cardinality does) and the last is for sets of binders (with vacuous binders | 934 cardinality does) and the last is for sets of binders (with vacuous binders | 
| 931 preserving alpha-equivalence). The ``\isacommand{in}-part'' of a binding | 935 preserving alpha-equivalence). The ``\isacommand{in}-part'' of a binding | 
| 932 clause will be called the \emph{body} of the abstraction; the | 936 clause will be called the \emph{body}; the | 
| 933 ``\isacommand{bind}-part'' will be the \emph{binder} of the binding clause. | 937 ``\isacommand{bind}-part'' will be the \emph{binder}. | 
| 934 | 938 | 
| 935 In addition we distinguish between \emph{shallow} and \emph{deep} | 939 In addition we distinguish between \emph{shallow} and \emph{deep} | 
| 936 binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; | 940 binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; | 
| 937 \isacommand{in}\; {\it label'} (similar for the other two modes). The | 941 \isacommand{in}\; {\it label'} (similar for the other two modes). The | 
| 938 restriction we impose on shallow binders is that the {\it label} must either | 942 restriction we impose on shallow binders is that the {\it label} must either | 
| 984 call such binders \emph{recursive}, see below). | 988 call such binders \emph{recursive}, see below). | 
| 985 The corresponding binding functions are expected to return either a set of atoms | 989 The corresponding binding functions are expected to return either a set of atoms | 
| 986 (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms | 990 (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms | 
| 987 (for \isacommand{bind}). They can be defined by primitive recursion over the | 991 (for \isacommand{bind}). They can be defined by primitive recursion over the | 
| 988 corresponding type; the equations must be given in the binding function part of | 992 corresponding type; the equations must be given in the binding function part of | 
| 989 the scheme shown in \eqref{scheme}. For example a term-calculus containing lets | 993 the scheme shown in \eqref{scheme}. For example a term-calculus containing @{text "Let"}s | 
| 990 with tuple patterns might be specified as: | 994 with tuple patterns might be specified as: | 
| 991 | 995 | 
| 992 \begin{center} | 996 \begin{center} | 
| 993 \begin{tabular}{l} | 997 \begin{tabular}{l} | 
| 994 \isacommand{nominal\_datatype} @{text trm} =\\ | 998 \isacommand{nominal\_datatype} @{text trm} =\\ | 
| 1064 \noindent | 1068 \noindent | 
| 1065 since there is no overlap of binders. | 1069 since there is no overlap of binders. | 
| 1066 | 1070 | 
| 1067 Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}. | 1071 Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}. | 
| 1068 Whenever such a binding clause is present, we will call the binder \emph{recursive}. | 1072 Whenever such a binding clause is present, we will call the binder \emph{recursive}. | 
| 1069 To see the purpose for such recursive binders, compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s: | 1073 To see the purpose of such recursive binders, compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s | 
| 1074 in the following specification: | |
| 1070 % | 1075 % | 
| 1071 \begin{equation}\label{letrecs} | 1076 \begin{equation}\label{letrecs} | 
| 1072 \mbox{% | 1077 \mbox{% | 
| 1073 \begin{tabular}{@ {}l@ {}} | 1078 \begin{tabular}{@ {}l@ {}} | 
| 1074 \isacommand{nominal\_datatype}~@{text "trm ="}\\ | 1079 \isacommand{nominal\_datatype}~@{text "trm ="}\\ | 
| 1159 \end{center} | 1164 \end{center} | 
| 1160 | 1165 | 
| 1161 \noindent | 1166 \noindent | 
| 1162 The reason for this setup is that in a deep binder not all atoms have to be | 1167 The reason for this setup is that in a deep binder not all atoms have to be | 
| 1163 bound, as we shall see in an example below. We need therefore the function | 1168 bound, as we shall see in an example below. We need therefore the function | 
| 1164 that returns us those unbound atoms. | 1169 that calculates those unbound atoms. | 
| 1165 | 1170 | 
| 1166 While the idea behind these | 1171 While the idea behind these | 
| 1167 free-variable functions is clear (they just collect all atoms that are not bound), | 1172 free-variable functions is clear (they just collect all atoms that are not bound), | 
| 1168 because of the rather complicated binding mechanisms their definitions are | 1173 because of the rather complicated binding mechanisms their definitions are | 
| 1169 somewhat involved. | 1174 somewhat involved. | 
| 1170 Given a term-constructor @{text "C"} of type @{text ty} with argument types | 1175 Given a term-constructor @{text "C"} of type @{text ty} with argument types | 
| 1171 \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function | 1176 \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function | 
| 1172 @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values | 1177 @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values | 
| 1173 calculated next for each argument. | 1178 calculated below for each argument. | 
| 1174 First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, | 1179 First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, | 
| 1175 we can determine whether the argument is a shallow or deep | 1180 we can determine whether the argument is a shallow or deep | 
| 1176 binder, and in the latter case also whether it is a recursive or | 1181 binder, and in the latter case also whether it is a recursive or | 
| 1177 non-recursive binder. | 1182 non-recursive binder. | 
| 1178 | 1183 | 
| 1199 whether the @{text "x\<^isub>i"} is the body of one or more binding clauses. | 1204 whether the @{text "x\<^isub>i"} is the body of one or more binding clauses. | 
| 1200 In this case we first calculate the set @{text "bnds"} as follows: | 1205 In this case we first calculate the set @{text "bnds"} as follows: | 
| 1201 either the corresponding binders are all shallow or there is a single deep binder. | 1206 either the corresponding binders are all shallow or there is a single deep binder. | 
| 1202 In the former case we take @{text bnds} to be the union of all shallow | 1207 In the former case we take @{text bnds} to be the union of all shallow | 
| 1203 binders; in the latter case, we just take the set of atoms specified by the | 1208 binders; in the latter case, we just take the set of atoms specified by the | 
| 1204 binding function. The value for @{text "x\<^isub>i"} is then given by: | 1209 corrsponding binding function. The value for @{text "x\<^isub>i"} is then given by: | 
| 1205 | 1210 % | 
| 1206 \begin{equation}\label{deepbody} | 1211 \begin{equation}\label{deepbody} | 
| 1207 \mbox{% | 1212 \mbox{% | 
| 1208 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} | 1213 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} | 
| 1209 $\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ | 1214 $\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ | 
| 1210 $\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ | 1215 $\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ | 
| 1216 $\bullet$ & @{term "{}"} otherwise | 1221 $\bullet$ & @{term "{}"} otherwise | 
| 1217 \end{tabular}} | 1222 \end{tabular}} | 
| 1218 \end{equation} | 1223 \end{equation} | 
| 1219 | 1224 | 
| 1220 \noindent | 1225 \noindent | 
| 1221 Like the coercion function @{text atom} used above, @{text "atoms as"} coerces | 1226 Like the coercion function @{text atom} used earlier, @{text "atoms as"} coerces | 
| 1222 the set @{text as} to the generic atom type. | 1227 the set @{text as} to the generic atom type. | 
| 1223 It is defined as @{text "atom as \<equiv> {atom a | a \<in> as}"}. | 1228 It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}. | 
| 1224 | 1229 | 
| 1225 The last case we need to consider is when @{text "x\<^isub>i"} is neither | 1230 The last case we need to consider is when @{text "x\<^isub>i"} is neither | 
| 1226 a binder nor a body of an abstraction. In this case it is defined | 1231 a binder nor a body of an abstraction. In this case it is defined | 
| 1227 as in \eqref{deepbody}, except that we do not need to subtract the | 1232 as in \eqref{deepbody}, except that we do not need to subtract the | 
| 1228 set @{text bnds}. | 1233 set @{text bnds}. | 
| 1229 | 1234 | 
| 1230 Next, we need to define a free-variable function @{text "fv_bn\<^isub>j"} for | 1235 Next, we need to define a free-variable function @{text "fv_bn\<^isub>j"} for | 
| 1231 each binding function @{text "bn\<^isub>j"}. The idea behind this | 1236 each binding function @{text "bn\<^isub>j"}. The idea behind these | 
| 1232 function is to compute the set of free atoms that are not bound by | 1237 functions is to compute the set of free atoms that are not bound by | 
| 1233 @{text "bn\<^isub>j"}. Because of the restrictions we imposed on the | 1238 @{text "bn\<^isub>j"}. Because of the restrictions we imposed on the | 
| 1234 form of binding functions, this can be done automatically by recursively | 1239 form of binding functions, this can be done automatically by recursively | 
| 1235 building up the the set of free variables from the arguments that are | 1240 building up the the set of free variables from the arguments that are | 
| 1236 not bound. Let us assume one clause of the binding function is | 1241 not bound. Let us assume one clause of a binding function is | 
| 1237 @{text "bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn\<^isub>j"} is the | 1242 @{text "bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn\<^isub>j"} is the | 
| 1238 union of the values calculated for @{text "x\<^isub>i"} of type @{text "ty\<^isub>i"} | 1243 union of the values calculated for @{text "x\<^isub>i"} of type @{text "ty\<^isub>i"} | 
| 1239 as follows: | 1244 as follows: | 
| 1240 | 1245 | 
| 1241 \begin{center} | 1246 \begin{center} | 
| 1243 \multicolumn{2}{l}{@{text "x\<^isub>i"} occurs in @{text "rhs"}:}\\ | 1248 \multicolumn{2}{l}{@{text "x\<^isub>i"} occurs in @{text "rhs"}:}\\ | 
| 1244 $\bullet$ & @{term "{}"} provided @{term "x\<^isub>i"} is a single atom, | 1249 $\bullet$ & @{term "{}"} provided @{term "x\<^isub>i"} is a single atom, | 
| 1245 atom list or atom set\\ | 1250 atom list or atom set\\ | 
| 1246 $\bullet$ & @{text "fv_bn x\<^isub>i"} in case @{text "rhs"} contains the | 1251 $\bullet$ & @{text "fv_bn x\<^isub>i"} in case @{text "rhs"} contains the | 
| 1247 recursive call @{text "bn x\<^isub>i"}\medskip\\ | 1252 recursive call @{text "bn x\<^isub>i"}\medskip\\ | 
| 1248 % | 1253 \end{tabular} | 
| 1254 \end{center} | |
| 1255 | |
| 1256 \begin{center} | |
| 1257 \begin{tabular}{c@ {\hspace{2mm}}p{7cm}} | |
| 1249 \multicolumn{2}{l}{@{text "x\<^isub>i"} does not occur in @{text "rhs"}:}\\ | 1258 \multicolumn{2}{l}{@{text "x\<^isub>i"} does not occur in @{text "rhs"}:}\\ | 
| 1250 $\bullet$ & @{text "atom x\<^isub>i"} provided @{term "x\<^isub>i"} is an atom\\ | 1259 $\bullet$ & @{text "atom x\<^isub>i"} provided @{term "x\<^isub>i"} is an atom\\ | 
| 1251 $\bullet$ & @{text "atoms x\<^isub>i"} provided @{term "x\<^isub>i"} is a set of atoms\\ | 1260 $\bullet$ & @{text "atoms x\<^isub>i"} provided @{term "x\<^isub>i"} is a set of atoms\\ | 
| 1252 $\bullet$ & @{term "atoms (set x\<^isub>i)"} provided @{term "x\<^isub>i"} is a list of atoms\\ | 1261 $\bullet$ & @{term "atoms (set x\<^isub>i)"} provided @{term "x\<^isub>i"} is a list of atoms\\ | 
| 1253 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i"} provided @{term "ty\<^isub>i"} is one of the raw | 1262 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i"} provided @{term "ty\<^isub>i"} is one of the raw | 
| 1258 \end{tabular} | 1267 \end{tabular} | 
| 1259 \end{center} | 1268 \end{center} | 
| 1260 | 1269 | 
| 1261 \noindent | 1270 \noindent | 
| 1262 To see how these definitions work in practise, let us reconsider the term-constructors | 1271 To see how these definitions work in practise, let us reconsider the term-constructors | 
| 1263 @{text "Let"} and @{text "Let_rec"} from example shown in \eqref{letrecs}. | 1272 @{text "Let"} and @{text "Let_rec"} from the example shown in \eqref{letrecs}. | 
| 1264 For this specification we need to define three functions, namely | 1273 For this specification we need to define three free-variable functions, namely | 
| 1265 @{text "fv\<^bsub>trm\<^esub>"}, @{text "fv\<^bsub>assn\<^esub>"} and @{text "fv\<^bsub>bn\<^esub>"}. They are as follows: | 1274 @{text "fv\<^bsub>trm\<^esub>"}, @{text "fv\<^bsub>assn\<^esub>"} and @{text "fv\<^bsub>bn\<^esub>"}. They are as follows: | 
| 1266 % | 1275 % | 
| 1267 \begin{center} | 1276 \begin{center} | 
| 1268 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} | 1277 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} | 
| 1269 @{text "fv\<^bsub>trm\<^esub> (Let as t)"} & @{text "="} & @{text "fv\<^bsub>bn\<^esub> as \<union> (fv\<^bsub>trm\<^esub> t - set (bn as))"}\\ | 1278 @{text "fv\<^bsub>trm\<^esub> (Let as t)"} & @{text "="} & @{text "fv\<^bsub>bn\<^esub> as \<union> (fv\<^bsub>trm\<^esub> t - set (bn as))"}\\ | 
| 1291 recursive binder where we want to also bind all occurences of the atoms | 1300 recursive binder where we want to also bind all occurences of the atoms | 
| 1292 @{text "bn as"} inside @{text "as"}. Therefore we have to subtract @{text | 1301 @{text "bn as"} inside @{text "as"}. Therefore we have to subtract @{text | 
| 1293 "set (bn as)"} from @{text "fv\<^bsub>assn\<^esub> as"}, as well as from | 1302 "set (bn as)"} from @{text "fv\<^bsub>assn\<^esub> as"}, as well as from | 
| 1294 @{text "fv\<^bsub>trm\<^esub> t"}. An interesting point in this example is | 1303 @{text "fv\<^bsub>trm\<^esub> t"}. An interesting point in this example is | 
| 1295 that an assignment ``alone'' does not have any bound variables. Only in the | 1304 that an assignment ``alone'' does not have any bound variables. Only in the | 
| 1296 context of a @{text Let} or @{text "Let_rec"} will some atoms become bound | 1305 context of a @{text Let} or @{text "Let_rec"} will some atoms become bound. | 
| 1297 (the term-constructors that have binding clauses). This is a phenomenon | 1306 This is a phenomenon | 
| 1298 that has also been pointed out in \cite{ott-jfp}. We can also see that | 1307 that has also been pointed out in \cite{ott-jfp}. We can also see that | 
| 1299 given a @{text "bn"}-function for a type @{text "ty"}, then we have | 1308 given a @{text "bn"}-function for a type @{text "ty"}, we have that | 
| 1300 % | 1309 % | 
| 1301 \begin{equation}\label{bnprop} | 1310 \begin{equation}\label{bnprop} | 
| 1302 @{text "fv_ty x = bn x \<union> fv_bn x"}. | 1311 @{text "fv_ty x = bn x \<union> fv_bn x"}. | 
| 1303 \end{equation} | 1312 \end{equation} | 
| 1304 | 1313 | 
| 1305 Next we define alpha-equivalence for the types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"}. We call them | 1314 Next we define alpha-equivalence for the types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"}. We call them | 
| 1306 @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"}. Like with the free-variable functions, | 1315 @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"}. Like with the free-variable functions, | 
| 1307 we also need to define auxiliary alpha-equivalence relations for the binding functions. | 1316 we also need to define auxiliary alpha-equivalence relations for the binding functions. | 
| 1308 Say we have @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, we also define @{text "\<approx>bn\<^isub>1, \<dots>, \<approx>b\<^isub>m"}. | 1317 Say we have @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, then we also define @{text "\<approx>bn\<^isub>1, \<dots>, \<approx>b\<^isub>m"}. | 
| 1309 To simplify our definitions we will use the following abbreviations for | 1318 To simplify our definitions we will use the following abbreviations for | 
| 1310 relations and free-variable acting on products. | 1319 relations and free-variable acting on products. | 
| 1311 % | 1320 % | 
| 1312 \begin{center} | 1321 \begin{center} | 
| 1313 \begin{tabular}{rcl} | 1322 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} | 
| 1314 @{text "(x\<^isub>1, y\<^isub>1) (R\<^isub>1 \<otimes> R\<^isub>2) (x\<^isub>2, y\<^isub>2)"} & @{text "\<equiv>"} & @{text "x\<^isub>1 R\<^isub>1 y\<^isub>1 \<and> x\<^isub>2 R\<^isub>2 y\<^isub>2"}\\ | 1323 @{text "(x\<^isub>1, y\<^isub>1) (R\<^isub>1 \<otimes> R\<^isub>2) (x\<^isub>2, y\<^isub>2)"} & @{text "\<equiv>"} & @{text "x\<^isub>1 R\<^isub>1 y\<^isub>1 \<and> x\<^isub>2 R\<^isub>2 y\<^isub>2"}\\ | 
| 1315 @{text "(fv\<^isub>1 \<oplus> fv\<^isub>2) (x, y)"} & @{text "\<equiv>"} & @{text "fv\<^isub>1 x \<union> fv\<^isub>2 y"}\\ | 1324 @{text "(fv\<^isub>1 \<oplus> fv\<^isub>2) (x, y)"} & @{text "\<equiv>"} & @{text "fv\<^isub>1 x \<union> fv\<^isub>2 y"}\\ | 
| 1316 \end{tabular} | 1325 \end{tabular} | 
| 1317 \end{center} | 1326 \end{center} | 
| 1318 | 1327 | 
| 1319 | 1328 | 
| 1320 The relations for alpha-equivalence are inductively defined predicates, whose clauses have | 1329 The relations for alpha-equivalence are inductively defined predicates, whose clauses have | 
| 1321 conclusions of the form @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"} (let us assume | 1330 conclusions of the form | 
| 1331 % | |
| 1332 \begin{center} | |
| 1333 @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"} | |
| 1334 \end{center} | |
| 1335 | |
| 1336 \noindent | |
| 1337 For what follows, let us assume | |
| 1322 @{text C} is of type @{text ty} and its arguments are given by @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"}). | 1338 @{text C} is of type @{text ty} and its arguments are given by @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"}). | 
| 1323 The task now is to specify what the premises of these clauses are. For this we | 1339 The task now is to specify what the premises of these clauses are. For this we | 
| 1324 consider the pairs @{text "(x\<^isub>i, y\<^isub>i)"}. We will analyse these pairs according to | 1340 consider the pairs \mbox{@{text "(x\<^isub>i, y\<^isub>i)"}}, but instead of considering them in turn, it will | 
| 1325 ``clusters'' of the binding clauses. There are the following cases: | 1341 be easier to analyse these pairs according to ``clusters'' of the binding clauses. | 
| 1342 Therefore we distinguish the following cases: | |
| 1326 *} | 1343 *} | 
| 1327 (*<*) | 1344 (*<*) | 
| 1328 consts alpha_ty ::'a | 1345 consts alpha_ty ::'a | 
| 1329 notation alpha_ty ("\<approx>ty") | 1346 notation alpha_ty ("\<approx>ty") | 
| 1330 (*>*) | 1347 (*>*) | 
| 1331 text {* | 1348 text {* | 
| 1332 \begin{itemize} | 1349 \begin{itemize} | 
| 1333 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the | 1350 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the | 
| 1334 @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding binders. For the binding mode | 1351 \mbox{@{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"}} are the corresponding binders. For the binding mode | 
| 1335 \isacommand{bind\_set} we generate the premise | 1352 \isacommand{bind\_set} we generate the premise | 
| 1336 \begin{center} | 1353 \begin{center} | 
| 1337 @{term "\<exists>p. (u\<^isub>1 \<union> \<xi> \<union> u\<^isub>m, x\<^isub>i) \<approx>gen alpha_ty fv_ty\<^isub>i p (v\<^isub>1 \<union> \<xi> \<union> v\<^isub>m, y\<^isub>i)"} | 1354 @{term "\<exists>p. (u\<^isub>1 \<union> \<xi> \<union> u\<^isub>m, x\<^isub>i) \<approx>gen alpha_ty fv_ty\<^isub>i p (v\<^isub>1 \<union> \<xi> \<union> v\<^isub>m, y\<^isub>i)"} | 
| 1338 \end{center} | 1355 \end{center} | 
| 1339 | 1356 | 
| 1340 Similarly for the other modes. | 1357 For the binding mode \isacommand{bind} we use $\approx_{\textit{list}}$, and for | 
| 1358 binding mode \isacommand{bind\_res} we use $\approx_{\textit{res}}$. | |
| 1341 | 1359 | 
| 1342 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep non-recursive binders with type @{text "ty"} | 1360 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep non-recursive binders with type @{text "ty"} | 
| 1343 and with @{text bn} being the auxiliary binding function. We assume | 1361 and @{text bn} being the auxiliary binding function. We assume | 
| 1344 @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. | 1362 @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. | 
| 1345 For the binding mode \isacommand{bind\_set} we generate the two premises | 1363 For the binding mode \isacommand{bind\_set} we generate two premises | 
| 1346 | 1364 % | 
| 1347 \begin{center} | 1365 \begin{center} | 
| 1348 @{text "x\<^isub>i \<approx>bn y\<^isub>i"}\\ | 1366 @{text "x\<^isub>i \<approx>bn y\<^isub>i"}\hfill | 
| 1349 @{term "\<exists>p. (bn x\<^isub>i, (u\<^isub>1,\<xi>,u\<^isub>m)) \<approx>gen R fv p (bn y\<^isub>i, (v\<^isub>1,\<xi>,v\<^isub>m))"} | 1367 @{term "\<exists>p. (bn x\<^isub>i, (u\<^isub>1,\<xi>,u\<^isub>m)) \<approx>gen R fv p (bn y\<^isub>i, (v\<^isub>1,\<xi>,v\<^isub>m))"} | 
| 1350 \end{center} | 1368 \end{center} | 
| 1351 | 1369 | 
| 1352 \noindent | 1370 \noindent | 
| 1353 where @{text R} is @{text "\<approx>ty\<^isub>1 \<otimes> ... \<otimes> \<approx>ty\<^isub>m"} and @{text fv} is | 1371 where @{text R} is @{text "\<approx>ty\<^isub>1 \<otimes> ... \<otimes> \<approx>ty\<^isub>m"} and @{text fv} is | 
| 1354 @{text "fv_ty\<^isub>1 \<oplus> ... \<oplus> fv_ty\<^isub>m"}. Similarly for the other modes. | 1372 @{text "fv_ty\<^isub>1 \<oplus> ... \<oplus> fv_ty\<^isub>m"}. Similarly for the other binding modes. | 
| 1355 | 1373 | 
| 1356 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep recursive binders with type @{text "ty"} | 1374 \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep recursive binders with type @{text "ty"} | 
| 1357 and with @{text bn} being the auxiliary binding function. We assume | 1375 and with @{text bn} being the auxiliary binding function. We assume | 
| 1358 @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. | 1376 @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. | 
| 1359 For the binding mode \isacommand{bind\_set} we generate the premise | 1377 For the binding mode \isacommand{bind\_set} we generate the premise | 
| 1360 | 1378 % | 
| 1361 \begin{center} | 1379 \begin{center} | 
| 1362 @{term "\<exists>p. (bn x\<^isub>i, (x\<^isub>i, u\<^isub>1,\<xi>,u\<^isub>m)) \<approx>gen R fv p (bn y\<^isub>i, (y\<^isub>i, v\<^isub>1,\<xi>,v\<^isub>m))"} | 1380 @{term "\<exists>p. (bn x\<^isub>i, (x\<^isub>i, u\<^isub>1,\<xi>,u\<^isub>m)) \<approx>gen R fv p (bn y\<^isub>i, (y\<^isub>i, v\<^isub>1,\<xi>,v\<^isub>m))"} | 
| 1363 \end{center} | 1381 \end{center} | 
| 1364 | 1382 | 
| 1365 \noindent | 1383 \noindent | 
| 1366 where @{text R} is @{text "\<approx>ty \<otimes> \<approx>ty\<^isub>1 \<otimes> ... \<otimes> \<approx>ty\<^isub>m"} and @{text fv} is | 1384 where @{text R} is @{text "\<approx>ty \<otimes> \<approx>ty\<^isub>1 \<otimes> ... \<otimes> \<approx>ty\<^isub>m"} and @{text fv} is | 
| 1367 @{text "fv_ty \<oplus> fv_ty\<^isub>1 \<oplus> ... \<oplus> fv_ty\<^isub>m"}. Similarly for the other modes. | 1385 @{text "fv_ty \<oplus> fv_ty\<^isub>1 \<oplus> ... \<oplus> fv_ty\<^isub>m"}. Similarly for the other modes. | 
| 1368 \end{itemize} | 1386 \end{itemize} | 
| 1369 | 1387 | 
| 1370 \noindent | 1388 \noindent | 
| 1371 The only cases that are not covered by these rules is if @{text "(x\<^isub>i, y\<^isub>i)"} is | 1389 From these definition it is clear why we can only support one binding mode per binder | 
| 1390 and body, as we cannot mix the relations $\approx_{\textit{set}}$, $\approx_{\textit{list}}$ | |
| 1391 and $\approx_{\textit{res}}$. It is also clear why we had to impose the restriction | |
| 1392 of excluding overlapping binders, as these would need to be translated to separate | |
| 1393 abstractions. | |
| 1394 | |
| 1395 | |
| 1396 The only cases that are not covered by the rules above are the cases where @{text "(x\<^isub>i, y\<^isub>i)"} is | |
| 1372 neither a binder nor a body. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"} provided | 1397 neither a binder nor a body. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"} provided | 
| 1373 the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are | 1398 the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are | 
| 1374 recursive arguments of the term constructor. If they are non-recursive arguments | 1399 recursive arguments of the term-constructor. If they are non-recursive arguments | 
| 1375 then we generate @{text "x\<^isub>i = y\<^isub>i"}. | 1400 then we generate just @{text "x\<^isub>i = y\<^isub>i"}. | 
| 1376 | 1401 | 
| 1377 TODO | 1402 TODO | 
| 1378 | 1403 | 
| 1379 The alpha-equivalence relations for binding functions are similar to the alpha-equivalences | 1404 The alpha-equivalence relations for binding functions are similar to the alpha-equivalences | 
| 1380 for their respective types, the difference is that they ommit checking the arguments that | 1405 for their respective types, the difference is that they ommit checking the arguments that |