LMCS-Paper/Paper.thy
changeset 3004 c6af56de923d
parent 3002 02d98590454d
child 3005 4df720c9b660
equal deleted inserted replaced
3002:02d98590454d 3004:c6af56de923d
   200 
   200 
   201   \[
   201   \[
   202   \mbox{\begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}ll}
   202   \mbox{\begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}ll}
   203   @{text trm} & @{text "::="}  & @{text "\<dots>"} \\
   203   @{text trm} & @{text "::="}  & @{text "\<dots>"} \\
   204               & @{text "|"}    & @{text "\<LET>  as::assn  s::trm"}\hspace{2mm} 
   204               & @{text "|"}    & @{text "\<LET>  as::assn  s::trm"}\hspace{2mm} 
   205                                  \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm]
   205                                  \isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm]
   206   @{text assn} & @{text "::="} & @{text "\<ANIL>"}\\
   206   @{text assn} & @{text "::="} & @{text "\<ANIL>"}\\
   207                &  @{text "|"}  & @{text "\<ACONS>  name  trm  assn"}
   207                &  @{text "|"}  & @{text "\<ACONS>  name  trm  assn"}
   208   \end{tabular}}
   208   \end{tabular}}
   209   \]\smallskip
   209   \]\smallskip
   210 
   210 
   220   \]\smallskip
   220   \]\smallskip
   221 
   221 
   222   \noindent
   222   \noindent
   223   The scope of the binding is indicated by labels given to the types, for
   223   The scope of the binding is indicated by labels given to the types, for
   224   example @{text "s::trm"}, and a binding clause, in this case
   224   example @{text "s::trm"}, and a binding clause, in this case
   225   \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   225   \isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   226   clause states that all the names the function @{text "bn(as)"} returns
   226   clause states that all the names the function @{text "bn(as)"} returns
   227   should be bound in @{text s}.  This style of specifying terms and bindings
   227   should be bound in @{text s}.  This style of specifying terms and bindings
   228   is heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. Our work
   228   is heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. Our work
   229   extends Ott in several aspects: one is that we support three binding
   229   extends Ott in several aspects: one is that we support three binding
   230   modes---Ott has only one, namely the one where the order of binders matters.
   230   modes---Ott has only one, namely the one where the order of binders matters.
   515   
   515   
   516   While often the support of an object can be relatively easily 
   516   While often the support of an object can be relatively easily 
   517   described, for example for atoms, products, lists, function applications, 
   517   described, for example for atoms, products, lists, function applications, 
   518   booleans and permutations as follows
   518   booleans and permutations as follows
   519   
   519   
   520   \[\mbox{
   520   \begin{equation}\label{supps}\mbox{
   521   \begin{tabular}{c@ {\hspace{10mm}}c}
   521   \begin{tabular}{c@ {\hspace{10mm}}c}
   522   \begin{tabular}{rcl}
   522   \begin{tabular}{rcl}
   523   @{term "supp a"} & $=$ & @{term "{a}"}\\
   523   @{term "supp a"} & $=$ & @{term "{a}"}\\
   524   @{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\
   524   @{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\
   525   @{term "supp []"} & $=$ & @{term "{}"}\\
   525   @{term "supp []"} & $=$ & @{term "{}"}\\
   530   @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\
   530   @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\
   531   @{term "supp b"} & $=$ & @{term "{}"}\\
   531   @{term "supp b"} & $=$ & @{term "{}"}\\
   532   @{term "supp \<pi>"} & $=$ & @{term "{a. \<pi> \<bullet> a \<noteq> a}"}
   532   @{term "supp \<pi>"} & $=$ & @{term "{a. \<pi> \<bullet> a \<noteq> a}"}
   533   \end{tabular}
   533   \end{tabular}
   534   \end{tabular}}
   534   \end{tabular}}
   535   \]\smallskip
   535   \end{equation}\smallskip
   536   
   536   
   537   \noindent 
   537   \noindent 
   538   in some cases it can be difficult to characterise the support precisely, and
   538   in some cases it can be difficult to characterise the support precisely, and
   539   only an approximation can be established (as for function applications
   539   only an approximation can be established (as for function applications
   540   above). Reasoning about such approximations can be simplified with the
   540   above). Reasoning about such approximations can be simplified with the
   611   the renamed binders @{term "\<pi> \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen
   611   the renamed binders @{term "\<pi> \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen
   612   as long as it is finitely supported) and also @{text "\<pi>"} does not affect anything
   612   as long as it is finitely supported) and also @{text "\<pi>"} does not affect anything
   613   in the support of @{text x} (that is @{term "supp x \<sharp>* \<pi>"}). The last 
   613   in the support of @{text x} (that is @{term "supp x \<sharp>* \<pi>"}). The last 
   614   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   614   fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders 
   615   @{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}. Note that @{term "supp x \<sharp>* \<pi>"}
   615   @{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}. Note that @{term "supp x \<sharp>* \<pi>"}
   616   is equivalent with @{term "supp \<pi> \<sharp>* x"}, which means we could also use the other
   616   is equivalent with @{term "supp \<pi> \<sharp>* x"}, which means we could also formulate 
   617   `direction' in Propositions \ref{supppermeq} and \ref{avoiding}.
   617   Propositions \ref{supppermeq} and \ref{avoiding} in the other `direction', however the 
       
   618   reasoning infrastructure of Nominal Isabelle is set up so that it provides more
       
   619   automation for the original formulation.
   618 
   620 
   619   Most properties given in this section are described in detail in \cite{HuffmanUrban10}
   621   Most properties given in this section are described in detail in \cite{HuffmanUrban10}
   620   and all are formalised in Isabelle/HOL. In the next sections we will make 
   622   and all are formalised in Isabelle/HOL. In the next sections we will make 
   621   use of these properties in order to define alpha-equivalence in 
   623   use of these properties in order to define alpha-equivalence in 
   622   the presence of multiple binders.
   624   the presence of multiple binders.
   751   relations and equivariant.
   753   relations and equivariant.
   752 
   754 
   753   \begin{lem}\label{alphaeq} 
   755   \begin{lem}\label{alphaeq} 
   754   The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_list}}$
   756   The relations $\approx_{\,\textit{abs\_set}}$, $\approx_{\,\textit{abs\_list}}$
   755   and $\approx_{\,\textit{abs\_set+}}$ are equivalence relations and equivariant. 
   757   and $\approx_{\,\textit{abs\_set+}}$ are equivalence relations and equivariant. 
   756   %, and if 
       
   757   %@{term "abs_set (as, x) (bs, y)"} then also 
       
   758   %@{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} (similarly for the other two relations).
       
   759   \end{lem}
   758   \end{lem}
   760 
   759 
   761   \begin{proof}
   760   \begin{proof}
   762   Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have
   761   Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have
   763   a permutation @{text "\<pi>"} and for the proof obligation take @{term "- \<pi>"}. In case 
   762   a permutation @{text "\<pi>"} and for the proof obligation take @{term "- \<pi>"}. In case 
   764   of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} and @{text "\<pi>\<^isub>2"}, and for the
   763   of transitivity, we have two permutations @{text "\<pi>\<^isub>1"} and @{text "\<pi>\<^isub>2"}, and for the
   765   proof obligation use @{text "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means
   764   proof obligation use @{text "\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means
   766   @{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} holds provided 
   765   @{term "abs_set (\<pi> \<bullet> as, \<pi> \<bullet> x) (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided 
   767   @{term "abs_set (as, x) (bs, y)"}.
   766   @{term "abs_set (as, x) (bs, y)"}. To show this, we need to unfold the
   768 
   767   definitions and `pull out' the permutations, which is possible since all
       
   768   operators, such as @{text "#\<^sup>*, -, set"} and @{text "supp"}, are equivariant
       
   769   (see \cite{HuffmanUrban10}).
   769   \end{proof}
   770   \end{proof}
   770 
   771 
   771   \noindent
   772   \noindent
   772   This lemma allows us to use our quotient package for introducing 
   773   This lemma allows us to use our quotient package for introducing 
   773   new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"}
   774   new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"}
   800   \end{array}
   801   \end{array}
   801   \]\smallskip
   802   \]\smallskip
   802   \end{thm}
   803   \end{thm}
   803 
   804 
   804   \noindent
   805   \noindent
   805   This theorem states that the bound names do not appear in the support.
   806   In effect, this theorem states that the bound names do not appear in the support
   806   Below we will show the first equation. The others follow by similar
   807   of abstractions. This can be seen as test that our Definitions \ref{alphaset}, \ref{alphalist}
       
   808   and \ref{alphares} capture the idea of alpha-equivalence relations. 
       
   809   Below we will show the first equation of Theorem \ref{suppabs}. The others follow by similar
   807   arguments. By definition of the abstraction type @{text "abs\<^bsub>set\<^esub>"} we have
   810   arguments. By definition of the abstraction type @{text "abs\<^bsub>set\<^esub>"} we have
   808 
   811 
   809   
       
   810   \begin{equation}\label{abseqiff}
   812   \begin{equation}\label{abseqiff}
   811   @{thm (lhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} \;\;\text{if and only if}\;\; 
   813   @{thm (lhs) Abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} \;\;\;\text{if and only if}\;\;\; 
   812   @{term "\<exists>\<pi>. alpha_set (as, x) equal supp \<pi> (bs, y)"}
   814   @{term "\<exists>\<pi>. alpha_set (as, x) equal supp \<pi> (bs, y)"}
   813   \end{equation}\smallskip
   815   \end{equation}\smallskip
   814   
   816   
   815   \noindent
   817   \noindent
   816   and also
   818   and also
   824   \eqref{permute} and alpha-equivalence being equivariant 
   826   \eqref{permute} and alpha-equivalence being equivariant 
   825   (see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   827   (see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show 
   826   the following lemma about swapping two atoms in an abstraction.
   828   the following lemma about swapping two atoms in an abstraction.
   827   
   829   
   828   \begin{lem}
   830   \begin{lem}
   829   @{thm[mode=IfThen] Abs_swap1(1)[where bs="as", no_vars]}
   831   If @{thm (prem 1) Abs_swap1(1)[where bs="as", no_vars]} and
       
   832   @{thm (prem 2) Abs_swap1(1)[where bs="as", no_vars]} then 
       
   833   @{thm (concl) Abs_swap1(1)[where bs="as", no_vars]}
   830   \end{lem}
   834   \end{lem}
   831   
   835   
   832   \begin{proof}
   836   \begin{proof}
   833   This lemma is straightforward using \eqref{abseqiff} and observing that
   837   This lemma is straightforward using \eqref{abseqiff} and observing that
   834   the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   838   the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}.
   835   Moreover @{text supp} and set difference are equivariant (see \cite{HuffmanUrban10}).
       
   836   \end{proof}
   839   \end{proof}
   837   
   840   
   838   \noindent
   841   \noindent
   839   Assuming that @{text "x"} has finite support, this lemma together 
   842   Assuming that @{text "x"} has finite support, this lemma together 
   840   with \eqref{absperm} allows us to show
   843   with \eqref{absperm} allows us to show
   841   
   844   
   842   \begin{equation}\label{halfone}
   845   \begin{equation}\label{halfone}
   843   @{thm Abs_supports(1)[no_vars]}
   846   @{thm Abs_supports(1)[no_vars]}
   844   \end{equation}
   847   \end{equation}\smallskip
   845   
   848   
   846   \noindent
   849   \noindent
   847   which by Property~\ref{supportsprop} gives us ``one half'' of
   850   which by Property~\ref{supportsprop} gives us ``one half'' of
   848   Theorem~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   851   Theorem~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   849   it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   852   it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   850   function @{text aux}, taking an abstraction as argument:
   853   function @{text aux}, taking an abstraction as argument
   851   @{thm supp_set.simps[THEN eq_reflection, no_vars]}.
   854 
   852   
   855   \[
       
   856   @{thm supp_set.simps[THEN eq_reflection, no_vars]}
       
   857   \]\smallskip 
       
   858 
       
   859   \noindent
   853   Using the second equation in \eqref{equivariance}, we can show that 
   860   Using the second equation in \eqref{equivariance}, we can show that 
   854   @{text "aux"} is equivariant (since @{term "p \<bullet> (supp x - as) = (supp (p \<bullet> x)) - (p \<bullet> as)"}) 
   861   @{text "aux"} is equivariant (since @{term "\<pi> \<bullet> (supp x - as) = (supp (\<pi> \<bullet> x)) - (\<pi> \<bullet> as)"}) 
   855   and therefore has empty support. 
   862   and therefore has empty support. 
   856   This in turn means
   863   This in turn means
   857   
   864   
   858   \begin{center}
   865   \[
   859   @{term "supp (supp_gen (Abs_set as x)) \<subseteq> supp (Abs_set as x)"}
   866   @{term "supp (supp_set (Abs_set as x)) \<subseteq> supp (Abs_set as x)"}
   860   \end{center}
   867   \]\smallskip
   861   
   868   
   862   \noindent
   869   \noindent
   863   using \eqref{suppfun}. Assuming @{term "supp x - as"} is a finite set,
   870   using fact about function applications in \eqref{supps}. Assuming 
   864   we further obtain
   871   @{term "supp x - as"} is a finite set, we further obtain
   865   
   872   
   866   \begin{equation}\label{halftwo}
   873   \begin{equation}\label{halftwo}
   867   @{thm (concl) Abs_supp_subset1(1)[no_vars]}
   874   @{thm (concl) Abs_supp_subset1(1)[no_vars]}
   868   \end{equation}
   875   \end{equation}\smallskip
   869   
   876   
   870   \noindent
   877   \noindent
   871   since for finite sets of atoms, @{text "bs"}, we have 
   878   since for every finite sets of atoms, say @{text "bs"}, we have 
   872   @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}.
   879   @{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}.
   873   Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes 
   880   Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes 
   874   Theorem~\ref{suppabs}. 
   881   Theorem~\ref{suppabs}. 
   875 
   882 
   876   The method of first considering abstractions of the
   883   The method of first considering abstractions of the form @{term "Abs_set as
   877   form @{term "Abs_set as x"} etc is motivated by the fact that 
   884   x"} etc is motivated by the fact that we can conveniently establish at the
   878   we can conveniently establish  at the Isabelle/HOL level
   885   Isabelle/HOL level properties about them.  It would be extremely laborious
   879   properties about them.  It would be
   886   to write custom ML-code that derives automatically such properties for every
   880   laborious to write custom ML-code that derives automatically such properties 
   887   term-constructor that binds some atoms. Also the generality of the
   881   for every term-constructor that binds some atoms. Also the generality of
   888   definitions for alpha-equivalence will help us in the next sections.
   882   the definitions for alpha-equivalence will help us in the next sections.
       
   883 *}
   889 *}
   884 
   890 
   885 section {* Specifying General Bindings\label{sec:spec} *}
   891 section {* Specifying General Bindings\label{sec:spec} *}
   886 
   892 
   887 text {*
   893 text {*
   912   \isacommand{where}\\
   918   \isacommand{where}\\
   913   \raisebox{2mm}{$\ldots$}\\[-2mm]
   919   \raisebox{2mm}{$\ldots$}\\[-2mm]
   914   \end{tabular}}
   920   \end{tabular}}
   915   \end{cases}$\\
   921   \end{cases}$\\
   916   \end{tabular}}
   922   \end{tabular}}
   917   \end{equation}
   923   \end{equation}\smallskip
   918 
   924 
   919   \noindent
   925   \noindent
   920   Every type declaration @{text ty}$^\alpha_{1..n}$ consists of a collection of 
   926   Every type declaration @{text ty}$^\alpha_{1..n}$ consists of a collection
   921   term-constructors, each of which comes with a list of labelled 
   927   of term-constructors, each of which comes with a list of labelled types that
   922   types that stand for the types of the arguments of the term-constructor.
   928   stand for the types of the arguments of the term-constructor.  For example a
   923   For example a term-constructor @{text "C\<^sup>\<alpha>"} might be specified with
   929   term-constructor @{text "C\<^sup>\<alpha>"} might be specified with
   924 
   930 
   925   \begin{center}
   931   \[
   926   @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$  @{text "binding_clauses"} 
   932   @{text "C\<^sup>\<alpha> label\<^isub>1::ty"}\mbox{$'_1$} @{text "\<dots> label\<^isub>l::ty"}\mbox{$'_l\;\;$}  @{text "binding_clauses"} 
   927   \end{center}
   933   \]\smallskip
   928   
   934   
   929   \noindent
   935   \noindent
   930   whereby some of the @{text ty}$'_{1..l}$ (or their components) 
   936   whereby some of the @{text ty}$'_{1..l}$ (or their components) can be
   931   can be contained
   937   contained in the collection of @{text ty}$^\alpha_{1..n}$ declared in
   932   in the collection of @{text ty}$^\alpha_{1..n}$ declared in
   938   \eqref{scheme}. In this case we will call the corresponding argument a
   933   \eqref{scheme}. 
   939   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such
   934   In this case we will call the corresponding argument a
   940   recursive arguments need to satisfy a ``positivity'' restriction, which
   935   \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. 
   941   ensures that the type has a set-theoretic semantics (see
   936   The types of such recursive 
   942   \cite{Berghofer99}).  The labels annotated on the types are optional. Their
   937   arguments need to satisfy a  ``positivity''
   943   purpose is to be used in the (possibly empty) list of \emph{binding
   938   restriction, which ensures that the type has a set-theoretic semantics 
   944   clauses}, which indicate the binders and their scope in a term-constructor.
   939   \cite{Berghofer99}.  
   945   They come in three \emph{modes}:
   940   The labels
   946 
   941   annotated on the types are optional. Their purpose is to be used in the
   947 
   942   (possibly empty) list of \emph{binding clauses}, which indicate the binders
   948   \[\mbox{
   943   and their scope in a term-constructor.  They come in three \emph{modes}:
       
   944   %
       
   945   \begin{center}
       
   946   \begin{tabular}{@ {}l@ {}}
   949   \begin{tabular}{@ {}l@ {}}
   947   \isacommand{bind} {\it binders} \isacommand{in} {\it bodies}\;\;\;\,
   950   \isacommand{binds} {\it binders} \isacommand{in} {\it bodies}\\
   948   \isacommand{bind (set)} {\it binders} \isacommand{in} {\it bodies}\;\;\;\,
   951   \isacommand{binds (set)} {\it binders} \isacommand{in} {\it bodies}\\
   949   \isacommand{bind (set+)} {\it binders} \isacommand{in} {\it bodies}
   952   \isacommand{binds (set+)} {\it binders} \isacommand{in} {\it bodies}
   950   \end{tabular}
   953   \end{tabular}}
   951   \end{center}
   954   \]\smallskip
   952   %
   955   
   953   \noindent
   956   \noindent
   954   The first mode is for binding lists of atoms (the order of binders matters);
   957   The first mode is for binding lists of atoms (the order of bound atoms
   955   the second is for sets of binders (the order does not matter, but the
   958   matters); the second is for sets of binders (the order does not matter, but
   956   cardinality does) and the last is for sets of binders (with vacuous binders
   959   the cardinality does) and the last is for sets of binders (with vacuous
   957   preserving alpha-equivalence). As indicated, the labels in the ``\isacommand{in}-part'' of a binding
   960   binders preserving alpha-equivalence). As indicated, the labels in the
   958   clause will be called \emph{bodies}; the
   961   ``\isacommand{in}-part'' of a binding clause will be called \emph{bodies};
   959   ``\isacommand{bind}-part'' will be called \emph{binders}. In contrast to
   962   the ``\isacommand{binds}-part'' will be called \emph{binders}. In contrast to
   960   Ott, we allow multiple labels in binders and bodies. 
   963   Ott, we allow multiple labels in binders and bodies.  For example we allow
   961 
       
   962   For example we allow
       
   963   binding clauses of the form:
   964   binding clauses of the form:
   964   
   965  
   965   \begin{center}
   966   \[\mbox{
   966   \begin{tabular}{@ {}ll@ {}}
   967   \begin{tabular}{@ {}ll@ {}}
   967   @{text "Foo\<^isub>1 x::name y::name t::trm s::trm"} &  
   968   @{text "Foo\<^isub>1 x::name y::name t::trm s::trm"} &  
   968       \isacommand{bind} @{text "x y"} \isacommand{in} @{text "t s"}\\
   969       \isacommand{binds} @{text "x y"} \isacommand{in} @{text "t s"}\\
   969   @{text "Foo\<^isub>2 x::name y::name t::trm s::trm"} &  
   970   @{text "Foo\<^isub>2 x::name y::name t::trm s::trm"} &  
   970       \isacommand{bind} @{text "x y"} \isacommand{in} @{text "t"}, 
   971       \isacommand{binds} @{text "x y"} \isacommand{in} @{text "t"}, 
   971       \isacommand{bind} @{text "x y"} \isacommand{in} @{text "s"}\\
   972       \isacommand{binds} @{text "x y"} \isacommand{in} @{text "s"}\\
   972   \end{tabular}
   973   \end{tabular}}
   973   \end{center}
   974   \]\smallskip
   974 
   975 
   975   \noindent
   976   \noindent
   976   Similarly for the other binding modes. 
   977   Similarly for the other binding modes. Interestingly, in case of
   977   Interestingly, in case of \isacommand{bind (set)}
   978   \isacommand{binds (set)} and \isacommand{binds (set+)} the binding clauses
   978   and \isacommand{bind (set+)} the binding clauses above will make a difference to the semantics
   979   above will make a difference to the semantics of the specifications (the
   979   of the specifications (the corresponding alpha-equivalence will differ). We will 
   980   corresponding alpha-equivalence will differ). We will show this later with
   980   show this later with an example.
   981   an example.
   981   
   982 
   982   There are also some restrictions we need to impose on our binding clauses in comparison to
   983   
   983   the ones of Ott. The
   984   There are also some restrictions we need to impose on our binding clauses in
   984   main idea behind these restrictions is that we obtain a sensible notion of
   985   comparison to the ones of Ott. The main idea behind these restrictions is
   985   alpha-equivalence where it is ensured that within a given scope an 
   986   that we obtain a sensible notion of alpha-equivalence where it is ensured
   986   atom occurrence cannot be both bound and free at the same time.  The first
   987   that within a given scope an atom occurrence cannot be both bound and free
   987   restriction is that a body can only occur in
   988   at the same time.  The first restriction is that a body can only occur in
   988   \emph{one} binding clause of a term constructor (this ensures that the bound
   989   \emph{one} binding clause of a term constructor (this ensures that the bound
   989   atoms of a body cannot be free at the same time by specifying an
   990   atoms of a body cannot be free at the same time by specifying an alternative
   990   alternative binder for the same body). 
   991   binder for the same body).
   991 
   992 
   992   For binders we distinguish between
   993   For binders we distinguish between \emph{shallow} and \emph{deep} binders.
   993   \emph{shallow} and \emph{deep} binders.  Shallow binders are just
   994   Shallow binders are just labels. The restriction we need to impose on them
   994   labels. The restriction we need to impose on them is that in case of
   995   is that in case of \isacommand{binds (set)} and \isacommand{binds (set+)} the
   995   \isacommand{bind (set)} and \isacommand{bind (set+)} the labels must either
   996   labels must either refer to atom types or to sets of atom types; in case of
   996   refer to atom types or to sets of atom types; in case of \isacommand{bind}
   997   \isacommand{binds} the labels must refer to atom types or lists of atom
   997   the labels must refer to atom types or lists of atom types. Two examples for
   998   types. Two examples for the use of shallow binders are the specification of
   998   the use of shallow binders are the specification of lambda-terms, where a
   999   lambda-terms, where a single name is bound, and type-schemes, where a finite
   999   single name is bound, and type-schemes, where a finite set of names is
  1000   set of names is bound:
  1000   bound:
  1001 
  1001 
  1002   \[\mbox{
  1002   \begin{center}
  1003   \begin{tabular}{@ {}c@ {\hspace{5mm}}c@ {}}
  1003   \begin{tabular}{@ {}c@ {\hspace{7mm}}c@ {}}
       
  1004   \begin{tabular}{@ {}l}
  1004   \begin{tabular}{@ {}l}
  1005   \isacommand{nominal\_datatype} @{text lam} $=$\\
  1005   \isacommand{nominal\_datatype} @{text lam} $=$\\
  1006   \hspace{2mm}\phantom{$\mid$}~@{text "Var name"}\\
  1006   \hspace{2mm}\phantom{$\mid$}~@{text "Var name"}\\
  1007   \hspace{2mm}$\mid$~@{text "App lam lam"}\\
  1007   \hspace{2mm}$\mid$~@{text "App lam lam"}\\
  1008   \hspace{2mm}$\mid$~@{text "Lam x::name t::lam"}~~\isacommand{bind} @{text x} \isacommand{in} @{text t}\\
  1008   \hspace{2mm}$\mid$~@{text "Lam x::name t::lam"}\hspace{3mm}%
       
  1009   \isacommand{binds} @{text x} \isacommand{in} @{text t}\\
  1009   \end{tabular} &
  1010   \end{tabular} &
  1010   \begin{tabular}{@ {}l@ {}}
  1011   \begin{tabular}{@ {}l@ {}}
  1011   \isacommand{nominal\_datatype}~@{text ty} $=$\\
  1012   \isacommand{nominal\_datatype}~@{text ty} $=$\\
  1012   \hspace{5mm}\phantom{$\mid$}~@{text "TVar name"}\\
  1013   \hspace{5mm}\phantom{$\mid$}~@{text "TVar name"}\\
  1013   \hspace{5mm}$\mid$~@{text "TFun ty ty"}\\
  1014   \hspace{5mm}$\mid$~@{text "TFun ty ty"}\\
  1014   \isacommand{and}~@{text "tsc = All xs::(name fset) T::ty"}~~%
  1015   \isacommand{and}~@{text "tsc = All xs::(name fset) T::ty"}\hspace{3mm}%
  1015   \isacommand{bind (set+)} @{text xs} \isacommand{in} @{text T}\\
  1016   \isacommand{binds (set+)} @{text xs} \isacommand{in} @{text T}\\
  1016   \end{tabular}
  1017   \end{tabular}
  1017   \end{tabular}
  1018   \end{tabular}}
  1018   \end{center}
  1019   \]\smallskip
       
  1020 
  1019 
  1021 
  1020   \noindent
  1022   \noindent
  1021   In these specifications @{text "name"} refers to an atom type, and @{text
  1023   In these specifications @{text "name"} refers to an atom type, and @{text
  1022   "fset"} to the type of finite sets.
  1024   "fset"} to the type of finite sets.  Note that for @{text lam} it does not
  1023   Note that for @{text lam} it does not matter which binding mode we use. The
  1025   matter which binding mode we use. The reason is that we bind only a single
  1024   reason is that we bind only a single @{text name}. However, having
  1026   @{text name}. However, having \isacommand{binds (set)} or \isacommand{binds}
  1025   \isacommand{bind (set)} or \isacommand{bind} in the second case makes a
  1027   in the second case makes a difference to the semantics of the specification
  1026   difference to the semantics of the specification (which we will define in the next section).
  1028   (which we will define in the next section).
  1027 
       
  1028 
  1029 
  1029   A \emph{deep} binder uses an auxiliary binding function that ``picks'' out
  1030   A \emph{deep} binder uses an auxiliary binding function that ``picks'' out
  1030   the atoms in one argument of the term-constructor, which can be bound in
  1031   the atoms in one argument of the term-constructor, which can be bound in
  1031   other arguments and also in the same argument (we will call such binders
  1032   other arguments and also in the same argument (we will call such binders
  1032   \emph{recursive}, see below). The binding functions are
  1033   \emph{recursive}, see below). The binding functions are
  1033   expected to return either a set of atoms (for \isacommand{bind (set)} and
  1034   expected to return either a set of atoms (for \isacommand{binds (set)} and
  1034   \isacommand{bind (set+)}) or a list of atoms (for \isacommand{bind}). They can
  1035   \isacommand{binds (set+)}) or a list of atoms (for \isacommand{binds}). They need
  1035   be defined by recursion over the corresponding type; the equations
  1036   to be defined by recursion over the corresponding type; the equations
  1036   must be given in the binding function part of the scheme shown in
  1037   must be given in the binding function part of the scheme shown in
  1037   \eqref{scheme}. For example a term-calculus containing @{text "Let"}s with
  1038   \eqref{scheme}. For example a term-calculus containing @{text "Let"}s with
  1038   tuple patterns might be specified as:
  1039   tuple patterns might be specified as:
  1039   %
  1040 
  1040   \begin{equation}\label{letpat}
  1041   \begin{equation}\label{letpat}
  1041   \mbox{%
  1042   \mbox{%
  1042   \begin{tabular}{l}
  1043   \begin{tabular}{l}
  1043   \isacommand{nominal\_datatype} @{text trm} $=$\\
  1044   \isacommand{nominal\_datatype} @{text trm} $=$\\
  1044   \hspace{5mm}\phantom{$\mid$}~@{term "Var name"}\\
  1045   \hspace{5mm}\phantom{$\mid$}~@{term "Var name"}\\
  1045   \hspace{5mm}$\mid$~@{term "App trm trm"}\\
  1046   \hspace{5mm}$\mid$~@{term "App trm trm"}\\
  1046   \hspace{5mm}$\mid$~@{text "Lam x::name t::trm"} 
  1047   \hspace{5mm}$\mid$~@{text "Lam x::name t::trm"} 
  1047      \;\;\isacommand{bind} @{text x} \isacommand{in} @{text t}\\
  1048      \;\;\isacommand{binds} @{text x} \isacommand{in} @{text t}\\
  1048   \hspace{5mm}$\mid$~@{text "Let p::pat trm t::trm"} 
  1049   \hspace{5mm}$\mid$~@{text "Let p::pat trm t::trm"} 
  1049      \;\;\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t}\\
  1050      \;\;\isacommand{binds} @{text "bn(p)"} \isacommand{in} @{text t}\\
  1050   \isacommand{and} @{text pat} $=$
  1051   \isacommand{and} @{text pat} $=$\\
  1051   @{text PNil}
  1052   \hspace{5mm}\phantom{$\mid$}~@{text PNil}\\
  1052   $\mid$~@{text "PVar name"}
  1053   \hspace{5mm}$\mid$~@{text "PVar name"}\\
  1053   $\mid$~@{text "PTup pat pat"}\\ 
  1054   \hspace{5mm}$\mid$~@{text "PTup pat pat"}\\ 
  1054   \isacommand{binder}~@{text "bn::pat \<Rightarrow> atom list"}\\
  1055   \isacommand{binder}~@{text "bn::pat \<Rightarrow> atom list"}\\
  1055   \isacommand{where}~@{text "bn(PNil) = []"}\\
  1056   \isacommand{where}~@{text "bn(PNil) = []"}\\
  1056   \hspace{5mm}$\mid$~@{text "bn(PVar x) = [atom x]"}\\
  1057   \hspace{5mm}$\mid$~@{text "bn(PVar x) = [atom x]"}\\
  1057   \hspace{5mm}$\mid$~@{text "bn(PTup p\<^isub>1 p\<^isub>2) = bn(p\<^isub>1) @ bn(p\<^isub>2)"}\smallskip\\ 
  1058   \hspace{5mm}$\mid$~@{text "bn(PTup p\<^isub>1 p\<^isub>2) = bn(p\<^isub>1) @ bn(p\<^isub>2)"}\smallskip\\ 
  1058   \end{tabular}}
  1059   \end{tabular}}
  1059   \end{equation}
  1060   \end{equation}\smallskip
  1060   %
  1061 
  1061   \noindent
  1062   \noindent
  1062   In this specification the function @{text "bn"} determines which atoms of
  1063   In this specification the function @{text "bn"} determines which atoms of
  1063   the pattern @{text p} are bound in the argument @{text "t"}. Note that in the
  1064   the pattern @{text p} are bound in the argument @{text "t"}. Note that in the
  1064   second-last @{text bn}-clause the function @{text "atom"} coerces a name
  1065   second-last @{text bn}-clause the function @{text "atom"} coerces a name
  1065   into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This
  1066   into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This
  1066   allows us to treat binders of different atom type uniformly.
  1067   allows us to treat binders of different atom type uniformly.
  1067 
  1068 
  1068   As said above, for deep binders we allow binding clauses such as
  1069   As said above, for deep binders we allow binding clauses such as
  1069   
  1070   
  1070   \begin{center}
  1071   \[\mbox{
  1071   \begin{tabular}{ll}
  1072   \begin{tabular}{ll}
  1072   @{text "Bar p::pat t::trm"} &  
  1073   @{text "Bar p::pat t::trm"} &  
  1073      \isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text "p t"} \\
  1074      \isacommand{binds} @{text "bn(p)"} \isacommand{in} @{text "p t"} \\
  1074   \end{tabular}
  1075   \end{tabular}}
  1075   \end{center}
  1076   \]\smallskip
       
  1077 
  1076   
  1078   
  1077   \noindent
  1079   \noindent
  1078   where the argument of the deep binder also occurs in the body. We call such
  1080   where the argument of the deep binder also occurs in the body. We call such
  1079   binders \emph{recursive}.  To see the purpose of such recursive binders,
  1081   binders \emph{recursive}.  To see the purpose of such recursive binders,
  1080   compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s in the following
  1082   compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s in the following
  1081   specification:
  1083   specification:
  1082   %
  1084  
  1083   \begin{equation}\label{letrecs}
  1085   \begin{equation}\label{letrecs}
  1084   \mbox{%
  1086   \mbox{%
  1085   \begin{tabular}{@ {}l@ {}}
  1087   \begin{tabular}{@ {}l@ {}}
  1086   \isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\
  1088   \isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\
  1087   \hspace{5mm}$\mid$~@{text "Let as::assn t::trm"} 
  1089   \hspace{5mm}$\mid$~@{text "Let as::assn t::trm"} 
  1088      \;\;\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text t}\\
  1090      \;\;\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text t}\\
  1089   \hspace{5mm}$\mid$~@{text "Let_rec as::assn t::trm"}
  1091   \hspace{5mm}$\mid$~@{text "Let_rec as::assn t::trm"}
  1090      \;\;\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "as t"}\\
  1092      \;\;\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "as t"}\\
  1091   \isacommand{and} @{text "assn"} $=$
  1093   \isacommand{and} @{text "assn"} $=$\\
  1092   @{text "ANil"}
  1094   \hspace{5mm}\phantom{$\mid$}~@{text "ANil"}\\
  1093   $\mid$~@{text "ACons name trm assn"}\\
  1095   \hspace{5mm}$\mid$~@{text "ACons name trm assn"}\\
  1094   \isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\
  1096   \isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\
  1095   \isacommand{where}~@{text "bn(ANil) = []"}\\
  1097   \isacommand{where}~@{text "bn(ANil) = []"}\\
  1096   \hspace{5mm}$\mid$~@{text "bn(ACons a t as) = [atom a] @ bn(as)"}\\
  1098   \hspace{5mm}$\mid$~@{text "bn(ACons a t as) = [atom a] @ bn(as)"}\\
  1097   \end{tabular}}
  1099   \end{tabular}}
  1098   \end{equation}
  1100   \end{equation}\smallskip
  1099   %
  1101   
  1100   \noindent
  1102   \noindent
  1101   The difference is that with @{text Let} we only want to bind the atoms @{text
  1103   The difference is that with @{text Let} we only want to bind the atoms @{text
  1102   "bn(as)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms
  1104   "bn(as)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms
  1103   inside the assignment. This difference has consequences for the associated
  1105   inside the assignment. This difference has consequences for the associated
  1104   notions of free-atoms and alpha-equivalence.
  1106   notions of free-atoms and alpha-equivalence.
  1108   Consequently we exclude specifications such as
  1110   Consequently we exclude specifications such as
  1109   %
  1111   %
  1110   \begin{center}
  1112   \begin{center}
  1111   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  1113   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  1112   @{text "Baz\<^isub>1 p::pat t::trm"} & 
  1114   @{text "Baz\<^isub>1 p::pat t::trm"} & 
  1113      \isacommand{bind} @{text "bn\<^isub>1(p) bn\<^isub>2(p)"} \isacommand{in} @{text t}\\
  1115      \isacommand{binds} @{text "bn\<^isub>1(p) bn\<^isub>2(p)"} \isacommand{in} @{text t}\\
  1114   @{text "Baz\<^isub>2 p::pat t\<^isub>1::trm t\<^isub>2::trm"} & 
  1116   @{text "Baz\<^isub>2 p::pat t\<^isub>1::trm t\<^isub>2::trm"} & 
  1115      \isacommand{bind} @{text "bn\<^isub>1(p)"} \isacommand{in} @{text "t\<^isub>1"},
  1117      \isacommand{binds} @{text "bn\<^isub>1(p)"} \isacommand{in} @{text "t\<^isub>1"},
  1116      \isacommand{bind} @{text "bn\<^isub>2(p)"} \isacommand{in} @{text "t\<^isub>2"}\\
  1118      \isacommand{binds} @{text "bn\<^isub>2(p)"} \isacommand{in} @{text "t\<^isub>2"}\\
  1117   \end{tabular}
  1119   \end{tabular}
  1118   \end{center}
  1120   \end{center}
  1119 
  1121 
  1120   \noindent
  1122   \noindent
  1121   Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"}  pick 
  1123   Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"}  pick 
  1145   In order to simplify our definitions of free atoms and alpha-equivalence, 
  1147   In order to simplify our definitions of free atoms and alpha-equivalence, 
  1146   we shall assume specifications 
  1148   we shall assume specifications 
  1147   of term-calculi are implicitly \emph{completed}. By this we mean that  
  1149   of term-calculi are implicitly \emph{completed}. By this we mean that  
  1148   for every argument of a term-constructor that is \emph{not} 
  1150   for every argument of a term-constructor that is \emph{not} 
  1149   already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding
  1151   already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding
  1150   clause, written \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case
  1152   clause, written \isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case
  1151   of the lambda-terms, the completion produces
  1153   of the lambda-terms, the completion produces
  1152 
  1154 
  1153   \begin{center}
  1155   \begin{center}
  1154   \begin{tabular}{@ {}l@ {\hspace{-1mm}}}
  1156   \begin{tabular}{@ {}l@ {\hspace{-1mm}}}
  1155   \isacommand{nominal\_datatype} @{text lam} =\\
  1157   \isacommand{nominal\_datatype} @{text lam} =\\
  1156   \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"}
  1158   \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"}
  1157     \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "x"}\\
  1159     \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "x"}\\
  1158   \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"}
  1160   \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"}
  1159     \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\
  1161     \;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\
  1160   \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}
  1162   \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}
  1161     \;\;\isacommand{bind}~@{text x} \isacommand{in} @{text t}\\
  1163     \;\;\isacommand{binds}~@{text x} \isacommand{in} @{text t}\\
  1162   \end{tabular}
  1164   \end{tabular}
  1163   \end{center}
  1165   \end{center}
  1164 
  1166 
  1165   \noindent 
  1167   \noindent 
  1166   The point of completion is that we can make definitions over the binding
  1168   The point of completion is that we can make definitions over the binding
  1234   binding mechanisms their definitions are somewhat involved.  Given
  1236   binding mechanisms their definitions are somewhat involved.  Given
  1235   a term-constructor @{text "C"} of type @{text ty} and some associated
  1237   a term-constructor @{text "C"} of type @{text ty} and some associated
  1236   binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text
  1238   binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text
  1237   "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text
  1239   "fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text
  1238   "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding
  1240   "fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding
  1239   clause means. We only show the details for the mode \isacommand{bind (set)} (the other modes are similar). 
  1241   clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar). 
  1240   Suppose the binding clause @{text bc\<^isub>i} is of the form 
  1242   Suppose the binding clause @{text bc\<^isub>i} is of the form 
  1241   
  1243   
  1242   \begin{center}
  1244   \begin{center}
  1243   \mbox{\isacommand{bind (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}}
  1245   \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}}
  1244   \end{center}
  1246   \end{center}
  1245   
  1247   
  1246   \noindent
  1248   \noindent
  1247   in which the body-labels @{text "d"}$_{1..q}$ refer to types @{text ty}$_{1..q}$,
  1249   in which the body-labels @{text "d"}$_{1..q}$ refer to types @{text ty}$_{1..q}$,
  1248   and the binders @{text b}$_{1..p}$
  1250   and the binders @{text b}$_{1..p}$
  1441   The task below is to specify what the premises of a binding clause are. As a
  1443   The task below is to specify what the premises of a binding clause are. As a
  1442   special instance, we first treat the case where @{text "bc\<^isub>i"} is the
  1444   special instance, we first treat the case where @{text "bc\<^isub>i"} is the
  1443   empty binding clause of the form
  1445   empty binding clause of the form
  1444   
  1446   
  1445   \begin{center}
  1447   \begin{center}
  1446   \mbox{\isacommand{bind (set)} @{term "{}"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
  1448   \mbox{\isacommand{binds (set)} @{term "{}"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
  1447   \end{center}
  1449   \end{center}
  1448 
  1450 
  1449   \noindent
  1451   \noindent
  1450   In this binding clause no atom is bound and we only have to alpha-relate the bodies. For this
  1452   In this binding clause no atom is bound and we only have to alpha-relate the bodies. For this
  1451   we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>, d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"}  
  1453   we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>, d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"}  
  1473   We will use the unfolded version in the examples below.
  1475   We will use the unfolded version in the examples below.
  1474 
  1476 
  1475   Now suppose the binding clause @{text "bc\<^isub>i"} is of the general form 
  1477   Now suppose the binding clause @{text "bc\<^isub>i"} is of the general form 
  1476   
  1478   
  1477   \begin{equation}\label{nonempty}
  1479   \begin{equation}\label{nonempty}
  1478   \mbox{\isacommand{bind (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
  1480   \mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
  1479   \end{equation}
  1481   \end{equation}
  1480 
  1482 
  1481   \noindent
  1483   \noindent
  1482   In this case we define a premise @{text P} using the relation
  1484   In this case we define a premise @{text P} using the relation
  1483   $\approx_{\,\textit{set}}$ given in Section~\ref{sec:binders} (similarly
  1485   $\approx_{\,\textit{set}}$ given in Section~\ref{sec:binders} (similarly
  1840   %\isacommand{and}~@{text "ckind ="}\\
  1842   %\isacommand{and}~@{text "ckind ="}\\
  1841   %\phantom{$|$}~@{text "CKSim ty ty"}\\
  1843   %\phantom{$|$}~@{text "CKSim ty ty"}\\
  1842   %\isacommand{and}~@{text "ty ="}\\
  1844   %\isacommand{and}~@{text "ty ="}\\
  1843   %\phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\
  1845   %\phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\
  1844   %$|$~@{text "TFun string ty_list"}~%
  1846   %$|$~@{text "TFun string ty_list"}~%
  1845   %$|$~@{text "TAll tv::tvar tkind ty::ty"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text ty}\\
  1847   %$|$~@{text "TAll tv::tvar tkind ty::ty"}  \isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text ty}\\
  1846   %$|$~@{text "TArr ckind ty"}\\
  1848   %$|$~@{text "TArr ckind ty"}\\
  1847   %\isacommand{and}~@{text "ty_lst ="}\\
  1849   %\isacommand{and}~@{text "ty_lst ="}\\
  1848   %\phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\
  1850   %\phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\
  1849   %\isacommand{and}~@{text "cty ="}\\
  1851   %\isacommand{and}~@{text "cty ="}\\
  1850   %\phantom{$|$}~@{text "CVar cvar"}~%
  1852   %\phantom{$|$}~@{text "CVar cvar"}~%
  1851   %$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\
  1853   %$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\
  1852   %$|$~@{text "CAll cv::cvar ckind cty::cty"}  \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text cty}\\
  1854   %$|$~@{text "CAll cv::cvar ckind cty::cty"}  \isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text cty}\\
  1853   %$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\
  1855   %$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\
  1854   %$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\
  1856   %$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\
  1855   %$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\
  1857   %$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\
  1856   %\isacommand{and}~@{text "co_lst ="}\\
  1858   %\isacommand{and}~@{text "co_lst ="}\\
  1857   %\phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\
  1859   %\phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\
  1858   %\isacommand{and}~@{text "trm ="}\\
  1860   %\isacommand{and}~@{text "trm ="}\\
  1859   %\phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\
  1861   %\phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\
  1860   %$|$~@{text "LAM_ty tv::tvar tkind t::trm"}  \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\
  1862   %$|$~@{text "LAM_ty tv::tvar tkind t::trm"}  \isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text t}\\
  1861   %$|$~@{text "LAM_cty cv::cvar ckind t::trm"}   \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\
  1863   %$|$~@{text "LAM_cty cv::cvar ckind t::trm"}   \isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text t}\\
  1862   %$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\
  1864   %$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\
  1863   %$|$~@{text "Lam v::var ty t::trm"}  \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\
  1865   %$|$~@{text "Lam v::var ty t::trm"}  \isacommand{binds}~@{text "v"}~\isacommand{in}~@{text t}\\
  1864   %$|$~@{text "Let x::var ty trm t::trm"}  \isacommand{bind}~@{text x}~\isacommand{in}~@{text t}\\
  1866   %$|$~@{text "Let x::var ty trm t::trm"}  \isacommand{binds}~@{text x}~\isacommand{in}~@{text t}\\
  1865   %$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\
  1867   %$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\
  1866   %\isacommand{and}~@{text "assoc_lst ="}\\
  1868   %\isacommand{and}~@{text "assoc_lst ="}\\
  1867   %\phantom{$|$}~@{text ANil}~%
  1869   %\phantom{$|$}~@{text ANil}~%
  1868   %$|$~@{text "ACons p::pat t::trm assoc_lst"}  \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\
  1870   %$|$~@{text "ACons p::pat t::trm assoc_lst"}  \isacommand{binds}~@{text "bv p"}~\isacommand{in}~@{text t}\\
  1869   %\isacommand{and}~@{text "pat ="}\\
  1871   %\isacommand{and}~@{text "pat ="}\\
  1870   %\phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  1872   %\phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
  1871   %\isacommand{and}~@{text "vt_lst ="}\\
  1873   %\isacommand{and}~@{text "vt_lst ="}\\
  1872   %\phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  1874   %\phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
  1873   %\isacommand{and}~@{text "tvtk_lst ="}\\
  1875   %\isacommand{and}~@{text "tvtk_lst ="}\\
  2248   covers cases of binders depending on other binders, which just do not make
  2250   covers cases of binders depending on other binders, which just do not make
  2249   sense for our alpha-equated terms. Third, it allows empty types that have no
  2251   sense for our alpha-equated terms. Third, it allows empty types that have no
  2250   meaning in a HOL-based theorem prover. We also had to generalise slightly Ott's 
  2252   meaning in a HOL-based theorem prover. We also had to generalise slightly Ott's 
  2251   binding clauses. In Ott you specify binding clauses with a single body; we 
  2253   binding clauses. In Ott you specify binding clauses with a single body; we 
  2252   allow more than one. We have to do this, because this makes a difference 
  2254   allow more than one. We have to do this, because this makes a difference 
  2253   for our notion of alpha-equivalence in case of \isacommand{bind (set)} and 
  2255   for our notion of alpha-equivalence in case of \isacommand{binds (set)} and 
  2254   \isacommand{bind (set+)}. 
  2256   \isacommand{binds (set+)}. 
  2255   
  2257   
  2256   Consider the examples
  2258   Consider the examples
  2257   
  2259   
  2258   \begin{center}
  2260   \begin{center}
  2259   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  2261   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  2260   @{text "Foo\<^isub>1 xs::name fset t::trm s::trm"} &  
  2262   @{text "Foo\<^isub>1 xs::name fset t::trm s::trm"} &  
  2261       \isacommand{bind (set)} @{text "xs"} \isacommand{in} @{text "t s"}\\
  2263       \isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "t s"}\\
  2262   @{text "Foo\<^isub>2 xs::name fset t::trm s::trm"} &  
  2264   @{text "Foo\<^isub>2 xs::name fset t::trm s::trm"} &  
  2263       \isacommand{bind (set)} @{text "xs"} \isacommand{in} @{text "t"}, 
  2265       \isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "t"}, 
  2264       \isacommand{bind (set)} @{text "xs"} \isacommand{in} @{text "s"}\\
  2266       \isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "s"}\\
  2265   \end{tabular}
  2267   \end{tabular}
  2266   \end{center}
  2268   \end{center}
  2267   
  2269   
  2268   \noindent
  2270   \noindent
  2269   In the first term-constructor we have a single
  2271   In the first term-constructor we have a single
  2294   implemented as a front-end that can be translated to OCaml with the help of
  2296   implemented as a front-end that can be translated to OCaml with the help of
  2295   a library. He presents a type-system in which the scope of general binders
  2297   a library. He presents a type-system in which the scope of general binders
  2296   can be specified using special markers, written @{text "inner"} and 
  2298   can be specified using special markers, written @{text "inner"} and 
  2297   @{text "outer"}. It seems our and his specifications can be
  2299   @{text "outer"}. It seems our and his specifications can be
  2298   inter-translated as long as ours use the binding mode 
  2300   inter-translated as long as ours use the binding mode 
  2299   \isacommand{bind} only.
  2301   \isacommand{binds} only.
  2300   However, we have not proved this. Pottier gives a definition for 
  2302   However, we have not proved this. Pottier gives a definition for 
  2301   alpha-equivalence, which also uses a permutation operation (like ours).
  2303   alpha-equivalence, which also uses a permutation operation (like ours).
  2302   Still, this definition is rather different from ours and he only proves that
  2304   Still, this definition is rather different from ours and he only proves that
  2303   it defines an equivalence relation. A complete
  2305   it defines an equivalence relation. A complete
  2304   reasoning infrastructure is well beyond the purposes of his language. 
  2306   reasoning infrastructure is well beyond the purposes of his language. 
  2305   Similar work for Haskell with similar results was reported by Cheney \cite{Cheney05a}.
  2307   Similar work for Haskell with similar results was reported by Cheney \cite{Cheney05a}.
  2306   
  2308   
  2307   In a slightly different domain (programming with dependent types), the 
  2309   In a slightly different domain (programming with dependent types), the 
  2308   paper \cite{Altenkirch10} presents a calculus with a notion of 
  2310   paper \cite{Altenkirch10} presents a calculus with a notion of 
  2309   alpha-equivalence related to our binding mode \isacommand{bind (set+)}.
  2311   alpha-equivalence related to our binding mode \isacommand{binds (set+)}.
  2310   The definition in \cite{Altenkirch10} is similar to the one by Pottier, except that it
  2312   The definition in \cite{Altenkirch10} is similar to the one by Pottier, except that it
  2311   has a more operational flavour and calculates a partial (renaming) map. 
  2313   has a more operational flavour and calculates a partial (renaming) map. 
  2312   In this way, the definition can deal with vacuous binders. However, to our
  2314   In this way, the definition can deal with vacuous binders. However, to our
  2313   best knowledge, no concrete mathematical result concerning this
  2315   best knowledge, no concrete mathematical result concerning this
  2314   definition of alpha-equivalence has been proved.  
  2316   definition of alpha-equivalence has been proved.