50 \begin{center} |
51 \begin{center} |
51 @{text "t ::= x | t t | \<lambda>x. t"} |
52 @{text "t ::= x | t t | \<lambda>x. t"} |
52 \end{center} |
53 \end{center} |
53 |
54 |
54 \noindent |
55 \noindent |
55 where free and bound variables have names. For such alpha-equated terms, Nominal Isabelle |
56 where free and bound variables have names. For such alpha-equated terms, |
56 derives automatically a reasoning infrastructure that has been used |
57 Nominal Isabelle derives automatically a reasoning infrastructure that has |
57 successfully in formalisations of an equivalence checking algorithm for LF |
58 been used successfully in formalisations of an equivalence checking |
58 \cite{UrbanCheneyBerghofer08}, Typed |
59 algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed |
59 Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
60 Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
60 \cite{BengtsonParow09} and a strong normalisation result |
61 \cite{BengtsonParow09} and a strong normalisation result for cut-elimination |
61 for cut-elimination in classical logic \cite{UrbanZhu08}. It has also been |
62 in classical logic \cite{UrbanZhu08}. It has also been used by Pollack for |
62 used by Pollack for formalisations in the locally-nameless approach to |
63 formalisations in the locally-nameless approach to binding |
63 binding \cite{SatoPollack10}. |
64 \cite{SatoPollack10}. |
64 |
65 |
65 However, Nominal Isabelle has fared less well in a formalisation of |
66 However, Nominal Isabelle has fared less well in a formalisation of |
66 the algorithm W \cite{UrbanNipkow09}, where types and type-schemes are, |
67 the algorithm W \cite{UrbanNipkow09}, where types and type-schemes are, |
67 respectively, of the form |
68 respectively, of the form |
68 % |
69 % |
1088 later on. |
1089 later on. |
1089 |
1090 |
1090 In order to simplify our definitions, we shall assume specifications |
1091 In order to simplify our definitions, we shall assume specifications |
1091 of term-calculi are \emph{completed}. By this we mean that |
1092 of term-calculi are \emph{completed}. By this we mean that |
1092 for every argument of a term-constructor that is \emph{not} |
1093 for every argument of a term-constructor that is \emph{not} |
1093 already part of a binding clause, we add implicitly a special \emph{empty} binding |
1094 already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding |
1094 clause, written \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "label"}. In case |
1095 clause, written \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case |
1095 of the lambda-calculus, the completion produces |
1096 of the lambda-calculus, the completion produces |
1096 |
1097 |
1097 \begin{center} |
1098 \begin{center} |
1098 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
1099 \begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
1099 \isacommand{nominal\_datatype} @{text lam} =\\ |
1100 \isacommand{nominal\_datatype} @{text lam} =\\ |
1100 \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"} |
1101 \hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"} |
1101 \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "x"}\\ |
1102 \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "x"}\\ |
1102 \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"} |
1103 \hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"} |
1103 \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1"}, |
1104 \;\;\isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\ |
1104 \isacommand{bind}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>2"}\\ |
|
1105 \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"} |
1105 \hspace{5mm}$\mid$~@{text "Lam x::name t::lam"} |
1106 \;\;\isacommand{bind}~@{text x} \isacommand{in} @{text t}\\ |
1106 \;\;\isacommand{bind}~@{text x} \isacommand{in} @{text t}\\ |
1107 \end{tabular} |
1107 \end{tabular} |
1108 \end{center} |
1108 \end{center} |
1109 |
1109 |
1911 de-Bruijn representation), but to different bound variables. A similar idea |
1911 de-Bruijn representation), but to different bound variables. A similar idea |
1912 has been recently explored for general binders in the locally nameless |
1912 has been recently explored for general binders in the locally nameless |
1913 approach to binding \cite{chargueraud09}. There, de-Bruijn indices consist |
1913 approach to binding \cite{chargueraud09}. There, de-Bruijn indices consist |
1914 of two numbers, one referring to the place where a variable is bound and the |
1914 of two numbers, one referring to the place where a variable is bound and the |
1915 other to which variable is bound. The reasoning infrastructure for both |
1915 other to which variable is bound. The reasoning infrastructure for both |
1916 representations of bindings comes for free in the theorem provers, like Isabelle/HOL or |
1916 representations of bindings comes for free in theorem provers like Isabelle/HOL or |
1917 Coq, as the corresponding term-calculi can be implemented as ``normal'' |
1917 Coq, as the corresponding term-calculi can be implemented as ``normal'' |
1918 datatypes. However, in both approaches it seems difficult to achieve our |
1918 datatypes. However, in both approaches it seems difficult to achieve our |
1919 fine-grained control over the ``semantics'' of bindings (i.e.~whether the |
1919 fine-grained control over the ``semantics'' of bindings (i.e.~whether the |
1920 order of binders should matter, or vacuous binders should be taken into |
1920 order of binders should matter, or vacuous binders should be taken into |
1921 account). To do so, one would require additional predicates that filter out |
1921 account). To do so, one would require additional predicates that filter out |
1922 unwanted terms. Our guess is that such predicates results in rather |
1922 unwanted terms. Our guess is that such predicates result in rather |
1923 intricate formal reasoning. |
1923 intricate formal reasoning. |
1924 |
1924 |
1925 Another representation technique for binding is higher-order abstract syntax |
1925 Another representation technique for binding is higher-order abstract syntax |
1926 (HOAS), which for example is implemented in the Twelf system. This representation |
1926 (HOAS), which for example is implemented in the Twelf system. This representation |
1927 technique supports very elegantly many aspects of \emph{single} binding, and |
1927 technique supports very elegantly many aspects of \emph{single} binding, and |
1934 patterns that bind multiple variables at once. In such situations, HOAS |
1934 patterns that bind multiple variables at once. In such situations, HOAS |
1935 representations have to resort to the iterated-single-binders-approach with |
1935 representations have to resort to the iterated-single-binders-approach with |
1936 all the unwanted consequences when reasoning about the resulting terms. |
1936 all the unwanted consequences when reasoning about the resulting terms. |
1937 |
1937 |
1938 Two formalisations involving general binders have also been performed in older |
1938 Two formalisations involving general binders have also been performed in older |
1939 versions of Nominal Isabelle \cite{BengtsonParow09, UrbanNipkow09}. Both |
1939 versions of Nominal Isabelle (one about Psi-calculi and one about alpgorithm W |
|
1940 \cite{BengtsonParow09, UrbanNipkow09}). Both |
1940 use the approach based on iterated single binders. Our experience with |
1941 use the approach based on iterated single binders. Our experience with |
1941 the latter formalisation has been disappointing. The major pain arose from |
1942 the latter formalisation has been disappointing. The major pain arose from |
1942 the need to ``unbind'' variables. This can be done in one step with our |
1943 the need to ``unbind'' variables. This can be done in one step with our |
1943 general binders, for example @{term "Abs as x"}, but needs a cumbersome |
1944 general binders, but needs a cumbersome |
1944 iteration with single binders. The resulting formal reasoning turned out to |
1945 iteration with single binders. The resulting formal reasoning turned out to |
1945 be rather unpleasant. The hope is that the extension presented in this paper |
1946 be rather unpleasant. The hope is that the extension presented in this paper |
1946 is a substantial improvement. |
1947 is a substantial improvement. |
1947 |
1948 |
1948 The most closely related work to the one presented here is the Ott-tool \cite{ott-jfp}. This tool is a |
1949 The most closely related work to the one presented here is the Ott-tool |
1949 nifty front-end for creating \LaTeX{} documents from specifications of |
1950 \cite{ott-jfp} and the C$\alpha$ml language \cite{Pottier06}. Ott is a nifty |
1950 term-calculi involving general binders. For a subset of the specifications, Ott can also generate |
1951 front-end for creating \LaTeX{} documents from specifications of |
1951 theorem prover code using a raw representation of terms, and in Coq also a |
1952 term-calculi involving general binders. For a subset of the specifications, |
1952 locally nameless representation. The developers of this tool have also put |
1953 Ott can also generate theorem prover code using a raw representation of |
1953 forward (on paper) a definition for alpha-equivalence of terms that can be |
1954 terms, and in Coq also a locally nameless representation. The developers of |
1954 specified in Ott. This definition is rather different from ours, not using |
1955 this tool have also put forward (on paper) a definition for |
1955 any nominal techniques. Although we were heavily inspired by their syntax, |
1956 alpha-equivalence of terms that can be specified in Ott. This definition is |
|
1957 rather different from ours, not using any nominal techniques. To our |
|
1958 knowledge there is also no concrete mathematical result concerning this |
|
1959 notion of alpha-equivalence. A definition for the notion of free variables |
|
1960 in a term are work in progress in Ott. |
|
1961 |
|
1962 Although we were heavily inspired by their syntax, |
1956 their definition of alpha-equivalence is unsuitable for our extension of |
1963 their definition of alpha-equivalence is unsuitable for our extension of |
1957 Nominal Isabelle. First, it is far too complicated to be a basis for |
1964 Nominal Isabelle. First, it is far too complicated to be a basis for |
1958 automated proofs implemented on the ML-level of Isabelle/HOL. Second, it |
1965 automated proofs implemented on the ML-level of Isabelle/HOL. Second, it |
1959 covers cases of binders depending on other binders, which just do not make |
1966 covers cases of binders depending on other binders, which just do not make |
1960 sense for our alpha-equated terms. Third, it allows empty types that have no |
1967 sense for our alpha-equated terms. Third, it allows empty types that have no |
1961 meaning in a HOL-based theorem prover. |
1968 meaning in a HOL-based theorem prover. We also had to generalise slightly their |
|
1969 binding clauses. In Ott you specify binding clauses with a single body; we |
|
1970 allow more than one. We have to do this, because this makes a difference |
|
1971 for our notion of alpha-equivalence in case of \isacommand{bind\_set} and |
|
1972 \isacommand{bind\_res}. This makes |
|
1973 |
|
1974 \begin{center} |
|
1975 \begin{tabular}{@ {}ll@ {}} |
|
1976 @{text "Foo\<^isub>1 xs::name fset x::name y::name"} & |
|
1977 \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "x y"}\\ |
|
1978 @{text "Foo\<^isub>2 xs::name fset x::name y::name"} & |
|
1979 \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "x"}, |
|
1980 \isacommand{bind\_set} @{text "xs"} \isacommand{in} @{text "y"}\\ |
|
1981 \end{tabular} |
|
1982 \end{center} |
|
1983 |
|
1984 \noindent |
|
1985 behave differently. To see this, consider the following equations |
|
1986 |
|
1987 \begin{center} |
|
1988 \begin{tabular}{c} |
|
1989 @{term "Abs_print [a,b] (a, b) = Abs_print [a,b] (b, a)"}\\ |
|
1990 @{term "Abs_print [a,b] (a, b) = Abs_print [a,b] (a, b)"}\\ |
|
1991 \end{tabular} |
|
1992 \end{center} |
|
1993 |
|
1994 \noindent |
|
1995 The interesting point is that they do not imply |
|
1996 |
|
1997 \begin{center} |
|
1998 \begin{tabular}{c} |
|
1999 @{term "Abs_print [a,b] ((a, b), (a, b)) = Abs_print [a,b] ((a, b), (b, a))"}\\ |
|
2000 \end{tabular} |
|
2001 \end{center} |
1962 |
2002 |
1963 Because of how we set up our definitions, we had to impose restrictions, |
2003 Because of how we set up our definitions, we had to impose restrictions, |
1964 like excluding overlapping deep binders, that are not present in Ott. Our |
2004 like a single binding function for a deep binder, that are not present in Ott. Our |
1965 expectation is that we can still cover many interesting term-calculi from |
2005 expectation is that we can still cover many interesting term-calculi from |
1966 programming language research, for example Core-Haskell. For providing support |
2006 programming language research, for example Core-Haskell. For providing support |
1967 of neat features in Ott, such as subgrammars, the existing datatype |
2007 of neat features in Ott, such as subgrammars, the existing datatype |
1968 infrastructure in Isabelle/HOL is unfortunately not powerful enough. On the |
2008 infrastructure in Isabelle/HOL is unfortunately not powerful enough. On the |
1969 other hand, we are not aware that Ott can make the distinction between our |
2009 other hand, we are not aware that Ott can make the distinction between our |
1970 three different binding modes. Also, definitions for notions like the free |
2010 three different binding modes. |
1971 variables of a term are work in progress in Ott. |
2011 |
|
2012 Pottier presents in \cite{Pottier06} a language, called C$\alpha$ml, for |
|
2013 representing terms with general binders inside OCaml. This language is |
|
2014 implemented as a front-end that can be translated to OCaml with a help of |
|
2015 a library. He presents a type-system in which the scope of general binders |
|
2016 can be indicated with some special constructs, written @{text "inner"} and |
|
2017 @{text "outer"}. With this, it seems, our and his specifications can be |
|
2018 inter-translated, but we have not proved this. However, we believe the |
|
2019 binding specifications in the style of Ott are a more natural way for |
|
2020 representing terms involving bindings. Pottier gives a definition for |
|
2021 alpha-equivalence, which is similar to our binding mod \isacommand{bind}. |
|
2022 Although he uses also a permutation in case of abstractions, his |
|
2023 definition is rather different from ours. He proves that his notion |
|
2024 of alpha-equivalence is indeed a equivalence relation, but a complete |
|
2025 reasoning infrastructure is well beyond the purposes of his language. |
1972 *} |
2026 *} |
1973 |
2027 |
1974 section {* Conclusion *} |
2028 section {* Conclusion *} |
1975 |
2029 |
1976 text {* |
2030 text {* |
2000 datatype definitions allow one to specify, for instance, the function kinds |
2054 datatype definitions allow one to specify, for instance, the function kinds |
2001 in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded |
2055 in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded |
2002 version @{text "TFun string ty_list"} in Figure~\ref{nominalcorehas}. For |
2056 version @{text "TFun string ty_list"} in Figure~\ref{nominalcorehas}. For |
2003 them we need a more clever implementation than we have at the moment. |
2057 them we need a more clever implementation than we have at the moment. |
2004 |
2058 |
2005 More |
2059 More interesting line of investigation is whether we can go beyond the |
2006 interesting is lifting our restriction about overlapping deep binders. Given |
|
2007 our current setup, we cannot deal with specifications such as |
|
2008 |
|
2009 |
|
2010 \begin{center} |
|
2011 \begin{tabular}{ll} |
|
2012 @{text "Foo r::pat s::pat t::trm"} & |
|
2013 \isacommand{bind} @{text "bn(r)"} \isacommand{in} @{text t},\; |
|
2014 \isacommand{bind} @{text "bn(s)"} \isacommand{in} @{text t} |
|
2015 \end{tabular} |
|
2016 \end{center} |
|
2017 |
|
2018 \noindent |
|
2019 where the deep binders @{text "bn(r)"} and @{text "bn(s)"} overlap. |
|
2020 The difficulty is that we would need to implement such overlapping bindings |
|
2021 with alpha-equivalences like |
|
2022 |
|
2023 \begin{center} |
|
2024 @{term "\<exists>p q. abs_set2 (bn r\<^isub>1, t\<^isub>1) p (bn r\<^isub>2, t\<^isub>2) \<and> abs_set2 (bn s\<^isub>1, t\<^isub>1) q (bn s\<^isub>2, t\<^isub>2)"} |
|
2025 \end{center} |
|
2026 |
|
2027 \noindent |
|
2028 or |
|
2029 |
|
2030 \begin{center} |
|
2031 @{term "\<exists>p q. abs_set2 (bn r\<^isub>1 \<union> bn s\<^isub>1, t\<^isub>1) (p + q) (bn r\<^isub>2 \<union> bn s\<^isub>2, t\<^isub>2)"} |
|
2032 \end{center} |
|
2033 |
|
2034 \noindent |
|
2035 Both versions require two permutations (for each binding). But unfortunately the |
|
2036 first version cannot work since it leaves some atoms unbound that should be |
|
2037 bound by the respective other binder. This problem is avoided in the second |
|
2038 version, but at the expense that the two permutations can interfere with each |
|
2039 other. We have not yet been able to find a way to avoid such interferences. |
|
2040 On the other hand, such bindings can be made sense of informally \cite{SewellBestiary}. |
|
2041 This suggest there should be an approriate notion of alpha-equivalence. |
|
2042 |
|
2043 Another interesting line of investigation is whether we can go beyond the |
|
2044 simple-minded form for binding functions that we adopted from Ott. At the moment, binding |
2060 simple-minded form for binding functions that we adopted from Ott. At the moment, binding |
2045 functions can only return the empty set, a singleton atom set or unions |
2061 functions can only return the empty set, a singleton atom set or unions |
2046 of atom sets (similarly for lists). It remains to be seen whether |
2062 of atom sets (similarly for lists). It remains to be seen whether |
2047 properties like \eqref{bnprop} provide us with means to support more interesting |
2063 properties like \eqref{bnprop} provide us with means to support more interesting |
2048 binding functions. |
2064 binding functions. |