Paper/Paper.thy
changeset 1890 23e3dc4f2c59
parent 1859 900ef226973e
child 1926 e42bd9d95f09
equal deleted inserted replaced
1885:edf10db61708 1890:23e3dc4f2c59
   439   in which the generic type @{text "\<beta>"} stands for the type of the object 
   439   in which the generic type @{text "\<beta>"} stands for the type of the object 
   440   over which the permutation 
   440   over which the permutation 
   441   acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"},
   441   acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"},
   442   the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, 
   442   the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, 
   443   and the inverse permutation of @{term p} as @{text "- p"}. The permutation
   443   and the inverse permutation of @{term p} as @{text "- p"}. The permutation
   444   operation is defined by induction over the type-hierarchy (see \cite{HuffmanUrban10});
   444   operation is defined by induction over the type-hierarchy \cite{HuffmanUrban10};
   445   for example permutations acting on products, lists, sets, functions and booleans is
   445   for example permutations acting on products, lists, sets, functions and booleans is
   446   given by:
   446   given by:
   447   %
   447   %
   448   \begin{equation}\label{permute}
   448   \begin{equation}\label{permute}
   449   \mbox{\begin{tabular}{@ {}cc@ {}}
   449   \mbox{\begin{tabular}{@ {}cc@ {}}
   612   first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}.  These pairs
   612   first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}.  These pairs
   613   are intended to represent the abstraction, or binding, of the set @{text
   613   are intended to represent the abstraction, or binding, of the set @{text
   614   "as"} in the body @{text "x"}.
   614   "as"} in the body @{text "x"}.
   615 
   615 
   616   The first question we have to answer is when two pairs @{text "(as, x)"} and
   616   The first question we have to answer is when two pairs @{text "(as, x)"} and
   617   @{text "(bs, y)"} are alpha-equivalent? (At the moment we are interested in
   617   @{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in
   618   the notion of alpha-equivalence that is \emph{not} preserved by adding
   618   the notion of alpha-equivalence that is \emph{not} preserved by adding
   619   vacuous binders.) To answer this, we identify four conditions: {\it i)}
   619   vacuous binders.) To answer this, we identify four conditions: {\it i)}
   620   given a free-variable function @{text "fv"} of type \mbox{@{text "\<beta> \<Rightarrow> atom
   620   given a free-variable function @{text "fv"} of type \mbox{@{text "\<beta> \<Rightarrow> atom
   621   set"}}, then @{text x} and @{text y} need to have the same set of free
   621   set"}}, then @{text x} and @{text y} need to have the same set of free
   622   variables; moreover there must be a permutation @{text p} such that {\it
   622   variables; moreover there must be a permutation @{text p} such that {\it
   678   \wedge     & @{text "(p \<bullet> x) R y"}\\
   678   \wedge     & @{text "(p \<bullet> x) R y"}\\
   679   \end{array}
   679   \end{array}
   680   \end{equation}
   680   \end{equation}
   681 
   681 
   682   It might be useful to consider some examples for how these definitions of alpha-equivalence
   682   It might be useful to consider some examples for how these definitions of alpha-equivalence
   683   pan out in practise.
   683   pan out in practice.
   684   For this consider the case of abstracting a set of variables over types (as in type-schemes). 
   684   For this consider the case of abstracting a set of variables over types (as in type-schemes). 
   685   We set @{text R} to be the equality and for @{text "fv(T)"} we define
   685   We set @{text R} to be the equality and for @{text "fv(T)"} we define
   686 
   686 
   687   \begin{center}
   687   \begin{center}
   688   @{text "fv(x) = {x}"}  \hspace{5mm} @{text "fv(T\<^isub>1 \<rightarrow> T\<^isub>2) = fv(T\<^isub>1) \<union> fv(T\<^isub>2)"}
   688   @{text "fv(x) = {x}"}  \hspace{5mm} @{text "fv(T\<^isub>1 \<rightarrow> T\<^isub>2) = fv(T\<^isub>1) \<union> fv(T\<^isub>2)"}
   782   \begin{thm}[Support of Abstractions]\label{suppabs} 
   782   \begin{thm}[Support of Abstractions]\label{suppabs} 
   783   Assuming @{text x} has finite support, then\\[-6mm] 
   783   Assuming @{text x} has finite support, then\\[-6mm] 
   784   \begin{center}
   784   \begin{center}
   785   \begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
   785   \begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
   786   @{thm (lhs) supp_abs(1)[no_vars]} & $=$ & @{thm (rhs) supp_abs(1)[no_vars]}\\
   786   @{thm (lhs) supp_abs(1)[no_vars]} & $=$ & @{thm (rhs) supp_abs(1)[no_vars]}\\
   787   @{thm (lhs) supp_abs(2)[no_vars]} & $=$ & @{thm (rhs) supp_abs(2)[no_vars]}\\
   787   @{thm (lhs) supp_abs(3)[where bs="as", no_vars]} & $=$ & @{thm (rhs) supp_abs(3)[where bs="as", no_vars]}\\
   788   @{thm (lhs) supp_abs(3)[where bs="as", no_vars]} & $=$ & @{thm (rhs) supp_abs(3)[where bs="as", no_vars]}
   788   @{thm (lhs) supp_abs(2)[no_vars]} & $=$ & @{thm (rhs) supp_abs(2)[no_vars]}
   789   \end{tabular}
   789   \end{tabular}
   790   \end{center}
   790   \end{center}
   791   \end{thm}
   791   \end{thm}
   792 
   792 
   793   \noindent
   793   \noindent
   807   @{thm permute_Abs[no_vars]}
   807   @{thm permute_Abs[no_vars]}
   808   \end{equation}
   808   \end{equation}
   809 
   809 
   810   \noindent
   810   \noindent
   811   The second fact derives from the definition of permutations acting on pairs 
   811   The second fact derives from the definition of permutations acting on pairs 
   812   (see \eqref{permute}) and alpha-equivalence being equivariant 
   812   \eqref{permute} and alpha-equivalence being equivariant 
   813   (see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   813   (see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   814   the following lemma about swapping two atoms.
   814   the following lemma about swapping two atoms.
   815   
   815   
   816   \begin{lemma}
   816   \begin{lemma}
   817   @{thm[mode=IfThen] abs_swap1(1)[where bs="as", no_vars]}
   817   @{thm[mode=IfThen] abs_swap1(1)[where bs="as", no_vars]}
  1256     @{term "x\<^isub>i"} and @{term "x\<^isub>i"} is of atom type.
  1256     @{term "x\<^isub>i"} and @{term "x\<^isub>i"} is of atom type.
  1257   \end{tabular}
  1257   \end{tabular}
  1258   \end{center}
  1258   \end{center}
  1259 
  1259 
  1260   \noindent
  1260   \noindent
  1261   To see how these definitions work in practise, let us reconsider the term-constructors 
  1261   To see how these definitions work in practice, let us reconsider the term-constructors 
  1262   @{text "Let"} and @{text "Let_rec"} from the example shown in \eqref{letrecs}. 
  1262   @{text "Let"} and @{text "Let_rec"} from the example shown in \eqref{letrecs}. 
  1263   For this specification we need to define three free-variable functions, namely
  1263   For this specification we need to define three free-variable functions, namely
  1264   @{text "fv\<^bsub>trm\<^esub>"}, @{text "fv\<^bsub>assn\<^esub>"} and @{text "fv\<^bsub>bn\<^esub>"}. They are as follows:
  1264   @{text "fv\<^bsub>trm\<^esub>"}, @{text "fv\<^bsub>assn\<^esub>"} and @{text "fv\<^bsub>bn\<^esub>"}. They are as follows:
  1265   %
  1265   %
  1266   \begin{center}
  1266   \begin{center}
  1735   $|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\
  1735   $|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\
  1736   $|$~@{text "bv3 TVCKNil = []"}\\
  1736   $|$~@{text "bv3 TVCKNil = []"}\\
  1737   $|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\
  1737   $|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\
  1738   \end{tabular}
  1738   \end{tabular}
  1739   \end{boxedminipage}
  1739   \end{boxedminipage}
  1740   \caption{The nominal datatype declaration for Core-Haskell. At the moment we
  1740   \caption{The nominal datatype declaration for Core-Haskell. For the moment we
  1741   do not support nested types; therefore we explicitly have to unfold the 
  1741   do not support nested types; therefore we explicitly have to unfold the 
  1742   lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved
  1742   lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved
  1743   in a future version of Nominal Isabelle. Apart from that, the 
  1743   in a future version of Nominal Isabelle. Apart from that, the 
  1744   declaration follows closely the original in Figure~\ref{corehas}. The
  1744   declaration follows closely the original in Figure~\ref{corehas}. The
  1745   point of our work is that having made such a declaration in Nominal Isabelle,
  1745   point of our work is that having made such a declaration in Nominal Isabelle,
  1915   we have to use the fact that @{term "(r \<bullet> (q \<bullet> t\<^isub>2)) = (r + q) \<bullet> t\<^isub>2"}).
  1915   we have to use the fact that @{term "(r \<bullet> (q \<bullet> t\<^isub>2)) = (r + q) \<bullet> t\<^isub>2"}).
  1916 
  1916 
  1917   Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps},
  1917   Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps},
  1918   we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}.
  1918   we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}.
  1919   This completes the proof showing that the strong induction principle derives from
  1919   This completes the proof showing that the strong induction principle derives from
  1920   the weak induction principle. At the moment we can derive the difficult cases of 
  1920   the weak induction principle. For the moment we can derive the difficult cases of 
  1921   the strong induction principles only by hand, but they are very schematically 
  1921   the strong induction principles only by hand, but they are very schematically 
  1922   so that with little effort we can even derive them for 
  1922   so that with little effort we can even derive them for 
  1923   Core-Haskell given in Figure~\ref{nominalcorehas}. 
  1923   Core-Haskell given in Figure~\ref{nominalcorehas}. 
  1924 *}
  1924 *}
  1925 
  1925 
  2002   automatically a convenient reasoning infrastructure that can deal with
  2002   automatically a convenient reasoning infrastructure that can deal with
  2003   general binders, that is term-constructors binding multiple variables at
  2003   general binders, that is term-constructors binding multiple variables at
  2004   once. This extension has been tried out with the Core-Haskell
  2004   once. This extension has been tried out with the Core-Haskell
  2005   term-calculus. For such general binders, we can also extend
  2005   term-calculus. For such general binders, we can also extend
  2006   earlier work that derives strong induction principles which have the usual
  2006   earlier work that derives strong induction principles which have the usual
  2007   variable convention already built in. At the moment we can do so only with manual help,
  2007   variable convention already built in. For the moment we can do so only with manual help,
  2008   but future work will automate them completely.  The code underlying the presented
  2008   but future work will automate them completely.  The code underlying the presented
  2009   extension will become part of the Isabelle distribution, but for the moment
  2009   extension will become part of the Isabelle distribution, but for the moment
  2010   it can be downloaded from the Mercurial repository linked at
  2010   it can be downloaded from the Mercurial repository linked at
  2011   \href{http://isabelle.in.tum.de/nominal/download}
  2011   \href{http://isabelle.in.tum.de/nominal/download}
  2012   {http://isabelle.in.tum.de/nominal/download}.
  2012   {http://isabelle.in.tum.de/nominal/download}.