Paper/Paper.thy
changeset 2128 abd46dfc0212
parent 1961 774d631726ad
child 2134 4648bd6930e4
equal deleted inserted replaced
2127:fc42d4a06c06 2128:abd46dfc0212
   342   For example, we will not be able to lift a bound-variable function. Although
   342   For example, we will not be able to lift a bound-variable function. Although
   343   this function can be defined for raw terms, it does not respect
   343   this function can be defined for raw terms, it does not respect
   344   alpha-equivalence and therefore cannot be lifted. To sum up, every lifting
   344   alpha-equivalence and therefore cannot be lifted. To sum up, every lifting
   345   of theorems to the quotient level needs proofs of some respectfulness
   345   of theorems to the quotient level needs proofs of some respectfulness
   346   properties (see \cite{Homeier05}). In the paper we show that we are able to
   346   properties (see \cite{Homeier05}). In the paper we show that we are able to
   347   automate these proofs and therefore can establish a reasoning infrastructure
   347   automate these proofs and as a result can automatically establish a reasoning 
   348   for alpha-equated terms.
   348   infrastructure for alpha-equated terms.
   349 
   349 
   350   The examples we have in mind where our reasoning infrastructure will be
   350   The examples we have in mind where our reasoning infrastructure will be
   351   helpful includes the term language of System @{text "F\<^isub>C"}, also
   351   helpful includes the term language of System @{text "F\<^isub>C"}, also
   352   known as Core-Haskell (see Figure~\ref{corehas}). This term language
   352   known as Core-Haskell (see Figure~\ref{corehas}). This term language
   353   involves patterns that have lists of type-, coercion- and term-variables,
   353   involves patterns that have lists of type-, coercion- and term-variables,
   561   %
   561   %
   562   \begin{center}
   562   \begin{center}
   563   @{text "x R y"} \;\;implies\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
   563   @{text "x R y"} \;\;implies\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
   564   \end{center}
   564   \end{center}
   565 
   565 
   566   Finally, the nominal logic work provides us with convenient means to rename 
   566   Finally, the nominal logic work provides us with general means to rename 
   567   binders. While in the older version of Nominal Isabelle, we used extensively 
   567   binders. While in the older version of Nominal Isabelle, we used extensively 
   568   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   568   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   569   proved unwieldy for dealing with multiple binders. For such binders the 
   569   proved unwieldy for dealing with multiple binders. For such binders the 
   570   following generalisations turned out to be easier to use.
   570   following generalisations turned out to be easier to use.
   571 
   571 
   588   as long as it is finitely supported) and also @{text "p"} does not affect anything
   588   as long as it is finitely supported) and also @{text "p"} does not affect anything
   589   in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last 
   589   in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last 
   590   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   590   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   591   @{text as} in @{text x}, because @{term "p \<bullet> x = x"}.
   591   @{text as} in @{text x}, because @{term "p \<bullet> x = x"}.
   592 
   592 
   593   Most properties given in this section are described in \cite{HuffmanUrban10}
   593   Most properties given in this section are described in detail in \cite{HuffmanUrban10}
   594   and of course all are formalised in Isabelle/HOL. In the next sections we will make 
   594   and of course all are formalised in Isabelle/HOL. In the next sections we will make 
   595   extensively use of these properties in order to define alpha-equivalence in 
   595   extensively use of these properties in order to define alpha-equivalence in 
   596   the presence of multiple binders.
   596   the presence of multiple binders.
   597 *}
   597 *}
   598 
   598 
   608   In order to keep our work with deriving the reasoning infrastructure
   608   In order to keep our work with deriving the reasoning infrastructure
   609   manageable, we will wherever possible state definitions and perform proofs
   609   manageable, we will wherever possible state definitions and perform proofs
   610   on the user-level of Isabelle/HOL, as opposed to write custom ML-code that
   610   on the user-level of Isabelle/HOL, as opposed to write custom ML-code that
   611   generates them anew for each specification. To that end, we will consider
   611   generates them anew for each specification. To that end, we will consider
   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 of atoms @{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? (For 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
   735 
   735 
   736   \noindent
   736   \noindent
   737   This lemma allows us to use our quotient package and introduce 
   737   This lemma allows us to use our quotient package and introduce 
   738   new types @{text "\<beta> abs_set"}, @{text "\<beta> abs_res"} and @{text "\<beta> abs_list"}
   738   new types @{text "\<beta> abs_set"}, @{text "\<beta> abs_res"} and @{text "\<beta> abs_list"}
   739   representing alpha-equivalence classes of pairs of type 
   739   representing alpha-equivalence classes of pairs of type 
   740   @{text "(atom set) \<times> \<beta>"} (in the first two cases) and of type @{text "(atom list) \<times> \<beta>"}. 
   740   @{text "(atom set) \<times> \<beta>"} (in the first two cases) and of type @{text "(atom list) \<times> \<beta>"}
       
   741   (in the third case). 
   741   The elements in these types will be, respectively, written as:
   742   The elements in these types will be, respectively, written as:
   742 
   743 
   743   \begin{center}
   744   \begin{center}
   744   @{term "Abs as x"} \hspace{5mm} 
   745   @{term "Abs as x"} \hspace{5mm} 
   745   @{term "Abs_res as x"} \hspace{5mm}
   746   @{term "Abs_res as x"} \hspace{5mm}
   774   \end{equation}
   775   \end{equation}
   775 
   776 
   776   \noindent
   777   \noindent
   777   and also
   778   and also
   778   %
   779   %
   779   \begin{equation}
   780   \begin{equation}\label{absperm}
   780   @{thm permute_Abs[no_vars]}
   781   @{thm permute_Abs[no_vars]}
   781   \end{equation}
   782   \end{equation}
   782 
   783 
   783   \noindent
   784   \noindent
   784   The second fact derives from the definition of permutations acting on pairs 
   785   The second fact derives from the definition of permutations acting on pairs 
   795   the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   796   the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   796   Moreover @{text supp} and set difference are equivariant (see \cite{HuffmanUrban10}).
   797   Moreover @{text supp} and set difference are equivariant (see \cite{HuffmanUrban10}).
   797   \end{proof}
   798   \end{proof}
   798 
   799 
   799   \noindent
   800   \noindent
   800   This lemma allows us to show
   801   This lemma together with \eqref{absperm} allows us to show
   801   %
   802   %
   802   \begin{equation}\label{halfone}
   803   \begin{equation}\label{halfone}
   803   @{thm abs_supports(1)[no_vars]}
   804   @{thm abs_supports(1)[no_vars]}
   804   \end{equation}
   805   \end{equation}
   805   
   806   
   888   \begin{center}
   889   \begin{center}
   889   @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$  @{text "binding_clauses"} 
   890   @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$  @{text "binding_clauses"} 
   890   \end{center}
   891   \end{center}
   891   
   892   
   892   \noindent
   893   \noindent
   893   whereby some of the @{text ty}$'_{1..l}$ (or their components) might be contained
   894   whereby some of the @{text ty}$'_{1..l}$ (or their components) can be contained
   894   in the collection of @{text ty}$^\alpha_{1..n}$ declared in
   895   in the collection of @{text ty}$^\alpha_{1..n}$ declared in
   895   \eqref{scheme}. 
   896   \eqref{scheme}. 
   896   In this case we will call the corresponding argument a
   897   In this case we will call the corresponding argument a
   897   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. 
   898   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. 
   898   %The types of such recursive 
   899   %The types of such recursive 
   939   Shallow binders are of the form \isacommand{bind}\; {\it labels}\;
   940   Shallow binders are of the form \isacommand{bind}\; {\it labels}\;
   940   \isacommand{in}\; {\it labels'} (similar for the other two modes). The
   941   \isacommand{in}\; {\it labels'} (similar for the other two modes). The
   941   restriction we impose on shallow binders is that in case of
   942   restriction we impose on shallow binders is that in case of
   942   \isacommand{bind\_set} and \isacommand{bind\_res} the {\it labels} must
   943   \isacommand{bind\_set} and \isacommand{bind\_res} the {\it labels} must
   943   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
   944   \isacommand{bind} we allow labels 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. Two
   945   examples for the use of shallow binders are the specification of
   946   examples for the use of shallow binders are the specification of
   946   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
   947   set of names is bound:
   948   set of names is bound:
   948 
   949 
   949   \begin{center}
   950   \begin{center}
   964   \end{tabular}
   965   \end{tabular}
   965   \end{tabular}
   966   \end{tabular}
   966   \end{center}
   967   \end{center}
   967 
   968 
   968   \noindent
   969   \noindent
   969   Note that in this specification @{text "name"} refers to an atom type, and
   970   Note that for @{text lam} we have a choice which mode we use. The reason is that 
   970   @{text "fset"} to the type of finite sets. Shallow binders can occur in the 
   971   we bind only a single @{text name}. Having \isacommand{bind\_set} in the second
   971   binding part of several binding clauses. 
   972   case changes the semantics of the specification. 
   972  
   973   Note also that in these specifications @{text "name"} refers to an atom type, and
   973   A \emph{deep} binder uses an auxiliary binding function that ``picks'' out
   974   @{text "fset"} to the type of finite sets. 
       
   975 
       
   976   The restrictions are as follows:
       
   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
   974   the atoms in one argument of the term-constructor, which can be bound in  
   979   the atoms in one argument of the term-constructor, which can be bound in  
   975   other arguments and also in the same argument (we will
   980   other arguments and also in the same argument (we will
   976   call such binders \emph{recursive}, see below). 
   981   call such binders \emph{recursive}, see below). 
   977   The corresponding binding functions are expected to return either a set of atoms
   982   The corresponding binding functions are expected to return either a set of atoms
   978   (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms
   983   (for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms
  1002   \end{tabular}}
  1007   \end{tabular}}
  1003   \end{equation}
  1008   \end{equation}
  1004   
  1009   
  1005   \noindent
  1010   \noindent
  1006   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1011   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1007   bound in the argument @{text "t"}. Note that in the second-last clause the function @{text "atom"}
  1012   bound in the argument @{text "t"}. Note that in the second-last @{text bn}-clause the 
       
  1013   function @{text "atom"}
  1008   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows
  1014   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows
  1009   us to treat binders of different atom type uniformly. 
  1015   us to treat binders of different atom type uniformly. 
  1010 
  1016 
  1011   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 
  1012   we cannot have ``overlapping'' deep binders. Consider for example the 
  1018   we cannot have ``overlapping'' deep binders. Consider for example the