LMCS-Paper/Paper.thy
changeset 3001 8d7d85e915b5
parent 3000 3c8d3aaf292c
child 3002 02d98590454d
equal deleted inserted replaced
3000:3c8d3aaf292c 3001:8d7d85e915b5
    99   because also there one would like to bind multiple variables at once.
    99   because 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 below the first pair of type-schemes as alpha-equivalent,
   104   we would like to regard in \eqref{ex1} below  the first pair of type-schemes as alpha-equivalent,
   105   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   105   but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
   106   the second pair should \emph{not} be alpha-equivalent:
   106   the second pair should \emph{not} be alpha-equivalent:
   107 
   107 
   108   \begin{equation}\label{ex1}
   108   \begin{equation}\label{ex1}
   109   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm}
   109   @{text "\<forall>{x, y}. x \<rightarrow> y  \<approx>\<^isub>\<alpha>  \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm}
   376   from the Ott-tool, but we introduce crucial restrictions, and also extensions, so 
   376   from the Ott-tool, but we introduce crucial restrictions, and also extensions, so 
   377   that our specifications make sense for reasoning about alpha-equated terms.  
   377   that our specifications make sense for reasoning about alpha-equated terms.  
   378   The main improvement over Ott is that we introduce three binding modes
   378   The main improvement over Ott is that we introduce three binding modes
   379   (only one is present in Ott), provide formalised definitions for alpha-equivalence and 
   379   (only one is present in Ott), provide formalised definitions for alpha-equivalence and 
   380   for free variables of our terms, and also derive a reasoning infrastructure
   380   for free variables of our terms, and also derive a reasoning infrastructure
   381   for our specifications from ``first principles''.
   381   for our specifications from ``first principles'' inside a theorem prover.
   382 
   382 
   383 
   383 
   384   \begin{figure}
   384   \begin{figure}
   385   \begin{boxedminipage}{\linewidth}
   385   \begin{boxedminipage}{\linewidth}
   386   \begin{center}
   386   \begin{center}
   429   Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in
   429   Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in
   430   \cite{HuffmanUrban10} (including proofs). We shall briefly review this work
   430   \cite{HuffmanUrban10} (including proofs). We shall briefly review this work
   431   to aid the description of what follows. 
   431   to aid the description of what follows. 
   432 
   432 
   433   Two central notions in the nominal logic work are sorted atoms and
   433   Two central notions in the nominal logic work are sorted atoms and
   434   sort-respecting permutations of atoms. We will use the letters @{text "a,
   434   sort-respecting permutations of atoms. We will use the letters @{text "a, b,
   435   b, c, \<dots>"} to stand for atoms and @{text "\<pi>, \<dots>"} to stand for
   435   c, \<dots>"} to stand for atoms and @{text "\<pi>, \<dots>"} to stand for permutations,
   436   permutations. The purpose of atoms is to represent variables, be they bound or free. 
   436   which in Nominal Isabelle have type @{typ perm}. The purpose of atoms is to
   437   The sorts of atoms can be used to represent different kinds of
   437   represent variables, be they bound or free. The sorts of atoms can be used
   438   variables, such as the term-, coercion- and type-variables in Core-Haskell.
   438   to represent different kinds of variables, such as the term-, coercion- and
   439   It is assumed that there is an infinite supply of atoms for each
   439   type-variables in Core-Haskell.  It is assumed that there is an infinite
   440   sort. In the interest of brevity, we shall restrict ourselves 
   440   supply of atoms for each sort. In the interest of brevity, we shall restrict
   441   in what follows to only one sort of atoms.
   441   ourselves in what follows to only one sort of atoms.
   442 
   442 
   443   Permutations are bijective functions from atoms to atoms that are 
   443   Permutations are bijective functions from atoms to atoms that are 
   444   the identity everywhere except on a finite number of atoms. There is a 
   444   the identity everywhere except on a finite number of atoms. There is a 
   445   two-place permutation operation written
   445   two-place permutation operation written
   446   @{text "_ \<bullet> _  ::  perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"}
   446   @{text "_ \<bullet> _  ::  perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"}
   485   permutation operation and on the notion of equality defined for the type of
   485   permutation operation and on the notion of equality defined for the type of
   486   @{text x}, namely:
   486   @{text x}, namely:
   487   
   487   
   488   \begin{equation}\label{suppdef}
   488   \begin{equation}\label{suppdef}
   489   @{thm supp_def[no_vars, THEN eq_reflection]}
   489   @{thm supp_def[no_vars, THEN eq_reflection]}
   490   \end{equation}
   490   \end{equation}\smallskip
   491 
   491 
   492   \noindent
   492   \noindent
   493   There is also the derived notion for when an atom @{text a} is \emph{fresh}
   493   There is also the derived notion for when an atom @{text a} is \emph{fresh}
   494   for an @{text x}, defined as 
   494   for an @{text x}, defined as 
   495 
   495 
   506   swapping two fresh atoms, say @{text a} and @{text b}, leaves 
   506   swapping two fresh atoms, say @{text a} and @{text b}, leaves 
   507   @{text x} unchanged, namely 
   507   @{text x} unchanged, namely 
   508   
   508   
   509   \begin{prop}\label{swapfreshfresh}
   509   \begin{prop}\label{swapfreshfresh}
   510   If @{thm (prem 1) swap_fresh_fresh[no_vars]} and @{thm (prem 2) swap_fresh_fresh[no_vars]}
   510   If @{thm (prem 1) swap_fresh_fresh[no_vars]} and @{thm (prem 2) swap_fresh_fresh[no_vars]}
   511   then @{thm (concl) swap_fresh_fresh[no_vars]}
   511   then @{thm (concl) swap_fresh_fresh[no_vars]}.
   512   \end{prop}
   512   \end{prop}
   513   
   513   
   514   While often the support of an object can be relatively easily 
   514   While often the support of an object can be relatively easily 
   515   described, for example for atoms, products, lists, function applications, 
   515   described, for example for atoms, products, lists, function applications, 
   516   booleans and permutations as follows
   516   booleans and permutations as follows
   537   only an approximation can be established (as for function applications
   537   only an approximation can be established (as for function applications
   538   above). Reasoning about such approximations can be simplified with the
   538   above). Reasoning about such approximations can be simplified with the
   539   notion \emph{supports}, defined as follows:
   539   notion \emph{supports}, defined as follows:
   540   
   540   
   541   \begin{defi}
   541   \begin{defi}
   542   A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b}
   542   A set @{text S} \emph{supports} @{text x}, if for all atoms @{text a} and @{text b}
   543   not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}.
   543   not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}.
   544   \end{defi}
   544   \end{defi}
   545   
   545   
   546   \noindent
   546   \noindent
   547   The main point of @{text supports} is that we can establish the following 
   547   The main point of @{text supports} is that we can establish the following 
   548   two properties.
   548   two properties.
   549   
   549   
   550   \begin{prop}\label{supportsprop}
   550   \begin{prop}\label{supportsprop}
   551   Given a set @{text "as"} of atoms.
   551   Given a set @{text "as"} of atoms.\\
   552   {\it (i)} @{thm[mode=IfThen] supp_is_subset[where S="as", no_vars]}
   552   {\it (i)} If @{thm (prem 1) supp_is_subset[where S="as", no_vars]}
       
   553   and @{thm (prem 2) supp_is_subset[where S="as", no_vars]} then 
       
   554   @{thm (concl) supp_is_subset[where S="as", no_vars]}.\\
   553   {\it (ii)} @{thm supp_supports[no_vars]}.
   555   {\it (ii)} @{thm supp_supports[no_vars]}.
   554   \end{prop}
   556   \end{prop}
   555   
   557   
   556   Another important notion in the nominal logic work is \emph{equivariance}.
   558   Another important notion in the nominal logic work is \emph{equivariance}.
   557   For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant 
   559   For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant 
   558   it is required that every permutation leaves @{text f} unchanged, that is
   560   it is required that every permutation leaves @{text f} unchanged, that is
   559   
   561   
   560   \begin{equation}\label{equivariancedef}
   562   \begin{equation}\label{equivariancedef}
   561   @{term "\<forall>p. p \<bullet> f = f"}
   563   @{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}
   562   \end{equation}
   564   \end{equation}\smallskip
   563   
   565   
   564   \noindent or equivalently that a permutation applied to the application
   566   \noindent or equivalently that a permutation applied to the application
   565   @{text "f x"} can be moved to the argument @{text x}. That means for equivariant
   567   @{text "f x"} can be moved to the argument @{text x}. That means for equivariant
   566   functions @{text f}, we have for all permutations @{text p}:
   568   functions @{text f}, we have for all permutations @{text "\<pi>"}:
   567   
   569   
   568   \begin{equation}\label{equivariance}
   570   \begin{equation}\label{equivariance}
   569   @{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\;
   571   @{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\;
   570   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   572   @{text "\<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"}
   571   \end{equation}
   573   \end{equation}\smallskip
   572    
   574    
   573   \noindent
   575   \noindent
   574   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   576   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   575   can easily deduce that equivariant functions have empty support. There is
   577   can easily deduce that equivariant functions have empty support. There is
   576   also a similar notion for equivariant relations, say @{text R}, namely the property
   578   also a similar notion for equivariant relations, say @{text R}, namely the property
   577   that
   579   that
   578   
   580   
   579   \begin{center}
   581   \begin{center}
   580   @{text "x R y"} \;\;\textit{implies}\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
   582   @{text "x R y"} \;\;\textit{implies}\;\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"}
   581   \end{center}
   583   \end{center}
   582   
   584   
   583   Using freshness, the nominal logic work provides us with general means for renaming 
   585   Using freshness, the nominal logic work provides us with general means for renaming 
   584   binders. 
   586   binders. 
   585   
   587   
   586   \noindent
   588   \noindent
   587   While in the older version of Nominal Isabelle, we used extensively 
   589   While in the older version of Nominal Isabelle, we used extensively 
   588   Property~\ref{swapfreshfresh}
   590   Property~\ref{swapfreshfresh} to rename single binders, this property 
   589   this property to rename single binders, it this property 
       
   590   proved too unwieldy for dealing with multiple binders. For such binders the 
   591   proved too unwieldy for dealing with multiple binders. For such binders the 
   591   following generalisations turned out to be easier to use.
   592   following generalisations turned out to be easier to use.
   592 
   593 
   593   \begin{prop}\label{supppermeq}
   594   \begin{prop}\label{supppermeq}
   594   @{thm[mode=IfThen] supp_perm_eq[no_vars]}
   595   @{thm[mode=IfThen] supp_perm_eq[where p="\<pi>", no_vars]}
   595   \end{prop}
   596   \end{prop}
   596 
   597 
   597   \begin{prop}\label{avoiding}
   598   \begin{prop}\label{avoiding}
   598   For a finite set @{text as} and a finitely supported @{text x} with
   599   For a finite set @{text as} and a finitely supported @{text x} with
   599   @{term "as \<sharp>* x"} and also a finitely supported @{text c}, there
   600   @{term "as \<sharp>* x"} and also a finitely supported @{text c}, there
   600   exists a permutation @{text p} such that @{term "(p \<bullet> as) \<sharp>* c"} and
   601   exists a permutation @{text "\<pi>"} such that @{term "(\<pi> \<bullet> as) \<sharp>* c"} and
   601   @{term "supp x \<sharp>* p"}.
   602   @{term "supp x \<sharp>* \<pi>"}.
   602   \end{prop}
   603   \end{prop}
   603 
   604 
   604   \noindent
   605   \noindent
   605   The idea behind the second property is that given a finite set @{text as}
   606   The idea behind the second property is that given a finite set @{text as}
   606   of binders (being bound, or fresh, in @{text x} is ensured by the
   607   of binders (being bound, or fresh, in @{text x} is ensured by the
   607   assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text p} such that
   608   assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text "\<pi>"} such that
   608   the renamed binders @{term "p \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen
   609   the renamed binders @{term "\<pi> \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen
   609   as long as it is finitely supported) and also @{text "p"} does not affect anything
   610   as long as it is finitely supported) and also @{text "\<pi>"} does not affect anything
   610   in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last 
   611   in the support of @{text x} (that is @{term "supp x \<sharp>* \<pi>"}). The last 
   611   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   612   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   612   @{text as} in @{text x}, because @{term "p \<bullet> x = x"}.
   613   @{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}.
   613 
   614 
   614   Most properties given in this section are described in detail in \cite{HuffmanUrban10}
   615   Most properties given in this section are described in detail in \cite{HuffmanUrban10}
   615   and all are formalised in Isabelle/HOL. In the next sections we will make 
   616   and all are formalised in Isabelle/HOL. In the next sections we will make 
   616   extensive use of these properties in order to define alpha-equivalence in 
   617   use of these properties in order to define alpha-equivalence in 
   617   the presence of multiple binders.
   618   the presence of multiple binders.
   618 *}
   619 *}
   619 
   620 
   620 
   621 
   621 section {* General Bindings\label{sec:binders} *}
   622 section {* General Bindings\label{sec:binders} *}
   626   from this specification (remember that Nominal Isabelle is a definitional
   627   from this specification (remember that Nominal Isabelle is a definitional
   627   extension of Isabelle/HOL, which does not introduce any new axioms).
   628   extension of Isabelle/HOL, which does not introduce any new axioms).
   628 
   629 
   629   In order to keep our work with deriving the reasoning infrastructure
   630   In order to keep our work with deriving the reasoning infrastructure
   630   manageable, we will wherever possible state definitions and perform proofs
   631   manageable, we will wherever possible state definitions and perform proofs
   631   on the ``user-level'' of Isabelle/HOL, as opposed to write custom ML-code.  that
   632   on the ``user-level'' of Isabelle/HOL, as opposed to write custom ML-code that
   632   generates them anew for each specification. 
   633   generates them anew for each specification. 
   633   To that end, we will consider
   634   To that end, we will consider
   634   first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}.  These pairs
   635   first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}.  These pairs
   635   are intended to represent the abstraction, or binding, of the set of atoms @{text
   636   are intended to represent the abstraction, or binding, of the set of atoms @{text
   636   "as"} in the body @{text "x"}.
   637   "as"} in the body @{text "x"}.
   639   @{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in
   640   @{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in
   640   the notion of alpha-equivalence that is \emph{not} preserved by adding
   641   the notion of alpha-equivalence that is \emph{not} preserved by adding
   641   vacuous binders.) To answer this question, we identify four conditions: {\it (i)}
   642   vacuous binders.) To answer this question, we identify four conditions: {\it (i)}
   642   given a free-atom function @{text "fa"} of type \mbox{@{text "\<beta> \<Rightarrow> atom
   643   given a free-atom function @{text "fa"} of type \mbox{@{text "\<beta> \<Rightarrow> atom
   643   set"}}, then @{text x} and @{text y} need to have the same set of free
   644   set"}}, then @{text x} and @{text y} need to have the same set of free
   644   atoms; moreover there must be a permutation @{text p} such that {\it
   645   atoms; moreover there must be a permutation @{text \<pi>} such that {\it
   645   (ii)} @{text p} leaves the free atoms of @{text x} and @{text y} unchanged, but
   646   (ii)} @{text \<pi>} leaves the free atoms of @{text x} and @{text y} unchanged, but
   646   {\it (iii)} ``moves'' their bound names so that we obtain modulo a relation,
   647   {\it (iii)} ``moves'' their bound names so that we obtain modulo a relation,
   647   say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)}
   648   say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)}
   648   @{text p} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The
   649   @{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The
   649   requirements {\it (i)} to {\it (iv)} can be stated formally as the conjunction of:
   650   requirements {\it (i)} to {\it (iv)} can be stated formally as the conjunction of:
   650   %
   651 
   651   \begin{equation}\label{alphaset}
   652   \begin{defi}[Alpha-Equivalence for Set-Bindings]\label{alphaset}\mbox{}\\
   652   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   653   \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}  
   653   \multicolumn{4}{l}{@{term "(as, x) \<approx>set R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   654   @{term "(as, x) \<approx>set R fa \<pi> (bs, y)"}\hspace{2mm}@{text "\<equiv>"} 
   654        \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"} &
   655        & \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"}\\
   655        \mbox{\it (iii)} &  @{text "(p \<bullet> x) R y"} \\
   656        & \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\
   656        \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* p"} & 
   657        & \mbox{\it (iii)} &  @{text "(\<pi> \<bullet> x) R y"} \\
   657        \mbox{\it (iv)}  & @{term "(p \<bullet> as) = bs"} \\ 
   658        & \mbox{\it (iv)}  & @{term "(\<pi> \<bullet> as) = bs"} \\ 
   658   \end{array}
   659   \end{tabular}
   659   \end{equation}
   660   \end{defi}
   660   %
   661  
   661   \noindent
   662   \noindent
   662   Note that this relation depends on the permutation @{text
   663   Note that this relation depends on the permutation @{text
   663   "p"}; alpha-equivalence between two pairs is then the relation where we
   664   "\<pi>"}; alpha-equivalence between two pairs is then the relation where we
   664   existentially quantify over this @{text "p"}. Also note that the relation is
   665   existentially quantify over this @{text "\<pi>"}. Also note that the relation is
   665   dependent on a free-atom function @{text "fa"} and a relation @{text
   666   dependent on a free-atom function @{text "fa"} and a relation @{text
   666   "R"}. The reason for this extra generality is that we will use
   667   "R"}. The reason for this extra generality is that we will use
   667   $\approx_{\,\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In
   668   $\approx_{\,\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In
   668   the latter case, @{text R} will be replaced by equality @{text "="} and we
   669   the latter case, @{text R} will be replaced by equality @{text "="} and we
   669   will prove that @{text "fa"} is equal to @{text "supp"}.
   670   will prove that @{text "fa"} is equal to @{text "supp"}.
   670 
   671 
   671   The definition in \eqref{alphaset} does not make any distinction between the
   672   Definition \ref{alphaset} does not make any distinction between the
   672   order of abstracted atoms. If we want this, then we can define alpha-equivalence 
   673   order of abstracted atoms. If we want this, then we can define alpha-equivalence 
   673   for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} 
   674   for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} 
   674   as follows
   675   as follows
   675   %
   676   
   676   \begin{equation}\label{alphalist}
   677   \begin{defi}[Alpha-Equivalence for List-Bindings]\label{alphalist}\mbox{}\\
   677   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   678   \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}  
   678   \multicolumn{4}{l}{@{term "(as, x) \<approx>lst R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   679   @{term "(as, x) \<approx>lst R fa \<pi> (bs, y)"}\hspace{2mm}@{text "\<equiv>"}
   679          \mbox{\it (i)}   & @{term "fa(x) - (set as) = fa(y) - (set bs)"} & 
   680          & \mbox{\it (i)}   & @{term "fa(x) - (set as) = fa(y) - (set bs)"}\\ 
   680          \mbox{\it (iii)} & @{text "(p \<bullet> x) R y"}\\
   681          & \mbox{\it (ii)}  & @{term "(fa(x) - set as) \<sharp>* \<pi>"}\\
   681          \mbox{\it (ii)}  & @{term "(fa(x) - set as) \<sharp>* p"} &
   682          & \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"}\\
   682          \mbox{\it (iv)}  & @{term "(p \<bullet> as) = bs"}\\
   683          & \mbox{\it (iv)}  & @{term "(\<pi> \<bullet> as) = bs"}\\
   683   \end{array}
   684   \end{tabular}
   684   \end{equation}
   685   \end{defi}
   685   %
   686   
   686   \noindent
   687   \noindent
   687   where @{term set} is the function that coerces a list of atoms into a set of atoms.
   688   where @{term set} is the function that coerces a list of atoms into a set of atoms.
   688   Now the last clause ensures that the order of the binders matters (since @{text as}
   689   Now the last clause ensures that the order of the binders matters (since @{text as}
   689   and @{text bs} are lists of atoms).
   690   and @{text bs} are lists of atoms).
   690 
   691 
   691   If we do not want to make any difference between the order of binders \emph{and}
   692   If we do not want to make any difference between the order of binders \emph{and}
   692   also allow vacuous binders, that means \emph{restrict} names, then we keep sets of binders, but drop 
   693   also allow vacuous binders, that means \emph{restrict} names, then we keep sets of binders, but drop 
   693   condition {\it (iv)} in \eqref{alphaset}:
   694   condition {\it (iv)} in Definition~\ref{alphaset}:
   694   %
   695 
   695   \begin{equation}\label{alphares}
   696   \begin{defi}[Alpha-Equivalence for Set+-Bindings]\label{alphares}\mbox{}\\
   696   \begin{array}{@ {\hspace{10mm}}l@ {\hspace{5mm}}l@ {\hspace{10mm}}l@ {\hspace{5mm}}l}
   697   \begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}  
   697   \multicolumn{2}{l}{@{term "(as, x) \<approx>res R fa p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}}\\[1mm]
   698   @{term "(as, x) \<approx>res R fa \<pi> (bs, y)"}\hspace{2mm}@{text "\<equiv>"}
   698              \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"} & 
   699              & \mbox{\it (i)}   & @{term "fa(x) - as = fa(y) - bs"}\\
   699              \mbox{\it (iii)} & @{text "(p \<bullet> x) R y"}\\
   700              & \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\
   700              \mbox{\it (ii)}  & @{term "(fa(x) - as) \<sharp>* p"}\\
   701              & \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"}\\
   701   \end{array}
   702   \end{tabular}
   702   \end{equation}
   703   \end{defi}
       
   704 
   703 
   705 
   704   It might be useful to consider first some examples how these definitions
   706   It might be useful to consider first some examples how these definitions
   705   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
   706   abstracting a set of atoms over types (as in type-schemes). We set
   708   abstracting a set of atoms over types (as in type-schemes). We set
   707   @{text R} to be the usual equality @{text "="} and for @{text "fa(T)"} we
   709   @{text R} to be the usual equality @{text "="} and for @{text "fa(T)"} we
   708   define
   710   define
   709   %
   711   
   710   \begin{center}
   712   \[
   711   @{text "fa(x) = {x}"}  \hspace{5mm} @{text "fa(T\<^isub>1 \<rightarrow> T\<^isub>2) = fa(T\<^isub>1) \<union> fa(T\<^isub>2)"}
   713   @{text "fa(x) = {x}"}  \hspace{5mm} @{text "fa(T\<^isub>1 \<rightarrow> T\<^isub>2) = fa(T\<^isub>1) \<union> fa(T\<^isub>2)"}
   712   \end{center}
   714   \]\smallskip
   713 
   715 
   714   \noindent
   716   \noindent
   715   Now recall the examples shown in \eqref{ex1} and
   717   Now recall the examples shown in \eqref{ex1} and
   716   \eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and
   718   \eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and
   717   @{text "({y, x}, y \<rightarrow> x)"} are alpha-equivalent according to
   719   @{text "({y, x}, y \<rightarrow> x)"} are alpha-equivalent according to
   718   $\approx_{\,\textit{set}}$ and $\approx_{\,\textit{set+}}$ by taking @{text p} to
   720   $\approx_{\,\textit{set}}$ and $\approx_{\,\textit{set+}}$ by taking @{text "\<pi>"} to
   719   be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then @{text
   721   be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then @{text
   720   "([x, y], x \<rightarrow> y)"} $\not\approx_{\,\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"}
   722   "([x, y], x \<rightarrow> y)"} $\not\approx_{\,\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"}
   721   since there is no permutation that makes the lists @{text "[x, y]"} and
   723   since there is no permutation that makes the lists @{text "[x, y]"} and
   722   @{text "[y, x]"} equal, and also leaves the type \mbox{@{text "x \<rightarrow> y"}}
   724   @{text "[y, x]"} equal, and also leaves the type \mbox{@{text "x \<rightarrow> y"}}
   723   unchanged. Another example is @{text "({x}, x)"} $\approx_{\,\textit{set+}}$
   725   unchanged. Another example is @{text "({x}, x)"} $\approx_{\,\textit{set+}}$
   724   @{text "({x, y}, x)"} which holds by taking @{text p} to be the identity
   726   @{text "({x, y}, x)"} which holds by taking @{text "\<pi>"} to be the identity
   725   permutation.  However, if @{text "x \<noteq> y"}, then @{text "({x}, x)"}
   727   permutation.  However, if @{text "x \<noteq> y"}, then @{text "({x}, x)"}
   726   $\not\approx_{\,\textit{set}}$ @{text "({x, y}, x)"} since there is no
   728   $\not\approx_{\,\textit{set}}$ @{text "({x, y}, x)"} since there is no
   727   permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal
   729   permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal
   728   (similarly for $\approx_{\,\textit{list}}$).  It can also relatively easily be
   730   (similarly for $\approx_{\,\textit{list}}$).  It can also relatively easily be
   729   shown that all three notions of alpha-equivalence coincide, if we only
   731   shown that all three notions of alpha-equivalence coincide, if we only
   730   abstract a single atom.
   732   abstract a single atom.
   731 
   733 
   732   In the rest of this section we are going to introduce three abstraction 
   734   In the rest of this section we are going to introduce three abstraction 
   733   types. For this we define 
   735   types. For this we define 
   734   %
   736 
   735   \begin{equation}
   737   \begin{equation}
   736   @{term "abs_set (as, x) (bs, x) \<equiv> \<exists>p. alpha_set (as, x) equal supp p (bs, x)"}
   738   \begin{array}{l}
       
   739   @{term "abs_set (as, x) (bs, x) \<equiv> \<exists>\<pi>. alpha_set (as, x) equal supp \<pi> (bs, x)"}\\
       
   740   @{term "abs_res (as, x) (bs, x) \<equiv> \<exists>\<pi>. alpha_res (as, x) equal supp \<pi> (bs, x)"}\\
       
   741   @{term "abs_lst (as, x) (bs, x) \<equiv> \<exists>\<pi>. alpha_lst (as, x) equal supp \<pi> (bs, x)"}\\
       
   742   \end{array}
   737   \end{equation}
   743   \end{equation}
   738   
   744   
   739   \noindent
   745   \noindent
   740   (similarly for $\approx_{\,\textit{abs\_set+}}$ 
   746   We can show that these relations are equivalence 
   741   and $\approx_{\,\textit{abs\_list}}$). We can show that these relations are equivalence 
   747   relations and equivariant.
   742   relations. %% and equivariant.
       
   743 
   748 
   744   \begin{lem}\label{alphaeq} 
   749   \begin{lem}\label{alphaeq} 
   745   The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_list}}$
   750   The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_list}}$
   746   and $\approx_{\,\textit{abs\_set+}}$ are equivalence relations. %, and if 
   751   and $\approx_{\,\textit{abs\_set+}}$ are equivalence relations. %, and if 
   747   %@{term "abs_set (as, x) (bs, y)"} then also 
   752   %@{term "abs_set (as, x) (bs, y)"} then also 
   748   %@{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} (similarly for the other two relations).
   753   %@{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} (similarly for the other two relations).
   749   \end{lem}
   754   \end{lem}
   750 
   755 
   751   \begin{proof}
   756   \begin{proof}
   752   Reflexivity is by taking @{text "p"} to be @{text "0"}. For symmetry we have
   757   Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have
   753   a permutation @{text p} and for the proof obligation take @{term "-p"}. In case 
   758   a permutation @{text p} and for the proof obligation take @{term "- \<pi>"}. In case 
   754   of transitivity, we have two permutations @{text p} and @{text q}, and for the
   759   of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} and @{text "\<pi>\<^isub>2"}, and for the
   755   proof obligation use @{text "q + p"}. All conditions are then by simple
   760   proof obligation use @{text "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. All conditions are then by simple
   756   calculations. 
   761   calculations. 
   757   \end{proof}
   762   \end{proof}
   758 
   763 
   759   \noindent
   764   \noindent
   760   This lemma allows us to use our quotient package for introducing 
   765   This lemma allows us to use our quotient package for introducing