Paper/Paper.thy
changeset 2134 4648bd6930e4
parent 2128 abd46dfc0212
child 2139 dff8bd922812
equal deleted inserted replaced
2132:d74e08799b63 2134:4648bd6930e4
   937   \emph{one} binding clause of a term constructor. 
   937   \emph{one} binding clause of a term constructor. 
   938 
   938 
   939   For binders we distinguish between \emph{shallow} and \emph{deep} binders.
   939   For binders we distinguish between \emph{shallow} and \emph{deep} binders.
   940   Shallow binders are of the form \isacommand{bind}\; {\it labels}\;
   940   Shallow binders are of the form \isacommand{bind}\; {\it labels}\;
   941   \isacommand{in}\; {\it labels'} (similar for the other two modes). The
   941   \isacommand{in}\; {\it labels'} (similar for the other two modes). The
   942   restriction we impose on shallow binders is that in case of
   942   restrictions we impose on shallow binders are that in case of
   943   \isacommand{bind\_set} and \isacommand{bind\_res} the {\it labels} must
   943   \isacommand{bind\_set} and \isacommand{bind\_res} the {\it labels} must
   944   either refer to atom types or to sets of atom types; in case of
   944   either refer to atom types or to sets of atom types; in case of
   945   \isacommand{bind} we allow labels to refer to atom types or lists of atom types. Two
   945   \isacommand{bind} we allow labels to refer to atom types or lists of atom types. 
   946   examples for the use of shallow binders are the specification of
   946   Two examples for the use of shallow binders are the specification of
   947   lambda-terms, where a single name is bound, and type-schemes, where a finite
   947   lambda-terms, where a single name is bound, and type-schemes, where a finite
   948   set of names is bound:
   948   set of names is bound:
   949 
   949 
   950   \begin{center}
   950   \begin{center}
   951   \begin{tabular}{@ {}cc@ {}}
   951   \begin{tabular}{@ {}cc@ {}}
   965   \end{tabular}
   965   \end{tabular}
   966   \end{tabular}
   966   \end{tabular}
   967   \end{center}
   967   \end{center}
   968 
   968 
   969   \noindent
   969   \noindent
   970   Note that for @{text lam} we have a choice which mode we use. The reason is that 
   970   Note that for @{text lam} it does not matter which binding mode we use. The reason is that 
   971   we bind only a single @{text name}. Having \isacommand{bind\_set} in the second
   971   we bind only a single @{text name}. However, having \isacommand{bind\_set}, or even 
       
   972   \isacommand{bind}, in the second
   972   case changes the semantics of the specification. 
   973   case changes the semantics of the specification. 
   973   Note also that in these specifications @{text "name"} refers to an atom type, and
   974   Note also that in these specifications @{text "name"} refers to an atom type, and
   974   @{text "fset"} to the type of finite sets. 
   975   @{text "fset"} to the type of finite sets. 
   975 
   976 
   976   The restrictions are as follows:
   977   A \emph{deep} binder uses an auxiliary binding function that ``picks'' out
   977   Shallow binders can occur in the binding part of several binding clauses. 
       
   978   A \emph{deep} binder, on the other hand, uses an auxiliary binding function that ``picks'' out
       
   979   the atoms in one argument of the term-constructor, which can be bound in  
   978   the atoms in one argument of the term-constructor, which can be bound in  
   980   other arguments and also in the same argument (we will
   979   other arguments and also in the same argument (we will
   981   call such binders \emph{recursive}, see below). 
   980   call such binders \emph{recursive}, see below). 
   982   The corresponding binding functions are expected to return either a set of atoms
   981   The corresponding binding functions are expected to return either a set of atoms
   983   (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms
   982   (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms
  1009   
  1008   
  1010   \noindent
  1009   \noindent
  1011   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1010   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1012   bound in the argument @{text "t"}. Note that in the second-last @{text bn}-clause the 
  1011   bound in the argument @{text "t"}. Note that in the second-last @{text bn}-clause the 
  1013   function @{text "atom"}
  1012   function @{text "atom"}
  1014   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows
  1013   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. 
       
  1014   This allows
  1015   us to treat binders of different atom type uniformly. 
  1015   us to treat binders of different atom type uniformly. 
  1016 
  1016 
  1017   The most drastic restriction we have to impose on deep binders is that 
  1017   The most drastic restriction we have to impose on deep binders is that 
  1018   we cannot have ``overlapping'' deep binders. Consider for example the 
  1018   we cannot have more than one binding function for one binder. Consider for example the 
  1019   term-constructors:
  1019   term-constructors:
  1020 
  1020 
  1021   \begin{center}
  1021   \begin{center}
  1022   \begin{tabular}{ll}
  1022   \begin{tabular}{ll}
  1023   @{text "Foo\<^isub>1 p::pat q::pat t::trm"} & 
  1023   @{text "Foo\<^isub>1 p::pat q::pat t::trm"} & 
  1538   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
  1538   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
  1539   "ty\<^bsub>1..n\<^esub>"} fall into this category. So we can also add to our infrastructure
  1539   "ty\<^bsub>1..n\<^esub>"} fall into this category. So we can also add to our infrastructure
  1540   induction principles that establish
  1540   induction principles that establish
  1541 
  1541 
  1542   \begin{center}
  1542   \begin{center}
  1543   @{text "P\<^bsub>ty\<AL>\<^isub>1\<^esub> y\<^isub>1 \<dots> P\<^bsub>ty\<AL>\<^isub>n\<^esub> y\<^isub>n "}
  1543   @{text "P\<^bsub>ty\<AL>\<^esub>\<^isub>1 y\<^isub>1 \<dots> P\<^bsub>ty\<AL>\<^esub>\<^isub>n y\<^isub>n "}
  1544   \end{center} 
  1544   \end{center} 
  1545 
  1545 
  1546   \noindent
  1546   \noindent
  1547   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<AL>\<^isub>i\<^esub>"} stand for properties
  1547   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<AL>\<^esub>\<^isub>i"} stand for properties
  1548   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
  1548   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
  1549   these induction principles look
  1549   these induction principles look
  1550   as follows
  1550   as follows
  1551 
  1551 
  1552   \begin{center}
  1552   \begin{center}
  1553   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<AL>\<^isub>i\<^esub> x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<AL>\<^isub>j\<^esub> x\<^isub>j \<Rightarrow> P\<^bsub>ty\<AL>\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
  1553   @{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)"} 
  1554   \end{center}
  1554   \end{center}
  1555 
  1555 
  1556   \noindent
  1556   \noindent
  1557   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1557   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1558   Next we lift the permutation operations defined in \eqref{ceqvt} for
  1558   Next we lift the permutation operations defined in \eqref{ceqvt} for
  1794   Using again the quotient package  we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1794   Using again the quotient package  we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1795   alpha-equated terms. We can then prove the following two facts
  1795   alpha-equated terms. We can then prove the following two facts
  1796 
  1796 
  1797   \begin{lemma}\label{permutebn} 
  1797   \begin{lemma}\label{permutebn} 
  1798   Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1798   Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1799   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"} and {\it ii)}
  1799   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^esub>\<^sup>\<alpha> x)"} and {\it ii)}
  1800     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"}.
  1800     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^esub>\<^sup>\<alpha> x)"}.
  1801   \end{lemma}
  1801   \end{lemma}
  1802 
  1802 
  1803   \begin{proof} 
  1803   \begin{proof} 
  1804   By induction on @{text x}. The equations follow by simple unfolding 
  1804   By induction on @{text x}. The equations follow by simple unfolding 
  1805   of the definitions. 
  1805   of the definitions. 
  1817   \eqref{letpat} this means for a permutation @{text "r"}:
  1817   \eqref{letpat} this means for a permutation @{text "r"}:
  1818   %
  1818   %
  1819   \begin{equation}\label{renaming}
  1819   \begin{equation}\label{renaming}
  1820   \begin{array}{l}
  1820   \begin{array}{l}
  1821   \mbox{if @{term "supp (Abs_lst (bn p) t\<^isub>2)  \<sharp>* r"}}\\ 
  1821   \mbox{if @{term "supp (Abs_lst (bn p) t\<^isub>2)  \<sharp>* r"}}\\ 
  1822   \qquad\mbox{then @{text "Let p t\<^isub>1 t\<^isub>2 = Let (r \<bullet>\<^bsub>bn\<^bsub>pat\<^esub>\<^esub> p) t\<^isub>1 (r \<bullet> t\<^isub>2)"}}
  1822   \qquad\mbox{then @{text "Let p t\<^isub>1 t\<^isub>2 = Let (r \<bullet>\<^bsub>bnpat\<^esub> p) t\<^isub>1 (r \<bullet> t\<^isub>2)"}}
  1823   \end{array}
  1823   \end{array}
  1824   \end{equation}
  1824   \end{equation}
  1825 
  1825 
  1826   \noindent
  1826   \noindent
  1827   This fact will be crucial when establishing the strong induction principles. 
  1827   This fact will be crucial when establishing the strong induction principles.