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