14 |
14 |
15 section {* Introduction *} |
15 section {* Introduction *} |
16 |
16 |
17 text {* |
17 text {* |
18 So far, Nominal Isabelle provides a mechanism for constructing |
18 So far, Nominal Isabelle provides a mechanism for constructing |
19 automatically alpha-equated terms such as |
19 alpha-equated terms such as |
20 |
20 |
21 \begin{center} |
21 \begin{center} |
22 $t ::= x \mid t\;t \mid \lambda x. t$ |
22 $t ::= x \mid t\;t \mid \lambda x. t$ |
23 \end{center} |
23 \end{center} |
24 |
24 |
25 \noindent |
25 \noindent |
26 where bound variables have a name. |
26 where free and bound variables have names. |
27 For such terms it derives automatically a reasoning |
27 For such terms Nominal Isabelle derives automatically a reasoning |
28 infrastructure, which has been used in formalisations of an equivalence |
28 infrastructure, which has been used in formalisations of an equivalence |
29 checking algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed |
29 checking algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed |
30 Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
30 Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
31 \cite{BengtsonParrow07,BengtsonParow09} and a strong normalisation result |
31 \cite{BengtsonParrow07,BengtsonParow09} and a strong normalisation result |
32 for cut-elimination in classical logic \cite{UrbanZhu08}. It has also been |
32 for cut-elimination in classical logic \cite{UrbanZhu08}. It has also been |
33 used by Pollack for formalisations in the locally-nameless approach to |
33 used by Pollack for formalisations in the locally-nameless approach to |
34 binding \cite{SatoPollack10}. |
34 binding \cite{SatoPollack10}. |
35 |
35 |
36 However, Nominal Isabelle fared less well in a formalisation of |
36 However, Nominal Isabelle has fared less well in a formalisation of |
37 the algorithm W \cite{UrbanNipkow09}, where types and type-schemes |
37 the algorithm W \cite{UrbanNipkow09}, where types and type-schemes |
38 are of the form |
38 are of the form |
39 |
39 |
40 \begin{center} |
40 \begin{center} |
41 \begin{tabular}{l} |
41 \begin{tabular}{l} |
42 $T ::= x \mid T \rightarrow T$ \hspace{5mm} $S ::= \forall \{x_1,\ldots, x_n\}. T$ |
42 $T ::= x \mid T \rightarrow T$ \hspace{5mm} $S ::= \forall \{x_1,\ldots, x_n\}. T$ |
43 \end{tabular} |
43 \end{tabular} |
44 \end{center} |
44 \end{center} |
45 |
45 |
46 \noindent |
46 \noindent |
47 and the quantification abstracts over a finite (possibly empty) set of type variables. |
47 and the quantification binds a finite (possibly empty) set of type-variables. |
48 While it is possible to formalise such abstractions by iterating single bindings, |
48 While it is possible to formalise such abstractions by iterating single bindings, |
49 it leads to a very clumsy formalisation of W. This need of iterating single binders |
49 this leads to a rather clumsy formalisation of W. This need of iterating single binders |
50 for representing multiple binders is also the reason why Nominal Isabelle and other |
50 in order to representing multiple binders is also one reason why Nominal Isabelle and other |
51 theorem provers have not fared extremely well with the more advanced tasks |
51 theorem provers have not fared extremely well with the more advanced tasks |
52 in the POPLmark challenge \cite{challenge05}, because also there one would be able |
52 in the POPLmark challenge \cite{challenge05}, because also there one would like |
53 to aviod clumsy reasoning if there were a mechanisms for abstracting several variables |
53 to bind multiple variables at once. |
54 at once. |
54 |
55 |
55 Binding multiple variables in a single abstraction has interesting properties that are not |
56 To see this, let us point out some interesting properties of binders abstracting multiple |
56 captured by iterating single binders. First, |
57 variables. First, in the case of type-schemes, we do not like to make a distinction |
57 in the case of type-schemes, we do not like to make a distinction |
58 about the order of the bound variables. Therefore we would like to regard the following two |
58 about the order of the bound variables. Therefore we would like to regard the following two |
59 type-schemes as alpha-equivalent |
59 type-schemes as alpha-equivalent |
60 |
60 |
61 \begin{center} |
61 \begin{center} |
62 $\forall \{x, y\}. x \rightarrow y \;\approx_\alpha\; \forall \{y, x\}. y \rightarrow x$ |
62 $\forall \{x, y\}. x \rightarrow y \;\approx_\alpha\; \forall \{y, x\}. y \rightarrow x$ |
87 |
88 |
88 |
89 |
89 However, the notion of alpha-equivalence that is preserved by vacuous binders is not |
90 However, the notion of alpha-equivalence that is preserved by vacuous binders is not |
90 alway wanted. For example in terms like |
91 alway wanted. For example in terms like |
91 |
92 |
92 \begin{center} |
93 \begin{equation}\label{one} |
93 $\LET x = 3 \AND y = 2 \IN x\,\backslash\,y \END$ |
94 \LET x = 3 \AND y = 2 \IN x\,\backslash\,y \END |
94 \end{center} |
95 \end{equation} |
95 |
96 |
96 \noindent |
97 \noindent |
97 we might not care in which order the assignments $x = 3$ and $y = 2$ are |
98 we might not care in which order the assignments $x = 3$ and $y = 2$ are |
98 given, but it would be unusual to regard the above term as alpha-equivalent |
99 given, but it would be unusual to regard \eqref{one} as alpha-equivalent |
99 with |
100 with |
100 |
101 |
101 \begin{center} |
102 \begin{center} |
102 $\LET x = 3 \AND y = 2 \AND z = loop \IN x\,\backslash\,y \END$ |
103 $\LET x = 3 \AND y = 2 \AND z = loop \IN x\,\backslash\,y \END$ |
103 \end{center} |
104 \end{center} |
104 |
105 |
105 \noindent |
106 \noindent |
106 Therefore we will also provide a separate abstraction mechanism for cases |
107 Therefore we will also provide a separate abstraction mechanism for cases |
107 in which the order of binders does not matter, but the ``cardinality'' of the |
108 in which the order of binders does not matter, but the ``cardinality'' of the |
108 binders has to be the same. |
109 binders has to agree. |
109 |
110 |
110 However, we found that this is still not sufficient for covering language |
111 However, we found that this is still not sufficient for covering language |
111 constructs frequently occuring in programming language research. For example |
112 constructs frequently occuring in programming language research. For example |
112 in $\mathtt{let}$s involving patterns |
113 in $\mathtt{let}$s involving patterns |
113 |
114 |
114 \begin{center} |
115 \begin{equation}\label{two} |
115 $\LET (x, y) = (3, 2) \IN x\,\backslash\,y \END$ |
116 \LET (x, y) = (3, 2) \IN x\,\backslash\,y \END |
116 \end{center} |
117 \end{equation} |
117 |
118 |
118 \noindent |
119 \noindent |
119 we want to bind all variables from the pattern (there might be an arbitrary |
120 we want to bind all variables from the pattern inside the body of the |
120 number of them) inside the body of the $\mathtt{let}$, but we also care about |
121 $\mathtt{let}$, but we also care about the order of these variables, since |
121 the order of these variables, since we do not want to identify the above term |
122 we do not want to identify \eqref{two} with |
122 with |
|
123 |
123 |
124 \begin{center} |
124 \begin{center} |
125 $\LET (y, x) = (3, 2) \IN x\,\backslash y\,\END$ |
125 $\LET (y, x) = (3, 2) \IN x\,\backslash y\,\END$ |
126 \end{center} |
126 \end{center} |
127 |
127 |
128 \noindent |
128 \noindent |
129 As a result, we provide three general abstraction mechanisms for multiple binders |
129 As a result, we provide three general abstraction mechanisms for binding multiple |
130 and allow the user to chose which one is intended when formalising a |
130 variables and allow the user to chose which one is intended when formalising a |
131 programming language calculus. |
131 programming language calculus. |
132 |
132 |
133 By providing these general abstraction mechanisms, however, we have to work around |
133 By providing these general abstraction mechanisms, however, we have to work around |
134 a problem that has been pointed out by Pottier in \cite{Pottier06}: in |
134 a problem that has been pointed out by Pottier in \cite{Pottier06}: in |
135 $\mathtt{let}$-constructs of the form |
135 $\mathtt{let}$-constructs of the form |
147 \begin{center} |
147 \begin{center} |
148 $\LET [x_1,\ldots,x_n].s\;\; [t_1,\ldots,t_n]$ |
148 $\LET [x_1,\ldots,x_n].s\;\; [t_1,\ldots,t_n]$ |
149 \end{center} |
149 \end{center} |
150 |
150 |
151 \noindent |
151 \noindent |
152 where the $[\_\!\_].\_\!\_$ indicates that a list of variables becomes |
152 where the notation $[\_\!\_].\_\!\_$ indicates that a set of variables becomes |
153 bound in $s$. In this representation we need additional predicates to ensure |
153 bound in $s$. In this representation we need additional predicates about terms |
154 that the two lists are of equal length. This can result into very |
154 to ensure that the two lists are of equal length. This can result into very |
155 unintelligible reasoning (see for example~\cite{BengtsonParow09}). |
155 unintelligible reasoning (see for example~\cite{BengtsonParow09}). |
156 To avoid this, we will allow for example specifications of $\mathtt{let}$s |
156 To avoid this, we will allow for example specifications of $\mathtt{let}$s |
157 as follows |
157 as follows |
158 |
158 |
159 \begin{center} |
159 \begin{center} |
166 \end{center} |
166 \end{center} |
167 |
167 |
168 \noindent |
168 \noindent |
169 where $assn$ is an auxiliary type representing a list of assignments |
169 where $assn$ is an auxiliary type representing a list of assignments |
170 and $bn$ an auxilary function identifying the variables to be bound by |
170 and $bn$ an auxilary function identifying the variables to be bound by |
171 the $\mathtt{let}$, given by |
171 the $\mathtt{let}$. This function can be defined as |
172 |
172 |
173 \begin{center} |
173 \begin{center} |
174 $bn\,(\mathtt{anil}) = \varnothing \qquad bn\,(\mathtt{acons}\;x\;t\;as) = \{x\} \cup bn\,(as)$ |
174 $bn\,(\mathtt{anil}) = \varnothing \qquad bn\,(\mathtt{acons}\;x\;t\;as) = \{x\} \cup bn\,(as)$ |
175 \end{center} |
175 \end{center} |
176 |
176 |
177 \noindent |
177 \noindent |
178 This style of specifications for term-calculi with multiple binders is heavily |
178 This style of specifying terms and bindings is heavily |
179 inspired by the Ott-tool \cite{ott-jfp}. |
179 inspired by the syntax of the Ott-tool \cite{ott-jfp}. |
180 |
180 |
181 We will not be able to deal with all specifications that are allowed by |
181 However, we will not be able to deal with all specifications that are allowed by |
182 Ott. One reason is that we establish the reasoning infrastructure for |
182 Ott. One reason is that we establish the reasoning infrastructure for |
183 alpha-\emph{equated} terms. In contrast, Ott produces for a subset of its |
183 alpha-\emph{equated} terms. In contrast, Ott produces for a subset of its |
184 specifiactions a reasoning infrastructure involving concrete, |
184 specifiactions a reasoning infrastructure for terms that have names for |
185 \emph{non}-alpha-equated terms. To see the difference, note that working |
185 bound variables, but these terms are concrete, \emph{non}-alpha-equated terms. To see |
|
186 the difference, note that working |
186 with alpha-equated terms means that the two type-schemes with $x$, $y$ and |
187 with alpha-equated terms means that the two type-schemes with $x$, $y$ and |
187 $z$ being distinct |
188 $z$ being distinct |
188 |
189 |
189 \begin{center} |
190 \begin{center} |
190 $\forall \{x\}. x \rightarrow y \;=\; \forall \{x, z\}. x \rightarrow y$ |
191 $\forall \{x\}. x \rightarrow y \;=\; \forall \{x, z\}. x \rightarrow y$ |
191 \end{center} |
192 \end{center} |
192 |
193 |
193 \noindent |
194 \noindent |
194 are not just alpha-equal, but actually equal---we are working with |
195 are not just alpha-equal, but actually equal. Our insistence on reasoning |
195 alpha-equivalence classes, but still have that bound variables |
196 with alpha-equated terms comes from the wealth of experience we gained with |
196 carry a name. |
197 the older version of Nominal Isabelle: for non-trivial properties, reasoning |
197 Our insistence on reasoning with alpha-equated terms comes from the |
198 about alpha-equated terms is much easier than reasoning with concrete |
198 wealth of experience we gained with the older version of Nominal |
199 terms. The fundamental reason for this is that the HOL-logic underlying |
199 Isabelle: for non-trivial properties, |
200 Nominal Isabelle allows us to replace ``equals-by-equals''. In contrast, |
200 reasoning about alpha-equated terms is much easier than reasoning |
201 replacing ``alpha-equals-by-alpha-equals'' requires a lot of extra work. |
201 with concrete terms. The fundamental reason is that the HOL-logic |
202 |
202 underlying Nominal Isabelle allows us to replace ``equals-by-equals''. |
203 |
203 Replacing ``alpha-equals-by-alpha-equals'' requires a lot of work. |
204 Although in informal settings a reasoning infrastructure for alpha-equated |
204 |
205 terms that have names is nearly always taken for granted, establishing |
205 Although a reasoning infrastructure for alpha-equated terms with names |
|
206 is in informal reasoning nearly always taken for granted, establishing |
|
207 it automatically in a theorem prover is a rather non-trivial task. |
206 it automatically in a theorem prover is a rather non-trivial task. |
208 For every specification we will construct a type that contains |
207 For every specification we will need to construct a type containing as |
209 exactly the corresponding alpha-equated terms. For this we use the |
208 elements exactly those sets containing alpha-equal terms. To do so we use |
210 standard HOL-technique of defining a new type that has been |
209 the standard HOL-technique of defining a new type by |
211 identified as a non-empty subset of an existing type. In our |
210 identifying a non-empty subset of an existing type. In our |
212 context we take as the starting point the type of sets of concrete |
211 we take as the starting point the type of sets of concrete |
213 terms (the latter being defined as datatypes). Then quotient these |
212 terms (the latter being defined as datatypes). Then quotient these |
214 sets according to our alpha-equivalence relation and then identifying |
213 sets according to our alpha-equivalence relation and then identifying |
215 the new type as these alpha-equivalence classes. The construction we |
214 the new type as these alpha-equivalence classes. The construction we |
216 can perform in HOL is illustrated by the following picture: |
215 can perform in HOL is illustrated by the following picture: |
217 |
216 |
269 \cite{HuffmanUrban10}, which we review here briefly to aid the description |
268 \cite{HuffmanUrban10}, which we review here briefly to aid the description |
270 of what follows in the next sections. Two central notions in the nominal |
269 of what follows in the next sections. Two central notions in the nominal |
271 logic work are sorted atoms and permutations of atoms. The sorted atoms |
270 logic work are sorted atoms and permutations of atoms. The sorted atoms |
272 represent different kinds of variables, such as term- and type-variables in |
271 represent different kinds of variables, such as term- and type-variables in |
273 Core-Haskell, and it is assumed that there is an infinite supply of atoms |
272 Core-Haskell, and it is assumed that there is an infinite supply of atoms |
274 for each sort. However, in order to simplify the description of our work, we |
273 for each sort. However, in order to simplify the description, we |
275 shall assume in this paper that there is only a single sort of atoms. |
274 shall assume in what follows that there is only a single sort of atoms. |
276 |
275 |
277 Permutations are bijective functions from atoms to atoms that are |
276 Permutations are bijective functions from atoms to atoms that are |
278 the identity everywhere except on a finite number of atoms. There is a |
277 the identity everywhere except on a finite number of atoms. There is a |
279 two-place permutation operation written |
278 two-place permutation operation written |
280 |
279 |