Paper/Paper.thy
changeset 1752 9e09253c80cf
parent 1749 24cc3dbd3c4a
child 1753 7440bfcdf849
equal deleted inserted replaced
1749:24cc3dbd3c4a 1752:9e09253c80cf
   497   @{thm[mode=IfThen] swap_fresh_fresh[no_vars]}
   497   @{thm[mode=IfThen] swap_fresh_fresh[no_vars]}
   498   \end{property}
   498   \end{property}
   499 
   499 
   500   While often the support of an object can be relatively easily 
   500   While often the support of an object can be relatively easily 
   501   described, for example for atoms, products, lists, function applications, 
   501   described, for example for atoms, products, lists, function applications, 
   502   booleans and permutations\\[-6mm]
   502   booleans and permutations as follows\\[-6mm]
   503   %
   503   %
   504   \begin{eqnarray}
   504   \begin{eqnarray}
   505   @{term "supp a"} & = & @{term "{a}"}\\
   505   @{term "supp a"} & = & @{term "{a}"}\\
   506   @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\
   506   @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\
   507   @{term "supp []"} & = & @{term "{}"}\\
   507   @{term "supp []"} & = & @{term "{}"}\\
   548   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   548   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   549   \end{equation}
   549   \end{equation}
   550  
   550  
   551   \noindent
   551   \noindent
   552   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   552   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   553   can be easily deduce that an equivariant function has empty support.
   553   can be easily deduce that equivariant functions have empty support.
   554 
   554 
   555   Finally, the nominal logic work provides us with convenient means to rename 
   555   Finally, the nominal logic work provides us with convenient means to rename 
   556   binders. While in the older version of Nominal Isabelle, we used extensively 
   556   binders. While in the older version of Nominal Isabelle, we used extensively 
   557   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   557   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   558   proved unwieldy for dealing with multiple binders. For such pinders the 
   558   proved unwieldy for dealing with multiple binders. For such binders the 
   559   following generalisations turned out to be easier to use.
   559   following generalisations turned out to be easier to use.
   560 
   560 
   561   \begin{property}\label{supppermeq}
   561   \begin{property}\label{supppermeq}
   562   @{thm[mode=IfThen] supp_perm_eq[no_vars]}
   562   @{thm[mode=IfThen] supp_perm_eq[no_vars]}
   563   \end{property}
   563   \end{property}
   650   \end{array}
   650   \end{array}
   651   \end{equation}
   651   \end{equation}
   652   
   652   
   653   \noindent
   653   \noindent
   654   where @{term set} is a function that coerces a list of atoms into a set of atoms.
   654   where @{term set} is a function that coerces a list of atoms into a set of atoms.
   655   Now the last clause ensures that the order of the binders matters.
   655   Now the last clause ensures that the order of the binders matters (since @{text as}
       
   656   and @{text bs} are lists of atoms).
   656 
   657 
   657   If we do not want to make any difference between the order of binders \emph{and}
   658   If we do not want to make any difference between the order of binders \emph{and}
   658   also allow vacuous binders, then we keep sets of binders, but drop the fourth 
   659   also allow vacuous binders, then we keep sets of binders, but drop the fourth 
   659   condition in \eqref{alphaset}:
   660   condition in \eqref{alphaset}:
   660   %
   661   %
   762   \end{center}
   763   \end{center}
   763 
   764 
   764   \noindent
   765   \noindent
   765   indicating that a set (or list) @{text as} is abstracted in @{text x}. We will
   766   indicating that a set (or list) @{text as} is abstracted in @{text x}. We will
   766   call the types \emph{abstraction types} and their elements
   767   call the types \emph{abstraction types} and their elements
   767   \emph{abstractions}. The important property we need to derive the support of 
   768   \emph{abstractions}. The important property we need to derive is the support of 
   768   abstractions, namely:
   769   abstractions, namely:
   769 
   770 
   770   \begin{thm}[Support of Abstractions]\label{suppabs} 
   771   \begin{thm}[Support of Abstractions]\label{suppabs} 
   771   Assuming @{text x} has finite support, then\\[-6mm] 
   772   Assuming @{text x} has finite support, then\\[-6mm] 
   772   \begin{center}
   773   \begin{center}
   818   @{thm abs_supports(1)[no_vars]}
   819   @{thm abs_supports(1)[no_vars]}
   819   \end{equation}
   820   \end{equation}
   820   
   821   
   821   \noindent
   822   \noindent
   822   which by Property~\ref{supportsprop} gives us ``one half'' of
   823   which by Property~\ref{supportsprop} gives us ``one half'' of
   823   Thm~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   824   Theorem~\ref{suppabs}. The ``other half'' is a bit more involved. To establish 
   824   it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   825   it, we use a trick from \cite{Pitts04} and first define an auxiliary 
   825   function @{text aux}, taking an abstraction as argument:
   826   function @{text aux}, taking an abstraction as argument:
   826   %
   827   %
   827   \begin{center}
   828   \begin{center}
   828   @{thm supp_gen.simps[THEN eq_reflection, no_vars]}
   829   @{thm supp_gen.simps[THEN eq_reflection, no_vars]}
   855   The method of first considering abstractions of the
   856   The method of first considering abstractions of the
   856   form @{term "Abs as x"} etc is motivated by the fact that properties about them
   857   form @{term "Abs as x"} etc is motivated by the fact that properties about them
   857   can be conveninetly established at the Isabelle/HOL level.  It would be
   858   can be conveninetly established at the Isabelle/HOL level.  It would be
   858   difficult to write custom ML-code that derives automatically such properties 
   859   difficult to write custom ML-code that derives automatically such properties 
   859   for every term-constructor that binds some atoms. Also the generality of
   860   for every term-constructor that binds some atoms. Also the generality of
   860   the definitions for alpha-equivalence will help us in the next section.
   861   the definitions for alpha-equivalence will help us in definitions in the next section.
   861 *}
   862 *}
   862 
   863 
   863 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *}
   864 section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *}
   864 
   865 
   865 text {*
   866 text {*
  1011   \end{tabular}
  1012   \end{tabular}
  1012   \end{center}
  1013   \end{center}
  1013   
  1014   
  1014   \noindent
  1015   \noindent
  1015   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1016   In this specification the function @{text "bn"} determines which atoms of @{text  p} are
  1016   bound in the argument @{text "t"}. Note that in the second last clause the function @{text "atom"}
  1017   bound in the argument @{text "t"}. Note that in the second-last clause the function @{text "atom"}
  1017   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows
  1018   coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows
  1018   us to treat binders of different atom type uniformly. 
  1019   us to treat binders of different atom type uniformly. 
  1019 
  1020 
  1020   As will shortly become clear, we cannot return an atom in a binding function
  1021   As will shortly become clear, we cannot return an atom in a binding function
  1021   that is also bound in the corresponding term-constructor. That means in the
  1022   that is also bound in the corresponding term-constructor. That means in the
  1065 
  1066 
  1066   \noindent
  1067   \noindent
  1067   since there is no overlap of binders.
  1068   since there is no overlap of binders.
  1068   
  1069   
  1069   Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}.
  1070   Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}.
  1070   Whenever such a binding clause is present, we will call the binder \emph{recursive}.
  1071   Whenever such a binding clause is present, we will call the corresponding binder \emph{recursive}.
  1071   To see the purpose of such recursive binders, compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s
  1072   To see the purpose of such recursive binders, compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s
  1072   in the following specification:
  1073   in the following specification:
  1073   %
  1074   %
  1074   \begin{equation}\label{letrecs}
  1075   \begin{equation}\label{letrecs}
  1075   \mbox{%
  1076   \mbox{%
  1103   Pottier and Cheney pointed out, we cannot in general re-arrange arguments of
  1104   Pottier and Cheney pointed out, we cannot in general re-arrange arguments of
  1104   term-constructors so that binders and their bodies are next to each other, and
  1105   term-constructors so that binders and their bodies are next to each other, and
  1105   then use the type constructors @{text "abs_set"}, @{text "abs_res"} and
  1106   then use the type constructors @{text "abs_set"}, @{text "abs_res"} and
  1106   @{text "abs_list"} from Section \ref{sec:binders}. Therefore we will first
  1107   @{text "abs_list"} from Section \ref{sec:binders}. Therefore we will first
  1107   extract datatype definitions from the specification and then define 
  1108   extract datatype definitions from the specification and then define 
  1108   independently an alpha-equivalence relation over them.
  1109   expicitly an alpha-equivalence relation over them.
  1109 
  1110 
  1110 
  1111 
  1111   The datatype definition can be obtained by stripping off the 
  1112   The datatype definition can be obtained by stripping off the 
  1112   binding clauses and the labels on the types. We also have to invent
  1113   binding clauses and the labels on the types. We also have to invent
  1113   new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"}
  1114   new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"}
  1161   @{text "fv_bn\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set  \<dots>  fv_bn\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"}
  1162   @{text "fv_bn\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set  \<dots>  fv_bn\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"}
  1162   \end{center}
  1163   \end{center}
  1163 
  1164 
  1164   \noindent
  1165   \noindent
  1165   The reason for this setup is that in a deep binder not all atoms have to be
  1166   The reason for this setup is that in a deep binder not all atoms have to be
  1166   bound, as we shall see in an example below. We need therefore the function
  1167   bound, as we shall see in an example below. We need therefore a function
  1167   that calculates those unbound atoms. 
  1168   that calculates those unbound atoms. 
  1168 
  1169 
  1169   While the idea behind these
  1170   While the idea behind these
  1170   free-variable functions is clear (they just collect all atoms that are not bound),
  1171   free-variable functions is clear (they just collect all atoms that are not bound),
  1171   because of the rather complicated binding mechanisms their definitions are
  1172   because of our rather complicated binding mechanisms their definitions are
  1172   somewhat involved.
  1173   somewhat involved.
  1173   Given a term-constructor @{text "C"} of type @{text ty} with argument types
  1174   Given a term-constructor @{text "C"} of type @{text ty} with argument types
  1174   \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function
  1175   \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function
  1175   @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values
  1176   @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values
  1176   calculated below for each argument. 
  1177   calculated below for each argument. 
  1219   $\bullet$ & @{term "{}"} otherwise
  1220   $\bullet$ & @{term "{}"} otherwise
  1220   \end{tabular}}
  1221   \end{tabular}}
  1221   \end{equation}
  1222   \end{equation}
  1222 
  1223 
  1223   \noindent 
  1224   \noindent 
  1224   Like the coercion function @{text atom} used earlier, @{text "atoms as"} coerces 
  1225   Like the coercion function @{text atom} used earlier, @{text "atoms"} coerces 
  1225   the set @{text as} to the generic atom type.
  1226   the set of atoms to a set of the generic atom type.
  1226   It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}.
  1227   It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}.
  1227 
  1228 
  1228   The last case we need to consider is when @{text "x\<^isub>i"} is neither
  1229   The last case we need to consider is when @{text "x\<^isub>i"} is neither
  1229   a binder nor a body of an abstraction. In this case it is defined 
  1230   a binder nor a body of an abstraction. In this case it is defined 
  1230   as in \eqref{deepbody}, except that we do not need to subtract the 
  1231   as in \eqref{deepbody}, except that we do not need to subtract the 
  1235   functions is to compute the set of free atoms that are not bound by 
  1236   functions is to compute the set of free atoms that are not bound by 
  1236   @{text "bn\<^isub>j"}. Because of the restrictions we imposed on the 
  1237   @{text "bn\<^isub>j"}. Because of the restrictions we imposed on the 
  1237   form of binding functions, this can be done automatically by recursively 
  1238   form of binding functions, this can be done automatically by recursively 
  1238   building up the the set of free variables from the arguments that are 
  1239   building up the the set of free variables from the arguments that are 
  1239   not bound. Let us assume one clause of a binding function is 
  1240   not bound. Let us assume one clause of a binding function is 
  1240   @{text "bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn\<^isub>j"} is the 
  1241   @{text "bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn\<^isub>j (C x\<^isub>1 \<dots> x\<^isub>n)"} is the 
  1241   union of the values calculated for @{text "x\<^isub>i"} of type @{text "ty\<^isub>i"}
  1242   union of the values calculated for @{text "x\<^isub>i"} as follows:
  1242   as follows:
       
  1243 
  1243 
  1244   \begin{center}
  1244   \begin{center}
  1245   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1245   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1246   \multicolumn{2}{l}{@{text "x\<^isub>i"} occurs in @{text "rhs"}:}\\ 
  1246   \multicolumn{2}{l}{@{text "x\<^isub>i"} occurs in @{text "rhs"}:}\\ 
  1247   $\bullet$ & @{term "{}"} provided @{term "x\<^isub>i"} is a single atom,
  1247   $\bullet$ & @{term "{}"} provided @{term "x\<^isub>i"} is a single atom,
  1255   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1255   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1256   \multicolumn{2}{l}{@{text "x\<^isub>i"} does not occur in @{text "rhs"}:}\\
  1256   \multicolumn{2}{l}{@{text "x\<^isub>i"} does not occur in @{text "rhs"}:}\\
  1257   $\bullet$ & @{text "atom x\<^isub>i"} provided @{term "x\<^isub>i"} is an atom\\
  1257   $\bullet$ & @{text "atom x\<^isub>i"} provided @{term "x\<^isub>i"} is an atom\\
  1258   $\bullet$ & @{text "atoms x\<^isub>i"} provided @{term "x\<^isub>i"} is a set of atoms\\
  1258   $\bullet$ & @{text "atoms x\<^isub>i"} provided @{term "x\<^isub>i"} is a set of atoms\\
  1259   $\bullet$ & @{term "atoms (set x\<^isub>i)"} provided @{term "x\<^isub>i"} is a list of atoms\\
  1259   $\bullet$ & @{term "atoms (set x\<^isub>i)"} provided @{term "x\<^isub>i"} is a list of atoms\\
  1260   $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i"} provided @{term "ty\<^isub>i"} is one of the raw
  1260   $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i"} provided @{term "ty\<^isub>i"} is the type of @{text "x\<^isub>i"} and one of the raw
  1261      types corresponding to the types specified by the user\\
  1261      types corresponding to the types specified by the user\\
  1262 %  $\bullet$ & @{text "fv_ty\<^isup>\<alpha> x\<^isub>i - bnds"} provided @{term "x\<^isub>i"}  is not in @{text "rhs"}
  1262 %  $\bullet$ & @{text "fv_ty\<^isup>\<alpha> x\<^isub>i - bnds"} provided @{term "x\<^isub>i"}  is not in @{text "rhs"}
  1263 %     and is an existing nominal datatype with the free-variable function @{text "fv\<^isup>\<alpha>"}\\
  1263 %     and is an existing nominal datatype with the free-variable function @{text "fv\<^isup>\<alpha>"}\\
  1264   $\bullet$ & @{term "{}"} otherwise
  1264   $\bullet$ & @{term "{}"} otherwise
  1265   \end{tabular}
  1265   \end{tabular}
  1294   @{text t}. Therefore we have to subtract @{text "set (bn as)"} from @{text
  1294   @{text t}. Therefore we have to subtract @{text "set (bn as)"} from @{text
  1295   "fv\<^bsub>trm\<^esub> t"}. However, we also need to add all atoms that are
  1295   "fv\<^bsub>trm\<^esub> t"}. However, we also need to add all atoms that are
  1296   free in @{text "as"}. This is what the purpose of the function @{text
  1296   free in @{text "as"}. This is what the purpose of the function @{text
  1297   "fv\<^bsub>bn\<^esub>"} is.  In contrast, in @{text "Let_rec"} we have a
  1297   "fv\<^bsub>bn\<^esub>"} is.  In contrast, in @{text "Let_rec"} we have a
  1298   recursive binder where we want to also bind all occurrences of the atoms
  1298   recursive binder where we want to also bind all occurrences of the atoms
  1299   @{text "bn as"} inside @{text "as"}. Therefore we have to subtract @{text
  1299   in @{text "set (bn as)"} inside @{text "as"}. Therefore we have to subtract @{text
  1300   "set (bn as)"} from @{text "fv\<^bsub>assn\<^esub> as"}, as well as from
  1300   "set (bn as)"} from @{text "fv\<^bsub>assn\<^esub> as"}, as well as from
  1301   @{text "fv\<^bsub>trm\<^esub> t"}. An interesting point in this example is
  1301   @{text "fv\<^bsub>trm\<^esub> t"}. An interesting point in this example is
  1302   that an assignment ``alone'' does not have any bound variables. Only in the
  1302   that an assignment ``alone'' does not have any bound variables. Only in the
  1303   context of a @{text Let} or @{text "Let_rec"} will some atoms become bound.  
  1303   context of a @{text Let} or @{text "Let_rec"} will some atoms become bound.  
  1304   This is a phenomenon 
  1304   This is a phenomenon 
  1356   \begin{itemize}
  1356   \begin{itemize}
  1357   \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the 
  1357   \item The @{text "(x\<^isub>i, y\<^isub>i)"} are bodies of shallow binders with type @{text "ty"}. We assume the 
  1358   \mbox{@{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"}} are the corresponding binders. For the binding mode
  1358   \mbox{@{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"}} are the corresponding binders. For the binding mode
  1359   \isacommand{bind\_set} we generate the premise
  1359   \isacommand{bind\_set} we generate the premise
  1360   \begin{center}
  1360   \begin{center}
  1361    @{term "\<exists>p. (u\<^isub>1 \<union> \<xi> \<union> u\<^isub>m, x\<^isub>i) \<approx>gen alpha_ty fv_ty\<^isub>i p (v\<^isub>1 \<union> \<xi> \<union> v\<^isub>m, y\<^isub>i)"}
  1361    @{term "\<exists>p. (u\<^isub>1 \<union> \<xi> \<union> u\<^isub>m, x\<^isub>i) \<approx>gen alpha_ty fv_ty p (v\<^isub>1 \<union> \<xi> \<union> v\<^isub>m, y\<^isub>i)"}
  1362   \end{center}
  1362   \end{center}
  1363 
  1363 
  1364   For the binding mode \isacommand{bind} we use $\approx_{\textit{list}}$, and for
  1364   For the binding mode \isacommand{bind}, we use $\approx_{\textit{list}}$, and for
  1365   binding mode \isacommand{bind\_res} we use $\approx_{\textit{res}}$. 
  1365   binding mode \isacommand{bind\_res} we use $\approx_{\textit{res}}$ instead. 
  1366 
  1366 
  1367   \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep non-recursive binders with type @{text "ty"}
  1367   \item The @{text "(x\<^isub>i, y\<^isub>i)"} are deep non-recursive binders with type @{text "ty"}
  1368   and @{text bn} being the auxiliary binding function. We assume 
  1368   and @{text bn} being the auxiliary binding function. We assume 
  1369   @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. 
  1369   @{text "(u\<^isub>1, v\<^isub>1),\<dots>,(u\<^isub>m, v\<^isub>m)"} are the corresponding bodies with types @{text "ty\<^isub>1,\<dots>, ty\<^isub>m"}. 
  1370   For the binding mode \isacommand{bind\_set} we generate two premises
  1370   For the binding mode \isacommand{bind\_set} we generate two premises
  1394 
  1394 
  1395   \noindent
  1395   \noindent
  1396   From these definition it is clear why we can only support one binding mode per binder
  1396   From these definition it is clear why we can only support one binding mode per binder
  1397   and body, as we cannot mix the relations $\approx_{\textit{set}}$, $\approx_{\textit{list}}$
  1397   and body, as we cannot mix the relations $\approx_{\textit{set}}$, $\approx_{\textit{list}}$
  1398   and $\approx_{\textit{res}}$. It is also clear why we had to impose the restriction
  1398   and $\approx_{\textit{res}}$. It is also clear why we had to impose the restriction
  1399   of excluding overlapping binders, as these would need to be translated to separate
  1399   of excluding overlapping binders, as these would need to be translated into separate
  1400   abstractions.
  1400   abstractions.
  1401 
  1401 
  1402 
  1402 
  1403   The only cases that are not covered by the rules above are the cases where @{text "(x\<^isub>i, y\<^isub>i)"} is
  1403   The only cases that are not covered by the rules above are the cases where @{text "(x\<^isub>i, y\<^isub>i)"} is
  1404   neither a binder nor a body. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"}  provided
  1404   neither a binder nor a body in a binding clause. Then we just generate @{text "x\<^isub>i \<approx>ty y\<^isub>i"}  provided
  1405   the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are 
  1405   the type of @{text "x\<^isub>i"} and @{text "y\<^isub>i"} is @{text ty} and the arguments are 
  1406   recursive arguments of the term-constructor. If they are non-recursive arguments
  1406   recursive arguments of the term-constructor. If they are non-recursive arguments,
  1407   then we generate just @{text "x\<^isub>i = y\<^isub>i"}.
  1407   then we generate just @{text "x\<^isub>i = y\<^isub>i"}.
  1408 
  1408 
  1409   {\bf TODO (I do not understand the definition below yet).} 
  1409 
  1410 
  1410   The definition of the alpha-equivalence relations @{text "\<approx>bn"} for binding functions 
  1411   The alpha-equivalence relations for binding functions are similar to the alpha-equivalences
  1411   are similar. We again have conclusions of the form \mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>bn C y\<^isub>1 \<dots> y\<^isub>n"}}. We
  1412   for their respective types, the difference is that they omit checking the arguments that
  1412   need to generate premises for each pair @{text "(x\<^isub>i, y\<^isub>i)"} depending on whether @{text "x\<^isub>i"} 
  1413   are bound. We assumed that there are no bindings in the type on which the binding function
  1413   occurs in @{text "rhs"} of  the clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}:
  1414   is defined so, there are no permutations involved. For a binding function clause 
  1414 
  1415   @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, two instances of the constructor are equivalent
  1415   \begin{center}
  1416   @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx> C y\<^isub>1 \<dots> y\<^isub>n"} if:
  1416   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1417   \begin{center}
  1417   $\bullet$ & @{text "x\<^isub>i \<approx>ty y\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text rhs}
  1418   \begin{tabular}{cp{7cm}}
  1418   and the type of @{text "x\<^isub>i"} is @{text "ty"}\\
  1419   $\bullet$ & @{text "x\<^isub>j"} is not of a type being defined and occurs in @{text "rhs"}\\
  1419   $\bullet$ & @{text "x\<^isub>i \<approx>bn y\<^isub>i"} provided @{text "x\<^isub>i"} occurs in @{text rhs}
  1420   $\bullet$ & @{text "x\<^isub>j = y\<^isub>j"} provided @{text "x\<^isub>j"} is not of a type being defined
  1420   with the recursive call @{text "bn x\<^isub>i"}\\
  1421     and does not occur in @{text "rhs"}\\
  1421   $\bullet$ & none provided @{text "x\<^isub>i"} occurs in @{text rhs} but it is not
  1422   $\bullet$ & @{text "x\<^isub>j \<approx>bn\<^isub>m y\<^isub>j"} provided @{text "x\<^isub>j"} is of a type being defined
  1422   in a recursive call involving a @{text "bn"}
  1423     occuring in @{text "rhs"} under the binding function @{text "bn\<^isub>m"}\\
  1423   \end{tabular}
  1424   $\bullet$ & @{text "x\<^isub>j \<approx> y\<^isub>j"} otherwise\\
  1424   \end{center}
  1425   \end{tabular}
  1425 
  1426   \end{center}
  1426    Again lets take a look at an example for these definitions. For \eqref{letrecs}
  1427 
       
  1428   Again lets take a look at an example for these definitions. For \eqref{letrecs}
       
  1429   we have three relations, namely $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and
  1427   we have three relations, namely $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and
  1430   $\approx_{\textit{bn}}$, with the clauses as follows:
  1428   $\approx_{\textit{bn}}$, with the clauses as follows:
  1431 
  1429 
  1432   \begin{center}
  1430   \begin{center}
  1433   \begin{tabular}{@ {}c @ {}}
  1431   \begin{tabular}{@ {}c @ {}}
  1457   \noindent
  1455   \noindent
  1458   Note the difference between  $\approx_{\textit{assn}}$ and
  1456   Note the difference between  $\approx_{\textit{assn}}$ and
  1459   $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of 
  1457   $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of 
  1460   the components in an assignment that are \emph{not} bound. Therefore we have
  1458   the components in an assignment that are \emph{not} bound. Therefore we have
  1461   a $\approx_{\textit{bn}}$-premise in the clause for @{text "Let"} (which is 
  1459   a $\approx_{\textit{bn}}$-premise in the clause for @{text "Let"} (which is 
  1462   a non-recursive binder), since the terms inside an assignment are not meant 
  1460   a non-recursive binder). The reason is that the terms inside an assignment are not meant 
  1463   to be under the binder. Such a premise is not needed in @{text "Let_rec"}, 
  1461   to be under the binder. Such a premise is not needed in @{text "Let_rec"}, 
  1464   because there everything from the assignment is under the binder. 
  1462   because there everything from the assignment is under the binder. 
  1465 *}
  1463 *}
  1466 
  1464 
  1467 section {* Establishing the Reasoning Infrastructure *}
  1465 section {* Establishing the Reasoning Infrastructure *}
  1468 
  1466 
  1469 text {*
  1467 text {*
  1470   Having made all these definition for raw terms, we can start to introduce
  1468   Having made all crucial definitions for raw terms, we can start introducing
  1471   the resoning infrastructure for the specified types. For this we first
  1469   the resoning infrastructure for the types the user specified. For this we first
  1472   have to show that the alpha-equivalence relation defined in the previous
  1470   have to show that the alpha-equivalence relation defined in the previous
  1473   sections are indeed equivalence relations. 
  1471   sections are indeed equivalence relations. 
  1474 
  1472 
  1475   \begin{lemma} 
  1473   \begin{lemma} 
  1476   Given the raw types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} and binding functions
  1474   Given the raw types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} and binding functions
  1477   @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, the relations @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"} and 
  1475   @{text "bn\<^isub>1, \<dots>, bn\<^isub>m"}, the relations @{text "\<approx>ty\<^isub>1, \<dots>, \<approx>ty\<^isub>n"} and 
  1478   @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} are equivalence relations and equivariant.
  1476   @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} are equivalence relations and equivariant.
  1479   \end{lemma}
  1477   \end{lemma}
  1480 
  1478 
  1481   \begin{proof} 
  1479   \begin{proof} 
  1482   The proof is by induction over the definitions. The non-trivial
  1480   The proof is by mutual induction over the definitions. The non-trivial
  1483   cases involves premises build up by $\approx_{\textit{set}}$, 
  1481   cases involve premises build up by $\approx_{\textit{set}}$, 
  1484   $\approx_{\textit{res}}$ and $\approx_{\textit{list}}$. They 
  1482   $\approx_{\textit{res}}$ and $\approx_{\textit{list}}$. They 
  1485   can be dealt with like in Lemma~\ref{alphaeq}.
  1483   can be dealt with as in Lemma~\ref{alphaeq}.
  1486   \end{proof}
  1484   \end{proof}
  1487 
  1485 
  1488   \noindent 
  1486   \noindent 
  1489   We can feed this lemma into our quotient package and obtain new types @{text
  1487   We can feed this lemma into our quotient package and obtain new types @{text
  1490   "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types @{text
  1488   "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types @{text