43 equal ("=") and |
43 equal ("=") and |
44 alpha_abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
44 alpha_abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
45 alpha_abs_lst ("_ \<approx>\<^raw:{$\,_{\textit{abs\_list}}$}> _") and |
45 alpha_abs_lst ("_ \<approx>\<^raw:{$\,_{\textit{abs\_list}}$}> _") and |
46 alpha_abs_res ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set+}}$}> _") and |
46 alpha_abs_res ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set+}}$}> _") and |
47 Abs_set ("[_]\<^bsub>set\<^esub>._" [20, 101] 999) and |
47 Abs_set ("[_]\<^bsub>set\<^esub>._" [20, 101] 999) and |
48 Abs_lst ("[_]\<^bsub>list\<^esub>._") and |
48 Abs_lst ("[_]\<^bsub>list\<^esub>._" [20, 101] 999) and |
49 Abs_dist ("[_]\<^bsub>#list\<^esub>._") and |
49 Abs_dist ("[_]\<^bsub>#list\<^esub>._" [20, 101] 999) and |
50 Abs_res ("[_]\<^bsub>set+\<^esub>._") and |
50 Abs_res ("[_]\<^bsub>set+\<^esub>._") and |
51 Abs_print ("_\<^bsub>set\<^esub>._") and |
51 Abs_print ("_\<^bsub>set\<^esub>._") and |
52 Cons ("_::_" [78,77] 73) and |
52 Cons ("_::_" [78,77] 73) and |
53 supp_set ("aux _" [1000] 10) and |
53 supp_set ("aux _" [1000] 10) and |
54 alpha_bn ("_ \<approx>bn _") |
54 alpha_bn ("_ \<approx>bn _") |
280 wealth of experience we gained with the older version of Nominal Isabelle: |
280 wealth of experience we gained with the older version of Nominal Isabelle: |
281 for non-trivial properties, reasoning with alpha-equated terms is much |
281 for non-trivial properties, reasoning with alpha-equated terms is much |
282 easier than reasoning with raw terms. The fundamental reason for this is |
282 easier than reasoning with raw terms. The fundamental reason for this is |
283 that the HOL-logic underlying Nominal Isabelle allows us to replace |
283 that the HOL-logic underlying Nominal Isabelle allows us to replace |
284 ``equals-by-equals''. In contrast, replacing |
284 ``equals-by-equals''. In contrast, replacing |
285 ``alpha-equals-by-alpha-equals'' in a representation based on raw terms |
285 ``alpha-equals-by-alpha-equals'' in a representation based on ``raw'' terms |
286 requires a lot of extra reasoning work. |
286 requires a lot of extra reasoning work. |
287 |
287 |
288 Although in informal settings a reasoning infrastructure for alpha-equated |
288 Although in informal settings a reasoning infrastructure for alpha-equated |
289 terms is nearly always taken for granted, establishing it automatically in |
289 terms is nearly always taken for granted, establishing it automatically in |
290 Isabelle/HOL is a rather non-trivial task. For every |
290 Isabelle/HOL is a rather non-trivial task. For every |
385 "\<CASE>"}-expressions. In these patterns we do not know in advance how many |
385 "\<CASE>"}-expressions. In these patterns we do not know in advance how many |
386 variables need to be bound. Another example is the algorithm W, |
386 variables need to be bound. Another example is the algorithm W, |
387 which includes multiple binders in type-schemes.\medskip |
387 which includes multiple binders in type-schemes.\medskip |
388 |
388 |
389 \noindent |
389 \noindent |
390 {\bf Contributions:} We provide three new definitions for when terms |
390 {\bf Contributions:} We provide three new definitions for when terms |
391 involving general binders are alpha-equivalent. These definitions are |
391 involving general binders are alpha-equivalent. These definitions are |
392 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
392 inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
393 proofs, we establish a reasoning infrastructure for alpha-equated |
393 proofs, we establish a reasoning infrastructure for alpha-equated terms, |
394 terms, including properties about support, freshness and equality |
394 including properties about support, freshness and equality conditions for |
395 conditions for alpha-equated terms. We are also able to derive strong |
395 alpha-equated terms. We are also able to automatically derive strong |
396 induction principles that have the variable convention already built in. |
396 induction principles that have the variable convention already built in. |
397 The method behind our specification of general binders is taken |
397 For this we simplify the earlier automated proofs by using the proof tools |
398 from the Ott-tool, but we introduce crucial restrictions, and also extensions, so |
398 from the function package~\cite{Krauss09} of Isabelle/HOL. The method |
399 that our specifications make sense for reasoning about alpha-equated terms. |
399 behind our specification of general binders is taken from the Ott-tool, but |
400 The main improvement over Ott is that we introduce three binding modes |
400 we introduce crucial restrictions, and also extensions, so that our |
401 (only one is present in Ott), provide formalised definitions for alpha-equivalence and |
401 specifications make sense for reasoning about alpha-equated terms. The main |
|
402 improvement over Ott is that we introduce three binding modes (only one is |
|
403 present in Ott), provide formalised definitions for alpha-equivalence and |
402 for free variables of our terms, and also derive a reasoning infrastructure |
404 for free variables of our terms, and also derive a reasoning infrastructure |
403 for our specifications from ``first principles'' inside a theorem prover. |
405 for our specifications from ``first principles'' inside a theorem prover. |
404 |
406 |
405 |
407 |
406 \begin{figure} |
408 \begin{figure}[t] |
407 \begin{boxedminipage}{\linewidth} |
409 \begin{boxedminipage}{\linewidth} |
408 \begin{center} |
410 \begin{center} |
409 \begin{tabular}{@ {\hspace{8mm}}r@ {\hspace{2mm}}r@ {\hspace{2mm}}l} |
411 \begin{tabular}{@ {\hspace{8mm}}r@ {\hspace{2mm}}r@ {\hspace{2mm}}l} |
410 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
412 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
411 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\ |
413 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\ |
636 fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
638 fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
637 @{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}. |
639 @{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}. |
638 |
640 |
639 Note that @{term "supp x \<sharp>* \<pi>"} |
641 Note that @{term "supp x \<sharp>* \<pi>"} |
640 is equivalent with @{term "supp \<pi> \<sharp>* x"}, which means we could also formulate |
642 is equivalent with @{term "supp \<pi> \<sharp>* x"}, which means we could also formulate |
641 Propositions \ref{supppermeq} and \ref{avoiding} in the other `direction', however the |
643 Propositions \ref{supppermeq} and \ref{avoiding} in the other `direction'; however the |
642 reasoning infrastructure of Nominal Isabelle is set up so that it provides more |
644 reasoning infrastructure of Nominal Isabelle is set up so that it provides more |
643 automation for the formulation given above. |
645 automation for the formulation given above. |
644 |
646 |
645 Most properties given in this section are described in detail in \cite{HuffmanUrban10} |
647 Most properties given in this section are described in detail in \cite{HuffmanUrban10} |
646 and all are formalised in Isabelle/HOL. In the next sections we will make |
648 and all are formalised in Isabelle/HOL. In the next sections we will make |
719 where @{term set} is the function that coerces a list of atoms into a set of atoms. |
721 where @{term set} is the function that coerces a list of atoms into a set of atoms. |
720 Now the last clause ensures that the order of the binders matters (since @{text as} |
722 Now the last clause ensures that the order of the binders matters (since @{text as} |
721 and @{text bs} are lists of atoms). |
723 and @{text bs} are lists of atoms). |
722 |
724 |
723 If we do not want to make any difference between the order of binders \emph{and} |
725 If we do not want to make any difference between the order of binders \emph{and} |
724 also allow vacuous binders, that means according to Pitts \emph{restrict} names |
726 also allow vacuous binders, that means according to Pitts~\cite{Pitts04} |
725 \cite{Pitts04}, then we keep sets of binders, but drop |
727 \emph{restrict} names, then we keep sets of binders, but drop |
726 condition {\it (iv)} in Definition~\ref{alphaset}: |
728 condition {\it (iv)} in Definition~\ref{alphaset}: |
727 |
729 |
728 \begin{defi}[Alpha-Equivalence for Set+-Bindings]\label{alphares}\mbox{}\\ |
730 \begin{defi}[Alpha-Equivalence for Set+-Bindings]\label{alphares}\mbox{}\\ |
729 \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl} |
731 \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl} |
730 @{term "alpha_res_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} & |
732 @{term "alpha_res_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} & |
762 permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal |
764 permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal |
763 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
765 (similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be |
764 shown that all three notions of alpha-equivalence coincide, if we only |
766 shown that all three notions of alpha-equivalence coincide, if we only |
765 abstract a single atom. |
767 abstract a single atom. |
766 |
768 |
767 In the rest of this section we are going to show that the alpha-equivalences really |
769 In the rest of this section we are going to show that the alpha-equivalences |
768 lead to abstractions where some atoms are bound (more precisely removed from the |
770 really lead to abstractions where some atoms are bound (more precisely |
769 support). For this we are going to introduce |
771 removed from the support). For this we will consider three abstraction |
770 three abstraction types that are quotients of the relations |
772 types that are quotients of the relations |
771 |
773 |
772 \begin{equation} |
774 \begin{equation} |
773 \begin{array}{r} |
775 \begin{array}{r} |
774 @{term "alpha_set_ex (as, x) equal supp (bs, y)"}\smallskip\\ |
776 @{term "alpha_set_ex (as, x) equal supp (bs, y)"}\smallskip\\ |
775 @{term "alpha_res_ex (as, x) equal supp (bs, y)"}\smallskip\\ |
777 @{term "alpha_res_ex (as, x) equal supp (bs, y)"}\smallskip\\ |
920 This is because for every finite sets of atoms, say @{text "bs"}, we have |
922 This is because for every finite sets of atoms, say @{text "bs"}, we have |
921 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
923 @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}. |
922 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
924 Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes |
923 the first equation of Theorem~\ref{suppabs}. |
925 the first equation of Theorem~\ref{suppabs}. |
924 |
926 |
925 Recall the definition of support in \eqref{suppdef}, and note the difference between |
927 Recall the definition of support given in \eqref{suppdef}, and note the difference between |
926 the support of a ``raw'' pair and an abstraction |
928 the support of a ``raw'' pair and an abstraction |
927 |
929 |
928 \[ |
930 \[ |
929 @{term "supp (as, x) = supp as \<union> supp x"}\hspace{15mm} |
931 @{term "supp (as, x) = supp as \<union> supp x"}\hspace{15mm} |
930 @{term "supp (Abs_set as x) = supp x - as"} |
932 @{term "supp (Abs_set as x) = supp x - as"} |
931 \]\smallskip |
933 \]\smallskip |
932 |
934 |
933 \noindent |
935 \noindent |
934 While the permutation operations behave in both cases the same (a permutation |
936 While the permutation operations behave in both cases the same (a permutation |
935 is just moved to the arguments), the notion of equality is different for pairs and |
937 is just moved to the arguments), the notion of equality is different for pairs and |
936 abstractions. Therefore we have different supports. |
938 abstractions. Therefore we have different supports. In case of abstractions, |
|
939 we have established that bound atoms are removed from the support of the |
|
940 abstractions' bodies. |
937 |
941 |
938 The method of first considering abstractions of the form @{term "Abs_set as |
942 The method of first considering abstractions of the form @{term "Abs_set as |
939 x"} etc is motivated by the fact that we can conveniently establish at the |
943 x"} etc is motivated by the fact that we can conveniently establish at the |
940 Isabelle/HOL level properties about them. It would be extremely laborious |
944 Isabelle/HOL level properties about them. It would be extremely laborious |
941 to write custom ML-code that derives automatically such properties for every |
945 to write custom ML-code that derives automatically such properties for every |
1280 But for the purpose of this paper, we use the superscript @{text "_\<^sup>\<alpha>"} to indicate |
1284 But for the purpose of this paper, we use the superscript @{text "_\<^sup>\<alpha>"} to indicate |
1281 that a notion is given for alpha-equivalence classes and leave it out |
1285 that a notion is given for alpha-equivalence classes and leave it out |
1282 for the corresponding notion given on the ``raw'' level. So for example |
1286 for the corresponding notion given on the ``raw'' level. So for example |
1283 we have @{text "ty\<^sup>\<alpha> \<mapsto> ty"} and @{text "C\<^sup>\<alpha> \<mapsto> C"} |
1287 we have @{text "ty\<^sup>\<alpha> \<mapsto> ty"} and @{text "C\<^sup>\<alpha> \<mapsto> C"} |
1284 where @{term ty} is the type used in the quotient construction for |
1288 where @{term ty} is the type used in the quotient construction for |
1285 @{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor in the ``raw'' type @{text "ty"}, |
1289 @{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor of the ``raw'' type @{text "ty"}, |
1286 respectively @{text "C\<^sup>\<alpha>"} is the corresponding term-constructor in @{text "ty\<^sup>\<alpha>"}. |
1290 respectively @{text "C\<^sup>\<alpha>"} is the corresponding term-constructor of @{text "ty\<^sup>\<alpha>"}. |
1287 |
1291 |
1288 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1292 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1289 non-empty and the types in the constructors only occur in positive |
1293 non-empty and the types in the constructors only occur in positive |
1290 position (see \cite{Berghofer99} for an in-depth description of the datatype package |
1294 position (see \cite{Berghofer99} for an in-depth description of the datatype package |
1291 in Isabelle/HOL). |
1295 in Isabelle/HOL). |
1364 \]\smallskip |
1368 \]\smallskip |
1365 |
1369 |
1366 \noindent |
1370 \noindent |
1367 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1371 where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the |
1368 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1372 specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function |
1369 we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i d\<^isub>i = supp d\<^isub>i"}}. The reason |
1373 we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i \<equiv> supp"}}. The reason |
1370 for the latter is that @{text "ty"}$_i$ is not a type that is part of the specification, and |
1374 for the latter is that @{text "ty"}$_i$ is not a type that is part of the specification, and |
1371 we assume @{text supp} is the generic notion that characterises the free variables of |
1375 we assume @{text supp} is the generic function that characterises the free variables of |
1372 a type (in fact in the next section we will show that the free-variable functions we |
1376 a type (in fact in the next section we will show that the free-variable functions we |
1373 define here, are equal to the support once lifted to alpha-equivalence classes). |
1377 define here, are equal to the support once lifted to alpha-equivalence classes). |
1374 |
1378 |
1375 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1379 In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions |
1376 for atom types to which shallow binders may refer\\[-4mm] |
1380 for atom types to which shallow binders may refer\\[-4mm] |
1593 \noindent |
1597 \noindent |
1594 In this case we define a premise @{text P} using the relation |
1598 In this case we define a premise @{text P} using the relation |
1595 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ given in Section~\ref{sec:binders} (similarly |
1599 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ given in Section~\ref{sec:binders} (similarly |
1596 $\approx_{\,\textit{set+}}^{\textit{R}, \textit{fa}}$ and |
1600 $\approx_{\,\textit{set+}}^{\textit{R}, \textit{fa}}$ and |
1597 $\approx_{\,\textit{list}}^{\textit{R}, \textit{fa}}$ for the other |
1601 $\approx_{\,\textit{list}}^{\textit{R}, \textit{fa}}$ for the other |
1598 binding modes). This premise defines alpha-equivalence of two abstractions |
1602 binding modes). As above, we first build the tuples @{text "D"} and |
1599 involving multiple binders. As above, we first build the tuples @{text "D"} and |
|
1600 @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding |
1603 @{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding |
1601 compound alpha-relation @{text "R"} (shown in \eqref{rempty}). |
1604 compound alpha-relation @{text "R"} (shown in \eqref{rempty}). |
1602 For $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ we also need |
1605 For $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ we also need |
1603 a compound free-atom function for the bodies defined as |
1606 a compound free-atom function for the bodies defined as |
1604 |
1607 |
1628 clause. However, in case the binders have non-recursive deep binders, this |
1631 clause. However, in case the binders have non-recursive deep binders, this |
1629 premise is not enough: we also have to ``propagate'' alpha-equivalence |
1632 premise is not enough: we also have to ``propagate'' alpha-equivalence |
1630 inside the structure of these binders. An example is @{text "Let"} where we |
1633 inside the structure of these binders. An example is @{text "Let"} where we |
1631 have to make sure the right-hand sides of assignments are |
1634 have to make sure the right-hand sides of assignments are |
1632 alpha-equivalent. For this we use relations @{text "\<approx>bn"}$_{1..m}$ (which we |
1635 alpha-equivalent. For this we use relations @{text "\<approx>bn"}$_{1..m}$ (which we |
1633 will formally define shortly). Let us assume the non-recursive deep binders |
1636 will define shortly). Let us assume the non-recursive deep binders |
1634 in @{text "bc\<^isub>i"} are |
1637 in @{text "bc\<^isub>i"} are |
1635 |
1638 |
1636 \[ |
1639 \[ |
1637 @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}. |
1640 @{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}. |
1638 \]\smallskip |
1641 \]\smallskip |
1685 non-empty ones (we just have to unfold the definition of |
1688 non-empty ones (we just have to unfold the definition of |
1686 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ and take @{text "0"} |
1689 $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ and take @{text "0"} |
1687 for the existentially quantified permutation). |
1690 for the existentially quantified permutation). |
1688 |
1691 |
1689 Again let us take a look at a concrete example for these definitions. For |
1692 Again let us take a look at a concrete example for these definitions. For |
1690 the specification given in \eqref{letrecs} |
1693 the specification shown in \eqref{letrecs} |
1691 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1694 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1692 $\approx_{\textit{bn}}$ with the following rules: |
1695 $\approx_{\textit{bn}}$ with the following rules: |
1693 |
1696 |
1694 \begin{equation}\label{rawalpha}\mbox{ |
1697 \begin{equation}\label{rawalpha}\mbox{ |
1695 \begin{tabular}{@ {}c @ {}} |
1698 \begin{tabular}{@ {}c @ {}} |
1723 clause for @{text "Let"} (which has |
1726 clause for @{text "Let"} (which has |
1724 a non-recursive binder). |
1727 a non-recursive binder). |
1725 The underlying reason is that the terms inside an assignment are not meant |
1728 The underlying reason is that the terms inside an assignment are not meant |
1726 to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, |
1729 to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, |
1727 because there all components of an assignment are ``under'' the binder. |
1730 because there all components of an assignment are ``under'' the binder. |
1728 Note also that in case of more than one body (that is in the @{text "Let_rec"}-case) |
1731 Note also that in case of more than one body (that is in the @{text "Let_rec"}-case above) |
1729 we need to parametrise the relation $\approx_{\textit{list}}$ with a compound |
1732 we need to parametrise the relation $\approx_{\textit{list}}$ with a compound |
1730 equivalence relation and a compound free-atom function. This is because the |
1733 equivalence relation and a compound free-atom function. This is because the |
1731 corresponding binding clause specifies a binder with two bodies, namely |
1734 corresponding binding clause specifies a binder with two bodies, namely |
1732 @{text "as"} and @{text "t"}. |
1735 @{text "as"} and @{text "t"}. |
1733 *} |
1736 *} |
2097 section {* Strong Induction Principles *} |
2100 section {* Strong Induction Principles *} |
2098 |
2101 |
2099 text {* |
2102 text {* |
2100 In the previous section we derived induction principles for alpha-equated |
2103 In the previous section we derived induction principles for alpha-equated |
2101 terms (see \eqref{induct} for the general form and \eqref{inductex} for an |
2104 terms (see \eqref{induct} for the general form and \eqref{inductex} for an |
2102 instance). This was done by lifting the corresponding inductions principles |
2105 example). This was done by lifting the corresponding inductions principles |
2103 for ``raw'' terms. We already employed these induction principles for |
2106 for ``raw'' terms. We already employed these induction principles for |
2104 deriving several facts for alpha-equated terms, including the property that |
2107 deriving several facts about alpha-equated terms, including the property that |
2105 the free-variable functions and the notion of support coincide. Still, we |
2108 the free-variable functions and the notion of support coincide. Still, we |
2106 call these induction principles \emph{weak}, because for a term-constructor, |
2109 call these induction principles \emph{weak}, because for a term-constructor, |
2107 say \mbox{@{text "C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r"}}, the induction |
2110 say \mbox{@{text "C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r"}}, the induction |
2108 hypothesis requires us to establish (under some assumptions) a property |
2111 hypothesis requires us to establish (under some assumptions) a property |
2109 @{text "P (C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r)"} for \emph{all} @{text |
2112 @{text "P (C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r)"} for \emph{all} @{text |
2110 "x"}$_{1..r}$. The problem is that in the presence of binders we cannot make |
2113 "x"}$_{1..r}$. The problem with this is that in the presence of binders we cannot make |
2111 any assumptions about the atoms that are bound. One obvious way around this |
2114 any assumptions about the atoms that are bound. One obvious way around this |
2112 problem is to rename them. Unfortunately, this leads to very clunky proofs |
2115 problem is to rename them. Unfortunately, this leads to very clunky proofs |
2113 and makes formalisations grievous experiences (especially in the case for |
2116 and makes formalisations grievous experiences (especially in the context of |
2114 multiple bound atoms). |
2117 multiple bound atoms). |
2115 |
2118 |
2116 |
2119 For the older versions of Nominal Isabelle we described in \cite{Urban08} a |
2117 For the older versions of Nominal Isabelle we described in |
2120 method for automatically strengthening weak induction principles. These |
2118 \cite{Urban08} a method for automatically strengthening weak induction |
2121 stronger induction principles allow the user to make additional assumptions |
2119 principles. These stronger induction principles allow the user to make |
2122 about bound atoms. The advantage of these assumptions is that they make in |
2120 additional assumptions about bound atoms. The advantage of these assumptions |
2123 most cases any renaming of bound atoms unnecessary. To explain how the |
2121 is that they make in most cases any renaming of bound atoms unnecessary. To |
2124 strengthening works, we use as running example the lambda-calculus with |
2122 explain how the strengthening works in the presence of multiple binders, we |
2125 @{text "Let"}-patterns shown in \eqref{letpat}. Its weak induction principle |
2123 use as running example the lambda-calculus with @{text "Let"}-patterns shown |
2126 is given in \eqref{inductex}. The stronger induction principle is as |
2124 in \eqref{letpat}. Its weak induction principle is given in |
2127 follows: |
2125 \eqref{inductex}. The stronger induction principle is as follows: |
|
2126 |
2128 |
2127 \begin{equation}\label{stronginduct} |
2129 \begin{equation}\label{stronginduct} |
2128 \mbox{ |
2130 \mbox{ |
2129 \begin{tabular}{@ {}c@ {}} |
2131 \begin{tabular}{@ {}c@ {}} |
2130 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2132 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2141 \end{tabular}} |
2143 \end{tabular}} |
2142 \end{equation}\smallskip |
2144 \end{equation}\smallskip |
2143 |
2145 |
2144 |
2146 |
2145 \noindent |
2147 \noindent |
2146 Instead of establishing the two properties @{text " P\<^bsub>trm\<^esub> |
2148 Notice that instead of establishing two properties of the form @{text " |
2147 y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}, as the weak one does, the |
2149 P\<^bsub>trm\<^esub> y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}, as the |
2148 stronger induction principle establishes the properties @{text " |
2150 weak one does, the stronger induction principle establishes the properties |
2149 P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"} in |
2151 of the form @{text " P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> |
2150 which the additional parameter @{text c} is assumed to be of finite |
2152 P\<^bsub>pat\<^esub> c y\<^isub>2"} in which the additional parameter @{text |
2151 support. The purpose of @{text "c"} is to ``control'' which freshness |
2153 c} is assumed to be of finite support. The purpose of @{text "c"} is to |
2152 assumptions the binders should satisfy in the @{text "Lam\<^sup>\<alpha>"} and |
2154 ``control'' which freshness assumptions the binders should satisfy in the |
2153 @{text "Let_pat\<^sup>\<alpha>"} cases: for @{text "Lam\<^sup>\<alpha>"} we can assume the |
2155 @{text "Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"} cases: for @{text |
2154 bound atom @{text "x\<^isub>1"} is fresh for @{text "c"}; for @{text |
2156 "Lam\<^sup>\<alpha>"} we can assume the bound atom @{text "x\<^isub>1"} is fresh |
2155 "Let_pat\<^sup>\<alpha>"} we can assume all bound atoms from an assignment are fresh |
2157 for @{text "c"} (third line); for @{text "Let_pat\<^sup>\<alpha>"} we can assume |
2156 for @{text "c"}. If @{text "c"} is instantiated appropriately, the user can |
2158 all bound atoms from an assignment are fresh for @{text "c"} (fourth |
2157 mimic the ``pencil-and-paper'' reasoning employing the usual variable |
2159 line). If @{text "c"} is instantiated appropriately in the strong induction |
2158 convention \cite{Urban08}. |
2160 principle, the user can mimic the usual ``pencil-and-paper'' reasoning |
2159 |
2161 employing the variable convention about bound and free variables being |
2160 In what follows we will show that the induction principle in |
2162 distinct \cite{Urban08}. |
2161 \eqref{inductex} implies \eqref{stronginduct}. This fact was established for |
2163 |
|
2164 In what follows we will show that the weak induction principle in |
|
2165 \eqref{inductex} implies the strong one \eqref{stronginduct}. This fact was established for |
2162 single binders in \cite{Urban08} by some quite involved, nevertheless |
2166 single binders in \cite{Urban08} by some quite involved, nevertheless |
2163 automated, induction proof. In this paper we simplify the proof by |
2167 automated, induction proof. In this paper we simplify the proof by |
2164 leveraging the automated proof methods from the function package of |
2168 leveraging the automated proving methods from the function package of |
2165 Isabelle/HOL \cite{Krauss09}. The reasoning principle behind these methods |
2169 Isabelle/HOL \cite{Krauss09}. The reasoning principle behind these methods |
2166 is well-founded induction. To use them in our setting, we have to discharge |
2170 is well-founded induction. To use them in our setting, we have to discharge |
2167 two proof obligations: one is that we have well-founded measures (one for |
2171 two proof obligations: one is that we have well-founded measures (one for |
2168 each type @{text "ty"}$^\alpha_{1..n}$) that decrease in every induction |
2172 each type @{text "ty"}$^\alpha_{1..n}$) that decrease in every induction |
2169 step and the other is that we have covered all cases in the induction |
2173 step and the other is that we have covered all cases in the induction |
2170 principle. Once these two proof obligations are discharged, the reasoning |
2174 principle. Once these two proof obligations are discharged, the reasoning |
2171 infrastructure in the function package will automatically derive the |
2175 infrastructure in the function package will automatically derive the |
2172 stronger induction principle. This considerably simplifies the work we have |
2176 stronger induction principle. This way of establishing the stronger induction |
2173 to do here. |
2177 principle is considerably simpler than the work presented \cite{Urban08}. |
2174 |
|
2175 |
2178 |
2176 As measures we can use the size functions @{text "size_ty"}$^\alpha_{1..n}$, |
2179 As measures we can use the size functions @{text "size_ty"}$^\alpha_{1..n}$, |
2177 which we lifted in the previous section and which are all well-founded. It |
2180 which we lifted in the previous section and which are all well-founded. It |
2178 is straightforward to establish that the sizes decrease in every |
2181 is straightforward to establish that the sizes decrease in every |
2179 induction step. What is left to show is that we covered all cases. |
2182 induction step. What is left to show is that we covered all cases. |
2198 \end{array}} |
2201 \end{array}} |
2199 \end{tabular}} |
2202 \end{tabular}} |
2200 \]\smallskip |
2203 \]\smallskip |
2201 |
2204 |
2202 \noindent |
2205 \noindent |
2203 They are stronger in the sense that they allow us to assume that the bound |
2206 They are stronger in the sense that they allow us to assume in the @{text |
2204 atoms avoid a context @{text "c"} (which is assumed to be finitely |
2207 "Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"} cases that the bound atoms |
2205 supported). This is similar with the stronger induction principles. |
2208 avoid a context @{text "c"} (which is assumed to be finitely supported). |
2206 |
2209 |
2207 These stronger cases lemmas need to be derived from the `weak' cases lemmas |
2210 These stronger cases lemmas need to be derived from the `weak' cases lemmas |
2208 given in \eqref{inductex}. This is trivial in case of patterns (the one on |
2211 given in \eqref{inductex}. This is trivial in case of patterns (the one on |
2209 the right-hand side) since the weak and strong cases lemma coincide (there |
2212 the right-hand side) since the weak and strong cases lemma coincide (there |
2210 is no binding in patterns). Interesting are only the cases for @{text |
2213 is no binding in patterns). Interesting are only the cases for @{text |
2211 "Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"}, where we have some binders and |
2214 "Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"}, where we have some binders and |
2212 therefore have an addition assumption. Let us show first establish the case |
2215 therefore have an addition assumption about avoiding @{text "c"}. Let us |
2213 for @{text "Lam\<^sup>\<alpha>"}. By the weak cases lemma \eqref{inductex} we can |
2216 first establish the case for @{text "Lam\<^sup>\<alpha>"}. By the weak cases lemma |
2214 assume that |
2217 \eqref{inductex} we can assume that |
2215 |
2218 |
2216 \begin{equation}\label{assm} |
2219 \begin{equation}\label{assm} |
2217 @{text "y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
2220 @{text "y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
2218 \end{equation}\smallskip |
2221 \end{equation}\smallskip |
2219 |
2222 |
2220 \noindent |
2223 \noindent |
2221 holds and need to establish @{text "P\<^bsub>trm\<^esub>"}. The stronger cases lemma has the |
2224 holds, and need to establish @{text "P\<^bsub>trm\<^esub>"}. The stronger cases lemma has the |
2222 corresponding implication |
2225 corresponding implication |
2223 |
2226 |
2224 \begin{equation}\label{imp} |
2227 \begin{equation}\label{imp} |
2225 @{text "\<forall>x\<^isub>1 x\<^isub>2. atom x\<^isub>1 # c \<and> y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
2228 @{text "\<forall>x\<^isub>1 x\<^isub>2. atom x\<^isub>1 # c \<and> y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
2226 \end{equation}\smallskip |
2229 \end{equation}\smallskip |
2227 |
2230 |
2228 \noindent |
2231 \noindent |
2229 which we can use to infer @{text "P\<^bsub>trm\<^esub>"}. Clearly, we cannot |
2232 which we must use to infer @{text "P\<^bsub>trm\<^esub>"}. Clearly, we cannot |
2230 use this implication directly, because we have no information whether @{text |
2233 use this implication directly, because we have no information whether @{text |
2231 "x\<^isub>1"} is fresh for @{text "c"}. However, we can use Properties |
2234 "x\<^isub>1"} is fresh for @{text "c"}. However, we can use Properties |
2232 \ref{supppermeq} and \ref{avoiding} to rename @{text "x\<^isub>1"}: We know |
2235 \ref{supppermeq} and \ref{avoiding} to rename @{text "x\<^isub>1"}: we know |
2233 by Theorem~\ref{suppfa} that @{text "{atom x\<^isub>1} #\<^sup>* Lam\<^sup>\<alpha> |
2236 by Theorem~\ref{suppfa} that @{text "{atom x\<^isub>1} #\<^sup>* Lam\<^sup>\<alpha> |
2234 x\<^isub>1 x\<^isub>2"} (since its support is @{text "supp x\<^isub>2 - |
2237 x\<^isub>1 x\<^isub>2"} (since its support is @{text "supp x\<^isub>2 - |
2235 {atom x\<^isub>1}"}). Property \ref{avoiding} provides us therefore with a |
2238 {atom x\<^isub>1}"}). Property \ref{avoiding} provides us then with a |
2236 permutation @{text "\<pi>"}, such that @{text "{atom (\<pi> \<bullet> x\<^isub>1)} #\<^sup>* |
2239 permutation @{text "\<pi>"}, such that @{text "{atom (\<pi> \<bullet> x\<^isub>1)} #\<^sup>* |
2237 c"} and \mbox{@{text "supp (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2) #\<^sup>* \<pi>"}} hold. |
2240 c"} and \mbox{@{text "supp (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2) #\<^sup>* \<pi>"}} hold. |
2238 By using Property \ref{supppermeq}, we can infer from the latter that @{text |
2241 By using Property \ref{supppermeq}, we can infer from the latter that |
2239 "Lam\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} holds. We can use this equation in |
2242 |
2240 the assumption \eqref{assm} and then use \eqref{imp} with the renamed @{text "\<pi> \<bullet> x\<^isub>1"} |
2243 \[ |
2241 and @{text "\<pi> \<bullet> x\<^isub>2"} in order to conclude this case. |
2244 @{text "Lam\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
|
2245 \]\smallskip |
|
2246 |
|
2247 \noindent |
|
2248 holds. We can use this equation in the assumption \eqref{assm}, and hence |
|
2249 use the implication \eqref{imp} with the renamed @{text "\<pi> \<bullet> x\<^isub>1"} |
|
2250 and @{text "\<pi> \<bullet> x\<^isub>2"} for concluding this case. |
2242 |
2251 |
2243 The @{text "Let_pat\<^sup>\<alpha>"}-case involving a deep binder is slightly more complicated. |
2252 The @{text "Let_pat\<^sup>\<alpha>"}-case involving a deep binder is slightly more complicated. |
2244 We have the assumption |
2253 We have the assumption |
2245 |
2254 |
2246 \begin{equation}\label{assmtwo} |
2255 \begin{equation}\label{assmtwo} |
2247 @{text "y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"} |
2256 @{text "y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"} |
2248 \end{equation}\smallskip |
2257 \end{equation}\smallskip |
2249 |
2258 |
2250 \noindent |
2259 \noindent |
2251 and the implication |
2260 and the implication from the stronger cases lemma |
2252 |
2261 |
2253 \[ |
2262 \begin{equation}\label{impletpat} |
2254 @{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. set (bn\<^sup>\<alpha> x\<^isub>1) #\<^sup>* c \<and> y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
2263 @{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. set (bn\<^sup>\<alpha> x\<^isub>1) #\<^sup>* c \<and> y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
2255 \]\smallskip |
2264 \end{equation}\smallskip |
2256 |
2265 |
2257 \noindent |
2266 \noindent |
2258 The reason that this case is more complicated is that we cannot apply directly Property |
2267 The reason that this case is more complicated is that we cannot apply directly Property |
2259 \ref{avoiding} for obtaining a renaming permutation. Property \ref{avoiding} requires |
2268 \ref{avoiding} for obtaining a renaming permutation. Property \ref{avoiding} requires |
2260 that the binders are fresh for the term in which we want to perform the renaming. But |
2269 that the binders are fresh for the term in which we want to perform the renaming. But |
2263 \[ |
2272 \[ |
2264 @{text "Let (x, y) := (x, y) in (x, y)"} |
2273 @{text "Let (x, y) := (x, y) in (x, y)"} |
2265 \]\smallskip |
2274 \]\smallskip |
2266 |
2275 |
2267 \noindent |
2276 \noindent |
2268 Although @{text x} and @{text y} are bound in this term, they are also free |
2277 where @{text x} and @{text y} are bound in the term, but they are also free |
2269 in the assignment. We can, however, obtain obtain such a renaming |
2278 in the assignment. We can, however, obtain such a renaming permutation, say |
2270 permutation, say @{text "\<pi>"}, for the abstraction @{term "Abs_lst (bn_al |
2279 @{text "\<pi>"}, for the abstraction @{term "Abs_lst (bn_al x\<^isub>1) |
2271 x\<^isub>1) x\<^isub>3"}. So we have \mbox{@{term "set (bn_al (\<pi> \<bullet> |
2280 x\<^isub>3"}. As a result we have \mbox{@{term "set (bn_al (\<pi> \<bullet> x\<^isub>1)) |
2272 x\<^isub>1)) \<sharp>* c"}} and @{term "Abs_lst (bn_al (\<pi> \<bullet> x\<^isub>1)) (\<pi> \<bullet> |
2281 \<sharp>* c"}} and @{term "Abs_lst (bn_al (\<pi> \<bullet> x\<^isub>1)) (\<pi> \<bullet> x\<^isub>3) = |
2273 x\<^isub>3) = Abs_lst (bn_al x\<^isub>1) x\<^isub>3"} (remember @{text "set"} and @{text "bn\<^sup>\<alpha>"} are equivariant). |
2282 Abs_lst (bn_al x\<^isub>1) x\<^isub>3"} (remember @{text "set"} and @{text |
2274 Now the quasi-injective property for @{text "Let_pat\<^sup>\<alpha>"} states |
2283 "bn\<^sup>\<alpha>"} are equivariant). Now the quasi-injective property for @{text |
|
2284 "Let_pat\<^sup>\<alpha>"} states that |
2275 |
2285 |
2276 \[ |
2286 \[ |
2277 \infer{@{text "Let_pat\<^sup>\<alpha> p t\<^isub>1 t\<^isub>2 = Let_pat\<^sup>\<alpha> p\<PRIME> t\<PRIME>\<^isub>1 t\<PRIME>\<^isub>2"}} |
2287 \infer{@{text "Let_pat\<^sup>\<alpha> p t\<^isub>1 t\<^isub>2 = Let_pat\<^sup>\<alpha> p\<PRIME> t\<PRIME>\<^isub>1 t\<PRIME>\<^isub>2"}} |
2278 {@{text "[bn\<^sup>\<alpha> p]\<^bsub>list\<^esub>. t\<^isub>2 = [bn\<^sup>\<alpha> p']\<^bsub>list\<^esub>. t\<PRIME>\<^isub>2"}\;\; & |
2288 {@{text "[bn\<^sup>\<alpha> p]\<^bsub>list\<^esub>. t\<^isub>2 = [bn\<^sup>\<alpha> p']\<^bsub>list\<^esub>. t\<PRIME>\<^isub>2"}\;\; & |
2279 @{text "p \<approx>\<AL>\<^bsub>bn\<^esub> p\<PRIME>"}\;\; & @{text "t\<^isub>1 = t\<PRIME>\<^isub>1"}} |
2289 @{text "p \<approx>\<AL>\<^bsub>bn\<^esub> p\<PRIME>"}\;\; & @{text "t\<^isub>1 = t\<PRIME>\<^isub>1"}} |
2280 \]\smallskip |
2290 \]\smallskip |
2281 |
2291 |
2282 \noindent |
2292 \noindent |
2283 Since all atoms in a pattern are bound by @{text "Let_pat\<^sup>\<alpha>"} |
2293 Since all atoms in a pattern are bound by @{text "Let_pat\<^sup>\<alpha>"}, we can infer |
2284 (hence @{text "(\<pi> \<bullet> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds for every @{text "\<pi>"}), we can infer the |
2294 @{text "(\<pi> \<bullet> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds for every @{text "\<pi>"}. Therefore we have that |
2285 equation |
|
2286 |
2295 |
2287 \[ |
2296 \[ |
2288 @{text "Let_pat\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) x\<^isub>2 (\<pi> \<bullet> x\<^isub>3) = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"} |
2297 @{text "Let_pat\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) x\<^isub>2 (\<pi> \<bullet> x\<^isub>3) = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"} |
2289 \]\smallskip |
2298 \]\smallskip |
2290 |
2299 |
2291 \noindent |
2300 \noindent |
2292 Taking the left-hand side as our assumption in \eqref{assmtwo}, we can use |
2301 Taking the left-hand side in the assumption from \eqref{assmtwo}, we can use |
2293 the implication from the stronger cases lemma to infer @{text "P\<^bsub>trm\<^esub>"}, as needed. |
2302 the implication \eqref{impletpat} from the stronger cases lemma to infer @{text "P\<^bsub>trm\<^esub>"}, as needed. |
2294 |
2303 |
2295 The remaining difficulty is when a deep binder contains atoms that are |
2304 The remaining difficulty is when a deep binder contains atoms that are |
2296 bound, but also atoms that are free. An example is @{text "Let\<^sup>\<alpha>"} in \eqref{}. |
2305 bound, but also some that are free. An example is @{text "Let\<^sup>\<alpha>"} in |
2297 Then @{text "(\<pi> \<bullet> x\<^isub>1) |
2306 the example \eqref{letrecs}. In such cases @{text "(\<pi> \<bullet> x\<^isub>1) |
2298 \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} does not hold in general. In such |
2307 \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} does not hold in general. The idea is |
2299 cases, however, we only want to rename binders that will become bound, which |
2308 that we only want to rename binders that will become bound. This does not |
2300 does not affect @{text "\<approx>\<AL>\<^bsub>bn\<^esub>"}. The problem is that the |
2309 affect @{text "\<approx>\<AL>\<^bsub>bn\<^esub>"}. However, the problem is that the |
2301 permutation operation @{text "\<bullet>"} permutes all of them. The remedy is to |
2310 permutation operation @{text "_ \<bullet> _"} applies to all of them. To avoid this |
2302 introduce an auxiliary permutation operation, written @{text "_ |
2311 we introduce an auxiliary permutation operations, written @{text "_ |
2303 \<bullet>\<^bsub>bn\<^esub> _"}, for deep binders that only permute bound atoms and |
2312 \<bullet>\<^bsub>bn\<^esub> _"}, for deep binders that only permutes bound atoms (or |
2304 leaves the other atoms unchanged. Like the @{text |
2313 more precisely the atoms specified by the @{text "bn"}-functions) and leaves |
2305 "fa_bn"}$_{1..m}$-functions, we can define this operation over raw terms |
2314 the other atoms unchanged. Like the @{text "fa_bn"}$_{1..m}$-functions, we |
2306 analysing how the @{text "bn"}$_{1..m}$-functions are defined and then lift |
2315 can define these operations over raw terms analysing how the @{text |
2307 them to alpha-equivalent terms. Assuming the user specified a clause |
2316 "bn"}$_{1..m}$-functions are defined. Assuming the user specified a clause |
2308 |
2317 |
2309 \[ |
2318 \[ |
2310 @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"} |
2319 @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"} |
2311 \]\smallskip |
2320 \]\smallskip |
2312 |
2321 |
2324 \noindent |
2333 \noindent |
2325 Using again the quotient package we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} functions to |
2334 Using again the quotient package we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} functions to |
2326 alpha-equated terms. Moreover we can prove the following two properties |
2335 alpha-equated terms. Moreover we can prove the following two properties |
2327 |
2336 |
2328 \begin{lem}\label{permutebn} |
2337 \begin{lem}\label{permutebn} |
2329 Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text "\<pi>"}\\ |
2338 Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text "\<pi>"}\smallskip\\ |
2330 {\it (i)} @{text "\<pi> \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x)"} and\\ |
2339 {\it (i)} @{text "\<pi> \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x)"} and\\ |
2331 {\it (ii)} @{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x) \<approx>\<AL>\<^bsub>bn\<^esub> x"}. |
2340 {\it (ii)} @{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x) \<approx>\<AL>\<^bsub>bn\<^esub> x"}. |
2332 \end{lem} |
2341 \end{lem} |
2333 |
2342 |
2334 \begin{proof} |
2343 \begin{proof} |
2335 By induction on @{text x}. The properties follow by simple unfolding |
2344 By induction on @{text x}. The properties follow by unfolding of the |
2336 of the definitions. |
2345 definitions. |
2337 \end{proof} |
2346 \end{proof} |
2338 |
2347 |
2339 \noindent |
2348 \noindent |
2340 The first property states that a permutation applied to a binding function is |
2349 The first property states that a permutation applied to a binding function |
2341 equivalent to first permuting the binders and then calculating the bound |
2350 is equivalent to first permuting the binders and then calculating the bound |
2342 atoms. The main point of the auxiliary permutation |
2351 atoms. The second states that @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} preserves |
2343 functions is that it allows us to rename just the binders in a term, |
2352 @{text "\<approx>\<AL>\<^bsub>bn\<^esub>"}. The main point of the auxiliary |
2344 without changing anything else. |
2353 permutation functions is that they allow us to rename just the binders in a |
|
2354 term, without changing anything else. |
2345 |
2355 |
2346 Having the auxiliary permutation function in place, we can now solve all remaining cases. |
2356 Having the auxiliary permutation function in place, we can now solve all remaining cases. |
2347 For @{text "Let\<^sup>\<alpha>"} term-constructor, for example, we can by Property \ref{avoiding} |
2357 For the @{text "Let\<^sup>\<alpha>"} term-constructor, for example, we can by Property \ref{avoiding} |
2348 obtain a @{text "\<pi>"} such that |
2358 obtain a @{text "\<pi>"} such that |
2349 |
2359 |
2350 \[ |
2360 \[ |
2351 @{text "(\<pi> \<bullet> (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c"} \hspace{10mm} |
2361 @{text "(\<pi> \<bullet> (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c"} \hspace{10mm} |
2352 @{text "\<pi> \<bullet> [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2 = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"} |
2362 @{text "\<pi> \<bullet> [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2 = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"} |
2354 |
2364 |
2355 \noindent |
2365 \noindent |
2356 hold. Using Lemma \ref{permutebn}{\it (i)} we can simplify this |
2366 hold. Using Lemma \ref{permutebn}{\it (i)} we can simplify this |
2357 to @{text "set (bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)) #\<^sup>* c"} and |
2367 to @{text "set (bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)) #\<^sup>* c"} and |
2358 @{text "[bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)]\<^bsub>list\<^esub>. (\<pi> \<bullet> x\<^isub>2) = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"}. Since |
2368 @{text "[bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)]\<^bsub>list\<^esub>. (\<pi> \<bullet> x\<^isub>2) = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"}. Since |
2359 @{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds by Lemma \ref{permutebn}{\it (ii)} |
2369 @{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds by Lemma \ref{permutebn}{\it (ii)}, |
2360 we can infer that |
2370 we can infer that |
2361 |
2371 |
2362 \[ |
2372 \[ |
2363 @{text "Let\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
2373 @{text "Let\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
2364 \]\smallskip |
2374 \]\smallskip |
2365 |
2375 |
2366 \noindent |
2376 \noindent |
2367 are alpha-equivalent. This allows us to use the implication from the strong cases |
2377 holds. This allows us to use the implication from the strong cases |
2368 lemma and we can discharge all proof-obligations to do with having covered all |
2378 lemma. |
2369 cases. |
2379 |
2370 |
2380 Conseqently, we can discharge all proof-obligations to do with having covered all |
2371 This completes the proof showing that the weak induction principles imply |
2381 cases. This completes the proof showing that the weak induction principles imply |
2372 the strong induction principles. We have automated the reasoning for all |
2382 the strong induction principles. |
2373 term-calculi the user might specify. The feature of the function package |
|
2374 by Krauss \cite{Krauss09} that allows us to establish an induction principle |
|
2375 by just finding decreasing measures and showing that the induction principle |
|
2376 covers all cases, tremendously helped us in implementing the automation. |
|
2377 *} |
2383 *} |
2378 |
2384 |
2379 |
2385 |
2380 section {* Related Work\label{related} *} |
2386 section {* Related Work\label{related} *} |
2381 |
2387 |
2553 \caption{The nominal datatype declaration for Core-Haskell. For the moment we |
2559 \caption{The nominal datatype declaration for Core-Haskell. For the moment we |
2554 do not support nested types; therefore we explicitly have to unfold the |
2560 do not support nested types; therefore we explicitly have to unfold the |
2555 lists @{text "co_lst"}, @{text "assoc_lst"} and so on. Apart from that, the |
2561 lists @{text "co_lst"}, @{text "assoc_lst"} and so on. Apart from that, the |
2556 declaration follows closely the original in Figure~\ref{corehas}. The |
2562 declaration follows closely the original in Figure~\ref{corehas}. The |
2557 point of our work is that having made such a declaration in Nominal Isabelle, |
2563 point of our work is that having made such a declaration in Nominal Isabelle, |
2558 one obtains automatically a reasoning infrastructure for Core-Haskell. |
2564 one obtains automatically a reasoning infrastructure for Core-Haskell.\bigskip\bigskip |
2559 \label{nominalcorehas}} |
2565 \label{nominalcorehas}} |
2560 \end{figure} |
2566 \end{figure} |
2561 |
2567 |
2562 |
2568 |
2563 Pottier presents a programming language, called C$\alpha$ml, for |
2569 Pottier presents a programming language, called C$\alpha$ml, for |