Paper/Paper.thy
changeset 1770 26e44bcddb5b
parent 1769 6ca795b1cd76
child 1771 3e71af53cedb
equal deleted inserted replaced
1769:6ca795b1cd76 1770:26e44bcddb5b
  1483   can be dealt with as in Lemma~\ref{alphaeq}.
  1483   can be dealt with as in Lemma~\ref{alphaeq}.
  1484   \end{proof}
  1484   \end{proof}
  1485 
  1485 
  1486   \noindent 
  1486   \noindent 
  1487   We can feed this lemma into our quotient package and obtain new types @{text
  1487   We can feed this lemma into our quotient package and obtain new types @{text
  1488   "ty"}$^\alpha_{1..n}$ representing alpha-equated terms. We also obtain 
  1488   "ty\<AL>\<^bsub>1..n\<^esub>"} representing alpha-equated terms of types @{text "ty\<^bsub>1..n\<^esub>"}. We also obtain 
  1489   definitions for the term-constructors @{text
  1489   definitions for the term-constructors @{text
  1490   "C"}$^\alpha_{1..m}$ from the raw term-constructors @{text
  1490   "C"}$^\alpha_{1..m}$ from the raw term-constructors @{text
  1491   "C"}$_{1..m}$, and similar definitions for the free-variable functions @{text
  1491   "C"}$_{1..m}$, and similar definitions for the free-variable functions @{text
  1492   "fv_ty"}$^\alpha_{1..n}$ and the binding functions @{text
  1492   "fv_ty"}$^\alpha_{1..n}$ and the binding functions @{text
  1493   "bn"}$^\alpha_{1..k}$. However, these definitions are not really useful to the 
  1493   "bn"}$^\alpha_{1..k}$. However, these definitions are not really useful to the 
  1514   \noindent
  1514   \noindent
  1515   In order to generate \eqref{distinctalpha} from \eqref{distinctraw}, the quotient
  1515   In order to generate \eqref{distinctalpha} from \eqref{distinctraw}, the quotient
  1516   package needs to know that the term-constructors @{text "C\<^isub>i"} and @{text "C\<^isub>j"} 
  1516   package needs to know that the term-constructors @{text "C\<^isub>i"} and @{text "C\<^isub>j"} 
  1517   are \emph{respectful} w.r.t.~the alpha-equivalence relations (see \cite{Homeier05}).
  1517   are \emph{respectful} w.r.t.~the alpha-equivalence relations (see \cite{Homeier05}).
  1518   Assuming @{text "C\<^isub>i"} is of type @{text "ty"} with argument types
  1518   Assuming @{text "C\<^isub>i"} is of type @{text "ty"} with argument types
  1519   @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"}, then respectfulness amounts to showing
  1519   @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"}, then respectfulness amounts to showing that
  1520   
  1520   
  1521   \begin{center}
  1521   \begin{center}
  1522   @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"}
  1522   @{text "C\<^isub>i x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C\<^isub>i y\<^isub>1 \<dots> y\<^isub>n"}
  1523   \end{center}  
  1523   \end{center}  
  1524 
  1524 
  1525   \noindent
  1525   \noindent
  1526   are alpha-equivalent under the assumption that @{text "x\<^isub>i \<approx>ty\<^isub>i y\<^isub>i"} holds for all recursive arguments
  1526   are alpha-equivalent under the assumption that @{text "x\<^isub>i \<approx>ty\<^isub>i y\<^isub>i"} holds for all recursive arguments
  1527   and  @{text "x\<^isub>i = y\<^isub>i"} holds for all non-recursive arguments. We can prove this by 
  1527   and  @{text "x\<^isub>i = y\<^isub>i"} holds for all non-recursive arguments of @{text "C\<^isub>i"}. We can prove this by 
  1528   analysing the definition of @{text "\<approx>ty"}. For this to succeed we have to establish 
  1528   analysing the definition of @{text "\<approx>ty"}. For this proof to succeed we have to establish 
  1529   the following auxiliary fact about binding functions. Given a binding function @{text bn\<^isub>i} defined 
  1529   the following auxiliary fact about binding functions. Given a binding function @{text bn\<^isub>i} defined 
  1530   for the type @{text ty\<^isub>i}, we have that
  1530   for the type @{text ty\<^isub>i}, we have that
  1531   %
  1531   %
  1532   \begin{center}
  1532   \begin{center}
  1533   @{text "x \<approx>ty\<^isub>i y"} implies @{text "x \<approx>bn\<^isub>i y"}
  1533   @{text "x \<approx>ty\<^isub>i y"} implies @{text "x \<approx>bn\<^isub>i y"}
  1536   \noindent
  1536   \noindent
  1537   This can be established by induction on the definition of @{text "\<approx>ty\<^isub>i"}. 
  1537   This can be established by induction on the definition of @{text "\<approx>ty\<^isub>i"}. 
  1538    
  1538    
  1539   Having established respectfulness for every raw term-constructor, the 
  1539   Having established respectfulness for every raw term-constructor, the 
  1540   quotient package is able to automatically deduce \eqref{distinctalpha} from \eqref{distinctraw}.
  1540   quotient package is able to automatically deduce \eqref{distinctalpha} from \eqref{distinctraw}.
  1541   In fact we can from now on lift any fact from the raw level to the alpha-equated level that
  1541   In fact we can from now on lift facts from the raw level to the alpha-equated level
  1542   apart from variables only contains the raw term-constructors. The 
  1542   as long as they contain raw term-constructors only. The 
  1543   induction principles derived by the datatype package in Isabelle/HOL for teh types @{text
  1543   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
  1544   "ty"}$^\alpha_{1..n}$ fall into this category. So we can also add to our infrastructure
  1544   "ty\<AL>\<^bsub>1..n\<^esub>"} fall into this category. So we can also add to our infrastructure
  1545   induction principles that establish
  1545   induction principles that establish
  1546 
  1546 
  1547   \begin{center}
  1547   \begin{center}
  1548   @{text "P\<^bsub>ty\<^isub>1\<^esub> y\<^isub>1 \<dots> P\<^bsub>ty\<^isub>n\<^esub> y\<^isub>n "}
  1548   @{text "P\<^bsub>ty\<^isub>1\<^esub> y\<^isub>1 \<dots> P\<^bsub>ty\<^isub>n\<^esub> y\<^isub>n "}
  1549   \end{center} 
  1549   \end{center} 
  1550 
  1550 
  1551   \noindent
  1551   \noindent
  1552   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<^isub>i\<^esub>"} stand for properties
  1552   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<^isub>i\<^esub>"} stand for properties
  1553   defined over the types @{text "ty\<^isub>1\<^isup>\<alpha> \<dots> ty\<^isub>n\<^isup>\<alpha>"}. The premises of 
  1553   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
  1554   these induction principles look
  1554   these induction principles look
  1555   as follows
  1555   as follows
  1556 
  1556 
  1557   \begin{center}
  1557   \begin{center}
  1558   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<^isub>i\<^esub> x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<^isub>j\<^esub> x\<^isub>j \<Rightarrow> P\<^bsub>ty\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
  1558   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<^isub>i\<^esub> x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<^isub>j\<^esub> x\<^isub>j \<Rightarrow> P\<^bsub>ty\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
  1565   to the term-constructors, also permutations operations. In order to make the 
  1565   to the term-constructors, also permutations operations. In order to make the 
  1566   lifting to go through, 
  1566   lifting to go through, 
  1567   we have to know that the permutation operations are respectful 
  1567   we have to know that the permutation operations are respectful 
  1568   w.r.t.~alpha-equivalence. This amounts to showing that the 
  1568   w.r.t.~alpha-equivalence. This amounts to showing that the 
  1569   alpha-equivalence relations are equivariant, which we already established 
  1569   alpha-equivalence relations are equivariant, which we already established 
  1570   in Lemma~\ref{equiv}. As a result we can add the equations
  1570   in Lemma~\ref{equiv}. As a result we can establish the equations
  1571   
  1571   
  1572   \begin{equation}\label{ceqvt}
  1572   \begin{equation}\label{ceqvt}
  1573   @{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)"}
  1573   @{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)"}
  1574   \end{equation}
  1574   \end{equation}
  1575 
  1575 
  1576   \noindent
  1576   \noindent
  1577   to our infrastructure. In a similar fashion we can lift the equations
  1577   for our infrastructure. In a similar fashion we can lift the equations
  1578   characterising the free-variable functions @{text "fn_ty\<AL>\<^isub>j"} and the 
  1578   characterising the free-variable functions @{text "fn_ty\<AL>\<^isub>j"} and @{text "fv_bn\<AL>\<^isub>k"}, and the 
  1579   binding functions @{text "bn\<AL>\<^isub>k"}. The necessary respectfulness lemmas for this
  1579   binding functions @{text "bn\<AL>\<^isub>k"}. The necessary respectfulness lemmas for this
  1580   lifting are the two properties:
  1580   lifting are the properties:
  1581   %
  1581   %
  1582   \begin{equation}\label{fnresp}
  1582   \begin{equation}\label{fnresp}
  1583   \mbox{%
  1583   \mbox{%
  1584   \begin{tabular}{l}
  1584   \begin{tabular}{l}
  1585   @{text "x \<approx>ty\<^isub>j y"} implies @{text "fv_ty\<^isub>j x = fv_ty\<^isub>j y"}\\
  1585   @{text "x \<approx>ty\<^isub>j y"} implies @{text "fv_ty\<^isub>j x = fv_ty\<^isub>j y"}\\
  1586   @{text "x \<approx>ty\<^isub>j y"} implies @{text "bn\<^isub>k x = bn\<^isub>k y"}
  1586   @{text "x \<approx>ty\<^isub>k y"} implies @{text "fv_bn\<^isub>k x = fv_bn\<^isub>k y"}\\
       
  1587   @{text "x \<approx>ty\<^isub>k y"} implies @{text "bn\<^isub>k x = bn\<^isub>k y"}
  1587   \end{tabular}}
  1588   \end{tabular}}
  1588   \end{equation}
  1589   \end{equation}
  1589 
  1590 
  1590   \noindent
  1591   \noindent
  1591   which can be established by induction on @{text "\<approx>ty"}. Whereas the first
  1592   which can be established by induction on @{text "\<approx>ty"}. Whereas the first
  1592   property is always true by the way how we defined the free-variable
  1593   property is always true by the way how we defined the free-variable
  1593   functions, the second does \emph{not} hold in general. There is, in principle, 
  1594   functions for types, the second and third do \emph{not} hold in general. There is, in principle, 
  1594   the possibility that the user defines @{text "bn\<^isub>k"} so that it returns an already bound
  1595   the possibility that the user defines @{text "bn\<^isub>k"} so that it returns an already bound
  1595   variable. Then the second property is just not true. However, our 
  1596   variable. Then the third property is just not true. However, our 
  1596   restrictions imposed on the binding functions
  1597   restrictions imposed on the binding functions
  1597   exclude this possibility.
  1598   exclude this possibility.
  1598 
  1599 
  1599   Having the facts \eqref{fnresp} at our disposal, we can lift the
  1600   Having the facts \eqref{fnresp} at our disposal, we can lift the
  1600   definitions that characterise when two terms of the form
  1601   definitions that characterise when two terms of the form
  1611   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n = C\<^sup>\<alpha> y\<^isub>1 \<dots> y\<^isub>n"}
  1612   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n = C\<^sup>\<alpha> y\<^isub>1 \<dots> y\<^isub>n"}
  1612   \end{center}
  1613   \end{center}
  1613 
  1614 
  1614   \noindent
  1615   \noindent
  1615   We call these conditions as \emph{quasi-injectivity}. Except for one function, which
  1616   We call these conditions as \emph{quasi-injectivity}. Except for one function, which
  1616   we have to lift in the next section, this stage completes
  1617   we have to lift in the next section, we completed
  1617   the lifting part of establishing the reasoning infrastructure. From
  1618   the lifting part of establishing the reasoning infrastructure. 
  1618   now on, we can almost completely ``forget'' about the raw types @{text "ty\<^bsub>1..n\<^esub>"} and only
  1619 
  1619   reason about @{text "ty\<AL>\<^bsub>1..n\<^esub>"}.
  1620   Working bow completely on the alpha-equated level, we can first show that 
  1620 
  1621   the free-variable functions and binding functions
  1621   We can first show that the free-variable functions and binding functions
       
  1622   are equivariant, namely
  1622   are equivariant, namely
  1623 
  1623 
  1624   \begin{center}
  1624   \begin{center}
  1625   \begin{tabular}{rcl}
  1625   \begin{tabular}{rcl}
  1626   @{text "p \<bullet> (fv_ty\<^sup>\<alpha> x)"} & $=$ & @{text "fv_ty\<^sup>\<alpha> (p \<bullet> x)"}\\
  1626   @{text "p \<bullet> (fv_ty\<^sup>\<alpha> x)"} & $=$ & @{text "fv_ty\<^sup>\<alpha> (p \<bullet> x)"}\\
       
  1627   @{text "p \<bullet> (fv_bn\<^sup>\<alpha> x)"} & $=$ & @{text "fv_bn\<^sup>\<alpha> (p \<bullet> x)"}\\
  1627   @{text "p \<bullet> (bn\<^sup>\<alpha> x)"}    & $=$ & @{text "bn\<^sup>\<alpha> (p \<bullet> x)"}
  1628   @{text "p \<bullet> (bn\<^sup>\<alpha> x)"}    & $=$ & @{text "bn\<^sup>\<alpha> (p \<bullet> x)"}
  1628   \end{tabular}
  1629   \end{tabular}
  1629   \end{center}
  1630   \end{center}
  1630 
  1631 
  1631   \noindent
  1632   \noindent
  1632   These two properties can be established by structural induction over the @{text x}.
  1633   These properties can be established by structural induction over the @{text x}
  1633 
  1634   (using the induction principles we lifted above for the types @{text "ty\<AL>\<^bsub>1..n\<^esub>"}).
  1634   Until now we have not yet derived any fact about the support of the 
  1635 
  1635   alpha-equated terms. Using the equivariance properties in \eqref{ceqvt} we can
  1636   Until now we have not yet derived anything about the support of the 
       
  1637   alpha-equated terms. This however will be necessary in order to derive
       
  1638   the strong induction principles in the next section.
       
  1639   Using the equivariance properties in \eqref{ceqvt} we can
  1636   show for every term-constructor @{text "C\<^sup>\<alpha>"} that 
  1640   show for every term-constructor @{text "C\<^sup>\<alpha>"} that 
  1637 
  1641 
  1638   \begin{center}
  1642   \begin{center}
  1639   @{text "supp x\<^isub>1 \<union> \<dots> supp x\<^isub>n supports (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"}.
  1643   @{text "(supp x\<^isub>1 \<union> \<dots> supp x\<^isub>n) supports (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"}
  1640   \end{center}
  1644   \end{center}
  1641  
  1645  
  1642   \noindent
  1646   \noindent
  1643   This together with Property~\ref{supportsprop} allows us to show
  1647   holds. This together with Property~\ref{supportsprop} allows us to show
  1644  
  1648  
  1645 
       
  1646   \begin{center}
  1649   \begin{center}
  1647   @{text "finite (supp x\<^isub>i)"}
  1650   @{text "finite (supp x\<^isub>i)"}
  1648   \end{center}
  1651   \end{center}
  1649 
  1652 
  1650   \noindent
  1653   \noindent
  1658   \end{lemma}
  1661   \end{lemma}
  1659 
  1662 
  1660   \begin{proof}
  1663   \begin{proof}
  1661   The proof proceeds by structural induction over the @{text "x\<^isub>i"}. In each case
  1664   The proof proceeds by structural induction over the @{text "x\<^isub>i"}. In each case
  1662   we unfold the definition of @{text "supp"}, move the swapping inside the 
  1665   we unfold the definition of @{text "supp"}, move the swapping inside the 
  1663   term-constructors and the use the quasi-injectivity lemmas in order to complete the
  1666   term-constructors and the use then quasi-injectivity lemmas in order to complete the
  1664   proof.
  1667   proof. For the abstraction cases we use the facts derived in Theorem~\ref{suppabs}.
  1665   \end{proof}
  1668   \end{proof}
  1666 
  1669 
  1667   \noindent
  1670   \noindent
  1668   To sum up this section, we established a reasoning infrastructure
  1671   To sum up, we can established automatically a reasoning infrastructure
  1669   for the types @{text "ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"} 
  1672   for the types @{text "ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"} 
  1670   by first lifting definitions from the raw level to the quotient level and
  1673   by first lifting definitions from the raw level to the quotient level and
  1671   then establish facts about these lifted definitions. All necessary proofs
  1674   then establish facts about these lifted definitions. All necessary proofs
  1672   are generated automatically by custom ML-code we implemented. This code can deal with 
  1675   are generated automatically by custom ML-code. This code can deal with 
  1673   specifications like the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1676   specifications like the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1674 
  1677 
  1675   \begin{figure}[t!]
  1678   \begin{figure}[t!]
  1676   \begin{boxedminipage}{\linewidth}
  1679   \begin{boxedminipage}{\linewidth}
  1677   \small
  1680   \small
  1748 section {* Strong Induction Principles *}
  1751 section {* Strong Induction Principles *}
  1749 
  1752 
  1750 text {*
  1753 text {*
  1751   In the previous section we were able to provide induction principles that 
  1754   In the previous section we were able to provide induction principles that 
  1752   allow us to perform structural inductions over alpha-equated terms. 
  1755   allow us to perform structural inductions over alpha-equated terms. 
  1753   We call such induction principles \emph{weak}, because in case of a term-contructor @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n"},
  1756   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"},
  1754   the induction hypothesis requires us to establish the implication
  1757   the induction hypothesis requires us to establish the implication
  1755   %
  1758   %
  1756   \begin{equation}\label{weakprem}
  1759   \begin{equation}\label{weakprem}
  1757   @{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)"} 
  1760   @{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)"} 
  1758   \end{equation}
  1761   \end{equation}
  1759 
  1762 
  1760   \noindent
  1763   \noindent
  1761   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1764   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1762   The problem with this implication is that in general it is not easy to establish this
  1765   The problem with this implication is that in general it is not easy to establish it.
  1763   implication
       
  1764   The reason is we cannot make any assumption about the binders in @{text "C\<^sup>\<alpha>"} 
  1766   The reason is we cannot make any assumption about the binders in @{text "C\<^sup>\<alpha>"} 
  1765   (for example we cannot assume the variable convention).
  1767   (for example we cannot assume the variable convention for them).
  1766 
  1768 
  1767   In \cite{UrbanTasson05} we introduced a method for automatically
  1769   In \cite{UrbanTasson05} we introduced a method for automatically
  1768   strengthening weak induction principles for terms containing single
  1770   strengthening weak induction principles for terms containing single
  1769   binders. These stronger induction principles allow the user to make additional
  1771   binders. These stronger induction principles allow the user to make additional
  1770   assumptions about binders when proving the induction hypotheses. 
  1772   assumptions about binders when proving the induction hypotheses. 
  1771   These additional assumptions amount to a formal
  1773   These additional assumptions amount to a formal
  1772   version of the informal variable convention for binders. A natural question is
  1774   version of the informal variable convention for binders. A natural question is
  1773   whether we can also strengthen the weak induction principles involving
  1775   whether we can also strengthen the weak induction principles involving
  1774   general binders. We will indeed be able to so, but for this we need an 
  1776   general binders. We will indeed be able to so, but for this we need an 
  1775   additional notion of permuting deep binders. 
  1777   additional notion for permuting deep binders. 
  1776 
  1778 
  1777   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1779   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1778   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1780   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1779   Given a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1781   Assuming a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1780   %
  1782   we define  %
  1781   \begin{center}
  1783   \begin{center}
  1782   @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>n) \<equiv> C y\<^isub>1 \<dots> y\<^isub>n"}
  1784   @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>n) \<equiv> C y\<^isub>1 \<dots> y\<^isub>n"}
  1783   \end{center}
  1785   \end{center}
  1784 
  1786 
  1785   \noindent
  1787   \noindent
  1793   \end{tabular}
  1795   \end{tabular}
  1794   \end{center}
  1796   \end{center}
  1795   
  1797   
  1796   \noindent
  1798   \noindent
  1797   Using the quotient package again we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1799   Using the quotient package again we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1798   alpha-equated terms. We can then prove:
  1800   alpha-equated terms. We can then prove the following two facts
  1799 
  1801 
  1800   \begin{lemma} Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1802   \begin{lemma}\label{permutebn} 
       
  1803   Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1801   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"} and {\it ii)}
  1804   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"} and {\it ii)}
  1802     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"}.
  1805     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"}.
  1803   \end{lemma}
  1806   \end{lemma}
  1804 
  1807 
  1805   \begin{proof} 
  1808   \begin{proof} 
  1812   equivalent to first permuting the binders and then calculating the bound
  1815   equivalent to first permuting the binders and then calculating the bound
  1813   variables. The second amounts to the fact that permuting the binders has no 
  1816   variables. The second amounts to the fact that permuting the binders has no 
  1814   effect on the free-variable function. The main point of this permutation
  1817   effect on the free-variable function. The main point of this permutation
  1815   function, however, is that if we have a permutation that is fresh 
  1818   function, however, is that if we have a permutation that is fresh 
  1816   for the support of an object @{text x}, then we can use this permutation 
  1819   for the support of an object @{text x}, then we can use this permutation 
  1817   to rename the binders, without ``changing'' the term. In case of the 
  1820   to rename the binders in @{text x}, without ``changing'' @{text x}. In case of the 
  1818   @{text "Let"} term-constructor from the example shown 
  1821   @{text "Let"} term-constructor from the example shown 
  1819   in \eqref{letpat} this means:
  1822   \eqref{letpat} this means for a permutation @{text "r"}:
  1820 
  1823   %
  1821   \begin{center}
  1824   \begin{equation}\label{renaming}
  1822   if @{term "supp (Abs_lst (bn p) t)  \<sharp>* q"} then @{text "Let p t = Let (q \<bullet>\<^bsub>bn\<^bsub>pat\<^esub>\<^esub> p) (q \<bullet> t)"}
  1825   \mbox{if @{term "supp (Abs_lst (bn p) t)  \<sharp>* r"} 
  1823   \end{center}
  1826   then @{text "Let p t = Let (r \<bullet>\<^bsub>bn\<^bsub>pat\<^esub>\<^esub> p) (r \<bullet> t)"}}
       
  1827   \end{equation}
  1824 
  1828 
  1825   \noindent
  1829   \noindent
  1826   This fact will be used when establishing the strong induction principles. 
  1830   This fact will be used when establishing the strong induction principles. 
  1827   They state that instead of establishing the implication 
  1831   
  1828 
  1832 
  1829   \begin{center}
  1833   In our running example about @{text "Let"}, they state that instead 
  1830   @{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)"}
  1834   of establishing the implication 
       
  1835 
       
  1836   \begin{center}
       
  1837   @{text "\<forall>p t. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t)"}
  1831   \end{center}
  1838   \end{center}
  1832 
  1839 
  1833   \noindent
  1840   \noindent
  1834   it is sufficient to establish the following implication
  1841   it is sufficient to establish the following implication
  1835   
  1842   %
  1836   \begin{center}
  1843   \begin{equation}\label{strong}
  1837   \begin{tabular}{l}
  1844   \mbox{\begin{tabular}{l}
  1838   @{text "\<forall>p t\<^isub>1 t\<^isub>2 c."}\\
  1845   @{text "\<forall>p t c."}\\
  1839   \hspace{5mm}@{text "set (bn\<^sup>\<alpha> p) #\<^sup>* c \<and>"}\\
  1846   \hspace{5mm}@{text "set (bn p) #\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t)"}\\
  1840   \hspace{5mm}@{text "(\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>2)"}\\
  1847   \hspace{15mm}@{text "\<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t)"}
  1841   \hspace{15mm}@{text "\<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t\<^isub>1 t\<^isub>2)"}
  1848   \end{tabular}}
       
  1849   \end{equation}
       
  1850 
       
  1851   \noindent 
       
  1852   While this implication contains an additional argument, namely @{text c}, and 
       
  1853   also additional universal quantifications, it is usually easier to establish.
       
  1854   The reason is that we can make the freshness 
       
  1855   assumption @{text "set (bn\<^sup>\<alpha> p) #\<^sup>* c"}, whereby @{text c} can be arbitrarily 
       
  1856   chosen by the user as long as it has finite support.
       
  1857 
       
  1858   Let us now show how we derive the strong induction principles from the
       
  1859   weak ones. In case of the @{text "Let"}-example we derive by the weak 
       
  1860   induction the following two properties
       
  1861   %
       
  1862   \begin{equation}\label{hyps}
       
  1863   @{text "\<forall>q c. P\<^bsub>trm\<^esub> c (q \<bullet> t)"} \hspace{4mm} 
       
  1864   @{text "\<forall>q\<^isub>1 q\<^isub>2 c. P\<^bsub>pat\<^esub> (q\<^isub>1 \<bullet>\<^bsub>bn\<^esub> (q\<^isub>2 \<bullet> p))"}
       
  1865   \end{equation} 
       
  1866 
       
  1867   \noindent
       
  1868   For the @{text Let} term-constructor  we therefore have to establish @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t)"} 
       
  1869   assuming \eqref{hyps} as induction hypotheses. By Property~\ref{avoiding} we
       
  1870   obtain a permutation @{text "r"} such that 
       
  1871   %
       
  1872   \begin{equation}\label{rprops}
       
  1873   @{term "(r \<bullet> set (bn (q \<bullet> p))) \<sharp>* c "}\hspace{4mm}
       
  1874   @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t)) \<sharp>* r"}
       
  1875   \end{equation}
       
  1876 
       
  1877   \noindent
       
  1878   hold. The latter fact and \eqref{renaming} give us
       
  1879 
       
  1880   \begin{center}
       
  1881   @{text "Let (q \<bullet> p) (q \<bullet> t) = Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (r \<bullet> (q \<bullet> t))"}
       
  1882   \end{center}
       
  1883 
       
  1884   \noindent
       
  1885   So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t)"}, we are can equally
       
  1886   establish
       
  1887 
       
  1888   \begin{center}
       
  1889   @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (r \<bullet> (q \<bullet> t)))"}
       
  1890   \end{center}
       
  1891 
       
  1892   \noindent
       
  1893   To do so, we will use the implication \eqref{strong} of the strong induction
       
  1894   principle, which requires us to discharge
       
  1895   the following three proof obligations:
       
  1896 
       
  1897   \begin{center}
       
  1898   \begin{tabular}{rl}
       
  1899   {\it i)} &   @{text "set (bn (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\
       
  1900   {\it ii)} &  @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\
       
  1901   {\it iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (r \<bullet> (q \<bullet> t))"}\\
  1842   \end{tabular}
  1902   \end{tabular}
  1843   \end{center}
  1903   \end{center}
  1844 
  1904 
  1845   \noindent 
  1905   \noindent
  1846   While this implication contains an additional argument, @{text c}, and 
  1906   The first follows from \eqref{rprops} and Lemma~\ref{permutebn}.{\it i)}; the 
  1847   also additional universal quantifications, it is usually easier to establish.
  1907   second and third from the induction hypotheses in \eqref{hyps} (in the latter case
  1848   The reason is that in the case of @{text "Let"} we can make the freshness 
  1908   we have to use the fact that @{term "(r \<bullet> (q \<bullet> t)) = (r + q) \<bullet> t"}).
  1849   assumption @{text "set (bn\<^sup>\<alpha> p) #\<^sup>* c"}, wherby @{text c} can be arbitrarily 
  1909 
  1850   chosen by the user as long as it has finite support.
  1910   Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps},
  1851 
  1911   we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}.
  1852   With the help of @{text "\<bullet>bn"} functions defined in the previous section
  1912   This completes the proof showing that the strong induction principle derives from
  1853   we can show that binders can be substituted in term constructors. We show
  1913   the weak induction principle. At the moment we can derive the difficult cases of 
  1854   this only for the specification from Figure~\ref{nominalcorehas}. The only
  1914   the strong induction principles only by hand, but they are very schematically 
  1855   constructor with a complicated binding structure is @{text "ACons"}. For this
  1915   so that with little effort we can even derive the strong induction principle for 
  1856   constructor we prove:
  1916   Core-Haskell given in Figure~\ref{nominalcorehas}. 
  1857   \begin{eqnarray}
       
  1858   \lefteqn{@{text "supp (Abs_lst (bv pat) trm) \<sharp>* \<pi> \<Longrightarrow>"}} \nonumber \\
       
  1859   & & @{text "ACons pat trm al = ACons (\<pi> \<bullet>bv pat) (\<pi> \<bullet> trm) al"} \nonumber
       
  1860   \end{eqnarray}
       
  1861 
       
  1862   \noindent With the Property~\ref{avoiding} we can prove a strong induction principle
       
  1863   which we show again only for the interesting constructors in the Core Haskell
       
  1864   example. We first show the weak induction principle for comparison:
       
  1865 
       
  1866 \begin{equation}\nonumber
       
  1867 \infer
       
  1868 {
       
  1869   \textrm{The properties }@{text "P1, P2, \<dots>, P12"}\textrm{ hold for all }@{text "tkind, ckind, \<dots>"}
       
  1870 }{
       
  1871   \begin{tabular}{cp{7cm}}
       
  1872 %%  @{text "P1 KStar"}\\
       
  1873 %%  @{text "\<forall>tk1 tk2. \<^raw:\big(>P1 tk1 \<and> P1 tk2\<^raw:\big)> \<Longrightarrow> P1 (KFun tk1 tk2)"}\\
       
  1874 %%  @{text "\<dots>"}\\
       
  1875   @{text "\<forall>v ty t1 t2. \<^raw:\big(>P3 ty \<and> P7 t1 \<and> P7 t2\<^raw:\big)> \<Longrightarrow> P7 (Let v ty t1 t2)"}\\
       
  1876   @{text "\<forall>p t al. \<^raw:\big(>P9 p \<and> P7 t \<and> P8 al\<^raw:\big)> \<Longrightarrow> P8 (ACons p t al)"}\\
       
  1877   @{text "\<dots>"}
       
  1878   \end{tabular}
       
  1879 }
       
  1880 \end{equation}
       
  1881 
       
  1882 
       
  1883   \noindent In comparison, the cases for the same constructors in the derived strong
       
  1884   induction principle are:
       
  1885 
       
  1886 \begin{equation}\nonumber
       
  1887 \infer
       
  1888 {
       
  1889   \begin{tabular}{cp{7cm}}
       
  1890   \textrm{The properties }@{text "P1, P2, \<dots>, P12"}\textrm{ hold for all }@{text "tkind, ckind, \<dots>"}\\
       
  1891   \textrm{ avoiding any atoms in a given }@{text "y"}
       
  1892   \end{tabular}
       
  1893 }{
       
  1894   \begin{tabular}{cp{7cm}}
       
  1895 %%  @{text "\<forall>b. P1 b KStar"}\\
       
  1896 %%  @{text "\<forall>tk1 tk2 b. \<^raw:\big(>\<forall>c. P1 c tk1 \<and> \<forall>c. P1 c tk2\<^raw:\big)> \<Longrightarrow> P1 b (KFun tk1 tk2)"}\\
       
  1897 %%  @{text "\<dots>"}\\
       
  1898   @{text "\<forall>v ty t1 t2 b. \<^raw:\big(>\<forall>c. P3 c ty \<and> \<forall>c. P7 c t1 \<and> \<forall>c. P7 c t2 \<and>"}\\
       
  1899   @{text "\<^raw:\hfill>\<and> atom var \<sharp> b\<^raw:\big)> \<Longrightarrow> P7 b (Let v ty t1 t2)"}\\
       
  1900   @{text "\<forall>p t al b. \<^raw:\big(>\<forall>c. P9 c p \<and> \<forall>c. P7 c t \<and> \<forall>c. P8 c al \<and>"}\\
       
  1901   @{text "\<^raw:\hfill>\<and> set (bv p) \<sharp>* b\<^raw:\big)> \<Longrightarrow> P8 b (ACons p t al)"}\\
       
  1902   @{text "\<dots>"}
       
  1903   \end{tabular}
       
  1904 }
       
  1905 \end{equation}
       
  1906 
       
  1907 *}
  1917 *}
  1908 
  1918 
  1909 
  1919 
  1910 section {* Related Work *}
  1920 section {* Related Work *}
  1911 
  1921