Paper/Paper.thy
changeset 1771 3e71af53cedb
parent 1770 26e44bcddb5b
child 1775 86122d793f32
equal deleted inserted replaced
1770:26e44bcddb5b 1771:3e71af53cedb
   211   
   211   
   212   \noindent
   212   \noindent
   213   The scope of the binding is indicated by labels given to the types, for
   213   The scope of the binding is indicated by labels given to the types, for
   214   example @{text "s::trm"}, and a binding clause, in this case
   214   example @{text "s::trm"}, and a binding clause, in this case
   215   \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   215   \isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
   216   clause states to bind in @{text s} all the names the function call @{text
   216   clause states to bind in @{text s} all the names the function @{text
   217   "bn(as)"} returns.  This style of specifying terms and bindings is heavily
   217   "bn(as)"} returns.  This style of specifying terms and bindings is heavily
   218   inspired by the syntax of the Ott-tool \cite{ott-jfp}.
   218   inspired by the syntax of the Ott-tool \cite{ott-jfp}.
   219 
   219 
   220   However, we will not be able to cope with all specifications that are
   220   However, we will not be able to cope with all specifications that are
   221   allowed by Ott. One reason is that Ott lets the user to specify ``empty'' 
   221   allowed by Ott. One reason is that Ott lets the user to specify ``empty'' 
   552   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   552   @{text "p \<bullet> (f x) = f (p \<bullet> x)"}
   553   \end{equation}
   553   \end{equation}
   554  
   554  
   555   \noindent
   555   \noindent
   556   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   556   From property \eqref{equivariancedef} and the definition of @{text supp}, we 
   557   can be easily deduce that equivariant functions have empty support.
   557   can be easily deduce that equivariant functions have empty support. There is
       
   558   also a similar notion for equivariant relations, say @{text R}, namely the property
       
   559   that
       
   560   %
       
   561   \begin{center}
       
   562   @{text "x R y"} \;\;implies\;\; @{text "(p \<bullet> x) R (p \<bullet> y)"}
       
   563   \end{center}
   558 
   564 
   559   Finally, the nominal logic work provides us with convenient means to rename 
   565   Finally, the nominal logic work provides us with convenient means to rename 
   560   binders. While in the older version of Nominal Isabelle, we used extensively 
   566   binders. While in the older version of Nominal Isabelle, we used extensively 
   561   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   567   Property~\ref{swapfreshfresh} for renaming single binders, this property 
   562   proved unwieldy for dealing with multiple binders. For such binders the 
   568   proved unwieldy for dealing with multiple binders. For such binders the 
   923   (possibly empty) list of \emph{binding clauses}, which indicate the binders
   929   (possibly empty) list of \emph{binding clauses}, which indicate the binders
   924   and their scope in a term-constructor.  They come in three \emph{modes}:
   930   and their scope in a term-constructor.  They come in three \emph{modes}:
   925 
   931 
   926   \begin{center}
   932   \begin{center}
   927   \begin{tabular}{l}
   933   \begin{tabular}{l}
   928   \isacommand{bind}\; {\it binders}\; \isacommand{in}\; {\it label}\\
   934   \isacommand{bind}\; {\it binder}\; \isacommand{in}\; {\it label}\\
   929   \isacommand{bind\_set}\; {\it binders}\; \isacommand{in}\; {\it label}\\
   935   \isacommand{bind\_set}\; {\it binder}\; \isacommand{in}\; {\it label}\\
   930   \isacommand{bind\_res}\; {\it binders}\; \isacommand{in}\; {\it label}\\
   936   \isacommand{bind\_res}\; {\it binder}\; \isacommand{in}\; {\it label}\\
   931   \end{tabular}
   937   \end{tabular}
   932   \end{center}
   938   \end{center}
   933 
   939 
   934   \noindent
   940   \noindent
   935   The first mode is for binding lists of atoms (the order of binders matters);
   941   The first mode is for binding lists of atoms (the order of binders matters);
  1112   extract datatype definitions from the specification and then define 
  1118   extract datatype definitions from the specification and then define 
  1113   expicitly an alpha-equivalence relation over them.
  1119   expicitly an alpha-equivalence relation over them.
  1114 
  1120 
  1115 
  1121 
  1116   The datatype definition can be obtained by stripping off the 
  1122   The datatype definition can be obtained by stripping off the 
  1117   binding clauses and the labels on the types. We also have to invent
  1123   binding clauses and the labels from the types. We also have to invent
  1118   new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"}
  1124   new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"}
  1119   given by the user. In our implementation we just use the affix ``@{text "_raw"}''.
  1125   given by the user. In our implementation we just use the affix ``@{text "_raw"}''.
  1120   But for the purpose of this paper, we just use the superscript @{text "_\<^sup>\<alpha>"} to indicate 
  1126   But for the purpose of this paper, we use the superscript @{text "_\<^sup>\<alpha>"} to indicate 
  1121   that a notion is defined over alpha-equivalence classes and leave it out 
  1127   that a notion is defined over alpha-equivalence classes and leave it out 
  1122   for the corresponding notion defined on the ``raw'' level. So for example 
  1128   for the corresponding notion defined on the ``raw'' level. So for example 
  1123   we have
  1129   we have
  1124   
  1130   
  1125   \begin{center}
  1131   \begin{center}
  1141   %
  1147   %
  1142   \begin{equation}\label{ceqvt}
  1148   \begin{equation}\label{ceqvt}
  1143   @{text "p \<bullet> (C x\<^isub>1 \<dots> x\<^isub>n) = C (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"}
  1149   @{text "p \<bullet> (C x\<^isub>1 \<dots> x\<^isub>n) = C (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"}
  1144   \end{equation}
  1150   \end{equation}
  1145   
  1151   
  1146   % TODO: we did not define permutation types
       
  1147   %\noindent
       
  1148   %From this definition we can easily show that the raw datatypes are 
       
  1149   %all permutation types (Def ??) by a simple structural induction over
       
  1150   %the @{text "ty"}s.
       
  1151 
       
  1152   The first non-trivial step we have to perform is the generation free-variable 
  1152   The first non-trivial step we have to perform is the generation free-variable 
  1153   functions from the specifications. Given the raw types @{text "ty\<^isub>1 \<dots> ty\<^isub>n"}
  1153   functions from the specifications. Given the raw types @{text "ty\<^isub>1 \<dots> ty\<^isub>n"}
  1154   we need to define free-variable functions
  1154   we need to define free-variable functions
  1155 
  1155 
  1156   \begin{center}
  1156   \begin{center}
  1158   \end{center}
  1158   \end{center}
  1159 
  1159 
  1160   \noindent
  1160   \noindent
  1161   We define them together with auxiliary free-variable functions for
  1161   We define them together with auxiliary free-variable functions for
  1162   the binding functions. Given binding functions 
  1162   the binding functions. Given binding functions 
  1163   @{text "bn\<^isub>1 \<dots> bn\<^isub>m"} we need to define
  1163   @{text "bn\<^isub>1 \<dots> bn\<^isub>m"} we define
  1164   %
  1164   %
  1165   \begin{center}
  1165   \begin{center}
  1166   @{text "fv_bn\<^isub>1, \<dots>, fv_bn\<^isub>m"}
  1166   @{text "fv_bn\<^isub>1, \<dots>, fv_bn\<^isub>m"}
  1167   \end{center}
  1167   \end{center}
  1168 
  1168 
  1169   \noindent
  1169   \noindent
  1170   The reason for this setup is that in a deep binder not all atoms have to be
  1170   The reason for this setup is that in a deep binder not all atoms have to be
  1171   bound, as we shall see in an example below. We need therefore a function
  1171   bound, as we saw in the example with ``plain'' @{text Let}s. We need therefore a function
  1172   that calculates those unbound atoms. 
  1172   that calculates those unbound atoms. 
  1173 
  1173 
  1174   While the idea behind these
  1174   While the idea behind these
  1175   free-variable functions is clear (they just collect all atoms that are not bound),
  1175   free-variable functions is clear (they just collect all atoms that are not bound),
  1176   because of our rather complicated binding mechanisms their definitions are
  1176   because of our rather complicated binding mechanisms their definitions are
  1177   somewhat involved.
  1177   somewhat involved.
  1178   Given a term-constructor @{text "C"} of type @{text ty} with argument types
  1178   Given a term-constructor @{text "C"} of type @{text ty} with argument types
  1179   \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function
  1179   \mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function
  1180   @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values
  1180   @{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values, @{text v},
  1181   calculated below for each argument. 
  1181   calculated below for each argument. 
  1182   First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, 
  1182   First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, 
  1183   we can determine whether the argument is a shallow or deep
  1183   we can determine whether the argument is a shallow or deep
  1184   binder, and in the latter case also whether it is a recursive or
  1184   binder, and in the latter case also whether it is a recursive or
  1185   non-recursive binder. 
  1185   non-recursive binder. 
  1186   %
  1186   %
  1187   \begin{equation}\label{deepbinder}
  1187   \begin{equation}\label{deepbinder}
  1188   \mbox{%
  1188   \mbox{%
  1189   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1189   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1190   $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\
  1190   $\bullet$ & @{term "v = {}"} provided @{text "x\<^isub>i"} is a shallow binder\\
  1191   $\bullet$ & @{text "fv_bn x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep
  1191   $\bullet$ & @{text "v = fv_bn x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep
  1192       non-recursive binder with the auxiliary binding function @{text "bn"}\\
  1192       non-recursive binder with the auxiliary binding function @{text "bn"}\\
  1193   $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn x\<^isub>i"} provided @{text "x\<^isub>i"} is
  1193   $\bullet$ & @{text "v = fv_ty\<^isub>i x\<^isub>i - bn x\<^isub>i"} provided @{text "x\<^isub>i"} is
  1194       a deep recursive binder with the auxiliary binding function @{text "bn"}
  1194       a deep recursive binder with the auxiliary binding function @{text "bn"}
  1195   \end{tabular}}
  1195   \end{tabular}}
  1196   \end{equation}
  1196   \end{equation}
  1197 
  1197 
  1198   \noindent
  1198   \noindent
  1213   corresponding binding function. The value for @{text "x\<^isub>i"} is then given by:
  1213   corresponding binding function. The value for @{text "x\<^isub>i"} is then given by:
  1214   %
  1214   %
  1215   \begin{equation}\label{deepbody}
  1215   \begin{equation}\label{deepbody}
  1216   \mbox{%
  1216   \mbox{%
  1217   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1217   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1218   $\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\
  1218   $\bullet$ & @{text "v = {atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\
  1219   $\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\
  1219   $\bullet$ & @{text "v = (atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\
  1220   $\bullet$ & @{text "(atoms (set x\<^isub>i)) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\
  1220   $\bullet$ & @{text "v = (atoms (set x\<^isub>i)) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\
  1221   $\bullet$ & @{text "(fv_ty\<^isub>i x\<^isub>i) - bnds"} provided @{term "ty\<^isub>i"} is one of the raw datatypes
  1221   $\bullet$ & @{text "v = (fv_ty\<^isub>i x\<^isub>i) - bnds"} provided @{term "ty\<^isub>i"} is one of the raw datatypes
  1222      corresponding to the types specified by the user\\
  1222      corresponding to the types specified by the user\\
  1223 %  $\bullet$ & @{text "(fv\<^isup>\<alpha> x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a defined nominal datatype
  1223 %  $\bullet$ & @{text "(fv\<^isup>\<alpha> x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a defined nominal datatype
  1224 %     with a free-variable function @{text "fv\<^isup>\<alpha>"}\\
  1224 %     with a free-variable function @{text "fv\<^isup>\<alpha>"}\\
  1225   $\bullet$ & @{term "{}"} otherwise
  1225   $\bullet$ & @{term "v = {}"} otherwise
  1226   \end{tabular}}
  1226   \end{tabular}}
  1227   \end{equation}
  1227   \end{equation}
  1228 
  1228 
  1229   \noindent 
  1229   \noindent 
  1230   Like the coercion function @{text atom} used earlier, @{text "atoms"} coerces 
  1230   Like the coercion function @{text atom} used earlier, @{text "atoms"} coerces 
  1247   appear in @{text "rhs"} we generate the premise according to the
  1247   appear in @{text "rhs"} we generate the premise according to the
  1248   rules for @{text "fv_ty"} described above in (\ref{deepbinder}--\ref{deepbody}). Otherwise:
  1248   rules for @{text "fv_ty"} described above in (\ref{deepbinder}--\ref{deepbody}). Otherwise:
  1249 
  1249 
  1250   \begin{center}
  1250   \begin{center}
  1251   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1251   \begin{tabular}{c@ {\hspace{2mm}}p{7cm}}
  1252    $\bullet$ & @{text "fv_bn x\<^isub>i"} provided @{text "rhs"} contains the
  1252    $\bullet$ & @{text "v = fv_bn x\<^isub>i"} provided @{text "rhs"} contains the
  1253     recursive call @{text "bn x\<^isub>i"}\medskip\\
  1253     recursive call @{text "bn x\<^isub>i"}\medskip\\
  1254   $\bullet$ & @{term "{}"} provided @{text "rhs"} contains
  1254   $\bullet$ & @{term "v = {}"} provided @{text "rhs"} contains
  1255     @{term "x\<^isub>i"} and @{term "x\<^isub>i"} is of atom type.
  1255     @{term "x\<^isub>i"} and @{term "x\<^isub>i"} is of atom type.
  1256   \end{tabular}
  1256   \end{tabular}
  1257   \end{center}
  1257   \end{center}
  1258 
  1258 
  1259   \noindent
  1259   \noindent
  1436 
  1436 
  1437   \begin{center}
  1437   \begin{center}
  1438   \begin{tabular}{@ {}c @ {}}
  1438   \begin{tabular}{@ {}c @ {}}
  1439   \infer{@{text "ANil \<approx>\<^bsub>assn\<^esub> ANil"}}{}\\
  1439   \infer{@{text "ANil \<approx>\<^bsub>assn\<^esub> ANil"}}{}\\
  1440   \infer{@{text "ACons a t as \<approx>\<^bsub>assn\<^esub> ACons a' t' as"}}
  1440   \infer{@{text "ACons a t as \<approx>\<^bsub>assn\<^esub> ACons a' t' as"}}
  1441   {@{text "a = a'"} & @{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>assn\<^esub> as'"}}\medskip\\
  1441   {@{text "a = a'"} & @{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>assn\<^esub> as'"}}
  1442   \end{tabular}
  1442   \end{tabular}
  1443   \end{center}
  1443   \end{center}
  1444 
  1444 
  1445   \begin{center}
  1445   \begin{center}
  1446   \begin{tabular}{@ {}c @ {}}
  1446   \begin{tabular}{@ {}c @ {}}
  1447   \infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\\
  1447   \infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\\
  1448   \infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}}
  1448   \infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}}
  1449   {@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\medskip\\
  1449   {@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & @{text "as \<approx>\<^bsub>bn\<^esub> as'"}}
  1450   \end{tabular}
  1450   \end{tabular}
  1451   \end{center}
  1451   \end{center}
  1452 
  1452 
  1453   \noindent
  1453   \noindent
  1454   Note the difference between  $\approx_{\textit{assn}}$ and
  1454   Note the difference between  $\approx_{\textit{assn}}$ and
  1455   $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of 
  1455   $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of 
  1456   the components in an assignment that are \emph{not} bound. Therefore we have
  1456   the components in an assignment that are \emph{not} bound. Therefore we have
  1457   a $\approx_{\textit{bn}}$-premise in the clause for @{text "Let"} (which is 
  1457   a $\approx_{\textit{bn}}$-premise in the clause for @{text "Let"} (which is 
  1458   a non-recursive binder). The reason is that the terms inside an assignment are not meant 
  1458   a non-recursive binder). The underlying reason is that the terms inside an assignment are not meant 
  1459   to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, 
  1459   to be ``under'' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"}, 
  1460   because there everything from the assignment is under the binder. 
  1460   because there everything from the assignment is under the binder. 
  1461 *}
  1461 *}
  1462 
  1462 
  1463 section {* Establishing the Reasoning Infrastructure *}
  1463 section {* Establishing the Reasoning Infrastructure *}
  1539   Having established respectfulness for every raw term-constructor, the 
  1539   Having established respectfulness for every raw term-constructor, the 
  1540   quotient package is able to automatically deduce \eqref{distinctalpha} from \eqref{distinctraw}.
  1540   quotient package is able to automatically deduce \eqref{distinctalpha} from \eqref{distinctraw}.
  1541   In fact we can from now on lift facts from the raw level to the alpha-equated level
  1541   In fact we can from now on lift facts from the raw level to the alpha-equated level
  1542   as long as they contain raw term-constructors only. The 
  1542   as long as they contain raw term-constructors only. The 
  1543   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
  1543   induction principles derived by the datatype package in Isabelle/HOL for the types @{text
  1544   "ty\<AL>\<^bsub>1..n\<^esub>"} fall into this category. So we can also add to our infrastructure
  1544   "ty\<^bsub>1..n\<^esub>"} fall into this category. So we can also add to our infrastructure
  1545   induction principles that establish
  1545   induction principles that establish
  1546 
  1546 
  1547   \begin{center}
  1547   \begin{center}
  1548   @{text "P\<^bsub>ty\<^isub>1\<^esub> y\<^isub>1 \<dots> P\<^bsub>ty\<^isub>n\<^esub> y\<^isub>n "}
  1548   @{text "P\<^bsub>ty\<AL>\<^isub>1\<^esub> y\<^isub>1 \<dots> P\<^bsub>ty\<AL>\<^isub>n\<^esub> y\<^isub>n "}
  1549   \end{center} 
  1549   \end{center} 
  1550 
  1550 
  1551   \noindent
  1551   \noindent
  1552   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<^isub>i\<^esub>"} stand for properties
  1552   for all @{text "y\<^isub>i"} wherby the variables @{text "P\<^bsub>ty\<AL>\<^isub>i\<^esub>"} stand for properties
  1553   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
  1553   defined over the types @{text "ty\<AL>\<^isub>1 \<dots> ty\<AL>\<^isub>n"}. The premises of 
  1554   these induction principles look
  1554   these induction principles look
  1555   as follows
  1555   as follows
  1556 
  1556 
  1557   \begin{center}
  1557   \begin{center}
  1558   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<^isub>i\<^esub> x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<^isub>j\<^esub> x\<^isub>j \<Rightarrow> P\<^bsub>ty\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
  1558   @{text "\<forall>x\<^isub>1\<dots>x\<^isub>n. P\<^bsub>ty\<AL>\<^isub>i\<^esub> x\<^isub>i \<and> \<dots> \<and> P\<^bsub>ty\<AL>\<^isub>j\<^esub> x\<^isub>j \<Rightarrow> P\<^bsub>ty\<AL>\<^esub> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n)"} 
  1559   \end{center}
  1559   \end{center}
  1560 
  1560 
  1561   \noindent
  1561   \noindent
  1562   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1562   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1563   Next we lift the permutation operations defined in \eqref{ceqvt} for
  1563   Next we lift the permutation operations defined in \eqref{ceqvt} for
  1604   @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"}
  1604   @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"}
  1605   \end{center}
  1605   \end{center}
  1606 
  1606 
  1607   \noindent
  1607   \noindent
  1608   are alpha-equivalent. This gives us conditions when the corresponding
  1608   are alpha-equivalent. This gives us conditions when the corresponding
  1609   alpha-equated terms are equal, namely
  1609   alpha-equated terms are \emph{equal}, namely
  1610 
  1610 
  1611   \begin{center}
  1611   \begin{center}
  1612   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n = C\<^sup>\<alpha> y\<^isub>1 \<dots> y\<^isub>n"}
  1612   @{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>n = C\<^sup>\<alpha> y\<^isub>1 \<dots> y\<^isub>n"}
  1613   \end{center}
  1613   \end{center}
  1614 
  1614 
  1615   \noindent
  1615   \noindent
  1616   We call these conditions as \emph{quasi-injectivity}. Except for one function, which
  1616   We call these conditions as \emph{quasi-injectivity}. Except for one function, which
  1617   we have to lift in the next section, we completed
  1617   we have to lift in the next section, we completed
  1618   the lifting part of establishing the reasoning infrastructure. 
  1618   the lifting part of establishing the reasoning infrastructure. 
  1619 
  1619 
  1620   Working bow completely on the alpha-equated level, we can first show that 
  1620   By working now completely on the alpha-equated level, we can first show that 
  1621   the free-variable functions and binding functions
  1621   the free-variable functions and binding functions
  1622   are equivariant, namely
  1622   are equivariant, namely
  1623 
  1623 
  1624   \begin{center}
  1624   \begin{center}
  1625   \begin{tabular}{rcl}
  1625   \begin{tabular}{rcl}
  1761   \end{equation}
  1761   \end{equation}
  1762 
  1762 
  1763   \noindent
  1763   \noindent
  1764   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1764   where the @{text "x\<^isub>i, \<dots>, x\<^isub>j"} are the recursive arguments of @{text "C\<^sup>\<alpha>"}. 
  1765   The problem with this implication is that in general it is not easy to establish it.
  1765   The problem with this implication is that in general it is not easy to establish it.
  1766   The reason is we cannot make any assumption about the binders in @{text "C\<^sup>\<alpha>"} 
  1766   The reason is that we cannot make any assumption about the binders that might be in @{text "C\<^sup>\<alpha>"} 
  1767   (for example we cannot assume the variable convention for them).
  1767   (for example we cannot assume the variable convention for them).
  1768 
  1768 
  1769   In \cite{UrbanTasson05} we introduced a method for automatically
  1769   In \cite{UrbanTasson05} we introduced a method for automatically
  1770   strengthening weak induction principles for terms containing single
  1770   strengthening weak induction principles for terms containing single
  1771   binders. These stronger induction principles allow the user to make additional
  1771   binders. These stronger induction principles allow the user to make additional
  1772   assumptions about binders when proving the induction hypotheses. 
  1772   assumptions about binders. 
  1773   These additional assumptions amount to a formal
  1773   These additional assumptions amount to a formal
  1774   version of the informal variable convention for binders. A natural question is
  1774   version of the informal variable convention for binders. A natural question is
  1775   whether we can also strengthen the weak induction principles involving
  1775   whether we can also strengthen the weak induction principles involving
  1776   general binders. We will indeed be able to so, but for this we need an 
  1776   the general binders presented here. We will indeed be able to so, but for this we need an 
  1777   additional notion for permuting deep binders. 
  1777   additional notion for permuting deep binders. 
  1778 
  1778 
  1779   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1779   Given a binding function @{text "bn"} we define an auxiliary permutation 
  1780   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1780   operation @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} which permutes only bound arguments in a deep binder.
  1781   Assuming a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1781   Assuming a clause of @{text bn} is defined as @{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then
  1794   $\bullet$ & @{text "y\<^isub>i \<equiv> p \<bullet> x\<^isub>i"} otherwise
  1794   $\bullet$ & @{text "y\<^isub>i \<equiv> p \<bullet> x\<^isub>i"} otherwise
  1795   \end{tabular}
  1795   \end{tabular}
  1796   \end{center}
  1796   \end{center}
  1797   
  1797   
  1798   \noindent
  1798   \noindent
  1799   Using the quotient package again we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1799   Using again the quotient package  we can lift the @{text "_ \<bullet>\<^bsub>bn\<^esub> _"} function to 
  1800   alpha-equated terms. We can then prove the following two facts
  1800   alpha-equated terms. We can then prove the following two facts
  1801 
  1801 
  1802   \begin{lemma}\label{permutebn} 
  1802   \begin{lemma}\label{permutebn} 
  1803   Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1803   Given a binding function @{text "bn\<^sup>\<alpha>"} then for all @{text p}
  1804   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"} and {\it ii)}
  1804   {\it i)} @{text "p \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"} and {\it ii)}
  1805     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"}.
  1805     @{text "fv_bn\<^isup>\<alpha> x = fv_bn\<^isup>\<alpha> (p \<bullet>\<^bsub>bn\<^sup>\<alpha>\<^esub> x)"}.
  1806   \end{lemma}
  1806   \end{lemma}
  1807 
  1807 
  1808   \begin{proof} 
  1808   \begin{proof} 
  1809   By induction on @{text x}. The equation follow by simple unfolding 
  1809   By induction on @{text x}. The equations follow by simple unfolding 
  1810   of the definitions. 
  1810   of the definitions. 
  1811   \end{proof}
  1811   \end{proof}
  1812 
  1812 
  1813   \noindent
  1813   \noindent
  1814   The first property states that a permutation applied to a binding function is
  1814   The first property states that a permutation applied to a binding function is
  1820   to rename the binders in @{text x}, without ``changing'' @{text x}. In case of the 
  1820   to rename the binders in @{text x}, without ``changing'' @{text x}. In case of the 
  1821   @{text "Let"} term-constructor from the example shown 
  1821   @{text "Let"} term-constructor from the example shown 
  1822   \eqref{letpat} this means for a permutation @{text "r"}:
  1822   \eqref{letpat} this means for a permutation @{text "r"}:
  1823   %
  1823   %
  1824   \begin{equation}\label{renaming}
  1824   \begin{equation}\label{renaming}
  1825   \mbox{if @{term "supp (Abs_lst (bn p) t)  \<sharp>* r"} 
  1825   \begin{array}{l}
  1826   then @{text "Let p t = Let (r \<bullet>\<^bsub>bn\<^bsub>pat\<^esub>\<^esub> p) (r \<bullet> t)"}}
  1826   \mbox{if @{term "supp (Abs_lst (bn p) t\<^isub>2)  \<sharp>* r"}}\\ 
  1827   \end{equation}
  1827   \qquad\mbox{then @{text "Let p t\<^isub>1 t\<^isub>2 = Let (r \<bullet>\<^bsub>bn\<^bsub>pat\<^esub>\<^esub> p) t\<^isub>1 (r \<bullet> t\<^isub>2)"}}
  1828 
  1828   \end{array}
  1829   \noindent
  1829   \end{equation}
  1830   This fact will be used when establishing the strong induction principles. 
  1830 
  1831   
  1831   \noindent
  1832 
  1832   This fact will be crucial when establishing the strong induction principles. 
  1833   In our running example about @{text "Let"}, they state that instead 
  1833   In our running example about @{text "Let"}, they state that instead 
  1834   of establishing the implication 
  1834   of establishing the implication 
  1835 
  1835 
  1836   \begin{center}
  1836   \begin{center}
  1837   @{text "\<forall>p t. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t)"}
  1837   @{text "\<forall>p t\<^isub>1 t\<^isub>2. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t\<^isub>1 \<and> P\<^bsub>trm\<^esub> t\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t\<^isub>1 t\<^isub>2)"}
  1838   \end{center}
  1838   \end{center}
  1839 
  1839 
  1840   \noindent
  1840   \noindent
  1841   it is sufficient to establish the following implication
  1841   it is sufficient to establish the following implication
  1842   %
  1842   %
  1843   \begin{equation}\label{strong}
  1843   \begin{equation}\label{strong}
  1844   \mbox{\begin{tabular}{l}
  1844   \mbox{\begin{tabular}{l}
  1845   @{text "\<forall>p t c."}\\
  1845   @{text "\<forall>p t\<^isub>1 t\<^isub>2 c."}\\
  1846   \hspace{5mm}@{text "set (bn p) #\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t)"}\\
  1846   \hspace{5mm}@{text "set (bn p) #\<^sup>* c \<and>"}\\
  1847   \hspace{15mm}@{text "\<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t)"}
  1847   \hspace{5mm}@{text "(\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>2)"}\\
       
  1848   \hspace{15mm}@{text "\<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t\<^isub>1 t\<^isub>2)"}
  1848   \end{tabular}}
  1849   \end{tabular}}
  1849   \end{equation}
  1850   \end{equation}
  1850 
  1851 
  1851   \noindent 
  1852   \noindent 
  1852   While this implication contains an additional argument, namely @{text c}, and 
  1853   While this implication contains an additional argument, namely @{text c}, and 
  1863   @{text "\<forall>q c. P\<^bsub>trm\<^esub> c (q \<bullet> t)"} \hspace{4mm} 
  1864   @{text "\<forall>q c. P\<^bsub>trm\<^esub> c (q \<bullet> t)"} \hspace{4mm} 
  1864   @{text "\<forall>q\<^isub>1 q\<^isub>2 c. P\<^bsub>pat\<^esub> (q\<^isub>1 \<bullet>\<^bsub>bn\<^esub> (q\<^isub>2 \<bullet> p))"}
  1865   @{text "\<forall>q\<^isub>1 q\<^isub>2 c. P\<^bsub>pat\<^esub> (q\<^isub>1 \<bullet>\<^bsub>bn\<^esub> (q\<^isub>2 \<bullet> p))"}
  1865   \end{equation} 
  1866   \end{equation} 
  1866 
  1867 
  1867   \noindent
  1868   \noindent
  1868   For the @{text Let} term-constructor  we therefore have to establish @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t)"} 
  1869   For the @{text Let} term-constructor  we therefore have to establish @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"} 
  1869   assuming \eqref{hyps} as induction hypotheses. By Property~\ref{avoiding} we
  1870   assuming \eqref{hyps} as induction hypotheses (the first for @{text t\<^isub>1} and @{text t\<^isub>2}). 
       
  1871   By Property~\ref{avoiding} we
  1870   obtain a permutation @{text "r"} such that 
  1872   obtain a permutation @{text "r"} such that 
  1871   %
  1873   %
  1872   \begin{equation}\label{rprops}
  1874   \begin{equation}\label{rprops}
  1873   @{term "(r \<bullet> set (bn (q \<bullet> p))) \<sharp>* c "}\hspace{4mm}
  1875   @{term "(r \<bullet> set (bn (q \<bullet> p))) \<sharp>* c "}\hspace{4mm}
  1874   @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t)) \<sharp>* r"}
  1876   @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t\<^isub>2)) \<sharp>* r"}
  1875   \end{equation}
  1877   \end{equation}
  1876 
  1878 
  1877   \noindent
  1879   \noindent
  1878   hold. The latter fact and \eqref{renaming} give us
  1880   hold. The latter fact and \eqref{renaming} give us
  1879 
  1881 
  1880   \begin{center}
  1882   \begin{center}
  1881   @{text "Let (q \<bullet> p) (q \<bullet> t) = Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (r \<bullet> (q \<bullet> t))"}
  1883   \begin{tabular}{l}
  1882   \end{center}
  1884   @{text "Let (q \<bullet> p) (q \<bullet> t\<^isub>1) (q \<bullet> t\<^isub>2) ="} \\
  1883 
  1885   \hspace{15mm}@{text "Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2))"}
  1884   \noindent
  1886   \end{tabular}
  1885   So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t)"}, we are can equally
  1887   \end{center}
       
  1888 
       
  1889   \noindent
       
  1890   So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"}, we are can equally
  1886   establish
  1891   establish
  1887 
  1892 
  1888   \begin{center}
  1893   \begin{center}
  1889   @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (r \<bullet> (q \<bullet> t)))"}
  1894   @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2)))"}
  1890   \end{center}
  1895   \end{center}
  1891 
  1896 
  1892   \noindent
  1897   \noindent
  1893   To do so, we will use the implication \eqref{strong} of the strong induction
  1898   To do so, we will use the implication \eqref{strong} of the strong induction
  1894   principle, which requires us to discharge
  1899   principle, which requires us to discharge
  1895   the following three proof obligations:
  1900   the following four proof obligations:
  1896 
  1901 
  1897   \begin{center}
  1902   \begin{center}
  1898   \begin{tabular}{rl}
  1903   \begin{tabular}{rl}
  1899   {\it i)} &   @{text "set (bn (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\
  1904   {\it i)} &   @{text "set (bn (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\
  1900   {\it ii)} &  @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\
  1905   {\it ii)} &  @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\
  1901   {\it iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (r \<bullet> (q \<bullet> t))"}\\
  1906   {\it iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (q \<bullet> t\<^isub>1)"}\\
       
  1907   {\it iv)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (r \<bullet> (q \<bullet> t\<^isub>2))"}\\
  1902   \end{tabular}
  1908   \end{tabular}
  1903   \end{center}
  1909   \end{center}
  1904 
  1910 
  1905   \noindent
  1911   \noindent
  1906   The first follows from \eqref{rprops} and Lemma~\ref{permutebn}.{\it i)}; the 
  1912   The first follows from \eqref{rprops} and Lemma~\ref{permutebn}.{\it i)}; the 
  1907   second and third from the induction hypotheses in \eqref{hyps} (in the latter case
  1913   others from the induction hypotheses in \eqref{hyps} (in the fourth case
  1908   we have to use the fact that @{term "(r \<bullet> (q \<bullet> t)) = (r + q) \<bullet> t"}).
  1914   we have to use the fact that @{term "(r \<bullet> (q \<bullet> t\<^isub>2)) = (r + q) \<bullet> t\<^isub>2"}).
  1909 
  1915 
  1910   Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps},
  1916   Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps},
  1911   we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}.
  1917   we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}.
  1912   This completes the proof showing that the strong induction principle derives from
  1918   This completes the proof showing that the strong induction principle derives from
  1913   the weak induction principle. At the moment we can derive the difficult cases of 
  1919   the weak induction principle. At the moment we can derive the difficult cases of 
  1914   the strong induction principles only by hand, but they are very schematically 
  1920   the strong induction principles only by hand, but they are very schematically 
  1915   so that with little effort we can even derive the strong induction principle for 
  1921   so that with little effort we can even derive them for 
  1916   Core-Haskell given in Figure~\ref{nominalcorehas}. 
  1922   Core-Haskell given in Figure~\ref{nominalcorehas}. 
  1917 *}
  1923 *}
  1918 
  1924 
  1919 
  1925 
  1920 section {* Related Work *}
  1926 section {* Related Work *}
  1928   de-Bruijn representation), but to different bound variables. A similar idea
  1934   de-Bruijn representation), but to different bound variables. A similar idea
  1929   has been recently explored for general binders in the locally nameless
  1935   has been recently explored for general binders in the locally nameless
  1930   approach to binding \cite{chargueraud09}.  There, de-Bruijn indices consist
  1936   approach to binding \cite{chargueraud09}.  There, de-Bruijn indices consist
  1931   of two numbers, one referring to the place where a variable is bound and the
  1937   of two numbers, one referring to the place where a variable is bound and the
  1932   other to which variable is bound. The reasoning infrastructure for both
  1938   other to which variable is bound. The reasoning infrastructure for both
  1933   representations of bindings comes for free in the theorem provers Isabelle/HOL and
  1939   representations of bindings comes for free in the theorem provers, like Isabelle/HOL or
  1934   Coq, for example, as the corresponding term-calculi can be implemented as ``normal''
  1940   Coq, as the corresponding term-calculi can be implemented as ``normal''
  1935   datatypes.  However, in both approaches it seems difficult to achieve our
  1941   datatypes.  However, in both approaches it seems difficult to achieve our
  1936   fine-grained control over the ``semantics'' of bindings (i.e.~whether the
  1942   fine-grained control over the ``semantics'' of bindings (i.e.~whether the
  1937   order of binders should matter, or vacuous binders should be taken into
  1943   order of binders should matter, or vacuous binders should be taken into
  1938   account). To do so, one would require additional predicates that filter out
  1944   account). To do so, one would require additional predicates that filter out
  1939   unwanted terms. Our guess is that such predicates results in rather
  1945   unwanted terms. Our guess is that such predicates results in rather
  1978   meaning in a HOL-based theorem prover.
  1984   meaning in a HOL-based theorem prover.
  1979 
  1985 
  1980   Because of how we set up our definitions, we had to impose restrictions,
  1986   Because of how we set up our definitions, we had to impose restrictions,
  1981   like excluding overlapping deep binders, that are not present in Ott. Our
  1987   like excluding overlapping deep binders, that are not present in Ott. Our
  1982   expectation is that we can still cover many interesting term-calculi from
  1988   expectation is that we can still cover many interesting term-calculi from
  1983   programming language research, for example Core-Haskell. For prviding support
  1989   programming language research, for example Core-Haskell. For providing support
  1984   of neat features in Ott, such as subgrammars, the existing datatype
  1990   of neat features in Ott, such as subgrammars, the existing datatype
  1985   infrastructure in Isabelle/HOL is unfortunately not powerful enough. On the
  1991   infrastructure in Isabelle/HOL is unfortunately not powerful enough. On the
  1986   other hand, we are not aware that Ott can make the distinction between our
  1992   other hand, we are not aware that Ott can make the distinction between our
  1987   three different binding modes. Also, definitions for notions like the free
  1993   three different binding modes. Also, definitions for notions like the free
  1988   variables of a term are work in progress in Ott.
  1994   variables of a term are work in progress in Ott.
  2056   other. We have not yet been able to find a way to avoid such interferences. 
  2062   other. We have not yet been able to find a way to avoid such interferences. 
  2057   On the other hand, such bindings can be made sense of informally \cite{SewellBestiary}.
  2063   On the other hand, such bindings can be made sense of informally \cite{SewellBestiary}.
  2058   This suggest there should be an approriate notion of alpha-equivalence.
  2064   This suggest there should be an approriate notion of alpha-equivalence.
  2059 
  2065 
  2060   Another interesting line of investigation is whether we can go beyond the 
  2066   Another interesting line of investigation is whether we can go beyond the 
  2061   simple-minded form of binding function we adopted from Ott. At the moment, binding
  2067   simple-minded form for binding functions that we adopted from Ott. At the moment, binding
  2062   functions can only return the empty set, a singleton atom set or unions
  2068   functions can only return the empty set, a singleton atom set or unions
  2063   of atom sets (similarly for lists). It remains to be seen whether 
  2069   of atom sets (similarly for lists). It remains to be seen whether 
  2064   properties like \eqref{bnprop} provide us with means to support more interesting
  2070   properties like \eqref{bnprop} provide us with means to support more interesting
  2065   binding functions. 
  2071   binding functions. 
  2066 
  2072