Paper/Paper.thy
changeset 2362 9d8ebeded16f
parent 2361 d73d4d151cce
child 2363 9832641ed955
equal deleted inserted replaced
2361:d73d4d151cce 2362:9d8ebeded16f
  2064   example in the second part of this challenge, @{text "Let"}s involve
  2064   example in the second part of this challenge, @{text "Let"}s involve
  2065   patterns that bind multiple variables at once. In such situations, HOAS
  2065   patterns that bind multiple variables at once. In such situations, HOAS
  2066   representations have to resort to the iterated-single-binders-approach with
  2066   representations have to resort to the iterated-single-binders-approach with
  2067   all the unwanted consequences when reasoning about the resulting terms.
  2067   all the unwanted consequences when reasoning about the resulting terms.
  2068 
  2068 
  2069   In a similar fashion, two formalisations involving general binders have been 
  2069   Two formalisations involving general binders have been 
  2070   performed in older
  2070   performed in older
  2071   versions of Nominal Isabelle (one about Psi-calculi and one about algorithm W 
  2071   versions of Nominal Isabelle (one about Psi-calculi and one about algorithm W 
  2072   \cite{BengtsonParow09, UrbanNipkow09}).  Both
  2072   \cite{BengtsonParow09, UrbanNipkow09}).  Both
  2073   use the approach based on iterated single binders. Our experience with
  2073   use the approach based on iterated single binders. Our experience with
  2074   the latter formalisation has been disappointing. The major pain arose from
  2074   the latter formalisation has been disappointing. The major pain arose from
  2087   this tool have also put forward (on paper) a definition for
  2087   this tool have also put forward (on paper) a definition for
  2088   $\alpha$-equivalence of terms that can be specified in Ott.  This definition is
  2088   $\alpha$-equivalence of terms that can be specified in Ott.  This definition is
  2089   rather different from ours, not using any nominal techniques.  To our
  2089   rather different from ours, not using any nominal techniques.  To our
  2090   knowledge there is also no concrete mathematical result concerning this
  2090   knowledge there is also no concrete mathematical result concerning this
  2091   notion of $\alpha$-equivalence.  A definition for the notion of free variables
  2091   notion of $\alpha$-equivalence.  A definition for the notion of free variables
  2092   in a term are work in progress in Ott.
  2092   is work in progress in Ott.
  2093 
  2093 
  2094   Although we were heavily inspired by their syntax,
  2094   Although we were heavily inspired by the syntax in Ott,
  2095   their definition of $\alpha$-equivalence is unsuitable for our extension of
  2095   its definition of $\alpha$-equivalence is unsuitable for our extension of
  2096   Nominal Isabelle. First, it is far too complicated to be a basis for
  2096   Nominal Isabelle. First, it is far too complicated to be a basis for
  2097   automated proofs implemented on the ML-level of Isabelle/HOL. Second, it
  2097   automated proofs implemented on the ML-level of Isabelle/HOL. Second, it
  2098   covers cases of binders depending on other binders, which just do not make
  2098   covers cases of binders depending on other binders, which just do not make
  2099   sense for our $\alpha$-equated terms. Third, it allows empty types that have no
  2099   sense for our $\alpha$-equated terms. Third, it allows empty types that have no
  2100   meaning in a HOL-based theorem prover. We also had to generalise slightly their 
  2100   meaning in a HOL-based theorem prover. We also had to generalise slightly their 
  2101   binding clauses. In Ott you specify binding clauses with a single body; we 
  2101   binding clauses. In Ott you specify binding clauses with a single body; we 
  2102   allow more than one. We have to do this, because this makes a difference 
  2102   allow more than one. We have to do this, because this makes a difference 
  2103   for our notion of $\alpha$-equivalence in case of \isacommand{bind\_set} and 
  2103   for our notion of $\alpha$-equivalence in case of \isacommand{bind\_set} and 
  2104   \isacommand{bind\_res}. This makes 
  2104   \isacommand{bind\_res}. For example
  2105 
  2105 
  2106   \begin{center}
  2106   \begin{center}
  2107   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  2107   \begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
  2108   @{text "Foo\<^isub>1 xs::name fset t::trm s::trm"} &  
  2108   @{text "Foo\<^isub>1 xs::name fset t::trm s::trm"} &  
  2109       \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "t s"}\\
  2109       \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "t s"}\\
  2112       \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "s"}\\
  2112       \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "s"}\\
  2113   \end{tabular}
  2113   \end{tabular}
  2114   \end{center}
  2114   \end{center}
  2115 
  2115 
  2116   \noindent
  2116   \noindent
  2117   behave differently. In the first term-constructor, we essentially have a single
  2117   in the first term-constructor we have a single
  2118   body, which happens to be ``spread'' over two arguments; in the second we have
  2118   body that happens to be ``spread'' over two arguments; in the second term-constructor we have
  2119   two independent bodies, in which the same variables are bound. As a result we 
  2119   two independent bodies in which the same variables are bound. As a result we 
  2120   have
  2120   have
  2121 
  2121 
  2122   \begin{center}
  2122   \begin{center}
  2123   \begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}l}
  2123   \begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}l}
  2124   @{text "Foo\<^isub>1 {a, b} (a, b) (a, b)"} & $\not=$ & 
  2124   @{text "Foo\<^isub>1 {a, b} (a, b) (a, b)"} & $\not=$ & 
  2126   @{text "Foo\<^isub>2 {a, b} (a, b) (a, b)"} & $=$ & 
  2126   @{text "Foo\<^isub>2 {a, b} (a, b) (a, b)"} & $=$ & 
  2127   @{text "Foo\<^isub>2 {a, b} (a, b) (b, a)"}\\
  2127   @{text "Foo\<^isub>2 {a, b} (a, b) (b, a)"}\\
  2128   \end{tabular}
  2128   \end{tabular}
  2129   \end{center}
  2129   \end{center}
  2130 
  2130 
  2131   Because of how we set up our definitions, we had to impose restrictions,
  2131   \noindent
  2132   like a single binding function for a deep binder, that are not present in Ott. Our
  2132   and therefore need the extra generality to be able to distinguish between 
       
  2133   both specifications.
       
  2134   Because of how we set up our definitions, we also had to impose some restrictions
       
  2135   (like a single binding function for a deep binder) that are not present in Ott. Our
  2133   expectation is that we can still cover many interesting term-calculi from
  2136   expectation is that we can still cover many interesting term-calculi from
  2134   programming language research, for example Core-Haskell. For providing support
  2137   programming language research, for example Core-Haskell. 
  2135   of neat features in Ott, such as subgrammars, the existing datatype
       
  2136   infrastructure in Isabelle/HOL is unfortunately not powerful enough. On the
       
  2137   other hand, we are not aware that Ott can make the distinction between our
       
  2138   three different binding modes.
       
  2139 
  2138 
  2140   Pottier presents in \cite{Pottier06} a language, called C$\alpha$ml, for 
  2139   Pottier presents in \cite{Pottier06} a language, called C$\alpha$ml, for 
  2141   representing terms with general binders inside OCaml. This language is
  2140   representing terms with general binders inside OCaml. This language is
  2142   implemented as a front-end that can be translated to OCaml with a help of
  2141   implemented as a front-end that can be translated to OCaml with the help of
  2143   a library. He presents a type-system in which the scope of general binders
  2142   a library. He presents a type-system in which the scope of general binders
  2144   can be indicated with some special markers, written @{text "inner"} and 
  2143   can be specified using special markers, written @{text "inner"} and 
  2145   @{text "outer"}. With this, it seems, our and his specifications can be
  2144   @{text "outer"}. It seems our and his specifications can be
  2146   inter-translated, but we have not proved this. However, we believe the
  2145   inter-translated as long as ours use the binding mode 
  2147   binding specifications in the style of Ott are a more natural way for 
  2146   \isacommand{bind} only.
  2148   representing terms involving bindings. Pottier gives a definition for 
  2147   However, we have not proved this. Pottier gives a definition for 
  2149   $\alpha$-equivalence, which is similar to our binding mode \isacommand{bind}. 
  2148   $\alpha$-equivalence, which also uses a permutation operation (like ours).
  2150   Although he uses also a permutation in case of abstractions, his
  2149   Still, this definition is rather different from ours and he only proves that
  2151   definition is rather different from ours. He proves that his notion
  2150   it defines an equivalence relation. A complete
  2152   of $\alpha$-equivalence is indeed a equivalence relation, but a complete
       
  2153   reasoning infrastructure is well beyond the purposes of his language. 
  2151   reasoning infrastructure is well beyond the purposes of his language. 
       
  2152   
  2154   In a slightly different domain (programming with dependent types), the 
  2153   In a slightly different domain (programming with dependent types), the 
  2155   paper \cite{Altenkirch10} presents a calculus with a notion of 
  2154   paper \cite{Altenkirch10} presents a calculus with a notion of 
  2156   $\alpha$-equivalence related to our binding mode \isacommand{bind\_res}.
  2155   $\alpha$-equivalence related to our binding mode \isacommand{bind\_res}.
  2157   This definition is similar to the one by Pottier, except that it
  2156   The corresponding definition is similar to the one by Pottier, except that it
  2158   has a more operational flavour and calculates a partial (renaming) map. 
  2157   has a more operational flavour and calculates a partial (renaming) map. 
  2159   In this way they can handle vacuous binders. However, their notion of
  2158   In this way Altenkirch et al can deal with vacuous binders. However, to our
  2160   equality between terms also includes rules for $\beta$ and to our
  2159   best knowledge, no concrete mathematical result concerning their notion
  2161   knowledge no concrete mathematical result concerning their notion
       
  2162   of equality has been proved.    
  2160   of equality has been proved.    
  2163 *}
  2161 *}
  2164 
  2162 
  2165 section {* Conclusion *}
  2163 section {* Conclusion *}
  2166 
  2164 
  2167 text {*
  2165 text {*
  2168   We have presented an extension of Nominal Isabelle for deriving
  2166   We have presented an extension of Nominal Isabelle for dealing with
  2169   automatically a convenient reasoning infrastructure that can deal with
  2167   general binders, that is term-constructors having multiple bound 
  2170   general binders, that is term-constructors binding multiple variables at
  2168   variables. For this extension we introduced novel definitions of 
  2171   once. This extension has been tried out with the Core-Haskell
  2169   $\alpha$-equivalence and automated all necessary proofs in Isabelle/HOL.
  2172   term-calculus. For such general binders, we can also extend
  2170   We have tried out the extension with terms from Core-Haskell and our code
  2173   earlier work that derives strong induction principles which have the usual
  2171   will become part of the Isabelle distribution.\footnote{For the moment
  2174   variable convention already built in. For the moment we can do so only with manual help,
       
  2175   but future work will automate them completely.  The code underlying the presented
       
  2176   extension will become part of the Isabelle distribution.\footnote{For the moment
       
  2177   it can be downloaded from the Mercurial repository linked at
  2172   it can be downloaded from the Mercurial repository linked at
  2178   \href{http://isabelle.in.tum.de/nominal/download}
  2173   \href{http://isabelle.in.tum.de/nominal/download}
  2179   {http://isabelle.in.tum.de/nominal/download}.}
  2174   {http://isabelle.in.tum.de/nominal/download}.}
  2180 
  2175 
  2181   We have left out a discussion about how functions can be defined over
  2176   We have left out a discussion about how functions can be defined over
  2182   $\alpha$-equated terms that involve general binders. In earlier versions of Nominal
  2177   $\alpha$-equated terms involving general binders. In earlier versions of Nominal
  2183   Isabelle \cite{UrbanBerghofer06} this turned out to be a thorny issue.  We
  2178   Isabelle \cite{UrbanBerghofer06} this turned out to be a thorny issue.  We
  2184   hope to do better this time by using the function package that has recently
  2179   hope to do better this time by using the function package that has recently
  2185   been implemented in Isabelle/HOL and also by restricting function
  2180   been implemented in Isabelle/HOL and also by restricting function
  2186   definitions to equivariant functions (for such functions it is possible to
  2181   definitions to equivariant functions (for such functions it is possible to
  2187   provide more automation).
  2182   provide more automation).
  2188 
  2183 
  2189   There are some restrictions we imposed in this paper, that we would like to lift in
  2184   There are some restrictions we imposed in this paper, that we would like to lift in
  2190   future work. One is the exclusion of nested datatype definitions. Nested
  2185   future work. One is the exclusion of nested datatype definitions. Nested
  2191   datatype definitions allow one to specify, for instance, the function kinds
  2186   datatype definitions allow one to specify, for instance, the function kinds
  2192   in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded
  2187   in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded
  2193   version @{text "TFun string ty_list"} in Figure~\ref{nominalcorehas}. For
  2188   version @{text "TFun string ty_list"} (see Figure~\ref{nominalcorehas}). To
  2194   them we need a more clever implementation than we have at the moment. 
  2189   achieve this, we need a slightly more clever implementation than we have at the moment. 
  2195 
  2190 
  2196   More interesting line of investigation is whether we can go beyond the 
  2191   A more interesting line of investigation is whether we can go beyond the 
  2197   simple-minded form for binding functions that we adopted from Ott. At the moment, binding
  2192   simple-minded form for binding functions that we adopted from Ott. At the moment, binding
  2198   functions can only return the empty set, a singleton atom set or unions
  2193   functions can only return the empty set, a singleton atom set or unions
  2199   of atom sets (similarly for lists). It remains to be seen whether 
  2194   of atom sets (similarly for lists). It remains to be seen whether 
  2200   properties like
  2195   properties like
  2201   %
  2196   %
  2202   \begin{center}
  2197   \begin{center}
  2203   @{text "fa_ty x  =  bn x \<union> fa_bn x"}.
  2198   @{text "fa_ty x  =  bn x \<union> fa_bn x"}.
  2204   \end{center}
  2199   \end{center}
  2205   
  2200   
  2206   \noindent
  2201   \noindent
  2207   provide us with means to support more interesting
  2202   allow us to support more interesting binding functions. 
  2208   binding functions. 
       
  2209 
       
  2210 
  2203 
  2211   We have also not yet played with other binding modes. For example we can
  2204   We have also not yet played with other binding modes. For example we can
  2212   imagine that there is need for a binding mode 
  2205   imagine that there is need for a binding mode 
  2213   where instead of lists, we abstract lists of distinct elements.
  2206   where instead of lists, we abstract lists of distinct elements.
  2214   Once we feel confident about such binding modes, our implementation 
  2207   Once we feel confident about such binding modes, our implementation 
  2215   can be easily extended to accommodate them.
  2208   can be easily extended to accommodate them.
  2216 
  2209 
  2217   %\medskip
  2210   \medskip
  2218   %\noindent
  2211   \noindent
  2219   %{\bf Acknowledgements:} We are very grateful to Andrew Pitts for  
  2212   {\bf Acknowledgements:} We are very grateful to Andrew Pitts for  
  2220   %many discussions about Nominal Isabelle. We also thank Peter Sewell for 
  2213   many discussions about Nominal Isabelle. We also thank Peter Sewell for 
  2221   %making the informal notes \cite{SewellBestiary} available to us and 
  2214   making the informal notes \cite{SewellBestiary} available to us and 
  2222   %also for patiently explaining some of the finer points of the work on the Ott-tool.
  2215   also for patiently explaining some of the finer points of the work on the Ott-tool.
  2223   %Stephanie Weirich suggested to separate the subgrammars
  2216   Stephanie Weirich suggested to separate the subgrammars
  2224   %of kinds and types in our Core-Haskell example.  
  2217   of kinds and types in our Core-Haskell example.  
  2225 
  2218 
  2226 *}
  2219 *}
  2227 
  2220 
  2228 (*<*)
  2221 (*<*)
  2229 end
  2222 end