Paper/Paper.thy
changeset 2361 d73d4d151cce
parent 2360 99134763d03e
child 2362 9d8ebeded16f
equal deleted inserted replaced
2360:99134763d03e 2361:d73d4d151cce
   306   \end{tikzpicture}
   306   \end{tikzpicture}
   307   \end{center}
   307   \end{center}
   308 
   308 
   309   \noindent
   309   \noindent
   310   We take as the starting point a definition of raw terms (defined as a
   310   We take as the starting point a definition of raw terms (defined as a
   311   datatype in Isabelle/HOL); identify then the $\alpha$-equivalence classes in
   311   datatype in Isabelle/HOL); then identify the $\alpha$-equivalence classes in
   312   the type of sets of raw terms according to our $\alpha$-equivalence relation,
   312   the type of sets of raw terms according to our $\alpha$-equivalence relation,
   313   and finally define the new type as these $\alpha$-equivalence classes
   313   and finally define the new type as these $\alpha$-equivalence classes
   314   (non-emptiness is satisfied whenever the raw terms are definable as datatype
   314   (non-emptiness is satisfied whenever the raw terms are definable as datatype
   315   in Isabelle/HOL and the property that our relation for $\alpha$-equivalence is
   315   in Isabelle/HOL and the property that our relation for $\alpha$-equivalence is
   316   indeed an equivalence relation).
   316   indeed an equivalence relation).
  1597 
  1597 
  1598 section {* Establishing the Reasoning Infrastructure *}
  1598 section {* Establishing the Reasoning Infrastructure *}
  1599 
  1599 
  1600 text {*
  1600 text {*
  1601   Having made all necessary definitions for raw terms, we can start
  1601   Having made all necessary definitions for raw terms, we can start
  1602   introducing the reasoning infrastructure for the $\alpha$-equated types the
  1602   with establishing the reasoning infrastructure for the $\alpha$-equated types
  1603   user originally specified. We sketch in this section the facts we need for establishing
  1603   @{text "ty\<AL>"}$_{1..n}$, that is the types the user originally specified. We sketch
  1604   this reasoning infrastructure. First we have to show that the
  1604   in this section the proofs we need for establishing this infrastructure. One
       
  1605   main point of our work is that we have completely automated these proofs in Isabelle/HOL.
       
  1606 
       
  1607   First we establish that the
  1605   $\alpha$-equivalence relations defined in the previous section are 
  1608   $\alpha$-equivalence relations defined in the previous section are 
  1606   equivalence relations.
  1609   equivalence relations.
  1607 
  1610 
  1608   \begin{lemma}\label{equiv} 
  1611   \begin{lemma}\label{equiv} 
  1609   Given the raw types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} and binding functions
  1612   Given the raw types @{text "ty"}$_{1..n}$ and binding functions
  1610   @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, the relations @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"} and 
  1613   @{text "bn"}$_{1..m}$, the relations @{text "\<approx>ty"}$_{1..n}$ and 
  1611   @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} are equivalence relations and equivariant.
  1614   @{text "\<approx>bn"}$_{1..m}$ are equivalence relations and equivariant.
  1612   \end{lemma}
  1615   \end{lemma}
  1613 
  1616 
  1614   \begin{proof} 
  1617   \begin{proof} 
  1615   The proof is by mutual induction over the definitions. The non-trivial
  1618   The proof is by mutual induction over the definitions. The non-trivial
  1616   cases involve premises built up by $\approx_{\textit{set}}$, 
  1619   cases involve premises built up by $\approx_{\textit{set}}$, 
  1620 
  1623 
  1621   \noindent 
  1624   \noindent 
  1622   We can feed this lemma into our quotient package and obtain new types @{text
  1625   We can feed this lemma into our quotient package and obtain new types @{text
  1623   "ty"}$^\alpha_{1..n}$ representing $\alpha$-equated terms of types @{text "ty"}$_{1..n}$. 
  1626   "ty"}$^\alpha_{1..n}$ representing $\alpha$-equated terms of types @{text "ty"}$_{1..n}$. 
  1624   We also obtain definitions for the term-constructors @{text
  1627   We also obtain definitions for the term-constructors @{text
  1625   "C"}$^\alpha_{1..m}$ from the raw term-constructors @{text
  1628   "C"}$^\alpha_{1..k}$ from the raw term-constructors @{text
  1626   "C"}$_{1..m}$, and similar definitions for the free-atom functions @{text
  1629   "C"}$_{1..k}$, and similar definitions for the free-atom functions @{text
  1627   "fa_ty"}$^\alpha_{1..n}$ and the binding functions @{text
  1630   "fa_ty"}$^\alpha_{1..n}$ and @{text "fa_bn"}$^\alpha_{1..m}$ as well as the binding functions @{text
  1628   "bn"}$^\alpha_{1..k}$. However, these definitions are not really useful to the 
  1631   "bn"}$^\alpha_{1..m}$. However, these definitions are not really useful to the 
  1629   user, since they are given in terms of the isomorphisms we obtained by 
  1632   user, since they are given in terms of the isomorphisms we obtained by 
  1630   creating new types in Isabelle/HOL (recall the picture shown in the 
  1633   creating new types in Isabelle/HOL (recall the picture shown in the 
  1631   Introduction).
  1634   Introduction).
  1632 
  1635 
  1633   The first useful property to the user is the fact that term-constructors are 
  1636   The first useful property for the user is the fact that distinct 
  1634   distinct, that is
  1637   term-constructors are not 
       
  1638   equal, that is
  1635   %
  1639   %
  1636   \begin{equation}\label{distinctalpha}
  1640   \begin{equation}\label{distinctalpha}
  1637   \mbox{@{text "C"}$^\alpha_i$@{text "x\<^isub>1 \<dots> x\<^isub>n"} @{text "\<noteq>"} 
  1641   \mbox{@{text "C"}$^\alpha$~@{text "x\<^isub>1 \<dots> x\<^isub>r"}~@{text "\<noteq>"}~% 
  1638   @{text "C"}$^\alpha_j$@{text "y\<^isub>1 \<dots> y\<^isub>m"} holds for @{text "i \<noteq> j"}.} 
  1642   @{text "D"}$^\alpha$~@{text "y\<^isub>1 \<dots> y\<^isub>s"}} 
  1639   \end{equation}
  1643   \end{equation}
  1640   
  1644   
  1641   \noindent
  1645   \noindent
  1642   By definition of $\alpha$-equivalence we can show that
  1646   whenever @{text "C"}$^\alpha$~@{text "\<noteq>"}~@{text "D"}$^\alpha$.
  1643   for the raw term-constructors
  1647   In order to derive this fact, we use the definition of $\alpha$-equivalence
       
  1648   and establish that
  1644   %
  1649   %
  1645   \begin{equation}\label{distinctraw}
  1650   \begin{equation}\label{distinctraw}
  1646   \mbox{@{text "C\<^isub>i x\<^isub>1 \<dots> x\<^isub>n"}\;$\not\approx$@{text ty}\;@{text "C\<^isub>j y\<^isub>1 \<dots> y\<^isub>m"} holds for @{text "i \<noteq> j"}.}
  1651   \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r"}\;$\not\approx$@{text ty}\;@{text "D y\<^isub>1 \<dots> y\<^isub>s"}}
  1647   \end{equation}
  1652   \end{equation}
  1648 
  1653 
  1649   \noindent
  1654   \noindent
  1650   In order to generate \eqref{distinctalpha} from \eqref{distinctraw}, the quotient
  1655   holds for the corresponding raw term-constructors.
  1651   package needs to know that the term-constructors @{text "C\<^isub>i"} and @{text "C\<^isub>j"} 
  1656   In order to deduce \eqref{distinctalpha} from \eqref{distinctraw}, our quotient
       
  1657   package needs to know that the raw term-constructors @{text "C"} and @{text "D"} 
  1652   are \emph{respectful} w.r.t.~the $\alpha$-equivalence relations (see \cite{Homeier05}).
  1658   are \emph{respectful} w.r.t.~the $\alpha$-equivalence relations (see \cite{Homeier05}).
  1653   Assuming @{text "C\<^isub>i"} is of type @{text "ty"} with argument types
  1659   Assuming, for example, @{text "C"} is of type @{text "ty"} with argument types
  1654   @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"}, then respectfulness amounts to showing that
  1660   @{text "ty"}$_{1..r}$, respectfulness amounts to showing that
  1655   %
  1661   %
  1656   \begin{center}
  1662   \begin{center}
  1657   @{text "C\<^isub>i x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C\<^isub>i y\<^isub>1 \<dots> y\<^isub>n"}
  1663   @{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}
  1658   \end{center}  
  1664   \end{center}  
  1659 
  1665 
  1660   \noindent
  1666   \noindent
  1661   are $\alpha$-equivalent under the assumption that @{text "x\<^isub>i \<approx>ty\<^isub>i y\<^isub>i"} holds for all recursive arguments
  1667   holds under the assumptions that we have \mbox{@{text
  1662   and  @{text "x\<^isub>i = y\<^isub>i"} holds for all non-recursive arguments of @{text "C\<^isub>i"}. We can prove this by 
  1668   "x\<^isub>i \<approx>ty\<^isub>i x\<PRIME>\<^isub>i"}} whenever @{text "x\<^isub>i"}
  1663   analysing the definition of @{text "\<approx>ty"}. For this proof to succeed we have to establish 
  1669   and @{text "x\<PRIME>\<^isub>i"} are recursive arguments of @{text C} and
  1664   the following auxiliary fact about binding functions. Given a binding function @{text bn\<^isub>i} defined 
  1670   @{text "x\<^isub>i = x\<PRIME>\<^isub>i"} whenever they are non-recursive arguments. We can prove this
  1665   for the type @{text ty\<^isub>i}, we have that
  1671   implication by applying the corresponding rule in our $\alpha$-equivalence
  1666   %
  1672   definition and by establishing the following auxiliary facts 
  1667   \begin{center}
       
  1668   @{text "x \<approx>ty\<^isub>i y"} implies @{text "x \<approx>bn\<^isub>i y"}
       
  1669   \end{center}
       
  1670 
       
  1671   \noindent
       
  1672   This can be established by induction on the definition of @{text "\<approx>ty\<^isub>i"}. 
       
  1673    
       
  1674   Having established respectfulness for every raw term-constructor, the 
       
  1675   quotient package is able to automatically deduce \eqref{distinctalpha} from \eqref{distinctraw}.
       
  1676   In fact we can from now on lift facts from the raw level to the $\alpha$-equated level
       
  1677   as long as they contain raw term-constructors only. The 
       
  1678   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
       
  1679   "ty"}$_{1..n}$ fall into this category. So we can also add to our infrastructure
       
  1680   induction principles that establish
       
  1681 
       
  1682   \begin{center}
       
  1683   @{text "P\<^bsub>ty\<AL>\<^esub>\<^isub>1 y\<^isub>1 \<dots> P\<^bsub>ty\<AL>\<^esub>\<^isub>n y\<^isub>n "}
       
  1684   \end{center} 
       
  1685 
       
  1686   \noindent
       
  1687   for all @{text "y\<^isub>i"} whereby the variables @{text "P\<^bsub>ty\<AL>\<^esub>\<^isub>i"} stand for properties
       
  1688   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
       
  1689   these induction principles look
       
  1690   as follows
       
  1691 
       
  1692   \begin{center}
       
  1693   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<AL>\<^esub>\<^isub>i x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<AL>\<^esub>\<^isub>j x\<^isub>j \<Rightarrow> P\<^bsub>ty\<AL>\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
       
  1694   \end{center}
       
  1695 
       
  1696   \noindent
       
  1697   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
       
  1698   Next we lift the permutation operations defined in \eqref{ceqvt} for
       
  1699   the raw term-constructors @{text "C"}. These facts contain, in addition 
       
  1700   to the term-constructors, also permutation operations. In order to make the 
       
  1701   lifting go through, 
       
  1702   we have to know that the permutation operations are respectful 
       
  1703   w.r.t.~$\alpha$-equivalence. This amounts to showing that the 
       
  1704   $\alpha$-equivalence relations are equivariant, which we already established 
       
  1705   in Lemma~\ref{equiv}. As a result we can establish the equations
       
  1706   
       
  1707   \begin{equation}\label{calphaeqvt}
       
  1708   @{text "p \<bullet> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n) = C\<^sup>\<alpha> (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"}
       
  1709   \end{equation}
       
  1710 
       
  1711   \noindent
       
  1712   for our infrastructure. In a similar fashion we can lift the equations
       
  1713   characterising the free-atom functions @{text "fn_ty\<AL>\<^isub>j"} and @{text "fa_bn\<AL>\<^isub>k"}, and the 
       
  1714   binding functions @{text "bn\<AL>\<^isub>k"}. The necessary respectfulness lemmas for these
       
  1715   lifting are the properties:
       
  1716   %
  1673   %
  1717   \begin{equation}\label{fnresp}
  1674   \begin{equation}\label{fnresp}
  1718   \mbox{%
  1675   \mbox{%
  1719   \begin{tabular}{l}
  1676   \begin{tabular}{l}
  1720   @{text "x \<approx>ty\<^isub>j y"} implies @{text "fa_ty\<^isub>j x = fa_ty\<^isub>j y"}\\
  1677   @{text "x \<approx>ty\<^isub>i x\<PRIME>"}~~implies~@{text "fa_ty\<^isub>i x = fa_ty\<^isub>i x\<PRIME>"}\\
  1721   @{text "x \<approx>ty\<^isub>k y"} implies @{text "fa_bn\<^isub>k x = fa_bn\<^isub>k y"}\\
  1678   @{text "x \<approx>ty\<^isub>j x\<PRIME>"}~~implies~@{text "fa_bn\<^isub>j x = fa_bn\<^isub>j x\<PRIME>"}\\
  1722   @{text "x \<approx>ty\<^isub>k y"} implies @{text "bn\<^isub>k x = bn\<^isub>k y"}
  1679   @{text "x \<approx>ty\<^isub>j x\<PRIME>"}~~implies~@{text "bn\<^isub>j x = bn\<^isub>j x\<PRIME>"}\\
       
  1680   @{text "x \<approx>ty\<^isub>j x\<PRIME>"}~~implies~@{text "x \<approx>bn\<^isub>j x\<PRIME>"}\\
  1723   \end{tabular}}
  1681   \end{tabular}}
  1724   \end{equation}
  1682   \end{equation}
  1725 
  1683 
  1726   \noindent
  1684   \noindent
  1727   which can be established by induction on @{text "\<approx>ty"}. Whereas the first
  1685   They can be established by induction on @{text "\<approx>ty"}$_{1..n}$. Whereas the first,
  1728   property is always true by the way we defined the free-atom
  1686   second and last implication are true by how we stated our definitions, the 
  1729   functions for types, the second and third do \emph{not} hold in general. There is, in principle, 
  1687   third \emph{only} holds because of our restriction
  1730   the possibility that the user defines @{text "bn\<^isub>k"} so that it returns an already bound
  1688   imposed on the form of the binding functions---namely \emph{not} returning 
  1731   atom. Then the third property is just not true. However, our 
  1689   any bound atoms. In Ott, in contrast, the user may 
  1732   restrictions imposed on the binding functions
  1690   define @{text "bn"}$_{1..m}$ so that they return bound
  1733   exclude this possibility.
  1691   atoms and in this case the third implication is \emph{not} true. A 
  1734 
  1692   result is that the lifing of the corresponding binding functions to $\alpha$-equated
  1735   Having the facts \eqref{fnresp} at our disposal, we can lift the
  1693   terms is impossible.
  1736   definitions that characterise when two terms of the form
  1694 
  1737 
  1695   Having established respectfulness for the raw term-constructors, the 
  1738   \begin{center}
  1696   quotient package is able to automatically deduce \eqref{distinctalpha} from 
  1739   @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"}
  1697   \eqref{distinctraw}. Having the facts \eqref{fnresp} at our disposal, we can 
       
  1698   also lift properties that characterise when two raw terms of the form
       
  1699   %
       
  1700   \begin{center}
       
  1701   @{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}
  1740   \end{center}
  1702   \end{center}
  1741 
  1703 
  1742   \noindent
  1704   \noindent
  1743   are $\alpha$-equivalent. This gives us conditions when the corresponding
  1705   are $\alpha$-equivalent. This gives us conditions when the corresponding
  1744   $\alpha$-equated terms are \emph{equal}, namely
  1706   $\alpha$-equated terms are \emph{equal}, namely
  1745 
  1707   %
  1746   \begin{center}
  1708   \begin{center}
  1747   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n = C\<^sup>\<alpha> y\<^isub>1 \<dots> y\<^isub>n"}
  1709   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r = C\<^sup>\<alpha> x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}
  1748   \end{center}
  1710   \end{center}
  1749 
  1711 
  1750   \noindent
  1712   \noindent
  1751   We call these conditions as \emph{quasi-injectivity}. Except for one function, which
  1713   We call these conditions as \emph{quasi-injectivity}. They correspond to
  1752   we have to lift in the next section, we completed
  1714   the premises in our $\alpha$-equivalence relations.
  1753   the lifting part of establishing the reasoning infrastructure. 
  1715 
  1754 
  1716   Next we can lift the permutation 
  1755   By working now completely on the $\alpha$-equated level, we can first show that 
  1717   operations defined in \eqref{ceqvt}. In order to make this 
  1756   the free-atom functions and binding functions
  1718   lifting to go through, we have to show that the permutation operations are respectful. 
  1757   are equivariant, namely
  1719   This amounts to showing that the 
  1758 
  1720   $\alpha$-equivalence relations are equivariant, which we already established 
       
  1721   in Lemma~\ref{equiv}. As a result we can add the equations
       
  1722   %
       
  1723   \begin{equation}\label{calphaeqvt}
       
  1724   @{text "p \<bullet> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r) = C\<^sup>\<alpha> (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>r)"}
       
  1725   \end{equation}
       
  1726 
       
  1727   \noindent
       
  1728   to our infrastructure. In a similar fashion we can lift the defining equations
       
  1729   of the free-atom functions @{text "fn_ty\<AL>"}$_{1..n}$ and
       
  1730   @{text "fa_bn\<AL>"}$_{1..m}$ as well as of the binding functions @{text
       
  1731   "bn\<AL>"}$_{1..m}$ and of the size functions @{text "size_ty\<AL>"}$_{1..n}$.
       
  1732   The latter are defined automatically for the raw types @{text "ty"}$_{1..n}$
       
  1733   by the datatype package of Isabelle/HOL.
       
  1734 
       
  1735   Finally we can add to our infrastructure a structural induction principle 
       
  1736   for the types @{text "ty\<AL>"}$_{i..n}$ whose 
       
  1737   conclusion of the form
       
  1738   %
       
  1739   \begin{equation}\label{weakinduct}
       
  1740   \mbox{@{text "P\<^isub>1 x\<^isub>1 \<and> \<dots> \<and> P\<^isub>n x\<^isub>n "}}
       
  1741   \end{equation} 
       
  1742 
       
  1743   \noindent
       
  1744   whereby the @{text P}$_{1..n}$ are predicates and the @{text x}$_{1..n}$ 
       
  1745   have types @{text "ty\<AL>"}$_{1..n}$. This induction principle has for each
       
  1746   term constructor @{text "C"}$^\alpha$ a premise of the form
       
  1747   %
       
  1748   \begin{equation}\label{weakprem}
       
  1749   \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)"}} 
       
  1750   \end{equation}
       
  1751 
       
  1752   \noindent 
       
  1753   in which the @{text "x"}$_{i..j}$ @{text "\<subseteq>"} @{text "x"}$_{1..r}$ are 
       
  1754   the recursive arguments of @{text "C\<AL>"}. 
       
  1755 
       
  1756   By working now completely on the $\alpha$-equated level, we
       
  1757   can first show that the free-atom functions and binding functions are
       
  1758   equivariant, namely
       
  1759   %
  1759   \begin{center}
  1760   \begin{center}
  1760   \begin{tabular}{rcl}
  1761   \begin{tabular}{rcl}
  1761   @{text "p \<bullet> (fa_ty\<^sup>\<alpha> x)"} & $=$ & @{text "fa_ty\<^sup>\<alpha> (p \<bullet> x)"}\\
  1762   @{text "p \<bullet> (fa_ty\<AL>\<^isub>i  x)"} & $=$ & @{text "fa_ty\<AL>\<^isub>i (p \<bullet> x)"}\\
  1762   @{text "p \<bullet> (fa_bn\<^sup>\<alpha> x)"} & $=$ & @{text "fa_bn\<^sup>\<alpha> (p \<bullet> x)"}\\
  1763   @{text "p \<bullet> (fa_bn\<AL>\<^isub>j  x)"} & $=$ & @{text "fa_bn\<AL>\<^isub>j (p \<bullet> x)"}\\
  1763   @{text "p \<bullet> (bn\<^sup>\<alpha> x)"}    & $=$ & @{text "bn\<^sup>\<alpha> (p \<bullet> x)"}
  1764   @{text "p \<bullet> (bn\<AL>\<^isub>j  x)"}    & $=$ & @{text "bn\<AL>\<^isub>j (p \<bullet> x)"}
  1764   \end{tabular}
  1765   \end{tabular}
  1765   \end{center}
  1766   \end{center}
  1766 
  1767 
  1767   \noindent
  1768   \noindent
  1768   These properties can be established by structural induction over the @{text x}
  1769   These properties can be established using the induction principle
  1769   (using the induction principles we lifted above for the types @{text "ty\<AL>\<^bsub>1..n\<^esub>"}).
  1770   in \eqref{weakinduct}.
  1770 
  1771   Having these equivariant properties established, we can
  1771   Until now we have not yet derived anything about the support of the 
       
  1772   $\alpha$-equated terms. This however will be necessary in order to derive
       
  1773   the strong induction principles in the next section.
       
  1774   Using the equivariance properties in \eqref{ceqvt} we can
       
  1775   show for every term-constructor @{text "C\<^sup>\<alpha>"} that 
  1772   show for every term-constructor @{text "C\<^sup>\<alpha>"} that 
  1776 
  1773 
  1777   \begin{center}
  1774   \begin{center}
  1778   @{text "(supp x\<^isub>1 \<union> \<dots> supp x\<^isub>n) supports (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"}
  1775   @{text "(supp x\<^isub>1 \<union> \<dots> supp x\<^isub>r) supports (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r)"}
  1779   \end{center}
  1776   \end{center}
  1780  
  1777  
  1781   \noindent
  1778   \noindent
  1782   holds. This together with Property~\ref{supportsprop} allows us to show
  1779   holds. This together with Property~\ref{supportsprop} allows us to show
  1783  
  1780   for every @{text x} of type @{text "ty\<AL>"}$_{1..n}$ is finitely supported, 
  1784   \begin{center}
  1781   namely @{text "finite (supp x)"}. This can be again shown by induction 
  1785   @{text "finite (supp x\<^isub>i)"}
  1782   over @{text "ty\<AL>"}$_{1..n}$. Lastly, we can show that the support of 
  1786   \end{center}
  1783   elements in  @{text "ty\<AL>"}$_{1..n}$ is the same as @{text "fa_ty\<AL>"}$_{1..n}$.
  1787 
  1784   This important fact provides evidence that our notions of free-atoms and 
  1788   \noindent
  1785   $\alpha$-equivalence are correct.
  1789   by a structural induction over @{text "x\<^isub>1, \<dots>, x\<^isub>n"} (whereby @{text "x\<^isub>i"} ranges over the types 
       
  1790   @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}). Lastly, we can show that the support of elements in 
       
  1791   @{text "ty\<AL>\<^bsub>1..n\<^esub>"} coincides with @{text "fa_ty\<AL>\<^bsub>1..n\<^esub>"}.
       
  1792 
  1786 
  1793   \begin{lemma} 
  1787   \begin{lemma} 
  1794   For every @{text "x\<^isub>i"} of type @{text "ty\<AL>\<^bsub>1..n\<^esub>"}, we have that 
  1788   For every @{text "x"} of type @{text "ty\<AL>"}$_{1..n}$, we have
  1795   @{text "supp x\<^isub>i = fa_ty\<AL>\<^isub>i x\<^isub>i"} holds.
  1789   @{text "supp x = fa_ty\<AL>\<^isub>i x"}.
  1796   \end{lemma}
  1790   \end{lemma}
  1797 
  1791 
  1798   \begin{proof}
  1792   \begin{proof}
  1799   The proof proceeds by structural induction over the @{text "x\<^isub>i"}. In each case
  1793   The proof is by induction. In each case
  1800   we unfold the definition of @{text "supp"}, move the swapping inside the 
  1794   we unfold the definition of @{text "supp"}, move the swapping inside the 
  1801   term-constructors and the use then quasi-injectivity lemmas in order to complete the
  1795   term-constructors and then use the quasi-injectivity lemmas in order to complete the
  1802   proof. For the abstraction cases we use the facts derived in Theorem~\ref{suppabs}.
  1796   proof. For the abstraction cases we use the facts derived in Theorem~\ref{suppabs}.
  1803   \end{proof}
  1797   \end{proof}
  1804 
  1798 
  1805   \noindent
  1799   \noindent
  1806   To sum up, we can established automatically a reasoning infrastructure
  1800   To sum up, we can established automatically a reasoning infrastructure
  1807   for the types @{text "ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"} 
  1801   for the types @{text "ty\<AL>"}$_{1..n}$ 
  1808   by first lifting definitions from the raw level to the quotient level and
  1802   by first lifting definitions from the raw level to the quotient level and
  1809   then establish facts about these lifted definitions. All necessary proofs
  1803   then by establishing facts about these lifted definitions. All necessary proofs
  1810   are generated automatically by custom ML-code. This code can deal with 
  1804   are generated automatically by custom ML-code. This code can deal with 
  1811   specifications like the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1805   specifications like the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1812 
  1806 
  1813   \begin{figure}[t!]
  1807   \begin{figure}[t!]
  1814   \begin{boxedminipage}{\linewidth}
  1808   \begin{boxedminipage}{\linewidth}
  1815   \small
  1809   \small
  1816   \begin{tabular}{l}
  1810   \begin{tabular}{l}
  1817   \isacommand{atom\_decl}~@{text "var"}\\
  1811   \isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm]
  1818   \isacommand{atom\_decl}~@{text "cvar"}\\
       
  1819   \isacommand{atom\_decl}~@{text "tvar"}\\[1mm]
       
  1820   \isacommand{nominal\_datatype}~@{text "tkind ="}\\
  1812   \isacommand{nominal\_datatype}~@{text "tkind ="}\\
  1821   \phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ 
  1813   \phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ 
  1822   \isacommand{and}~@{text "ckind ="}\\
  1814   \isacommand{and}~@{text "ckind ="}\\
  1823   \phantom{$|$}~@{text "CKSim ty ty"}\\
  1815   \phantom{$|$}~@{text "CKSim ty ty"}\\
  1824   \isacommand{and}~@{text "ty ="}\\
  1816   \isacommand{and}~@{text "ty ="}\\
  1886 section {* Strong Induction Principles *}
  1878 section {* Strong Induction Principles *}
  1887 
  1879 
  1888 text {*
  1880 text {*
  1889   In the previous section we were able to provide induction principles that 
  1881   In the previous section we were able to provide induction principles that 
  1890   allow us to perform structural inductions over $\alpha$-equated terms. 
  1882   allow us to perform structural inductions over $\alpha$-equated terms. 
  1891   We call such induction principles \emph{weak}, because in case of a term-constructor @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n"},
  1883   We call such induction principles \emph{weak}, because in case of a term-constructor @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r"},
  1892   the induction hypothesis requires us to establish the implication
  1884   the induction hypothesis requires us to establish the implications \eqref{weakprem}.
  1893   %
  1885   The problem with these implications is that in general they are not easy to establish.
  1894   \begin{equation}\label{weakprem}
       
  1895   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. 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>n)"} 
       
  1896   \end{equation}
       
  1897 
       
  1898   \noindent
       
  1899   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
       
  1900   The problem with this implication is that in general it is not easy to establish it.
       
  1901   The reason is that we cannot make any assumption about the binders that might be in @{text "C\<^sup>\<alpha>"} 
  1886   The reason is that we cannot make any assumption about the binders that might be in @{text "C\<^sup>\<alpha>"} 
  1902   (for example we cannot assume the variable convention for them).
  1887   (for example we cannot assume the variable convention for them).
  1903 
  1888 
  1904   In \cite{UrbanTasson05} we introduced a method for automatically
  1889   In \cite{UrbanTasson05} we introduced a method for automatically
  1905   strengthening weak induction principles for terms containing single
  1890   strengthening weak induction principles for terms containing single
  1912   additional notion for permuting deep binders. 
  1897   additional notion for permuting deep binders. 
  1913 
  1898 
  1914   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1899   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1915   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1900   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1916   Assuming a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1901   Assuming a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1917   we define  %
  1902   we define @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>n) \<equiv> C y\<^isub>1 \<dots> y\<^isub>n"} with @{text "y\<^isub>i"} determined as follows:
  1918   \begin{center}
       
  1919   @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>n) \<equiv> C y\<^isub>1 \<dots> y\<^isub>n"}
       
  1920   \end{center}
       
  1921 
       
  1922   \noindent
       
  1923   with @{text "y\<^isub>i"} determined as follows:
       
  1924   %
  1903   %
  1925   \begin{center}
  1904   \begin{center}
  1926   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1905   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1927   $\bullet$ & @{text "y\<^isub>i \<equiv> x\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text "rhs"}\\
  1906   $\bullet$ & @{text "y\<^isub>i \<equiv> x\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text "rhs"}\\
  1928   $\bullet$ & @{text "y\<^isub>i \<equiv> p \<bullet>\<^bsub>bn'\<^esub> x\<^isub>i"} provided @{text "bn' x\<^isub>i"} is in @{text "rhs"}\\
  1907   $\bullet$ & @{text "y\<^isub>i \<equiv> p \<bullet>\<^bsub>bn'\<^esub> x\<^isub>i"} provided @{text "bn' x\<^isub>i"} is in @{text "rhs"}\\
  1965 
  1944 
  1966   \noindent
  1945   \noindent
  1967   This fact will be crucial when establishing the strong induction principles. 
  1946   This fact will be crucial when establishing the strong induction principles. 
  1968   In our running example about @{text "Let"}, they state that instead 
  1947   In our running example about @{text "Let"}, they state that instead 
  1969   of establishing the implication 
  1948   of establishing the implication 
  1970 
  1949   %
  1971   \begin{center}
  1950   \begin{center}
  1972   @{text "\<forall>p t\<^isub>1 t\<^isub>2. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t\<^isub>1 \<and> P\<^bsub>trm\<^esub> t\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t\<^isub>1 t\<^isub>2)"}
  1951   @{text "\<forall>p t\<^isub>1 t\<^isub>2. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t\<^isub>1 \<and> P\<^bsub>trm\<^esub> t\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t\<^isub>1 t\<^isub>2)"}
  1973   \end{center}
  1952   \end{center}
  1974 
  1953 
  1975   \noindent
  1954   \noindent
  2011   @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t\<^isub>2)) \<sharp>* r"}
  1990   @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t\<^isub>2)) \<sharp>* r"}
  2012   \end{equation}
  1991   \end{equation}
  2013 
  1992 
  2014   \noindent
  1993   \noindent
  2015   hold. The latter fact and \eqref{renaming} give us
  1994   hold. The latter fact and \eqref{renaming} give us
  2016 
  1995   %
  2017   \begin{center}
  1996   \begin{center}
  2018   \begin{tabular}{l}
  1997   \begin{tabular}{l}
  2019   @{text "Let (q \<bullet> p) (q \<bullet> t\<^isub>1) (q \<bullet> t\<^isub>2) ="} \\
  1998   @{text "Let (q \<bullet> p) (q \<bullet> t\<^isub>1) (q \<bullet> t\<^isub>2) ="} \\
  2020   \hspace{15mm}@{text "Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2))"}
  1999   \hspace{15mm}@{text "Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2))"}
  2021   \end{tabular}
  2000   \end{tabular}
  2022   \end{center}
  2001   \end{center}
  2023 
  2002 
  2024   \noindent
  2003   \noindent
  2025   So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"}, we can equally
  2004   So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"}, we can equally
  2026   establish
  2005   establish @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2)))"}.
  2027 
       
  2028   \begin{center}
       
  2029   @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2)))"}
       
  2030   \end{center}
       
  2031 
       
  2032   \noindent
       
  2033   To do so, we will use the implication \eqref{strong} of the strong induction
  2006   To do so, we will use the implication \eqref{strong} of the strong induction
  2034   principle, which requires us to discharge
  2007   principle, which requires us to discharge
  2035   the following four proof obligations:
  2008   the following four proof obligations:
  2036 
  2009   %
  2037   \begin{center}
  2010   \begin{center}
  2038   \begin{tabular}{rl}
  2011   \begin{tabular}{rl}
  2039   {\it i)} &   @{text "set (bn (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\
  2012   {\it i)} &   @{text "set (bn (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\
  2040   {\it ii)} &  @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\
  2013   {\it ii)} &  @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\
  2041   {\it iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (q \<bullet> t\<^isub>1)"}\\
  2014   {\it iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (q \<bullet> t\<^isub>1)"}\\
  2061 section {* Related Work *}
  2034 section {* Related Work *}
  2062 
  2035 
  2063 text {*
  2036 text {*
  2064   To our knowledge the earliest usage of general binders in a theorem prover
  2037   To our knowledge the earliest usage of general binders in a theorem prover
  2065   is described in \cite{NaraschewskiNipkow99} about a formalisation of the
  2038   is described in \cite{NaraschewskiNipkow99} about a formalisation of the
  2066   algorithm W. This formalisation implements binding in type schemes using a
  2039   algorithm W. This formalisation implements binding in type-schemes using a
  2067   de-Bruijn indices representation. Since type schemes in W contain only a single
  2040   de-Bruijn indices representation. Since type-schemes in W contain only a single
  2068   place where variables are bound, different indices do not refer to different binders (as in the usual
  2041   place where variables are bound, different indices do not refer to different binders (as in the usual
  2069   de-Bruijn representation), but to different bound variables. A similar idea
  2042   de-Bruijn representation), but to different bound variables. A similar idea
  2070   has been recently explored for general binders in the locally nameless
  2043   has been recently explored for general binders in the locally nameless
  2071   approach to binding \cite{chargueraud09}.  There, de-Bruijn indices consist
  2044   approach to binding \cite{chargueraud09}.  There, de-Bruijn indices consist
  2072   of two numbers, one referring to the place where a variable is bound and the
  2045   of two numbers, one referring to the place where a variable is bound and the
  2190 *}
  2163 *}
  2191 
  2164 
  2192 section {* Conclusion *}
  2165 section {* Conclusion *}
  2193 
  2166 
  2194 text {*
  2167 text {*
  2195 We can also see that
       
  2196   %
       
  2197   \begin{equation}\label{bnprop}
       
  2198   @{text "fa_ty x  =  bn x \<union> fa_bn x"}.
       
  2199   \end{equation}
       
  2200 
       
  2201   \noindent
       
  2202   holds for any @{text "bn"}-function defined for the type @{text "ty"}.
       
  2203 
       
  2204 *}
       
  2205 
       
  2206 
       
  2207 text {*
       
  2208   We have presented an extension of Nominal Isabelle for deriving
  2168   We have presented an extension of Nominal Isabelle for deriving
  2209   automatically a convenient reasoning infrastructure that can deal with
  2169   automatically a convenient reasoning infrastructure that can deal with
  2210   general binders, that is term-constructors binding multiple variables at
  2170   general binders, that is term-constructors binding multiple variables at
  2211   once. This extension has been tried out with the Core-Haskell
  2171   once. This extension has been tried out with the Core-Haskell
  2212   term-calculus. For such general binders, we can also extend
  2172   term-calculus. For such general binders, we can also extend
  2213   earlier work that derives strong induction principles which have the usual
  2173   earlier work that derives strong induction principles which have the usual
  2214   variable convention already built in. For the moment we can do so only with manual help,
  2174   variable convention already built in. For the moment we can do so only with manual help,
  2215   but future work will automate them completely.  The code underlying the presented
  2175   but future work will automate them completely.  The code underlying the presented
  2216   extension will become part of the Isabelle distribution, but for the moment
  2176   extension will become part of the Isabelle distribution.\footnote{For the moment
  2217   it can be downloaded from the Mercurial repository linked at
  2177   it can be downloaded from the Mercurial repository linked at
  2218   \href{http://isabelle.in.tum.de/nominal/download}
  2178   \href{http://isabelle.in.tum.de/nominal/download}
  2219   {http://isabelle.in.tum.de/nominal/download}.
  2179   {http://isabelle.in.tum.de/nominal/download}.}
  2220 
  2180 
  2221   We have left out a discussion about how functions can be defined over
  2181   We have left out a discussion about how functions can be defined over
  2222   $\alpha$-equated terms that involve general binders. In earlier versions of Nominal
  2182   $\alpha$-equated terms that involve general binders. In earlier versions of Nominal
  2223   Isabelle \cite{UrbanBerghofer06} this turned out to be a thorny issue.  We
  2183   Isabelle \cite{UrbanBerghofer06} this turned out to be a thorny issue.  We
  2224   hope to do better this time by using the function package that has recently
  2184   hope to do better this time by using the function package that has recently
  2235 
  2195 
  2236   More interesting line of investigation is whether we can go beyond the 
  2196   More interesting line of investigation is whether we can go beyond the 
  2237   simple-minded form for binding functions that we adopted from Ott. At the moment, binding
  2197   simple-minded form for binding functions that we adopted from Ott. At the moment, binding
  2238   functions can only return the empty set, a singleton atom set or unions
  2198   functions can only return the empty set, a singleton atom set or unions
  2239   of atom sets (similarly for lists). It remains to be seen whether 
  2199   of atom sets (similarly for lists). It remains to be seen whether 
  2240   properties like \eqref{bnprop} provide us with means to support more interesting
  2200   properties like
       
  2201   %
       
  2202   \begin{center}
       
  2203   @{text "fa_ty x  =  bn x \<union> fa_bn x"}.
       
  2204   \end{center}
       
  2205   
       
  2206   \noindent
       
  2207   provide us with means to support more interesting
  2241   binding functions. 
  2208   binding functions. 
  2242 
  2209 
  2243 
  2210 
  2244   We have also not yet played with other binding modes. For example we can
  2211   We have also not yet played with other binding modes. For example we can
  2245   imagine that there is need for a binding mode \isacommand{bind\_\#list} with
  2212   imagine that there is need for a binding mode 
  2246   an associated abstraction of the form
       
  2247   %
       
  2248   \begin{center}
       
  2249   @{term "Abs_dist as x"}
       
  2250   \end{center}
       
  2251 
       
  2252   \noindent
       
  2253   where instead of lists, we abstract lists of distinct elements.
  2213   where instead of lists, we abstract lists of distinct elements.
  2254   Once we feel confident about such binding modes, our implementation 
  2214   Once we feel confident about such binding modes, our implementation 
  2255   can be easily extended to accommodate them.
  2215   can be easily extended to accommodate them.
  2256 
  2216 
  2257   \medskip
  2217   %\medskip
  2258   \noindent
  2218   %\noindent
  2259   {\bf Acknowledgements:} We are very grateful to Andrew Pitts for  
  2219   %{\bf Acknowledgements:} We are very grateful to Andrew Pitts for  
  2260   many discussions about Nominal Isabelle. We also thank Peter Sewell for 
  2220   %many discussions about Nominal Isabelle. We also thank Peter Sewell for 
  2261   making the informal notes \cite{SewellBestiary} available to us and 
  2221   %making the informal notes \cite{SewellBestiary} available to us and 
  2262   also for patiently explaining some of the finer points of the work on the Ott-tool.
  2222   %also for patiently explaining some of the finer points of the work on the Ott-tool.
  2263   Stephanie Weirich suggested to separate the subgrammars
  2223   %Stephanie Weirich suggested to separate the subgrammars
  2264   of kinds and types in our Core-Haskell example.  
  2224   %of kinds and types in our Core-Haskell example.  
  2265 
  2225 
  2266 *}
  2226 *}
  2267 
  2227 
  2268 (*<*)
  2228 (*<*)
  2269 end
  2229 end