author | Christian Urban <urbanc@in.tum.de> |
Wed, 24 Mar 2010 19:50:42 +0100 | |
changeset 1636 | d5b223b9c2bb |
parent 1629 | a0ca7d9f6781 |
child 1637 | a5501c9fad9b |
permissions | -rw-r--r-- |
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(*<*) |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
theory Paper |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
3 |
imports "../Nominal/Test" "LaTeXsugar" |
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
begin |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
5 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
6 |
notation (latex output) |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
7 |
swap ("'(_ _')" [1000, 1000] 1000) and |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
8 |
fresh ("_ # _" [51, 51] 50) and |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
9 |
fresh_star ("_ #* _" [51, 51] 50) and |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
10 |
supp ("supp _" [78] 73) and |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
11 |
uminus ("-_" [78] 73) and |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
12 |
If ("if _ then _ else _" 10) |
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
(*>*) |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
section {* Introduction *} |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
|
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
text {* |
1524 | 18 |
So far, Nominal Isabelle provides a mechanism for constructing |
1607 | 19 |
alpha-equated terms, for example |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
20 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
21 |
\begin{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
22 |
$t ::= x \mid t\;t \mid \lambda x. t$ |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
23 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
24 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
25 |
\noindent |
1550 | 26 |
where free and bound variables have names. For such terms Nominal Isabelle |
1607 | 27 |
derives automatically a reasoning infrastructure that has been used |
1550 | 28 |
successfully in formalisations of an equivalence checking algorithm for LF |
29 |
\cite{UrbanCheneyBerghofer08}, Typed |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
30 |
Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
31 |
\cite{BengtsonParrow07,BengtsonParow09} and a strong normalisation result |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
32 |
for cut-elimination in classical logic \cite{UrbanZhu08}. It has also been |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
33 |
used by Pollack for formalisations in the locally-nameless approach to |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
34 |
binding \cite{SatoPollack10}. |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
35 |
|
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
36 |
However, Nominal Isabelle has fared less well in a formalisation of |
1524 | 37 |
the algorithm W \cite{UrbanNipkow09}, where types and type-schemes |
38 |
are of the form |
|
1570 | 39 |
% |
40 |
\begin{equation}\label{tysch} |
|
41 |
\begin{array}{l} |
|
42 |
T ::= x \mid T \rightarrow T \hspace{5mm} S ::= \forall \{x_1,\ldots, x_n\}. T |
|
43 |
\end{array} |
|
44 |
\end{equation} |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
45 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
46 |
\noindent |
1566 | 47 |
and the quantification $\forall$ binds a finite (possibly empty) set of |
1550 | 48 |
type-variables. While it is possible to implement this kind of more general |
49 |
binders by iterating single binders, this leads to a rather clumsy |
|
50 |
formalisation of W. The need of iterating single binders is also one reason |
|
51 |
why Nominal Isabelle and similar theorem provers that only provide |
|
52 |
mechanisms for binding single variables have not fared extremely well with the |
|
53 |
more advanced tasks in the POPLmark challenge \cite{challenge05}, because |
|
54 |
also there one would like to bind multiple variables at once. |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
55 |
|
1577 | 56 |
Binding multiple variables has interesting properties that cannot be captured |
1587 | 57 |
easily by iterating single binders. For example in case of type-schemes we do not |
58 |
want to make a distinction about the order of the bound variables. Therefore |
|
1550 | 59 |
we would like to regard the following two type-schemes as alpha-equivalent |
1572 | 60 |
% |
61 |
\begin{equation}\label{ex1} |
|
62 |
\forall \{x, y\}. x \rightarrow y \;\approx_\alpha\; \forall \{y, x\}. y \rightarrow x |
|
63 |
\end{equation} |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
64 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
65 |
\noindent |
1587 | 66 |
but assuming that $x$, $y$ and $z$ are distinct variables, |
67 |
the following two should \emph{not} be alpha-equivalent |
|
1572 | 68 |
% |
69 |
\begin{equation}\label{ex2} |
|
70 |
\forall \{x, y\}. x \rightarrow y \;\not\approx_\alpha\; \forall \{z\}. z \rightarrow z |
|
71 |
\end{equation} |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
72 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
73 |
\noindent |
1587 | 74 |
Moreover, we like to regard type-schemes as |
1524 | 75 |
alpha-equivalent, if they differ only on \emph{vacuous} binders, such as |
1572 | 76 |
% |
77 |
\begin{equation}\label{ex3} |
|
78 |
\forall \{x\}. x \rightarrow y \;\approx_\alpha\; \forall \{x, z\}. x \rightarrow y |
|
79 |
\end{equation} |
|
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
80 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
81 |
\noindent |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
82 |
where $z$ does not occur freely in the type. |
1545 | 83 |
In this paper we will give a general binding mechanism and associated |
1524 | 84 |
notion of alpha-equivalence that can be used to faithfully represent |
1545 | 85 |
this kind of binding in Nominal Isabelle. The difficulty of finding the right notion |
1607 | 86 |
for alpha-equivalence can be appreciated in this case by considering that the |
1524 | 87 |
definition given by Leroy in \cite{Leroy92} is incorrect (it omits a side-condition). |
88 |
||
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
89 |
However, the notion of alpha-equivalence that is preserved by vacuous binders is not |
1566 | 90 |
always wanted. For example in terms like |
1587 | 91 |
% |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
92 |
\begin{equation}\label{one} |
1550 | 93 |
\LET x = 3 \AND y = 2 \IN x\,-\,y \END |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
94 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
95 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
96 |
\noindent |
1524 | 97 |
we might not care in which order the assignments $x = 3$ and $y = 2$ are |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
98 |
given, but it would be unusual to regard \eqref{one} as alpha-equivalent |
1524 | 99 |
with |
1587 | 100 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
101 |
\begin{center} |
1550 | 102 |
$\LET x = 3 \AND y = 2 \AND z = loop \IN x\,-\,y \END$ |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
103 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
104 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
105 |
\noindent |
1550 | 106 |
Therefore we will also provide a separate binding mechanism for cases in |
107 |
which the order of binders does not matter, but the ``cardinality'' of the |
|
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
108 |
binders has to agree. |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
109 |
|
1550 | 110 |
However, we found that this is still not sufficient for dealing with |
111 |
language constructs frequently occurring in programming language |
|
112 |
research. For example in $\mathtt{let}$s containing patterns |
|
1587 | 113 |
% |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
114 |
\begin{equation}\label{two} |
1550 | 115 |
\LET (x, y) = (3, 2) \IN x\,-\,y \END |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
116 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
117 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
118 |
\noindent |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
119 |
we want to bind all variables from the pattern inside the body of the |
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
120 |
$\mathtt{let}$, but we also care about the order of these variables, since |
1566 | 121 |
we do not want to regard \eqref{two} as alpha-equivalent with |
1587 | 122 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
123 |
\begin{center} |
1550 | 124 |
$\LET (y, x) = (3, 2) \IN x\,- y\,\END$ |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
125 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
126 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
127 |
\noindent |
1545 | 128 |
As a result, we provide three general binding mechanisms each of which binds multiple |
1566 | 129 |
variables at once, and let the user chose which one is intended when formalising a |
1524 | 130 |
programming language calculus. |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
131 |
|
1545 | 132 |
By providing these general binding mechanisms, however, we have to work around |
1636 | 133 |
a problem that has been pointed out by Pottier \cite{Pottier06} and Cheney |
134 |
\cite{Cheney05}: in $\mathtt{let}$-constructs of the form |
|
1587 | 135 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
136 |
\begin{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
137 |
$\LET x_1 = t_1 \AND \ldots \AND x_n = t_n \IN s \END$ |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
138 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
139 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
140 |
\noindent |
1524 | 141 |
which bind all the $x_i$ in $s$, we might not care about the order in |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
142 |
which the $x_i = t_i$ are given, but we do care about the information that there are |
1524 | 143 |
as many $x_i$ as there are $t_i$. We lose this information if we represent the |
1550 | 144 |
$\mathtt{let}$-constructor by something like |
1587 | 145 |
% |
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
146 |
\begin{center} |
1524 | 147 |
$\LET [x_1,\ldots,x_n].s\;\; [t_1,\ldots,t_n]$ |
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
148 |
\end{center} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
149 |
|
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
150 |
\noindent |
1566 | 151 |
where the notation $[\_\!\_].\_\!\_$ indicates that the $x_i$ become bound |
152 |
in $s$. In this representation the term \mbox{$\LET [x].s\;\;[t_1,t_2]$} |
|
1628 | 153 |
would be a perfectly legal instance. To exclude such terms, additional |
154 |
predicates about well-formed terms are needed in order to ensure that the two |
|
1566 | 155 |
lists are of equal length. This can result into very messy reasoning (see |
1577 | 156 |
for example~\cite{BengtsonParow09}). To avoid this, we will allow type specifications |
1566 | 157 |
for $\mathtt{let}$s as follows |
1587 | 158 |
% |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
159 |
\begin{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
160 |
\begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}l} |
1570 | 161 |
$trm$ & $::=$ & \ldots\\ |
1545 | 162 |
& $\mid$ & $\mathtt{let}\;a\!::\!assn\;\;s\!::\!trm\quad\mathtt{bind}\;bn\,(a) \IN s$\\[1mm] |
1570 | 163 |
$assn$ & $::=$ & $\mathtt{anil}$\\ |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
164 |
& $\mid$ & $\mathtt{acons}\;\;name\;\;trm\;\;assn$ |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
165 |
\end{tabular} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
166 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
167 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
168 |
\noindent |
1577 | 169 |
where $assn$ is an auxiliary type representing a list of assignments |
1545 | 170 |
and $bn$ an auxiliary function identifying the variables to be bound by |
1566 | 171 |
the $\mathtt{let}$. This function is defined by recursion over $assn$ as follows |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
172 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
173 |
\begin{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
174 |
$bn\,(\mathtt{anil}) = \varnothing \qquad bn\,(\mathtt{acons}\;x\;t\;as) = \{x\} \cup bn\,(as)$ |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
175 |
\end{center} |
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
176 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
177 |
\noindent |
1550 | 178 |
The scope of the binding is indicated by labels given to the types, for |
179 |
example \mbox{$s\!::\!trm$}, and a binding clause, in this case |
|
1577 | 180 |
$\mathtt{bind}\;bn\,(a) \IN s$, that states to bind in $s$ all the names the |
1607 | 181 |
function call $bn\,(a)$ returns. This style of specifying terms and bindings is |
1577 | 182 |
heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
183 |
|
1545 | 184 |
However, we will not be able to deal with all specifications that are |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
185 |
allowed by Ott. One reason is that Ott lets the user to specify ``empty'' |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
186 |
types like |
1570 | 187 |
|
188 |
\begin{center} |
|
189 |
$t ::= t\;t \mid \lambda x. t$ |
|
190 |
\end{center} |
|
191 |
||
192 |
\noindent |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
193 |
where no clause for variables is given. Arguably, such specifications make |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
194 |
some sense in the context of Coq's type theory (which Ott supports), but not |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
195 |
at all in a HOL-based environment where every datatype must have a non-empty |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
196 |
set-theoretic model. |
1570 | 197 |
|
198 |
Another reason is that we establish the reasoning infrastructure |
|
199 |
for alpha-\emph{equated} terms. In contrast, Ott produces a reasoning |
|
200 |
infrastructure in Isabelle/HOL for |
|
1545 | 201 |
\emph{non}-alpha-equated, or ``raw'', terms. While our alpha-equated terms |
1556 | 202 |
and the raw terms produced by Ott use names for bound variables, |
1545 | 203 |
there is a key difference: working with alpha-equated terms means that the |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
204 |
two type-schemes (with $x$, $y$ and $z$ being distinct) |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
205 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
206 |
\begin{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
207 |
$\forall \{x\}. x \rightarrow y \;=\; \forall \{x, z\}. x \rightarrow y$ |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
208 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
209 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
210 |
\noindent |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
211 |
are not just alpha-equal, but actually \emph{equal}. As a |
1550 | 212 |
result, we can only support specifications that make sense on the level of |
213 |
alpha-equated terms (offending specifications, which for example bind a variable |
|
1556 | 214 |
according to a variable bound somewhere else, are not excluded by Ott, but we |
215 |
have to). Our |
|
1550 | 216 |
insistence on reasoning with alpha-equated terms comes from the wealth of |
217 |
experience we gained with the older version of Nominal Isabelle: for |
|
218 |
non-trivial properties, reasoning about alpha-equated terms is much easier |
|
1556 | 219 |
than reasoning with raw terms. The fundamental reason for this is that the |
1550 | 220 |
HOL-logic underlying Nominal Isabelle allows us to replace |
1628 | 221 |
``equals-by-equals''. In contrast, replacing ``alpha-equals-by-alpha-equals'' |
1550 | 222 |
in a representation based on raw terms requires a lot of extra reasoning work. |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
223 |
|
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
224 |
Although in informal settings a reasoning infrastructure for alpha-equated |
1607 | 225 |
terms is nearly always taken for granted, establishing |
1550 | 226 |
it automatically in the Isabelle/HOL theorem prover is a rather non-trivial task. |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
227 |
For every specification we will need to construct a type containing as |
1556 | 228 |
elements the alpha-equated terms. To do so, we use |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
229 |
the standard HOL-technique of defining a new type by |
1556 | 230 |
identifying a non-empty subset of an existing type. The construction we |
1607 | 231 |
perform in HOL can be illustrated by the following picture: |
1545 | 232 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
233 |
\begin{center} |
1552 | 234 |
\begin{tikzpicture} |
235 |
%\draw[step=2mm] (-4,-1) grid (4,1); |
|
236 |
||
237 |
\draw[very thick] (0.7,0.4) circle (4.25mm); |
|
238 |
\draw[rounded corners=1mm, very thick] ( 0.0,-0.8) rectangle ( 1.8, 0.9); |
|
239 |
\draw[rounded corners=1mm, very thick] (-1.95,0.85) rectangle (-2.85,-0.05); |
|
240 |
||
241 |
\draw (-2.0, 0.845) -- (0.7,0.845); |
|
242 |
\draw (-2.0,-0.045) -- (0.7,-0.045); |
|
243 |
||
244 |
\draw ( 0.7, 0.4) node {\begin{tabular}{@ {}c@ {}}$\alpha$-\\[-1mm]clas.\end{tabular}}; |
|
245 |
\draw (-2.4, 0.4) node {\begin{tabular}{@ {}c@ {}}$\alpha$-eq.\\[-1mm]terms\end{tabular}}; |
|
246 |
\draw (1.8, 0.48) node[right=-0.1mm] |
|
247 |
{\begin{tabular}{@ {}l@ {}}existing\\[-1mm] type\\ (sets of raw terms)\end{tabular}}; |
|
248 |
\draw (0.9, -0.35) node {\begin{tabular}{@ {}l@ {}}non-empty\\[-1mm]subset\end{tabular}}; |
|
249 |
\draw (-3.25, 0.55) node {\begin{tabular}{@ {}l@ {}}new\\[-1mm]type\end{tabular}}; |
|
250 |
||
251 |
\draw[<->, very thick] (-1.8, 0.3) -- (-0.1,0.3); |
|
252 |
\draw (-0.95, 0.3) node[above=0mm] {isomorphism}; |
|
253 |
||
254 |
\end{tikzpicture} |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
255 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
256 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
257 |
\noindent |
1577 | 258 |
We take as the starting point a definition of raw terms (defined as a |
1556 | 259 |
datatype in Isabelle/HOL); identify then the |
1607 | 260 |
alpha-equivalence classes in the type of sets of raw terms according to our |
1556 | 261 |
alpha-equivalence relation and finally define the new type as these |
262 |
alpha-equivalence classes (non-emptiness is satisfied whenever the raw terms are |
|
1607 | 263 |
definable as datatype in Isabelle/HOL and the fact that our relation for |
264 |
alpha-equivalence is indeed an equivalence relation). |
|
1556 | 265 |
|
1607 | 266 |
The fact that we obtain an isomorphism between the new type and the non-empty |
1556 | 267 |
subset shows that the new type is a faithful representation of alpha-equated terms. |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
268 |
That is not the case for example for terms using the locally |
1607 | 269 |
nameless representation of binders \cite{McKinnaPollack99}: in this representation |
270 |
there are ``junk'' terms that need to |
|
1556 | 271 |
be excluded by reasoning about a well-formedness predicate. |
272 |
||
1577 | 273 |
The problem with introducing a new type in Isabelle/HOL is that in order to be useful, |
1572 | 274 |
a reasoning infrastructure needs to be ``lifted'' from the underlying subset to |
1607 | 275 |
the new type. This is usually a tricky and arduous task. To ease it, |
1577 | 276 |
we re-implemented in Isabelle/HOL the quotient package described by Homeier |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
277 |
\cite{Homeier05} for the HOL4 system. This package |
1577 | 278 |
allows us to lift definitions and theorems involving raw terms |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
279 |
to definitions and theorems involving alpha-equated terms. For example |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
280 |
if we define the free-variable function over raw lambda-terms |
1577 | 281 |
|
282 |
\begin{center} |
|
283 |
$\fv(x) = \{x\}$\hspace{10mm} |
|
284 |
$\fv(t_1\;t_2) = \fv(t_1) \cup \fv(t_2)$\\[1mm] |
|
285 |
$\fv(\lambda x.t) = \fv(t) - \{x\}$ |
|
286 |
\end{center} |
|
287 |
||
288 |
\noindent |
|
1620 | 289 |
then with not too great effort we obtain a function $\fv^\alpha$ |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
290 |
operating on quotients, or alpha-equivalence classes of lambda-terms. This |
1628 | 291 |
lifted function is characterised by the equations |
1577 | 292 |
|
293 |
\begin{center} |
|
1620 | 294 |
$\fv^\alpha(x) = \{x\}$\hspace{10mm} |
295 |
$\fv^\alpha(t_1\;t_2) = \fv^\alpha(t_1) \cup \fv^\alpha(t_2)$\\[1mm] |
|
296 |
$\fv^\alpha(\lambda x.t) = \fv^\alpha(t) - \{x\}$ |
|
1577 | 297 |
\end{center} |
298 |
||
299 |
\noindent |
|
300 |
(Note that this means also the term-constructors for variables, applications |
|
301 |
and lambda are lifted to the quotient level.) This construction, of course, |
|
1628 | 302 |
only works if alpha-equivalence is indeed an equivalence relation, and the lifted |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
303 |
definitions and theorems are respectful w.r.t.~alpha-equivalence. Accordingly, we |
1607 | 304 |
will not be able to lift a bound-variable function to alpha-equated terms |
305 |
(since it does not respect alpha-equivalence). To sum up, every lifting of |
|
306 |
theorems to the quotient level needs proofs of some respectfulness |
|
307 |
properties. In the paper we show that we are able to automate these |
|
308 |
proofs and therefore can establish a reasoning infrastructure for |
|
309 |
alpha-equated terms.\medskip |
|
1577 | 310 |
|
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
311 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
312 |
\noindent |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
313 |
{\bf Contributions:} We provide new definitions for when terms |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
314 |
involving multiple binders are alpha-equivalent. These definitions are |
1607 | 315 |
inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
316 |
proofs, we establish a reasoning infrastructure for alpha-equated |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
317 |
terms, including properties about support, freshness and equality |
1607 | 318 |
conditions for alpha-equated terms. We are also able to derive, at the moment |
319 |
only manually, strong induction principles that |
|
320 |
have the variable convention already built in. |
|
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
321 |
*} |
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
322 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
323 |
section {* A Short Review of the Nominal Logic Work *} |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
324 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
325 |
text {* |
1556 | 326 |
At its core, Nominal Isabelle is an adaption of the nominal logic work by |
327 |
Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
328 |
\cite{HuffmanUrban10}, which we review here briefly to aid the description |
1556 | 329 |
of what follows. Two central notions in the nominal logic work are sorted |
1570 | 330 |
atoms and sort-respecting permutations of atoms. The sorts can be used to |
331 |
represent different kinds of variables, such as term- and type-variables in |
|
332 |
Core-Haskell, and it is assumed that there is an infinite supply of atoms |
|
333 |
for each sort. However, in order to simplify the description, we shall |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
334 |
assume in what follows that there is only one sort of atoms. |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
335 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
336 |
Permutations are bijective functions from atoms to atoms that are |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
337 |
the identity everywhere except on a finite number of atoms. There is a |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
338 |
two-place permutation operation written |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
339 |
% |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
340 |
@{text[display,indent=5] "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
341 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
342 |
\noindent |
1628 | 343 |
in which the generic type @{text "\<beta>"} stands for the type of the object |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
344 |
on which the permutation |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
345 |
acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
346 |
the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}} |
1570 | 347 |
and the inverse permutation of @{term p} as @{text "- p"}. The permutation |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
348 |
operation is defined for products, lists, sets, functions, booleans etc |
1628 | 349 |
(see \cite{HuffmanUrban10}). Concrete permutations are build up from |
350 |
swappings, written as @{text "(a b)"}, |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
351 |
which are permutations that behave as follows: |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
352 |
% |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
353 |
@{text[display,indent=5] "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
354 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
355 |
|
1570 | 356 |
The most original aspect of the nominal logic work of Pitts is a general |
357 |
definition for the notion of ``the set of free variables of an object @{text |
|
358 |
"x"}''. This notion, written @{term "supp x"}, is general in the sense that |
|
1628 | 359 |
it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
1570 | 360 |
products, sets and even functions. The definition depends only on the |
361 |
permutation operation and on the notion of equality defined for the type of |
|
362 |
@{text x}, namely: |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
363 |
% |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
364 |
@{thm[display,indent=5] supp_def[no_vars, THEN eq_reflection]} |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
365 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
366 |
\noindent |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
367 |
There is also the derived notion for when an atom @{text a} is \emph{fresh} |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
368 |
for an @{text x}, defined as |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
369 |
% |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
370 |
@{thm[display,indent=5] fresh_def[no_vars]} |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
371 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
372 |
\noindent |
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
373 |
We also use for sets of atoms the abbreviation |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
374 |
@{thm (lhs) fresh_star_def[no_vars]} defined as |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
375 |
@{thm (rhs) fresh_star_def[no_vars]}. |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
376 |
A striking consequence of these definitions is that we can prove |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
377 |
without knowing anything about the structure of @{term x} that |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
378 |
swapping two fresh atoms, say @{text a} and @{text b}, leave |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
379 |
@{text x} unchanged. |
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
380 |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
381 |
\begin{property} |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
382 |
@{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
383 |
\end{property} |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
384 |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
385 |
\noindent |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
386 |
For a proof see \cite{HuffmanUrban10}. |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
387 |
|
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
388 |
\begin{property} |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
389 |
@{thm[mode=IfThen] at_set_avoiding[no_vars]} |
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
390 |
\end{property} |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
391 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
392 |
*} |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
393 |
|
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
394 |
|
1620 | 395 |
section {* General Binders\label{sec:binders} *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
396 |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
397 |
text {* |
1587 | 398 |
In Nominal Isabelle, the user is expected to write down a specification of a |
399 |
term-calculus and then a reasoning infrastructure is automatically derived |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
400 |
from this specification (remember that Nominal Isabelle is a definitional |
1587 | 401 |
extension of Isabelle/HOL, which does not introduce any new axioms). |
1579 | 402 |
|
1556 | 403 |
|
1579 | 404 |
In order to keep our work manageable, we will wherever possible state |
405 |
definitions and perform proofs inside Isabelle, as opposed to write custom |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
406 |
ML-code that generates them anew for each specification. To that |
1579 | 407 |
end, we will consider pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}. |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
408 |
These pairs are intended to represent the abstraction, or binding, of the set @{text "as"} |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
409 |
in the body @{text "x"}. |
1570 | 410 |
|
1579 | 411 |
The first question we have to answer is when the pairs $(as, x)$ and $(bs, y)$ are |
412 |
alpha-equivalent? (At the moment we are interested in |
|
1570 | 413 |
the notion of alpha-equivalence that is \emph{not} preserved by adding |
1579 | 414 |
vacuous binders.) To answer this, we identify four conditions: {\it i)} given |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
415 |
a free-variable function $\fv$ of type \mbox{@{text "\<beta> \<Rightarrow> atom set"}}, then @{text x} and @{text y} |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
416 |
need to have the same set of free variables; moreover there must be a permutation |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
417 |
@{text p} such that {\it ii)} it leaves the free variables of @{text x} and @{text y} unchanged, |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
418 |
but {\it iii)} ``moves'' their bound names so that we obtain modulo a relation, |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
419 |
say \mbox{@{text "_ R _"}}, two equal terms. We also require {\it iv)} that @{text p} makes |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
420 |
the abstracted sets @{text as} and @{text bs} equal. The requirements {\it i)} to {\it iv)} can |
1579 | 421 |
be stated formally as follows: |
1556 | 422 |
% |
1572 | 423 |
\begin{equation}\label{alphaset} |
424 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
|
1579 | 425 |
\multicolumn{2}{l}{(as, x) \approx\hspace{0.05mm}_{set}^{\fv, R, p} (bs, y) \;\dn\hspace{30mm}\;}\\[1mm] |
1572 | 426 |
& @{text "fv(x) - as = fv(y) - bs"}\\ |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
427 |
\wedge & @{text "(fv(x) - as) #* p"}\\ |
1572 | 428 |
\wedge & @{text "(p \<bullet> x) R y"}\\ |
429 |
\wedge & @{text "(p \<bullet> as) = bs"}\\ |
|
430 |
\end{array} |
|
1556 | 431 |
\end{equation} |
432 |
||
433 |
\noindent |
|
1579 | 434 |
Note that this relation is dependent on $p$. Alpha-equivalence is then the relation where |
435 |
we existentially quantify over this $p$. |
|
436 |
Also note that the relation is dependent on a free-variable function $\fv$ and a relation |
|
437 |
$R$. The reason for this extra generality is that we will use $\approx_{set}$ for both |
|
438 |
``raw'' terms and alpha-equated terms. In the latter case, $R$ will be replaced by |
|
439 |
equality $(op =)$ and we are going to prove that $\fv$ will be equal to the support |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
440 |
of $x$ and $y$. |
1572 | 441 |
|
442 |
The definition in \eqref{alphaset} does not make any distinction between the |
|
1579 | 443 |
order of abstracted variables. If we want this, then we can define alpha-equivalence |
444 |
for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} |
|
445 |
as follows |
|
1572 | 446 |
% |
447 |
\begin{equation}\label{alphalist} |
|
448 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
|
1579 | 449 |
\multicolumn{2}{l}{(as, x) \approx\hspace{0.05mm}_{list}^{\fv, R, p} (bs, y) \;\dn\hspace{30mm}\;}\\[1mm] |
1572 | 450 |
& @{text "fv(x) - (set as) = fv(y) - (set bs)"}\\ |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
451 |
\wedge & @{text "(fv(x) - set as) #* p"}\\ |
1572 | 452 |
\wedge & @{text "(p \<bullet> x) R y"}\\ |
453 |
\wedge & @{text "(p \<bullet> as) = bs"}\\ |
|
454 |
\end{array} |
|
455 |
\end{equation} |
|
456 |
||
457 |
\noindent |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
458 |
where $set$ is the function that coerces a list of atoms into a set of atoms. |
1556 | 459 |
|
1572 | 460 |
If we do not want to make any difference between the order of binders and |
1579 | 461 |
also allow vacuous binders, then we keep sets of binders, but drop the fourth |
462 |
condition in \eqref{alphaset}: |
|
1572 | 463 |
% |
1579 | 464 |
\begin{equation}\label{alphares} |
1572 | 465 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
1579 | 466 |
\multicolumn{2}{l}{(as, x) \approx\hspace{0.05mm}_{res}^{\fv, R, p} (bs, y) \;\dn\hspace{30mm}\;}\\[1mm] |
1572 | 467 |
& @{text "fv(x) - as = fv(y) - bs"}\\ |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
468 |
\wedge & @{text "(fv(x) - as) #* p"}\\ |
1572 | 469 |
\wedge & @{text "(p \<bullet> x) R y"}\\ |
470 |
\end{array} |
|
471 |
\end{equation} |
|
1556 | 472 |
|
1579 | 473 |
\begin{exmple}\rm |
474 |
It might be useful to consider some examples for how these definitions pan out in practise. |
|
475 |
For this consider the case of abstracting a set of variables over types (as in type-schemes). |
|
476 |
We set $R$ to be the equality and for $\fv(T)$ we define |
|
1572 | 477 |
|
478 |
\begin{center} |
|
479 |
$\fv(x) = \{x\} \qquad \fv(T_1 \rightarrow T_2) = \fv(T_1) \cup \fv(T_2)$ |
|
480 |
\end{center} |
|
481 |
||
482 |
\noindent |
|
1579 | 483 |
Now recall the examples shown in \eqref{ex1}, \eqref{ex2} and \eqref{ex3}. It can be easily |
484 |
checked that @{text "({x, y}, x \<rightarrow> y)"} and |
|
485 |
@{text "({y, x}, y \<rightarrow> x)"} are equal according to $\approx_{set}$ and $\approx_{res}$ by taking $p$ to |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
486 |
be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then |
1579 | 487 |
$([x, y], x \rightarrow y) \not\approx_{list} ([y,x], x \rightarrow y)$ since there is no permutation that |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
488 |
makes the lists @{text "[x, y]"} and @{text "[y, x]"} equal, and also leaves the |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
489 |
type \mbox{@{text "x \<rightarrow> y"}} unchanged. Another examples is |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
490 |
$(\{x\}, x) \approx_{res} (\{x,y\}, x)$ which holds by taking $p$ to be the identity permutation. |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
491 |
However, if @{text "x \<noteq> y"}, then |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
492 |
$(\{x\}, x) \not\approx_{set} (\{x,y\}, x)$ since there is no permutation that makes |
1579 | 493 |
the sets $\{x\}$ and $\{x,y\}$ equal (similarly for $\approx_{list}$). |
494 |
\end{exmple} |
|
495 |
||
496 |
\noindent |
|
497 |
Let $\star$ range over $\{set, res, list\}$. We prove next under which |
|
498 |
conditions the $\approx\hspace{0.05mm}_\star^{\fv, R, p}$ are equivalence |
|
499 |
relations and equivariant: |
|
500 |
||
501 |
\begin{lemma} |
|
502 |
{\it i)} Given the fact that $x\;R\;x$ holds, then |
|
503 |
$(as, x) \approx\hspace{0.05mm}^{\fv, R, 0}_\star (as, x)$. {\it ii)} Given |
|
504 |
that @{text "(p \<bullet> x) R y"} implies @{text "(-p \<bullet> y) R x"}, then |
|
505 |
$(as, x) \approx\hspace{0.05mm}^{\fv, R, p}_\star (bs, y)$ implies |
|
506 |
$(bs, y) \approx\hspace{0.05mm}^{\fv, R, - p}_\star (as, x)$. {\it iii)} Given |
|
507 |
that @{text "(p \<bullet> x) R y"} and @{text "(q \<bullet> y) R z"} implies |
|
508 |
@{text "((q + p) \<bullet> x) R z"}, then $(as, x) \approx\hspace{0.05mm}^{\fv, R, p}_\star (bs, y)$ |
|
509 |
and $(bs, y) \approx\hspace{0.05mm}^{\fv, R, q}_\star (cs, z)$ implies |
|
510 |
$(as, x) \approx\hspace{0.05mm}^{\fv, R, q + p}_\star (cs, z)$. Given |
|
511 |
@{text "(q \<bullet> x) R y"} implies @{text "(p \<bullet> (q \<bullet> x)) R (p \<bullet> y)"} and |
|
512 |
@{text "p \<bullet> (fv x) = fv (p \<bullet> x)"} then @{text "p \<bullet> (fv y) = fv (p \<bullet> y)"}, then |
|
513 |
$(as, x) \approx\hspace{0.05mm}^{\fv, R, q}_\star (bs, y)$ implies |
|
514 |
$(p \;\isasymbullet\; as, p \;\isasymbullet\; x) \approx\hspace{0.05mm}^{\fv, R, q}_\star |
|
515 |
(p \;\isasymbullet\; bs, p \;\isasymbullet\; y)$. |
|
516 |
\end{lemma} |
|
517 |
||
518 |
\begin{proof} |
|
519 |
All properties are by unfolding the definitions and simple calculations. |
|
520 |
\end{proof} |
|
1587 | 521 |
|
522 |
||
523 |
\begin{lemma} |
|
524 |
$supp ([as]set. x) = supp x - as$ |
|
525 |
\end{lemma} |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
526 |
*} |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
527 |
|
1491
f970ca9b5bec
paper uses now a heap file - does not compile so long anymore
Christian Urban <urbanc@in.tum.de>
parents:
1485
diff
changeset
|
528 |
section {* Alpha-Equivalence and Free Variables *} |
f970ca9b5bec
paper uses now a heap file - does not compile so long anymore
Christian Urban <urbanc@in.tum.de>
parents:
1485
diff
changeset
|
529 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
530 |
text {* |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
531 |
Our specifications for term-calculi are heavily |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
532 |
inspired by the syntax of the Ott-tool \cite{ott-jfp}. A specification is |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
533 |
a collection of (possibly mutual recursive) type declarations, say |
1620 | 534 |
$ty^\alpha_1$, $ty^\alpha_2$, \ldots $ty^\alpha_n$, and an |
1636 | 535 |
associated collection of binding functions, say |
536 |
$bn^\alpha_1$, \ldots, $bn^\alpha_m$. The syntax in Nominal Isabelle |
|
1628 | 537 |
for such specifications is rougly as follows: |
538 |
% |
|
1619 | 539 |
\begin{equation}\label{scheme} |
1636 | 540 |
\mbox{\begin{tabular}{@ {\hspace{-5mm}}p{1.8cm}l} |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
541 |
type \mbox{declaration part} & |
1611 | 542 |
$\begin{cases} |
543 |
\mbox{\begin{tabular}{l} |
|
1620 | 544 |
\isacommand{nominal\_datatype} $ty^\alpha_1 = \ldots$\\ |
545 |
\isacommand{and} $ty^\alpha_2 = \ldots$\\ |
|
1587 | 546 |
$\ldots$\\ |
1620 | 547 |
\isacommand{and} $ty^\alpha_n = \ldots$\\ |
1611 | 548 |
\end{tabular}} |
549 |
\end{cases}$\\ |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
550 |
binding \mbox{function part} & |
1611 | 551 |
$\begin{cases} |
552 |
\mbox{\begin{tabular}{l} |
|
1620 | 553 |
\isacommand{with} $bn^\alpha_1$ \isacommand{and} \ldots \isacommand{and} $bn^\alpha_m$ |
1587 | 554 |
$\ldots$\\ |
1611 | 555 |
\isacommand{where}\\ |
1587 | 556 |
$\ldots$\\ |
1611 | 557 |
\end{tabular}} |
558 |
\end{cases}$\\ |
|
1619 | 559 |
\end{tabular}} |
560 |
\end{equation} |
|
1587 | 561 |
|
562 |
\noindent |
|
1620 | 563 |
Every type declaration $ty^\alpha_i$ consists of a collection of |
1611 | 564 |
term-constructors, each of which comes with a list of labelled |
1620 | 565 |
types that stand for the types of the arguments of the term-constructor. |
1636 | 566 |
For example a term-constructor $C^\alpha$ might have |
1611 | 567 |
|
568 |
\begin{center} |
|
1620 | 569 |
$C^\alpha\;label_1\!::\!ty'_1\;\ldots label_l\!::\!ty'_l\;\;\textit{binding\_clauses}$ |
1611 | 570 |
\end{center} |
1587 | 571 |
|
1611 | 572 |
\noindent |
1636 | 573 |
whereby some of the $ty'_k$ (or their components) are contained in the collection |
574 |
of $ty^\alpha_i$ declared in \eqref{scheme}. In this case we will call the |
|
575 |
corresponding argument a \emph{recursive argument}. The labels annotated on |
|
576 |
the types are optional and can be used in the (possibly empty) list of |
|
577 |
\emph{binding clauses}. These clauses indicate the binders and the scope of |
|
578 |
the binders in a term-constructor. They come in three \emph{modes} |
|
579 |
||
1587 | 580 |
|
1611 | 581 |
\begin{center} |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
582 |
\begin{tabular}{l} |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
583 |
\isacommand{bind}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
584 |
\isacommand{bind\_set}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
585 |
\isacommand{bind\_res}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
586 |
\end{tabular} |
1611 | 587 |
\end{center} |
588 |
||
589 |
\noindent |
|
1636 | 590 |
The first mode is for binding lists of atoms (the order of binders matters); the second is for sets |
1628 | 591 |
of binders (the order does not matter, but cardinality does) and the last is for |
1620 | 592 |
sets of binders (with vacuous binders preserving alpha-equivalence). |
593 |
||
594 |
In addition we distinguish between \emph{shallow} binders and \emph{deep} |
|
595 |
binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; |
|
1628 | 596 |
\isacommand{in}\; {\it another\_label} (similar for the other two modes). The |
1620 | 597 |
restriction we impose on shallow binders is that the {\it label} must either |
598 |
refer to a type that is an atom type or to a type that is a finite set or |
|
1636 | 599 |
list of an atom type. For example the specifications for lambda-terms, where |
1620 | 600 |
a single name is bound, and type-schemes, where a finite set of names is |
601 |
bound, use shallow binders (the type \emph{name} is an atom type): |
|
1611 | 602 |
|
603 |
\begin{center} |
|
1612 | 604 |
\begin{tabular}{@ {}cc@ {}} |
605 |
\begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
|
606 |
\isacommand{nominal\_datatype} {\it lam} =\\ |
|
607 |
\hspace{5mm}\phantom{$\mid$} Var\;{\it name}\\ |
|
608 |
\hspace{5mm}$\mid$ App\;{\it lam}\;{\it lam}\\ |
|
609 |
\hspace{5mm}$\mid$ Lam\;{\it x::name}\;{\it t::lam}\\ |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
610 |
\hspace{21mm}\isacommand{bind} {\it x} \isacommand{in} {\it t}\\ |
1611 | 611 |
\end{tabular} & |
1612 | 612 |
\begin{tabular}{@ {}l@ {}} |
613 |
\isacommand{nominal\_datatype} {\it ty} =\\ |
|
614 |
\hspace{5mm}\phantom{$\mid$} TVar\;{\it name}\\ |
|
615 |
\hspace{5mm}$\mid$ TFun\;{\it ty}\;{\it ty}\\ |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
616 |
\isacommand{and} {\it tsc} = All\;{\it xs::(name fset)}\;{\it T::ty}\\ |
1619 | 617 |
\hspace{24mm}\isacommand{bind\_res} {\it xs} \isacommand{in} {\it T}\\ |
1611 | 618 |
\end{tabular} |
619 |
\end{tabular} |
|
620 |
\end{center} |
|
1587 | 621 |
|
1612 | 622 |
\noindent |
1628 | 623 |
If we have shallow binders that ``share'' a body, for instance $t$ in |
624 |
the term-constructor Foo$_0$ |
|
1620 | 625 |
|
626 |
\begin{center} |
|
627 |
\begin{tabular}{ll} |
|
628 |
\it {\rm Foo}$_0$ x::name y::name t::lam & \it |
|
629 |
\isacommand{bind}\;x\;\isacommand{in}\;t,\; |
|
630 |
\isacommand{bind}\;y\;\isacommand{in}\;t |
|
631 |
\end{tabular} |
|
632 |
\end{center} |
|
633 |
||
634 |
\noindent |
|
1628 | 635 |
then we have to make sure the modes of the binders agree. We cannot |
1620 | 636 |
have in the first binding clause the mode \isacommand{bind} and in the second |
637 |
\isacommand{bind\_set}. |
|
638 |
||
639 |
A \emph{deep} binder uses an auxiliary binding function that ``picks'' out |
|
1636 | 640 |
the atoms in one argument of the term-constructor, which can be bound in |
1628 | 641 |
other arguments and also in the same argument (we will |
1620 | 642 |
call such binders \emph{recursive}). |
643 |
The binding functions are expected to return either a set of atoms |
|
644 |
(for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms |
|
645 |
(for \isacommand{bind}). They can be defined by primitive recursion over the |
|
646 |
corresponding type; the equations must be given in the binding function part of |
|
1628 | 647 |
the scheme shown in \eqref{scheme}. For example for a calculus containing lets |
648 |
with tuple patterns, you might declare |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
649 |
|
1619 | 650 |
\begin{center} |
651 |
\begin{tabular}{l} |
|
652 |
\isacommand{nominal\_datatype} {\it trm} =\\ |
|
653 |
\hspace{5mm}\phantom{$\mid$} Var\;{\it name}\\ |
|
654 |
\hspace{5mm}$\mid$ App\;{\it trm}\;{\it trm}\\ |
|
655 |
\hspace{5mm}$\mid$ Lam\;{\it x::name}\;{\it t::trm} |
|
656 |
\;\;\isacommand{bind} {\it x} \isacommand{in} {\it t}\\ |
|
657 |
\hspace{5mm}$\mid$ Let\;{\it p::pat}\;{\it trm}\; {\it t::trm} |
|
1636 | 658 |
\;\;\isacommand{bind} {\it bn(p)} \isacommand{in} {\it t}\\ |
1619 | 659 |
\isacommand{and} {\it pat} =\\ |
660 |
\hspace{5mm}\phantom{$\mid$} PNo\\ |
|
661 |
\hspace{5mm}$\mid$ PVr\;{\it name}\\ |
|
662 |
\hspace{5mm}$\mid$ PPr\;{\it pat}\;{\it pat}\\ |
|
1636 | 663 |
\isacommand{with} {\it bn::pat $\Rightarrow$ atom list}\\ |
664 |
\isacommand{where} $bn(\textrm{PNil}) = []$\\ |
|
665 |
\hspace{5mm}$\mid$ $bn(\textrm{PVar}\;x) = [atom\; x]$\\ |
|
666 |
\hspace{5mm}$\mid$ $bn(\textrm{PPrd}\;p_1\;p_2) = bn(p_1)\; @\;bn(p_2)$\\ |
|
1619 | 667 |
\end{tabular} |
668 |
\end{center} |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
669 |
|
1619 | 670 |
\noindent |
1628 | 671 |
In this specification the function $atom$ coerces a name into the generic |
1620 | 672 |
atom type of Nominal Isabelle. This allows us to treat binders of different |
1628 | 673 |
atom type uniformly. As will shortly become clear, we cannot return an atom in a |
674 |
binding function that also is bound in the term-constructor. In the present |
|
675 |
version of Nominal Isabelle, we adopted the restriction the Ott-tool imposes |
|
676 |
on the binding functions, namely a binding function can only return the |
|
677 |
empty set (case PNil), a singleton set containing an atom (case PVar) or |
|
678 |
unions of atom sets (case PPrd). Moreover, as with shallow binders, deep |
|
679 |
binders with shared body need to have the same binding mode. Finally, the |
|
680 |
most drastic restriction we have to impose on deep binders is that we cannot |
|
681 |
have ``overlapping'' deep binders. Consider for example the term-constructors: |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
682 |
|
1620 | 683 |
\begin{center} |
684 |
\begin{tabular}{ll} |
|
685 |
\it {\rm Foo}$_1$ p::pat q::pat t::trm & \it \isacommand{bind}\;bn(p)\;\isacommand{in}\;t,\; |
|
686 |
\isacommand{bind}\;bn(q)\;\isacommand{in}\;t\\ |
|
687 |
\it {\rm Foo}$_2$ x::name p::pat t::trm & \it \it \isacommand{bind}\;x\;\isacommand{in}\;t,\; |
|
688 |
\isacommand{bind}\;bn(p)\;\isacommand{in}\;t |
|
689 |
||
690 |
\end{tabular} |
|
691 |
\end{center} |
|
692 |
||
693 |
\noindent |
|
694 |
In the first case we bind all atoms from the pattern $p$ in $t$ and also all atoms |
|
1628 | 695 |
from $q$ in $t$. As a result we have no way to determine whether the binder came from the |
696 |
binding function in $p$ or $q$. Similarly in the second case: |
|
697 |
the binder $bn(p)$ overlaps with the shallow binder $x$. We must exclude such specifiactions, |
|
1620 | 698 |
as we will not be able to represent them using the general binders described in |
699 |
Section \ref{sec:binders}. However the following two term-constructors are allowed: |
|
700 |
||
701 |
\begin{center} |
|
702 |
\begin{tabular}{ll} |
|
703 |
\it {\rm Bar}$_1$ p::pat t::trm s::trm & \it \isacommand{bind}\;bn(p)\;\isacommand{in}\;t,\; |
|
704 |
\isacommand{bind}\;bn(p)\;\isacommand{in}\;s\\ |
|
705 |
\it {\rm Bar}$_2$ p::pat t::trm & \it \isacommand{bind}\;bn(p)\;\isacommand{in}\;p,\; |
|
706 |
\isacommand{bind}\;bn(p)\;\isacommand{in}\;t\\ |
|
707 |
\end{tabular} |
|
708 |
\end{center} |
|
709 |
||
710 |
\noindent |
|
1628 | 711 |
since there is no overlap of binders. |
1619 | 712 |
|
1636 | 713 |
Let us come back one more time to the specification of simultaneous lets. |
714 |
A specification for them looks as follows: |
|
715 |
||
716 |
\begin{center} |
|
717 |
\begin{tabular}{l} |
|
718 |
\isacommand{nominal\_datatype} {\it trm} =\\ |
|
719 |
\hspace{5mm}\phantom{$\mid$}\ldots\\ |
|
720 |
\hspace{5mm}$\mid$ Let\;{\it a::assn}\; {\it t::trm} |
|
721 |
\;\;\isacommand{bind} {\it bn(a)} \isacommand{in} {\it t}\\ |
|
722 |
\isacommand{and} {\it assn} =\\ |
|
723 |
\hspace{5mm}\phantom{$\mid$} ANil\\ |
|
724 |
\hspace{5mm}$\mid$ ACons\;{\it name}\;{\it trm}\;{\it assn}\\ |
|
725 |
\isacommand{with} {\it bn::assn $\Rightarrow$ atom list}\\ |
|
726 |
\isacommand{where} $bn(\textrm{ANil}) = []$\\ |
|
727 |
\hspace{5mm}$\mid$ $bn(\textrm{ACons}\;x\;t\;a) = [atom\; x]\; @\; bn(a)$\\ |
|
728 |
\end{tabular} |
|
729 |
\end{center} |
|
730 |
||
731 |
\noindent |
|
732 |
The intention with this specification is to bind all variables |
|
733 |
from the assignments inside the body @{text t}. However one might |
|
734 |
like to consider the variant where the variables are not just |
|
735 |
bound in @{term t}, but also in the assignments themselves. In |
|
736 |
this case we need to specify |
|
737 |
||
738 |
\begin{center} |
|
739 |
\begin{tabular}{l} |
|
740 |
Let\_rec\;{\it a::assn}\; {\it t::trm} |
|
741 |
\;\;\isacommand{bind} {\it bn(a)} \isacommand{in} {\it t}, |
|
742 |
\isacommand{bind} {\it bn(a)} \isacommand{in} {\it a}\\ |
|
743 |
\end{tabular} |
|
744 |
\end{center} |
|
745 |
||
746 |
\noindent |
|
747 |
where we bind also in @{text a} all the atoms @{text bn} returns. In this |
|
748 |
case we will say the binder is a \emph{recursive binder}. |
|
749 |
||
750 |
Having dealt with all syntax matters, the problem now is how we can turn |
|
751 |
specifications into actual type |
|
1628 | 752 |
definitions in Isabelle/HOL and then establish a reasoning infrastructure |
1636 | 753 |
for them. Because of the problem Pottier and Cheney pointed out, we cannot |
1628 | 754 |
in general re-arrange arguments of term-constructors so that binders and |
1636 | 755 |
their bodies next to each other, an then use the type constructors |
756 |
@{text "abs_set"}, @{text "abs_res"} and @{text "abs_list"} from Section |
|
757 |
\ref{sec:binders}. Therefore |
|
1628 | 758 |
we will first extract datatype definitions from the specification and |
759 |
then define an alpha-equiavlence relation over them. |
|
760 |
||
761 |
The datatype definition can be obtained by just stripping of the |
|
762 |
binding clauses and the labels on the types. We also have to invent |
|
763 |
new names for the types, $ty^\alpha$ and term-constructors $C^\alpha$ |
|
1636 | 764 |
given by user. We just use an affix like |
1587 | 765 |
|
1628 | 766 |
\begin{center} |
767 |
$ty^\alpha \mapsto ty\_raw \qquad C^\alpha \mapsto C\_raw$ |
|
768 |
\end{center} |
|
769 |
||
770 |
\noindent |
|
1636 | 771 |
The datatype definition can be made, provided the usual conditions hold: |
772 |
the datatypes must be non-empty and they must only occur in positive |
|
773 |
position (see \cite{}). We then consider the user-specified binding |
|
774 |
functions and define them by primitive recursion over the raw datatypes. |
|
1628 | 775 |
|
1636 | 776 |
The first non-trivial step we have to generate free-variable |
777 |
functions from the specifications. The basic idea is to collect |
|
778 |
all atoms that are not bound, but because of the rather complicated |
|
779 |
binding mechanisms the details are somewhat involved. |
|
780 |
There are two kinds of free-variable functions: one corresponds to types, |
|
781 |
written $\fv\_ty$, and the other corresponds to binding functions, |
|
782 |
written $\fv\_bn$. They have to be defined at the same time, since there can |
|
783 |
be dependencies between them. |
|
784 |
||
785 |
Given a term-constructor $C\_raw\;ty_1 \ldots ty_n$, of type $ty$ together with |
|
786 |
some binding clauses, the function $\fv\_ty (C\_raw\;x_1 \ldots x_n)$ will be |
|
787 |
the union of the values generated for each argument, say $x_i$ with type $ty_i$. |
|
788 |
By the binding clause we know whether the argument $x_i$ is a shallow or deep |
|
789 |
binder and in the latter case also whether it is a recursive or non-recursive |
|
790 |
of a binder. In these cases we return as value: |
|
1628 | 791 |
|
792 |
\begin{center} |
|
1636 | 793 |
\begin{tabular}{cp{7cm}} |
794 |
$\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
|
795 |
$\bullet$ & @{text "fv_bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep non-recursive binder\\ |
|
796 |
$\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep recursive binder\\ |
|
1628 | 797 |
\end{tabular} |
798 |
\end{center} |
|
799 |
||
1636 | 800 |
\noindent |
801 |
The binding clause will also give us whether the argument @{term "x\<^isub>i"} is |
|
802 |
a body of one or more abstractions. There are two cases: either the |
|
803 |
corresponding binders are all shallow or there is a single deep binder. |
|
804 |
In the former case we build the union of all shallow binders; in the |
|
805 |
later case we just take set or list of atoms the specified binding |
|
806 |
function returns. Below use @{text "bnds"} to stand for them. |
|
807 |
||
808 |
\begin{center} |
|
809 |
\begin{tabular}{cp{7cm}} |
|
810 |
$\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ |
|
811 |
$\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ |
|
812 |
$\bullet$ & @{text "(atoml x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\ |
|
813 |
$\bullet$ & @{text "(fv_ty\<^isub>i x\<^isub>i) - bnds"} provided @{term "ty\<^isub>i"} is a nominal datatype\\ |
|
814 |
$\bullet$ & @{term "{}"} otherwise |
|
815 |
\end{tabular} |
|
816 |
\end{center} |
|
1628 | 817 |
|
1636 | 818 |
\noindent |
819 |
If the argument is neither a binder, nor a body, then it is defined as |
|
820 |
the four clauses above, except that @{text "bnds"} is empty. i.e.~no atoms |
|
821 |
are abstracted. |
|
1628 | 822 |
|
1587 | 823 |
*} |
824 |
||
825 |
||
826 |
||
827 |
text {* |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
828 |
Restrictions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
829 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
830 |
\begin{itemize} |
1572 | 831 |
\item non-emptiness |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
832 |
\item positive datatype definitions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
833 |
\item finitely supported abstractions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
834 |
\item respectfulness of the bn-functions\bigskip |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
835 |
\item binders can only have a ``single scope'' |
1577 | 836 |
\item all bindings must have the same mode |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
837 |
\end{itemize} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
838 |
*} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
839 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
840 |
section {* Examples *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
841 |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
842 |
section {* Adequacy *} |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
843 |
|
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
844 |
section {* Related Work *} |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
845 |
|
1570 | 846 |
text {* |
847 |
Ott is better with list dot specifications; subgrammars |
|
848 |
||
849 |
untyped; |
|
850 |
||
851 |
*} |
|
852 |
||
853 |
||
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
854 |
section {* Conclusion *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
855 |
|
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
856 |
text {* |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
857 |
Complication when the single scopedness restriction is lifted (two |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
858 |
overlapping permutations) |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
859 |
*} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
860 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
861 |
text {* |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
862 |
|
1517
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
863 |
TODO: function definitions: |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
864 |
\medskip |
62d6f7acc110
corrected the strong induction principle in the lambda-calculus case; gave a second (oartial) version that is more elegant
Christian Urban <urbanc@in.tum.de>
parents:
1506
diff
changeset
|
865 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
866 |
\noindent |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
867 |
{\bf Acknowledgements:} We are very grateful to Andrew Pitts for |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
868 |
many discussions about Nominal Isabelle. We thank Peter Sewell for |
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
869 |
making the informal notes \cite{SewellBestiary} available to us and |
1556 | 870 |
also for patiently explaining some of the finer points about the abstract |
1545 | 871 |
definitions and about the implementation of the Ott-tool. |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
872 |
|
1577 | 873 |
Lookup: Merlin paper by James Cheney; Mark Shinwell PhD |
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
874 |
|
1577 | 875 |
Future work: distinct list abstraction |
876 |
||
877 |
||
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
878 |
*} |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
879 |
|
1484 | 880 |
|
881 |
||
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
882 |
(*<*) |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
883 |
end |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
884 |
(*>*) |