13 Abs_print :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
13 Abs_print :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
14 |
14 |
15 definition |
15 definition |
16 "equal \<equiv> (op =)" |
16 "equal \<equiv> (op =)" |
17 |
17 |
|
18 fun alpha_set_ex where |
|
19 "alpha_set_ex (bs, x) R f (cs, y) = (\<exists>pi. alpha_set (bs, x) R f pi (cs, y))" |
|
20 |
|
21 fun alpha_res_ex where |
|
22 "alpha_res_ex (bs, x) R f pi (cs, y) = (\<exists>pi. alpha_res (bs, x) R f pi (cs, y))" |
|
23 |
|
24 fun alpha_lst_ex where |
|
25 "alpha_lst_ex (bs, x) R f pi (cs, y) = (\<exists>pi. alpha_lst (bs, x) R f pi (cs, y))" |
|
26 |
|
27 |
|
28 |
18 notation (latex output) |
29 notation (latex output) |
19 swap ("'(_ _')" [1000, 1000] 1000) and |
30 swap ("'(_ _')" [1000, 1000] 1000) and |
20 fresh ("_ # _" [51, 51] 50) and |
31 fresh ("_ # _" [51, 51] 50) and |
21 fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
32 fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
22 supp ("supp _" [78] 73) and |
33 supp ("supp _" [78] 73) and |
23 uminus ("-_" [78] 73) and |
34 uminus ("-_" [78] 73) and |
24 If ("if _ then _ else _" 10) and |
35 If ("if _ then _ else _" 10) and |
25 alpha_set ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set}}$}}>\<^bsup>_, _, _\<^esup> _") and |
36 alpha_set_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set}}$}}>\<^bsup>_, _\<^esup> _") and |
26 alpha_lst ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{list}}$}}>\<^bsup>_, _, _\<^esup> _") and |
37 alpha_lst_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{list}}$}}>\<^bsup>_, _\<^esup> _") and |
27 alpha_res ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set+}}$}}>\<^bsup>_, _, _\<^esup> _") and |
38 alpha_res_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set+}}$}}>\<^bsup>_, _\<^esup> _") and |
28 abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
39 abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
29 abs_set2 ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_\<^esup> _") and |
40 abs_set2 ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_\<^esup> _") and |
30 fv ("fa'(_')" [100] 100) and |
41 fv ("fa'(_')" [100] 100) and |
31 equal ("=") and |
42 equal ("=") and |
32 alpha_abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
43 alpha_abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
655 @{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The |
666 @{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The |
656 requirements {\it (i)} to {\it (iv)} can be stated formally as the conjunction of: |
667 requirements {\it (i)} to {\it (iv)} can be stated formally as the conjunction of: |
657 |
668 |
658 \begin{defi}[Alpha-Equivalence for Set-Bindings]\label{alphaset}\mbox{}\\ |
669 \begin{defi}[Alpha-Equivalence for Set-Bindings]\label{alphaset}\mbox{}\\ |
659 \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl} |
670 \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl} |
660 @{term "(as, x) \<approx>set R fa \<pi> (bs, y)"}\hspace{2mm}@{text "\<equiv>"} |
671 @{term "alpha_set_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} & |
|
672 \multicolumn{2}{@ {}l}{if there exists a @{text "\<pi>"} such that:}\\ |
661 & \mbox{\it (i)} & @{term "fa(x) - as = fa(y) - bs"}\\ |
673 & \mbox{\it (i)} & @{term "fa(x) - as = fa(y) - bs"}\\ |
662 & \mbox{\it (ii)} & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\ |
674 & \mbox{\it (ii)} & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\ |
663 & \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"} \\ |
675 & \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"} \\ |
664 & \mbox{\it (iv)} & @{term "(\<pi> \<bullet> as) = bs"} \\ |
676 & \mbox{\it (iv)} & @{term "(\<pi> \<bullet> as) = bs"} \\ |
665 \end{tabular} |
677 \end{tabular} |
666 \end{defi} |
678 \end{defi} |
667 |
679 |
668 \noindent |
680 \noindent |
669 Note that this relation depends on the permutation @{text |
681 Note that the relation is |
670 "\<pi>"}; alpha-equivalence between two pairs is then the relation where we |
|
671 existentially quantify over this @{text "\<pi>"}. Also note that the relation is |
|
672 dependent on a free-atom function @{text "fa"} and a relation @{text |
682 dependent on a free-atom function @{text "fa"} and a relation @{text |
673 "R"}. The reason for this extra generality is that we will use |
683 "R"}. The reason for this extra generality is that we will use |
674 $\approx_{\,\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In |
684 $\approx_{\,\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In |
675 the latter case, @{text R} will be replaced by equality @{text "="} and we |
685 the latter case, @{text R} will be replaced by equality @{text "="} and we |
676 will prove that @{text "fa"} is equal to @{text "supp"}. |
686 will prove that @{text "fa"} is equal to @{text "supp"}. |
735 permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal |
747 permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal |
736 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
748 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
737 shown that all three notions of alpha-equivalence coincide, if we only |
749 shown that all three notions of alpha-equivalence coincide, if we only |
738 abstract a single atom. |
750 abstract a single atom. |
739 |
751 |
740 In the rest of this section we are going to introduce three abstraction |
752 In the rest of this section we are going to show that the alpha-equivalences really |
741 types. For this we define the relations |
753 lead to abstractions where some atoms are bound. For this we are going to introduce |
|
754 three abstraction types that are quotients with respect to the relations |
742 |
755 |
743 \begin{equation} |
756 \begin{equation} |
744 \begin{array}{r} |
757 \begin{array}{r} |
745 @{term "alpha_abs_set (as, x) (bs, y) \<equiv> \<exists>\<pi>. alpha_set (as, x) equal supp \<pi> (bs, y)"}\\ |
758 @{term "alpha_abs_set (as, x) (bs, y)"}~~@{text "\<equiv>"}~~@{term "alpha_set_ex (as, x) equal supp (bs, y)"}\\ |
746 @{term "alpha_abs_res (as, x) (bs, y) \<equiv> \<exists>\<pi>. alpha_res (as, x) equal supp \<pi> (bs, y)"}\\ |
759 @{term "alpha_abs_res (as, x) (bs, y)"}~~@{text "\<equiv>"}~~@{term "alpha_res_ex (as, x) equal supp (bs, y)"}\\ |
747 @{term "alpha_abs_lst (as, x) (bs, y) \<equiv> \<exists>\<pi>. alpha_lst (as, x) equal supp \<pi> (bs, y)"}\\ |
760 @{term "alpha_abs_lst (as, x) (bs, y)"}~~@{text "\<equiv>"}~~@{term "alpha_lst_ex (as, x) equal supp (bs, y)"}\\ |
748 \end{array} |
761 \end{array} |
749 \end{equation}\smallskip |
762 \end{equation}\smallskip |
750 |
763 |
751 \noindent |
764 \noindent |
752 We can show that these relations are equivalence |
765 In these relation we replaced the free-atom function @{text "fa"} with @{term "supp"} and the |
753 relations and equivariant. |
766 relation @{text R} with equality. We can show the following properties: |
754 |
767 |
755 \begin{lem}\label{alphaeq} |
768 \begin{lem}\label{alphaeq} |
756 The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_list}}$ |
769 The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_set+}}$ |
757 and $\approx_{\,\textit{abs\_set+}}$ are equivalence relations and equivariant. |
770 and $\approx_{\,\textit{abs\_list}}$ are equivalence relations and equivariant. |
758 \end{lem} |
771 \end{lem} |
759 |
772 |
760 \begin{proof} |
773 \begin{proof} |
761 Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have |
774 Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have |
762 a permutation @{text "\<pi>"} and for the proof obligation take @{term "- \<pi>"}. In case |
775 a permutation @{text "\<pi>"} and for the proof obligation take @{term "- \<pi>"}. In case |
763 of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} and @{text "\<pi>\<^isub>2"}, and for the |
776 of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} and @{text "\<pi>\<^isub>2"}, and for the |
764 proof obligation use @{text "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means |
777 proof obligation use @{text "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means |
765 @{term "abs_set (\<pi> \<bullet> as, \<pi> \<bullet> x) (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided |
778 @{term "abs_set (\<pi> \<bullet> as, \<pi> \<bullet> x) (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided |
766 @{term "abs_set (as, x) (bs, y)"}. To show this, we need to unfold the |
779 \mbox{@{term "abs_set (as, x) (bs, y)"}} holds. To show this, we need to unfold the |
767 definitions and `pull out' the permutations, which is possible since all |
780 definitions and `pull out' the permutations, which is possible since all |
768 operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, are equivariant |
781 operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, are equivariant |
769 (see \cite{HuffmanUrban10}). |
782 (see \cite{HuffmanUrban10}). Finally we apply the permutation operation on booleans. |
770 \end{proof} |
783 \end{proof} |
771 |
784 |
772 \noindent |
785 \noindent |
773 This lemma allows us to use our quotient package for introducing |
786 This lemma allows us to use our quotient package for introducing |
774 new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"} |
787 new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"} |
1106 notions of free-atoms and alpha-equivalence. |
1130 notions of free-atoms and alpha-equivalence. |
1107 |
1131 |
1108 To make sure that atoms bound by deep binders cannot be free at the |
1132 To make sure that atoms bound by deep binders cannot be free at the |
1109 same time, we cannot have more than one binding function for a deep binder. |
1133 same time, we cannot have more than one binding function for a deep binder. |
1110 Consequently we exclude specifications such as |
1134 Consequently we exclude specifications such as |
1111 % |
1135 |
1112 \begin{center} |
1136 \[\mbox{ |
1113 \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}} |
1137 \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}} |
1114 @{text "Baz\<^isub>1 p::pat t::trm"} & |
1138 @{text "Baz\<^isub>1 p::pat t::trm"} & |
1115 \isacommand{binds} @{text "bn\<^isub>1(p) bn\<^isub>2(p)"} \isacommand{in} @{text t}\\ |
1139 \isacommand{binds} @{text "bn\<^isub>1(p) bn\<^isub>2(p)"} \isacommand{in} @{text t}\\ |
1116 @{text "Baz\<^isub>2 p::pat t\<^isub>1::trm t\<^isub>2::trm"} & |
1140 @{text "Baz\<^isub>2 p::pat t\<^isub>1::trm t\<^isub>2::trm"} & |
1117 \isacommand{binds} @{text "bn\<^isub>1(p)"} \isacommand{in} @{text "t\<^isub>1"}, |
1141 \isacommand{binds} @{text "bn\<^isub>1(p)"} \isacommand{in} @{text "t\<^isub>1"}, |
1118 \isacommand{binds} @{text "bn\<^isub>2(p)"} \isacommand{in} @{text "t\<^isub>2"}\\ |
1142 \isacommand{binds} @{text "bn\<^isub>2(p)"} \isacommand{in} @{text "t\<^isub>2"}\\ |
1119 \end{tabular} |
1143 \end{tabular}} |
1120 \end{center} |
1144 \]\smallskip |
1121 |
1145 |
1122 \noindent |
1146 \noindent |
1123 Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"} pick |
1147 Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"} pick |
1124 out different atoms to become bound, respectively be free, in @{text "p"}. |
1148 out different atoms to become bound, respectively be free, in @{text "p"}. |
1125 (Since the Ott-tool does not derive a reasoning infrastructure for |
1149 (Since the Ott-tool does not derive a reasoning infrastructure for |
1126 alpha-equated terms with deep binders, it can permit such specifications.) |
1150 alpha-equated terms with deep binders, it can permit such specifications.) |
1127 |
1151 |
1128 We also need to restrict the form of the binding functions in order |
1152 We also need to restrict the form of the binding functions in order to |
1129 to ensure the @{text "bn"}-functions can be defined for alpha-equated |
1153 ensure the @{text "bn"}-functions can be defined for alpha-equated |
1130 terms. The main restriction is that we cannot return an atom in a binding function that is also |
1154 terms. The main restriction is that we cannot return an atom in a binding |
1131 bound in the corresponding term-constructor. That means in \eqref{letpat} |
1155 function that is also bound in the corresponding term-constructor. |
1132 that the term-constructors @{text PVar} and @{text PTup} may |
1156 Consider again the specification for @{text "trm"} and a contrived |
1133 not have a binding clause (all arguments are used to define @{text "bn"}). |
1157 version for assignments, @{text "assn"}: |
1134 In contrast, in case of \eqref{letrecs} the term-constructor @{text ACons} |
1158 |
1135 may have a binding clause involving the argument @{text trm} (the only one that |
1159 \begin{equation}\label{bnexp} |
1136 is \emph{not} used in the definition of the binding function). This restriction |
1160 \mbox{% |
1137 is sufficient for lifting the binding function to alpha-equated terms. |
1161 \begin{tabular}{@ {}l@ {}} |
1138 |
1162 \isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\ |
1139 In the version of |
1163 \isacommand{and} @{text "assn"} $=$\\ |
1140 Nominal Isabelle described here, we also adopted the restriction from the |
1164 \hspace{5mm}\phantom{$\mid$}~@{text "ANil"}\\ |
1141 Ott-tool that binding functions can only return: the empty set or empty list |
1165 \hspace{5mm}$\mid$~@{text "ACons x::name y::name t::trm assn"} |
1142 (as in case @{text PNil}), a singleton set or singleton list containing an |
1166 \;\;\isacommand{binds} @{text "y"} \isacommand{in} @{text t}\\ |
1143 atom (case @{text PVar}), or unions of atom sets or appended atom lists |
1167 \isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\ |
1144 (case @{text PTup}). This restriction will simplify some automatic definitions and proofs |
1168 \isacommand{where}~@{text "bn(ANil) = []"}\\ |
1145 later on. |
1169 \hspace{5mm}$\mid$~@{text "bn(ACons x y t as) = [atom x] @ bn(as)"}\\ |
|
1170 \end{tabular}} |
|
1171 \end{equation}\smallskip |
|
1172 |
|
1173 \noindent |
|
1174 In this example the term constructor @{text "ACons"} contains a binding |
|
1175 clause, and also is used in the definition of the binding function. The |
|
1176 restriction we have to impose is that the binding function can only return |
|
1177 free atoms, that is the ones that are not mentioned in a binding clause. |
|
1178 Therefore @{text "y"} cannot be used in the binding function, @{text "bn"} |
|
1179 (since it is bound in @{text "ACons"} by the binding clause), but @{text x} |
|
1180 can (since it is a free atom). This restriction is sufficient for lifting |
|
1181 the binding function to alpha-equated terms. If we would allow that @{text "bn"} |
|
1182 can return also @{text "y"}, then it would not be respectful and therefore |
|
1183 cannot be lifted. |
|
1184 |
|
1185 In the version of Nominal Isabelle described here, we also adopted the |
|
1186 restriction from the Ott-tool that binding functions can only return: the |
|
1187 empty set or empty list (as in case @{text ANil}), a singleton set or |
|
1188 singleton list containing an atom (case @{text PVar} in \eqref{letpat}), or |
|
1189 unions of atom sets or appended atom lists (case @{text ACons}). This |
|
1190 restriction will simplify some automatic definitions and proofs later on. |
1146 |
1191 |
1147 In order to simplify our definitions of free atoms and alpha-equivalence, |
1192 In order to simplify our definitions of free atoms and alpha-equivalence, |
1148 we shall assume specifications |
1193 we shall assume specifications |
1149 of term-calculi are implicitly \emph{completed}. By this we mean that |
1194 of term-calculi are implicitly \emph{completed}. By this we mean that |
1150 for every argument of a term-constructor that is \emph{not} |
1195 for every argument of a term-constructor that is \emph{not} |
1151 already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding |
1196 already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding |
1152 clause, written \isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case |
1197 clause, written \isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case |
1153 of the lambda-terms, the completion produces |
1198 of the lambda-terms, the completion produces |
1154 |
1199 |
1155 \begin{center} |
1200 \[\mbox{ |
1156 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
1201 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
1157 \isacommand{nominal\_datatype} @{text lam} =\\ |
1202 \isacommand{nominal\_datatype} @{text lam} =\\ |
1158 \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"} |
1203 \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"} |
1159 \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "x"}\\ |
1204 \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "x"}\\ |
1160 \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"} |
1205 \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"} |
1161 \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\ |
1206 \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\ |
1162 \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"} |
1207 \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"} |
1163 \;\;\isacommand{binds}~@{text x} \isacommand{in} @{text t}\\ |
1208 \;\;\isacommand{binds}~@{text x} \isacommand{in} @{text t}\\ |
1164 \end{tabular} |
1209 \end{tabular}} |
1165 \end{center} |
1210 \]\smallskip |
1166 |
1211 |
1167 \noindent |
1212 \noindent |
1168 The point of completion is that we can make definitions over the binding |
1213 The point of completion is that we can make definitions over the binding |
1169 clauses and be sure to have captured all arguments of a term constructor. |
1214 clauses and be sure to have captured all arguments of a term constructor. |
1170 *} |
1215 *} |
1172 section {* Alpha-Equivalence and Free Atoms\label{sec:alpha} *} |
1217 section {* Alpha-Equivalence and Free Atoms\label{sec:alpha} *} |
1173 |
1218 |
1174 text {* |
1219 text {* |
1175 Having dealt with all syntax matters, the problem now is how we can turn |
1220 Having dealt with all syntax matters, the problem now is how we can turn |
1176 specifications into actual type definitions in Isabelle/HOL and then |
1221 specifications into actual type definitions in Isabelle/HOL and then |
1177 establish a reasoning infrastructure for them. As |
1222 establish a reasoning infrastructure for them. As Pottier and Cheney pointed |
1178 Pottier and Cheney pointed out \cite{Pottier06,Cheney05}, just |
1223 out \cite{Cheney05,Pottier06}, just re-arranging the arguments of |
1179 re-arranging the arguments of |
1224 term-constructors so that binders and their bodies are next to each other |
1180 term-constructors so that binders and their bodies are next to each other will |
1225 will result in inadequate representations in cases like \mbox{@{text "Let |
1181 result in inadequate representations in cases like @{text "Let x\<^isub>1 = t\<^isub>1\<dots>x\<^isub>n = t\<^isub>n in s"}. |
1226 x\<^isub>1 = t\<^isub>1\<dots>x\<^isub>n = t\<^isub>n in s"}}. Therefore we will |
1182 Therefore we will first |
1227 first extract ``raw'' datatype definitions from the specification and then |
1183 extract ``raw'' datatype definitions from the specification and then define |
1228 define explicitly an alpha-equivalence relation over them. We subsequently |
1184 explicitly an alpha-equivalence relation over them. We subsequently |
|
1185 construct the quotient of the datatypes according to our alpha-equivalence. |
1229 construct the quotient of the datatypes according to our alpha-equivalence. |
|
1230 |
1186 |
1231 |
1187 The ``raw'' datatype definition can be obtained by stripping off the |
1232 The ``raw'' datatype definition can be obtained by stripping off the |
1188 binding clauses and the labels from the types. We also have to invent |
1233 binding clauses and the labels from the types. We also have to invent |
1189 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
1234 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
1190 given by the user. In our implementation we just use the affix ``@{text "_raw"}''. |
1235 given by the user. In our implementation we just use the affix ``@{text "_raw"}''. |
1201 in Isabelle/HOL). |
1246 in Isabelle/HOL). |
1202 We subsequently define each of the user-specified binding |
1247 We subsequently define each of the user-specified binding |
1203 functions @{term "bn"}$_{1..m}$ by recursion over the corresponding |
1248 functions @{term "bn"}$_{1..m}$ by recursion over the corresponding |
1204 raw datatype. We can also easily define permutation operations by |
1249 raw datatype. We can also easily define permutation operations by |
1205 recursion so that for each term constructor @{text "C"} we have that |
1250 recursion so that for each term constructor @{text "C"} we have that |
1206 % |
1251 |
1207 \begin{equation}\label{ceqvt} |
1252 \begin{equation}\label{ceqvt} |
1208 @{text "p \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (p \<bullet> z\<^isub>1) \<dots> (p \<bullet> z\<^isub>n)"} |
1253 @{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"} |
1209 \end{equation} |
1254 \end{equation}\smallskip |
1210 |
1255 |
1211 The first non-trivial step we have to perform is the generation of |
1256 The first non-trivial step we have to perform is the generation of |
1212 free-atom functions from the specification. For the |
1257 \emph{free-atom functions} from the specification.\footnote{Admittedly, the |
|
1258 details of our definitions are somewhat involved. However they are still |
|
1259 conceptually simple in comparison with the ``positional'' approach taken in |
|
1260 Ott \cite[Pages 88--95]{ott-jfp}, which uses \emph{occurences} and |
|
1261 \emph{partial equivalence relations} over sets of occurences.} For the |
1213 \emph{raw} types @{text "ty"}$_{1..n}$ we define the free-atom functions |
1262 \emph{raw} types @{text "ty"}$_{1..n}$ we define the free-atom functions |
1214 |
1263 |
1215 \begin{equation}\label{fvars} |
1264 \begin{equation}\label{fvars} |
1216 \mbox{@{text "fa_ty"}$_{1..n}$} |
1265 \mbox{@{text "fa_ty"}$_{1..n}$} |
1217 \end{equation} |
1266 \end{equation}\smallskip |
1218 |
1267 |
1219 \noindent |
1268 \noindent |
1220 by recursion. |
1269 by recursion. |
1221 We define these functions together with auxiliary free-atom functions for |
1270 We define these functions together with auxiliary free-atom functions for |
1222 the binding functions. Given raw binding functions @{text "bn"}$_{1..m}$ |
1271 the binding functions. Given raw binding functions @{text "bn"}$_{1..m}$ |
1223 we define |
1272 we define |
1224 |
1273 |
1225 \begin{center} |
1274 \[ |
1226 @{text "fa_bn"}$_{1..m}$. |
1275 @{text "fa_bn"}\mbox{$_{1..m}$}. |
1227 \end{center} |
1276 \]\smallskip |
1228 |
1277 |
1229 \noindent |
1278 \noindent |
1230 The reason for this setup is that in a deep binder not all atoms have to be |
1279 The reason for this setup is that in a deep binder not all atoms have to be |
1231 bound, as we saw in the example with ``plain'' @{text Let}s. We need therefore a function |
1280 bound, as we saw in the example with ``plain'' @{text Let}s. We need therefore a function |
1232 that calculates those free atoms in a deep binder. |
1281 that calculates those free atoms in a deep binder. |
1239 "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text |
1288 "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text |
1240 "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding |
1289 "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding |
1241 clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). |
1290 clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). |
1242 Suppose the binding clause @{text bc\<^isub>i} is of the form |
1291 Suppose the binding clause @{text bc\<^isub>i} is of the form |
1243 |
1292 |
1244 \begin{center} |
1293 \[ |
1245 \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}} |
1294 \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}} |
1246 \end{center} |
1295 \]\smallskip |
1247 |
1296 |
1248 \noindent |
1297 \noindent |
1249 in which the body-labels @{text "d"}$_{1..q}$ refer to types @{text ty}$_{1..q}$, |
1298 in which the body-labels @{text "d"}$_{1..q}$ refer to types @{text |
1250 and the binders @{text b}$_{1..p}$ |
1299 ty}$_{1..q}$, and the binders @{text b}$_{1..p}$ either refer to labels of |
1251 either refer to labels of atom types (in case of shallow binders) or to binding |
1300 atom types (in case of shallow binders) or to binding functions taking a |
1252 functions taking a single label as argument (in case of deep binders). Assuming |
1301 single label as argument (in case of deep binders). Assuming @{text "D"} |
1253 @{text "D"} stands for the set of free atoms of the bodies, @{text B} for the |
1302 stands for the set of free atoms of the bodies, @{text B} for the set of |
1254 set of binding atoms in the binders and @{text "B'"} for the set of free atoms in |
1303 binding atoms in the binders and @{text "B'"} for the set of free atoms in |
1255 non-recursive deep binders, |
1304 non-recursive deep binders, then the free atoms of the binding clause @{text |
1256 then the free atoms of the binding clause @{text bc\<^isub>i} are\\[-2mm] |
1305 bc\<^isub>i} are |
1257 % |
1306 |
1258 \begin{equation}\label{fadef} |
1307 \begin{equation}\label{fadef} |
1259 \mbox{@{text "fa(bc\<^isub>i) \<equiv> (D - B) \<union> B'"}}. |
1308 \mbox{@{text "fa(bc\<^isub>i) \<equiv> (D - B) \<union> B'"}}. |
1260 \end{equation} |
1309 \end{equation}\smallskip |
1261 % |
1310 |
1262 \noindent |
1311 \noindent |
1263 The set @{text D} is formally defined as |
1312 The set @{text D} is formally defined as |
1264 |
1313 |
1265 \begin{center} |
1314 \[ |
1266 @{text "D \<equiv> fa_ty\<^isub>1 d\<^isub>1 \<union> ... \<union> fa_ty\<^isub>q d\<^isub>q"} |
1315 @{text "D \<equiv> fa_ty\<^isub>1 d\<^isub>1 \<union> ... \<union> fa_ty\<^isub>q d\<^isub>q"} |
1267 \end{center} |
1316 \]\smallskip |
1268 |
1317 |
1269 \noindent |
1318 \noindent |
1270 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1319 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1271 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1320 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1272 we are defining by recursion; |
1321 we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i d\<^isub>i = supp d\<^isub>i"}}. The reason |
1273 (see \eqref{fvars}); |
1322 for the latter choice is that @{text "ty"}$_i$ is not a type that is part of the specification, and |
1274 otherwise we set @{text "fa_ty\<^isub>i d\<^isub>i = supp d\<^isub>i"}. |
1323 we assume @{text supp} is the generic notion that characterises the free variables of |
|
1324 a type (in fact in the next section we will show that the free-variable functions we |
|
1325 define here, are equal to the support once lifted to alpha-equivalence classes). |
1275 |
1326 |
1276 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1327 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1277 for atom types to which shallow binders may refer\\[-4mm] |
1328 for atom types to which shallow binders may refer\\[-4mm] |
1278 |
1329 |
1279 \begin{center} |
1330 \[\mbox{ |
1280 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1331 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1281 @{text "bn_atom a"} & @{text "\<equiv>"} & @{text "{atom a}"}\\ |
1332 @{text "bn\<^bsub>atom\<^esup> a"} & @{text "\<equiv>"} & @{text "{atom a}"}\\ |
1282 @{text "bn_atom_set as"} & @{text "\<equiv>"} & @{text "atoms as"}\\ |
1333 @{text "bn\<^bsub>atom_set\<^esup> as"} & @{text "\<equiv>"} & @{text "atoms as"}\\ |
1283 @{text "bn_atom_list as"} & @{text "\<equiv>"} & @{text "atoms (set as)"} |
1334 @{text "bn\<^bsub>atom_list\<^esub> as"} & @{text "\<equiv>"} & @{text "atoms (set as)"} |
1284 \end{tabular} |
1335 \end{tabular}} |
1285 \end{center} |
1336 \]\smallskip |
1286 |
1337 |
1287 \begin{center} |
|
1288 @{text "bn\<^bsub>atom\<^esub> a \<equiv> {atom a}"}\hfill |
|
1289 @{text "bn\<^bsub>atom_set\<^esub> as \<equiv> atoms as"}\hfill |
|
1290 @{text "bn\<^bsub>atom_list\<^esub> as \<equiv> atoms (set as)"} |
|
1291 \end{center} |
|
1292 % |
|
1293 \noindent |
1338 \noindent |
1294 Like the function @{text atom}, the function @{text "atoms"} coerces |
1339 Like the function @{text atom}, the function @{text "atoms"} coerces |
1295 a set of atoms to a set of the generic atom type. |
1340 a set of atoms to a set of the generic atom type. |
1296 It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}. |
1341 It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}. |
1297 The set @{text B} is then formally defined as\\[-4mm] |
1342 The set @{text B} is then formally defined as |
1298 % |
1343 |
1299 \begin{center} |
1344 \begin{equation}\label{bdef} |
1300 @{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> ... \<union> bn_ty\<^isub>p b\<^isub>p"} |
1345 @{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> ... \<union> bn_ty\<^isub>p b\<^isub>p"} |
1301 \end{center} |
1346 \end{equation}\smallskip |
1302 % |
1347 |
1303 \noindent |
1348 \noindent |
1304 where we use the auxiliary binding functions for shallow binders. |
1349 where we use the auxiliary binding functions for shallow binders (that means |
1305 The set @{text "B'"} collects all free atoms in non-recursive deep |
1350 when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or |
1306 binders. Let us assume these binders in @{text "bc\<^isub>i"} are |
1351 @{text "atom list"}). The set @{text "B'"} collects all free atoms in |
1307 |
1352 non-recursive deep binders. Let us assume these binders in the binding |
1308 \begin{center} |
1353 clause @{text "bc\<^isub>i"} are |
|
1354 |
|
1355 \[ |
1309 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1356 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1310 \end{center} |
1357 \]\smallskip |
1311 |
1358 |
1312 \noindent |
1359 \noindent |
1313 with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ and none of the |
1360 with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ (see |
1314 @{text "l"}$_{1..r}$ being among the bodies @{text |
1361 \eqref{bdef}) and none of the @{text "l"}$_{1..r}$ being among the bodies |
1315 "d"}$_{1..q}$. The set @{text "B'"} is defined as\\[-5mm] |
1362 @{text "d"}$_{1..q}$. The set @{text "B'"} is defined as |
1316 % |
1363 |
1317 \begin{center} |
1364 \begin{equation}\label{bprimedef} |
1318 @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"}\\[-9mm] |
1365 @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"} |
1319 \end{center} |
1366 \end{equation}\smallskip |
1320 % |
1367 |
1321 \noindent |
1368 \noindent |
1322 This completes the definition of the free-atom functions @{text "fa_ty"}$_{1..n}$. |
1369 This completes the definition of the free-atom functions @{text "fa_ty"}$_{1..n}$. |
1323 |
1370 |
1324 Note that for non-recursive deep binders, we have to add in \eqref{fadef} |
1371 Note that for non-recursive deep binders, we have to add in \eqref{fadef} |
1325 the set of atoms that are left unbound by the binding functions @{text |
1372 the set of atoms that are left unbound by the binding functions @{text |
1326 "bn"}$_{1..m}$. We used for the definition of |
1373 "bn"}$_{1..m}$, see also the definition in \eqref{bprimedef}. We used for |
1327 this set the functions @{text "fa_bn"}$_{1..m}$, which are also defined by mutual |
1374 the definition of this set the functions @{text "fa_bn"}$_{1..m}$. The |
1328 recursion. Assume the user specified a @{text bn}-clause of the form |
1375 definition for those functions needs to be extracted from the clauses the |
1329 |
1376 user provided for @{text "bn"}$_{1..m}$ Assume the user specified a @{text |
1330 \begin{center} |
1377 bn}-clause of the form |
|
1378 |
|
1379 \[ |
1331 @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"} |
1380 @{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"} |
1332 \end{center} |
1381 \]\smallskip |
1333 |
1382 |
1334 \noindent |
1383 \noindent |
1335 where the @{text "z"}$_{1..s}$ are of types @{text "ty"}$_{1..s}$. For each of |
1384 where the @{text "z"}$_{1..s}$ are of types @{text "ty"}$_{1..s}$. For |
1336 the arguments we calculate the free atoms as follows: |
1385 each of the arguments we calculate the free atoms as follows: |
1337 |
1386 |
1338 \begin{center} |
1387 \[\mbox{ |
1339 \begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}} |
1388 \begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}} |
1340 $\bullet$ & @{term "fa_ty\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text "rhs"} |
1389 $\bullet$ & @{term "fa_ty\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text "rhs"}\\ |
1341 (that means nothing is bound in @{text "z\<^isub>i"} by the binding function),\\ |
1390 & (that means nothing is bound in @{text "z\<^isub>i"} by the binding function),\smallskip\\ |
1342 $\bullet$ & @{term "fa_bn\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"} |
1391 $\bullet$ & @{term "fa_bn\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"} |
1343 with the recursive call @{text "bn\<^isub>i z\<^isub>i"}, and\\ |
1392 with the recursive call @{text "bn\<^isub>i z\<^isub>i"}, and\smallskip\\ |
1344 $\bullet$ & @{term "{}"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"}, |
1393 $\bullet$ & @{term "{}"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"}, |
1345 but without a recursive call. |
1394 but without a recursive call\\ |
1346 \end{tabular} |
1395 & (that means @{text "z\<^isub>i"} is supposed to become bound by the binding function)\\ |
1347 \end{center} |
1396 \end{tabular}} |
|
1397 \]\smallskip |
1348 |
1398 |
1349 \noindent |
1399 \noindent |
1350 For defining @{text "fa_bn (C z\<^isub>1 \<dots> z\<^isub>n)"} we just union up all these sets. |
1400 For defining @{text "fa_bn (C z\<^isub>1 \<dots> z\<^isub>n)"} we just union up all these sets. |
1351 |
1401 |
1352 To see how these definitions work in practice, let us reconsider the |
1402 To see how these definitions work in practice, let us reconsider the |
1354 \eqref{letrecs} together with the term-constructors for assignments @{text |
1404 \eqref{letrecs} together with the term-constructors for assignments @{text |
1355 "ANil"} and @{text "ACons"}. Since there is a binding function defined for |
1405 "ANil"} and @{text "ACons"}. Since there is a binding function defined for |
1356 assignments, we have three free-atom functions, namely @{text |
1406 assignments, we have three free-atom functions, namely @{text |
1357 "fa\<^bsub>trm\<^esub>"}, @{text "fa\<^bsub>assn\<^esub>"} and @{text |
1407 "fa\<^bsub>trm\<^esub>"}, @{text "fa\<^bsub>assn\<^esub>"} and @{text |
1358 "fa\<^bsub>bn\<^esub>"} as follows: |
1408 "fa\<^bsub>bn\<^esub>"} as follows: |
1359 % |
1409 |
1360 \begin{center} |
1410 \[\mbox{ |
1361 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} |
1411 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} |
1362 @{text "fa\<^bsub>trm\<^esub> (Let as t)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t - set (bn as)) \<union> fa\<^bsub>bn\<^esub> as"}\\ |
1412 @{text "fa\<^bsub>trm\<^esub> (Let as t)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t - set (bn as)) \<union> fa\<^bsub>bn\<^esub> as"}\\ |
1363 @{text "fa\<^bsub>trm\<^esub> (Let_rec as t)"} & @{text "="} & @{text "(fa\<^bsub>assn\<^esub> as \<union> fa\<^bsub>trm\<^esub> t) - set (bn as)"}\\[1mm] |
1413 @{text "fa\<^bsub>trm\<^esub> (Let_rec as t)"} & @{text "="} & @{text "(fa\<^bsub>assn\<^esub> as \<union> fa\<^bsub>trm\<^esub> t) - set (bn as)"}\smallskip\\ |
1364 |
1414 |
1365 @{text "fa\<^bsub>assn\<^esub> (ANil)"} & @{text "="} & @{term "{}"}\\ |
1415 @{text "fa\<^bsub>assn\<^esub> (ANil)"} & @{text "="} & @{term "{}"}\\ |
1366 @{text "fa\<^bsub>assn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(supp a) \<union> (fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>assn\<^esub> as)"}\\[1mm] |
1416 @{text "fa\<^bsub>assn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(supp a) \<union> (fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>assn\<^esub> as)"}\smallskip\\ |
1367 |
1417 |
1368 @{text "fa\<^bsub>bn\<^esub> (ANil)"} & @{text "="} & @{term "{}"}\\ |
1418 @{text "fa\<^bsub>bn\<^esub> (ANil)"} & @{text "="} & @{term "{}"}\\ |
1369 @{text "fa\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>bn\<^esub> as)"} |
1419 @{text "fa\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>bn\<^esub> as)"} |
1370 \end{tabular} |
1420 \end{tabular}} |
1371 \end{center} |
1421 \]\smallskip |
1372 |
1422 |
1373 \noindent |
1423 |
1374 Recall that @{text ANil} and @{text "ACons"} have no |
1424 \noindent |
1375 binding clause in the specification. The corresponding free-atom |
1425 Recall that @{text ANil} and @{text "ACons"} have no binding clause in the |
1376 function @{text "fa\<^bsub>assn\<^esub>"} therefore returns all free atoms |
1426 specification. The corresponding free-atom function @{text |
1377 of an assignment (in case of @{text "ACons"}, they are given in |
1427 "fa\<^bsub>assn\<^esub>"} therefore returns all free atoms of an assignment |
1378 terms of @{text supp}, @{text "fa\<^bsub>trm\<^esub>"} and @{text "fa\<^bsub>assn\<^esub>"}). |
1428 (in case of @{text "ACons"}, they are given in terms of @{text supp}, @{text |
1379 The binding only takes place in @{text Let} and |
1429 "fa\<^bsub>trm\<^esub>"} and @{text "fa\<^bsub>assn\<^esub>"}). The binding |
1380 @{text "Let_rec"}. In case of @{text "Let"}, the binding clause specifies |
1430 only takes place in @{text Let} and @{text "Let_rec"}. In case of @{text |
1381 that all atoms given by @{text "set (bn as)"} have to be bound in @{text |
1431 "Let"}, the binding clause specifies that all atoms given by @{text "set (bn |
1382 t}. Therefore we have to subtract @{text "set (bn as)"} from @{text |
1432 as)"} have to be bound in @{text t}. Therefore we have to subtract @{text |
1383 "fa\<^bsub>trm\<^esub> t"}. However, we also need to add all atoms that are |
1433 "set (bn as)"} from @{text "fa\<^bsub>trm\<^esub> t"}. However, we also need |
1384 free in @{text "as"}. This is |
1434 to add all atoms that are free in @{text "as"}. This is in contrast with |
1385 in contrast with @{text "Let_rec"} where we have a recursive |
1435 @{text "Let_rec"} where we have a recursive binder to bind all occurrences |
1386 binder to bind all occurrences of the atoms in @{text |
1436 of the atoms in @{text "set (bn as)"} also inside @{text "as"}. Therefore we |
1387 "set (bn as)"} also inside @{text "as"}. Therefore we have to subtract |
1437 have to subtract @{text "set (bn as)"} from both @{text |
1388 @{text "set (bn as)"} from both @{text "fa\<^bsub>trm\<^esub> t"} and @{text "fa\<^bsub>assn\<^esub> as"}. |
1438 "fa\<^bsub>trm\<^esub> t"} and @{text "fa\<^bsub>assn\<^esub> as"}. Like the |
1389 Like the function @{text "bn"}, the function @{text "fa\<^bsub>bn\<^esub>"} traverses the |
1439 function @{text "bn"}, the function @{text "fa\<^bsub>bn\<^esub>"} traverses |
1390 list of assignments, but instead returns the free atoms, which means in this |
1440 the list of assignments, but instead returns the free atoms, which means in |
1391 example the free atoms in the argument @{text "t"}. |
1441 this example the free atoms in the argument @{text "t"}. |
1392 |
1442 |
1393 An interesting point in this |
1443 |
1394 example is that a ``naked'' assignment (@{text "ANil"} or @{text "ACons"}) does not bind any |
1444 An interesting point in this example is that a ``naked'' assignment (@{text |
1395 atoms, even if the binding function is specified over assignments. |
1445 "ANil"} or @{text "ACons"}) does not bind any atoms, even if the binding |
1396 Only in the context of a @{text Let} or @{text "Let_rec"}, where the binding clauses are given, will |
1446 function is specified over assignments. Only in the context of a @{text Let} |
1397 some atoms actually become bound. This is a phenomenon that has also been pointed |
1447 or @{text "Let_rec"}, where the binding clauses are given, will some atoms |
1398 out in \cite{ott-jfp}. For us this observation is crucial, because we would |
1448 actually become bound. This is a phenomenon that has also been pointed out |
1399 not be able to lift the @{text "bn"}-functions to alpha-equated terms if they act on |
1449 in \cite{ott-jfp}. For us this observation is crucial, because we would not |
1400 atoms that are bound. In that case, these functions would \emph{not} respect |
1450 be able to lift the @{text "bn"}-functions to alpha-equated terms if they |
1401 alpha-equivalence. |
1451 act on atoms that are bound. In that case, these functions would \emph{not} |
1402 |
1452 respect alpha-equivalence. |
1403 Next we define the alpha-equivalence relations for the raw types @{text |
1453 |
1404 "ty"}$_{1..n}$ from the specification. We write them as |
1454 Having the free atom functions at our disposal, we can next define the |
1405 |
1455 alpha-equivalence relations for the raw types @{text |
1406 \begin{center} |
1456 "ty"}$_{1..n}$. We write them as |
1407 @{text "\<approx>ty"}$_{1..n}$. |
1457 |
1408 \end{center} |
1458 \[ |
|
1459 \mbox{@{text "\<approx>ty"}$_{1..n}$}. |
|
1460 \]\smallskip |
1409 |
1461 |
1410 \noindent |
1462 \noindent |
1411 Like with the free-atom functions, we also need to |
1463 Like with the free-atom functions, we also need to |
1412 define auxiliary alpha-equivalence relations |
1464 define auxiliary alpha-equivalence relations |
1413 |
1465 |
1414 \begin{center} |
1466 \[ |
1415 @{text "\<approx>bn\<^isub>"}$_{1..m}$ |
1467 \mbox{@{text "\<approx>bn\<^isub>"}$_{1..m}$} |
1416 \end{center} |
1468 \]\smallskip |
1417 |
1469 |
1418 \noindent |
1470 \noindent |
1419 for the binding functions @{text "bn"}$_{1..m}$, |
1471 for the binding functions @{text "bn"}$_{1..m}$, |
1420 To simplify our definitions we will use the following abbreviations for |
1472 To simplify our definitions we will use the following abbreviations for |
1421 \emph{compound equivalence relations} and \emph{compound free-atom functions} acting on tuples. |
1473 \emph{compound equivalence relations} and \emph{compound free-atom functions} acting on tuples. |
1422 |
1474 |
1423 \begin{center} |
1475 \[\mbox{ |
1424 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1476 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1425 @{text "(x\<^isub>1,\<dots>, x\<^isub>n) (R\<^isub>1,\<dots>, R\<^isub>n) (x\<PRIME>\<^isub>1,\<dots>, x\<PRIME>\<^isub>n)"} & @{text "\<equiv>"} & |
1477 @{text "(x\<^isub>1,\<dots>, x\<^isub>n) (R\<^isub>1,\<dots>, R\<^isub>n) (y\<^isub>1,\<dots>, y\<^isub>n)"} & @{text "\<equiv>"} & |
1426 @{text "x\<^isub>1 R\<^isub>1 x\<PRIME>\<^isub>1 \<and> \<dots> \<and> x\<^isub>n R\<^isub>n x\<PRIME>\<^isub>n"}\\ |
1478 @{text "x\<^isub>1 R\<^isub>1 y\<^isub>1 \<and> \<dots> \<and> x\<^isub>n R\<^isub>n y\<^isub>n"}\\ |
1427 @{text "(fa\<^isub>1,\<dots>, fa\<^isub>n) (x\<^isub>1,\<dots>, x\<^isub>n)"} & @{text "\<equiv>"} & @{text "fa\<^isub>1 x\<^isub>1 \<union> \<dots> \<union> fa\<^isub>n x\<^isub>n"}\\ |
1479 @{text "(fa\<^isub>1,\<dots>, fa\<^isub>n) (x\<^isub>1,\<dots>, x\<^isub>n)"} & @{text "\<equiv>"} & @{text "fa\<^isub>1 x\<^isub>1 \<union> \<dots> \<union> fa\<^isub>n x\<^isub>n"}\\ |
1428 \end{tabular} |
1480 \end{tabular}} |
1429 \end{center} |
1481 \]\smallskip |
1430 |
1482 |
1431 |
1483 |
1432 The alpha-equivalence relations are defined as inductive predicates |
1484 The alpha-equivalence relations are defined as inductive predicates |
1433 having a single clause for each term-constructor. Assuming a |
1485 having a single clause for each term-constructor. Assuming a |
1434 term-constructor @{text C} is of type @{text ty} and has the binding clauses |
1486 term-constructor @{text C} is of type @{text ty} and has the binding clauses |
1435 @{term "bc"}$_{1..k}$, then the alpha-equivalence clause has the form |
1487 @{term "bc"}$_{1..k}$, then the alpha-equivalence clause has the form |
1436 |
1488 |
1437 \begin{center} |
1489 \[ |
1438 \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>n \<approx>ty C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>n"}} |
1490 \mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>n \<approx>ty C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>n"}} |
1439 {@{text "prems(bc\<^isub>1) \<dots> prems(bc\<^isub>k)"}}} |
1491 {@{text "prems(bc\<^isub>1) \<dots> prems(bc\<^isub>k)"}}} |
1440 \end{center} |
1492 \]\smallskip |
1441 |
1493 |
1442 \noindent |
1494 \noindent |
1443 The task below is to specify what the premises of a binding clause are. As a |
1495 The task below is to specify what the premises corresponding to a binding |
1444 special instance, we first treat the case where @{text "bc\<^isub>i"} is the |
1496 clause are. To understand better whet the general pattern is, let us first |
1445 empty binding clause of the form |
1497 treat the special instance where @{text "bc\<^isub>i"} is the empty binding clause |
1446 |
1498 of the form |
1447 \begin{center} |
1499 |
|
1500 \[ |
1448 \mbox{\isacommand{binds (set)} @{term "{}"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.} |
1501 \mbox{\isacommand{binds (set)} @{term "{}"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.} |
1449 \end{center} |
1502 \]\smallskip |
1450 |
1503 |
1451 \noindent |
1504 \noindent |
1452 In this binding clause no atom is bound and we only have to alpha-relate the bodies. For this |
1505 In this binding clause no atom is bound and we only have to `alpha-relate' the bodies. For this |
1453 we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>, d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"} |
1506 we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>, d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"} |
1454 whereby the labels @{text "d"}$_{1..q}$ refer to arguments @{text "z"}$_{1..n}$ and |
1507 whereby the labels @{text "d"}$_{1..q}$ refer to arguments @{text "z"}$_{1..n}$ and |
1455 respectively @{text "d\<PRIME>"}$_{1..q}$ to @{text "z\<PRIME>"}$_{1..n}$. In order to relate |
1508 respectively @{text "d\<PRIME>"}$_{1..q}$ to @{text "z\<PRIME>"}$_{1..n}$. In order to relate |
1456 two such tuples we define the compound alpha-equivalence relation @{text "R"} as follows |
1509 two such tuples we define the compound alpha-equivalence relation @{text "R"} as follows |
1457 |
1510 |