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