282 specification we will need to construct type(s) containing as elements the |
282 specification we will need to construct type(s) containing as elements the |
283 alpha-equated terms. To do so, we use the standard HOL-technique of defining |
283 alpha-equated terms. To do so, we use the standard HOL-technique of defining |
284 a new type by identifying a non-empty subset of an existing type. The |
284 a new type by identifying a non-empty subset of an existing type. The |
285 construction we perform in Isabelle/HOL can be illustrated by the following picture: |
285 construction we perform in Isabelle/HOL can be illustrated by the following picture: |
286 |
286 |
287 \[ |
287 \begin{equation}\label{picture} |
288 \mbox{\begin{tikzpicture}[scale=1.1] |
288 \mbox{\begin{tikzpicture}[scale=1.1] |
289 %\draw[step=2mm] (-4,-1) grid (4,1); |
289 %\draw[step=2mm] (-4,-1) grid (4,1); |
290 |
290 |
291 \draw[very thick] (0.7,0.4) circle (4.25mm); |
291 \draw[very thick] (0.7,0.4) circle (4.25mm); |
292 \draw[rounded corners=1mm, very thick] ( 0.0,-0.8) rectangle ( 1.8, 0.9); |
292 \draw[rounded corners=1mm, very thick] ( 0.0,-0.8) rectangle ( 1.8, 0.9); |
492 |
492 |
493 The most original aspect of the nominal logic work of Pitts is a general |
493 The most original aspect of the nominal logic work of Pitts is a general |
494 definition for the notion of the ``set of free variables of an object @{text |
494 definition for the notion of the ``set of free variables of an object @{text |
495 "x"}''. This notion, written @{term "supp x"}, is general in the sense that |
495 "x"}''. This notion, written @{term "supp x"}, is general in the sense that |
496 it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
496 it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
497 products, sets and even functions. The definition depends only on the |
497 products, sets and even functions. Its definition depends only on the |
498 permutation operation and on the notion of equality defined for the type of |
498 permutation operation and on the notion of equality defined for the type of |
499 @{text x}, namely: |
499 @{text x}, namely: |
500 |
500 |
501 \begin{equation}\label{suppdef} |
501 \begin{equation}\label{suppdef} |
502 @{thm supp_def[no_vars, THEN eq_reflection]} |
502 @{thm supp_def[no_vars, THEN eq_reflection]} |
748 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
748 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
749 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 |
750 abstract a single atom. |
750 abstract a single atom. |
751 |
751 |
752 In the rest of this section we are going to show that the alpha-equivalences really |
752 In the rest of this section we are going to show that the alpha-equivalences really |
753 lead to abstractions where some atoms are bound. For this we are going to introduce |
753 lead to abstractions where some atoms are bound (more precisely removed from the |
|
754 support). For this we are going to introduce |
754 three abstraction types that are quotients with respect to the relations |
755 three abstraction types that are quotients with respect to the relations |
755 |
756 |
756 \begin{equation} |
757 \begin{equation} |
757 \begin{array}{r} |
758 \begin{array}{r} |
758 @{term "alpha_abs_set (as, x) (bs, y)"}~~@{text "\<equiv>"}~~@{term "alpha_set_ex (as, x) equal supp (bs, y)"}\\ |
759 @{term "alpha_abs_set (as, x) (bs, y)"}~~@{text "\<equiv>"}~~@{term "alpha_set_ex (as, x) equal supp (bs, y)"}\\ |
783 operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, are equivariant |
783 operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, are equivariant |
784 (see \cite{HuffmanUrban10}). Finally we apply the permutation operation on booleans. |
784 (see \cite{HuffmanUrban10}). Finally we apply the permutation operation on booleans. |
785 \end{proof} |
785 \end{proof} |
786 |
786 |
787 \noindent |
787 \noindent |
788 This lemma allows us to use our quotient package for introducing |
788 Recall the picture shown in \eqref{picture} about new types in HOL. |
|
789 The lemma above allows us to use our quotient package for introducing |
789 new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"} |
790 new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"} |
790 representing alpha-equivalence classes of pairs of type |
791 representing alpha-equivalence classes of pairs of type |
791 @{text "(atom set) \<times> \<beta>"} (in the first two cases) and of type @{text "(atom list) \<times> \<beta>"} |
792 @{text "(atom set) \<times> \<beta>"} (in the first two cases) and of type @{text "(atom list) \<times> \<beta>"} |
792 (in the third case). |
793 (in the third case). |
793 The elements in these types will be, respectively, written as |
794 The elements in these types will be, respectively, written as |
894 |
895 |
895 \noindent |
896 \noindent |
896 This is because for every finite sets of atoms, say @{text "bs"}, we have |
897 This is because for every finite sets of atoms, say @{text "bs"}, we have |
897 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
898 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
898 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
899 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
899 Theorem~\ref{suppabs}. |
900 the first equation of Theorem~\ref{suppabs}. |
900 |
901 |
901 The method of first considering abstractions of the form @{term "Abs_set as |
902 The method of first considering abstractions of the form @{term "Abs_set as |
902 x"} etc is motivated by the fact that we can conveniently establish at the |
903 x"} etc is motivated by the fact that we can conveniently establish at the |
903 Isabelle/HOL level properties about them. It would be extremely laborious |
904 Isabelle/HOL level properties about them. It would be extremely laborious |
904 to write custom ML-code that derives automatically such properties for every |
905 to write custom ML-code that derives automatically such properties for every |
1154 We also need to restrict the form of the binding functions in order to |
1156 We also need to restrict the form of the binding functions in order to |
1155 ensure the @{text "bn"}-functions can be defined for alpha-equated |
1157 ensure the @{text "bn"}-functions can be defined for alpha-equated |
1156 terms. The main restriction is that we cannot return an atom in a binding |
1158 terms. The main restriction is that we cannot return an atom in a binding |
1157 function that is also bound in the corresponding term-constructor. |
1159 function that is also bound in the corresponding term-constructor. |
1158 Consider again the specification for @{text "trm"} and a contrived |
1160 Consider again the specification for @{text "trm"} and a contrived |
1159 version for assignments, @{text "assn"}: |
1161 version for assignments @{text "assn"}: |
1160 |
1162 |
1161 \begin{equation}\label{bnexp} |
1163 \begin{equation}\label{bnexp} |
1162 \mbox{% |
1164 \mbox{% |
1163 \begin{tabular}{@ {}l@ {}} |
1165 \begin{tabular}{@ {}l@ {}} |
1164 \isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\ |
1166 \isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\ |
1165 \isacommand{and} @{text "assn"} $=$\\ |
1167 \isacommand{and} @{text "assn"} $=$\\ |
1166 \hspace{5mm}\phantom{$\mid$}~@{text "ANil"}\\ |
1168 \hspace{5mm}\phantom{$\mid$}~@{text "ANil'"}\\ |
1167 \hspace{5mm}$\mid$~@{text "ACons x::name y::name t::trm assn"} |
1169 \hspace{5mm}$\mid$~@{text "ACons' x::name y::name t::trm assn"} |
1168 \;\;\isacommand{binds} @{text "y"} \isacommand{in} @{text t}\\ |
1170 \;\;\isacommand{binds} @{text "y"} \isacommand{in} @{text t}\\ |
1169 \isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\ |
1171 \isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\ |
1170 \isacommand{where}~@{text "bn(ANil) = []"}\\ |
1172 \isacommand{where}~@{text "bn(ANil') = []"}\\ |
1171 \hspace{5mm}$\mid$~@{text "bn(ACons x y t as) = [atom x] @ bn(as)"}\\ |
1173 \hspace{5mm}$\mid$~@{text "bn(ACons' x y t as) = [atom x] @ bn(as)"}\\ |
1172 \end{tabular}} |
1174 \end{tabular}} |
1173 \end{equation}\smallskip |
1175 \end{equation}\smallskip |
1174 |
1176 |
1175 \noindent |
1177 \noindent |
1176 In this example the term constructor @{text "ACons"} contains a binding |
1178 In this example the term constructor @{text "ACons'"} contains a binding |
1177 clause, and also is used in the definition of the binding function. The |
1179 clause, and also is used in the definition of the binding function. The |
1178 restriction we have to impose is that the binding function can only return |
1180 restriction we have to impose is that the binding function can only return |
1179 free atoms, that is the ones that are not mentioned in a binding clause. |
1181 free atoms, that is the ones that are not mentioned in a binding clause. |
1180 Therefore @{text "y"} cannot be used in the binding function @{text "bn"} |
1182 Therefore @{text "y"} cannot be used in the binding function @{text "bn"} |
1181 (since it is bound in @{text "ACons"} by the binding clause), but @{text x} |
1183 (since it is bound in @{text "ACons'"} by the binding clause), but @{text x} |
1182 can (since it is a free atom). This restriction is sufficient for lifting |
1184 can (since it is a free atom). This restriction is sufficient for lifting |
1183 the binding function to alpha-equated terms. If we would permit that @{text "bn"} |
1185 the binding function to alpha-equated terms. If we would permit that @{text "bn"} |
1184 can also return @{text "y"}, then it would not be respectful and therefore |
1186 can also return @{text "y"}, then it would not be respectful and therefore |
1185 cannot be lifted. |
1187 cannot be lifted. |
1186 |
1188 |
1187 In the version of Nominal Isabelle described here, we also adopted the |
1189 In the version of Nominal Isabelle described here, we also adopted the |
1188 restriction from the Ott-tool that binding functions can only return: the |
1190 restriction from the Ott-tool that binding functions can only return: the |
1189 empty set or empty list (as in case @{text ANil}), a singleton set or |
1191 empty set or empty list (as in case @{text ANil'}), a singleton set or |
1190 singleton list containing an atom (case @{text PVar} in \eqref{letpat}), or |
1192 singleton list containing an atom (case @{text PVar} in \eqref{letpat}), or |
1191 unions of atom sets or appended atom lists (case @{text ACons}). This |
1193 unions of atom sets or appended atom lists (case @{text ACons'}). This |
1192 restriction will simplify some automatic definitions and proofs later on. |
1194 restriction will simplify some automatic definitions and proofs later on. |
1193 |
1195 |
1194 In order to simplify our definitions of free atoms and alpha-equivalence, |
1196 In order to simplify our definitions of free atoms and alpha-equivalence, |
1195 we shall assume specifications |
1197 we shall assume specifications |
1196 of term-calculi are implicitly \emph{completed}. By this we mean that |
1198 of term-calculi are implicitly \emph{completed}. By this we mean that |
1246 non-empty and the types in the constructors only occur in positive |
1248 non-empty and the types in the constructors only occur in positive |
1247 position (see \cite{Berghofer99} for an in-depth description of the datatype package |
1249 position (see \cite{Berghofer99} for an in-depth description of the datatype package |
1248 in Isabelle/HOL). |
1250 in Isabelle/HOL). |
1249 We subsequently define each of the user-specified binding |
1251 We subsequently define each of the user-specified binding |
1250 functions @{term "bn"}$_{1..m}$ by recursion over the corresponding |
1252 functions @{term "bn"}$_{1..m}$ by recursion over the corresponding |
1251 raw datatype. We can also easily define permutation operations by |
1253 raw datatype. We also define permutation operations by |
1252 recursion so that for each term constructor @{text "C"} we have that |
1254 recursion so that for each term constructor @{text "C"} we have that |
1253 |
1255 |
1254 \begin{equation}\label{ceqvt} |
1256 \begin{equation}\label{ceqvt} |
1255 @{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"} |
1257 @{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"} |
1256 \end{equation}\smallskip |
1258 \end{equation}\smallskip |
1257 |
1259 |
1258 The first non-trivial step we have to perform is the generation of |
1260 The first non-trivial step we have to perform is the generation of |
1259 \emph{free-atom functions} from the specification.\footnote{Admittedly, the |
1261 \emph{free-atom functions} from the specification.\footnote{Admittedly, the |
1260 details of our definitions are somewhat involved. However they are still |
1262 details of our definitions will be somewhat involved. However they are still |
1261 conceptually simple in comparison with the ``positional'' approach taken in |
1263 conceptually simple in comparison with the ``positional'' approach taken in |
1262 Ott \cite[Pages 88--95]{ott-jfp}, which uses \emph{occurences} and |
1264 Ott \cite[Pages 88--95]{ott-jfp}, which uses \emph{occurences} and |
1263 \emph{partial equivalence relations} over sets of occurences.} For the |
1265 \emph{partial equivalence relations} over sets of occurences.} For the |
1264 \emph{raw} types @{text "ty"}$_{1..n}$ we define the free-atom functions |
1266 \emph{raw} types @{text "ty"}$_{1..n}$ we define the free-atom functions |
1265 |
1267 |
1319 |
1321 |
1320 \noindent |
1322 \noindent |
1321 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1323 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1322 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1324 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1323 we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i d\<^isub>i = supp d\<^isub>i"}}. The reason |
1325 we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i d\<^isub>i = supp d\<^isub>i"}}. The reason |
1324 for the latter choice is that @{text "ty"}$_i$ is not a type that is part of the specification, and |
1326 for the latter is that @{text "ty"}$_i$ is not a type that is part of the specification, and |
1325 we assume @{text supp} is the generic notion that characterises the free variables of |
1327 we assume @{text supp} is the generic notion that characterises the free variables of |
1326 a type (in fact in the next section we will show that the free-variable functions we |
1328 a type (in fact in the next section we will show that the free-variable functions we |
1327 define here, are equal to the support once lifted to alpha-equivalence classes). |
1329 define here, are equal to the support once lifted to alpha-equivalence classes). |
1328 |
1330 |
1329 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1331 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1330 for atom types to which shallow binders may refer\\[-4mm] |
1332 for atom types to which shallow binders may refer\\[-4mm] |
1331 |
1333 |
1332 \[\mbox{ |
1334 \begin{equation}\label{bnaux}\mbox{ |
1333 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1335 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
1334 @{text "bn\<^bsub>atom\<^esup> a"} & @{text "\<equiv>"} & @{text "{atom a}"}\\ |
1336 @{text "bn\<^bsub>atom\<^esup> a"} & @{text "\<equiv>"} & @{text "{atom a}"}\\ |
1335 @{text "bn\<^bsub>atom_set\<^esup> as"} & @{text "\<equiv>"} & @{text "atoms as"}\\ |
1337 @{text "bn\<^bsub>atom_set\<^esup> as"} & @{text "\<equiv>"} & @{text "atoms as"}\\ |
1336 @{text "bn\<^bsub>atom_list\<^esub> as"} & @{text "\<equiv>"} & @{text "atoms (set as)"} |
1338 @{text "bn\<^bsub>atom_list\<^esub> as"} & @{text "\<equiv>"} & @{text "atoms (set as)"} |
1337 \end{tabular}} |
1339 \end{tabular}} |
1338 \]\smallskip |
1340 \end{equation}\smallskip |
1339 |
1341 |
1340 \noindent |
1342 \noindent |
1341 Like the function @{text atom}, the function @{text "atoms"} coerces |
1343 Like the function @{text atom}, the function @{text "atoms"} coerces |
1342 a set of atoms to a set of the generic atom type. |
1344 a set of atoms to a set of the generic atom type. |
1343 It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}. |
1345 It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}. |
1344 The set @{text B} is then formally defined as |
1346 The set @{text B} in \eqref{fadef} is then formally defined as |
1345 |
1347 |
1346 \begin{equation}\label{bdef} |
1348 \begin{equation}\label{bdef} |
1347 @{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> ... \<union> bn_ty\<^isub>p b\<^isub>p"} |
1349 @{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> ... \<union> bn_ty\<^isub>p b\<^isub>p"} |
1348 \end{equation}\smallskip |
1350 \end{equation}\smallskip |
1349 |
1351 |
1350 \noindent |
1352 \noindent |
1351 where we use the auxiliary binding functions for shallow binders (that means |
1353 where we use the auxiliary binding functions from \eqref{bnaux} for shallow |
1352 when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or |
1354 binders (that means when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or |
1353 @{text "atom list"}). The set @{text "B'"} collects all free atoms in |
1355 @{text "atom list"}). The set @{text "B'"} in \eqref{fadef} collects all free atoms in |
1354 non-recursive deep binders. Let us assume these binders in the binding |
1356 non-recursive deep binders. Let us assume these binders in the binding |
1355 clause @{text "bc\<^isub>i"} are |
1357 clause @{text "bc\<^isub>i"} are |
1356 |
1358 |
1357 \[ |
1359 \[ |
1358 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1360 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1359 \]\smallskip |
1361 \]\smallskip |
1360 |
1362 |
1361 \noindent |
1363 \noindent |
1362 with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ (see |
1364 with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ and |
1363 \eqref{bdef}) and none of the @{text "l"}$_{1..r}$ being among the bodies |
1365 none of the @{text "l"}$_{1..r}$ being among the bodies |
1364 @{text "d"}$_{1..q}$. The set @{text "B'"} is defined as |
1366 @{text "d"}$_{1..q}$. The set @{text "B'"} is defined as |
1365 |
1367 |
1366 \begin{equation}\label{bprimedef} |
1368 \begin{equation}\label{bprimedef} |
1367 @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"} |
1369 @{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"} |
1368 \end{equation}\smallskip |
1370 \end{equation}\smallskip |
1369 |
1371 |
1370 \noindent |
1372 \noindent |
1371 This completes the definition of the free-atom functions @{text "fa_ty"}$_{1..n}$. |
1373 This completes all clauses for the free-atom functions @{text "fa_ty"}$_{1..n}$. |
1372 |
1374 |
1373 Note that for non-recursive deep binders, we have to add in \eqref{fadef} |
1375 Note that for non-recursive deep binders, we have to add in \eqref{fadef} |
1374 the set of atoms that are left unbound by the binding functions @{text |
1376 the set of atoms that are left unbound by the binding functions @{text |
1375 "bn"}$_{1..m}$, see also the definition in \eqref{bprimedef}. We used for |
1377 "bn"}$_{1..m}$. We used for |
1376 the definition of this set the functions @{text "fa_bn"}$_{1..m}$. The |
1378 the definition of this set the functions @{text "fa_bn"}$_{1..m}$. The |
1377 definition for those functions needs to be extracted from the clauses the |
1379 definition for those functions needs to be extracted from the clauses the |
1378 user provided for @{text "bn"}$_{1..m}$ Assume the user specified a @{text |
1380 user provided for @{text "bn"}$_{1..m}$ Assume the user specified a @{text |
1379 bn}-clause of the form |
1381 bn}-clause of the form |
1380 |
1382 |
1389 \[\mbox{ |
1391 \[\mbox{ |
1390 \begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}} |
1392 \begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}} |
1391 $\bullet$ & @{term "fa_ty\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text "rhs"}\\ |
1393 $\bullet$ & @{term "fa_ty\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text "rhs"}\\ |
1392 & (that means nothing is bound in @{text "z\<^isub>i"} by the binding function),\smallskip\\ |
1394 & (that means nothing is bound in @{text "z\<^isub>i"} by the binding function),\smallskip\\ |
1393 $\bullet$ & @{term "fa_bn\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"} |
1395 $\bullet$ & @{term "fa_bn\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"} |
1394 with the recursive call @{text "bn\<^isub>i z\<^isub>i"}, and\smallskip\\ |
1396 with the recursive call @{text "bn\<^isub>i z\<^isub>i"}\\ |
|
1397 & (that means whatever is ``left over'' from the @{text "bn"}-function is free)\smallskip\\ |
1395 $\bullet$ & @{term "{}"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"}, |
1398 $\bullet$ & @{term "{}"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"}, |
1396 but without a recursive call\\ |
1399 but without a recursive call\\ |
1397 & (that means @{text "z\<^isub>i"} is supposed to become bound by the binding function)\\ |
1400 & (that means @{text "z\<^isub>i"} is supposed to become bound by the binding function)\\ |
1398 \end{tabular}} |
1401 \end{tabular}} |
1399 \]\smallskip |
1402 \]\smallskip |