Paper/Paper.thy
changeset 2508 6d9018d62b40
parent 2507 f5621efe5a20
child 2509 679cef364022
equal deleted inserted replaced
2507:f5621efe5a20 2508:6d9018d62b40
    59 
    59 
    60 text {*
    60 text {*
    61 
    61 
    62   So far, Nominal Isabelle provided a mechanism for constructing
    62   So far, Nominal Isabelle provided a mechanism for constructing
    63   $\alpha$-equated terms, for example lambda-terms
    63   $\alpha$-equated terms, for example lambda-terms
    64 
    64   %
    65   \begin{center}
    65   \begin{center}
    66   @{text "t ::= x | t t | \<lambda>x. t"}
    66   @{text "t ::= x | t t | \<lambda>x. t"}
    67   \end{center}
    67   \end{center}
    68 
    68   %
    69   \noindent
    69   \noindent
    70   where free and bound variables have names.  For such $\alpha$-equated terms,
    70   where free and bound variables have names.  For such $\alpha$-equated terms,
    71   Nominal Isabelle derives automatically a reasoning infrastructure that has
    71   Nominal Isabelle derives automatically a reasoning infrastructure that has
    72   been used successfully in formalisations of an equivalence checking
    72   been used successfully in formalisations of an equivalence checking
    73   algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed
    73   algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed
    85   \begin{array}{l}
    85   \begin{array}{l}
    86   @{text "T ::= x | T \<rightarrow> T"}\hspace{5mm}
    86   @{text "T ::= x | T \<rightarrow> T"}\hspace{5mm}
    87   @{text "S ::= \<forall>{x\<^isub>1,\<dots>, x\<^isub>n}. T"}
    87   @{text "S ::= \<forall>{x\<^isub>1,\<dots>, x\<^isub>n}. T"}
    88   \end{array}
    88   \end{array}
    89   \end{equation}
    89   \end{equation}
    90 
    90   %
    91   \noindent
    91   \noindent
    92   and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of
    92   and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of
    93   type-variables.  While it is possible to implement this kind of more general
    93   type-variables.  While it is possible to implement this kind of more general
    94   binders by iterating single binders, this leads to a rather clumsy
    94   binders by iterating single binders, this leads to a rather clumsy
    95   formalisation of W. The need of iterating single binders is also one reason
    95   formalisation of W. The need of iterating single binders is also one reason
    96   why Nominal Isabelle and similar theorem provers that only provide
    96   why Nominal Isabelle and similar theorem provers that only provide
    97   mechanisms for binding single variables have not fared extremely well with the
    97   mechanisms for binding single variables have not fared extremely well with the
    98   more advanced tasks in the POPLmark challenge \cite{challenge05}, because
    98   more advanced tasks in the POPLmark challenge \cite{challenge05}, because
    99   also there one would like to bind multiple variables at once.
    99   also there one would like to bind multiple variables at once. 
   100 
   100 
   101   Binding multiple variables has interesting properties that cannot be captured
   101   Binding multiple variables has interesting properties that cannot be captured
   102   easily by iterating single binders. For example in the case of type-schemes we do not
   102   easily by iterating single binders. For example in the case of type-schemes we do not
   103   want to make a distinction about the order of the bound variables. Therefore
   103   want to make a distinction about the order of the bound variables. Therefore
   104   we would like to regard the following two type-schemes as $\alpha$-equivalent
   104   we would like to regard the following two type-schemes as $\alpha$-equivalent
   105   %
   105   %
   106   \begin{equation}\label{ex1}
   106   \begin{equation}\label{ex1}
   107   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{y, x}. x \<rightarrow> y"} 
   107   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{y, x}. x \<rightarrow> y"} 
   108   \end{equation}
   108   \end{equation}
   109 
   109   %
   110   \noindent
   110   \noindent
   111   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   111   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   112   the following two should \emph{not} be $\alpha$-equivalent
   112   the following two should \emph{not} be $\alpha$-equivalent
   113   %
   113   %
   114   \begin{equation}\label{ex2}
   114   \begin{equation}\label{ex2}
   115   @{text "\<forall>{x, y}. x \<rightarrow> y  \<notapprox>\<^isub>\<alpha>  \<forall>{z}. z \<rightarrow> z"} 
   115   @{text "\<forall>{x, y}. x \<rightarrow> y  \<notapprox>\<^isub>\<alpha>  \<forall>{z}. z \<rightarrow> z"} 
   116   \end{equation}
   116   \end{equation}
   117 
   117   %
   118   \noindent
   118   \noindent
   119   Moreover, we like to regard type-schemes as $\alpha$-equivalent, if they differ
   119   Moreover, we like to regard type-schemes as $\alpha$-equivalent, if they differ
   120   only on \emph{vacuous} binders, such as
   120   only on \emph{vacuous} binders, such as
   121   %
   121   %
   122   \begin{equation}\label{ex3}
   122   \begin{equation}\label{ex3}
   123   @{text "\<forall>{x}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{x, z}. x \<rightarrow> y"}
   123   @{text "\<forall>{x}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{x, z}. x \<rightarrow> y"}
   124   \end{equation}
   124   \end{equation}
   125 
   125   %
   126   \noindent
   126   \noindent
   127   where @{text z} does not occur freely in the type.  In this paper we will
   127   where @{text z} does not occur freely in the type.  In this paper we will
   128   give a general binding mechanism and associated notion of $\alpha$-equivalence
   128   give a general binding mechanism and associated notion of $\alpha$-equivalence
   129   that can be used to faithfully represent this kind of binding in Nominal
   129   that can be used to faithfully represent this kind of binding in Nominal
   130   Isabelle.  The difficulty of finding the right notion for $\alpha$-equivalence
   130   Isabelle.  The difficulty of finding the right notion for $\alpha$-equivalence
   144   \eqref{one} as $\alpha$-equivalent with
   144   \eqref{one} as $\alpha$-equivalent with
   145   %
   145   %
   146   \begin{center}
   146   \begin{center}
   147   @{text "\<LET> x = 3 \<AND> y = 2 \<AND> z = loop \<IN> x - y \<END>"}
   147   @{text "\<LET> x = 3 \<AND> y = 2 \<AND> z = loop \<IN> x - y \<END>"}
   148   \end{center}
   148   \end{center}
   149 
   149   %
   150   \noindent
   150   \noindent
   151   Therefore we will also provide a separate binding mechanism for cases in
   151   Therefore we will also provide a separate binding mechanism for cases in
   152   which the order of binders does not matter, but the ``cardinality'' of the
   152   which the order of binders does not matter, but the ``cardinality'' of the
   153   binders has to agree.
   153   binders has to agree.
   154 
   154 
   157   research. For example in @{text "\<LET>"}s containing patterns like
   157   research. For example in @{text "\<LET>"}s containing patterns like
   158   %
   158   %
   159   \begin{equation}\label{two}
   159   \begin{equation}\label{two}
   160   @{text "\<LET> (x, y) = (3, 2) \<IN> x - y \<END>"}
   160   @{text "\<LET> (x, y) = (3, 2) \<IN> x - y \<END>"}
   161   \end{equation}
   161   \end{equation}
   162 
   162   %
   163   \noindent
   163   \noindent
   164   we want to bind all variables from the pattern inside the body of the
   164   we want to bind all variables from the pattern inside the body of the
   165   $\mathtt{let}$, but we also care about the order of these variables, since
   165   $\mathtt{let}$, but we also care about the order of these variables, since
   166   we do not want to regard \eqref{two} as $\alpha$-equivalent with
   166   we do not want to regard \eqref{two} as $\alpha$-equivalent with
   167   %
   167   %
   170   \end{center}
   170   \end{center}
   171   %
   171   %
   172   \noindent
   172   \noindent
   173   As a result, we provide three general binding mechanisms each of which binds
   173   As a result, we provide three general binding mechanisms each of which binds
   174   multiple variables at once, and let the user chose which one is intended
   174   multiple variables at once, and let the user chose which one is intended
   175   when formalising a term-calculus.
   175   in a formalisation.
       
   176   %%when formalising a term-calculus.
   176 
   177 
   177   By providing these general binding mechanisms, however, we have to work
   178   By providing these general binding mechanisms, however, we have to work
   178   around a problem that has been pointed out by Pottier \cite{Pottier06} and
   179   around a problem that has been pointed out by Pottier \cite{Pottier06} and
   179   Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form
   180   Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form
   180   %
   181   %
   181   \begin{center}
   182   \begin{center}
   182   @{text "\<LET> x\<^isub>1 = t\<^isub>1 \<AND> \<dots> \<AND> x\<^isub>n = t\<^isub>n \<IN> s \<END>"}
   183   @{text "\<LET> x\<^isub>1 = t\<^isub>1 \<AND> \<dots> \<AND> x\<^isub>n = t\<^isub>n \<IN> s \<END>"}
   183   \end{center}
   184   \end{center}
   184 
   185   %
   185   \noindent
   186   \noindent
   186   which bind all the @{text "x\<^isub>i"} in @{text s}, we might not care
   187   we care about the 
   187   about the order in which the @{text "x\<^isub>i = t\<^isub>i"} are given,
   188   information that there are as many bound variables @{text
   188   but we do care about the information that there are as many @{text
       
   189   "x\<^isub>i"} as there are @{text "t\<^isub>i"}. We lose this information if
   189   "x\<^isub>i"} as there are @{text "t\<^isub>i"}. We lose this information if
   190   we represent the @{text "\<LET>"}-constructor by something like
   190   we represent the @{text "\<LET>"}-constructor by something like
   191   %
   191   %
   192   \begin{center}
   192   \begin{center}
   193   @{text "\<LET> (\<lambda>x\<^isub>1\<dots>x\<^isub>n . s)  [t\<^isub>1,\<dots>,t\<^isub>n]"}
   193   @{text "\<LET> (\<lambda>x\<^isub>1\<dots>x\<^isub>n . s)  [t\<^isub>1,\<dots>,t\<^isub>n]"}
   194   \end{center}
   194   \end{center}
   195 
   195   %
   196   \noindent
   196   \noindent
   197   where the notation @{text "\<lambda>_ . _"} indicates that the list of @{text
   197   where the notation @{text "\<lambda>_ . _"} indicates that the list of @{text
   198   "x\<^isub>i"} becomes bound in @{text s}. In this representation the term
   198   "x\<^isub>i"} becomes bound in @{text s}. In this representation the term
   199   \mbox{@{text "\<LET> (\<lambda>x . s)  [t\<^isub>1, t\<^isub>2]"}} is a perfectly legal
   199   \mbox{@{text "\<LET> (\<lambda>x . s)  [t\<^isub>1, t\<^isub>2]"}} is a perfectly legal
   200   instance, but the lengths of the two lists do not agree. To exclude such
   200   instance, but the lengths of the two lists do not agree. To exclude such
   202   ensure that the two lists are of equal length. This can result in very messy
   202   ensure that the two lists are of equal length. This can result in very messy
   203   reasoning (see for example~\cite{BengtsonParow09}). To avoid this, we will
   203   reasoning (see for example~\cite{BengtsonParow09}). To avoid this, we will
   204   allow type specifications for @{text "\<LET>"}s as follows
   204   allow type specifications for @{text "\<LET>"}s as follows
   205   %
   205   %
   206   \begin{center}
   206   \begin{center}
   207   \begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}l}
   207   \begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}cl}
   208   @{text trm} & @{text "::="}  & @{text "\<dots>"}\\ 
   208   @{text trm} & @{text "::="}  & @{text "\<dots>"} 
   209               & @{text "|"}    & @{text "\<LET>  as::assn  s::trm"}\hspace{4mm} 
   209               & @{text "|"}  @{text "\<LET>  as::assn  s::trm"}\hspace{2mm} 
   210                                  \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm]
   210                                  \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm]
   211   @{text assn} & @{text "::="} & @{text "\<ANIL>"}\\
   211   @{text assn} & @{text "::="} & @{text "\<ANIL>"}
   212                & @{text "|"}   & @{text "\<ACONS>  name  trm  assn"}
   212                &  @{text "|"}  @{text "\<ACONS>  name  trm  assn"}
   213   \end{tabular}
   213   \end{tabular}
   214   \end{center}
   214   \end{center}
   215 
   215   %
   216   \noindent
   216   \noindent
   217   where @{text assn} is an auxiliary type representing a list of assignments
   217   where @{text assn} is an auxiliary type representing a list of assignments
   218   and @{text bn} an auxiliary function identifying the variables to be bound
   218   and @{text bn} an auxiliary function identifying the variables to be bound
   219   by the @{text "\<LET>"}. This function can be defined by recursion over @{text
   219   by the @{text "\<LET>"}. This function can be defined by recursion over @{text
   220   assn} as follows
   220   assn} as follows
   221 
   221   %
   222   \begin{center}
   222   \begin{center}
   223   @{text "bn(\<ANIL>) ="} @{term "{}"} \hspace{5mm} 
   223   @{text "bn(\<ANIL>) ="} @{term "{}"} \hspace{5mm} 
   224   @{text "bn(\<ACONS> x t as) = {x} \<union> bn(as)"} 
   224   @{text "bn(\<ACONS> x t as) = {x} \<union> bn(as)"} 
   225   \end{center}
   225   \end{center}
   226   
   226   %
   227   \noindent
   227   \noindent
   228   The scope of the binding is indicated by labels given to the types, for
   228   The scope of the binding is indicated by labels given to the types, for
   229   example @{text "s::trm"}, and a binding clause, in this case
   229   example @{text "s::trm"}, and a binding clause, in this case
   230   \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   230   \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   231   clause states that all the names the function @{text
   231   clause states that all the names the function @{text
   232   "bn(as)"} returns should be bound in @{text s}.  This style of specifying terms and bindings is heavily
   232   "bn(as)"} returns should be bound in @{text s}.  This style of specifying terms and bindings is heavily
   233   inspired by the syntax of the Ott-tool \cite{ott-jfp}. Though, Ott
   233   inspired by the syntax of the Ott-tool \cite{ott-jfp}. 
   234   has only one binding mode, namely the one where the order of
   234 
   235   binders matters. Consequently, type-schemes with binding sets
   235   %Though, Ott
   236   of names cannot be modelled in Ott.
   236   %has only one binding mode, namely the one where the order of
       
   237   %binders matters. Consequently, type-schemes with binding sets
       
   238   %of names cannot be modelled in Ott.
   237 
   239 
   238   However, we will not be able to cope with all specifications that are
   240   However, we will not be able to cope with all specifications that are
   239   allowed by Ott. One reason is that Ott lets the user specify ``empty'' 
   241   allowed by Ott. One reason is that Ott lets the user specify ``empty'' 
   240   types like
   242   types like
   241 
   243   %
   242   \begin{center}
   244   \begin{center}
   243   @{text "t ::= t t | \<lambda>x. t"}
   245   @{text "t ::= t t | \<lambda>x. t"}
   244   \end{center}
   246   \end{center}
   245 
   247   %
   246   \noindent
   248   \noindent
   247   where no clause for variables is given. Arguably, such specifications make
   249   where no clause for variables is given. Arguably, such specifications make
   248   some sense in the context of Coq's type theory (which Ott supports), but not
   250   some sense in the context of Coq's type theory (which Ott supports), but not
   249   at all in a HOL-based environment where every datatype must have a non-empty
   251   at all in a HOL-based environment where every datatype must have a non-empty
   250   set-theoretic model \cite{Berghofer99}.
   252   set-theoretic model \cite{Berghofer99}.
   277   ``$\alpha$-equals-by-$\alpha$-equals'' in a representation based on raw terms
   279   ``$\alpha$-equals-by-$\alpha$-equals'' in a representation based on raw terms
   278   requires a lot of extra reasoning work.
   280   requires a lot of extra reasoning work.
   279 
   281 
   280   Although in informal settings a reasoning infrastructure for $\alpha$-equated
   282   Although in informal settings a reasoning infrastructure for $\alpha$-equated
   281   terms is nearly always taken for granted, establishing it automatically in
   283   terms is nearly always taken for granted, establishing it automatically in
   282   the Isabelle/HOL theorem prover is a rather non-trivial task. For every
   284   the Isabelle/HOL is a rather non-trivial task. For every
   283   specification we will need to construct a type containing as elements the
   285   specification we will need to construct a type containing as elements the
   284   $\alpha$-equated terms. To do so, we use the standard HOL-technique of defining
   286   $\alpha$-equated terms. To do so, we use the standard HOL-technique of defining
   285   a new type by identifying a non-empty subset of an existing type.  The
   287   a new type by identifying a non-empty subset of an existing type.  The
   286   construction we perform in Isabelle/HOL can be illustrated by the following picture:
   288   construction we perform in Isabelle/HOL can be illustrated by the following picture:
   287 
   289   %
   288   \begin{center}
   290   \begin{center}
   289   \begin{tikzpicture}
   291   \begin{tikzpicture}
   290   %\draw[step=2mm] (-4,-1) grid (4,1);
   292   %\draw[step=2mm] (-4,-1) grid (4,1);
   291   
   293   
   292   \draw[very thick] (0.7,0.4) circle (4.25mm);
   294   \draw[very thick] (0.7,0.4) circle (4.25mm);
   306   \draw[<->, very thick] (-1.8, 0.3) -- (-0.1,0.3);
   308   \draw[<->, very thick] (-1.8, 0.3) -- (-0.1,0.3);
   307   \draw (-0.95, 0.3) node[above=0mm] {isomorphism};
   309   \draw (-0.95, 0.3) node[above=0mm] {isomorphism};
   308 
   310 
   309   \end{tikzpicture}
   311   \end{tikzpicture}
   310   \end{center}
   312   \end{center}
   311 
   313   %
   312   \noindent
   314   \noindent
   313   We take as the starting point a definition of raw terms (defined as a
   315   We take as the starting point a definition of raw terms (defined as a
   314   datatype in Isabelle/HOL); then identify the $\alpha$-equivalence classes in
   316   datatype in Isabelle/HOL); then identify the $\alpha$-equivalence classes in
   315   the type of sets of raw terms according to our $\alpha$-equivalence relation,
   317   the type of sets of raw terms according to our $\alpha$-equivalence relation,
   316   and finally define the new type as these $\alpha$-equivalence classes
   318   and finally define the new type as these $\alpha$-equivalence classes
   317   (non-emptiness is satisfied whenever the raw terms are definable as datatype
   319   (non-emptiness is satisfied whenever the raw terms are definable as datatype
   318   in Isabelle/HOL and the property that our relation for $\alpha$-equivalence is
   320   in Isabelle/HOL and the property that our relation for $\alpha$-equivalence is
   319   indeed an equivalence relation).
   321   indeed an equivalence relation).
   320 
   322 
   321   The fact that we obtain an isomorphism between the new type and the
   323   %The fact that we obtain an isomorphism between the new type and the
   322   non-empty subset shows that the new type is a faithful representation of
   324   %non-empty subset shows that the new type is a faithful representation of
   323   $\alpha$-equated terms. That is not the case for example for terms using the
   325   %$\alpha$-equated terms. That is not the case for example for terms using the
   324   locally nameless representation of binders \cite{McKinnaPollack99}: in this
   326   %locally nameless representation of binders \cite{McKinnaPollack99}: in this
   325   representation there are ``junk'' terms that need to be excluded by
   327   %representation there are ``junk'' terms that need to be excluded by
   326   reasoning about a well-formedness predicate.
   328   %reasoning about a well-formedness predicate.
   327 
   329 
   328   The problem with introducing a new type in Isabelle/HOL is that in order to
   330   The problem with introducing a new type in Isabelle/HOL is that in order to
   329   be useful, a reasoning infrastructure needs to be ``lifted'' from the
   331   be useful, a reasoning infrastructure needs to be ``lifted'' from the
   330   underlying subset to the new type. This is usually a tricky and arduous
   332   underlying subset to the new type. This is usually a tricky and arduous
   331   task. To ease it, we re-implemented in Isabelle/HOL the quotient package
   333   task. To ease it, we re-implemented in Isabelle/HOL the quotient package
   333   allows us to lift definitions and theorems involving raw terms to
   335   allows us to lift definitions and theorems involving raw terms to
   334   definitions and theorems involving $\alpha$-equated terms. For example if we
   336   definitions and theorems involving $\alpha$-equated terms. For example if we
   335   define the free-variable function over raw lambda-terms
   337   define the free-variable function over raw lambda-terms
   336 
   338 
   337   \begin{center}
   339   \begin{center}
   338   @{text "fv(x) = {x}"}\hspace{10mm}
   340   @{text "fv(x) = {x}"}\hspace{8mm}
   339   @{text "fv(t\<^isub>1 t\<^isub>2) = fv(t\<^isub>1) \<union> fv(t\<^isub>2)"}\\[1mm]
   341   @{text "fv(t\<^isub>1 t\<^isub>2) = fv(t\<^isub>1) \<union> fv(t\<^isub>2)"}\hspace{8mm}
   340   @{text "fv(\<lambda>x.t) = fv(t) - {x}"}
   342   @{text "fv(\<lambda>x.t) = fv(t) - {x}"}
   341   \end{center}
   343   \end{center}
   342   
   344   
   343   \noindent
   345   \noindent
   344   then with the help of the quotient package we can obtain a function @{text "fv\<^sup>\<alpha>"}
   346   then with the help of the quotient package we can obtain a function @{text "fv\<^sup>\<alpha>"}
   345   operating on quotients, or $\alpha$-equivalence classes of lambda-terms. This
   347   operating on quotients, or $\alpha$-equivalence classes of lambda-terms. This
   346   lifted function is characterised by the equations
   348   lifted function is characterised by the equations
   347 
   349 
   348   \begin{center}
   350   \begin{center}
   349   @{text "fv\<^sup>\<alpha>(x) = {x}"}\hspace{10mm}
   351   @{text "fv\<^sup>\<alpha>(x) = {x}"}\hspace{8mm}
   350   @{text "fv\<^sup>\<alpha>(t\<^isub>1 t\<^isub>2) = fv\<^sup>\<alpha>(t\<^isub>1) \<union> fv\<^sup>\<alpha>(t\<^isub>2)"}\\[1mm]
   352   @{text "fv\<^sup>\<alpha>(t\<^isub>1 t\<^isub>2) = fv\<^sup>\<alpha>(t\<^isub>1) \<union> fv\<^sup>\<alpha>(t\<^isub>2)"}\hspace{8mm}
   351   @{text "fv\<^sup>\<alpha>(\<lambda>x.t) = fv\<^sup>\<alpha>(t) - {x}"}
   353   @{text "fv\<^sup>\<alpha>(\<lambda>x.t) = fv\<^sup>\<alpha>(t) - {x}"}
   352   \end{center}
   354   \end{center}
   353 
   355 
   354   \noindent
   356   \noindent
   355   (Note that this means also the term-constructors for variables, applications
   357   (Note that this means also the term-constructors for variables, applications
   363   properties (see \cite{Homeier05}). In the paper we show that we are able to
   365   properties (see \cite{Homeier05}). In the paper we show that we are able to
   364   automate these proofs and as a result can automatically establish a reasoning 
   366   automate these proofs and as a result can automatically establish a reasoning 
   365   infrastructure for $\alpha$-equated terms.
   367   infrastructure for $\alpha$-equated terms.
   366 
   368 
   367   The examples we have in mind where our reasoning infrastructure will be
   369   The examples we have in mind where our reasoning infrastructure will be
   368   helpful includes the term language of System @{text "F\<^isub>C"}, also
   370   helpful includes the term language of Core-Haskell. This term language
   369   known as Core-Haskell (see Figure~\ref{corehas}). This term language
       
   370   involves patterns that have lists of type-, coercion- and term-variables,
   371   involves patterns that have lists of type-, coercion- and term-variables,
   371   all of which are bound in @{text "\<CASE>"}-expressions. One
   372   all of which are bound in @{text "\<CASE>"}-expressions. In these
   372   feature is that we do not know in advance how many variables need to
   373   patterns we do not know in advance how many variables need to
   373   be bound. Another is that each bound variable comes with a kind or type
   374   be bound. Another example is the specification of SML, which includes
   374   annotation. Representing such binders with single binders and reasoning
   375   includes bindings as in type-schemes.\medskip
   375   about them in a theorem prover would be a major pain.  \medskip
       
   376 
   376 
   377   \noindent
   377   \noindent
   378   {\bf Contributions:}  We provide three new definitions for when terms
   378   {\bf Contributions:}  We provide three new definitions for when terms
   379   involving general binders are $\alpha$-equivalent. These definitions are
   379   involving general binders are $\alpha$-equivalent. These definitions are
   380   inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic
   380   inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic
   382   terms, including properties about support, freshness and equality
   382   terms, including properties about support, freshness and equality
   383   conditions for $\alpha$-equated terms. We are also able to derive strong 
   383   conditions for $\alpha$-equated terms. We are also able to derive strong 
   384   induction principles that have the variable convention already built in.
   384   induction principles that have the variable convention already built in.
   385   The method behind our specification of general binders is taken 
   385   The method behind our specification of general binders is taken 
   386   from the Ott-tool, but we introduce crucial restrictions, and also extensions, so 
   386   from the Ott-tool, but we introduce crucial restrictions, and also extensions, so 
   387   that our specifications make sense for reasoning about $\alpha$-equated terms.  The main improvement over Ott is that we introduce three binding modes,
   387   that our specifications make sense for reasoning about $\alpha$-equated terms.  
   388    provide precise definitions for $\alpha$-equivalence and for free
   388   The main improvement over Ott is that we introduce three binding modes
   389    variables of our terms, and provide automated proofs inside the
   389   (only one is present in Ott), provide definitions for $\alpha$-equivalence and 
   390    Isabelle theorem prover.
   390   for free variables of our terms, and also derive a reasoning infrastructure
   391 
   391   about our specifications inside Isabelle/HOL.
   392 
   392 
   393   \begin{figure}
   393 
   394   \begin{boxedminipage}{\linewidth}
   394   %\begin{figure}
   395   \begin{center}
   395   %\begin{boxedminipage}{\linewidth}
   396   \begin{tabular}{r@ {\hspace{1mm}}r@ {\hspace{2mm}}l}
   396   %%\begin{center}
   397   \multicolumn{3}{@ {}l}{Type Kinds}\\
   397   %\begin{tabular}{r@ {\hspace{1mm}}r@ {\hspace{2mm}}l}
   398   @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\
   398   %\multicolumn{3}{@ {}l}{Type Kinds}\\
   399   \multicolumn{3}{@ {}l}{Coercion Kinds}\\
   399   %@{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\
   400   @{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\smallskip\\
   400   %\multicolumn{3}{@ {}l}{Coercion Kinds}\\
   401   \multicolumn{3}{@ {}l}{Types}\\
   401   %@{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\smallskip\\
   402   @{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"} 
   402   %\multicolumn{3}{@ {}l}{Types}\\
   403   @{text "| \<forall>a:\<kappa>. \<sigma> | \<iota> \<Rightarrow> \<sigma>"}\smallskip\\
   403   %@{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"} 
   404   \multicolumn{3}{@ {}l}{Coercion Types}\\
   404   %@{text "| \<forall>a:\<kappa>. \<sigma> | \<iota> \<Rightarrow> \<sigma>"}\smallskip\\
   405   @{text "\<gamma>"} & @{text "::="} & @{text "c | C | \<gamma>\<^isub>1 \<gamma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"}
   405   %\multicolumn{3}{@ {}l}{Coercion Types}\\
   406   @{text "| \<forall>c:\<iota>. \<gamma> | \<iota> \<Rightarrow> \<gamma> "}\\
   406   %@{text "\<gamma>"} & @{text "::="} & @{text "c | C | \<gamma>\<^isub>1 \<gamma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"}
   407   & @{text "|"} & @{text "refl \<sigma> | sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2 | \<gamma> @ \<sigma> | left \<gamma> | right \<gamma>"}\\
   407   %@{text "| \<forall>c:\<iota>. \<gamma> | \<iota> \<Rightarrow> \<gamma> "}\\
   408   & @{text "|"} & @{text "\<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 | rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\smallskip\\
   408   %& @{text "|"} & @{text "refl \<sigma> | sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2 | \<gamma> @ \<sigma> | left \<gamma> | right \<gamma>"}\\
   409   \multicolumn{3}{@ {}l}{Terms}\\
   409   %& @{text "|"} & @{text "\<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 | rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\smallskip\\
   410   @{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>c:\<iota>. e | e \<sigma> | e \<gamma>"}\\
   410   %\multicolumn{3}{@ {}l}{Terms}\\
   411   & @{text "|"} & @{text "\<lambda>x:\<sigma>. e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2"}\\
   411   %@{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>c:\<iota>. e | e \<sigma> | e \<gamma>"}\\
   412   & @{text "|"} & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\smallskip\\
   412   %& @{text "|"} & @{text "\<lambda>x:\<sigma>. e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2"}\\
   413   \multicolumn{3}{@ {}l}{Patterns}\\
   413   %& @{text "|"} & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\smallskip\\
   414   @{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "c:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\smallskip\\
   414   %\multicolumn{3}{@ {}l}{Patterns}\\
   415   \multicolumn{3}{@ {}l}{Constants}\\
   415   %@{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "c:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\smallskip\\
   416   & @{text C} & coercion constants\\
   416   %\multicolumn{3}{@ {}l}{Constants}\\
   417   & @{text T} & value type constructors\\
   417   %& @{text C} & coercion constants\\
   418   & @{text "S\<^isub>n"} & n-ary type functions (which need to be fully applied)\\
   418   %& @{text T} & value type constructors\\
   419   & @{text K} & data constructors\smallskip\\
   419   %& @{text "S\<^isub>n"} & n-ary type functions (which need to be fully applied)\\
   420   \multicolumn{3}{@ {}l}{Variables}\\
   420   %& @{text K} & data constructors\smallskip\\
   421   & @{text a} & type variables\\
   421   %\multicolumn{3}{@ {}l}{Variables}\\
   422   & @{text c} & coercion variables\\
   422   %& @{text a} & type variables\\
   423   & @{text x} & term variables\\
   423   %& @{text c} & coercion variables\\
   424   \end{tabular}
   424   %& @{text x} & term variables\\
   425   \end{center}
   425   %\end{tabular}
   426   \end{boxedminipage}
   426   %\end{center}
   427   \caption{The System @{text "F\<^isub>C"}
   427   %\end{boxedminipage}
   428   \cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this
   428   %\caption{The System @{text "F\<^isub>C"}
   429   version of @{text "F\<^isub>C"} we made a modification by separating the
   429   %\cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this
   430   grammars for type kinds and coercion kinds, as well as for types and coercion
   430   %version of @{text "F\<^isub>C"} we made a modification by separating the
   431   types. For this paper the interesting term-constructor is @{text "\<CASE>"},
   431   %grammars for type kinds and coercion kinds, as well as for types and coercion
   432   which binds multiple type-, coercion- and term-variables.\label{corehas}}
   432   %types. For this paper the interesting term-constructor is @{text "\<CASE>"},
   433   \end{figure}
   433   %which binds multiple type-, coercion- and term-variables.\label{corehas}}
       
   434   %\end{figure}
   434 *}
   435 *}
   435 
   436 
   436 section {* A Short Review of the Nominal Logic Work *}
   437 section {* A Short Review of the Nominal Logic Work *}
   437 
   438 
   438 text {*
   439 text {*
   452   in what follows to only one sort of atoms.
   453   in what follows to only one sort of atoms.
   453 
   454 
   454   Permutations are bijective functions from atoms to atoms that are 
   455   Permutations are bijective functions from atoms to atoms that are 
   455   the identity everywhere except on a finite number of atoms. There is a 
   456   the identity everywhere except on a finite number of atoms. There is a 
   456   two-place permutation operation written
   457   two-place permutation operation written
   457   %
       
   458   \begin{center}
       
   459   @{text "_ \<bullet> _  ::  perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"}
   458   @{text "_ \<bullet> _  ::  perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"}
   460   \end{center}
       
   461 
       
   462   \noindent 
       
   463   in which the generic type @{text "\<beta>"} stands for the type of the object 
   459   in which the generic type @{text "\<beta>"} stands for the type of the object 
   464   over which the permutation 
   460   over which the permutation 
   465   acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"},
   461   acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"},
   466   the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, 
   462   the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, 
   467   and the inverse permutation of @{term p} as @{text "- p"}. The permutation
   463   and the inverse permutation of @{term p} as @{text "- p"}. The permutation
   468   operation is defined by induction over the type-hierarchy \cite{HuffmanUrban10};
   464   operation is defined by induction over the type-hierarchy \cite{HuffmanUrban10};
   469   for example permutations acting on products, lists, sets, functions and booleans is
   465   for example permutations acting on products, lists, sets, functions and booleans is
   470   given by:
   466   given by:
   471   %
   467   %
   472   \begin{equation}\label{permute}
   468   \begin{equation}\label{permute}
   473   \mbox{\begin{tabular}{@ {}cc@ {}}
   469   \mbox{\begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}}
   474   \begin{tabular}{@ {}l@ {}}
   470   \begin{tabular}{@ {}l@ {}}
   475   @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm]
   471   @{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm]
   476   @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\
   472   @{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\
   477   @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\
   473   @{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\
   478   \end{tabular} &
   474   \end{tabular} &
   479   \begin{tabular}{@ {}l@ {}}
   475   \begin{tabular}{@ {}l@ {}}
   480   @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\
   476   @{thm permute_set_eq[no_vars, THEN eq_reflection]}\\
   481   @{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\
   477   @{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\
   482   @{thm permute_bool_def[no_vars, THEN eq_reflection]}\\
   478   @{thm permute_bool_def[no_vars, THEN eq_reflection]}
   483   \end{tabular}
   479   \end{tabular}
   484   \end{tabular}}
   480   \end{tabular}}
   485   \end{equation}
   481   \end{equation}
   486 
   482 
   487   \noindent
   483   \noindent
   505   @{thm supp_def[no_vars, THEN eq_reflection]}
   501   @{thm supp_def[no_vars, THEN eq_reflection]}
   506   \end{equation}
   502   \end{equation}
   507 
   503 
   508   \noindent
   504   \noindent
   509   There is also the derived notion for when an atom @{text a} is \emph{fresh}
   505   There is also the derived notion for when an atom @{text a} is \emph{fresh}
   510   for an @{text x}, defined as
   506   for an @{text x}, defined as @{thm fresh_def[no_vars]}.
   511   %
       
   512   \begin{center}
       
   513   @{thm fresh_def[no_vars]}
       
   514   \end{center}
       
   515 
       
   516   \noindent
       
   517   We use for sets of atoms the abbreviation 
   507   We use for sets of atoms the abbreviation 
   518   @{thm (lhs) fresh_star_def[no_vars]}, defined as 
   508   @{thm (lhs) fresh_star_def[no_vars]}, defined as 
   519   @{thm (rhs) fresh_star_def[no_vars]}.
   509   @{thm (rhs) fresh_star_def[no_vars]}.
   520   A striking consequence of these definitions is that we can prove
   510   A striking consequence of these definitions is that we can prove
   521   without knowing anything about the structure of @{term x} that
   511   without knowing anything about the structure of @{term x} that
   528 
   518 
   529   While often the support of an object can be relatively easily 
   519   While often the support of an object can be relatively easily 
   530   described, for example for atoms, products, lists, function applications, 
   520   described, for example for atoms, products, lists, function applications, 
   531   booleans and permutations as follows
   521   booleans and permutations as follows
   532   %
   522   %
   533   \begin{eqnarray}
   523   \begin{center}
   534   @{term "supp a"} & = & @{term "{a}"}\\
   524   \begin{tabular}{c@ {\hspace{10mm}}c}
   535   @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\
   525   \begin{tabular}{rcl}
   536   @{term "supp []"} & = & @{term "{}"}\\
   526   @{term "supp a"} & $=$ & @{term "{a}"}\\
   537   @{term "supp (x#xs)"} & = & @{term "supp x \<union> supp xs"}\\
   527   @{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\
   538   @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\label{suppfun}\\
   528   @{term "supp []"} & $=$ & @{term "{}"}\\
   539   @{term "supp b"} & = & @{term "{}"}\\
   529   @{term "supp (x#xs)"} & $=$ & @{term "supp x \<union> supp xs"}\\
   540   @{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"}
   530   \end{tabular}
   541   \end{eqnarray}
   531   &
       
   532   \begin{tabular}{rcl}
       
   533   @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\
       
   534   @{term "supp b"} & $=$ & @{term "{}"}\\
       
   535   @{term "supp p"} & $=$ & @{term "{a. p \<bullet> a \<noteq> a}"}
       
   536   \end{tabular}
       
   537   \end{tabular}
       
   538   \end{center}
   542   
   539   
   543   \noindent 
   540   \noindent 
   544   in some cases it can be difficult to characterise the support precisely, and
   541   in some cases it can be difficult to characterise the support precisely, and
   545   only an approximation can be established (see \eqref{suppfun} above). Reasoning about
   542   only an approximation can be established (as for functions above). 
   546   such approximations can be simplified with the notion \emph{supports}, defined 
   543 
   547   as follows:
   544   %Reasoning about
   548 
   545   %such approximations can be simplified with the notion \emph{supports}, defined 
   549   \begin{definition}
   546   %as follows:
   550   A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b}
   547   %
   551   not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}.
   548   %\begin{definition}
   552   \end{definition}
   549   %A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b}
   553 
   550   %not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}.
   554   \noindent
   551   %\end{definition}
   555   The main point of @{text supports} is that we can establish the following 
   552   %
   556   two properties.
   553   %\noindent
   557 
   554   %The main point of @{text supports} is that we can establish the following 
   558   \begin{property}\label{supportsprop}
   555   %two properties.
   559   Given a set @{text "as"} of atoms.
   556   %
   560   {\it (i)} @{thm[mode=IfThen] supp_is_subset[where S="as", no_vars]}
   557   %\begin{property}\label{supportsprop}
   561   {\it (ii)} @{thm supp_supports[no_vars]}.
   558   %Given a set @{text "as"} of atoms.
   562   \end{property}
   559   %{\it (i)} @{thm[mode=IfThen] supp_is_subset[where S="as", no_vars]}
   563 
   560   %{\it (ii)} @{thm supp_supports[no_vars]}.
   564   Another important notion in the nominal logic work is \emph{equivariance}.
   561   %\end{property}
   565   For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant 
   562   %
   566   it is required that every permutation leaves @{text f} unchanged, that is
   563   %Another important notion in the nominal logic work is \emph{equivariance}.
   567   %
   564   %For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant 
   568   \begin{equation}\label{equivariancedef}
   565   %it is required that every permutation leaves @{text f} unchanged, that is
   569   @{term "\<forall>p. p \<bullet> f = f"}
   566   %%
   570   \end{equation}
   567   %\begin{equation}\label{equivariancedef}
   571 
   568   %@{term "\<forall>p. p \<bullet> f = f"}
   572   \noindent or equivalently that a permutation applied to the application
   569   %\end{equation}
   573   @{text "f x"} can be moved to the argument @{text x}. That means for equivariant
   570   %
   574   functions @{text f}, we have for all permutations @{text p}:
   571   %\noindent or equivalently that a permutation applied to the application
   575   %
   572   %@{text "f x"} can be moved to the argument @{text x}. That means for equivariant
   576   \begin{equation}\label{equivariance}
   573   %functions @{text f}, we have for all permutations @{text p}:
   577   @{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\;
   574   %%
   578   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   575   %\begin{equation}\label{equivariance}
   579   \end{equation}
   576   %@{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\;
   580  
   577   %@{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   581   \noindent
   578   %\end{equation}
   582   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   579   % 
   583   can easily deduce that equivariant functions have empty support. There is
   580   %\noindent
   584   also a similar notion for equivariant relations, say @{text R}, namely the property
   581   %From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   585   that
   582   %can easily deduce that equivariant functions have empty support. There is
   586   %
   583   %also a similar notion for equivariant relations, say @{text R}, namely the property
   587   \begin{center}
   584   %that
   588   @{text "x R y"} \;\;\textit{implies}\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
   585   %%
   589   \end{center}
   586   %\begin{center}
   590 
   587   %@{text "x R y"} \;\;\textit{implies}\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
   591   Finally, the nominal logic work provides us with general means for renaming 
   588   %\end{center}
       
   589 
       
   590   Using support and freshness, the nominal logic work provides us with general means for renaming 
   592   binders. While in the older version of Nominal Isabelle, we used extensively 
   591   binders. While in the older version of Nominal Isabelle, we used extensively 
   593   Property~\ref{swapfreshfresh} to rename single binders, this property 
   592   Property~\ref{swapfreshfresh} to rename single binders, this property 
   594   proved too unwieldy for dealing with multiple binders. For such binders the 
   593   proved too unwieldy for dealing with multiple binders. For such binders the 
   595   following generalisations turned out to be easier to use.
   594   following generalisations turned out to be easier to use.
   596 
   595 
   647   atoms; moreover there must be a permutation @{text p} such that {\it
   646   atoms; moreover there must be a permutation @{text p} such that {\it
   648   (ii)} @{text p} leaves the free atoms of @{text x} and @{text y} unchanged, but
   647   (ii)} @{text p} leaves the free atoms of @{text x} and @{text y} unchanged, but
   649   {\it (iii)} ``moves'' their bound names so that we obtain modulo a relation,
   648   {\it (iii)} ``moves'' their bound names so that we obtain modulo a relation,
   650   say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)}
   649   say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)}
   651   @{text p} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The
   650   @{text p} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The
   652   requirements {\it (i)} to {\it (iv)} can be stated formally as follows:
   651   requirements {\it (i)} to {\it (iv)} can be stated formally as the conjunction of:
   653   %
   652   %
   654   \begin{equation}\label{alphaset}
   653   \begin{equation}\label{alphaset}
   655   \begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l@ {\hspace{4mm}}r}
   654   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   656   \multicolumn{3}{l}{@{term "(as, x) \<approx>set R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   655   \multicolumn{4}{l}{@{term "(as, x) \<approx>set R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   657               & @{term "fa(x) - as = fa(y) - bs"} & \mbox{\it (i)}\\
   656        \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"} &
   658   @{text "\<and>"} & @{term "(fa(x) - as) \<sharp>* p"} & \mbox{\it (ii)}\\
   657        \mbox{\it (iii)} &  @{text "(p \<bullet> x) R y"} \\
   659   @{text "\<and>"} & @{text "(p \<bullet> x) R y"} & \mbox{\it (iii)}\\
   658        \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* p"} & 
   660   @{text "\<and>"} & @{term "(p \<bullet> as) = bs"} & \mbox{\it (iv)}\\ 
   659        \mbox{\it (iv)}  & @{term "(p \<bullet> as) = bs"} \\ 
   661   \end{array}
   660   \end{array}
   662   \end{equation}
   661   \end{equation}
   663 
   662 
   664   \noindent
   663   \noindent
   665   Note that this relation depends on the permutation @{text
   664   Note that this relation depends on the permutation @{text
   675   order of abstracted atoms. If we want this, then we can define $\alpha$-equivalence 
   674   order of abstracted atoms. If we want this, then we can define $\alpha$-equivalence 
   676   for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} 
   675   for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} 
   677   as follows
   676   as follows
   678   %
   677   %
   679   \begin{equation}\label{alphalist}
   678   \begin{equation}\label{alphalist}
   680   \begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l@ {\hspace{4mm}}r}
   679   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   681   \multicolumn{2}{l}{@{term "(as, x) \<approx>lst R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   680   \multicolumn{4}{l}{@{term "(as, x) \<approx>lst R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   682              & @{term "fa(x) - (set as) = fa(y) - (set bs)"} & \mbox{\it (i)}\\
   681          \mbox{\it (i)}   & @{term "fa(x) - (set as) = fa(y) - (set bs)"} & 
   683   \wedge     & @{term "(fa(x) - set as) \<sharp>* p"} & \mbox{\it (ii)}\\
   682          \mbox{\it (iii)} & @{text "(p \<bullet> x) R y"}\\
   684   \wedge     & @{text "(p \<bullet> x) R y"} & \mbox{\it (iii)}\\
   683          \mbox{\it (ii)}  & @{term "(fa(x) - set as) \<sharp>* p"} &
   685   \wedge     & @{term "(p \<bullet> as) = bs"} & \mbox{\it (iv)}\\ 
   684          \mbox{\it (iv)}  & @{term "(p \<bullet> as) = bs"}\\
   686   \end{array}
   685   \end{array}
   687   \end{equation}
   686   \end{equation}
   688   
   687   
   689   \noindent
   688   \noindent
   690   where @{term set} is the function that coerces a list of atoms into a set of atoms.
   689   where @{term set} is the function that coerces a list of atoms into a set of atoms.
   694   If we do not want to make any difference between the order of binders \emph{and}
   693   If we do not want to make any difference between the order of binders \emph{and}
   695   also allow vacuous binders, then we keep sets of binders, but drop the fourth 
   694   also allow vacuous binders, then we keep sets of binders, but drop the fourth 
   696   condition in \eqref{alphaset}:
   695   condition in \eqref{alphaset}:
   697   %
   696   %
   698   \begin{equation}\label{alphares}
   697   \begin{equation}\label{alphares}
   699   \begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l@ {\hspace{4mm}}r}
   698   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   700   \multicolumn{2}{l}{@{term "(as, x) \<approx>res R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   699   \multicolumn{2}{l}{@{term "(as, x) \<approx>res R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   701              & @{term "fa(x) - as = fa(y) - bs"} & \mbox{\it (i)}\\
   700              \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"} & 
   702   \wedge     & @{term "(fa(x) - as) \<sharp>* p"} & \mbox{\it (ii)}\\
   701              \mbox{\it (iii)} & @{text "(p \<bullet> x) R y"}\\
   703   \wedge     & @{text "(p \<bullet> x) R y"} & \mbox{\it (iii)}\\
   702              \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* p"}\\
   704   \end{array}
   703   \end{array}
   705   \end{equation}
   704   \end{equation}
   706 
   705 
   707   It might be useful to consider first some examples about how these definitions
   706   It might be useful to consider first some examples about how these definitions
   708   of $\alpha$-equivalence pan out in practice.  For this consider the case of
   707   of $\alpha$-equivalence pan out in practice.  For this consider the case of
   778   call the types \emph{abstraction types} and their elements
   777   call the types \emph{abstraction types} and their elements
   779   \emph{abstractions}. The important property we need to derive is the support of 
   778   \emph{abstractions}. The important property we need to derive is the support of 
   780   abstractions, namely:
   779   abstractions, namely:
   781 
   780 
   782   \begin{theorem}[Support of Abstractions]\label{suppabs} 
   781   \begin{theorem}[Support of Abstractions]\label{suppabs} 
   783   Assuming @{text x} has finite support, then\\[-6mm] 
   782   Assuming @{text x} has finite support, then
   784   \begin{center}
   783 
   785   \begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
   784   \begin{center}
   786   @{thm (lhs) supp_Abs(1)[no_vars]} & $=$ & @{thm (rhs) supp_Abs(1)[no_vars]}\\
   785   \begin{tabular}{l}
   787   @{thm (lhs) supp_Abs(2)[no_vars]} & $=$ & @{thm (rhs) supp_Abs(2)[no_vars]}\\
   786   @{thm (lhs) supp_Abs(1)[no_vars]} $=$
   788   @{thm (lhs) supp_Abs(3)[where bs="as", no_vars]} & $=$ & @{thm (rhs) supp_Abs(3)[where bs="as", no_vars]}
   787   @{thm supp_Abs(2)[no_vars]}, and\\
       
   788   @{thm supp_Abs(3)[where bs="as", no_vars]}
   789   \end{tabular}
   789   \end{tabular}
   790   \end{center}
   790   \end{center}
   791   \end{theorem}
   791   \end{theorem}
   792 
   792 
   793   \noindent
   793   \noindent
   794   Below we will show the first equation. The others 
   794   This theorem states that the bound names do not appear in the support, as expected.
   795   follow by similar arguments. By definition of the abstraction type @{text "abs_set"} 
   795   For brevity we omit the proof of this resul and again refer the reader to
   796   we have 
   796   our formalisation in Isabelle/HOL.
   797   %
   797 
   798   \begin{equation}\label{abseqiff}
   798   %\noindent
   799   @{thm (lhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} \;\;\text{if and only if}\;\; 
   799   %Below we will show the first equation. The others 
   800   @{thm (rhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]}
   800   %follow by similar arguments. By definition of the abstraction type @{text "abs_set"} 
   801   \end{equation}
   801   %we have 
   802 
   802   %%
   803   \noindent
   803   %\begin{equation}\label{abseqiff}
   804   and also
   804   %@{thm (lhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} \;\;\text{if and only if}\;\; 
   805   %
   805   %@{thm (rhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]}
   806   \begin{equation}\label{absperm}
   806   %\end{equation}
   807   @{thm permute_Abs[no_vars]}
   807   %
   808   \end{equation}
   808   %\noindent
   809 
   809   %and also
   810   \noindent
   810   %
   811   The second fact derives from the definition of permutations acting on pairs 
   811   %\begin{equation}\label{absperm}
   812   \eqref{permute} and $\alpha$-equivalence being equivariant 
   812   %%@%{%thm %permute_Abs[no_vars]}%
   813   (see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   813   %\end{equation}
   814   the following lemma about swapping two atoms in an abstraction.
   814 
   815   
   815   %\noindent
   816   \begin{lemma}
   816   %The second fact derives from the definition of permutations acting on pairs 
   817   @{thm[mode=IfThen] Abs_swap1(1)[where bs="as", no_vars]}
   817   %\eqref{permute} and $\alpha$-equivalence being equivariant 
   818   \end{lemma}
   818   %(see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   819 
   819   %the following lemma about swapping two atoms in an abstraction.
   820   \begin{proof}
   820   %
   821   This lemma is straightforward using \eqref{abseqiff} and observing that
   821   %\begin{lemma}
   822   the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   822   %@{thm[mode=IfThen] Abs_swap1(1)[where bs="as", no_vars]}
   823   Moreover @{text supp} and set difference are equivariant (see \cite{HuffmanUrban10}).
   823   %\end{lemma}
   824   \end{proof}
   824   %
   825 
   825   %\begin{proof}
   826   \noindent
   826   %This lemma is straightforward using \eqref{abseqiff} and observing that
   827   Assuming that @{text "x"} has finite support, this lemma together 
   827   %the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   828   with \eqref{absperm} allows us to show
   828   %Moreover @{text supp} and set difference are equivariant (see \cite{HuffmanUrban10}).
   829   %
   829   %\end{proof}
   830   \begin{equation}\label{halfone}
   830   %
   831   @{thm Abs_supports(1)[no_vars]}
   831   %\noindent
   832   \end{equation}
   832   %Assuming that @{text "x"} has finite support, this lemma together 
   833   
   833   %with \eqref{absperm} allows us to show
   834   \noindent
   834   %
   835   which by Property~\ref{supportsprop} gives us ``one half'' of
   835   %\begin{equation}\label{halfone}
   836   Theorem~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   836   %@{thm Abs_supports(1)[no_vars]}
   837   it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   837   %\end{equation}
   838   function @{text aux}, taking an abstraction as argument:
   838   %
   839   %
   839   %\noindent
   840   \begin{center}
   840   %which by Property~\ref{supportsprop} gives us ``one half'' of
   841   @{thm supp_set.simps[THEN eq_reflection, no_vars]}
   841   %Theorem~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   842   \end{center}
   842   %it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   843   
   843   %function @{text aux}, taking an abstraction as argument:
   844   \noindent
   844   %@{thm supp_set.simps[THEN eq_reflection, no_vars]}.
   845   Using the second equation in \eqref{equivariance}, we can show that 
   845   %
   846   @{text "aux"} is equivariant (since @{term "p \<bullet> (supp x - as) =
   846   %Using the second equation in \eqref{equivariance}, we can show that 
   847   (supp (p \<bullet> x)) - (p \<bullet> as)"}) and therefore has empty support. 
   847   %@{text "aux"} is equivariant (since @{term "p \<bullet> (supp x - as) = (supp (p \<bullet> x)) - (p \<bullet> as)"}) 
   848   This in turn means
   848   %and therefore has empty support. 
   849   %
   849   %This in turn means
   850   \begin{center}
   850   %
   851   @{term "supp (supp_gen (Abs_set as x)) \<subseteq> supp (Abs_set as x)"}
   851   %\begin{center}
   852   \end{center}
   852   %@{term "supp (supp_gen (Abs_set as x)) \<subseteq> supp (Abs_set as x)"}
   853 
   853   %\end{center}
   854   \noindent
   854   %
   855   using \eqref{suppfun}. Assuming @{term "supp x - as"} is a finite set,
   855   %\noindent
   856   we further obtain
   856   %using \eqref{suppfun}. Assuming @{term "supp x - as"} is a finite set,
   857   %
   857   %we further obtain
   858   \begin{equation}\label{halftwo}
   858   %
   859   @{thm (concl) Abs_supp_subset1(1)[no_vars]}
   859   %\begin{equation}\label{halftwo}
   860   \end{equation}
   860   %@{thm (concl) Abs_supp_subset1(1)[no_vars]}
   861 
   861   %\end{equation}
   862   \noindent
   862   %
   863   since for finite sets of atoms, @{text "bs"}, we have 
   863   %\noindent
   864   @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}.
   864   %since for finite sets of atoms, @{text "bs"}, we have 
   865   Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes 
   865   %@{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}.
   866   Theorem~\ref{suppabs}. 
   866   %Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes 
       
   867   %Theorem~\ref{suppabs}. 
   867 
   868 
   868   The method of first considering abstractions of the
   869   The method of first considering abstractions of the
   869   form @{term "Abs_set as x"} etc is motivated by the fact that 
   870   form @{term "Abs_set as x"} etc is motivated by the fact that 
   870   we can conveniently establish  at the Isabelle/HOL level
   871   we can conveniently establish  at the Isabelle/HOL level
   871   properties about them.  It would be
   872   properties about them.  It would be
   884   "ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"}, and an associated collection of
   885   "ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"}, and an associated collection of
   885   binding functions, say @{text "bn\<AL>\<^isub>1, \<dots>, bn\<AL>\<^isub>m"}. The
   886   binding functions, say @{text "bn\<AL>\<^isub>1, \<dots>, bn\<AL>\<^isub>m"}. The
   886   syntax in Nominal Isabelle for such specifications is roughly as follows:
   887   syntax in Nominal Isabelle for such specifications is roughly as follows:
   887   %
   888   %
   888   \begin{equation}\label{scheme}
   889   \begin{equation}\label{scheme}
   889   \mbox{\begin{tabular}{@ {\hspace{-5mm}}p{1.8cm}l}
   890   \mbox{\begin{tabular}{@ {}p{2.5cm}l}
   890   type \mbox{declaration part} &
   891   type \mbox{declaration part} &
   891   $\begin{cases}
   892   $\begin{cases}
   892   \mbox{\begin{tabular}{l}
   893   \mbox{\begin{tabular}{l}
   893   \isacommand{nominal\_datatype} @{text "ty\<AL>\<^isub>1 = \<dots>"}\\
   894   \isacommand{nominal\_datatype} @{text "ty\<AL>\<^isub>1 = \<dots>"}\\
   894   \isacommand{and} @{text "ty\<AL>\<^isub>2 = \<dots>"}\\
   895   \isacommand{and} @{text "ty\<AL>\<^isub>2 = \<dots>"}\\
   985   single name is bound, and type-schemes, where a finite set of names is
   986   single name is bound, and type-schemes, where a finite set of names is
   986   bound:
   987   bound:
   987 
   988 
   988 
   989 
   989   \begin{center}
   990   \begin{center}
   990   \begin{tabular}{@ {}cc@ {}}
   991   \begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}}
   991   \begin{tabular}{@ {}l@ {\hspace{-2mm}}}
   992   \begin{tabular}{@ {}l}
   992   \isacommand{nominal\_datatype} @{text lam} $=$\\
   993   \isacommand{nominal\_datatype} @{text lam} $=$\\
   993   \hspace{5mm}\phantom{$\mid$}~@{text "Var name"}\\
   994   \hspace{5mm}\phantom{$\mid$}~@{text "Var name"}\\
   994   \hspace{5mm}$\mid$~@{text "App lam lam"}\\
   995   \hspace{5mm}$\mid$~@{text "App lam lam"}\\
   995   \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}\\
   996   \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}\\
   996   \hspace{21mm}\isacommand{bind} @{text x} \isacommand{in} @{text t}\\
   997   \hspace{21mm}\isacommand{bind} @{text x} \isacommand{in} @{text t}\\
  1208   \begin{equation}\label{fvars}
  1209   \begin{equation}\label{fvars}
  1209   @{text "fa_ty\<^isub>1, \<dots>, fa_ty\<^isub>n"}
  1210   @{text "fa_ty\<^isub>1, \<dots>, fa_ty\<^isub>n"}
  1210   \end{equation}
  1211   \end{equation}
  1211 
  1212 
  1212   \noindent
  1213   \noindent
  1213   by mutual recursion.
  1214   by recursion.
  1214   We define these functions together with auxiliary free-atom functions for
  1215   We define these functions together with auxiliary free-atom functions for
  1215   the binding functions. Given raw binding functions @{text "bn"}$_{1..m}$ 
  1216   the binding functions. Given raw binding functions @{text "bn"}$_{1..m}$ 
  1216   we define
  1217   we define
  1217   %
  1218   %
  1218   \begin{center}
  1219   \begin{center}
  1807   by first lifting definitions from the raw level to the quotient level and
  1808   by first lifting definitions from the raw level to the quotient level and
  1808   then by establishing facts about these lifted definitions. All necessary proofs
  1809   then by establishing facts about these lifted definitions. All necessary proofs
  1809   are generated automatically by custom ML-code. This code can deal with 
  1810   are generated automatically by custom ML-code. This code can deal with 
  1810   specifications such as the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1811   specifications such as the one shown in Figure~\ref{nominalcorehas} for Core-Haskell.  
  1811 
  1812 
  1812   \begin{figure}[t!]
  1813   %\begin{figure}[t!]
  1813   \begin{boxedminipage}{\linewidth}
  1814   %\begin{boxedminipage}{\linewidth}
  1814   \small
  1815   %\small
  1815   \begin{tabular}{l}
  1816   %\begin{tabular}{l}
  1816   \isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm]
  1817   %\isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm]
  1817   \isacommand{nominal\_datatype}~@{text "tkind ="}\\
  1818   %\isacommand{nominal\_datatype}~@{text "tkind ="}\\
  1818   \phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ 
  1819   %\phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ 
  1819   \isacommand{and}~@{text "ckind ="}\\
  1820   %\isacommand{and}~@{text "ckind ="}\\
  1820   \phantom{$|$}~@{text "CKSim ty ty"}\\
  1821   %\phantom{$|$}~@{text "CKSim ty ty"}\\
  1821   \isacommand{and}~@{text "ty ="}\\
  1822   %\isacommand{and}~@{text "ty ="}\\
  1822   \phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\
  1823   %\phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\
  1823   $|$~@{text "TFun string ty_list"}~%
  1824   %$|$~@{text "TFun string ty_list"}~%
  1824   $|$~@{text "TAll tv::tvar tkind ty::ty"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text ty}\\
  1825   %$|$~@{text "TAll tv::tvar tkind ty::ty"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text ty}\\
  1825   $|$~@{text "TArr ckind ty"}\\
  1826   %$|$~@{text "TArr ckind ty"}\\
  1826   \isacommand{and}~@{text "ty_lst ="}\\
  1827   %\isacommand{and}~@{text "ty_lst ="}\\
  1827   \phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\
  1828   %\phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\
  1828   \isacommand{and}~@{text "cty ="}\\
  1829   %\isacommand{and}~@{text "cty ="}\\
  1829   \phantom{$|$}~@{text "CVar cvar"}~%
  1830   %\phantom{$|$}~@{text "CVar cvar"}~%
  1830   $|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\
  1831   %$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\
  1831   $|$~@{text "CAll cv::cvar ckind cty::cty"}  \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text cty}\\
  1832   %$|$~@{text "CAll cv::cvar ckind cty::cty"}  \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text cty}\\
  1832   $|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\
  1833   %$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\
  1833   $|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\
  1834   %$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\
  1834   $|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\
  1835   %$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\
  1835   \isacommand{and}~@{text "co_lst ="}\\
  1836   %\isacommand{and}~@{text "co_lst ="}\\
  1836   \phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\
  1837   %\phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\
  1837   \isacommand{and}~@{text "trm ="}\\
  1838   %\isacommand{and}~@{text "trm ="}\\
  1838   \phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\
  1839   %\phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\
  1839   $|$~@{text "LAM_ty tv::tvar tkind t::trm"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\
  1840   %$|$~@{text "LAM_ty tv::tvar tkind t::trm"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\
  1840   $|$~@{text "LAM_cty cv::cvar ckind t::trm"}   \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\
  1841   %$|$~@{text "LAM_cty cv::cvar ckind t::trm"}   \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\
  1841   $|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\
  1842   %$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\
  1842   $|$~@{text "Lam v::var ty t::trm"}  \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\
  1843   %$|$~@{text "Lam v::var ty t::trm"}  \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\
  1843   $|$~@{text "Let x::var ty trm t::trm"}  \isacommand{bind}~@{text x}~\isacommand{in}~@{text t}\\
  1844   %$|$~@{text "Let x::var ty trm t::trm"}  \isacommand{bind}~@{text x}~\isacommand{in}~@{text t}\\
  1844   $|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\
  1845   %$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\
  1845   \isacommand{and}~@{text "assoc_lst ="}\\
  1846   %\isacommand{and}~@{text "assoc_lst ="}\\
  1846   \phantom{$|$}~@{text ANil}~%
  1847   %\phantom{$|$}~@{text ANil}~%
  1847   $|$~@{text "ACons p::pat t::trm assoc_lst"}  \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\
  1848   %$|$~@{text "ACons p::pat t::trm assoc_lst"}  \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\
  1848   \isacommand{and}~@{text "pat ="}\\
  1849   %\isacommand{and}~@{text "pat ="}\\
  1849   \phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  1850   %\phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  1850   \isacommand{and}~@{text "vt_lst ="}\\
  1851   %\isacommand{and}~@{text "vt_lst ="}\\
  1851   \phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  1852   %\phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  1852   \isacommand{and}~@{text "tvtk_lst ="}\\
  1853   %\isacommand{and}~@{text "tvtk_lst ="}\\
  1853   \phantom{$|$}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\
  1854   %\phantom{$|$}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\
  1854   \isacommand{and}~@{text "tvck_lst ="}\\ 
  1855   %\isacommand{and}~@{text "tvck_lst ="}\\ 
  1855   \phantom{$|$}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\
  1856   %\phantom{$|$}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\
  1856   \isacommand{binder}\\
  1857   %\isacommand{binder}\\
  1857   @{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}~%
  1858   %@{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}~%
  1858   @{text "bv1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  1859   %@{text "bv1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\
  1859   @{text "bv2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}~%
  1860   %@{text "bv2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}~%
  1860   @{text "bv3 :: tvck_lst \<Rightarrow> atom list"}\\
  1861   %@{text "bv3 :: tvck_lst \<Rightarrow> atom list"}\\
  1861   \isacommand{where}\\
  1862   %\isacommand{where}\\
  1862   \phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv3 tvts) @ (bv2 tvcs) @ (bv1 vs)"}\\
  1863   %\phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv3 tvts) @ (bv2 tvcs) @ (bv1 vs)"}\\
  1863   $|$~@{text "bv1 VTNil = []"}\\
  1864   %$|$~@{text "bv1 VTNil = []"}\\
  1864   $|$~@{text "bv1 (VTCons x ty tl) = (atom x)::(bv1 tl)"}\\
  1865   %$|$~@{text "bv1 (VTCons x ty tl) = (atom x)::(bv1 tl)"}\\
  1865   $|$~@{text "bv2 TVTKNil = []"}\\
  1866   %$|$~@{text "bv2 TVTKNil = []"}\\
  1866   $|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\
  1867   %$|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\
  1867   $|$~@{text "bv3 TVCKNil = []"}\\
  1868   %$|$~@{text "bv3 TVCKNil = []"}\\
  1868   $|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\
  1869   %$|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\
  1869   \end{tabular}
  1870   %\end{tabular}
  1870   \end{boxedminipage}
  1871   %\end{boxedminipage}
  1871   \caption{The nominal datatype declaration for Core-Haskell. For the moment we
  1872   %\caption{The nominal datatype declaration for Core-Haskell. For the moment we
  1872   do not support nested types; therefore we explicitly have to unfold the 
  1873   %do not support nested types; therefore we explicitly have to unfold the 
  1873   lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved
  1874   %lists @{text "co_lst"}, @{text "assoc_lst"} and so on. This will be improved
  1874   in a future version of Nominal Isabelle. Apart from that, the 
  1875   %in a future version of Nominal Isabelle. Apart from that, the 
  1875   declaration follows closely the original in Figure~\ref{corehas}. The
  1876   %declaration follows closely the original in Figure~\ref{corehas}. The
  1876   point of our work is that having made such a declaration in Nominal Isabelle,
  1877   %point of our work is that having made such a declaration in Nominal Isabelle,
  1877   one obtains automatically a reasoning infrastructure for Core-Haskell.
  1878   %one obtains automatically a reasoning infrastructure for Core-Haskell.
  1878   \label{nominalcorehas}}
  1879   %\label{nominalcorehas}}
  1879   \end{figure}
  1880   %\end{figure}
  1880 *}
  1881 *}
  1881 
  1882 
  1882 
  1883 
  1883 section {* Strong Induction Principles *}
  1884 section {* Strong Induction Principles *}
  1884 
  1885