author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Wed, 31 Mar 2010 15:20:58 +0200 | |
changeset 1729 | 2293711213dd |
parent 1728 | 9bbf2a1f9b3f |
child 1732 | 6eaae2651292 |
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" |
|
1728 | 8 |
abs_set :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
9 |
alpha_bn :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
|
1657 | 10 |
|
11 |
definition |
|
12 |
"equal \<equiv> (op =)" |
|
13 |
||
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
14 |
notation (latex output) |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
15 |
swap ("'(_ _')" [1000, 1000] 1000) and |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
16 |
fresh ("_ # _" [51, 51] 50) and |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
17 |
fresh_star ("_ #\<^sup>* _" [51, 51] 50) and |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
18 |
supp ("supp _" [78] 73) and |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
19 |
uminus ("-_" [78] 73) and |
1657 | 20 |
If ("if _ then _ else _" 10) and |
1662 | 21 |
alpha_gen ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{set}}$}}>\<^bsup>_,_,_\<^esup> _") and |
22 |
alpha_lst ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_,_,_\<^esup> _") and |
|
23 |
alpha_res ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{res}}$}}>\<^bsup>_,_,_\<^esup> _") and |
|
1657 | 24 |
abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
25 |
fv ("fv'(_')" [100] 100) and |
|
26 |
equal ("=") and |
|
27 |
alpha_abs ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and |
|
1703 | 28 |
Abs ("[_]\<^raw:$\!$>\<^bsub>set\<^esub>._" [20, 101] 999) and |
1657 | 29 |
Abs_lst ("[_]\<^raw:$\!$>\<^bsub>list\<^esub>._") and |
1690 | 30 |
Abs_res ("[_]\<^raw:$\!$>\<^bsub>res\<^esub>._") and |
1703 | 31 |
Cons ("_::_" [78,77] 73) and |
1728 | 32 |
supp_gen ("aux _" [1000] 10) and |
33 |
alpha_bn ("_ \<approx>bn _") |
|
34 |
||
754
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 |
|
1657 | 37 |
|
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
section {* Introduction *} |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
|
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
text {* |
1524 | 41 |
So far, Nominal Isabelle provides a mechanism for constructing |
1607 | 42 |
alpha-equated terms, for example |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
43 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
44 |
\begin{center} |
1657 | 45 |
@{text "t ::= x | t t | \<lambda>x. t"} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
46 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
47 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
48 |
\noindent |
1687 | 49 |
where free and bound variables have names. For such alpha-equated terms, Nominal Isabelle |
1657 | 50 |
derives automatically a reasoning infrastructure that has been used |
1550 | 51 |
successfully in formalisations of an equivalence checking algorithm for LF |
52 |
\cite{UrbanCheneyBerghofer08}, Typed |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
53 |
Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
54 |
\cite{BengtsonParow09} and a strong normalisation result |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
55 |
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
|
56 |
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
|
57 |
binding \cite{SatoPollack10}. |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
58 |
|
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
59 |
However, Nominal Isabelle has fared less well in a formalisation of |
1690 | 60 |
the algorithm W \cite{UrbanNipkow09}, where types and type-schemes are, |
61 |
respectively, of the form |
|
1570 | 62 |
% |
63 |
\begin{equation}\label{tysch} |
|
64 |
\begin{array}{l} |
|
1657 | 65 |
@{text "T ::= x | T \<rightarrow> T"}\hspace{5mm} |
66 |
@{text "S ::= \<forall>{x\<^isub>1,\<dots>, x\<^isub>n}. T"} |
|
1570 | 67 |
\end{array} |
68 |
\end{equation} |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
69 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
70 |
\noindent |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
71 |
and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of |
1550 | 72 |
type-variables. While it is possible to implement this kind of more general |
73 |
binders by iterating single binders, this leads to a rather clumsy |
|
74 |
formalisation of W. The need of iterating single binders is also one reason |
|
75 |
why Nominal Isabelle and similar theorem provers that only provide |
|
76 |
mechanisms for binding single variables have not fared extremely well with the |
|
77 |
more advanced tasks in the POPLmark challenge \cite{challenge05}, because |
|
78 |
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
|
79 |
|
1577 | 80 |
Binding multiple variables has interesting properties that cannot be captured |
1587 | 81 |
easily by iterating single binders. For example in case of type-schemes we do not |
82 |
want to make a distinction about the order of the bound variables. Therefore |
|
1550 | 83 |
we would like to regard the following two type-schemes as alpha-equivalent |
1572 | 84 |
% |
85 |
\begin{equation}\label{ex1} |
|
1667 | 86 |
@{text "\<forall>{x, y}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{y, x}. y \<rightarrow> x"} |
1572 | 87 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
88 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
89 |
\noindent |
1657 | 90 |
but assuming that @{text x}, @{text y} and @{text z} are distinct variables, |
1587 | 91 |
the following two should \emph{not} be alpha-equivalent |
1572 | 92 |
% |
93 |
\begin{equation}\label{ex2} |
|
1667 | 94 |
@{text "\<forall>{x, y}. x \<rightarrow> y \<notapprox>\<^isub>\<alpha> \<forall>{z}. z \<rightarrow> z"} |
1572 | 95 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
96 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
97 |
\noindent |
1657 | 98 |
Moreover, we like to regard type-schemes as alpha-equivalent, if they differ |
99 |
only on \emph{vacuous} binders, such as |
|
1572 | 100 |
% |
101 |
\begin{equation}\label{ex3} |
|
1667 | 102 |
@{text "\<forall>{x}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{x, z}. x \<rightarrow> y"} |
1572 | 103 |
\end{equation} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
104 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
105 |
\noindent |
1657 | 106 |
where @{text z} does not occur freely in the type. In this paper we will |
107 |
give a general binding mechanism and associated notion of alpha-equivalence |
|
108 |
that can be used to faithfully represent this kind of binding in Nominal |
|
109 |
Isabelle. The difficulty of finding the right notion for alpha-equivalence |
|
110 |
can be appreciated in this case by considering that the definition given by |
|
111 |
Leroy in \cite{Leroy92} is incorrect (it omits a side-condition). |
|
1524 | 112 |
|
1657 | 113 |
However, the notion of alpha-equivalence that is preserved by vacuous |
114 |
binders is not always wanted. For example in terms like |
|
1587 | 115 |
% |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
116 |
\begin{equation}\label{one} |
1657 | 117 |
@{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
|
118 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
119 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
120 |
\noindent |
1524 | 121 |
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
|
122 |
given, but it would be unusual to regard \eqref{one} as alpha-equivalent |
1524 | 123 |
with |
1587 | 124 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
125 |
\begin{center} |
1657 | 126 |
@{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
|
127 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
128 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
129 |
\noindent |
1550 | 130 |
Therefore we will also provide a separate binding mechanism for cases in |
131 |
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
|
132 |
binders has to agree. |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
133 |
|
1550 | 134 |
However, we found that this is still not sufficient for dealing with |
135 |
language constructs frequently occurring in programming language |
|
1690 | 136 |
research. For example in @{text "\<LET>"}s containing patterns like |
1587 | 137 |
% |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
138 |
\begin{equation}\label{two} |
1657 | 139 |
@{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
|
140 |
\end{equation} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
141 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
142 |
\noindent |
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
143 |
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
|
144 |
$\mathtt{let}$, but we also care about the order of these variables, since |
1566 | 145 |
we do not want to regard \eqref{two} as alpha-equivalent with |
1587 | 146 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
147 |
\begin{center} |
1657 | 148 |
@{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
|
149 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
150 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
151 |
\noindent |
1657 | 152 |
As a result, we provide three general binding mechanisms each of which binds |
153 |
multiple variables at once, and let the user chose which one is intended |
|
1711 | 154 |
when formalising a term-calculus. |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
155 |
|
1657 | 156 |
By providing these general binding mechanisms, however, we have to work |
157 |
around a problem that has been pointed out by Pottier \cite{Pottier06} and |
|
158 |
Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form |
|
1587 | 159 |
% |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
160 |
\begin{center} |
1657 | 161 |
@{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
|
162 |
\end{center} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
163 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
164 |
\noindent |
1657 | 165 |
which bind all the @{text "x\<^isub>i"} in @{text s}, we might not care |
166 |
about the order in which the @{text "x\<^isub>i = t\<^isub>i"} are given, |
|
167 |
but we do care about the information that there are as many @{text |
|
168 |
"x\<^isub>i"} as there are @{text "t\<^isub>i"}. We lose this information if |
|
169 |
we represent the @{text "\<LET>"}-constructor by something like |
|
1587 | 170 |
% |
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
171 |
\begin{center} |
1657 | 172 |
@{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
|
173 |
\end{center} |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
174 |
|
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
175 |
\noindent |
1703 | 176 |
where the notation @{text "[_]._"} indicates that the list of @{text "x\<^isub>i"} |
177 |
becomes bound in @{text s}. In this representation the term |
|
1690 | 178 |
\mbox{@{text "\<LET> [x].s [t\<^isub>1, t\<^isub>2]"}} is a perfectly legal |
1687 | 179 |
instance, but the lengths of two lists do not agree. To exclude such terms, |
180 |
additional predicates about well-formed |
|
1657 | 181 |
terms are needed in order to ensure that the two lists are of equal |
182 |
length. This can result into very messy reasoning (see for |
|
183 |
example~\cite{BengtsonParow09}). To avoid this, we will allow type |
|
184 |
specifications for $\mathtt{let}$s as follows |
|
1587 | 185 |
% |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
186 |
\begin{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
187 |
\begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}l} |
1657 | 188 |
@{text trm} & @{text "::="} & @{text "\<dots>"}\\ |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
189 |
& @{text "|"} & @{text "\<LET> as::assn s::trm"}\hspace{4mm} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
190 |
\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm] |
1657 | 191 |
@{text assn} & @{text "::="} & @{text "\<ANIL>"}\\ |
192 |
& @{text "|"} & @{text "\<ACONS> name trm assn"} |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
193 |
\end{tabular} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
194 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
195 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
196 |
\noindent |
1657 | 197 |
where @{text assn} is an auxiliary type representing a list of assignments |
198 |
and @{text bn} an auxiliary function identifying the variables to be bound |
|
1687 | 199 |
by the @{text "\<LET>"}. This function can be defined by recursion over @{text |
1657 | 200 |
assn} as follows |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
201 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
202 |
\begin{center} |
1657 | 203 |
@{text "bn(\<ANIL>) ="} @{term "{}"} \hspace{5mm} |
204 |
@{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
|
205 |
\end{center} |
1523
eb95360d6ac6
another little bit for the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1520
diff
changeset
|
206 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
207 |
\noindent |
1550 | 208 |
The scope of the binding is indicated by labels given to the types, for |
1657 | 209 |
example @{text "s::trm"}, and a binding clause, in this case |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
210 |
\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
211 |
clause states to bind in @{text s} all the names the function call @{text |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
212 |
"bn(as)"} returns. This style of specifying terms and bindings is heavily |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
213 |
inspired by the syntax of the Ott-tool \cite{ott-jfp}. |
1657 | 214 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
215 |
However, we will not be able to cope with all specifications that are |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
216 |
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
|
217 |
types like |
1570 | 218 |
|
219 |
\begin{center} |
|
1657 | 220 |
@{text "t ::= t t | \<lambda>x. t"} |
1570 | 221 |
\end{center} |
222 |
||
223 |
\noindent |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
224 |
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
|
225 |
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
|
226 |
at all in a HOL-based environment where every datatype must have a non-empty |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
227 |
set-theoretic model \cite{Berghofer99}. |
1570 | 228 |
|
229 |
Another reason is that we establish the reasoning infrastructure |
|
230 |
for alpha-\emph{equated} terms. In contrast, Ott produces a reasoning |
|
231 |
infrastructure in Isabelle/HOL for |
|
1545 | 232 |
\emph{non}-alpha-equated, or ``raw'', terms. While our alpha-equated terms |
1556 | 233 |
and the raw terms produced by Ott use names for bound variables, |
1690 | 234 |
there is a key difference: working with alpha-equated terms means, for example, |
1693 | 235 |
that the two type-schemes |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
236 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
237 |
\begin{center} |
1667 | 238 |
@{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
|
239 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
240 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
241 |
\noindent |
1703 | 242 |
are not just alpha-equal, but actually \emph{equal}! As a result, we can |
1657 | 243 |
only support specifications that make sense on the level of alpha-equated |
244 |
terms (offending specifications, which for example bind a variable according |
|
245 |
to a variable bound somewhere else, are not excluded by Ott, but we have |
|
1687 | 246 |
to). |
247 |
||
248 |
Our insistence on reasoning with alpha-equated terms comes from the |
|
1657 | 249 |
wealth of experience we gained with the older version of Nominal Isabelle: |
250 |
for non-trivial properties, reasoning about alpha-equated terms is much |
|
251 |
easier than reasoning with raw terms. The fundamental reason for this is |
|
252 |
that the HOL-logic underlying Nominal Isabelle allows us to replace |
|
253 |
``equals-by-equals''. In contrast, replacing |
|
254 |
``alpha-equals-by-alpha-equals'' in a representation based on raw terms |
|
255 |
requires a lot of extra reasoning work. |
|
1535
a37c65fe10de
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1528
diff
changeset
|
256 |
|
1657 | 257 |
Although in informal settings a reasoning infrastructure for alpha-equated |
258 |
terms is nearly always taken for granted, establishing it automatically in |
|
259 |
the Isabelle/HOL theorem prover is a rather non-trivial task. For every |
|
260 |
specification we will need to construct a type containing as elements the |
|
261 |
alpha-equated terms. To do so, we use the standard HOL-technique of defining |
|
262 |
a new type by identifying a non-empty subset of an existing type. The |
|
1667 | 263 |
construction we perform in Isabelle/HOL can be illustrated by the following picture: |
1657 | 264 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
265 |
\begin{center} |
1552 | 266 |
\begin{tikzpicture} |
267 |
%\draw[step=2mm] (-4,-1) grid (4,1); |
|
268 |
||
269 |
\draw[very thick] (0.7,0.4) circle (4.25mm); |
|
270 |
\draw[rounded corners=1mm, very thick] ( 0.0,-0.8) rectangle ( 1.8, 0.9); |
|
271 |
\draw[rounded corners=1mm, very thick] (-1.95,0.85) rectangle (-2.85,-0.05); |
|
272 |
||
273 |
\draw (-2.0, 0.845) -- (0.7,0.845); |
|
274 |
\draw (-2.0,-0.045) -- (0.7,-0.045); |
|
275 |
||
276 |
\draw ( 0.7, 0.4) node {\begin{tabular}{@ {}c@ {}}$\alpha$-\\[-1mm]clas.\end{tabular}}; |
|
277 |
\draw (-2.4, 0.4) node {\begin{tabular}{@ {}c@ {}}$\alpha$-eq.\\[-1mm]terms\end{tabular}}; |
|
278 |
\draw (1.8, 0.48) node[right=-0.1mm] |
|
279 |
{\begin{tabular}{@ {}l@ {}}existing\\[-1mm] type\\ (sets of raw terms)\end{tabular}}; |
|
280 |
\draw (0.9, -0.35) node {\begin{tabular}{@ {}l@ {}}non-empty\\[-1mm]subset\end{tabular}}; |
|
281 |
\draw (-3.25, 0.55) node {\begin{tabular}{@ {}l@ {}}new\\[-1mm]type\end{tabular}}; |
|
282 |
||
283 |
\draw[<->, very thick] (-1.8, 0.3) -- (-0.1,0.3); |
|
284 |
\draw (-0.95, 0.3) node[above=0mm] {isomorphism}; |
|
285 |
||
286 |
\end{tikzpicture} |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
287 |
\end{center} |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
288 |
|
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
289 |
\noindent |
1657 | 290 |
We take as the starting point a definition of raw terms (defined as a |
291 |
datatype in Isabelle/HOL); identify then the alpha-equivalence classes in |
|
292 |
the type of sets of raw terms according to our alpha-equivalence relation |
|
293 |
and finally define the new type as these alpha-equivalence classes |
|
294 |
(non-emptiness is satisfied whenever the raw terms are definable as datatype |
|
1690 | 295 |
in Isabelle/HOL and the property that our relation for alpha-equivalence is |
1657 | 296 |
indeed an equivalence relation). |
1556 | 297 |
|
1657 | 298 |
The fact that we obtain an isomorphism between the new type and the |
299 |
non-empty subset shows that the new type is a faithful representation of |
|
300 |
alpha-equated terms. That is not the case for example for terms using the |
|
301 |
locally nameless representation of binders \cite{McKinnaPollack99}: in this |
|
302 |
representation there are ``junk'' terms that need to be excluded by |
|
303 |
reasoning about a well-formedness predicate. |
|
1556 | 304 |
|
1657 | 305 |
The problem with introducing a new type in Isabelle/HOL is that in order to |
306 |
be useful, a reasoning infrastructure needs to be ``lifted'' from the |
|
307 |
underlying subset to the new type. This is usually a tricky and arduous |
|
308 |
task. To ease it, we re-implemented in Isabelle/HOL the quotient package |
|
309 |
described by Homeier \cite{Homeier05} for the HOL4 system. This package |
|
310 |
allows us to lift definitions and theorems involving raw terms to |
|
311 |
definitions and theorems involving alpha-equated terms. For example if we |
|
312 |
define the free-variable function over raw lambda-terms |
|
1577 | 313 |
|
314 |
\begin{center} |
|
1657 | 315 |
@{text "fv(x) = {x}"}\hspace{10mm} |
316 |
@{text "fv(t\<^isub>1 t\<^isub>2) = fv(t\<^isub>1) \<union> fv(t\<^isub>2)"}\\[1mm] |
|
317 |
@{text "fv(\<lambda>x.t) = fv(t) - {x}"} |
|
1577 | 318 |
\end{center} |
319 |
||
320 |
\noindent |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
321 |
then with the help of the quotient package we can obtain a function @{text "fv\<^sup>\<alpha>"} |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
322 |
operating on quotients, or alpha-equivalence classes of lambda-terms. This |
1628 | 323 |
lifted function is characterised by the equations |
1577 | 324 |
|
325 |
\begin{center} |
|
1657 | 326 |
@{text "fv\<^sup>\<alpha>(x) = {x}"}\hspace{10mm} |
327 |
@{text "fv\<^sup>\<alpha>(t\<^isub>1 t\<^isub>2) = fv\<^sup>\<alpha>(t\<^isub>1) \<union> fv\<^sup>\<alpha>(t\<^isub>2)"}\\[1mm] |
|
328 |
@{text "fv\<^sup>\<alpha>(\<lambda>x.t) = fv\<^sup>\<alpha>(t) - {x}"} |
|
1577 | 329 |
\end{center} |
330 |
||
331 |
\noindent |
|
332 |
(Note that this means also the term-constructors for variables, applications |
|
333 |
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
|
334 |
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
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
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
|
341 |
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
|
342 |
for alpha-equated terms. |
1667 | 343 |
|
344 |
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
|
345 |
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
|
346 |
known as Core-Haskell (see Figure~\ref{corehas}). This term language |
1711 | 347 |
involves patterns that have lists of type-, coercion- and term-variables, |
1703 | 348 |
all of which are bound in @{text "\<CASE>"}-expressions. One |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
349 |
difficulty is that we do not know in advance how many variables need to |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
350 |
be bound. Another is that each bound variable comes with a kind or type |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
351 |
annotation. Representing such binders with single binders and reasoning |
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
352 |
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
|
353 |
|
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
354 |
\noindent |
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
355 |
{\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
|
356 |
involving multiple binders are alpha-equivalent. These definitions are |
1607 | 357 |
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
|
358 |
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
|
359 |
terms, including properties about support, freshness and equality |
1607 | 360 |
conditions for alpha-equated terms. We are also able to derive, at the moment |
361 |
only manually, strong induction principles that |
|
362 |
have the variable convention already built in. |
|
1667 | 363 |
|
364 |
\begin{figure} |
|
1687 | 365 |
\begin{boxedminipage}{\linewidth} |
366 |
\begin{center} |
|
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
367 |
\begin{tabular}{r@ {\hspace{1mm}}r@ {\hspace{2mm}}l} |
1690 | 368 |
\multicolumn{3}{@ {}l}{Type Kinds}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
369 |
@{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\ |
1690 | 370 |
\multicolumn{3}{@ {}l}{Coercion Kinds}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
371 |
@{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\smallskip\\ |
1690 | 372 |
\multicolumn{3}{@ {}l}{Types}\\ |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
373 |
@{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"} |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
374 |
@{text "| \<forall>a:\<kappa>. \<sigma> | \<iota> \<Rightarrow> \<sigma>"}\smallskip\\ |
1690 | 375 |
\multicolumn{3}{@ {}l}{Coercion Types}\\ |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
376 |
@{text "\<gamma>"} & @{text "::="} & @{text "c | C | \<gamma>\<^isub>1 \<gamma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"} |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
377 |
@{text "| \<forall>c:\<iota>. \<gamma> | \<iota> \<Rightarrow> \<gamma> "}\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
378 |
& @{text "|"} & @{text "refl \<sigma> | sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2 | \<gamma> @ \<sigma> | left \<gamma> | right \<gamma>"}\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
379 |
& @{text "|"} & @{text "\<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 | rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\smallskip\\ |
1690 | 380 |
\multicolumn{3}{@ {}l}{Terms}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
381 |
@{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>c:\<iota>. e | e \<sigma> | e \<gamma>"}\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
382 |
& @{text "|"} & @{text "\<lambda>x:\<sigma>. e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2"}\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
383 |
& @{text "|"} & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\smallskip\\ |
1690 | 384 |
\multicolumn{3}{@ {}l}{Patterns}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
385 |
@{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "c:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\smallskip\\ |
1690 | 386 |
\multicolumn{3}{@ {}l}{Constants}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
387 |
& @{text C} & coercion constants\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
388 |
& @{text T} & value type constructors\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
389 |
& @{text "S\<^isub>n"} & n-ary type functions (which need to be fully applied)\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
390 |
& @{text K} & data constructors\smallskip\\ |
1690 | 391 |
\multicolumn{3}{@ {}l}{Variables}\\ |
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
392 |
& @{text a} & type variables\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
393 |
& @{text c} & coercion variables\\ |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
394 |
& @{text x} & term variables\\ |
1687 | 395 |
\end{tabular} |
396 |
\end{center} |
|
397 |
\end{boxedminipage} |
|
1699
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
398 |
\caption{The term-language of System @{text "F\<^isub>C"} |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
399 |
\cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this |
2dca07aca287
small changes in the core-haskell spec
Christian Urban <urbanc@in.tum.de>
parents:
1694
diff
changeset
|
400 |
version of the term-language we made a modification by separating the |
1711 | 401 |
grammars for type kinds and coercion kinds, as well as for types and coercion |
1702 | 402 |
types. For this paper the interesting term-constructor is @{text "\<CASE>"}, |
403 |
which binds multiple type-, coercion- and term-variables.\label{corehas}} |
|
1667 | 404 |
\end{figure} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
405 |
*} |
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
406 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
407 |
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
|
408 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
409 |
text {* |
1556 | 410 |
At its core, Nominal Isabelle is an adaption of the nominal logic work by |
411 |
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
|
412 |
\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
|
413 |
to aid the description of what follows. |
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
414 |
|
1711 | 415 |
Two central notions in the nominal logic work are sorted atoms and |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
416 |
sort-respecting permutations of atoms. We will use the letters @{text "a, |
1711 | 417 |
b, c, \<dots>"} to stand for atoms and @{text "p, q, \<dots>"} to stand for |
418 |
permutations. The sorts of atoms can be used to represent different kinds of |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
419 |
variables, such as the term-, coercion- and type-variables in Core-Haskell. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
420 |
It is assumed that there is an infinite supply of atoms for each |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
421 |
sort. However, in order to simplify the description, we shall restrict ourselves |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
422 |
in what follows to only one sort of atoms. |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
423 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
424 |
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
|
425 |
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
|
426 |
two-place permutation operation written |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
427 |
% |
1703 | 428 |
\begin{center} |
429 |
@{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"} |
|
430 |
\end{center} |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
431 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
432 |
\noindent |
1628 | 433 |
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
|
434 |
over which the permutation |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
435 |
acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"}, |
1690 | 436 |
the composition of two permutations @{term p} and @{term q} as \mbox{@{term "p + q"}}, |
1570 | 437 |
and the inverse permutation of @{term p} as @{text "- p"}. The permutation |
1703 | 438 |
operation is defined by induction over the type-hierarchy (see \cite{HuffmanUrban10}); |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
439 |
for example permutations acting on products, lists, sets, functions and booleans is |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
440 |
given by: |
1702 | 441 |
% |
1703 | 442 |
\begin{equation}\label{permute} |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
443 |
\mbox{\begin{tabular}{@ {}cc@ {}} |
1690 | 444 |
\begin{tabular}{@ {}l@ {}} |
445 |
@{thm permute_prod.simps[no_vars, THEN eq_reflection]}\\[2mm] |
|
446 |
@{thm permute_list.simps(1)[no_vars, THEN eq_reflection]}\\ |
|
447 |
@{thm permute_list.simps(2)[no_vars, THEN eq_reflection]}\\ |
|
448 |
\end{tabular} & |
|
449 |
\begin{tabular}{@ {}l@ {}} |
|
450 |
@{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
|
451 |
@{text "p \<bullet> f \<equiv> \<lambda>x. p \<bullet> (f (- p \<bullet> x))"}\\ |
1690 | 452 |
@{thm permute_bool_def[no_vars, THEN eq_reflection]}\\ |
453 |
\end{tabular} |
|
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
454 |
\end{tabular}} |
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
455 |
\end{equation} |
1690 | 456 |
|
457 |
\noindent |
|
1703 | 458 |
Concrete permutations are built up from swappings, written as \mbox{@{text "(a |
459 |
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
|
460 |
% |
1703 | 461 |
\begin{center} |
462 |
@{text "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"} |
|
463 |
\end{center} |
|
464 |
||
1570 | 465 |
The most original aspect of the nominal logic work of Pitts is a general |
1703 | 466 |
definition for the notion of the ``set of free variables of an object @{text |
1570 | 467 |
"x"}''. This notion, written @{term "supp x"}, is general in the sense that |
1628 | 468 |
it applies not only to lambda-terms (alpha-equated or not), but also to lists, |
1570 | 469 |
products, sets and even functions. The definition depends only on the |
470 |
permutation operation and on the notion of equality defined for the type of |
|
471 |
@{text x}, namely: |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
472 |
% |
1703 | 473 |
\begin{equation}\label{suppdef} |
474 |
@{thm supp_def[no_vars, THEN eq_reflection]} |
|
475 |
\end{equation} |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
476 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
477 |
\noindent |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
478 |
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
|
479 |
for an @{text x}, defined as |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
480 |
% |
1703 | 481 |
\begin{center} |
482 |
@{thm fresh_def[no_vars]} |
|
483 |
\end{center} |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
484 |
|
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
485 |
\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
|
486 |
We also use for sets of atoms the abbreviation |
1703 | 487 |
@{thm (lhs) fresh_star_def[no_vars]}, defined as |
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
|
488 |
@{thm (rhs) fresh_star_def[no_vars]}. |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
@{text x} unchanged. |
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
493 |
|
1711 | 494 |
\begin{property}\label{swapfreshfresh} |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
495 |
@{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
|
496 |
\end{property} |
1506
7c607df46a0a
slightly more in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1493
diff
changeset
|
497 |
|
1711 | 498 |
While often the support of an object can be relatively easily |
499 |
described, for example\\[-6mm] |
|
1690 | 500 |
% |
501 |
\begin{eqnarray} |
|
1703 | 502 |
@{term "supp a"} & = & @{term "{a}"}\\ |
1690 | 503 |
@{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\ |
504 |
@{term "supp []"} & = & @{term "{}"}\\ |
|
1711 | 505 |
@{term "supp (x#xs)"} & = & @{term "supp x \<union> supp xs"}\\ |
1703 | 506 |
@{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp (f, x)"}\label{suppfun}\\ |
507 |
@{term "supp b"} & = & @{term "{}"}\\ |
|
508 |
@{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"} |
|
1690 | 509 |
\end{eqnarray} |
510 |
||
511 |
\noindent |
|
1703 | 512 |
in some cases it can be difficult to establish the support precisely, and |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
513 |
only give an approximation (see \eqref{suppfun} above). Reasoning about |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
514 |
such approximations can be made precise with the notion \emph{supports}, defined |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
515 |
as follows: |
1693 | 516 |
|
517 |
\begin{defn} |
|
518 |
A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
|
519 |
not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
|
520 |
\end{defn} |
|
1690 | 521 |
|
1693 | 522 |
\noindent |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
523 |
The main point of @{text supports} is that we can establish the following |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
524 |
two properties. |
1693 | 525 |
|
1703 | 526 |
\begin{property}\label{supportsprop} |
527 |
{\it i)} @{thm[mode=IfThen] supp_is_subset[no_vars]}\\ |
|
1693 | 528 |
{\it ii)} @{thm supp_supports[no_vars]}. |
529 |
\end{property} |
|
530 |
||
531 |
Another important notion in the nominal logic work is \emph{equivariance}. |
|
1703 | 532 |
For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
533 |
it is required that every permutation leaves @{text f} unchanged, that is |
1711 | 534 |
% |
535 |
\begin{equation}\label{equivariancedef} |
|
536 |
@{term "\<forall>p. p \<bullet> f = f"} |
|
537 |
\end{equation} |
|
538 |
||
539 |
\noindent or equivalently that a permutation applied to the application |
|
540 |
@{text "f x"} can be moved to the argument @{text x}. That means we have for |
|
541 |
all permutations @{text p} |
|
1703 | 542 |
% |
543 |
\begin{equation}\label{equivariance} |
|
1711 | 544 |
@{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\; |
545 |
@{text "p \<bullet> (f x) = f (p \<bullet> x)"} |
|
1703 | 546 |
\end{equation} |
1694
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
547 |
|
3bf0fddb7d44
clarified core-haskell example
Christian Urban <urbanc@in.tum.de>
parents:
1693
diff
changeset
|
548 |
\noindent |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
549 |
From property \eqref{equivariancedef} and the definition of @{text supp}, we |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
550 |
can be easily deduce that an equivariant function has empty support. |
1711 | 551 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
552 |
Finally, the nominal logic work provides us with convenient means to rename |
1711 | 553 |
binders. While in the older version of Nominal Isabelle, we used extensively |
554 |
Property~\ref{swapfreshfresh} for renaming single binders, this property |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
555 |
proved unwieldy for dealing with multiple binders. For such pinders the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
556 |
following generalisations turned out to be easier to use. |
1711 | 557 |
|
558 |
\begin{property}\label{supppermeq} |
|
559 |
@{thm[mode=IfThen] supp_perm_eq[no_vars]} |
|
560 |
\end{property} |
|
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
|
561 |
|
1711 | 562 |
\begin{property} |
1716 | 563 |
For a finite set @{text as} and a finitely supported @{text x} with |
564 |
@{term "as \<sharp>* x"} and also a finitely supported @{text c}, there |
|
565 |
exists a permutation @{text p} such that @{term "(p \<bullet> as) \<sharp>* c"} and |
|
1711 | 566 |
@{term "supp x \<sharp>* p"}. |
567 |
\end{property} |
|
568 |
||
569 |
\noindent |
|
1716 | 570 |
The idea behind the second property is that given a finite set @{text as} |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
571 |
of binders (being bound, or fresh, in @{text x} is ensured by the |
1716 | 572 |
assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text p} such that |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
573 |
the renamed binders @{term "p \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
574 |
as long as it is finitely supported) and also it does not affect anything |
1711 | 575 |
in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last |
576 |
fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
577 |
@{text as} in @{text x}, because @{term "p \<bullet> x = x"}. |
1711 | 578 |
|
579 |
All properties given in this section are formalised in Isabelle/HOL and also |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
580 |
most of proofs are described in \cite{HuffmanUrban10} to which we refer the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
581 |
reader. In the next sections we will make extensively use of these |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
582 |
properties in order to define alpha-equivalence in the presence of multiple |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
583 |
binders. |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
584 |
*} |
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
585 |
|
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
586 |
|
1620 | 587 |
section {* General Binders\label{sec:binders} *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
588 |
|
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
|
589 |
text {* |
1587 | 590 |
In Nominal Isabelle, the user is expected to write down a specification of a |
591 |
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
|
592 |
from this specification (remember that Nominal Isabelle is a definitional |
1587 | 593 |
extension of Isabelle/HOL, which does not introduce any new axioms). |
1579 | 594 |
|
1657 | 595 |
In order to keep our work with deriving the reasoning infrastructure |
596 |
manageable, we will wherever possible state definitions and perform proofs |
|
597 |
on the user-level of Isabelle/HOL, as opposed to write custom ML-code that |
|
598 |
generates them anew for each specification. To that end, we will consider |
|
599 |
first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}. These pairs |
|
600 |
are intended to represent the abstraction, or binding, of the set @{text |
|
601 |
"as"} in the body @{text "x"}. |
|
1570 | 602 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
603 |
The first question we have to answer is when two pairs @{text "(as, x)"} and |
1657 | 604 |
@{text "(bs, y)"} are alpha-equivalent? (At the moment we are interested in |
605 |
the notion of alpha-equivalence that is \emph{not} preserved by adding |
|
606 |
vacuous binders.) To answer this, we identify four conditions: {\it i)} |
|
607 |
given a free-variable function @{text "fv"} of type \mbox{@{text "\<beta> \<Rightarrow> atom |
|
608 |
set"}}, then @{text x} and @{text y} need to have the same set of free |
|
609 |
variables; moreover there must be a permutation @{text p} such that {\it |
|
1687 | 610 |
ii)} @{text p} leaves the free variables of @{text x} and @{text y} unchanged, but |
1657 | 611 |
{\it iii)} ``moves'' their bound names so that we obtain modulo a relation, |
1662 | 612 |
say \mbox{@{text "_ R _"}}, two equivalent terms. We also require {\it iv)} that |
613 |
@{text p} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The |
|
1657 | 614 |
requirements {\it i)} to {\it iv)} can be stated formally as follows: |
1556 | 615 |
% |
1572 | 616 |
\begin{equation}\label{alphaset} |
617 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
|
1687 | 618 |
\multicolumn{2}{l}{@{term "(as, x) \<approx>gen R fv p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}\hspace{30mm}}\\[1mm] |
1657 | 619 |
& @{term "fv(x) - as = fv(y) - bs"}\\ |
620 |
@{text "\<and>"} & @{term "(fv(x) - as) \<sharp>* p"}\\ |
|
621 |
@{text "\<and>"} & @{text "(p \<bullet> x) R y"}\\ |
|
622 |
@{text "\<and>"} & @{term "(p \<bullet> as) = bs"}\\ |
|
1572 | 623 |
\end{array} |
1556 | 624 |
\end{equation} |
625 |
||
626 |
\noindent |
|
1657 | 627 |
Note that this relation is dependent on the permutation @{text |
628 |
"p"}. Alpha-equivalence between two pairs is then the relation where we |
|
629 |
existentially quantify over this @{text "p"}. Also note that the relation is |
|
630 |
dependent on a free-variable function @{text "fv"} and a relation @{text |
|
631 |
"R"}. The reason for this extra generality is that we will use |
|
632 |
$\approx_{\textit{set}}$ for both ``raw'' terms and alpha-equated terms. In |
|
1716 | 633 |
the latter case, $R$ will be replaced by equality @{text "="} and we |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
634 |
will prove that @{text "fv"} is equal to @{text "supp"}. |
1572 | 635 |
|
636 |
The definition in \eqref{alphaset} does not make any distinction between the |
|
1579 | 637 |
order of abstracted variables. If we want this, then we can define alpha-equivalence |
638 |
for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"} |
|
639 |
as follows |
|
1572 | 640 |
% |
641 |
\begin{equation}\label{alphalist} |
|
642 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
|
1687 | 643 |
\multicolumn{2}{l}{@{term "(as, x) \<approx>lst R fv p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}\hspace{30mm}}\\[1mm] |
1657 | 644 |
& @{term "fv(x) - (set as) = fv(y) - (set bs)"}\\ |
645 |
\wedge & @{term "(fv(x) - set as) \<sharp>* p"}\\ |
|
1572 | 646 |
\wedge & @{text "(p \<bullet> x) R y"}\\ |
1657 | 647 |
\wedge & @{term "(p \<bullet> as) = bs"}\\ |
1572 | 648 |
\end{array} |
649 |
\end{equation} |
|
650 |
||
651 |
\noindent |
|
1657 | 652 |
where @{term set} is a function that coerces a list of atoms into a set of atoms. |
653 |
Now the last clause ensures that the order of the binders matters. |
|
1556 | 654 |
|
1657 | 655 |
If we do not want to make any difference between the order of binders \emph{and} |
1579 | 656 |
also allow vacuous binders, then we keep sets of binders, but drop the fourth |
657 |
condition in \eqref{alphaset}: |
|
1572 | 658 |
% |
1579 | 659 |
\begin{equation}\label{alphares} |
1572 | 660 |
\begin{array}{@ {\hspace{10mm}}r@ {\hspace{2mm}}l} |
1687 | 661 |
\multicolumn{2}{l}{@{term "(as, x) \<approx>res R fv p (bs, y)"}\hspace{2mm}@{text "\<equiv>"}\hspace{30mm}}\\[1mm] |
1657 | 662 |
& @{term "fv(x) - as = fv(y) - bs"}\\ |
663 |
\wedge & @{term "(fv(x) - as) \<sharp>* p"}\\ |
|
1572 | 664 |
\wedge & @{text "(p \<bullet> x) R y"}\\ |
665 |
\end{array} |
|
666 |
\end{equation} |
|
1556 | 667 |
|
1662 | 668 |
It might be useful to consider some examples for how these definitions of alpha-equivalence |
669 |
pan out in practise. |
|
1579 | 670 |
For this consider the case of abstracting a set of variables over types (as in type-schemes). |
1657 | 671 |
We set @{text R} to be the equality and for @{text "fv(T)"} we define |
1572 | 672 |
|
673 |
\begin{center} |
|
1657 | 674 |
@{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 | 675 |
\end{center} |
676 |
||
677 |
\noindent |
|
1657 | 678 |
Now recall the examples shown in \eqref{ex1}, \eqref{ex2} and |
1687 | 679 |
\eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
680 |
@{text "({y, x}, y \<rightarrow> x)"} are alpha-equivalent according to $\approx_{\textit{set}}$ and |
1657 | 681 |
$\approx_{\textit{res}}$ by taking @{text p} to be the swapping @{term "(x \<rightleftharpoons> |
682 |
y)"}. In case of @{text "x \<noteq> y"}, then @{text "([x, y], x \<rightarrow> y)"} |
|
1687 | 683 |
$\not\approx_{\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"} since there is no permutation |
1657 | 684 |
that makes the lists @{text "[x, y]"} and @{text "[y, x]"} equal, and also |
685 |
leaves the type \mbox{@{text "x \<rightarrow> y"}} unchanged. Another example is |
|
1687 | 686 |
@{text "({x}, x)"} $\approx_{\textit{res}}$ @{text "({x, y}, x)"} which holds by |
1657 | 687 |
taking @{text p} to be the |
688 |
identity permutation. However, if @{text "x \<noteq> y"}, then @{text "({x}, x)"} |
|
1687 | 689 |
$\not\approx_{\textit{set}}$ @{text "({x, y}, x)"} since there is no permutation |
1657 | 690 |
that makes the |
1687 | 691 |
sets @{text "{x}"} and @{text "{x, y}"} equal (similarly for $\approx_{\textit{list}}$). |
692 |
It can also relatively easily be shown that all tree notions of alpha-equivalence |
|
693 |
coincide, if we only abstract a single atom. |
|
1579 | 694 |
|
1657 | 695 |
% looks too ugly |
696 |
%\noindent |
|
697 |
%Let $\star$ range over $\{set, res, list\}$. We prove next under which |
|
698 |
%conditions the $\approx\hspace{0.05mm}_\star^{\fv, R, p}$ are equivalence |
|
699 |
%relations and equivariant: |
|
700 |
% |
|
701 |
%\begin{lemma} |
|
702 |
%{\it i)} Given the fact that $x\;R\;x$ holds, then |
|
703 |
%$(as, x) \approx\hspace{0.05mm}^{\fv, R, 0}_\star (as, x)$. {\it ii)} Given |
|
704 |
%that @{text "(p \<bullet> x) R y"} implies @{text "(-p \<bullet> y) R x"}, then |
|
705 |
%$(as, x) \approx\hspace{0.05mm}^{\fv, R, p}_\star (bs, y)$ implies |
|
706 |
%$(bs, y) \approx\hspace{0.05mm}^{\fv, R, - p}_\star (as, x)$. {\it iii)} Given |
|
707 |
%that @{text "(p \<bullet> x) R y"} and @{text "(q \<bullet> y) R z"} implies |
|
708 |
%@{text "((q + p) \<bullet> x) R z"}, then $(as, x) \approx\hspace{0.05mm}^{\fv, R, p}_\star (bs, y)$ |
|
709 |
%and $(bs, y) \approx\hspace{0.05mm}^{\fv, R, q}_\star (cs, z)$ implies |
|
710 |
%$(as, x) \approx\hspace{0.05mm}^{\fv, R, q + p}_\star (cs, z)$. Given |
|
711 |
%@{text "(q \<bullet> x) R y"} implies @{text "(p \<bullet> (q \<bullet> x)) R (p \<bullet> y)"} and |
|
712 |
%@{text "p \<bullet> (fv x) = fv (p \<bullet> x)"} then @{text "p \<bullet> (fv y) = fv (p \<bullet> y)"}, then |
|
713 |
%$(as, x) \approx\hspace{0.05mm}^{\fv, R, q}_\star (bs, y)$ implies |
|
714 |
%$(p \;\isasymbullet\; as, p \;\isasymbullet\; x) \approx\hspace{0.05mm}^{\fv, R, q}_\star |
|
715 |
%(p \;\isasymbullet\; bs, p \;\isasymbullet\; y)$. |
|
716 |
%\end{lemma} |
|
717 |
||
718 |
%\begin{proof} |
|
719 |
%All properties are by unfolding the definitions and simple calculations. |
|
720 |
%\end{proof} |
|
721 |
||
722 |
||
1687 | 723 |
In the rest of this section we are going to introduce a type- and term-constructors |
724 |
for abstraction. For this we define |
|
1657 | 725 |
% |
726 |
\begin{equation} |
|
727 |
@{term "abs_set (as, x) (bs, x) \<equiv> \<exists>p. alpha_gen (as, x) equal supp p (bs, x)"} |
|
728 |
\end{equation} |
|
729 |
||
1579 | 730 |
\noindent |
1687 | 731 |
(similarly for $\approx_{\textit{abs\_list}}$ |
732 |
and $\approx_{\textit{abs\_res}}$). We can show that these relations are equivalence |
|
733 |
relations and equivariant. |
|
1579 | 734 |
|
1687 | 735 |
\begin{lemma}\label{alphaeq} The relations |
736 |
$\approx_{\textit{abs\_set}}$, |
|
737 |
$\approx_{\textit{abs\_list}}$ |
|
738 |
and $\approx_{\textit{abs\_res}}$ |
|
739 |
are equivalence |
|
1662 | 740 |
relations, and if @{term "abs_set (as, x) (bs, y)"} then also |
1687 | 741 |
@{term "abs_set (p \<bullet> as, p \<bullet> x) (p \<bullet> bs, p \<bullet> y)"} (similarly for |
742 |
the other two relations). |
|
1657 | 743 |
\end{lemma} |
744 |
||
745 |
\begin{proof} |
|
746 |
Reflexivity is by taking @{text "p"} to be @{text "0"}. For symmetry we have |
|
747 |
a permutation @{text p} and for the proof obligation take @{term "-p"}. In case |
|
1662 | 748 |
of transitivity, we have two permutations @{text p} and @{text q}, and for the |
749 |
proof obligation use @{text "q + p"}. All conditions are then by simple |
|
1657 | 750 |
calculations. |
751 |
\end{proof} |
|
752 |
||
753 |
\noindent |
|
1687 | 754 |
This lemma allows us to use our quotient package and introduce |
1662 | 755 |
new types @{text "\<beta> abs_set"}, @{text "\<beta> abs_res"} and @{text "\<beta> abs_list"} |
1687 | 756 |
representing alpha-equivalence classes of pairs. The elements in these types |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
757 |
will be, respectively, written as: |
1657 | 758 |
|
759 |
\begin{center} |
|
760 |
@{term "Abs as x"} \hspace{5mm} |
|
761 |
@{term "Abs_lst as x"} \hspace{5mm} |
|
762 |
@{term "Abs_res as x"} |
|
763 |
\end{center} |
|
764 |
||
1662 | 765 |
\noindent |
1716 | 766 |
indicating that a set or list @{text as} is abstracted in @{text x}. We will |
767 |
call the types \emph{abstraction types} and their elements |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
768 |
\emph{abstractions}. The important property we need to know is what the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
769 |
support of abstractions is, namely: |
1662 | 770 |
|
1687 | 771 |
\begin{thm}[Support of Abstractions]\label{suppabs} |
1703 | 772 |
Assuming @{text x} has finite support, then\\[-6mm] |
1662 | 773 |
\begin{center} |
1687 | 774 |
\begin{tabular}{l@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
775 |
@{thm (lhs) supp_abs(1)[no_vars]} & $=$ & @{thm (rhs) supp_abs(1)[no_vars]}\\ |
|
776 |
@{thm (lhs) supp_abs(2)[no_vars]} & $=$ & @{thm (rhs) supp_abs(2)[no_vars]}\\ |
|
1716 | 777 |
@{thm (lhs) supp_abs(3)[where bs="as", no_vars]} & $=$ & @{thm (rhs) supp_abs(3)[where bs="as", no_vars]} |
1687 | 778 |
\end{tabular} |
1662 | 779 |
\end{center} |
1687 | 780 |
\end{thm} |
1662 | 781 |
|
782 |
\noindent |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
783 |
Below we will show the first equation. The others |
1687 | 784 |
follow similar arguments. By definition of the abstraction type @{text "abs_set"} |
785 |
we have |
|
786 |
% |
|
787 |
\begin{equation}\label{abseqiff} |
|
1703 | 788 |
@{thm (lhs) abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} \;\;\text{if and only if}\;\; |
1687 | 789 |
@{thm (rhs) abs_eq_iff(1)[where bs="as" and cs="bs", no_vars]} |
790 |
\end{equation} |
|
791 |
||
792 |
\noindent |
|
1703 | 793 |
and also |
794 |
% |
|
795 |
\begin{equation} |
|
796 |
@{thm permute_Abs[no_vars]} |
|
797 |
\end{equation} |
|
1662 | 798 |
|
1703 | 799 |
\noindent |
1716 | 800 |
The second fact derives from the definition of permutations acting on pairs |
801 |
(see \eqref{permute}) and alpha-equivalence being equivariant |
|
802 |
(see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show |
|
803 |
the following lemma about swapping two atoms. |
|
1703 | 804 |
|
1662 | 805 |
\begin{lemma} |
1716 | 806 |
@{thm[mode=IfThen] abs_swap1(1)[where bs="as", no_vars]} |
1662 | 807 |
\end{lemma} |
808 |
||
809 |
\begin{proof} |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
810 |
This lemma is straightforward by using \eqref{abseqiff} and observing that |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
811 |
the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) = (supp x - as)"}. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
812 |
Moreover @{text supp} and set difference are equivariant \cite{HuffmanUrban10}. |
1662 | 813 |
\end{proof} |
1587 | 814 |
|
1687 | 815 |
\noindent |
1716 | 816 |
This lemma allows us to show |
1687 | 817 |
% |
818 |
\begin{equation}\label{halfone} |
|
819 |
@{thm abs_supports(1)[no_vars]} |
|
820 |
\end{equation} |
|
821 |
||
822 |
\noindent |
|
1716 | 823 |
which by Property~\ref{supportsprop} gives us ``one half'' of |
824 |
Thm~\ref{suppabs}. The ``other half'' is a bit more involved. To establish |
|
825 |
it, we use a trick from \cite{Pitts04} and first define an auxiliary |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
826 |
function taking an abstraction as argument: |
1687 | 827 |
% |
828 |
\begin{center} |
|
1703 | 829 |
@{thm supp_gen.simps[THEN eq_reflection, no_vars]} |
1687 | 830 |
\end{center} |
831 |
||
1703 | 832 |
\noindent |
833 |
Using the second equation in \eqref{equivariance}, we can show that |
|
1716 | 834 |
@{text "aux"} is equivariant (since @{term "p \<bullet> (supp x - as) = |
835 |
(supp (p \<bullet> x)) - (p \<bullet> as)"}) and therefore has empty support. |
|
836 |
This in turn means |
|
1703 | 837 |
% |
838 |
\begin{center} |
|
1716 | 839 |
@{term "supp (supp_gen (Abs as x)) \<subseteq> supp (Abs as x)"} |
1703 | 840 |
\end{center} |
1687 | 841 |
|
842 |
\noindent |
|
1716 | 843 |
using \eqref{suppfun}. Assuming @{term "supp x - as"} is a finite set |
844 |
we further obtain |
|
1703 | 845 |
% |
846 |
\begin{equation}\label{halftwo} |
|
847 |
@{thm (concl) supp_abs_subset1(1)[no_vars]} |
|
848 |
\end{equation} |
|
849 |
||
850 |
\noindent |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
851 |
since for finite sets, @{text "S"}, we have @{thm (concl) supp_finite_atom_set[no_vars]}. |
1703 | 852 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
853 |
Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes of |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
854 |
Theorem~\ref{suppabs}. This theorem gives us confidence that our |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
855 |
abstractions behave as one expects. To consider first abstractions of the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
856 |
form @{term "Abs as x"} is motivated by the fact that properties about them |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
857 |
can be conveninetly established at the Isabelle/HOL level. But we can also |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
858 |
use when we deal with binding in our term-calculi specifications. |
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
|
859 |
*} |
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
|
860 |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
861 |
section {* Alpha-Equivalence and Free Variables\label{sec:alpha} *} |
1491
f970ca9b5bec
paper uses now a heap file - does not compile so long anymore
Christian Urban <urbanc@in.tum.de>
parents:
1485
diff
changeset
|
862 |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
863 |
text {* |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
864 |
Our choice of syntax for specifications is influenced by the existing |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
865 |
datatype package of Isabelle/HOL \cite{Berghofer99} and by the syntax of the Ott-tool |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
866 |
\cite{ott-jfp}. For us a specification of a term-calculus is a collection of (possibly mutual |
1637 | 867 |
recursive) type declarations, say @{text "ty"}$^\alpha_1$, \ldots, |
868 |
@{text ty}$^\alpha_n$, and an associated collection |
|
869 |
of binding functions, say @{text bn}$^\alpha_1$, \ldots, @{text |
|
870 |
bn}$^\alpha_m$. The syntax in Nominal Isabelle for such specifications is |
|
1693 | 871 |
roughly as follows: |
1628 | 872 |
% |
1619 | 873 |
\begin{equation}\label{scheme} |
1636 | 874 |
\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
|
875 |
type \mbox{declaration part} & |
1611 | 876 |
$\begin{cases} |
877 |
\mbox{\begin{tabular}{l} |
|
1637 | 878 |
\isacommand{nominal\_datatype} @{text ty}$^\alpha_1 = \ldots$\\ |
879 |
\isacommand{and} @{text ty}$^\alpha_2 = \ldots$\\ |
|
1587 | 880 |
$\ldots$\\ |
1637 | 881 |
\isacommand{and} @{text ty}$^\alpha_n = \ldots$\\ |
1611 | 882 |
\end{tabular}} |
883 |
\end{cases}$\\ |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
884 |
binding \mbox{function part} & |
1611 | 885 |
$\begin{cases} |
886 |
\mbox{\begin{tabular}{l} |
|
1637 | 887 |
\isacommand{with} @{text bn}$^\alpha_1$ \isacommand{and} \ldots \isacommand{and} @{text bn}$^\alpha_m$\\ |
1611 | 888 |
\isacommand{where}\\ |
1587 | 889 |
$\ldots$\\ |
1611 | 890 |
\end{tabular}} |
891 |
\end{cases}$\\ |
|
1619 | 892 |
\end{tabular}} |
893 |
\end{equation} |
|
1587 | 894 |
|
895 |
\noindent |
|
1637 | 896 |
Every type declaration @{text ty}$^\alpha_{1..n}$ consists of a collection of |
1611 | 897 |
term-constructors, each of which comes with a list of labelled |
1620 | 898 |
types that stand for the types of the arguments of the term-constructor. |
1637 | 899 |
For example a term-constructor @{text "C\<^sup>\<alpha>"} might have |
1611 | 900 |
|
901 |
\begin{center} |
|
1637 | 902 |
@{text "C\<^sup>\<alpha> label\<^isub>1::ty"}$'_1$ @{text "\<dots> label\<^isub>l::ty"}$'_l\;\;$ @{text "binding_clauses"} |
1611 | 903 |
\end{center} |
1587 | 904 |
|
1611 | 905 |
\noindent |
1637 | 906 |
whereby some of the @{text ty}$'_{1..l}$ (or their components) are contained in the collection |
907 |
of @{text ty}$^\alpha_{1..n}$ declared in \eqref{scheme}. In this case we will call the |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
908 |
corresponding argument a \emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The labels annotated on |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
909 |
the types are optional. Their purpose is to be used in the (possibly empty) list of |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
910 |
\emph{binding clauses}, which indicate the binders and their scope |
1637 | 911 |
in a term-constructor. They come in three \emph{modes}: |
1636 | 912 |
|
1587 | 913 |
|
1611 | 914 |
\begin{center} |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
915 |
\begin{tabular}{l} |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
916 |
\isacommand{bind}\; {\it binders}\; \isacommand{in}\; {\it label}\\ |
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
917 |
\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
|
918 |
\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
|
919 |
\end{tabular} |
1611 | 920 |
\end{center} |
921 |
||
922 |
\noindent |
|
1636 | 923 |
The first mode is for binding lists of atoms (the order of binders matters); the second is for sets |
1637 | 924 |
of binders (the order does not matter, but the cardinality does) and the last is for |
1620 | 925 |
sets of binders (with vacuous binders preserving alpha-equivalence). |
926 |
||
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
927 |
In addition we distinguish between \emph{shallow} and \emph{deep} |
1620 | 928 |
binders. Shallow binders are of the form \isacommand{bind}\; {\it label}\; |
1637 | 929 |
\isacommand{in}\; {\it label'} (similar for the other two modes). The |
1620 | 930 |
restriction we impose on shallow binders is that the {\it label} must either |
931 |
refer to a type that is an atom type or to a type that is a finite set or |
|
1637 | 932 |
list of an atom type. Two examples for the use of shallow binders are the |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
933 |
specification of lambda-terms, where a single name is bound, and |
1637 | 934 |
type-schemes, where a finite set of names is bound: |
1611 | 935 |
|
936 |
\begin{center} |
|
1612 | 937 |
\begin{tabular}{@ {}cc@ {}} |
938 |
\begin{tabular}{@ {}l@ {\hspace{-1mm}}} |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
939 |
\isacommand{nominal\_datatype} @{text lam} =\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
940 |
\hspace{5mm}\phantom{$\mid$}~@{text "Var name"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
941 |
\hspace{5mm}$\mid$~@{text "App lam lam"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
942 |
\hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
943 |
\hspace{21mm}\isacommand{bind} @{text x} \isacommand{in} @{text t}\\ |
1611 | 944 |
\end{tabular} & |
1612 | 945 |
\begin{tabular}{@ {}l@ {}} |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
946 |
\isacommand{nominal\_datatype}~@{text ty} =\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
947 |
\hspace{5mm}\phantom{$\mid$}~@{text "TVar name"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
948 |
\hspace{5mm}$\mid$~@{text "TFun ty ty"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
949 |
\isacommand{and}~@{text "tsc = All xs::(name fset) T::ty"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
950 |
\hspace{24mm}\isacommand{bind\_res} @{text xs} \isacommand{in} @{text T}\\ |
1611 | 951 |
\end{tabular} |
952 |
\end{tabular} |
|
953 |
\end{center} |
|
1587 | 954 |
|
1612 | 955 |
\noindent |
1637 | 956 |
Note that in this specification \emph{name} refers to an atom type. |
1628 | 957 |
If we have shallow binders that ``share'' a body, for instance $t$ in |
1637 | 958 |
the following term-constructor |
1620 | 959 |
|
960 |
\begin{center} |
|
961 |
\begin{tabular}{ll} |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
962 |
@{text "Foo x::name y::name t::lam"} & |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
963 |
\isacommand{bind} @{text x} \isacommand{in} @{text t},\; |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
964 |
\isacommand{bind} @{text y} \isacommand{in} @{text t} |
1620 | 965 |
\end{tabular} |
966 |
\end{center} |
|
967 |
||
968 |
\noindent |
|
1628 | 969 |
then we have to make sure the modes of the binders agree. We cannot |
1637 | 970 |
have, for instance, in the first binding clause the mode \isacommand{bind} |
971 |
and in the second \isacommand{bind\_set}. |
|
1620 | 972 |
|
973 |
A \emph{deep} binder uses an auxiliary binding function that ``picks'' out |
|
1636 | 974 |
the atoms in one argument of the term-constructor, which can be bound in |
1628 | 975 |
other arguments and also in the same argument (we will |
1637 | 976 |
call such binders \emph{recursive}, see below). |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
977 |
The corresponding binding functions are expected to return either a set of atoms |
1620 | 978 |
(for \isacommand{bind\_set} and \isacommand{bind\_res}) or a list of atoms |
979 |
(for \isacommand{bind}). They can be defined by primitive recursion over the |
|
980 |
corresponding type; the equations must be given in the binding function part of |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
981 |
the scheme shown in \eqref{scheme}. For example a term-calculus containing lets |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
982 |
with tuple patterns might be specified as: |
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
983 |
|
1619 | 984 |
\begin{center} |
985 |
\begin{tabular}{l} |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
986 |
\isacommand{nominal\_datatype} @{text trm} =\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
987 |
\hspace{5mm}\phantom{$\mid$}~@{term "Var name"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
988 |
\hspace{5mm}$\mid$~@{term "App trm trm"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
989 |
\hspace{5mm}$\mid$~@{text "Lam x::name t::trm"} |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
990 |
\;\;\isacommand{bind} @{text x} \isacommand{in} @{text t}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
991 |
\hspace{5mm}$\mid$~@{text "Let p::pat trm t::trm"} |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
992 |
\;\;\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
993 |
\isacommand{and} @{text pat} =\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
994 |
\hspace{5mm}\phantom{$\mid$}~@{text PNil}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
995 |
\hspace{5mm}$\mid$~@{text "PVar name"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
996 |
\hspace{5mm}$\mid$~@{text "PTup pat pat"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
997 |
\isacommand{with}~@{text "bn::pat \<Rightarrow> atom list"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
998 |
\isacommand{where}~@{text "bn(PNil) = []"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
999 |
\hspace{5mm}$\mid$~@{text "bn(PVar x) = [atom x]"}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1000 |
\hspace{5mm}$\mid$~@{text "bn(PTup p\<^isub>1 p\<^isub>2) = bn(p\<^isub>1) @ bn(p\<^isub>2)"}\\ |
1619 | 1001 |
\end{tabular} |
1002 |
\end{center} |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
1003 |
|
1619 | 1004 |
\noindent |
1637 | 1005 |
In this specification the function @{text "bn"} determines which atoms of @{text p} are |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1006 |
bound in the argument @{text "t"}. Note that in the second last clause the function @{text "atom"} |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1007 |
coerces a name into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This allows |
1637 | 1008 |
us to treat binders of different atom type uniformly. |
1009 |
||
1010 |
As will shortly become clear, we cannot return an atom in a binding function |
|
1011 |
that is also bound in the corresponding term-constructor. That means in the |
|
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1012 |
example above that the term-constructors @{text PVar} and @{text PTup} must not have a |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1013 |
binding clause. In the version of Nominal Isabelle described here, we also adopted |
1637 | 1014 |
the restriction from the Ott-tool that binding functions can only return: |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1015 |
the empty set or empty list (as in case @{text PNil}), a singleton set or singleton |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1016 |
list containing an atom (case @{text PVar}), or unions of atom sets or appended atom |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1017 |
lists (case @{text PTup}). This restriction will simplify definitions and |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1018 |
proofs later on. |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1019 |
|
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1020 |
The most drastic restriction we have to impose on deep binders is that |
1637 | 1021 |
we cannot have ``overlapping'' deep binders. Consider for example the |
1022 |
term-constructors: |
|
1617
99cee15cb5ff
more tuning in the paper
Christian Urban <urbanc@in.tum.de>
parents:
1613
diff
changeset
|
1023 |
|
1620 | 1024 |
\begin{center} |
1025 |
\begin{tabular}{ll} |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1026 |
@{text "Foo p::pat q::pat t::trm"} & |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1027 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t},\; |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1028 |
\isacommand{bind} @{text "bn(q)"} \isacommand{in} @{text t}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1029 |
@{text "Foo' x::name p::pat t::trm"} & |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1030 |
\isacommand{bind} @{text x} \isacommand{in} @{text t},\; |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1031 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t} |
1620 | 1032 |
|
1033 |
\end{tabular} |
|
1034 |
\end{center} |
|
1035 |
||
1036 |
\noindent |
|
1637 | 1037 |
In the first case we bind all atoms from the pattern @{text p} in @{text t} |
1038 |
and also all atoms from @{text q} in @{text t}. As a result we have no way |
|
1039 |
to determine whether the binder came from the binding function @{text |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1040 |
"bn(p)"} or @{text "bn(q)"}. Similarly in the second case. The reason why |
1693 | 1041 |
we must exclude such specifications is that they cannot be represent by |
1637 | 1042 |
the general binders described in Section \ref{sec:binders}. However |
1043 |
the following two term-constructors are allowed |
|
1620 | 1044 |
|
1045 |
\begin{center} |
|
1046 |
\begin{tabular}{ll} |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1047 |
@{text "Bar p::pat t::trm s::trm"} & |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1048 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t},\; |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1049 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text s}\\ |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1050 |
@{text "Bar' p::pat t::trm"} & |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1051 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text p},\; |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1052 |
\isacommand{bind} @{text "bn(p)"} \isacommand{in} @{text t}\\ |
1620 | 1053 |
\end{tabular} |
1054 |
\end{center} |
|
1055 |
||
1056 |
\noindent |
|
1628 | 1057 |
since there is no overlap of binders. |
1619 | 1058 |
|
1637 | 1059 |
Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}. |
1693 | 1060 |
Whenever such a binding clause is present, we will call the binder \emph{recursive}. |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1061 |
To see the purpose for such recursive binders, compare ``plain'' @{text "Let"}s and @{text "Let_rec"}s: |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1062 |
% |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1063 |
\begin{equation}\label{letrecs} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1064 |
\mbox{% |
1637 | 1065 |
\begin{tabular}{@ {}l@ {}} |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1066 |
\isacommand{nominal\_datatype}~@{text "trm ="}\\ |
1636 | 1067 |
\hspace{5mm}\phantom{$\mid$}\ldots\\ |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1068 |
\hspace{5mm}$\mid$~@{text "Let as::assn t::trm"} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1069 |
\;\;\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text t}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1070 |
\hspace{5mm}$\mid$~@{text "Let_rec as::assn t::trm"} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1071 |
\;\;\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text t}, |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1072 |
\isacommand{bind} @{text "bn(as)"} \isacommand{in} @{text as}\\ |
1636 | 1073 |
\isacommand{and} {\it assn} =\\ |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1074 |
\hspace{5mm}\phantom{$\mid$}~@{text "ANil"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1075 |
\hspace{5mm}$\mid$~@{text "ACons name trm assn"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1076 |
\isacommand{with} @{text "bn::assn \<Rightarrow> atom list"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1077 |
\isacommand{where}~@{text "bn(ANil) = []"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1078 |
\hspace{5mm}$\mid$~@{text "bn(ACons a t as) = [atom a] @ bn(as)"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1079 |
\end{tabular}} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1080 |
\end{equation} |
1636 | 1081 |
|
1082 |
\noindent |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1083 |
The difference is that with @{text Let} we only want to bind the atoms @{text |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1084 |
"bn(a)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1085 |
inside the assignment. This difference has consequences for the free-variable |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1086 |
function and alpha-equivalence relation, which we are going to describe in the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1087 |
rest of this section. |
1637 | 1088 |
|
1089 |
Having dealt with all syntax matters, the problem now is how we can turn |
|
1090 |
specifications into actual type definitions in Isabelle/HOL and then |
|
1091 |
establish a reasoning infrastructure for them. Because of the problem |
|
1092 |
Pottier and Cheney pointed out, we cannot in general re-arrange arguments of |
|
1093 |
term-constructors so that binders and their bodies are next to each other, and |
|
1094 |
then use the type constructors @{text "abs_set"}, @{text "abs_res"} and |
|
1095 |
@{text "abs_list"} from Section \ref{sec:binders}. Therefore we will first |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1096 |
extract datatype definitions from the specification and then define |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1097 |
independently an alpha-equivalence relation over them. |
1637 | 1098 |
|
1099 |
||
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1100 |
The datatype definition can be obtained by stripping off the |
1637 | 1101 |
binding clauses and the labels on the types. We also have to invent |
1102 |
new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1103 |
given by user. In our implementation we just use the affix @{text "_raw"}. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1104 |
But for the purpose of this paper, we just use the superscript @{text "_\<^sup>\<alpha>"} to indicate |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1105 |
that a notion is defined over alpha-equivalence classes and leave it out |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1106 |
for the corresponding notion defined on the ``raw'' level. So for example |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1107 |
we have |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1108 |
|
1636 | 1109 |
\begin{center} |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1110 |
@{text "ty\<^sup>\<alpha> \<mapsto> ty"} \hspace{2mm}and\hspace{2mm} @{text "C\<^sup>\<alpha> \<mapsto> C"} |
1636 | 1111 |
\end{center} |
1112 |
||
1113 |
\noindent |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1114 |
where the type @{term ty} is the type used in the quotient construction for |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1115 |
@{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor on the ``raw'' type @{text "ty"}. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1116 |
|
1637 | 1117 |
The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1118 |
non-empty and the types in the constructors only occur in positive |
|
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1119 |
position (see \cite{Berghofer99} for an indepth description of the datatype package |
1637 | 1120 |
in Isabelle/HOL). We then define the user-specified binding |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1121 |
functions, called @{term "bn_ty"}, by primitive recursion over the corresponding |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1122 |
raw datatype @{text ty}. We can also easily define permutation operations by |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1123 |
primitive recursion so that for each term constructor @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"} |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1124 |
we have that |
1587 | 1125 |
|
1628 | 1126 |
\begin{center} |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1127 |
@{text "p \<bullet> (C x\<^isub>1 \<dots> x\<^isub>n) = C (p \<bullet> x\<^isub>1) \<dots> (p \<bullet> x\<^isub>n)"} |
1628 | 1128 |
\end{center} |
1129 |
||
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1130 |
% TODO: we did not define permutation types |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1131 |
%\noindent |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1132 |
%From this definition we can easily show that the raw datatypes are |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1133 |
%all permutation types (Def ??) by a simple structural induction over |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1134 |
%the @{text "ty"}s. |
1637 | 1135 |
|
1693 | 1136 |
The first non-trivial step we have to perform is the generation free-variable |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1137 |
functions from the specifications. Given the raw types @{text "ty\<^isub>1 \<dots> ty\<^isub>n"} |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1138 |
we need to define free-variable functions |
1637 | 1139 |
|
1140 |
\begin{center} |
|
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1141 |
@{text "fv_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_ty\<^isub>n :: ty\<^isub>n \<Rightarrow> atom set"} |
1637 | 1142 |
\end{center} |
1143 |
||
1144 |
\noindent |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1145 |
We define them together with auxiliary free-variable functions for |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1146 |
the binding functions. Given binding functions |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1147 |
@{text "bn_ty\<^isub>1 \<dots> bn_ty\<^isub>m"} we need to define |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1148 |
% |
1637 | 1149 |
\begin{center} |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1150 |
@{text "fv_bn_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_bn_ty\<^isub>m :: ty\<^isub>m \<Rightarrow> atom set"} |
1637 | 1151 |
\end{center} |
1636 | 1152 |
|
1637 | 1153 |
\noindent |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1154 |
The reason for this setup is that in a deep binder not all atoms have to be |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1155 |
bound, as we shall see in an example below. While the idea behind these |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1156 |
free-variable functions is clear (they just collect all atoms that are not bound), |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1157 |
because of the rather complicated binding mechanisms their definitions are |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1158 |
somewhat involved. |
1637 | 1159 |
|
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1160 |
Given a term-constructor @{text "C"} of type @{text ty} with argument types |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1161 |
\mbox{@{text "ty\<^isub>1 \<dots> ty\<^isub>n"}}, the function |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1162 |
@{text "fv_ty (C x\<^isub>1 \<dots> x\<^isub>n)"} will be the union of the values |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1163 |
calculated next for each argument. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1164 |
First we deal with the case that @{text "x\<^isub>i"} is a binder. From the binding clauses, |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1165 |
we can determine whether the argument is a shallow or deep |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1166 |
binder, and in the latter case also whether it is a recursive or |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1167 |
non-recursive binder. |
1628 | 1168 |
|
1169 |
\begin{center} |
|
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1170 |
\begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1636 | 1171 |
$\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1172 |
$\bullet$ & @{text "fv_bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1173 |
non-recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"}\\ |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1174 |
$\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is |
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1175 |
a deep recursive binder with the auxiliary function @{text "bn_ty\<^isub>i"} |
1628 | 1176 |
\end{tabular} |
1177 |
\end{center} |
|
1178 |
||
1636 | 1179 |
\noindent |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1180 |
The first clause states that shallow binders do not contribute to the |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1181 |
free variables; in the second clause, we have to collect all |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1182 |
variables that are left unbound by the binding function @{text "bn_ty\<^isub>i"}---this |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1183 |
is done with function @{text "fv_bn_ty\<^isub>i"}; in the third clause, since the |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1184 |
binder is recursive, we need to bind all variables specified by |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1185 |
@{text "bn_ty\<^isub>i"}---therefore we subtract @{text "bn_ty\<^isub>i x\<^isub>i"} from the free |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1186 |
variables of @{text "x\<^isub>i"}. |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1187 |
|
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1188 |
In case the argument is \emph{not} a binder, we need to consider |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1189 |
whether the @{text "x\<^isub>i"} is the body of one or more binding clauses. |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1190 |
In this case we first calculate the set @{text "bnds"} as follows: |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1191 |
either the corresponding binders are all shallow or there is a single deep binder. |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1192 |
In the former case we take @{text bnds} to be the union of all shallow |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1193 |
binders; in the latter case, we just take the set of atoms specified by the |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1194 |
binding function. The value for @{text "x\<^isub>i"} is then given by: |
1709 | 1195 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1196 |
\begin{equation}\label{deepbody} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1197 |
\mbox{% |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1198 |
\begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
1636 | 1199 |
$\bullet$ & @{text "{atom x\<^isub>i} - bnds"} provided @{term "x\<^isub>i"} is an atom\\ |
1200 |
$\bullet$ & @{text "(atoms x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a set of atoms\\ |
|
1657 | 1201 |
$\bullet$ & @{text "(atoms (set x\<^isub>i)) - bnds"} provided @{term "x\<^isub>i"} is a list of atoms\\ |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1202 |
$\bullet$ & @{text "(fv_ty\<^isub>i x\<^isub>i) - bnds"} provided @{term "ty\<^isub>i"} is one of the raw datatypes |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1203 |
corresponding to the types specified by the user\\ |
1715
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1204 |
% $\bullet$ & @{text "(fv\<^isup>\<alpha> x\<^isub>i) - bnds"} provided @{term "x\<^isub>i"} is a defined nominal datatype |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1205 |
% with a free-variable function @{text "fv\<^isup>\<alpha>"}\\ |
1709 | 1206 |
$\bullet$ & @{term "{}"} otherwise |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1207 |
\end{tabular}} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1208 |
\end{equation} |
1628 | 1209 |
|
1723
1cd509cba23f
tuned beginning of section 4
Christian Urban <urbanc@in.tum.de>
parents:
1722
diff
changeset
|
1210 |
\noindent |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1211 |
Like the coercion function @{text atom} used above, @{text "atoms as"} coerces |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1212 |
the set @{text as} to the generic atom type. |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1213 |
It is defined as @{text "atom as \<equiv> {atom a | a \<in> as}"}. |
1637 | 1214 |
|
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1215 |
The last case we need to consider is when @{text "x\<^isub>i"} is neither |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1216 |
a binder nor a body of an abstraction. In this case it is defined |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1217 |
as in \eqref{deepbody}, except that we do not need to subtract the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1218 |
set @{text bnds}. |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1219 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1220 |
Next, we need to define a free-variable function @{text "fv_bn_ty\<^isub>i"} for |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1221 |
each binding function @{text "bn_ty\<^isub>i"}. The idea behind this |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1222 |
function is to compute the set of free atoms that are not bound by |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1223 |
@{text "bn_ty\<^isub>i"}. Because of the restrictions we imposed on the |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1224 |
form of binding functions, this can be done automatically by recursively |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1225 |
building up the the set of free variables from the arguments that are |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1226 |
not bound. Let us assume one clause of the binding function is |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1227 |
@{text "bn_ty\<^isub>i (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, then @{text "fv_bn_ty\<^isub>i"} is the |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1228 |
union of the values calculated for @{text "x\<^isub>j"} of type @{text "ty\<^isub>j"} |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1229 |
as follows: |
1637 | 1230 |
|
1231 |
\begin{center} |
|
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1232 |
\begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1233 |
\multicolumn{2}{l}{@{text "x\<^isub>j"} occurs in @{text "rhs"}:}\\ |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1234 |
$\bullet$ & @{term "{}"} provided @{term "x\<^isub>j"} is a single atom, |
1709 | 1235 |
atom list or atom set\\ |
1724
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1236 |
$\bullet$ & @{text "fv_bn_ty\<^isub>j x\<^isub>j"} in case @{text "rhs"} contains the |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1237 |
recursive call @{text "bn_ty\<^isub>j x\<^isub>j"}\\[1mm] |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1238 |
% |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1239 |
\multicolumn{2}{l}{@{text "x\<^isub>j"} does not occur in @{text "rhs"}:}\\ |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1240 |
$\bullet$ & @{text "atoms x\<^isub>j"} provided @{term "x\<^isub>j"} is a set of atoms\\ |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1241 |
$\bullet$ & @{term "atoms (set x\<^isub>j)"} provided @{term "x\<^isub>j"} is a list of atoms\\ |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1242 |
$\bullet$ & @{text "fv_ty\<^isub>j x\<^isub>j"} provided @{term "ty\<^isub>j"} is one of the raw |
8c788ad71752
cleaned up the section about fv's
Christian Urban <urbanc@in.tum.de>
parents:
1723
diff
changeset
|
1243 |
types corresponding to the types specified by the user\\ |
1715
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1244 |
% $\bullet$ & @{text "fv_ty\<^isup>\<alpha> x\<^isub>j - bnds"} provided @{term "x\<^isub>j"} is not in @{text "rhs"} |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1245 |
% and is an existing nominal datatype with the free-variable function @{text "fv\<^isup>\<alpha>"}\\ |
1706 | 1246 |
$\bullet$ & @{term "{}"} otherwise |
1637 | 1247 |
\end{tabular} |
1248 |
\end{center} |
|
1249 |
||
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1250 |
\noindent |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1251 |
To see how these definitions work, let us consider again the term-constructors |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1252 |
@{text "Let"} and @{text "Let_rec"} from example shown in \eqref{letrecs}. |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1253 |
For this specification we need to define three functions, namely |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1254 |
@{text "fv\<^bsub>trm\<^esub>"}, @{text "fv\<^bsub>assn\<^esub>"} and @{text "fv\<^bsub>bn\<^esub>"}. They are as follows: |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1255 |
% |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1256 |
\begin{center} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1257 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1258 |
@{text "fv\<^bsub>trm\<^esub> (Let as t)"} & @{text "="} & @{text "fv\<^bsub>bn\<^esub> as \<union> (fv\<^bsub>trm\<^esub> t - set (bn as))"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1259 |
@{text "fv\<^bsub>trm\<^esub> (Let_rec as t)"} & @{text "="} &\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1260 |
\multicolumn{3}{r}{@{text "(fv\<^bsub>assn\<^esub> as - set (bn as)) \<union> (fv\<^bsub>trm\<^esub> t - set (bn as))"}}\\[1mm] |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1261 |
|
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1262 |
@{text "fv\<^bsub>assn\<^esub> (ANil)"} & @{text "="} & @{text "[]"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1263 |
@{text "fv\<^bsub>assn\<^esub> (ACons a t as)"} & @{text "="} & @{text "{atom a} \<union> (fv\<^bsub>trm\<^esub> t) \<union> (fv\<^bsub>assn\<^esub> as)"}\\[1mm] |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1264 |
|
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1265 |
@{text "fv\<^bsub>bn\<^esub> (ANil)"} & @{text "="} & @{text "[]"}\\ |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1266 |
@{text "fv\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "="} & @{text "(fv\<^bsub>trm\<^esub> t) \<union> (fv\<^bsub>bn\<^esub> as)"} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1267 |
\end{tabular} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1268 |
\end{center} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1269 |
|
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1270 |
\noindent |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1271 |
Since there are no binding clauses for the term-constructors @{text ANil} |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1272 |
and @{text "ACons"}, the corresponding free-variable function @{text |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1273 |
"fv\<^bsub>assn\<^esub>"} returns all atoms occuring in an assignment. The |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1274 |
binding only takes place in @{text Let} and @{text "Let_rec"}. In the @{text |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1275 |
"Let"}-clause we want to bind all atoms given by @{text "set (bn as)"} in |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1276 |
@{text t}. Therefore we have to subtract @{text "set (bn as)"} from @{text |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1277 |
"fv\<^bsub>trm\<^esub> t"}. However, we also need to add all atoms that are |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1278 |
free in @{text "as"}. This is what the purpose of the function @{text |
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1279 |
"fv\<^bsub>bn\<^esub>"} is. In contrast, in @{text "Let_rec"} we have a |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1280 |
recursive binder where we want to also bind all occurences of the atoms |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1281 |
@{text "bn as"} inside @{text "as"}. Therefore we have to subtract @{text |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1282 |
"set (bn as)"} from @{text "fv\<^bsub>assn\<^esub> as"}, as well as from |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1283 |
@{text "fv\<^bsub>trm\<^esub> t"}. An interesting point in this example is |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1284 |
that an assignment ``alone'' does not have any bound variables. Only in the |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1285 |
context of a @{text Let} or @{text "Let_rec"} will some atoms become bound |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1286 |
(teh term-constructors that have binding clauses). This is a phenomenon |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1287 |
that has also been pointed out in \cite{ott-jfp}. |
1725
1801cc460fc9
polished and added an example for fvars
Christian Urban <urbanc@in.tum.de>
parents:
1724
diff
changeset
|
1288 |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1289 |
Next we define alpha-equivalence realtions for the types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"}. We call them |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1290 |
@{text "\<approx>ty\<^isub>1 \<dots> \<approx>ty\<^isub>n"}. Like with the free-variable functions, |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1291 |
we also need to define auxiliary alpha-equivalence relations for the binding functions. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1292 |
Say we have @{text "bn_ty\<^isub>1 \<dots> bn_ty\<^isub>m"}, we also define @{text "\<approx>bn_ty\<^isub>1 \<dots> \<approx>bn_ty\<^isub>n"}. |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1293 |
|
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1294 |
The relations are inductively defined predicates, whose clauses have |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1295 |
conclusions of the form @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx>ty C y\<^isub>1 \<dots> y\<^isub>n"} (let us assume |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1296 |
@{text C} is of type @{text ty} and its arguments are specified as @{text "C ty\<^isub>1 \<dots> ty\<^isub>n"}). |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1297 |
The task is to specify what the premises of these clauses are. For this we |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1298 |
consider the pairs @{text "(x\<^isub>i, y\<^isub>i)"} which necesarily must have the same type, say |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1299 |
@{text "ty\<^isub>i"}. For each of these pairs we calculate a premise as follows. |
1705 | 1300 |
|
1301 |
\begin{center} |
|
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1302 |
\begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1303 |
\multicolumn{2}{l}{@{text "x\<^isub>i"} is a binder:}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1304 |
$\bullet$ & @{text "True"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1305 |
$\bullet$ & @{text "x\<^isub>i \<approx>bn_ty\<^isub>i y\<^isub>i"} provided @{text "x\<^isub>i"} is a deep |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1306 |
non-recursive binder\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1307 |
$\bullet$ & @{text "True"} provided @{text "x\<^isub>i"} is a deep |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1308 |
recursive binder\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1309 |
\end{tabular} |
1705 | 1310 |
\end{center} |
1311 |
||
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1312 |
TODO BELOW |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1313 |
|
1705 | 1314 |
\begin{center} |
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1315 |
\begin{tabular}{c@ {\hspace{2mm}}p{7cm}} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1316 |
\multicolumn{2}{l}{@{text "x\<^isub>i"} is a body where the binding clause has mode \isacommand{bind}:}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1317 |
$\bullet$ & @{text "\<exists>p. (bnds_x\<^isub>i, x\<^isub>i) \<approx>lst (\<approx>ty\<^isub>i) fv_ty\<^isub>i p (bnds_y\<^isub>i, y\<^isub>j)"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1318 |
provided @{text "x\<^isub>i"} has only shallow binders; in this case @{text "bnds_x\<^isub>i"} is the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1319 |
union of all these shallow binders (similarly for @{text "bnds_y\<^isub>i"}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1320 |
$\bullet$ & @{text "\<exists>p. (bn_ty\<^isub>j x\<^isub>j, x\<^isub>i) \<approx>lst (\<approx>ty\<^isub>i) fv_ty\<^isub>i p (bn_ty y\<^isub>j, y\<^isub>i)"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1321 |
provided @{text "x\<^isub>i"} is a body with a deep non-recursive binder @{text x\<^isub>j} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1322 |
(similarly @{text "y\<^isub>j"} is the deep non-recursive binder for @{text "y\<^isub>i"})\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1323 |
$\bullet$ & @{text "\<exists>p (bn_ty\<^isub>i x\<^isub>i, (x\<^isub>j, x\<^isub>n)) \<approx>lst R fvs \<pi> (bn\<^isub>m y\<^isub>j, (y\<^isub>j, y\<^isub>n))"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1324 |
provided @{text "x\<^isub>j"} is a deep recursive binder with the auxiliary binding |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1325 |
function @{text "bn\<^isub>m"} and permutation @{text "\<pi>"}, @{term "fvs"} is a compound |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1326 |
free variable function returning the union of appropriate @{term "fv_ty\<^isub>x"} and |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1327 |
@{term "R"} is the composition of equivalence relations @{text "\<approx>"} and @{text "\<approx>\<^isub>n"}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1328 |
$\bullet$ & @{text "x\<^isub>j"} has a deep recursive binding\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1329 |
$\bullet$ & @{text "({x\<^isub>n}, x\<^isub>j) \<approx>gen R fv_ty \<pi> ({y\<^isub>n}, y\<^isub>j)"} provided @{text "x\<^isub>j"} has |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1330 |
a shallow binder @{text "x\<^isub>n"} with permutation @{text "\<pi>"}, @{term "R"} is the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1331 |
alpha-equivalence for @{term "x\<^isub>j"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1332 |
and @{term "fv_ty"} is the free-variable function for @{term "x\<^isub>j"}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1333 |
$\bullet$ & @{text "(bn\<^isub>m x\<^isub>n, x\<^isub>j) \<approx>gen R fv_ty \<pi> (bn\<^isub>m y\<^isub>n, y\<^isub>j)"} provided @{text "x\<^isub>j"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1334 |
has a deep non-recursive binder @{text "bn\<^isub>m x\<^isub>n"} with permutation @{text "\<pi>"}, @{term "R"} is the |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1335 |
alpha-equivalence for @{term "x\<^isub>j"} |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1336 |
and @{term "fv_ty"} is the free-variable function for @{term "x\<^isub>j"}\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1337 |
$\bullet$ & @{text "x\<^isub>j \<approx>\<^isub>j y\<^isub>j"} provided @{term "x\<^isub>j"} is one of the types being |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1338 |
defined\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1339 |
$\bullet$ & @{text "x\<^isub>j = y\<^isub>j"} otherwise\\ |
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1340 |
\end{tabular} |
1705 | 1341 |
\end{center} |
1342 |
||
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1343 |
, of a type @{text ty}, two instances |
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1344 |
of this constructor are alpha-equivalent @{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx> C y\<^isub>1 \<dots> y\<^isub>n"} if there |
1707
70c5e688f677
Change @{text} to @{term}
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1706
diff
changeset
|
1345 |
exist permutations @{text "\<pi>\<^isub>1 \<dots> \<pi>\<^isub>p"} (one for each bound argument) such that |
1710 | 1346 |
the conjunction of equivalences defined below for each argument pair @{text "x\<^isub>j"}, @{text "y\<^isub>j"} holds. |
1706 | 1347 |
For an argument pair @{text "x\<^isub>j"}, @{text "y\<^isub>j"} this holds if: |
1348 |
||
1727
fd2913415a73
started to polish alpha-equivalence section, but needs more work
Christian Urban <urbanc@in.tum.de>
parents:
1726
diff
changeset
|
1349 |
|
1705 | 1350 |
|
1708 | 1351 |
The alpha-equivalence relations for binding functions are similar to the alpha-equivalences |
1352 |
for their respective types, the difference is that they ommit checking the arguments that |
|
1353 |
are bound. We assumed that there are no bindings in the type on which the binding function |
|
1354 |
is defined so, there are no permutations involved. For a binding function clause |
|
1719
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1355 |
@{text "bn (C x\<^isub>1 \<dots> x\<^isub>n) = rhs"}, two instances of the constructor are equivalent |
0c3c66f5c0e7
removed "raw" distinction
Christian Urban <urbanc@in.tum.de>
parents:
1717
diff
changeset
|
1356 |
@{text "C x\<^isub>1 \<dots> x\<^isub>n \<approx> C y\<^isub>1 \<dots> y\<^isub>n"} if: |
1708 | 1357 |
\begin{center} |
1358 |
\begin{tabular}{cp{7cm}} |
|
1715
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1359 |
$\bullet$ & @{text "x\<^isub>j"} is not of a type being defined and occurs in @{text "rhs"}\\ |
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1360 |
$\bullet$ & @{text "x\<^isub>j = y\<^isub>j"} provided @{text "x\<^isub>j"} is not of a type being defined |
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1361 |
and does not occur in @{text "rhs"}\\ |
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1362 |
$\bullet$ & @{text "x\<^isub>j \<approx>bn\<^isub>m y\<^isub>j"} provided @{text "x\<^isub>j"} is of a type being defined |
3d6df74fc934
Avoid mentioning other nominal datatypes as it makes things too complicated.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1714
diff
changeset
|
1363 |
occuring in @{text "rhs"} under the binding function @{text "bn\<^isub>m"}\\ |
1708 | 1364 |
$\bullet$ & @{text "x\<^isub>j \<approx> y\<^isub>j"} otherwise\\ |
1365 |
\end{tabular} |
|
1366 |
\end{center} |
|
1367 |
||
1587 | 1368 |
*} |
1369 |
||
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1370 |
section {* The Lifting of Definitions and Properties *} |
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1371 |
|
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1372 |
text {* |
1721 | 1373 |
To define the quotient types we first need to show that the defined |
1374 |
relations are equivalence relations. |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1375 |
|
1718 | 1376 |
\begin{lemma} The relations @{text "\<approx>\<^isub>1 \<dots> \<approx>\<^isub>1"} and @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} |
1377 |
defined as above are equivalence relations and are equivariant. |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1378 |
\end{lemma} |
1718 | 1379 |
\begin{proof} Reflexivity by induction on the raw datatype. Symmetry, |
1380 |
transitivity and equivariance by induction on the alpha equivalence |
|
1381 |
relation. Using lemma \ref{alphaeq}, the conditions follow by simple |
|
1382 |
calculations. \end{proof} |
|
1383 |
||
1384 |
\noindent We then define the quotient types @{text "ty\<^isub>1\<^isup>\<alpha> \<dots> ty\<^isub>n\<^isup>\<alpha>"}. To lift |
|
1385 |
the raw definitions to the quotient type, we need to prove that they |
|
1386 |
\emph{respect} the relation. We follow the definition of respectfullness given |
|
1387 |
by Homeier~\cite{Homeier05}. The intuition behind a respectfullness condition |
|
1388 |
is that when a function (or constructor) is given arguments that are |
|
1389 |
alpha-equivalent the results are also alpha equivalent. For arguments that are |
|
1390 |
not of any of the relations taken into account, equivalence is replaced by |
|
1391 |
equality. In particular the respectfullness condition for a @{text "bn"} |
|
1392 |
function means that for alpha equivalent raw terms it returns the same bound |
|
1393 |
names. Thanks to the restrictions on the binding functions introduced in |
|
1394 |
Section~\ref{sec:alpha} we can show that are respectful. |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1395 |
|
1718 | 1396 |
\begin{lemma} The functions @{text "bn\<^isub>1 \<dots> bn\<^isub>m"}, @{text "fv_ty\<^isub>1 \<dots> fv_ty\<^isub>n"}, |
1397 |
the raw constructors, the raw permutations and @{text "\<approx>bn\<^isub>1 \<dots> \<approx>bn\<^isub>m"} are |
|
1398 |
respectful w.r.t. the relations @{text "\<approx>\<^isub>1 \<dots> \<approx>\<^isub>n"}. |
|
1399 |
\end{lemma} |
|
1400 |
\begin{proof} Respectfullness of permutations is a direct consequence of |
|
1401 |
equivariance. All other properties by induction on the alpha-equivalence |
|
1402 |
relation. For @{text "bn"} the thesis follows by simple calculations thanks |
|
1403 |
to the restrictions on the binding functions. For @{text "fv"} functions it |
|
1404 |
follows using respectfullness of @{text "bn"}. For type constructors it is a |
|
1405 |
simple calculation thanks to the way alpha-equivalence was defined. For @{text |
|
1406 |
"alpha_bn"} after a second induction on the second relation by simple |
|
1407 |
calculations. \end{proof} |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1408 |
|
1718 | 1409 |
With these respectfullness properties we can use the quotient package |
1410 |
to define the above constants on the quotient level. We can then automatically |
|
1411 |
lift the theorems that talk about the raw constants to theorems on the quotient |
|
1412 |
level. The following lifted properties are proved: |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1413 |
|
1718 | 1414 |
\begin{center} |
1415 |
\begin{tabular}{cp{7cm}} |
|
1721 | 1416 |
%skipped permute_zero and permute_add, since we do not have a permutation |
1417 |
%definition |
|
1718 | 1418 |
$\bullet$ & permutation defining equations \\ |
1419 |
$\bullet$ & @{term "bn"} defining equations \\ |
|
1420 |
$\bullet$ & @{term "fv_ty"} and @{term "fv_bn"} defining equations \\ |
|
1721 | 1421 |
$\bullet$ & induction. The induction principle that we obtain by lifting |
1422 |
is the weak induction principle, just on the term structure \\ |
|
1423 |
$\bullet$ & quasi-injectivity. This means the equations that specify |
|
1424 |
when two constructors are equal and comes from lifting the alpha |
|
1425 |
equivalence defining relations\\ |
|
1718 | 1426 |
$\bullet$ & distinctness\\ |
1721 | 1427 |
%may be skipped |
1718 | 1428 |
$\bullet$ & equivariance of @{term "fv"} and @{term "bn"} functions\\ |
1429 |
\end{tabular} |
|
1430 |
\end{center} |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1431 |
|
1721 | 1432 |
Notice that until now we have not said anything about the support of the |
1433 |
defined type. This is because we could not use the general definition of |
|
1434 |
support in lifted theorems, since it does not preserve the relation. |
|
1435 |
Indeed, take the term @{text "\<lambda>x. x"}. The support of the term is empty @{term "{}"}, |
|
1436 |
since the @{term "x"} is bound. On the raw level, before the binding is |
|
1722 | 1437 |
introduced the term has the support equal to @{text "{x}"}. |
1721 | 1438 |
|
1722 | 1439 |
To show the support equations for the lifted types we want to use the |
1728 | 1440 |
Theorem \ref{suppabs}, so we start with showing that they have a finite |
1722 | 1441 |
support. |
1721 | 1442 |
|
1722 | 1443 |
\begin{lemma} The types @{text "ty\<^isup>\<alpha>\<^isub>1 \<dots> ty\<^isup>\<alpha>\<^isub>n"} have finite support. |
1444 |
\end{lemma} |
|
1445 |
\begin{proof} |
|
1446 |
By induction on the lifted types. For each constructor its support is |
|
1447 |
supported by the union of the supports of all arguments. By induction |
|
1448 |
hypothesis we know that each of the recursive arguments has finite |
|
1449 |
support. We also know that atoms and finite atom sets and lists that |
|
1450 |
occur in the constructors have finite support. A union of finite |
|
1451 |
sets is finite thus the support of the constructor is finite. |
|
1452 |
\end{proof} |
|
1721 | 1453 |
|
1728 | 1454 |
% Very vague... |
1722 | 1455 |
\begin{lemma} For each lifted type @{text "ty\<^isup>\<alpha>\<^isub>i"}, for every @{text "x"} |
1456 |
of this type: |
|
1457 |
\begin{center} |
|
1458 |
@{term "supp x = fv_ty\<^isup>\<alpha>\<^isub>i x"}. |
|
1459 |
\end{center} |
|
1460 |
\end{lemma} |
|
1461 |
\begin{proof} |
|
1728 | 1462 |
We will show this by induction together with equations that characterize |
1463 |
@{term "fv_bn\<^isup>\<alpha>\<^isub>"} in terms of @{term "alpha_bn\<^isup>\<alpha>"}. For each of @{text "fv_bn\<^isup>\<alpha>"} |
|
1464 |
functions this equaton is: |
|
1465 |
\begin{center} |
|
1466 |
@{term "{a. infinite {b. \<not> alpha_bn\<^isup>\<alpha> ((a \<rightleftharpoons> b) \<bullet> x) x}} = fv_bn\<^isup>\<alpha> x"} |
|
1467 |
\end{center} |
|
1468 |
||
1469 |
In the induction we need to show these equations together with the goal |
|
1470 |
for the appropriate constructors. We first transform the right hand sides. |
|
1471 |
The free variable functions are applied to theirs respective constructors |
|
1472 |
so we can apply the lifted free variable defining equations to obtain |
|
1473 |
free variable functions applied to subterms minus binders. Using the |
|
1474 |
induction hypothesis we can replace free variable functions applied to |
|
1475 |
subterms by support. Using Theorem \ref{suppabs} we replace the differences |
|
1476 |
by supports of appropriate abstractions. |
|
1477 |
||
1478 |
Unfolding the definition of supports on both sides of the equations we |
|
1479 |
obtain by simple calculations the equalities. |
|
1722 | 1480 |
\end{proof} |
1728 | 1481 |
|
1729 | 1482 |
%%% Without defining permute_bn, we cannot even write the substitution |
1483 |
%%% of bindings in term constructors... |
|
1484 |
||
1485 |
% With the above equations we can substitute free variables for support in |
|
1486 |
% the lifted free variable equations, which gives us the support equations |
|
1487 |
% for the term constructors. With this we can show that for each binding in |
|
1488 |
% a constructors the bindings can be renamed. |
|
1728 | 1489 |
|
1717
a3ef7fba983f
Beginning of section 5.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
1716
diff
changeset
|
1490 |
*} |
1587 | 1491 |
|
1492 |
text {* |
|
1722 | 1493 |
%%% FIXME: The restricions should have already been described in previous sections? |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1494 |
Restrictions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1495 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1496 |
\begin{itemize} |
1572 | 1497 |
\item non-emptiness |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1498 |
\item positive datatype definitions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1499 |
\item finitely supported abstractions |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1500 |
\item respectfulness of the bn-functions\bigskip |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1501 |
\item binders can only have a ``single scope'' |
1577 | 1502 |
\item all bindings must have the same mode |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1503 |
\end{itemize} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1504 |
*} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1505 |
|
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
1506 |
section {* Examples *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
1507 |
|
1702 | 1508 |
text {* |
1509 |
||
1510 |
\begin{figure} |
|
1511 |
\begin{boxedminipage}{\linewidth} |
|
1512 |
\small |
|
1513 |
\begin{tabular}{l} |
|
1514 |
\isacommand{atom\_decl}~@{text "var"}\\ |
|
1515 |
\isacommand{atom\_decl}~@{text "cvar"}\\ |
|
1516 |
\isacommand{atom\_decl}~@{text "tvar"}\\[1mm] |
|
1517 |
\isacommand{nominal\_datatype}~@{text "tkind ="}\\ |
|
1518 |
\phantom{$|$}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\ |
|
1519 |
\isacommand{and}~@{text "ckind ="}\\ |
|
1520 |
\phantom{$|$}~@{text "CKSim ty ty"}\\ |
|
1521 |
\isacommand{and}~@{text "ty ="}\\ |
|
1522 |
\phantom{$|$}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\ |
|
1523 |
$|$~@{text "TFun string ty_list"}~% |
|
1524 |
$|$~@{text "TAll tv::tvar tkind ty::ty"} \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text ty}\\ |
|
1525 |
$|$~@{text "TArr ckind ty"}\\ |
|
1526 |
\isacommand{and}~@{text "ty_lst ="}\\ |
|
1527 |
\phantom{$|$}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\ |
|
1528 |
\isacommand{and}~@{text "cty ="}\\ |
|
1529 |
\phantom{$|$}~@{text "CVar cvar"}~% |
|
1530 |
$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\ |
|
1531 |
$|$~@{text "CAll cv::cvar ckind cty::cty"} \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text cty}\\ |
|
1532 |
$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\ |
|
1533 |
$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\ |
|
1534 |
$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\ |
|
1535 |
\isacommand{and}~@{text "co_lst ="}\\ |
|
1536 |
\phantom{$|$}@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\ |
|
1537 |
\isacommand{and}~@{text "trm ="}\\ |
|
1538 |
\phantom{$|$}~@{text "Var var"}~$|$~@{text "K string"}\\ |
|
1539 |
$|$~@{text "LAM_ty tv::tvar tkind t::trm"} \isacommand{bind}~@{text "tv"}~\isacommand{in}~@{text t}\\ |
|
1540 |
$|$~@{text "LAM_cty cv::cvar ckind t::trm"} \isacommand{bind}~@{text "cv"}~\isacommand{in}~@{text t}\\ |
|
1541 |
$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\ |
|
1542 |
$|$~@{text "Lam v::var ty t::trm"} \isacommand{bind}~@{text "v"}~\isacommand{in}~@{text t}\\ |
|
1543 |
$|$~@{text "Let x::var ty trm t::trm"} \isacommand{bind}~{text x}~\isacommand{in}~{text t}\\ |
|
1544 |
$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\ |
|
1545 |
\isacommand{and}~@{text "assoc_lst ="}\\ |
|
1546 |
\phantom{$|$}~@{text ANil}~% |
|
1547 |
$|$~@{text "ACons p::pat t::trm assoc_lst"} \isacommand{bind}~@{text "bv p"}~\isacommand{in}~@{text t}\\ |
|
1548 |
\isacommand{and}~@{text "pat ="}\\ |
|
1549 |
\phantom{$|$}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\ |
|
1550 |
\isacommand{and}~@{text "vt_lst ="}\\ |
|
1551 |
\phantom{$|$}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\ |
|
1552 |
\isacommand{and}~@{text "tvtk_lst ="}\\ |
|
1553 |
\phantom{$|$}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\ |
|
1554 |
\isacommand{and}~@{text "tvck_lst ="}\\ |
|
1555 |
\phantom{$|$}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\ |
|
1556 |
\isacommand{binder}\\ |
|
1557 |
@{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}~% |
|
1558 |
@{text "bv1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\ |
|
1559 |
@{text "bv2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}~% |
|
1560 |
@{text "bv3 :: tvck_lst \<Rightarrow> atom list"}\\ |
|
1561 |
\isacommand{where}\\ |
|
1562 |
\phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv3 tvts) @ (bv2 tvcs) @ (bv1 vs)"}\\ |
|
1563 |
$|$~@{text "bv1 VTNil = []"}\\ |
|
1564 |
$|$~@{text "bv1 (VTCons x ty tl) = (atom x)::(bv1 tl)"}\\ |
|
1565 |
$|$~@{text "bv2 TVTKNil = []"}\\ |
|
1566 |
$|$~@{text "bv2 (TVTKCons a ty tl) = (atom a)::(bv2 tl)"}\\ |
|
1567 |
$|$~@{text "bv3 TVCKNil = []"}\\ |
|
1568 |
$|$~@{text "bv3 (TVCKCons c cty tl) = (atom c)::(bv3 tl)"}\\ |
|
1569 |
\end{tabular} |
|
1570 |
\end{boxedminipage} |
|
1571 |
\caption{\label{nominalcorehas}} |
|
1572 |
\end{figure} |
|
1573 |
*} |
|
1574 |
||
1575 |
||
1576 |
||
1577 |
||
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
|
1578 |
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
|
1579 |
|
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
|
1580 |
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
|
1581 |
|
1570 | 1582 |
text {* |
1726
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1583 |
The earliest usage we know of general binders in a theorem prover setting is |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1584 |
in the paper \cite{NaraschewskiNipkow99}, which describes a formalisation of |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1585 |
the algorithm W. This formalisation implements binding in type schemes using a |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1586 |
a de-Bruijn indices representation. Also recently an extension for general binders |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1587 |
has been proposed for the locally nameless approach to binding \cite{chargueraud09}. . |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1588 |
But we have not yet seen it to be employed in a non-trivial formal verification. |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1589 |
In both approaches, it seems difficult to achieve our fine-grained control over the |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1590 |
``semantics'' of bindings (whether the order should matter, or vacous binders |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1591 |
should be taken into account). To do so, it is necessary to introduce predicates |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1592 |
that filter out some unwanted terms. This very likely results in intricate |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1593 |
formal reasoning. |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1594 |
|
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1595 |
Higher-Order Abstract Syntax (HOAS) approaches to representing binders are |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1596 |
nicely supported in the Twelf theorem prover and work is in progress to use |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1597 |
HOAS in a mechanisation of the metatheory of SML |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1598 |
\cite{LeeCraryHarper07}. HOAS supports elegantly reasoning about |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1599 |
term-calculi with single binders. We are not aware how more complicated |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1600 |
binders from SML are represented in HOAS, but we know that HOAS cannot |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1601 |
easily deal with binding constructs where the number of bound variables is |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1602 |
not fixed. An example is the second part of the POPLmark challenge where |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1603 |
@{text "Let"}s involving patterns need to be formalised. In such situations |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1604 |
HOAS needs to use essentially has to represent multiple binders with |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1605 |
iterated single binders. |
1570 | 1606 |
|
1726
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1607 |
An attempt of representing general binders in the old version of Isabelle |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1608 |
based also on iterating single binders is described in \cite{BengtsonParow09}. |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1609 |
The reasoning there turned out to be quite complex. |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1610 |
|
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1611 |
Ott is better with list dot specifications; subgrammars, is untyped; |
1570 | 1612 |
|
1613 |
*} |
|
1614 |
||
1615 |
||
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
1616 |
section {* Conclusion *} |
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
1617 |
|
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
1618 |
text {* |
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1619 |
Complication when the single scopedness restriction is lifted (two |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1620 |
overlapping permutations) |
1662 | 1621 |
|
1726
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1622 |
Future work: distinct list abstraction |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1623 |
|
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1624 |
TODO: function definitions: |
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1625 |
|
1662 | 1626 |
|
1627 |
The formalisation presented here will eventually become part of the |
|
1628 |
Isabelle distribution, but for the moment it can be downloaded from |
|
1629 |
the Mercurial repository linked at |
|
1630 |
\href{http://isabelle.in.tum.de/nominal/download} |
|
1631 |
{http://isabelle.in.tum.de/nominal/download}.\medskip |
|
1520
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1632 |
*} |
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1633 |
|
6ac75fd979d4
more of the introduction
Christian Urban <urbanc@in.tum.de>
parents:
1517
diff
changeset
|
1634 |
text {* |
1493
52f68b524fd2
slightly more of the paper
Christian Urban <urbanc@in.tum.de>
parents:
1491
diff
changeset
|
1635 |
\noindent |
1528
d6ee4a1b34ce
more tuning on the paper
Christian Urban <urbanc@in.tum.de>
parents:
1524
diff
changeset
|
1636 |
{\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
|
1637 |
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
|
1638 |
making the informal notes \cite{SewellBestiary} available to us and |
1556 | 1639 |
also for patiently explaining some of the finer points about the abstract |
1702 | 1640 |
definitions and about the implementation of the Ott-tool. We |
1641 |
also thank Stephanie Weirich for suggesting to separate the subgrammars |
|
1642 |
of kinds and types in our Core-Haskell example. |
|
1485
c004e7448dca
temporarily disabled tests in Nominal/ROOT
Christian Urban <urbanc@in.tum.de>
parents:
1484
diff
changeset
|
1643 |
|
1726
2eafd8ed4bbf
started with a related work section
Christian Urban <urbanc@in.tum.de>
parents:
1725
diff
changeset
|
1644 |
|
1577 | 1645 |
|
1646 |
||
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1647 |
*} |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1648 |
|
1484 | 1649 |
|
1650 |
||
754
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1651 |
(*<*) |
b85875d65b10
added a paper for possible notes
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1652 |
end |
1704 | 1653 |
(*>*) |