683 |
683 |
684 \noindent |
684 \noindent |
685 Note that the relation is |
685 Note that the relation is |
686 dependent on a free-atom function @{text "fa"} and a relation @{text |
686 dependent on a free-atom function @{text "fa"} and a relation @{text |
687 "R"}. The reason for this extra generality is that we will use |
687 "R"}. The reason for this extra generality is that we will use |
688 $\approx_{\,\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In |
688 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ for both ``raw'' terms and |
|
689 alpha-equated terms. In |
689 the latter case, @{text R} will be replaced by equality @{text "="} and we |
690 the latter case, @{text R} will be replaced by equality @{text "="} and we |
690 will prove that @{text "fa"} is equal to @{text "supp"}. |
691 will prove that @{text "fa"} is equal to @{text "supp"}. |
691 |
692 |
692 Definition \ref{alphaset} does not make any distinction between the |
693 Definition \ref{alphaset} does not make any distinction between the |
693 order of abstracted atoms. If we want this, then we can define alpha-equivalence |
694 order of abstracted atoms. If we want this, then we can define alpha-equivalence |
768 \end{equation}\smallskip |
769 \end{equation}\smallskip |
769 |
770 |
770 \noindent |
771 \noindent |
771 Note that in these relation we replaced the free-atom function @{text "fa"} |
772 Note that in these relation we replaced the free-atom function @{text "fa"} |
772 with @{term "supp"} and the relation @{text R} with equality. We can show |
773 with @{term "supp"} and the relation @{text R} with equality. We can show |
773 the following properties: |
774 the following two properties: |
774 |
775 |
775 \begin{lem}\label{alphaeq} |
776 \begin{lem}\label{alphaeq} |
776 The relations $\approx_{\,\textit{set}}^{=, \textit{supp}}$, |
777 The relations $\approx_{\,\textit{set}}^{=, \textit{supp}}$, |
777 $\approx_{\,\textit{set+}}^{=, \textit{supp}}$ |
778 $\approx_{\,\textit{set+}}^{=, \textit{supp}}$ |
778 and $\approx_{\,\textit{list}}^{=, \textit{supp}}$ are |
779 and $\approx_{\,\textit{list}}^{=, \textit{supp}}$ are |
784 a permutation @{text "\<pi>"} and for the proof obligation take @{term "- |
785 a permutation @{text "\<pi>"} and for the proof obligation take @{term "- |
785 \<pi>"}. In case of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} |
786 \<pi>"}. In case of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} |
786 and @{text "\<pi>\<^isub>2"}, and for the proof obligation use @{text |
787 and @{text "\<pi>\<^isub>2"}, and for the proof obligation use @{text |
787 "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means @{term "alpha_set_ex (\<pi> \<bullet> as, |
788 "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means @{term "alpha_set_ex (\<pi> \<bullet> as, |
788 \<pi> \<bullet> x) equal supp (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided \mbox{@{term |
789 \<pi> \<bullet> x) equal supp (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided \mbox{@{term |
789 "alpha_set_ex (as, x) equal supp(bs, y)"}} holds. To show this, we need to |
790 "alpha_set_ex (as, x) equal supp(bs, y)"}} holds. From the assumption we |
790 unfold the definitions and `pull out' the permutations, which is possible |
791 have a permutation @{text "\<pi>'"} and for the proof obligation use @{text "\<pi> \<bullet> |
791 since all operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, |
792 \<pi>'"}. To show then equivariance, we need to `pull out' the permutations, |
792 are equivariant (see \cite{HuffmanUrban10}). Finally we apply the |
793 which is possible since all operators, namely as @{text "#\<^sup>*, -, =, \<bullet>, |
793 permutation operation on booleans. |
794 set"} and @{text "supp"}, are equivariant (see |
|
795 \cite{HuffmanUrban10}). Finally, we apply the permutation operation on |
|
796 booleans. |
794 \end{proof} |
797 \end{proof} |
795 |
798 |
796 \noindent |
799 \noindent |
797 Recall the picture shown in \eqref{picture} about new types in HOL. |
800 Recall the picture shown in \eqref{picture} about new types in HOL. |
798 The lemma above allows us to use our quotient package for introducing |
801 The lemma above allows us to use our quotient package for introducing |
859 @{thm (prem 2) Abs_swap1(1)[where bs="as", no_vars]} then |
862 @{thm (prem 2) Abs_swap1(1)[where bs="as", no_vars]} then |
860 @{thm (concl) Abs_swap1(1)[where bs="as", no_vars]} |
863 @{thm (concl) Abs_swap1(1)[where bs="as", no_vars]} |
861 \end{lem} |
864 \end{lem} |
862 |
865 |
863 \begin{proof} |
866 \begin{proof} |
864 This lemma is straightforward using \eqref{abseqiff} and observing that |
867 If @{term "a = b"} the lemma is immediate, since @{term "(a \<rightleftharpoons> b) = 0"}. |
865 the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}. |
868 Also in the other case, it is straightforward using \eqref{abseqiff} and |
866 We therefore can use as permutation the swapping @{term "(a \<rightleftharpoons> b)"}. |
869 observing that the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = |
|
870 (supp x - as)"}. We therefore can use as permutation the swapping @{term |
|
871 "(a \<rightleftharpoons> b)"}. |
867 \end{proof} |
872 \end{proof} |
868 |
873 |
869 \noindent |
874 \noindent |
870 Assuming that @{text "x"} has finite support, this lemma together |
875 Assuming that @{text "x"} has finite support, this lemma together |
871 with \eqref{absperm} allows us to show |
876 with \eqref{absperm} allows us to show |
906 This is because for every finite sets of atoms, say @{text "bs"}, we have |
911 This is because for every finite sets of atoms, say @{text "bs"}, we have |
907 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
912 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
908 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
913 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
909 the first equation of Theorem~\ref{suppabs}. |
914 the first equation of Theorem~\ref{suppabs}. |
910 |
915 |
911 Recall the definition of support \eqref{suppdef}, and note the difference between |
916 Recall the definition of support in \eqref{suppdef}, and note the difference between |
912 the support of a ``raw'' pair and an abstraction |
917 the support of a ``raw'' pair and an abstraction |
913 |
918 |
914 \[ |
919 \[ |
915 @{term "supp (as, x) = supp as \<union> supp x"}\hspace{15mm} |
920 @{term "supp (as, x) = supp as \<union> supp x"}\hspace{15mm} |
916 @{term "supp (Abs_set as x) = supp x - as"} |
921 @{term "supp (Abs_set as x) = supp x - as"} |
917 \]\smallskip |
922 \]\smallskip |
918 |
923 |
919 \noindent |
924 \noindent |
920 While the permutation operations behave in both cases the same (the permutation |
925 While the permutation operations behave in both cases the same (a permutation |
921 is just moved to the arguments), the notion of equality is different for pairs and |
926 is just moved to the arguments), the notion of equality is different for pairs and |
922 abstractions. Therefore we have different supports. |
927 abstractions. Therefore we have different supports. |
923 |
928 |
924 The method of first considering abstractions of the form @{term "Abs_set as |
929 The method of first considering abstractions of the form @{term "Abs_set as |
925 x"} etc is motivated by the fact that we can conveniently establish at the |
930 x"} etc is motivated by the fact that we can conveniently establish at the |
1280 |
1285 |
1281 \begin{equation}\label{ceqvt} |
1286 \begin{equation}\label{ceqvt} |
1282 @{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"} |
1287 @{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"} |
1283 \end{equation}\smallskip |
1288 \end{equation}\smallskip |
1284 |
1289 |
|
1290 \noindent |
|
1291 We need this operation later when we define the notion of alpha-equivalence. |
|
1292 |
1285 The first non-trivial step we have to perform is the generation of |
1293 The first non-trivial step we have to perform is the generation of |
1286 \emph{free-atom functions} from the specifications.\footnote{Admittedly, the |
1294 \emph{free-atom functions} from the specifications.\footnote{Admittedly, the |
1287 details of our definitions will be somewhat involved. However they are still |
1295 details of our definitions will be somewhat involved. However they are still |
1288 conceptually simple in comparison with the ``positional'' approach taken in |
1296 conceptually simple in comparison with the ``positional'' approach taken in |
1289 Ott \cite[Pages 88--95]{ott-jfp}, which uses the notions of \emph{occurences} and |
1297 Ott \cite[Pages 88--95]{ott-jfp}, which uses the notions of \emph{occurences} and |
1304 @{text "fa_bn"}\mbox{$_{1..m}$}. |
1312 @{text "fa_bn"}\mbox{$_{1..m}$}. |
1305 \]\smallskip |
1313 \]\smallskip |
1306 |
1314 |
1307 \noindent |
1315 \noindent |
1308 The reason for this setup is that in a deep binder not all atoms have to be |
1316 The reason for this setup is that in a deep binder not all atoms have to be |
1309 bound, as we saw in the example with ``plain'' @{text Let}s. We need therefore a function |
1317 bound, as we saw in the example with ``plain'' @{text Let}s. We need |
1310 that calculates those free atoms in a deep binder. |
1318 therefore functions that calculate those free atoms in deep binders. |
1311 |
1319 |
1312 While the idea behind these free-atom functions is clear (they just |
1320 While the idea behind these free-atom functions is simple (they just |
1313 collect all atoms that are not bound), because of our rather complicated |
1321 collect all atoms that are not bound), because of our rather complicated |
1314 binding mechanisms their definitions are somewhat involved. Given |
1322 binding mechanisms their definitions are somewhat involved. Given |
1315 a term-constructor @{text "C"} of type @{text ty} and some associated |
1323 a ``raw'' term-constructor @{text "C"} of type @{text ty} and some associated |
1316 binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text |
1324 binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text |
1317 "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text |
1325 "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text |
1318 "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding |
1326 "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding |
1319 clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). |
1327 clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). |
1320 Suppose the binding clause @{text bc\<^isub>i} is of the form |
1328 Suppose the binding clause @{text bc\<^isub>i} is of the form |
1375 \end{equation}\smallskip |
1383 \end{equation}\smallskip |
1376 |
1384 |
1377 \noindent |
1385 \noindent |
1378 where we use the auxiliary binding functions from \eqref{bnaux} for shallow |
1386 where we use the auxiliary binding functions from \eqref{bnaux} for shallow |
1379 binders (that means when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or |
1387 binders (that means when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or |
1380 @{text "atom list"}). The set @{text "B'"} in \eqref{fadef} collects all free atoms in |
1388 @{text "atom list"}). |
|
1389 |
|
1390 The set @{text "B'"} in \eqref{fadef} collects all free atoms in |
1381 non-recursive deep binders. Let us assume these binders in the binding |
1391 non-recursive deep binders. Let us assume these binders in the binding |
1382 clause @{text "bc\<^isub>i"} are |
1392 clause @{text "bc\<^isub>i"} are |
1383 |
1393 |
1384 \[ |
1394 \[ |
1385 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1395 \mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}} |
1576 $\approx_{\,\textit{list}}^{\textit{R}, \textit{fa}}$ for the other |
1586 $\approx_{\,\textit{list}}^{\textit{R}, \textit{fa}}$ for the other |
1577 binding modes). This premise defines alpha-equivalence of two abstractions |
1587 binding modes). This premise defines alpha-equivalence of two abstractions |
1578 involving multiple binders. As above, we first build the tuples @{text "D"} and |
1588 involving multiple binders. As above, we first build the tuples @{text "D"} and |
1579 @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding |
1589 @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding |
1580 compound alpha-relation @{text "R"} (shown in \eqref{rempty}). |
1590 compound alpha-relation @{text "R"} (shown in \eqref{rempty}). |
1581 For $\approx_{\,\textit{set}}^{R, fa}$ we also need |
1591 For $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ we also need |
1582 a compound free-atom function for the bodies defined as |
1592 a compound free-atom function for the bodies defined as |
1583 |
1593 |
1584 \[ |
1594 \[ |
1585 \mbox{@{text "fa \<equiv> (fa_ty\<^isub>1,\<dots>, fa_ty\<^isub>q)"}} |
1595 \mbox{@{text "fa \<equiv> (fa_ty\<^isub>1,\<dots>, fa_ty\<^isub>q)"}} |
1586 \]\smallskip |
1596 \]\smallskip |
1664 non-empty ones (we just have to unfold the definition of |
1674 non-empty ones (we just have to unfold the definition of |
1665 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ and take @{text "0"} |
1675 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ and take @{text "0"} |
1666 for the existentially quantified permutation). |
1676 for the existentially quantified permutation). |
1667 |
1677 |
1668 Again let us take a look at a concrete example for these definitions. For |
1678 Again let us take a look at a concrete example for these definitions. For |
1669 teh specification given in \eqref{letrecs} |
1679 the specification given in \eqref{letrecs} |
1670 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1680 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1671 $\approx_{\textit{bn}}$ with the following clauses: |
1681 $\approx_{\textit{bn}}$ with the following clauses: |
1672 |
1682 |
1673 \[\mbox{ |
1683 \[\mbox{ |
1674 \begin{tabular}{@ {}c @ {}} |
1684 \begin{tabular}{@ {}c @ {}} |
1702 clause for @{text "Let"} (which has |
1712 clause for @{text "Let"} (which has |
1703 a non-recursive binder). |
1713 a non-recursive binder). |
1704 The underlying reason is that the terms inside an assignment are not meant |
1714 The underlying reason is that the terms inside an assignment are not meant |
1705 to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, |
1715 to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, |
1706 because there all components of an assignment are ``under'' the binder. |
1716 because there all components of an assignment are ``under'' the binder. |
1707 Note also that in case of more than one body (e.g.~@{text "Let_rec"}-case) |
1717 Note also that in case of more than one body (e.g.~in the @{text "Let_rec"}-case) |
1708 we need to parametrise the relation $\approx_{\textit{list}}$ with compound |
1718 we need to parametrise the relation $\approx_{\textit{list}}$ with a compound |
1709 equivalence relations and compund free-atom functions. |
1719 equivalence relation and a compound free-atom function. This is because the |
|
1720 corresponding binding cluase specifies a binder with two bodies. |
1710 *} |
1721 *} |
1711 |
1722 |
1712 section {* Establishing the Reasoning Infrastructure *} |
1723 section {* Establishing the Reasoning Infrastructure *} |
1713 |
1724 |
1714 text {* |
1725 text {* |
1728 @{text "(ii)"} The relations @{text "\<approx>ty"}$_{1..n}$ and |
1739 @{text "(ii)"} The relations @{text "\<approx>ty"}$_{1..n}$ and |
1729 @{text "\<approx>bn"}$_{1..m}$ are equivariant. |
1740 @{text "\<approx>bn"}$_{1..m}$ are equivariant. |
1730 \end{lem} |
1741 \end{lem} |
1731 |
1742 |
1732 \begin{proof} |
1743 \begin{proof} |
1733 The function package of Isabelle/HOL allows us to prove the first part is by |
1744 The function package of Isabelle/HOL \cite{Krauss09} allows us to prove the |
1734 mutual induction over the definitions of the functions (we know that they |
1745 first part is by mutual induction over the definitions of the functions.\footnote{We |
1735 are terminating functions, from which an induction principle can be |
1746 know that they are terminating functions. From this an induction principle |
1736 derived). The second is by a straightforward induction over the rules of |
1747 is derived by the function package.} The second is by a straightforward |
1737 @{text "\<approx>ty"}$_{1..n}$ and @{text "\<approx>bn"}$_{1..m}$ using the first part. |
1748 induction over the rules of @{text "\<approx>ty"}$_{1..n}$ and @{text "\<approx>bn"}$_{1..m}$ using |
|
1749 the first part. |
1738 \end{proof} |
1750 \end{proof} |
1739 |
1751 |
1740 \noindent |
1752 \noindent |
1741 Next we establish that the alpha-equivalence relations defined in the |
1753 Next we establish that the alpha-equivalence relations defined in the |
1742 previous section are indeed equivalence relations. |
1754 previous section are indeed equivalence relations. |
1756 |
1768 |
1757 \noindent |
1769 \noindent |
1758 We can feed the last lemma into our quotient package and obtain new types |
1770 We can feed the last lemma into our quotient package and obtain new types |
1759 @{text "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types |
1771 @{text "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types |
1760 @{text "ty"}$_{1..n}$. We also obtain definitions for the term-constructors |
1772 @{text "ty"}$_{1..n}$. We also obtain definitions for the term-constructors |
1761 @{text "C"}$^\alpha_{1..k}$ from the raw term-constructors @{text |
1773 @{text "C"}$^\alpha_{1..k}$ from the ``raw'' term-constructors @{text |
1762 "C"}$_{1..k}$, and similar definitions for the free-atom functions @{text |
1774 "C"}$_{1..k}$, and similar definitions for the free-atom functions @{text |
1763 "fa_ty"}$^\alpha_{1..n}$ and @{text "fa_bn"}$^\alpha_{1..m}$ as well as the |
1775 "fa_ty"}$^\alpha_{1..n}$ and @{text "fa_bn"}$^\alpha_{1..m}$ as well as the |
1764 binding functions @{text "bn"}$^\alpha_{1..m}$. However, these definitions |
1776 binding functions @{text "bn"}$^\alpha_{1..m}$. However, these definitions |
1765 are not really useful to the user, since they are given in terms of the |
1777 are not really useful to the user, since they are given in terms of the |
1766 isomorphisms we obtained by creating new types in Isabelle/HOL (recall the |
1778 isomorphisms we obtained by creating new types in Isabelle/HOL (recall the |
1782 \begin{equation}\label{distinctraw} |
1794 \begin{equation}\label{distinctraw} |
1783 \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r"}\;$\not\approx$@{text ty}\;@{text "D y\<^isub>1 \<dots> y\<^isub>s"}} |
1795 \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r"}\;$\not\approx$@{text ty}\;@{text "D y\<^isub>1 \<dots> y\<^isub>s"}} |
1784 \end{equation}\smallskip |
1796 \end{equation}\smallskip |
1785 |
1797 |
1786 \noindent |
1798 \noindent |
1787 holds for the corresponding raw term-constructors. |
1799 holds for the corresponding ``raw'' term-constructors. |
1788 In order to deduce \eqref{distinctalpha} from \eqref{distinctraw}, our quotient |
1800 In order to deduce \eqref{distinctalpha} from \eqref{distinctraw}, our quotient |
1789 package needs to know that the raw term-constructors @{text "C"} and @{text "D"} |
1801 package needs to know that the ``raw'' term-constructors @{text "C"} and @{text "D"} |
1790 are \emph{respectful} w.r.t.~the alpha-equivalence relations (see \cite{Homeier05}). |
1802 are \emph{respectful} w.r.t.~the alpha-equivalence relations (see \cite{Homeier05}). |
1791 Given, for example, @{text "C"} is of type @{text "ty"} with argument types |
1803 Given, for example, @{text "C"} is of type @{text "ty"} with argument types |
1792 @{text "ty"}$_{1..r}$, respectfulness amounts to showing that |
1804 @{text "ty"}$_{1..r}$, respectfulness amounts to showing that |
1793 |
1805 |
1794 \[\mbox{ |
1806 \[\mbox{ |
1813 \end{tabular} |
1825 \end{tabular} |
1814 }\end{equation}\smallskip |
1826 }\end{equation}\smallskip |
1815 |
1827 |
1816 \noindent |
1828 \noindent |
1817 whereby @{text "ty\<^isub>l"} is the type over which @{text "bn\<^isub>j"} |
1829 whereby @{text "ty\<^isub>l"} is the type over which @{text "bn\<^isub>j"} |
1818 is defined. These implications can be established by induction on @{text |
1830 is defined. Whereas the first, second and last implication are true by |
1819 "\<approx>ty"}$_{1..n}$. Whereas the first, second and last implication are true by |
|
1820 how we stated our definitions, the third \emph{only} holds because of our |
1831 how we stated our definitions, the third \emph{only} holds because of our |
1821 restriction imposed on the form of the binding functions---namely \emph{not} |
1832 restriction imposed on the form of the binding functions---namely \emph{not} |
1822 returning any bound atoms. In Ott, in contrast, the user may define @{text |
1833 to return any bound atoms. In Ott, in contrast, the user may define @{text |
1823 "bn"}$_{1..m}$ so that they return bound atoms and in this case the third |
1834 "bn"}$_{1..m}$ so that they return bound atoms and in this case the third |
1824 implication is \emph{not} true. A result is that the lifting of the |
1835 implication is \emph{not} true. A result is that in general the lifting of the |
1825 corresponding binding functions in Ott to alpha-equated terms is impossible. |
1836 corresponding binding functions in Ott to alpha-equated terms is impossible. |
1826 |
1837 |
1827 Having established respectfulness for the raw term-constructors, the |
1838 Having established respectfulness for the ``raw'' term-constructors, the |
1828 quotient package is able to automatically deduce \eqref{distinctalpha} from |
1839 quotient package is able to automatically deduce \eqref{distinctalpha} from |
1829 \eqref{distinctraw}. Having the facts \eqref{fnresp} at our disposal, we can |
1840 \eqref{distinctraw}. Having the facts \eqref{fnresp} at our disposal, we can |
1830 also lift properties that characterise when two raw terms of the form |
1841 also lift properties that characterise when two ``raw'' terms of the form |
1831 |
1842 |
1832 \[ |
1843 \[ |
1833 \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}} |
1844 \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}} |
1834 \]\smallskip |
1845 \]\smallskip |
1835 |
1846 |
1841 @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r = C\<^sup>\<alpha> x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}. |
1852 @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r = C\<^sup>\<alpha> x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}. |
1842 \]\smallskip |
1853 \]\smallskip |
1843 |
1854 |
1844 \noindent |
1855 \noindent |
1845 We call these conditions as \emph{quasi-injectivity}. They correspond to |
1856 We call these conditions as \emph{quasi-injectivity}. They correspond to |
1846 the premises in our alpha-equiva\-lence relations. |
1857 the premises in our alpha-equiva\-lence relations, with the exception that |
|
1858 in case of binders the relations $\approx_{\textit{set}}^{\textit{R}, \textit{fa}}$ |
|
1859 are replaced by $\approx_{\textit{set}}^{=, \textit{fa}}$. |
1847 |
1860 |
1848 Next we can lift the permutation operations defined in \eqref{ceqvt}. In |
1861 Next we can lift the permutation operations defined in \eqref{ceqvt}. In |
1849 order to make this lifting to go through, we have to show that the |
1862 order to make this lifting to go through, we have to show that the |
1850 permutation operations are respectful. This amounts to showing that the |
1863 permutation operations are respectful. This amounts to showing that the |
1851 alpha-equivalence relations are equivariant, which |
1864 alpha-equivalence relations are equivariant, which |
1862 @{text "fa_bn\<AL>"}$_{1..m}$ as well as of the binding functions @{text |
1875 @{text "fa_bn\<AL>"}$_{1..m}$ as well as of the binding functions @{text |
1863 "bn\<AL>"}$_{1..m}$ and the size functions @{text "size_ty\<AL>"}$_{1..n}$. |
1876 "bn\<AL>"}$_{1..m}$ and the size functions @{text "size_ty\<AL>"}$_{1..n}$. |
1864 The latter are defined automatically for the raw types @{text "ty"}$_{1..n}$ |
1877 The latter are defined automatically for the raw types @{text "ty"}$_{1..n}$ |
1865 by the datatype package of Isabelle/HOL. |
1878 by the datatype package of Isabelle/HOL. |
1866 |
1879 |
1867 Finally we can add to our infrastructure cases lemmas and a structural |
1880 Finally we can add to our infrastructure cases lemmas and a (mutual) |
1868 induction principle for the types @{text "ty\<AL>"}$_{1..n}$. The cases |
1881 induction principle for the types @{text "ty\<AL>"}$_{1..n}$. The cases |
1869 lemmas allow the user to deduce a property @{text "P"} by exhaustively |
1882 lemmas allow the user to deduce a property @{text "P"} by exhaustively |
1870 analysing all cases how the elements in a type @{text "ty\<AL>"}$_i$ can |
1883 analysing all cases how an element in a type @{text "ty\<AL>"}$_i$ can |
1871 be constructed (that means one case for each of term-constructors @{text "C\<AL>"}$_{1..m}$ |
1884 be constructed (that means one case for each of term-constructors |
1872 of type @{text "ty\<AL>"}$_i\,$). These are lifted versions of the cases |
1885 of type @{text "ty\<AL>"}$_i\,$). The lifted cases |
1873 lemma over the raw type @{text "ty"}$_i$ and schematically look as |
1886 lemma for the type @{text "ty\<AL>"}$_i\,$ looks as |
1874 follows |
1887 follows |
1875 |
1888 |
1876 \[ |
1889 \[ |
1877 \infer{P} |
1890 \infer{P} |
1878 {\begin{array}{l} |
1891 {\begin{array}{l} |
1897 \]\smallskip |
1911 \]\smallskip |
1898 |
1912 |
1899 \noindent |
1913 \noindent |
1900 whereby the @{text P}$_{1..n}$ are the properties established by induction |
1914 whereby the @{text P}$_{1..n}$ are the properties established by induction |
1901 and the @{text y}$_{1..n}$ are of type @{text "ty\<AL>"}$_{1..n}$. |
1915 and the @{text y}$_{1..n}$ are of type @{text "ty\<AL>"}$_{1..n}$. |
1902 This induction principle has for all term constructors @{text "C"}$^\alpha$ |
1916 This induction principle has for the term constructors @{text "C"}$^\alpha_1$ |
1903 a premise of the form |
1917 a premise of the form |
1904 |
1918 |
1905 \begin{equation}\label{weakprem} |
1919 \begin{equation}\label{weakprem} |
1906 \mbox{@{text "\<forall>x\<^isub>1\<dots>x\<^isub>r. P\<^isub>i x\<^isub>i \<and> \<dots> \<and> P\<^isub>j x\<^isub>j \<Rightarrow> P (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r)"}} |
1920 \mbox{@{text "\<forall>x\<^isub>1\<dots>x\<^isub>k. P\<^isub>i x\<^isub>i \<and> \<dots> \<and> P\<^isub>j x\<^isub>j \<Rightarrow> P (C\<AL>\<^sub>1 x\<^isub>1 \<dots> x\<^isub>k)"}} |
1907 \end{equation}\smallskip |
1921 \end{equation}\smallskip |
1908 |
1922 |
1909 \noindent |
1923 \noindent |
1910 in which the @{text "x"}$_{i..j}$ @{text "\<subseteq>"} @{text "x"}$_{1..r}$ are |
1924 in which the @{text "x"}$_{i..j}$ @{text "\<subseteq>"} @{text "x"}$_{1..k}$ are |
1911 the recursive arguments of the term constructor. In case of the lambda-calculus, |
1925 the recursive arguments of this term constructor (similarly for the other |
1912 the cases lemma and the induction principle boil down to the following: |
1926 term-constructors). In case of the lambda-calculus (with constructors |
|
1927 @{text "Var\<^sup>\<alpha>"}, @{text "App\<^sup>\<alpha>"} and @{text "Lam\<^sup>\<alpha>"}), |
|
1928 the cases lemmas and the induction principle boil down to the following |
|
1929 two inference rules: |
1913 |
1930 |
1914 \[\mbox{ |
1931 \[\mbox{ |
1915 \begin{tabular}{c@ {\hspace{10mm}}c} |
1932 \begin{tabular}{c@ {\hspace{10mm}}c} |
1916 \infer{@{text "P"}} |
1933 \infer{@{text "P"}} |
1917 {\begin{array}{l} |
1934 {\begin{array}{l} |
1943 |
1966 |
1944 |
1967 |
1945 \noindent |
1968 \noindent |
1946 These properties can be established using the induction principle for the |
1969 These properties can be established using the induction principle for the |
1947 types @{text "ty\<AL>"}$_{1..n}$. Having these |
1970 types @{text "ty\<AL>"}$_{1..n}$. Having these |
1948 equivariant properties established, we can show that the support of |
1971 equivariant properties at our disposal, we can show that the support of |
1949 term-constructors @{text "C\<^sup>\<alpha>"} is included in the support of its |
1972 term-constructors @{text "C\<^sup>\<alpha>"} is included in the support of its |
1950 arguments, that means |
1973 arguments, that means |
1951 |
1974 |
1952 \[ |
1975 \[ |
1953 @{text "supp (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r) \<subseteq> (supp x\<^isub>1 \<union> \<dots> \<union> supp x\<^isub>r)"} |
1976 @{text "supp (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r) \<subseteq> (supp x\<^isub>1 \<union> \<dots> \<union> supp x\<^isub>r)"} |
1954 \]\smallskip |
1977 \]\smallskip |
1955 |
1978 |
1956 \noindent |
1979 \noindent |
1957 holds. This allows us to prove by induction that every @{text x} of type |
1980 holds. This allows us to prove by induction that every @{text x} of type |
1958 @{text "ty\<AL>"}$_{1..n}$ is finitely supported. This can be again shown by |
1981 @{text "ty\<AL>"}$_{1..n}$ is finitely supported. This can be again shown by |
1959 induction over @{text "ty\<AL>"}$_{1..n}$. Lastly, we can show that the |
1982 the induction principle for @{text "ty\<AL>"}$_{1..n}$. Lastly, we can show that the |
1960 support of elements in @{text "ty\<AL>"}$_{1..n}$ is the same as @{text |
1983 support of elements in @{text "ty\<AL>"}$_{1..n}$ is the same as @{text |
1961 "fa_ty\<AL>"}$_{1..n}$. This fact is important in the nominal setting, but |
1984 "fa_ty\<AL>"}$_{1..n}$. This fact is important in the nominal setting |
|
1985 where the general theory is formulated in terms of @{text "supp"} and @{text "#"}, but |
1962 also provides evidence that our notions of free-atoms and alpha-equivalence |
1986 also provides evidence that our notions of free-atoms and alpha-equivalence |
1963 are sensible. |
1987 are sensible. |
1964 |
1988 |
1965 \begin{thm} |
1989 \begin{thm} |
1966 For @{text "x"}$_{1..n}$ with type @{text "ty\<AL>"}$_{1..n}$, we have |
1990 For @{text "x"}$_{1..n}$ with type @{text "ty\<AL>"}$_{1..n}$, we have |
1975 \end{proof} |
1999 \end{proof} |
1976 |
2000 |
1977 \noindent |
2001 \noindent |
1978 To sum up this section, we can establish automatically a reasoning infrastructure |
2002 To sum up this section, we can establish automatically a reasoning infrastructure |
1979 for the types @{text "ty\<AL>"}$_{1..n}$ |
2003 for the types @{text "ty\<AL>"}$_{1..n}$ |
1980 by first lifting definitions from the raw level to the quotient level and |
2004 by first lifting definitions from the ``raw'' level to the quotient level and |
1981 then by establishing facts about these lifted definitions. All necessary proofs |
2005 then by establishing facts about these lifted definitions. All necessary proofs |
1982 are generated automatically by custom ML-code. |
2006 are generated automatically by custom ML-code. |
1983 |
2007 |
1984 %This code can deal with |
|
1985 %specifications such as the one shown in Figure~\ref{nominalcorehas} for Core-Haskell. |
|
1986 |
|
1987 %\begin{figure}[t!] |
|
1988 %\begin{boxedminipage}{\linewidth} |
|
1989 %\small |
|
1990 %\begin{tabular}{l} |
|
1991 %\isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm] |
|
1992 %\isacommand{nominal\_datatype}~@{text "tkind ="}\\ |
|
1993 %\phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ |
|
1994 %\isacommand{and}~@{text "ckind ="}\\ |
|
1995 %\phantom{$|$}~@{text "CKSim ty ty"}\\ |
|
1996 %\isacommand{and}~@{text "ty ="}\\ |
|
1997 %\phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\ |
|
1998 %$|$~@{text "TFun string ty_list"}~% |
|
1999 %$|$~@{text "TAll tv::tvar tkind ty::ty"} \isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text ty}\\ |
|
2000 %$|$~@{text "TArr ckind ty"}\\ |
|
2001 %\isacommand{and}~@{text "ty_lst ="}\\ |
|
2002 %\phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\ |
|
2003 %\isacommand{and}~@{text "cty ="}\\ |
|
2004 %\phantom{$|$}~@{text "CVar cvar"}~% |
|
2005 %$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\ |
|
2006 %$|$~@{text "CAll cv::cvar ckind cty::cty"} \isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text cty}\\ |
|
2007 %$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\ |
|
2008 %$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\ |
|
2009 %$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\ |
|
2010 %\isacommand{and}~@{text "co_lst ="}\\ |
|
2011 %\phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\ |
|
2012 %\isacommand{and}~@{text "trm ="}\\ |
|
2013 %\phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\ |
|
2014 %$|$~@{text "LAM_ty tv::tvar tkind t::trm"} \isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text t}\\ |
|
2015 %$|$~@{text "LAM_cty cv::cvar ckind t::trm"} \isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text t}\\ |
|
2016 %$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\ |
|
2017 %$|$~@{text "Lam v::var ty t::trm"} \isacommand{binds}~@{text "v"}~\isacommand{in}~@{text t}\\ |
|
2018 %$|$~@{text "Let x::var ty trm t::trm"} \isacommand{binds}~@{text x}~\isacommand{in}~@{text t}\\ |
|
2019 %$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\ |
|
2020 %\isacommand{and}~@{text "assoc_lst ="}\\ |
|
2021 %\phantom{$|$}~@{text ANil}~% |
|
2022 %$|$~@{text "ACons p::pat t::trm assoc_lst"} \isacommand{binds}~@{text "bv p"}~\isacommand{in}~@{text t}\\ |
|
2023 %\isacommand{and}~@{text "pat ="}\\ |
|
2024 %\phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\ |
|
2025 %\isacommand{and}~@{text "vt_lst ="}\\ |
|
2026 %\phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\ |
|
2027 %\isacommand{and}~@{text "tvtk_lst ="}\\ |
|
2028 %\phantom{$|$}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\ |
|
2029 %\isacommand{and}~@{text "tvck_lst ="}\\ |
|
2030 %\phantom{$|$}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\ |
|
2031 %\isacommand{binder}\\ |
|
2032 %@{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}~% |
|
2033 %@{text "bv1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\ |
|
2034 %@{text "bv2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}~% |
|
2035 %@{text "bv3 :: tvck_lst \<Rightarrow> atom list"}\\ |
|
2036 %\isacommand{where}\\ |
|
2037 %\phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv3 tvts) @ (bv2 tvcs) @ (bv1 vs)"}\\ |
|
2038 %$|$~@{text "bv1 VTNil = []"}\\ |
|
2039 %$|$~@{text "bv1 (VTCons x ty tl) = (atom x)::(bv1 tl)"}\\ |
|
2040 %$|$~@{text "bv2 TVTKNil = []"}\\ |
|
2041 %$|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\ |
|
2042 %$|$~@{text "bv3 TVCKNil = []"}\\ |
|
2043 %$|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\ |
|
2044 %\end{tabular} |
|
2045 %\end{boxedminipage} |
|
2046 %\caption{The nominal datatype declaration for Core-Haskell. For the moment we |
|
2047 %do not support nested types; therefore we explicitly have to unfold the |
|
2048 %lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved |
|
2049 %in a future version of Nominal Isabelle. Apart from that, the |
|
2050 %declaration follows closely the original in Figure~\ref{corehas}. The |
|
2051 %point of our work is that having made such a declaration in Nominal Isabelle, |
|
2052 %one obtains automatically a reasoning infrastructure for Core-Haskell. |
|
2053 %\label{nominalcorehas}} |
|
2054 %\end{figure} |
|
2055 *} |
2008 *} |
2056 |
2009 |
2057 |
2010 |
2058 section {* Strong Induction Principles *} |
2011 section {* Strong Induction Principles *} |
2059 |
2012 |
2347 approach to |
2300 approach to |
2348 binding \cite{chargueraud09}. There, de-Bruijn indices consist of two |
2301 binding \cite{chargueraud09}. There, de-Bruijn indices consist of two |
2349 numbers, one referring to the place where a variable is bound, and the other |
2302 numbers, one referring to the place where a variable is bound, and the other |
2350 to which variable is bound. The reasoning infrastructure for both |
2303 to which variable is bound. The reasoning infrastructure for both |
2351 representations of bindings comes for free in theorem provers like |
2304 representations of bindings comes for free in theorem provers like |
2352 Isabelle/HOL or Coq, since the corresponding term-calculi can be implemented |
2305 Isabelle/HOL and Coq, since the corresponding term-calculi can be implemented |
2353 as ``normal'' datatypes. However, in both approaches it seems difficult to |
2306 as ``normal'' datatypes. However, in both approaches it seems difficult to |
2354 achieve our fine-grained control over the ``semantics'' of bindings |
2307 achieve our fine-grained control over the ``semantics'' of bindings |
2355 (i.e.~whether the order of binders should matter, or vacuous binders should |
2308 (i.e.~whether the order of binders should matter, or vacuous binders should |
2356 be taken into account). To do so, one would require additional predicates |
2309 be taken into account). To do so, one would require additional predicates |
2357 that filter out unwanted terms. Our guess is that such predicates result in |
2310 that filter out unwanted terms. Our guess is that such predicates result in |
2358 rather intricate formal reasoning. We are not aware of any non-trivial |
2311 rather intricate formal reasoning. We are not aware of any formalisation of |
2359 formalisation that uses Chargu\'eraud's idea. |
2312 a non-trivial language that uses Chargu\'eraud's idea. |
2360 |
|
2361 |
2313 |
2362 Another technique for representing binding is higher-order abstract syntax |
2314 Another technique for representing binding is higher-order abstract syntax |
2363 (HOAS), which for example is implemented in the Twelf system. This |
2315 (HOAS), which for example is implemented in the Twelf system. This |
2364 representation technique supports very elegantly many aspects of |
2316 representation technique supports very elegantly many aspects of |
2365 \emph{single} binding, and impressive work by Lee et al has been done that |
2317 \emph{single} binding, and impressive work by Lee et al has been done that |
2387 |
2339 |
2388 The most closely related work to the one presented here is the Ott-tool by |
2340 The most closely related work to the one presented here is the Ott-tool by |
2389 Sewell et al \cite{ott-jfp} and the C$\alpha$ml language by Pottier |
2341 Sewell et al \cite{ott-jfp} and the C$\alpha$ml language by Pottier |
2390 \cite{Pottier06}. Ott is a nifty front-end for creating \LaTeX{} documents |
2342 \cite{Pottier06}. Ott is a nifty front-end for creating \LaTeX{} documents |
2391 from specifications of term-calculi involving general binders. For a subset |
2343 from specifications of term-calculi involving general binders. For a subset |
2392 of the specifications Ott can also generate theorem prover code using a raw |
2344 of the specifications Ott can also generate theorem prover code using a ``raw'' |
2393 representation of terms, and in Coq also a locally nameless |
2345 representation of terms, and in Coq also a locally nameless |
2394 representation. The developers of this tool have also put forward (on paper) |
2346 representation. The developers of this tool have also put forward (on paper) |
2395 a definition for alpha-equivalence and free variables for terms that can be |
2347 a definition for alpha-equivalence and free variables for terms that can be |
2396 specified in Ott. This definition is rather different from ours, not using |
2348 specified in Ott. This definition is rather different from ours, not using |
2397 any nominal techniques. To our knowledge there is no concrete mathematical |
2349 any nominal techniques. To our knowledge there is no concrete mathematical |
2398 result concerning this notion of alpha-equivalence and free variables. We |
2350 result concerning this notion of alpha-equivalence and free variables. We |
2399 have proved that our definitions lead to alpha-equated terms, whose support |
2351 have proved that our definitions lead to alpha-equated terms, whose support |
2400 is as expected (that means bound names are removed from the support). We |
2352 is as expected (that means bound names are removed from the support). We |
2401 also showed that our specifications lift from a raw type to a type of |
2353 also showed that our specifications lift from ``raw'' types to types of |
2402 alpha-equivalence classes. For this we had to establish (automatically) that every |
2354 alpha-equivalence classes. For this we had to establish (automatically) that every |
2403 term-constructor and function is repectful w.r.t.~alpha-equivalence. |
2355 term-constructor and function is repectful w.r.t.~alpha-equivalence. |
2404 |
2356 |
2405 Although we were heavily inspired by the syntax of Ott, its definition of |
2357 Although we were heavily inspired by the syntax of Ott, its definition of |
2406 alpha-equi\-valence is unsuitable for our extension of Nominal |
2358 alpha-equi\-valence is unsuitable for our extension of Nominal |
2456 and therefore need the extra generality to be able to distinguish between |
2408 and therefore need the extra generality to be able to distinguish between |
2457 both specifications. Because of how we set up our definitions, we also had |
2409 both specifications. Because of how we set up our definitions, we also had |
2458 to impose some restrictions (like a single binding function for a deep |
2410 to impose some restrictions (like a single binding function for a deep |
2459 binder) that are not present in Ott. Our expectation is that we can still |
2411 binder) that are not present in Ott. Our expectation is that we can still |
2460 cover many interesting term-calculi from programming language research, for |
2412 cover many interesting term-calculi from programming language research, for |
2461 example Core-Haskell. ??? |
2413 example Core-Haskell (see Figure~\ref{nominalcorehas}). |
|
2414 |
|
2415 \begin{figure}[p!] |
|
2416 \begin{boxedminipage}{\linewidth} |
|
2417 \small |
|
2418 \begin{tabular}{l} |
|
2419 \isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm] |
|
2420 \isacommand{nominal\_datatype}~@{text "tkind ="}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ |
|
2421 \isacommand{and}~@{text "ckind ="}~@{text "CKSim ty ty"}\\ |
|
2422 \isacommand{and}~@{text "ty ="}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\ |
|
2423 $|$~@{text "TFun string ty_list"}~% |
|
2424 $|$~@{text "TAll tv::tvar tkind ty::ty"}\hspace{3mm}\isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text ty}\\ |
|
2425 $|$~@{text "TArr ckind ty"}\\ |
|
2426 \isacommand{and}~@{text "ty_lst ="}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\ |
|
2427 \isacommand{and}~@{text "cty ="}~@{text "CVar cvar"}~% |
|
2428 $|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\ |
|
2429 $|$~@{text "CAll cv::cvar ckind cty::cty"}\hspace{3mm}\isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text cty}\\ |
|
2430 $|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\ |
|
2431 $|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\ |
|
2432 $|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\ |
|
2433 \isacommand{and}~@{text "co_lst ="}~@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\ |
|
2434 \isacommand{and}~@{text "trm ="}~@{text "Var var"}~$|$~@{text "K string"}\\ |
|
2435 $|$~@{text "LAM_ty tv::tvar tkind t::trm"}\hspace{3mm}\isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text t}\\ |
|
2436 $|$~@{text "LAM_cty cv::cvar ckind t::trm"}\hspace{3mm}\isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text t}\\ |
|
2437 $|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\ |
|
2438 $|$~@{text "Lam v::var ty t::trm"}\hspace{3mm}\isacommand{binds}~@{text "v"}~\isacommand{in}~@{text t}\\ |
|
2439 $|$~@{text "Let x::var ty trm t::trm"}\hspace{3mm}\isacommand{binds}~@{text x}~\isacommand{in}~@{text t}\\ |
|
2440 $|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\ |
|
2441 \isacommand{and}~@{text "assoc_lst ="}~@{text ANil}~% |
|
2442 $|$~@{text "ACons p::pat t::trm assoc_lst"}\hspace{3mm}\isacommand{binds}~@{text "bv p"}~\isacommand{in}~@{text t}\\ |
|
2443 \isacommand{and}~@{text "pat ="}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\ |
|
2444 \isacommand{and}~@{text "vt_lst ="}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\ |
|
2445 \isacommand{and}~@{text "tvtk_lst ="}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\ |
|
2446 \isacommand{and}~@{text "tvck_lst ="}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\ |
|
2447 \isacommand{binder}\\ |
|
2448 @{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}\\ |
|
2449 @{text "bv\<^isub>1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\ |
|
2450 @{text "bv\<^isub>2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}\\ |
|
2451 @{text "bv\<^isub>3 :: tvck_lst \<Rightarrow> atom list"}\\ |
|
2452 \isacommand{where}\\ |
|
2453 \phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv\<^isub>3 tvts) @ (bv\<^isub>2 tvcs) @ (bv\<^isub>1 vs)"}\\ |
|
2454 $|$~@{text "bv\<^isub>1 VTNil = []"}\\ |
|
2455 $|$~@{text "bv\<^isub>1 (VTCons x ty tl) = (atom x)::(bv\<^isub>1 tl)"}\\ |
|
2456 $|$~@{text "bv\<^isub>2 TVTKNil = []"}\\ |
|
2457 $|$~@{text "bv\<^isub>2 (TVTKCons a ty tl) = (atom a)::(bv\<^isub>2 tl)"}\\ |
|
2458 $|$~@{text "bv\<^isub>3 TVCKNil = []"}\\ |
|
2459 $|$~@{text "bv\<^isub>3 (TVCKCons c cty tl) = (atom c)::(bv\<^isub>3 tl)"}\\ |
|
2460 \end{tabular} |
|
2461 \end{boxedminipage} |
|
2462 \caption{The nominal datatype declaration for Core-Haskell. For the moment we |
|
2463 do not support nested types; therefore we explicitly have to unfold the |
|
2464 lists @{text "co_lst"}, @{text "assoc_lst"} and so on. Apart from that, the |
|
2465 declaration follows closely the original in Figure~\ref{corehas}. The |
|
2466 point of our work is that having made such a declaration in Nominal Isabelle, |
|
2467 one obtains automatically a reasoning infrastructure for Core-Haskell. |
|
2468 \label{nominalcorehas}} |
|
2469 \end{figure} |
|
2470 |
2462 |
2471 |
2463 Pottier presents a programming language, called C$\alpha$ml, for |
2472 Pottier presents a programming language, called C$\alpha$ml, for |
2464 representing terms with general binders inside OCaml \cite{Pottier06}. This |
2473 representing terms with general binders inside OCaml \cite{Pottier06}. This |
2465 language is implemented as a front-end that can be translated to OCaml with |
2474 language is implemented as a front-end that can be translated to OCaml with |
2466 the help of a library. He presents a type-system in which the scope of |
2475 the help of a library. He presents a type-system in which the scope of |
2504 eventually become part of the next Isabelle distribution.\footnote{It |
2513 eventually become part of the next Isabelle distribution.\footnote{It |
2505 can be downloaded from \href{http://isabelle.in.tum.de/nominal/download} |
2514 can be downloaded from \href{http://isabelle.in.tum.de/nominal/download} |
2506 {http://isabelle.in.tum.de/nominal/download}.} |
2515 {http://isabelle.in.tum.de/nominal/download}.} |
2507 |
2516 |
2508 We have left out a discussion about how functions can be defined over |
2517 We have left out a discussion about how functions can be defined over |
2509 alpha-equated terms involving general binders. In earlier versions of Nominal |
2518 alpha-equated terms involving general binders. In earlier versions of |
2510 Isabelle this turned out to be a thorny issue. We |
2519 Nominal Isabelle this turned out to be a thorny issue. We hope to do better |
2511 hope to do better this time by using the function package that has recently |
2520 this time by using the function package \cite{Krauss09} that has recently |
2512 been implemented in Isabelle/HOL and also by restricting function |
2521 been implemented in Isabelle/HOL and also by restricting function |
2513 definitions to equivariant functions (for them we can |
2522 definitions to equivariant functions (for them we can provide more |
2514 provide more automation). |
2523 automation). |
2515 |
2524 |
2516 There are some restrictions we imposed in this paper that we would like to lift in |
2525 There are some restrictions we imposed in this paper that we would like to lift in |
2517 future work. One is the exclusion of nested datatype definitions. Nested |
2526 future work. One is the exclusion of nested datatype definitions. Nested |
2518 datatype definitions allow one to specify, for instance, the function kinds |
2527 datatype definitions allow one to specify, for instance, the function kinds |
2519 in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded |
2528 in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded |