2985
+ − 1
(*<*)
+ − 2
theory Paper
+ − 3
imports "../Nominal/Nominal2"
+ − 4
"~~/src/HOL/Library/LaTeXsugar"
+ − 5
begin
+ − 6
+ − 7
consts
+ − 8
fv :: "'a \<Rightarrow> 'b"
+ − 9
abs_set :: "'a \<Rightarrow> 'b \<Rightarrow> 'c"
+ − 10
alpha_bn :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
+ − 11
abs_set2 :: "'a \<Rightarrow> perm \<Rightarrow> 'b \<Rightarrow> 'c"
3016
+ − 12
equ2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
2985
+ − 13
Abs_dist :: "'a \<Rightarrow> 'b \<Rightarrow> 'c"
+ − 14
Abs_print :: "'a \<Rightarrow> 'b \<Rightarrow> 'c"
+ − 15
+ − 16
definition
+ − 17
"equal \<equiv> (op =)"
+ − 18
3006
+ − 19
fun alpha_set_ex where
+ − 20
"alpha_set_ex (bs, x) R f (cs, y) = (\<exists>pi. alpha_set (bs, x) R f pi (cs, y))"
+ − 21
+ − 22
fun alpha_res_ex where
+ − 23
"alpha_res_ex (bs, x) R f pi (cs, y) = (\<exists>pi. alpha_res (bs, x) R f pi (cs, y))"
+ − 24
+ − 25
fun alpha_lst_ex where
+ − 26
"alpha_lst_ex (bs, x) R f pi (cs, y) = (\<exists>pi. alpha_lst (bs, x) R f pi (cs, y))"
+ − 27
+ − 28
+ − 29
2985
+ − 30
notation (latex output)
+ − 31
swap ("'(_ _')" [1000, 1000] 1000) and
+ − 32
fresh ("_ # _" [51, 51] 50) and
+ − 33
fresh_star ("_ #\<^sup>* _" [51, 51] 50) and
+ − 34
supp ("supp _" [78] 73) and
+ − 35
uminus ("-_" [78] 73) and
+ − 36
If ("if _ then _ else _" 10) and
3006
+ − 37
alpha_set_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set}}$}}>\<^bsup>_, _\<^esup> _") and
+ − 38
alpha_lst_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{list}}$}}>\<^bsup>_, _\<^esup> _") and
+ − 39
alpha_res_ex ("_ \<approx>\<^raw:\,\raisebox{-1pt}{\makebox[0mm][l]{$_{\textit{set+}}$}}>\<^bsup>_, _\<^esup> _") and
2985
+ − 40
abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and
+ − 41
abs_set2 ("_ \<approx>\<^raw:\raisebox{-1pt}{\makebox[0mm][l]{$\,_{\textit{list}}$}}>\<^bsup>_\<^esup> _") and
+ − 42
fv ("fa'(_')" [100] 100) and
+ − 43
equal ("=") and
+ − 44
alpha_abs_set ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set}}$}> _") and
3002
+ − 45
alpha_abs_lst ("_ \<approx>\<^raw:{$\,_{\textit{abs\_list}}$}> _") and
+ − 46
alpha_abs_res ("_ \<approx>\<^raw:{$\,_{\textit{abs\_set+}}$}> _") and
2985
+ − 47
Abs_set ("[_]\<^bsub>set\<^esub>._" [20, 101] 999) and
3021
+ − 48
Abs_lst ("[_]\<^bsub>list\<^esub>._" [20, 101] 999) and
+ − 49
Abs_dist ("[_]\<^bsub>#list\<^esub>._" [20, 101] 999) and
2985
+ − 50
Abs_res ("[_]\<^bsub>set+\<^esub>._") and
+ − 51
Abs_print ("_\<^bsub>set\<^esub>._") and
+ − 52
Cons ("_::_" [78,77] 73) and
+ − 53
supp_set ("aux _" [1000] 10) and
+ − 54
alpha_bn ("_ \<approx>bn _")
+ − 55
+ − 56
consts alpha_trm ::'a
+ − 57
consts fa_trm :: 'a
3016
+ − 58
consts fa_trm_al :: 'a
2985
+ − 59
consts alpha_trm2 ::'a
+ − 60
consts fa_trm2 :: 'a
3016
+ − 61
consts fa_trm2_al :: 'a
+ − 62
consts supp2 :: 'a
2985
+ − 63
consts ast :: 'a
+ − 64
consts ast' :: 'a
3016
+ − 65
consts bn_al :: "'b \<Rightarrow> 'a"
2985
+ − 66
notation (latex output)
+ − 67
alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and
+ − 68
fa_trm ("fa\<^bsub>trm\<^esub>") and
3016
+ − 69
fa_trm_al ("fa\<AL>\<^bsub>trm\<^esub>") and
2985
+ − 70
alpha_trm2 ("'(\<approx>\<^bsub>assn\<^esub>, \<approx>\<^bsub>trm\<^esub>')") and
+ − 71
fa_trm2 ("'(fa\<^bsub>assn\<^esub>, fa\<^bsub>trm\<^esub>')") and
3016
+ − 72
fa_trm2_al ("'(fa\<AL>\<^bsub>assn\<^esub>, fa\<AL>\<^bsub>trm\<^esub>')") and
2985
+ − 73
ast ("'(as, t')") and
3016
+ − 74
ast' ("'(as', t\<PRIME> ')") and
+ − 75
equ2 ("'(=, =')") and
+ − 76
supp2 ("'(supp, supp')") and
3018
+ − 77
bn_al ("bn\<^sup>\<alpha> _" [100] 100)
2985
+ − 78
(*>*)
+ − 79
+ − 80
+ − 81
section {* Introduction *}
+ − 82
+ − 83
text {*
2989
+ − 84
So far, Nominal Isabelle provided a mechanism for constructing alpha-equated
+ − 85
terms, for example lambda-terms
2985
+ − 86
2989
+ − 87
\[
+ − 88
@{text "t ::= x | t t | \<lambda>x. t"}
+ − 89
\]\smallskip
+ − 90
+ − 91
\noindent
+ − 92
where free and bound variables have names. For such alpha-equated terms,
2985
+ − 93
Nominal Isabelle derives automatically a reasoning infrastructure that has
+ − 94
been used successfully in formalisations of an equivalence checking
+ − 95
algorithm for LF \cite{UrbanCheneyBerghofer08}, Typed
+ − 96
Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency
+ − 97
\cite{BengtsonParow09} and a strong normalisation result for cut-elimination
+ − 98
in classical logic \cite{UrbanZhu08}. It has also been used by Pollack for
+ − 99
formalisations in the locally-nameless approach to binding
+ − 100
\cite{SatoPollack10}.
+ − 101
2989
+ − 102
However, Nominal Isabelle has fared less well in a formalisation of the
+ − 103
algorithm W \cite{UrbanNipkow09}, where types and type-schemes are,
2985
+ − 104
respectively, of the form
2989
+ − 105
2985
+ − 106
\begin{equation}\label{tysch}
+ − 107
\begin{array}{l}
2989
+ − 108
@{text "T ::= x | T \<rightarrow> T"}\hspace{15mm}
2985
+ − 109
@{text "S ::= \<forall>{x\<^isub>1,\<dots>, x\<^isub>n}. T"}
+ − 110
\end{array}
2989
+ − 111
\end{equation}\smallskip
+ − 112
2985
+ − 113
\noindent
+ − 114
and the @{text "\<forall>"}-quantification binds a finite (possibly empty) set of
+ − 115
type-variables. While it is possible to implement this kind of more general
+ − 116
binders by iterating single binders, this leads to a rather clumsy
2989
+ − 117
formalisation of W. The need of iterating single binders is also one reason
+ − 118
why Nominal Isabelle and similar theorem provers that only provide
3002
+ − 119
mechanisms for binding single variables have not fared extremely well with
2989
+ − 120
the more advanced tasks in the POPLmark challenge \cite{challenge05},
+ − 121
because also there one would like to bind multiple variables at once.
2985
+ − 122
+ − 123
Binding multiple variables has interesting properties that cannot be captured
+ − 124
easily by iterating single binders. For example in the case of type-schemes we do not
+ − 125
want to make a distinction about the order of the bound variables. Therefore
3001
+ − 126
we would like to regard in \eqref{ex1} below the first pair of type-schemes as alpha-equivalent,
2985
+ − 127
but assuming that @{text x}, @{text y} and @{text z} are distinct variables,
2989
+ − 128
the second pair should \emph{not} be alpha-equivalent:
+ − 129
2985
+ − 130
\begin{equation}\label{ex1}
+ − 131
@{text "\<forall>{x, y}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{y, x}. y \<rightarrow> x"}\hspace{10mm}
+ − 132
@{text "\<forall>{x, y}. x \<rightarrow> y \<notapprox>\<^isub>\<alpha> \<forall>{z}. z \<rightarrow> z"}
2989
+ − 133
\end{equation}\smallskip
+ − 134
2985
+ − 135
\noindent
2989
+ − 136
Moreover, we like to regard type-schemes as alpha-equivalent, if they differ
2985
+ − 137
only on \emph{vacuous} binders, such as
2989
+ − 138
2985
+ − 139
\begin{equation}\label{ex3}
+ − 140
@{text "\<forall>{x}. x \<rightarrow> y \<approx>\<^isub>\<alpha> \<forall>{x, z}. x \<rightarrow> y"}
2989
+ − 141
\end{equation}\smallskip
+ − 142
2985
+ − 143
\noindent
+ − 144
where @{text z} does not occur freely in the type. In this paper we will
2989
+ − 145
give a general binding mechanism and associated notion of alpha-equivalence
2985
+ − 146
that can be used to faithfully represent this kind of binding in Nominal
2989
+ − 147
Isabelle. The difficulty of finding the right notion for alpha-equivalence
3002
+ − 148
can be appreciated in this case by considering that the definition given for
+ − 149
type-schemes by Leroy in \cite[Page 18--19]{Leroy92} is incorrect (it omits a side-condition).
2985
+ − 150
2989
+ − 151
However, the notion of alpha-equivalence that is preserved by vacuous
2985
+ − 152
binders is not always wanted. For example in terms like
2989
+ − 153
2985
+ − 154
\begin{equation}\label{one}
+ − 155
@{text "\<LET> x = 3 \<AND> y = 2 \<IN> x - y \<END>"}
2989
+ − 156
\end{equation}\smallskip
2985
+ − 157
+ − 158
\noindent
+ − 159
we might not care in which order the assignments @{text "x = 3"} and
2989
+ − 160
\mbox{@{text "y = 2"}} are given, but it would be often unusual (particularly
+ − 161
in strict languages) to regard \eqref{one} as alpha-equivalent with
+ − 162
+ − 163
\[
2985
+ − 164
@{text "\<LET> x = 3 \<AND> y = 2 \<AND> z = foo \<IN> x - y \<END>"}
2989
+ − 165
\]\smallskip
+ − 166
2985
+ − 167
\noindent
+ − 168
Therefore we will also provide a separate binding mechanism for cases in
3023
+ − 169
which the order of binders does not matter, but the `cardinality' of the
2985
+ − 170
binders has to agree.
+ − 171
+ − 172
However, we found that this is still not sufficient for dealing with
+ − 173
language constructs frequently occurring in programming language
+ − 174
research. For example in @{text "\<LET>"}s containing patterns like
2989
+ − 175
2985
+ − 176
\begin{equation}\label{two}
+ − 177
@{text "\<LET> (x, y) = (3, 2) \<IN> x - y \<END>"}
2989
+ − 178
\end{equation}\smallskip
+ − 179
2985
+ − 180
\noindent
+ − 181
we want to bind all variables from the pattern inside the body of the
+ − 182
$\mathtt{let}$, but we also care about the order of these variables, since
2989
+ − 183
we do not want to regard \eqref{two} as alpha-equivalent with
+ − 184
+ − 185
\[
2985
+ − 186
@{text "\<LET> (y, x) = (3, 2) \<IN> x - y \<END>"}
2989
+ − 187
\]\smallskip
+ − 188
2985
+ − 189
\noindent
+ − 190
As a result, we provide three general binding mechanisms each of which binds
+ − 191
multiple variables at once, and let the user chose which one is intended
2989
+ − 192
when formalising a term-calculus.
2985
+ − 193
+ − 194
By providing these general binding mechanisms, however, we have to work
+ − 195
around a problem that has been pointed out by Pottier \cite{Pottier06} and
+ − 196
Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form
2989
+ − 197
+ − 198
\[
2985
+ − 199
@{text "\<LET> x\<^isub>1 = t\<^isub>1 \<AND> \<dots> \<AND> x\<^isub>n = t\<^isub>n \<IN> s \<END>"}
2989
+ − 200
\]\smallskip
+ − 201
2985
+ − 202
\noindent
2989
+ − 203
we care about the information that there are as many bound variables @{text
2985
+ − 204
"x\<^isub>i"} as there are @{text "t\<^isub>i"}. We lose this information if
+ − 205
we represent the @{text "\<LET>"}-constructor by something like
2989
+ − 206
+ − 207
\[
2985
+ − 208
@{text "\<LET> (\<lambda>x\<^isub>1\<dots>x\<^isub>n . s) [t\<^isub>1,\<dots>,t\<^isub>n]"}
2989
+ − 209
\]\smallskip
+ − 210
2985
+ − 211
\noindent
+ − 212
where the notation @{text "\<lambda>_ . _"} indicates that the list of @{text
+ − 213
"x\<^isub>i"} becomes bound in @{text s}. In this representation the term
2989
+ − 214
\mbox{@{text "\<LET> (\<lambda>x . s) [t\<^isub>1, t\<^isub>2]"}} is a perfectly
+ − 215
legal instance, but the lengths of the two lists do not agree. To exclude
+ − 216
such terms, additional predicates about well-formed terms are needed in
+ − 217
order to ensure that the two lists are of equal length. This can result in
+ − 218
very messy reasoning (see for example~\cite{BengtsonParow09}). To avoid
+ − 219
this, we will allow type specifications for @{text "\<LET>"}s as follows
+ − 220
+ − 221
\[
+ − 222
\mbox{\begin{tabular}{r@ {\hspace{2mm}}r@ {\hspace{2mm}}ll}
+ − 223
@{text trm} & @{text "::="} & @{text "\<dots>"} \\
+ − 224
& @{text "|"} & @{text "\<LET> as::assn s::trm"}\hspace{2mm}
3004
+ − 225
\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "s"}\\[1mm]
2989
+ − 226
@{text assn} & @{text "::="} & @{text "\<ANIL>"}\\
+ − 227
& @{text "|"} & @{text "\<ACONS> name trm assn"}
+ − 228
\end{tabular}}
+ − 229
\]\smallskip
+ − 230
2985
+ − 231
\noindent
+ − 232
where @{text assn} is an auxiliary type representing a list of assignments
+ − 233
and @{text bn} an auxiliary function identifying the variables to be bound
+ − 234
by the @{text "\<LET>"}. This function can be defined by recursion over @{text
+ − 235
assn} as follows
2989
+ − 236
+ − 237
\[
3025
+ − 238
@{text "bn(\<ANIL>) ="}~@{term "{}"} \hspace{10mm}
2985
+ − 239
@{text "bn(\<ACONS> x t as) = {x} \<union> bn(as)"}
2989
+ − 240
\]\smallskip
+ − 241
2985
+ − 242
\noindent
+ − 243
The scope of the binding is indicated by labels given to the types, for
+ − 244
example @{text "s::trm"}, and a binding clause, in this case
3004
+ − 245
\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "s"}. This binding
2989
+ − 246
clause states that all the names the function @{text "bn(as)"} returns
+ − 247
should be bound in @{text s}. This style of specifying terms and bindings
+ − 248
is heavily inspired by the syntax of the Ott-tool \cite{ott-jfp}. Our work
+ − 249
extends Ott in several aspects: one is that we support three binding
+ − 250
modes---Ott has only one, namely the one where the order of binders matters.
3000
+ − 251
Another is that our reasoning infrastructure, like strong induction principles
+ − 252
and the notion of free variables, is derived from first principles within
+ − 253
the Isabelle/HOL theorem prover.
2985
+ − 254
+ − 255
However, we will not be able to cope with all specifications that are
3023
+ − 256
allowed by Ott. One reason is that Ott lets the user specify `empty' types
2989
+ − 257
like \mbox{@{text "t ::= t t | \<lambda>x. t"}} where no clause for variables is
+ − 258
given. Arguably, such specifications make some sense in the context of Coq's
+ − 259
type theory (which Ott supports), but not at all in a HOL-based environment
+ − 260
where every datatype must have a non-empty set-theoretic model
+ − 261
\cite{Berghofer99}. Another reason is that we establish the reasoning
+ − 262
infrastructure for alpha-\emph{equated} terms. In contrast, Ott produces a
+ − 263
reasoning infrastructure in Isabelle/HOL for \emph{non}-alpha-equated, or
3025
+ − 264
`raw', terms. While our alpha-equated terms and the `raw' terms produced by
2989
+ − 265
Ott use names for bound variables, there is a key difference: working with
+ − 266
alpha-equated terms means, for example, that the two type-schemes
2985
+ − 267
2989
+ − 268
\[
2985
+ − 269
@{text "\<forall>{x}. x \<rightarrow> y = \<forall>{x, z}. x \<rightarrow> y"}
2989
+ − 270
\]\smallskip
2985
+ − 271
+ − 272
\noindent
2989
+ − 273
are not just alpha-equal, but actually \emph{equal}! As a result, we can
+ − 274
only support specifications that make sense on the level of alpha-equated
2985
+ − 275
terms (offending specifications, which for example bind a variable according
+ − 276
to a variable bound somewhere else, are not excluded by Ott, but we have
+ − 277
to).
+ − 278
2989
+ − 279
Our insistence on reasoning with alpha-equated terms comes from the
2985
+ − 280
wealth of experience we gained with the older version of Nominal Isabelle:
2989
+ − 281
for non-trivial properties, reasoning with alpha-equated terms is much
3025
+ − 282
easier than reasoning with `raw' terms. The fundamental reason for this is
2985
+ − 283
that the HOL-logic underlying Nominal Isabelle allows us to replace
3023
+ − 284
`equals-by-equals'. In contrast, replacing
+ − 285
`alpha-equals-by-alpha-equals' in a representation based on `raw' terms
2985
+ − 286
requires a lot of extra reasoning work.
+ − 287
2989
+ − 288
Although in informal settings a reasoning infrastructure for alpha-equated
2985
+ − 289
terms is nearly always taken for granted, establishing it automatically in
+ − 290
Isabelle/HOL is a rather non-trivial task. For every
+ − 291
specification we will need to construct type(s) containing as elements the
2989
+ − 292
alpha-equated terms. To do so, we use the standard HOL-technique of defining
2985
+ − 293
a new type by identifying a non-empty subset of an existing type. The
+ − 294
construction we perform in Isabelle/HOL can be illustrated by the following picture:
2989
+ − 295
3008
+ − 296
\begin{equation}\label{picture}
2989
+ − 297
\mbox{\begin{tikzpicture}[scale=1.1]
2985
+ − 298
%\draw[step=2mm] (-4,-1) grid (4,1);
+ − 299
+ − 300
\draw[very thick] (0.7,0.4) circle (4.25mm);
+ − 301
\draw[rounded corners=1mm, very thick] ( 0.0,-0.8) rectangle ( 1.8, 0.9);
+ − 302
\draw[rounded corners=1mm, very thick] (-1.95,0.85) rectangle (-2.85,-0.05);
+ − 303
+ − 304
\draw (-2.0, 0.845) -- (0.7,0.845);
+ − 305
\draw (-2.0,-0.045) -- (0.7,-0.045);
+ − 306
3022
+ − 307
\draw ( 0.7, 0.5) node {\footnotesize\begin{tabular}{@ {}c@ {}}$\alpha$-\\[-1mm]classes\end{tabular}};
+ − 308
\draw (-2.4, 0.5) node {\footnotesize\begin{tabular}{@ {}c@ {}}$\alpha$-eq.\\[-1mm]terms\end{tabular}};
2985
+ − 309
\draw (1.8, 0.48) node[right=-0.1mm]
2989
+ − 310
{\small\begin{tabular}{@ {}l@ {}}existing\\[-1mm] type\\ (sets of raw terms)\end{tabular}};
2985
+ − 311
\draw (0.9, -0.35) node {\footnotesize\begin{tabular}{@ {}l@ {}}non-empty\\[-1mm]subset\end{tabular}};
2989
+ − 312
\draw (-3.25, 0.55) node {\small\begin{tabular}{@ {}l@ {}}new\\[-1mm]type\end{tabular}};
2985
+ − 313
+ − 314
\draw[<->, very thick] (-1.8, 0.3) -- (-0.1,0.3);
+ − 315
\draw (-0.95, 0.3) node[above=0mm] {\footnotesize{}isomorphism};
+ − 316
2989
+ − 317
\end{tikzpicture}}
3008
+ − 318
\end{equation}\smallskip
2989
+ − 319
2985
+ − 320
\noindent
+ − 321
We take as the starting point a definition of raw terms (defined as a
2989
+ − 322
datatype in Isabelle/HOL); then identify the alpha-equivalence classes in
+ − 323
the type of sets of raw terms according to our alpha-equivalence relation,
+ − 324
and finally define the new type as these alpha-equivalence classes (the
+ − 325
non-emptiness requirement is always satisfied whenever the raw terms are
+ − 326
definable as datatype in Isabelle/HOL and our relation for alpha-equivalence
+ − 327
is an equivalence relation).
2985
+ − 328
+ − 329
The fact that we obtain an isomorphism between the new type and the
+ − 330
non-empty subset shows that the new type is a faithful representation of
2989
+ − 331
alpha-equated terms. That is not the case for example for terms using the
2985
+ − 332
locally nameless representation of binders \cite{McKinnaPollack99}: in this
3023
+ − 333
representation there are `junk' terms that need to be excluded by
2985
+ − 334
reasoning about a well-formedness predicate.
+ − 335
+ − 336
The problem with introducing a new type in Isabelle/HOL is that in order to
3023
+ − 337
be useful, a reasoning infrastructure needs to be `lifted' from the
2985
+ − 338
underlying subset to the new type. This is usually a tricky and arduous
2990
+ − 339
task. To ease it, we re-implemented in Isabelle/HOL \cite{KaliszykUrban11}
+ − 340
the quotient package described by Homeier \cite{Homeier05} for the HOL4
+ − 341
system. This package allows us to lift definitions and theorems involving
+ − 342
raw terms to definitions and theorems involving alpha-equated terms. For
+ − 343
example if we define the free-variable function over raw lambda-terms
2991
+ − 344
as follows
2985
+ − 345
2990
+ − 346
\[
+ − 347
\mbox{\begin{tabular}{l@ {\hspace{1mm}}r@ {\hspace{1mm}}l}
+ − 348
@{text "fv(x)"} & @{text "\<equiv>"} & @{text "{x}"}\\
+ − 349
@{text "fv(t\<^isub>1 t\<^isub>2)"} & @{text "\<equiv>"} & @{text "fv(t\<^isub>1) \<union> fv(t\<^isub>2)"}\\
+ − 350
@{text "fv(\<lambda>x.t)"} & @{text "\<equiv>"} & @{text "fv(t) - {x}"}
+ − 351
\end{tabular}}
+ − 352
\]\smallskip
2985
+ − 353
+ − 354
\noindent
+ − 355
then with the help of the quotient package we can obtain a function @{text "fv\<^sup>\<alpha>"}
3000
+ − 356
operating on quotients, that is alpha-equivalence classes of lambda-terms. This
2985
+ − 357
lifted function is characterised by the equations
+ − 358
2990
+ − 359
\[
+ − 360
\mbox{\begin{tabular}{l@ {\hspace{1mm}}r@ {\hspace{1mm}}l}
+ − 361
@{text "fv\<^sup>\<alpha>(x)"} & @{text "="} & @{text "{x}"}\\
+ − 362
@{text "fv\<^sup>\<alpha>(t\<^isub>1 t\<^isub>2)"} & @{text "="} & @{text "fv\<^sup>\<alpha>(t\<^isub>1) \<union> fv\<^sup>\<alpha>(t\<^isub>2)"}\\
+ − 363
@{text "fv\<^sup>\<alpha>(\<lambda>x.t)"} & @{text "="} & @{text "fv\<^sup>\<alpha>(t) - {x}"}
+ − 364
\end{tabular}}
+ − 365
\]\smallskip
2985
+ − 366
+ − 367
\noindent
+ − 368
(Note that this means also the term-constructors for variables, applications
+ − 369
and lambda are lifted to the quotient level.) This construction, of course,
2989
+ − 370
only works if alpha-equivalence is indeed an equivalence relation, and the
3023
+ − 371
`raw' definitions and theorems are respectful w.r.t.~alpha-equivalence.
2985
+ − 372
For example, we will not be able to lift a bound-variable function. Although
+ − 373
this function can be defined for raw terms, it does not respect
2989
+ − 374
alpha-equivalence and therefore cannot be lifted.
2985
+ − 375
To sum up, every lifting
+ − 376
of theorems to the quotient level needs proofs of some respectfulness
+ − 377
properties (see \cite{Homeier05}). In the paper we show that we are able to
+ − 378
automate these proofs and as a result can automatically establish a reasoning
2989
+ − 379
infrastructure for alpha-equated terms.\smallskip
2985
+ − 380
+ − 381
The examples we have in mind where our reasoning infrastructure will be
3003
+ − 382
helpful include the term language of Core-Haskell (see
2991
+ − 383
Figure~\ref{corehas}). This term language involves patterns that have lists
+ − 384
of type-, coercion- and term-variables, all of which are bound in @{text
+ − 385
"\<CASE>"}-expressions. In these patterns we do not know in advance how many
3002
+ − 386
variables need to be bound. Another example is the algorithm W,
3000
+ − 387
which includes multiple binders in type-schemes.\medskip
2985
+ − 388
+ − 389
\noindent
3021
+ − 390
{\bf Contributions:} We provide three new definitions for when terms
2989
+ − 391
involving general binders are alpha-equivalent. These definitions are
2985
+ − 392
inspired by earlier work of Pitts \cite{Pitts04}. By means of automatic
3021
+ − 393
proofs, we establish a reasoning infrastructure for alpha-equated terms,
+ − 394
including properties about support, freshness and equality conditions for
+ − 395
alpha-equated terms. We are also able to automatically derive strong
2985
+ − 396
induction principles that have the variable convention already built in.
3025
+ − 397
For this we simplify the earlier automated proofs by using the proving tools
3021
+ − 398
from the function package~\cite{Krauss09} of Isabelle/HOL. The method
+ − 399
behind our specification of general binders is taken from the Ott-tool, but
+ − 400
we introduce crucial restrictions, and also extensions, so that our
+ − 401
specifications make sense for reasoning about alpha-equated terms. The main
+ − 402
improvement over Ott is that we introduce three binding modes (only one is
+ − 403
present in Ott), provide formalised definitions for alpha-equivalence and
2985
+ − 404
for free variables of our terms, and also derive a reasoning infrastructure
3023
+ − 405
for our specifications from `first principles' inside a theorem prover.
2985
+ − 406
+ − 407
3021
+ − 408
\begin{figure}[t]
2991
+ − 409
\begin{boxedminipage}{\linewidth}
+ − 410
\begin{center}
+ − 411
\begin{tabular}{@ {\hspace{8mm}}r@ {\hspace{2mm}}r@ {\hspace{2mm}}l}
+ − 412
\multicolumn{3}{@ {}l}{Type Kinds}\\
+ − 413
@{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\smallskip\\
+ − 414
\multicolumn{3}{@ {}l}{Coercion Kinds}\\
+ − 415
@{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\smallskip\\
+ − 416
\multicolumn{3}{@ {}l}{Types}\\
+ − 417
@{text "\<sigma>"} & @{text "::="} & @{text "a | T | \<sigma>\<^isub>1 \<sigma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<sigma>"}}$@{text "\<^sup>n"}
+ − 418
@{text "| \<forall>a:\<kappa>. \<sigma> | \<iota> \<Rightarrow> \<sigma>"}\smallskip\\
+ − 419
\multicolumn{3}{@ {}l}{Coercion Types}\\
+ − 420
@{text "\<gamma>"} & @{text "::="} & @{text "c | C | \<gamma>\<^isub>1 \<gamma>\<^isub>2 | S\<^isub>n"}$\;\overline{@{text "\<gamma>"}}$@{text "\<^sup>n"}
+ − 421
@{text "| \<forall>c:\<iota>. \<gamma> | \<iota> \<Rightarrow> \<gamma> | refl \<sigma> | sym \<gamma> | \<gamma>\<^isub>1 \<circ> \<gamma>\<^isub>2"}\\
+ − 422
& @{text "|"} & @{text "\<gamma> @ \<sigma> | left \<gamma> | right \<gamma> | \<gamma>\<^isub>1 \<sim> \<gamma>\<^isub>2 | rightc \<gamma> | leftc \<gamma> | \<gamma>\<^isub>1 \<triangleright> \<gamma>\<^isub>2"}\smallskip\\
+ − 423
\multicolumn{3}{@ {}l}{Terms}\\
+ − 424
@{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>c:\<iota>. e | e \<sigma> | e \<gamma> | \<lambda>x:\<sigma>. e | e\<^isub>1 e\<^isub>2"}\\
+ − 425
& @{text "|"} & @{text "\<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2 | \<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\smallskip\\
+ − 426
\multicolumn{3}{@ {}l}{Patterns}\\
+ − 427
@{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "c:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\smallskip\\
+ − 428
\multicolumn{3}{@ {}l}{Constants}\\
+ − 429
& @{text C} & coercion constants\\
+ − 430
& @{text T} & value type constructors\\
+ − 431
& @{text "S\<^isub>n"} & n-ary type functions (which need to be fully applied)\\
+ − 432
& @{text K} & data constructors\smallskip\\
+ − 433
\multicolumn{3}{@ {}l}{Variables}\\
+ − 434
& @{text a} & type variables\\
+ − 435
& @{text c} & coercion variables\\
+ − 436
& @{text x} & term variables\\
+ − 437
\end{tabular}
+ − 438
\end{center}
+ − 439
\end{boxedminipage}
+ − 440
\caption{The System @{text "F\<^isub>C"}
+ − 441
\cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this
+ − 442
version of @{text "F\<^isub>C"} we made a modification by separating the
+ − 443
grammars for type kinds and coercion kinds, as well as for types and coercion
+ − 444
types. For this paper the interesting term-constructor is @{text "\<CASE>"},
3041
+ − 445
which binds multiple type-, coercion- and term-variables (the overlines stand for lists).\label{corehas}}
2991
+ − 446
\end{figure}
2985
+ − 447
*}
+ − 448
+ − 449
section {* A Short Review of the Nominal Logic Work *}
+ − 450
+ − 451
text {*
+ − 452
At its core, Nominal Isabelle is an adaption of the nominal logic work by
+ − 453
Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in
+ − 454
\cite{HuffmanUrban10} (including proofs). We shall briefly review this work
+ − 455
to aid the description of what follows.
+ − 456
+ − 457
Two central notions in the nominal logic work are sorted atoms and
3001
+ − 458
sort-respecting permutations of atoms. We will use the letters @{text "a, b,
3002
+ − 459
c, \<dots>"} to stand for atoms and @{text "\<pi>, \<pi>\<^isub>1, \<dots>"} to stand for permutations,
3001
+ − 460
which in Nominal Isabelle have type @{typ perm}. The purpose of atoms is to
+ − 461
represent variables, be they bound or free. The sorts of atoms can be used
+ − 462
to represent different kinds of variables, such as the term-, coercion- and
+ − 463
type-variables in Core-Haskell. It is assumed that there is an infinite
+ − 464
supply of atoms for each sort. In the interest of brevity, we shall restrict
+ − 465
ourselves in what follows to only one sort of atoms.
2985
+ − 466
+ − 467
Permutations are bijective functions from atoms to atoms that are
+ − 468
the identity everywhere except on a finite number of atoms. There is a
+ − 469
two-place permutation operation written
+ − 470
@{text "_ \<bullet> _ :: perm \<Rightarrow> \<beta> \<Rightarrow> \<beta>"}
+ − 471
where the generic type @{text "\<beta>"} is the type of the object
+ − 472
over which the permutation
+ − 473
acts. In Nominal Isabelle, the identity permutation is written as @{term "0::perm"},
3000
+ − 474
the composition of two permutations @{term "\<pi>\<^isub>1"} and @{term "\<pi>\<^isub>2"} as \mbox{@{term "\<pi>\<^isub>1 + \<pi>\<^isub>2"}},
+ − 475
and the inverse permutation of @{term "\<pi>"} as @{text "- \<pi>"}. The permutation
3002
+ − 476
operation is defined over Isabelle/HOL's type-hierarchy \cite{HuffmanUrban10};
3011
+ − 477
for example permutations acting on atoms, products, lists, permutations, sets,
+ − 478
functions and booleans are given by:
2985
+ − 479
+ − 480
\begin{equation}\label{permute}
+ − 481
\mbox{\begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}}
+ − 482
\begin{tabular}{@ {}l@ {}}
3011
+ − 483
@{text "\<pi> \<bullet> a \<equiv> \<pi> a"}\\
3000
+ − 484
@{thm permute_prod.simps[where p="\<pi>", no_vars, THEN eq_reflection]}\\[2mm]
+ − 485
@{thm permute_list.simps(1)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
+ − 486
@{thm permute_list.simps(2)[where p="\<pi>", no_vars, THEN eq_reflection]}\\
2985
+ − 487
\end{tabular} &
+ − 488
\begin{tabular}{@ {}l@ {}}
3011
+ − 489
@{thm permute_perm_def[where p="\<pi>" and q="\<pi>'", no_vars, THEN eq_reflection]}\\
3000
+ − 490
@{thm permute_set_eq[where p="\<pi>", no_vars, THEN eq_reflection]}\\
+ − 491
@{text "\<pi> \<bullet> f \<equiv> \<lambda>x. \<pi> \<bullet> (f (- \<pi> \<bullet> x))"}\\
+ − 492
@{thm permute_bool_def[where p="\<pi>", no_vars, THEN eq_reflection]}
2985
+ − 493
\end{tabular}
+ − 494
\end{tabular}}
3000
+ − 495
\end{equation}\smallskip
2985
+ − 496
+ − 497
\noindent
+ − 498
Concrete permutations in Nominal Isabelle are built up from swappings,
+ − 499
written as \mbox{@{text "(a b)"}}, which are permutations that behave
+ − 500
as follows:
2991
+ − 501
3000
+ − 502
\[
2985
+ − 503
@{text "(a b) = \<lambda>c. if a = c then b else if b = c then a else c"}
3000
+ − 504
\]\smallskip
2985
+ − 505
+ − 506
The most original aspect of the nominal logic work of Pitts is a general
3023
+ − 507
definition for the notion of the `set of free variables of an object @{text
+ − 508
"x"}'. This notion, written @{term "supp x"}, is general in the sense that
2989
+ − 509
it applies not only to lambda-terms (alpha-equated or not), but also to lists,
3008
+ − 510
products, sets and even functions. Its definition depends only on the
2985
+ − 511
permutation operation and on the notion of equality defined for the type of
+ − 512
@{text x}, namely:
2991
+ − 513
2985
+ − 514
\begin{equation}\label{suppdef}
+ − 515
@{thm supp_def[no_vars, THEN eq_reflection]}
3001
+ − 516
\end{equation}\smallskip
2985
+ − 517
+ − 518
\noindent
+ − 519
There is also the derived notion for when an atom @{text a} is \emph{fresh}
3000
+ − 520
for an @{text x}, defined as
+ − 521
+ − 522
\[
+ − 523
@{thm fresh_def[no_vars]}
+ − 524
\]\smallskip
+ − 525
+ − 526
\noindent
2985
+ − 527
We use for sets of atoms the abbreviation
+ − 528
@{thm (lhs) fresh_star_def[no_vars]}, defined as
+ − 529
@{thm (rhs) fresh_star_def[no_vars]}.
+ − 530
A striking consequence of these definitions is that we can prove
+ − 531
without knowing anything about the structure of @{term x} that
+ − 532
swapping two fresh atoms, say @{text a} and @{text b}, leaves
3000
+ − 533
@{text x} unchanged, namely
2985
+ − 534
2989
+ − 535
\begin{prop}\label{swapfreshfresh}
3000
+ − 536
If @{thm (prem 1) swap_fresh_fresh[no_vars]} and @{thm (prem 2) swap_fresh_fresh[no_vars]}
3001
+ − 537
then @{thm (concl) swap_fresh_fresh[no_vars]}.
2989
+ − 538
\end{prop}
2985
+ − 539
+ − 540
While often the support of an object can be relatively easily
+ − 541
described, for example for atoms, products, lists, function applications,
+ − 542
booleans and permutations as follows
+ − 543
3004
+ − 544
\begin{equation}\label{supps}\mbox{
2985
+ − 545
\begin{tabular}{c@ {\hspace{10mm}}c}
+ − 546
\begin{tabular}{rcl}
+ − 547
@{term "supp a"} & $=$ & @{term "{a}"}\\
+ − 548
@{term "supp (x, y)"} & $=$ & @{term "supp x \<union> supp y"}\\
+ − 549
@{term "supp []"} & $=$ & @{term "{}"}\\
+ − 550
@{term "supp (x#xs)"} & $=$ & @{term "supp x \<union> supp xs"}\\
+ − 551
\end{tabular}
+ − 552
&
+ − 553
\begin{tabular}{rcl}
+ − 554
@{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp f \<union> supp x"}\\
+ − 555
@{term "supp b"} & $=$ & @{term "{}"}\\
3000
+ − 556
@{term "supp \<pi>"} & $=$ & @{term "{a. \<pi> \<bullet> a \<noteq> a}"}
2985
+ − 557
\end{tabular}
3000
+ − 558
\end{tabular}}
3004
+ − 559
\end{equation}\smallskip
2985
+ − 560
+ − 561
\noindent
+ − 562
in some cases it can be difficult to characterise the support precisely, and
3000
+ − 563
only an approximation can be established (as for function applications
+ − 564
above). Reasoning about such approximations can be simplified with the
+ − 565
notion \emph{supports}, defined as follows:
2985
+ − 566
2989
+ − 567
\begin{defi}
3001
+ − 568
A set @{text S} \emph{supports} @{text x}, if for all atoms @{text a} and @{text b}
2985
+ − 569
not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}.
2989
+ − 570
\end{defi}
2985
+ − 571
+ − 572
\noindent
+ − 573
The main point of @{text supports} is that we can establish the following
+ − 574
two properties.
+ − 575
2989
+ − 576
\begin{prop}\label{supportsprop}
3001
+ − 577
Given a set @{text "as"} of atoms.\\
+ − 578
{\it (i)} If @{thm (prem 1) supp_is_subset[where S="as", no_vars]}
+ − 579
and @{thm (prem 2) supp_is_subset[where S="as", no_vars]} then
+ − 580
@{thm (concl) supp_is_subset[where S="as", no_vars]}.\\
2985
+ − 581
{\it (ii)} @{thm supp_supports[no_vars]}.
2989
+ − 582
\end{prop}
2985
+ − 583
+ − 584
Another important notion in the nominal logic work is \emph{equivariance}.
+ − 585
For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant
+ − 586
it is required that every permutation leaves @{text f} unchanged, that is
+ − 587
+ − 588
\begin{equation}\label{equivariancedef}
3001
+ − 589
@{term "\<forall>\<pi>. \<pi> \<bullet> f = f"}
+ − 590
\end{equation}\smallskip
2985
+ − 591
+ − 592
\noindent or equivalently that a permutation applied to the application
+ − 593
@{text "f x"} can be moved to the argument @{text x}. That means for equivariant
3001
+ − 594
functions @{text f}, we have for all permutations @{text "\<pi>"}:
2985
+ − 595
+ − 596
\begin{equation}\label{equivariance}
3001
+ − 597
@{text "\<pi> \<bullet> f = f"} \;\;\;\;\textit{if and only if}\;\;\;\;
3003
+ − 598
@{text "\<forall>x. \<pi> \<bullet> (f x) = f (\<pi> \<bullet> x)"}
3001
+ − 599
\end{equation}\smallskip
2985
+ − 600
+ − 601
\noindent
+ − 602
From property \eqref{equivariancedef} and the definition of @{text supp}, we
+ − 603
can easily deduce that equivariant functions have empty support. There is
+ − 604
also a similar notion for equivariant relations, say @{text R}, namely the property
+ − 605
that
+ − 606
3025
+ − 607
\[
3001
+ − 608
@{text "x R y"} \;\;\textit{implies}\;\; @{text "(\<pi> \<bullet> x) R (\<pi> \<bullet> y)"}
3025
+ − 609
\]\smallskip
2985
+ − 610
+ − 611
Using freshness, the nominal logic work provides us with general means for renaming
+ − 612
binders.
+ − 613
+ − 614
\noindent
+ − 615
While in the older version of Nominal Isabelle, we used extensively
3001
+ − 616
Property~\ref{swapfreshfresh} to rename single binders, this property
2985
+ − 617
proved too unwieldy for dealing with multiple binders. For such binders the
+ − 618
following generalisations turned out to be easier to use.
+ − 619
2989
+ − 620
\begin{prop}\label{supppermeq}
3001
+ − 621
@{thm[mode=IfThen] supp_perm_eq[where p="\<pi>", no_vars]}
2989
+ − 622
\end{prop}
2985
+ − 623
2989
+ − 624
\begin{prop}\label{avoiding}
2985
+ − 625
For a finite set @{text as} and a finitely supported @{text x} with
+ − 626
@{term "as \<sharp>* x"} and also a finitely supported @{text c}, there
3001
+ − 627
exists a permutation @{text "\<pi>"} such that @{term "(\<pi> \<bullet> as) \<sharp>* c"} and
+ − 628
@{term "supp x \<sharp>* \<pi>"}.
2989
+ − 629
\end{prop}
2985
+ − 630
+ − 631
\noindent
+ − 632
The idea behind the second property is that given a finite set @{text as}
+ − 633
of binders (being bound, or fresh, in @{text x} is ensured by the
3001
+ − 634
assumption @{term "as \<sharp>* x"}), then there exists a permutation @{text "\<pi>"} such that
+ − 635
the renamed binders @{term "\<pi> \<bullet> as"} avoid @{text c} (which can be arbitrarily chosen
+ − 636
as long as it is finitely supported) and also @{text "\<pi>"} does not affect anything
+ − 637
in the support of @{text x} (that is @{term "supp x \<sharp>* \<pi>"}). The last
3023
+ − 638
fact and Property~\ref{supppermeq} allow us to `rename' just the binders
3011
+ − 639
@{text as} in @{text x}, because @{term "\<pi> \<bullet> x = x"}.
+ − 640
+ − 641
Note that @{term "supp x \<sharp>* \<pi>"}
3004
+ − 642
is equivalent with @{term "supp \<pi> \<sharp>* x"}, which means we could also formulate
3021
+ − 643
Propositions \ref{supppermeq} and \ref{avoiding} in the other `direction'; however the
3004
+ − 644
reasoning infrastructure of Nominal Isabelle is set up so that it provides more
3011
+ − 645
automation for the formulation given above.
2985
+ − 646
+ − 647
Most properties given in this section are described in detail in \cite{HuffmanUrban10}
+ − 648
and all are formalised in Isabelle/HOL. In the next sections we will make
3001
+ − 649
use of these properties in order to define alpha-equivalence in
2985
+ − 650
the presence of multiple binders.
+ − 651
*}
+ − 652
+ − 653
3016
+ − 654
section {* Abstractions\label{sec:binders} *}
2985
+ − 655
+ − 656
text {*
+ − 657
In Nominal Isabelle, the user is expected to write down a specification of a
+ − 658
term-calculus and then a reasoning infrastructure is automatically derived
+ − 659
from this specification (remember that Nominal Isabelle is a definitional
+ − 660
extension of Isabelle/HOL, which does not introduce any new axioms).
+ − 661
+ − 662
In order to keep our work with deriving the reasoning infrastructure
+ − 663
manageable, we will wherever possible state definitions and perform proofs
3023
+ − 664
on the `user-level' of Isabelle/HOL, as opposed to writing custom ML-code that
2985
+ − 665
generates them anew for each specification.
+ − 666
To that end, we will consider
+ − 667
first pairs @{text "(as, x)"} of type @{text "(atom set) \<times> \<beta>"}. These pairs
+ − 668
are intended to represent the abstraction, or binding, of the set of atoms @{text
+ − 669
"as"} in the body @{text "x"}.
+ − 670
+ − 671
The first question we have to answer is when two pairs @{text "(as, x)"} and
2989
+ − 672
@{text "(bs, y)"} are alpha-equivalent? (For the moment we are interested in
+ − 673
the notion of alpha-equivalence that is \emph{not} preserved by adding
2985
+ − 674
vacuous binders.) To answer this question, we identify four conditions: {\it (i)}
+ − 675
given a free-atom function @{text "fa"} of type \mbox{@{text "\<beta> \<Rightarrow> atom
+ − 676
set"}}, then @{text x} and @{text y} need to have the same set of free
3001
+ − 677
atoms; moreover there must be a permutation @{text \<pi>} such that {\it
+ − 678
(ii)} @{text \<pi>} leaves the free atoms of @{text x} and @{text y} unchanged, but
3023
+ − 679
{\it (iii)} `moves' their bound names so that we obtain modulo a relation,
2985
+ − 680
say \mbox{@{text "_ R _"}}, two equivalent terms. We also require that {\it (iv)}
3001
+ − 681
@{text \<pi>} makes the sets of abstracted atoms @{text as} and @{text bs} equal. The
3010
+ − 682
requirements {\it (i)} to {\it (iv)} can be stated formally as:
3001
+ − 683
+ − 684
\begin{defi}[Alpha-Equivalence for Set-Bindings]\label{alphaset}\mbox{}\\
+ − 685
\begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}
3006
+ − 686
@{term "alpha_set_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} &
+ − 687
\multicolumn{2}{@ {}l}{if there exists a @{text "\<pi>"} such that:}\\
3001
+ − 688
& \mbox{\it (i)} & @{term "fa(x) - as = fa(y) - bs"}\\
+ − 689
& \mbox{\it (ii)} & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\
+ − 690
& \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"} \\
+ − 691
& \mbox{\it (iv)} & @{term "(\<pi> \<bullet> as) = bs"} \\
+ − 692
\end{tabular}
+ − 693
\end{defi}
+ − 694
2985
+ − 695
\noindent
3006
+ − 696
Note that the relation is
2985
+ − 697
dependent on a free-atom function @{text "fa"} and a relation @{text
+ − 698
"R"}. The reason for this extra generality is that we will use
3025
+ − 699
$\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ for both raw terms and
3013
+ − 700
alpha-equated terms. In
2985
+ − 701
the latter case, @{text R} will be replaced by equality @{text "="} and we
+ − 702
will prove that @{text "fa"} is equal to @{text "supp"}.
+ − 703
3001
+ − 704
Definition \ref{alphaset} does not make any distinction between the
2989
+ − 705
order of abstracted atoms. If we want this, then we can define alpha-equivalence
2985
+ − 706
for pairs of the form \mbox{@{text "(as, x)"}} with type @{text "(atom list) \<times> \<beta>"}
+ − 707
as follows
3001
+ − 708
+ − 709
\begin{defi}[Alpha-Equivalence for List-Bindings]\label{alphalist}\mbox{}\\
+ − 710
\begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}
3006
+ − 711
@{term "alpha_lst_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} &
+ − 712
\multicolumn{2}{@ {}l}{if there exists a @{text "\<pi>"} such that:}\\
3001
+ − 713
& \mbox{\it (i)} & @{term "fa(x) - (set as) = fa(y) - (set bs)"}\\
+ − 714
& \mbox{\it (ii)} & @{term "(fa(x) - set as) \<sharp>* \<pi>"}\\
+ − 715
& \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"}\\
+ − 716
& \mbox{\it (iv)} & @{term "(\<pi> \<bullet> as) = bs"}\\
+ − 717
\end{tabular}
+ − 718
\end{defi}
+ − 719
2985
+ − 720
\noindent
+ − 721
where @{term set} is the function that coerces a list of atoms into a set of atoms.
+ − 722
Now the last clause ensures that the order of the binders matters (since @{text as}
+ − 723
and @{text bs} are lists of atoms).
+ − 724
+ − 725
If we do not want to make any difference between the order of binders \emph{and}
3021
+ − 726
also allow vacuous binders, that means according to Pitts~\cite{Pitts04}
3044
+ − 727
\emph{restrict} atoms, then we keep sets of binders, but drop
3001
+ − 728
condition {\it (iv)} in Definition~\ref{alphaset}:
+ − 729
+ − 730
\begin{defi}[Alpha-Equivalence for Set+-Bindings]\label{alphares}\mbox{}\\
+ − 731
\begin{tabular}{@ {\hspace{10mm}}l@ {\hspace{5mm}}rl}
3006
+ − 732
@{term "alpha_res_ex (as, x) R fa (bs, y)"}\hspace{2mm}@{text "\<equiv>"} &
+ − 733
\multicolumn{2}{@ {}l}{if there exists a @{text "\<pi>"} such that:}\\
3001
+ − 734
& \mbox{\it (i)} & @{term "fa(x) - as = fa(y) - bs"}\\
+ − 735
& \mbox{\it (ii)} & @{term "(fa(x) - as) \<sharp>* \<pi>"}\\
+ − 736
& \mbox{\it (iii)} & @{text "(\<pi> \<bullet> x) R y"}\\
+ − 737
\end{tabular}
+ − 738
\end{defi}
+ − 739
2985
+ − 740
+ − 741
It might be useful to consider first some examples how these definitions
2989
+ − 742
of alpha-equivalence pan out in practice. For this consider the case of
2985
+ − 743
abstracting a set of atoms over types (as in type-schemes). We set
+ − 744
@{text R} to be the usual equality @{text "="} and for @{text "fa(T)"} we
+ − 745
define
3001
+ − 746
+ − 747
\[
3044
+ − 748
@{text "fa(x) \<equiv> {x}"} \hspace{10mm} @{text "fa(T\<^isub>1 \<rightarrow> T\<^isub>2) \<equiv> fa(T\<^isub>1) \<union> fa(T\<^isub>2)"}
3001
+ − 749
\]\smallskip
2985
+ − 750
+ − 751
\noindent
+ − 752
Now recall the examples shown in \eqref{ex1} and
+ − 753
\eqref{ex3}. It can be easily checked that @{text "({x, y}, x \<rightarrow> y)"} and
2989
+ − 754
@{text "({y, x}, y \<rightarrow> x)"} are alpha-equivalent according to
3001
+ − 755
$\approx_{\,\textit{set}}$ and $\approx_{\,\textit{set+}}$ by taking @{text "\<pi>"} to
2985
+ − 756
be the swapping @{term "(x \<rightleftharpoons> y)"}. In case of @{text "x \<noteq> y"}, then @{text
+ − 757
"([x, y], x \<rightarrow> y)"} $\not\approx_{\,\textit{list}}$ @{text "([y, x], x \<rightarrow> y)"}
+ − 758
since there is no permutation that makes the lists @{text "[x, y]"} and
+ − 759
@{text "[y, x]"} equal, and also leaves the type \mbox{@{text "x \<rightarrow> y"}}
+ − 760
unchanged. Another example is @{text "({x}, x)"} $\approx_{\,\textit{set+}}$
3001
+ − 761
@{text "({x, y}, x)"} which holds by taking @{text "\<pi>"} to be the identity
2985
+ − 762
permutation. However, if @{text "x \<noteq> y"}, then @{text "({x}, x)"}
+ − 763
$\not\approx_{\,\textit{set}}$ @{text "({x, y}, x)"} since there is no
+ − 764
permutation that makes the sets @{text "{x}"} and @{text "{x, y}"} equal
+ − 765
(similarly for $\approx_{\,\textit{list}}$). It can also relatively easily be
2989
+ − 766
shown that all three notions of alpha-equivalence coincide, if we only
3037
+ − 767
abstract a single atom. In this case they also agree with the alpha-equivalence
3038
+ − 768
used in older versions of Nominal Isabelle \cite{Urban08}.\footnote{We omit a
+ − 769
proof of this fact since the details are hairy and not really important for the
+ − 770
purpose of this paper.}
2985
+ − 771
3021
+ − 772
In the rest of this section we are going to show that the alpha-equivalences
3025
+ − 773
really lead to abstractions where some atoms are bound (or more precisely
3021
+ − 774
removed from the support). For this we will consider three abstraction
+ − 775
types that are quotients of the relations
3001
+ − 776
2985
+ − 777
\begin{equation}
3002
+ − 778
\begin{array}{r}
3011
+ − 779
@{term "alpha_set_ex (as, x) equal supp (bs, y)"}\smallskip\\
+ − 780
@{term "alpha_res_ex (as, x) equal supp (bs, y)"}\smallskip\\
+ − 781
@{term "alpha_lst_ex (as, x) equal supp (bs, y)"}\\
3001
+ − 782
\end{array}
3002
+ − 783
\end{equation}\smallskip
2985
+ − 784
+ − 785
\noindent
3007
+ − 786
Note that in these relation we replaced the free-atom function @{text "fa"}
+ − 787
with @{term "supp"} and the relation @{text R} with equality. We can show
3013
+ − 788
the following two properties:
3007
+ − 789
2989
+ − 790
\begin{lem}\label{alphaeq}
3011
+ − 791
The relations $\approx_{\,\textit{set}}^{=, \textit{supp}}$,
+ − 792
$\approx_{\,\textit{set+}}^{=, \textit{supp}}$
+ − 793
and $\approx_{\,\textit{list}}^{=, \textit{supp}}$ are
+ − 794
equivalence relations and equivariant.
2989
+ − 795
\end{lem}
2985
+ − 796
+ − 797
\begin{proof}
3001
+ − 798
Reflexivity is by taking @{text "\<pi>"} to be @{text "0"}. For symmetry we have
3011
+ − 799
a permutation @{text "\<pi>"} and for the proof obligation take @{term "-
+ − 800
\<pi>"}. In case of transitivity, we have two permutations @{text "\<pi>\<^isub>1"}
+ − 801
and @{text "\<pi>\<^isub>2"}, and for the proof obligation use @{text
+ − 802
"\<pi>\<^isub>1 + \<pi>\<^isub>2"}. Equivariance means @{term "alpha_set_ex (\<pi> \<bullet> as,
+ − 803
\<pi> \<bullet> x) equal supp (\<pi> \<bullet> bs, \<pi> \<bullet> y)"} holds provided \mbox{@{term
3013
+ − 804
"alpha_set_ex (as, x) equal supp(bs, y)"}} holds. From the assumption we
+ − 805
have a permutation @{text "\<pi>'"} and for the proof obligation use @{text "\<pi> \<bullet>
3044
+ − 806
\<pi>'"}. To show equivariance, we need to `pull out' the permutations,
3013
+ − 807
which is possible since all operators, namely as @{text "#\<^sup>*, -, =, \<bullet>,
+ − 808
set"} and @{text "supp"}, are equivariant (see
+ − 809
\cite{HuffmanUrban10}). Finally, we apply the permutation operation on
+ − 810
booleans.
2985
+ − 811
\end{proof}
+ − 812
+ − 813
\noindent
3008
+ − 814
Recall the picture shown in \eqref{picture} about new types in HOL.
+ − 815
The lemma above allows us to use our quotient package for introducing
3002
+ − 816
new types @{text "\<beta> abs\<^bsub>set\<^esub>"}, @{text "\<beta> abs\<^bsub>set+\<^esub>"} and @{text "\<beta> abs\<^bsub>list\<^esub>"}
2989
+ − 817
representing alpha-equivalence classes of pairs of type
2985
+ − 818
@{text "(atom set) \<times> \<beta>"} (in the first two cases) and of type @{text "(atom list) \<times> \<beta>"}
+ − 819
(in the third case).
+ − 820
The elements in these types will be, respectively, written as
+ − 821
3002
+ − 822
\[
+ − 823
@{term "Abs_set as x"} \hspace{10mm}
+ − 824
@{term "Abs_res as x"} \hspace{10mm}
+ − 825
@{term "Abs_lst as x"}
+ − 826
\]\smallskip
2985
+ − 827
+ − 828
\noindent
+ − 829
indicating that a set (or list) of atoms @{text as} is abstracted in @{text x}. We will
+ − 830
call the types \emph{abstraction types} and their elements
+ − 831
\emph{abstractions}. The important property we need to derive is the support of
+ − 832
abstractions, namely:
+ − 833
2989
+ − 834
\begin{thm}[Support of Abstractions]\label{suppabs}
2985
+ − 835
Assuming @{text x} has finite support, then
+ − 836
3002
+ − 837
\[
+ − 838
\begin{array}{l@ {\;=\;}l}
+ − 839
@{thm (lhs) supp_Abs(1)[no_vars]} & @{thm (rhs) supp_Abs(1)[no_vars]}\\
+ − 840
@{thm (lhs) supp_Abs(2)[no_vars]} & @{thm (rhs) supp_Abs(2)[no_vars]}\\
+ − 841
@{thm (lhs) supp_Abs(3)[where bs="as", no_vars]} &
+ − 842
@{thm (rhs) supp_Abs(3)[where bs="as", no_vars]}\\
+ − 843
\end{array}
+ − 844
\]\smallskip
2989
+ − 845
\end{thm}
2985
+ − 846
+ − 847
\noindent
3006
+ − 848
In effect, this theorem states that the atoms @{text "as"} are bound in the
3025
+ − 849
abstraction. As stated earlier, this can be seen as a litmus test that our
3006
+ − 850
Definitions \ref{alphaset}, \ref{alphalist} and \ref{alphares} capture the
+ − 851
idea of alpha-equivalence relations. Below we will give the proof for the
+ − 852
first equation of Theorem \ref{suppabs}. The others follow by similar
+ − 853
arguments. By definition of the abstraction type @{text
+ − 854
"abs\<^bsub>set\<^esub>"} we have
2985
+ − 855
+ − 856
\begin{equation}\label{abseqiff}
3098
+ − 857
@{thm (lhs) Abs_eq_iff(1)[where bs="as" and bs'="bs", no_vars]} \;\;\;\text{if and only if}\;\;\;
3006
+ − 858
@{term "alpha_set_ex (as, x) equal supp (bs, y)"}
3002
+ − 859
\end{equation}\smallskip
2985
+ − 860
+ − 861
\noindent
+ − 862
and also
+ − 863
+ − 864
\begin{equation}\label{absperm}
3002
+ − 865
@{thm permute_Abs(1)[where p="\<pi>", no_vars]}
+ − 866
\end{equation}\smallskip
2985
+ − 867
+ − 868
\noindent
+ − 869
The second fact derives from the definition of permutations acting on pairs
2989
+ − 870
\eqref{permute} and alpha-equivalence being equivariant
2985
+ − 871
(see Lemma~\ref{alphaeq}). With these two facts at our disposal, we can show
+ − 872
the following lemma about swapping two atoms in an abstraction.
+ − 873
2989
+ − 874
\begin{lem}
3004
+ − 875
If @{thm (prem 1) Abs_swap1(1)[where bs="as", no_vars]} and
+ − 876
@{thm (prem 2) Abs_swap1(1)[where bs="as", no_vars]} then
+ − 877
@{thm (concl) Abs_swap1(1)[where bs="as", no_vars]}
2989
+ − 878
\end{lem}
2985
+ − 879
+ − 880
\begin{proof}
3025
+ − 881
If @{term "a = b"} the lemma is immediate, since @{term "(a \<rightleftharpoons> b)"} is then
+ − 882
the identity permutation.
3021
+ − 883
Also in the other case the lemma is straightforward using \eqref{abseqiff}
+ − 884
and observing that the assumptions give us @{term "(a \<rightleftharpoons> b) \<bullet> (supp x - as) =
3025
+ − 885
(supp x - as)"}. We therefore can use the swapping @{term "(a \<rightleftharpoons> b)"} as
+ − 886
the permutation for the proof obligation.
2985
+ − 887
\end{proof}
+ − 888
+ − 889
\noindent
+ − 890
Assuming that @{text "x"} has finite support, this lemma together
+ − 891
with \eqref{absperm} allows us to show
+ − 892
+ − 893
\begin{equation}\label{halfone}
+ − 894
@{thm Abs_supports(1)[no_vars]}
3004
+ − 895
\end{equation}\smallskip
2985
+ − 896
+ − 897
\noindent
3023
+ − 898
which by Property~\ref{supportsprop} gives us `one half' of
+ − 899
Theorem~\ref{suppabs}. The `other half' is a bit more involved. To establish
2985
+ − 900
it, we use a trick from \cite{Pitts04} and first define an auxiliary
3004
+ − 901
function @{text aux}, taking an abstraction as argument
+ − 902
+ − 903
\[
+ − 904
@{thm supp_set.simps[THEN eq_reflection, no_vars]}
+ − 905
\]\smallskip
+ − 906
+ − 907
\noindent
2985
+ − 908
Using the second equation in \eqref{equivariance}, we can show that
3004
+ − 909
@{text "aux"} is equivariant (since @{term "\<pi> \<bullet> (supp x - as) = (supp (\<pi> \<bullet> x)) - (\<pi> \<bullet> as)"})
2985
+ − 910
and therefore has empty support.
+ − 911
This in turn means
+ − 912
3004
+ − 913
\[
+ − 914
@{term "supp (supp_set (Abs_set as x)) \<subseteq> supp (Abs_set as x)"}
+ − 915
\]\smallskip
2985
+ − 916
+ − 917
\noindent
3006
+ − 918
using the fact about the support of function applications in \eqref{supps}. Assuming
3004
+ − 919
@{term "supp x - as"} is a finite set, we further obtain
2985
+ − 920
+ − 921
\begin{equation}\label{halftwo}
+ − 922
@{thm (concl) Abs_supp_subset1(1)[no_vars]}
3004
+ − 923
\end{equation}\smallskip
2985
+ − 924
+ − 925
\noindent
3044
+ − 926
This is because for every finite set of atoms, say @{text "bs"}, we have
2985
+ − 927
@{thm (concl) supp_finite_atom_set[where S="bs", no_vars]}.
+ − 928
Finally, taking \eqref{halfone} and \eqref{halftwo} together establishes
3025
+ − 929
the first equation of Theorem~\ref{suppabs}. The others are similar.
2985
+ − 930
3021
+ − 931
Recall the definition of support given in \eqref{suppdef}, and note the difference between
3025
+ − 932
the support of a raw pair and an abstraction
3010
+ − 933
+ − 934
\[
+ − 935
@{term "supp (as, x) = supp as \<union> supp x"}\hspace{15mm}
+ − 936
@{term "supp (Abs_set as x) = supp x - as"}
+ − 937
\]\smallskip
+ − 938
+ − 939
\noindent
3013
+ − 940
While the permutation operations behave in both cases the same (a permutation
3010
+ − 941
is just moved to the arguments), the notion of equality is different for pairs and
3021
+ − 942
abstractions. Therefore we have different supports. In case of abstractions,
3023
+ − 943
we have established in Theorem~\ref{suppabs} that bound atoms are removed from
+ − 944
the support of the abstractions' bodies.
3010
+ − 945
3004
+ − 946
The method of first considering abstractions of the form @{term "Abs_set as
+ − 947
x"} etc is motivated by the fact that we can conveniently establish at the
+ − 948
Isabelle/HOL level properties about them. It would be extremely laborious
+ − 949
to write custom ML-code that derives automatically such properties for every
+ − 950
term-constructor that binds some atoms. Also the generality of the
+ − 951
definitions for alpha-equivalence will help us in the next sections.
2985
+ − 952
*}
+ − 953
+ − 954
section {* Specifying General Bindings\label{sec:spec} *}
+ − 955
+ − 956
text {*
+ − 957
Our choice of syntax for specifications is influenced by the existing
+ − 958
datatype package of Isabelle/HOL \cite{Berghofer99}
+ − 959
and by the syntax of the
+ − 960
Ott-tool \cite{ott-jfp}. For us a specification of a term-calculus is a
+ − 961
collection of (possibly mutual recursive) type declarations, say @{text
+ − 962
"ty\<AL>\<^isub>1, \<dots>, ty\<AL>\<^isub>n"}, and an associated collection of
+ − 963
binding functions, say @{text "bn\<AL>\<^isub>1, \<dots>, bn\<AL>\<^isub>m"}. The
3006
+ − 964
syntax in Nominal Isabelle for such specifications is schematically as follows:
2985
+ − 965
+ − 966
\begin{equation}\label{scheme}
+ − 967
\mbox{\begin{tabular}{@ {}p{2.5cm}l}
+ − 968
type \mbox{declaration part} &
+ − 969
$\begin{cases}
2989
+ − 970
\mbox{\begin{tabular}{l}
2985
+ − 971
\isacommand{nominal\_datatype} @{text "ty\<AL>\<^isub>1 = \<dots>"}\\
+ − 972
\isacommand{and} @{text "ty\<AL>\<^isub>2 = \<dots>"}\\
+ − 973
\raisebox{2mm}{$\ldots$}\\[-2mm]
+ − 974
\isacommand{and} @{text "ty\<AL>\<^isub>n = \<dots>"}\\
+ − 975
\end{tabular}}
3006
+ − 976
\end{cases}$\\[2mm]
2985
+ − 977
binding \mbox{function part} &
+ − 978
$\begin{cases}
2989
+ − 979
\mbox{\begin{tabular}{l}
2985
+ − 980
\isacommand{binder} @{text "bn\<AL>\<^isub>1"} \isacommand{and} \ldots \isacommand{and} @{text "bn\<AL>\<^isub>m"}\\
+ − 981
\isacommand{where}\\
+ − 982
\raisebox{2mm}{$\ldots$}\\[-2mm]
+ − 983
\end{tabular}}
+ − 984
\end{cases}$\\
+ − 985
\end{tabular}}
3004
+ − 986
\end{equation}\smallskip
2985
+ − 987
+ − 988
\noindent
3004
+ − 989
Every type declaration @{text ty}$^\alpha_{1..n}$ consists of a collection
+ − 990
of term-constructors, each of which comes with a list of labelled types that
+ − 991
stand for the types of the arguments of the term-constructor. For example a
+ − 992
term-constructor @{text "C\<^sup>\<alpha>"} might be specified with
2985
+ − 993
3004
+ − 994
\[
3008
+ − 995
@{text "C\<^sup>\<alpha> label\<^isub>1::ty"}\mbox{$'_1$} @{text "\<dots> label\<^isub>l::ty"}\mbox{$'_l\;\;\;\;\;$}
+ − 996
@{text "binding_clauses"}
3004
+ − 997
\]\smallskip
+ − 998
+ − 999
\noindent
+ − 1000
whereby some of the @{text ty}$'_{1..l}$ (or their components) can be
+ − 1001
contained in the collection of @{text ty}$^\alpha_{1..n}$ declared in
+ − 1002
\eqref{scheme}. In this case we will call the corresponding argument a
+ − 1003
\emph{recursive argument} of @{text "C\<^sup>\<alpha>"}. The types of such
3023
+ − 1004
recursive arguments need to satisfy a `positivity' restriction, which
3004
+ − 1005
ensures that the type has a set-theoretic semantics (see
+ − 1006
\cite{Berghofer99}). The labels annotated on the types are optional. Their
+ − 1007
purpose is to be used in the (possibly empty) list of \emph{binding
+ − 1008
clauses}, which indicate the binders and their scope in a term-constructor.
+ − 1009
They come in three \emph{modes}:
+ − 1010
+ − 1011
+ − 1012
\[\mbox{
+ − 1013
\begin{tabular}{@ {}l@ {}}
+ − 1014
\isacommand{binds} {\it binders} \isacommand{in} {\it bodies}\\
+ − 1015
\isacommand{binds (set)} {\it binders} \isacommand{in} {\it bodies}\\
+ − 1016
\isacommand{binds (set+)} {\it binders} \isacommand{in} {\it bodies}
+ − 1017
\end{tabular}}
+ − 1018
\]\smallskip
2985
+ − 1019
+ − 1020
\noindent
3004
+ − 1021
The first mode is for binding lists of atoms (the order of bound atoms
+ − 1022
matters); the second is for sets of binders (the order does not matter, but
+ − 1023
the cardinality does) and the last is for sets of binders (with vacuous
+ − 1024
binders preserving alpha-equivalence). As indicated, the labels in the
3023
+ − 1025
`\isacommand{in}-part' of a binding clause will be called \emph{bodies};
+ − 1026
the `\isacommand{binds}-part' will be called \emph{binders}. In contrast to
3004
+ − 1027
Ott, we allow multiple labels in binders and bodies. For example we allow
2985
+ − 1028
binding clauses of the form:
3004
+ − 1029
+ − 1030
\[\mbox{
2985
+ − 1031
\begin{tabular}{@ {}ll@ {}}
+ − 1032
@{text "Foo\<^isub>1 x::name y::name t::trm s::trm"} &
3004
+ − 1033
\isacommand{binds} @{text "x y"} \isacommand{in} @{text "t s"}\\
2985
+ − 1034
@{text "Foo\<^isub>2 x::name y::name t::trm s::trm"} &
3004
+ − 1035
\isacommand{binds} @{text "x y"} \isacommand{in} @{text "t"},
+ − 1036
\isacommand{binds} @{text "x y"} \isacommand{in} @{text "s"}\\
+ − 1037
\end{tabular}}
+ − 1038
\]\smallskip
2985
+ − 1039
+ − 1040
\noindent
3004
+ − 1041
Similarly for the other binding modes. Interestingly, in case of
+ − 1042
\isacommand{binds (set)} and \isacommand{binds (set+)} the binding clauses
+ − 1043
above will make a difference to the semantics of the specifications (the
+ − 1044
corresponding alpha-equivalence will differ). We will show this later with
+ − 1045
an example.
+ − 1046
2985
+ − 1047
3004
+ − 1048
There are also some restrictions we need to impose on our binding clauses in
3018
+ − 1049
comparison to Ott. The main idea behind these restrictions is
3017
+ − 1050
that we obtain a notion of alpha-equivalence where it is ensured
3004
+ − 1051
that within a given scope an atom occurrence cannot be both bound and free
+ − 1052
at the same time. The first restriction is that a body can only occur in
3006
+ − 1053
\emph{one} binding clause of a term constructor. So for example
+ − 1054
+ − 1055
\[\mbox{
+ − 1056
@{text "Foo x::name y::name t::trm"}\hspace{3mm}
+ − 1057
\isacommand{binds} @{text "x"} \isacommand{in} @{text "t"},
+ − 1058
\isacommand{binds} @{text "y"} \isacommand{in} @{text "t"}}
+ − 1059
\]\smallskip
+ − 1060
+ − 1061
\noindent
+ − 1062
is not allowed. This ensures that the bound atoms of a body cannot be free
+ − 1063
at the same time by specifying an alternative binder for the same body.
2985
+ − 1064
3004
+ − 1065
For binders we distinguish between \emph{shallow} and \emph{deep} binders.
+ − 1066
Shallow binders are just labels. The restriction we need to impose on them
+ − 1067
is that in case of \isacommand{binds (set)} and \isacommand{binds (set+)} the
+ − 1068
labels must either refer to atom types or to sets of atom types; in case of
3010
+ − 1069
\isacommand{binds} the labels must refer to atom types or to lists of atom
3004
+ − 1070
types. Two examples for the use of shallow binders are the specification of
+ − 1071
lambda-terms, where a single name is bound, and type-schemes, where a finite
+ − 1072
set of names is bound:
2985
+ − 1073
3004
+ − 1074
\[\mbox{
3010
+ − 1075
\begin{tabular}{@ {}c@ {\hspace{8mm}}c@ {}}
2985
+ − 1076
\begin{tabular}{@ {}l}
+ − 1077
\isacommand{nominal\_datatype} @{text lam} $=$\\
+ − 1078
\hspace{2mm}\phantom{$\mid$}~@{text "Var name"}\\
+ − 1079
\hspace{2mm}$\mid$~@{text "App lam lam"}\\
3004
+ − 1080
\hspace{2mm}$\mid$~@{text "Lam x::name t::lam"}\hspace{3mm}%
+ − 1081
\isacommand{binds} @{text x} \isacommand{in} @{text t}\\
3010
+ − 1082
\\
2985
+ − 1083
\end{tabular} &
+ − 1084
\begin{tabular}{@ {}l@ {}}
+ − 1085
\isacommand{nominal\_datatype}~@{text ty} $=$\\
3010
+ − 1086
\hspace{2mm}\phantom{$\mid$}~@{text "TVar name"}\\
+ − 1087
\hspace{2mm}$\mid$~@{text "TFun ty ty"}\\
+ − 1088
\isacommand{and}~@{text "tsc ="}\\
+ − 1089
\hspace{2mm}\phantom{$\mid$}~@{text "TAll xs::(name fset) T::ty"}\hspace{3mm}%
3004
+ − 1090
\isacommand{binds (set+)} @{text xs} \isacommand{in} @{text T}\\
2985
+ − 1091
\end{tabular}
3004
+ − 1092
\end{tabular}}
+ − 1093
\]\smallskip
+ − 1094
2985
+ − 1095
+ − 1096
\noindent
3018
+ − 1097
In these specifications @{text "name"} refers to a (concrete) atom type, and @{text
3006
+ − 1098
"fset"} to the type of finite sets. Note that for @{text Lam} it does not
3004
+ − 1099
matter which binding mode we use. The reason is that we bind only a single
3009
+ − 1100
@{text name}, in which case all three binding modes coincide. However, having
+ − 1101
\isacommand{binds (set)} or just \isacommand{binds}
3004
+ − 1102
in the second case makes a difference to the semantics of the specification
+ − 1103
(which we will define in the next section).
2985
+ − 1104
3023
+ − 1105
A \emph{deep} binder uses an auxiliary binding function that `picks' out
2985
+ − 1106
the atoms in one argument of the term-constructor, which can be bound in
+ − 1107
other arguments and also in the same argument (we will call such binders
+ − 1108
\emph{recursive}, see below). The binding functions are
3004
+ − 1109
expected to return either a set of atoms (for \isacommand{binds (set)} and
+ − 1110
\isacommand{binds (set+)}) or a list of atoms (for \isacommand{binds}). They need
+ − 1111
to be defined by recursion over the corresponding type; the equations
2985
+ − 1112
must be given in the binding function part of the scheme shown in
+ − 1113
\eqref{scheme}. For example a term-calculus containing @{text "Let"}s with
3011
+ − 1114
tuple patterns may be specified as:
3004
+ − 1115
2985
+ − 1116
\begin{equation}\label{letpat}
2989
+ − 1117
\mbox{%
2985
+ − 1118
\begin{tabular}{l}
+ − 1119
\isacommand{nominal\_datatype} @{text trm} $=$\\
+ − 1120
\hspace{5mm}\phantom{$\mid$}~@{term "Var name"}\\
+ − 1121
\hspace{5mm}$\mid$~@{term "App trm trm"}\\
+ − 1122
\hspace{5mm}$\mid$~@{text "Lam x::name t::trm"}
3004
+ − 1123
\;\;\isacommand{binds} @{text x} \isacommand{in} @{text t}\\
3018
+ − 1124
\hspace{5mm}$\mid$~@{text "Let_pat p::pat trm t::trm"}
3004
+ − 1125
\;\;\isacommand{binds} @{text "bn(p)"} \isacommand{in} @{text t}\\
+ − 1126
\isacommand{and} @{text pat} $=$\\
3029
+ − 1127
\hspace{5mm}\phantom{$\mid$}~@{text "PVar name"}\\
3004
+ − 1128
\hspace{5mm}$\mid$~@{text "PTup pat pat"}\\
2985
+ − 1129
\isacommand{binder}~@{text "bn::pat \<Rightarrow> atom list"}\\
3029
+ − 1130
\isacommand{where}~@{text "bn(PVar x) = [atom x]"}\\
2985
+ − 1131
\hspace{5mm}$\mid$~@{text "bn(PTup p\<^isub>1 p\<^isub>2) = bn(p\<^isub>1) @ bn(p\<^isub>2)"}\smallskip\\
+ − 1132
\end{tabular}}
3004
+ − 1133
\end{equation}\smallskip
+ − 1134
2985
+ − 1135
\noindent
+ − 1136
In this specification the function @{text "bn"} determines which atoms of
3011
+ − 1137
the pattern @{text p} (fifth line) are bound in the argument @{text "t"}. Note that in the
2985
+ − 1138
second-last @{text bn}-clause the function @{text "atom"} coerces a name
+ − 1139
into the generic atom type of Nominal Isabelle \cite{HuffmanUrban10}. This
+ − 1140
allows us to treat binders of different atom type uniformly.
+ − 1141
3008
+ − 1142
For deep binders we allow binding clauses such as
2985
+ − 1143
3004
+ − 1144
\[\mbox{
2985
+ − 1145
\begin{tabular}{ll}
+ − 1146
@{text "Bar p::pat t::trm"} &
3004
+ − 1147
\isacommand{binds} @{text "bn(p)"} \isacommand{in} @{text "p t"} \\
+ − 1148
\end{tabular}}
+ − 1149
\]\smallskip
+ − 1150
2985
+ − 1151
+ − 1152
\noindent
+ − 1153
where the argument of the deep binder also occurs in the body. We call such
+ − 1154
binders \emph{recursive}. To see the purpose of such recursive binders,
3023
+ − 1155
compare `plain' @{text "Let"}s and @{text "Let_rec"}s in the following
2985
+ − 1156
specification:
3004
+ − 1157
2985
+ − 1158
\begin{equation}\label{letrecs}
2989
+ − 1159
\mbox{%
3031
+ − 1160
\begin{tabular}{@ {}l@ {}l}
2985
+ − 1161
\isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\
+ − 1162
\hspace{5mm}$\mid$~@{text "Let as::assn t::trm"}
3031
+ − 1163
& \hspace{-19mm}\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text t}\\
2985
+ − 1164
\hspace{5mm}$\mid$~@{text "Let_rec as::assn t::trm"}
3031
+ − 1165
& \hspace{-19mm}\isacommand{binds} @{text "bn(as)"} \isacommand{in} @{text "as t"}\\
3004
+ − 1166
\isacommand{and} @{text "assn"} $=$\\
+ − 1167
\hspace{5mm}\phantom{$\mid$}~@{text "ANil"}\\
+ − 1168
\hspace{5mm}$\mid$~@{text "ACons name trm assn"}\\
2985
+ − 1169
\isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\
+ − 1170
\isacommand{where}~@{text "bn(ANil) = []"}\\
+ − 1171
\hspace{5mm}$\mid$~@{text "bn(ACons a t as) = [atom a] @ bn(as)"}\\
+ − 1172
\end{tabular}}
3004
+ − 1173
\end{equation}\smallskip
+ − 1174
2985
+ − 1175
\noindent
+ − 1176
The difference is that with @{text Let} we only want to bind the atoms @{text
+ − 1177
"bn(as)"} in the term @{text t}, but with @{text "Let_rec"} we also want to bind the atoms
+ − 1178
inside the assignment. This difference has consequences for the associated
2989
+ − 1179
notions of free-atoms and alpha-equivalence.
2985
+ − 1180
+ − 1181
To make sure that atoms bound by deep binders cannot be free at the
+ − 1182
same time, we cannot have more than one binding function for a deep binder.
+ − 1183
Consequently we exclude specifications such as
3006
+ − 1184
+ − 1185
\[\mbox{
2985
+ − 1186
\begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
+ − 1187
@{text "Baz\<^isub>1 p::pat t::trm"} &
3004
+ − 1188
\isacommand{binds} @{text "bn\<^isub>1(p) bn\<^isub>2(p)"} \isacommand{in} @{text t}\\
2985
+ − 1189
@{text "Baz\<^isub>2 p::pat t\<^isub>1::trm t\<^isub>2::trm"} &
3004
+ − 1190
\isacommand{binds} @{text "bn\<^isub>1(p)"} \isacommand{in} @{text "t\<^isub>1"},
+ − 1191
\isacommand{binds} @{text "bn\<^isub>2(p)"} \isacommand{in} @{text "t\<^isub>2"}\\
3006
+ − 1192
\end{tabular}}
+ − 1193
\]\smallskip
2985
+ − 1194
+ − 1195
\noindent
+ − 1196
Otherwise it is possible that @{text "bn\<^isub>1"} and @{text "bn\<^isub>2"} pick
+ − 1197
out different atoms to become bound, respectively be free, in @{text "p"}.
+ − 1198
(Since the Ott-tool does not derive a reasoning infrastructure for
2989
+ − 1199
alpha-equated terms with deep binders, it can permit such specifications.)
2985
+ − 1200
3006
+ − 1201
We also need to restrict the form of the binding functions in order to
+ − 1202
ensure the @{text "bn"}-functions can be defined for alpha-equated
+ − 1203
terms. The main restriction is that we cannot return an atom in a binding
+ − 1204
function that is also bound in the corresponding term-constructor.
+ − 1205
Consider again the specification for @{text "trm"} and a contrived
3008
+ − 1206
version for assignments @{text "assn"}:
2985
+ − 1207
3006
+ − 1208
\begin{equation}\label{bnexp}
+ − 1209
\mbox{%
+ − 1210
\begin{tabular}{@ {}l@ {}}
+ − 1211
\isacommand{nominal\_datatype}~@{text "trm ="}~\ldots\\
+ − 1212
\isacommand{and} @{text "assn"} $=$\\
3008
+ − 1213
\hspace{5mm}\phantom{$\mid$}~@{text "ANil'"}\\
+ − 1214
\hspace{5mm}$\mid$~@{text "ACons' x::name y::name t::trm assn"}
3006
+ − 1215
\;\;\isacommand{binds} @{text "y"} \isacommand{in} @{text t}\\
+ − 1216
\isacommand{binder} @{text "bn::assn \<Rightarrow> atom list"}\\
3008
+ − 1217
\isacommand{where}~@{text "bn(ANil') = []"}\\
+ − 1218
\hspace{5mm}$\mid$~@{text "bn(ACons' x y t as) = [atom x] @ bn(as)"}\\
3006
+ − 1219
\end{tabular}}
+ − 1220
\end{equation}\smallskip
+ − 1221
+ − 1222
\noindent
3011
+ − 1223
In this example the term constructor @{text "ACons'"} has four arguments with
3017
+ − 1224
a binding clause involving two of them. This constructor is also used in the definition
3010
+ − 1225
of the binding function. The restriction we have to impose is that the
3017
+ − 1226
binding function can only return free atoms, that is the ones that are \emph{not}
3010
+ − 1227
mentioned in a binding clause. Therefore @{text "y"} cannot be used in the
+ − 1228
binding function @{text "bn"} (since it is bound in @{text "ACons'"} by the
+ − 1229
binding clause), but @{text x} can (since it is a free atom). This
+ − 1230
restriction is sufficient for lifting the binding function to alpha-equated
3017
+ − 1231
terms. If we would permit @{text "bn"} to return @{text "y"},
+ − 1232
then it would not be respectful and therefore cannot be lifted to
+ − 1233
alpha-equated lambda-terms.
3006
+ − 1234
+ − 1235
In the version of Nominal Isabelle described here, we also adopted the
+ − 1236
restriction from the Ott-tool that binding functions can only return: the
3008
+ − 1237
empty set or empty list (as in case @{text ANil'}), a singleton set or
3006
+ − 1238
singleton list containing an atom (case @{text PVar} in \eqref{letpat}), or
3008
+ − 1239
unions of atom sets or appended atom lists (case @{text ACons'}). This
3006
+ − 1240
restriction will simplify some automatic definitions and proofs later on.
2985
+ − 1241
2989
+ − 1242
In order to simplify our definitions of free atoms and alpha-equivalence,
2985
+ − 1243
we shall assume specifications
+ − 1244
of term-calculi are implicitly \emph{completed}. By this we mean that
+ − 1245
for every argument of a term-constructor that is \emph{not}
+ − 1246
already part of a binding clause given by the user, we add implicitly a special \emph{empty} binding
3004
+ − 1247
clause, written \isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "labels"}. In case
2985
+ − 1248
of the lambda-terms, the completion produces
+ − 1249
3006
+ − 1250
\[\mbox{
2985
+ − 1251
\begin{tabular}{@ {}l@ {\hspace{-1mm}}}
+ − 1252
\isacommand{nominal\_datatype} @{text lam} =\\
+ − 1253
\hspace{5mm}\phantom{$\mid$}~@{text "Var x::name"}
3004
+ − 1254
\;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "x"}\\
2985
+ − 1255
\hspace{5mm}$\mid$~@{text "App t\<^isub>1::lam t\<^isub>2::lam"}
3004
+ − 1256
\;\;\isacommand{binds}~@{term "{}"}~\isacommand{in}~@{text "t\<^isub>1 t\<^isub>2"}\\
2985
+ − 1257
\hspace{5mm}$\mid$~@{text "Lam x::name t::lam"}
3004
+ − 1258
\;\;\isacommand{binds}~@{text x} \isacommand{in} @{text t}\\
3006
+ − 1259
\end{tabular}}
+ − 1260
\]\smallskip
2985
+ − 1261
+ − 1262
\noindent
+ − 1263
The point of completion is that we can make definitions over the binding
+ − 1264
clauses and be sure to have captured all arguments of a term constructor.
+ − 1265
*}
+ − 1266
+ − 1267
section {* Alpha-Equivalence and Free Atoms\label{sec:alpha} *}
+ − 1268
+ − 1269
text {*
+ − 1270
Having dealt with all syntax matters, the problem now is how we can turn
+ − 1271
specifications into actual type definitions in Isabelle/HOL and then
3006
+ − 1272
establish a reasoning infrastructure for them. As Pottier and Cheney pointed
+ − 1273
out \cite{Cheney05,Pottier06}, just re-arranging the arguments of
+ − 1274
term-constructors so that binders and their bodies are next to each other
+ − 1275
will result in inadequate representations in cases like \mbox{@{text "Let
+ − 1276
x\<^isub>1 = t\<^isub>1\<dots>x\<^isub>n = t\<^isub>n in s"}}. Therefore we will
3023
+ − 1277
first extract `raw' datatype definitions from the specification and then
3006
+ − 1278
define explicitly an alpha-equivalence relation over them. We subsequently
2989
+ − 1279
construct the quotient of the datatypes according to our alpha-equivalence.
2985
+ − 1280
3006
+ − 1281
3023
+ − 1282
The `raw' datatype definition can be obtained by stripping off the
3025
+ − 1283
binding clauses and the labels from the types given by the user. We also have to invent
+ − 1284
new names for the types @{text "ty\<^sup>\<alpha>"} and the term-constructors @{text "C\<^sup>\<alpha>"}.
+ − 1285
In our implementation we just use the affix ``@{text "_raw"}''.
2985
+ − 1286
But for the purpose of this paper, we use the superscript @{text "_\<^sup>\<alpha>"} to indicate
2989
+ − 1287
that a notion is given for alpha-equivalence classes and leave it out
3025
+ − 1288
for the corresponding notion given on the raw level. So for example
3022
+ − 1289
we have @{text "ty\<^sup>\<alpha> / ty"} and @{text "C\<^sup>\<alpha> / C"}
2985
+ − 1290
where @{term ty} is the type used in the quotient construction for
3025
+ − 1291
@{text "ty\<^sup>\<alpha>"} and @{text "C"} is the term-constructor of the raw type @{text "ty"},
3021
+ − 1292
respectively @{text "C\<^sup>\<alpha>"} is the corresponding term-constructor of @{text "ty\<^sup>\<alpha>"}.
2985
+ − 1293
+ − 1294
The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are
+ − 1295
non-empty and the types in the constructors only occur in positive
+ − 1296
position (see \cite{Berghofer99} for an in-depth description of the datatype package
+ − 1297
in Isabelle/HOL).
+ − 1298
We subsequently define each of the user-specified binding
+ − 1299
functions @{term "bn"}$_{1..m}$ by recursion over the corresponding
3025
+ − 1300
raw datatype. We also define permutation operations by
2985
+ − 1301
recursion so that for each term constructor @{text "C"} we have that
3006
+ − 1302
2985
+ − 1303
\begin{equation}\label{ceqvt}
3006
+ − 1304
@{text "\<pi> \<bullet> (C z\<^isub>1 \<dots> z\<^isub>n) = C (\<pi> \<bullet> z\<^isub>1) \<dots> (\<pi> \<bullet> z\<^isub>n)"}
+ − 1305
\end{equation}\smallskip
2985
+ − 1306
3013
+ − 1307
\noindent
3021
+ − 1308
We will need this operation later when we define the notion of alpha-equivalence.
3013
+ − 1309
2985
+ − 1310
The first non-trivial step we have to perform is the generation of
3011
+ − 1311
\emph{free-atom functions} from the specifications.\footnote{Admittedly, the
3008
+ − 1312
details of our definitions will be somewhat involved. However they are still
3023
+ − 1313
conceptually simple in comparison with the `positional' approach taken in
3014
+ − 1314
Ott \cite[Pages 88--95]{ott-jfp}, which uses the notions of \emph{occurrences} and
+ − 1315
\emph{partial equivalence relations} over sets of occurrences.} For the
2985
+ − 1316
\emph{raw} types @{text "ty"}$_{1..n}$ we define the free-atom functions
3006
+ − 1317
2985
+ − 1318
\begin{equation}\label{fvars}
+ − 1319
\mbox{@{text "fa_ty"}$_{1..n}$}
3006
+ − 1320
\end{equation}\smallskip
2985
+ − 1321
+ − 1322
\noindent
+ − 1323
by recursion.
+ − 1324
We define these functions together with auxiliary free-atom functions for
+ − 1325
the binding functions. Given raw binding functions @{text "bn"}$_{1..m}$
+ − 1326
we define
+ − 1327
3006
+ − 1328
\[
+ − 1329
@{text "fa_bn"}\mbox{$_{1..m}$}.
+ − 1330
\]\smallskip
2985
+ − 1331
+ − 1332
\noindent
+ − 1333
The reason for this setup is that in a deep binder not all atoms have to be
3023
+ − 1334
bound, as we saw in \eqref{letrecs} with the example of `plain' @{text Let}s. We need
3013
+ − 1335
therefore functions that calculate those free atoms in deep binders.
2985
+ − 1336
3013
+ − 1337
While the idea behind these free-atom functions is simple (they just
2985
+ − 1338
collect all atoms that are not bound), because of our rather complicated
+ − 1339
binding mechanisms their definitions are somewhat involved. Given
3025
+ − 1340
a raw term-constructor @{text "C"} of type @{text ty} and some associated
2985
+ − 1341
binding clauses @{text "bc\<^isub>1\<dots>bc\<^isub>k"}, the result of @{text
+ − 1342
"fa_ty (C z\<^isub>1 \<dots> z\<^isub>n)"} will be the union @{text
+ − 1343
"fa(bc\<^isub>1) \<union> \<dots> \<union> fa(bc\<^isub>k)"} where we will define below what @{text "fa"} for a binding
3004
+ − 1344
clause means. We only show the details for the mode \isacommand{binds (set)} (the other modes are similar).
2985
+ − 1345
Suppose the binding clause @{text bc\<^isub>i} is of the form
+ − 1346
3006
+ − 1347
\[
3004
+ − 1348
\mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}}
3006
+ − 1349
\]\smallskip
2985
+ − 1350
+ − 1351
\noindent
3006
+ − 1352
in which the body-labels @{text "d"}$_{1..q}$ refer to types @{text
+ − 1353
ty}$_{1..q}$, and the binders @{text b}$_{1..p}$ either refer to labels of
+ − 1354
atom types (in case of shallow binders) or to binding functions taking a
+ − 1355
single label as argument (in case of deep binders). Assuming @{text "D"}
+ − 1356
stands for the set of free atoms of the bodies, @{text B} for the set of
+ − 1357
binding atoms in the binders and @{text "B'"} for the set of free atoms in
+ − 1358
non-recursive deep binders, then the free atoms of the binding clause @{text
+ − 1359
bc\<^isub>i} are
+ − 1360
2985
+ − 1361
\begin{equation}\label{fadef}
+ − 1362
\mbox{@{text "fa(bc\<^isub>i) \<equiv> (D - B) \<union> B'"}}.
3006
+ − 1363
\end{equation}\smallskip
+ − 1364
2985
+ − 1365
\noindent
+ − 1366
The set @{text D} is formally defined as
+ − 1367
3006
+ − 1368
\[
2985
+ − 1369
@{text "D \<equiv> fa_ty\<^isub>1 d\<^isub>1 \<union> ... \<union> fa_ty\<^isub>q d\<^isub>q"}
3006
+ − 1370
\]\smallskip
2985
+ − 1371
+ − 1372
\noindent
+ − 1373
where in case @{text "d\<^isub>i"} refers to one of the raw types @{text "ty"}$_{1..n}$ from the
+ − 1374
specification, the function @{text "fa_ty\<^isub>i"} is the corresponding free-atom function
3021
+ − 1375
we are defining by recursion; otherwise we set \mbox{@{text "fa_ty\<^isub>i \<equiv> supp"}}. The reason
3008
+ − 1376
for the latter is that @{text "ty"}$_i$ is not a type that is part of the specification, and
3021
+ − 1377
we assume @{text supp} is the generic function that characterises the free variables of
3006
+ − 1378
a type (in fact in the next section we will show that the free-variable functions we
+ − 1379
define here, are equal to the support once lifted to alpha-equivalence classes).
2985
+ − 1380
+ − 1381
In order to formally define the set @{text B} we use the following auxiliary @{text "bn"}-functions
+ − 1382
for atom types to which shallow binders may refer\\[-4mm]
+ − 1383
3008
+ − 1384
\begin{equation}\label{bnaux}\mbox{
2985
+ − 1385
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
3006
+ − 1386
@{text "bn\<^bsub>atom\<^esup> a"} & @{text "\<equiv>"} & @{text "{atom a}"}\\
+ − 1387
@{text "bn\<^bsub>atom_set\<^esup> as"} & @{text "\<equiv>"} & @{text "atoms as"}\\
+ − 1388
@{text "bn\<^bsub>atom_list\<^esub> as"} & @{text "\<equiv>"} & @{text "atoms (set as)"}
+ − 1389
\end{tabular}}
3008
+ − 1390
\end{equation}\smallskip
2985
+ − 1391
+ − 1392
\noindent
+ − 1393
Like the function @{text atom}, the function @{text "atoms"} coerces
+ − 1394
a set of atoms to a set of the generic atom type.
+ − 1395
It is defined as @{text "atoms as \<equiv> {atom a | a \<in> as}"}.
3008
+ − 1396
The set @{text B} in \eqref{fadef} is then formally defined as
3006
+ − 1397
+ − 1398
\begin{equation}\label{bdef}
2985
+ − 1399
@{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> ... \<union> bn_ty\<^isub>p b\<^isub>p"}
3006
+ − 1400
\end{equation}\smallskip
+ − 1401
2985
+ − 1402
\noindent
3008
+ − 1403
where we use the auxiliary binding functions from \eqref{bnaux} for shallow
+ − 1404
binders (that means when @{text "ty"}$_i$ is of type @{text "atom"}, @{text "atom set"} or
3013
+ − 1405
@{text "atom list"}).
+ − 1406
+ − 1407
The set @{text "B'"} in \eqref{fadef} collects all free atoms in
3006
+ − 1408
non-recursive deep binders. Let us assume these binders in the binding
+ − 1409
clause @{text "bc\<^isub>i"} are
+ − 1410
+ − 1411
\[
2985
+ − 1412
\mbox{@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}}
3006
+ − 1413
\]\smallskip
2985
+ − 1414
+ − 1415
\noindent
3008
+ − 1416
with @{text "l"}$_{1..r}$ $\subseteq$ @{text "b"}$_{1..p}$ and
+ − 1417
none of the @{text "l"}$_{1..r}$ being among the bodies
3006
+ − 1418
@{text "d"}$_{1..q}$. The set @{text "B'"} is defined as
+ − 1419
+ − 1420
\begin{equation}\label{bprimedef}
+ − 1421
@{text "B' \<equiv> fa_bn\<^isub>1 l\<^isub>1 \<union> ... \<union> fa_bn\<^isub>r l\<^isub>r"}
+ − 1422
\end{equation}\smallskip
+ − 1423
2985
+ − 1424
\noindent
3008
+ − 1425
This completes all clauses for the free-atom functions @{text "fa_ty"}$_{1..n}$.
2985
+ − 1426
+ − 1427
Note that for non-recursive deep binders, we have to add in \eqref{fadef}
+ − 1428
the set of atoms that are left unbound by the binding functions @{text
3008
+ − 1429
"bn"}$_{1..m}$. We used for
3006
+ − 1430
the definition of this set the functions @{text "fa_bn"}$_{1..m}$. The
+ − 1431
definition for those functions needs to be extracted from the clauses the
+ − 1432
user provided for @{text "bn"}$_{1..m}$ Assume the user specified a @{text
+ − 1433
bn}-clause of the form
2985
+ − 1434
3006
+ − 1435
\[
2985
+ − 1436
@{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
3006
+ − 1437
\]\smallskip
2985
+ − 1438
+ − 1439
\noindent
3006
+ − 1440
where the @{text "z"}$_{1..s}$ are of types @{text "ty"}$_{1..s}$. For
+ − 1441
each of the arguments we calculate the free atoms as follows:
2985
+ − 1442
3006
+ − 1443
\[\mbox{
2985
+ − 1444
\begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}}
3006
+ − 1445
$\bullet$ & @{term "fa_ty\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text "rhs"}\\
+ − 1446
& (that means nothing is bound in @{text "z\<^isub>i"} by the binding function),\smallskip\\
2985
+ − 1447
$\bullet$ & @{term "fa_bn\<^isub>i z\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"}
3008
+ − 1448
with the recursive call @{text "bn\<^isub>i z\<^isub>i"}\\
3023
+ − 1449
& (that means whatever is `left over' from the @{text "bn"}-function is free)\smallskip\\
2985
+ − 1450
$\bullet$ & @{term "{}"} provided @{text "z\<^isub>i"} occurs in @{text "rhs"},
3006
+ − 1451
but without a recursive call\\
+ − 1452
& (that means @{text "z\<^isub>i"} is supposed to become bound by the binding function)\\
+ − 1453
\end{tabular}}
+ − 1454
\]\smallskip
2985
+ − 1455
+ − 1456
\noindent
+ − 1457
For defining @{text "fa_bn (C z\<^isub>1 \<dots> z\<^isub>n)"} we just union up all these sets.
+ − 1458
+ − 1459
To see how these definitions work in practice, let us reconsider the
+ − 1460
term-constructors @{text "Let"} and @{text "Let_rec"} shown in
+ − 1461
\eqref{letrecs} together with the term-constructors for assignments @{text
+ − 1462
"ANil"} and @{text "ACons"}. Since there is a binding function defined for
+ − 1463
assignments, we have three free-atom functions, namely @{text
+ − 1464
"fa\<^bsub>trm\<^esub>"}, @{text "fa\<^bsub>assn\<^esub>"} and @{text
+ − 1465
"fa\<^bsub>bn\<^esub>"} as follows:
3006
+ − 1466
+ − 1467
\[\mbox{
2985
+ − 1468
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}}
3009
+ − 1469
@{text "fa\<^bsub>trm\<^esub> (Let as t)"} & @{text "\<equiv>"} & @{text "(fa\<^bsub>trm\<^esub> t - set (bn as)) \<union> fa\<^bsub>bn\<^esub> as"}\\
+ − 1470
@{text "fa\<^bsub>trm\<^esub> (Let_rec as t)"} & @{text "\<equiv>"} & @{text "(fa\<^bsub>assn\<^esub> as \<union> fa\<^bsub>trm\<^esub> t) - set (bn as)"}\smallskip\\
2985
+ − 1471
3009
+ − 1472
@{text "fa\<^bsub>assn\<^esub> (ANil)"} & @{text "\<equiv>"} & @{term "{}"}\\
+ − 1473
@{text "fa\<^bsub>assn\<^esub> (ACons a t as)"} & @{text "\<equiv>"} & @{text "(supp a) \<union> (fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>assn\<^esub> as)"}\smallskip\\
2985
+ − 1474
3009
+ − 1475
@{text "fa\<^bsub>bn\<^esub> (ANil)"} & @{text "\<equiv>"} & @{term "{}"}\\
+ − 1476
@{text "fa\<^bsub>bn\<^esub> (ACons a t as)"} & @{text "\<equiv>"} & @{text "(fa\<^bsub>trm\<^esub> t) \<union> (fa\<^bsub>bn\<^esub> as)"}
3006
+ − 1477
\end{tabular}}
+ − 1478
\]\smallskip
+ − 1479
2985
+ − 1480
+ − 1481
\noindent
3006
+ − 1482
Recall that @{text ANil} and @{text "ACons"} have no binding clause in the
+ − 1483
specification. The corresponding free-atom function @{text
+ − 1484
"fa\<^bsub>assn\<^esub>"} therefore returns all free atoms of an assignment
+ − 1485
(in case of @{text "ACons"}, they are given in terms of @{text supp}, @{text
+ − 1486
"fa\<^bsub>trm\<^esub>"} and @{text "fa\<^bsub>assn\<^esub>"}). The binding
+ − 1487
only takes place in @{text Let} and @{text "Let_rec"}. In case of @{text
+ − 1488
"Let"}, the binding clause specifies that all atoms given by @{text "set (bn
+ − 1489
as)"} have to be bound in @{text t}. Therefore we have to subtract @{text
+ − 1490
"set (bn as)"} from @{text "fa\<^bsub>trm\<^esub> t"}. However, we also need
+ − 1491
to add all atoms that are free in @{text "as"}. This is in contrast with
+ − 1492
@{text "Let_rec"} where we have a recursive binder to bind all occurrences
+ − 1493
of the atoms in @{text "set (bn as)"} also inside @{text "as"}. Therefore we
+ − 1494
have to subtract @{text "set (bn as)"} from both @{text
+ − 1495
"fa\<^bsub>trm\<^esub> t"} and @{text "fa\<^bsub>assn\<^esub> as"}. Like the
+ − 1496
function @{text "bn"}, the function @{text "fa\<^bsub>bn\<^esub>"} traverses
+ − 1497
the list of assignments, but instead returns the free atoms, which means in
+ − 1498
this example the free atoms in the argument @{text "t"}.
2985
+ − 1499
+ − 1500
3023
+ − 1501
An interesting point in this example is that a `naked' assignment (@{text
3006
+ − 1502
"ANil"} or @{text "ACons"}) does not bind any atoms, even if the binding
+ − 1503
function is specified over assignments. Only in the context of a @{text Let}
+ − 1504
or @{text "Let_rec"}, where the binding clauses are given, will some atoms
+ − 1505
actually become bound. This is a phenomenon that has also been pointed out
+ − 1506
in \cite{ott-jfp}. For us this observation is crucial, because we would not
+ − 1507
be able to lift the @{text "bn"}-functions to alpha-equated terms if they
+ − 1508
act on atoms that are bound. In that case, these functions would \emph{not}
+ − 1509
respect alpha-equivalence.
+ − 1510
3023
+ − 1511
Having the free-atom functions at our disposal, we can next define the
3006
+ − 1512
alpha-equivalence relations for the raw types @{text
+ − 1513
"ty"}$_{1..n}$. We write them as
2985
+ − 1514
3006
+ − 1515
\[
+ − 1516
\mbox{@{text "\<approx>ty"}$_{1..n}$}.
+ − 1517
\]\smallskip
2985
+ − 1518
+ − 1519
\noindent
+ − 1520
Like with the free-atom functions, we also need to
2989
+ − 1521
define auxiliary alpha-equivalence relations
2985
+ − 1522
3006
+ − 1523
\[
+ − 1524
\mbox{@{text "\<approx>bn\<^isub>"}$_{1..m}$}
+ − 1525
\]\smallskip
2985
+ − 1526
+ − 1527
\noindent
+ − 1528
for the binding functions @{text "bn"}$_{1..m}$,
+ − 1529
To simplify our definitions we will use the following abbreviations for
+ − 1530
\emph{compound equivalence relations} and \emph{compound free-atom functions} acting on tuples.
+ − 1531
3006
+ − 1532
\[\mbox{
2985
+ − 1533
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
3006
+ − 1534
@{text "(x\<^isub>1,\<dots>, x\<^isub>n) (R\<^isub>1,\<dots>, R\<^isub>n) (y\<^isub>1,\<dots>, y\<^isub>n)"} & @{text "\<equiv>"} &
+ − 1535
@{text "x\<^isub>1 R\<^isub>1 y\<^isub>1 \<and> \<dots> \<and> x\<^isub>n R\<^isub>n y\<^isub>n"}\\
2985
+ − 1536
@{text "(fa\<^isub>1,\<dots>, fa\<^isub>n) (x\<^isub>1,\<dots>, x\<^isub>n)"} & @{text "\<equiv>"} & @{text "fa\<^isub>1 x\<^isub>1 \<union> \<dots> \<union> fa\<^isub>n x\<^isub>n"}\\
3006
+ − 1537
\end{tabular}}
+ − 1538
\]\smallskip
2985
+ − 1539
+ − 1540
2989
+ − 1541
The alpha-equivalence relations are defined as inductive predicates
2985
+ − 1542
having a single clause for each term-constructor. Assuming a
+ − 1543
term-constructor @{text C} is of type @{text ty} and has the binding clauses
2989
+ − 1544
@{term "bc"}$_{1..k}$, then the alpha-equivalence clause has the form
2985
+ − 1545
3006
+ − 1546
\[
2985
+ − 1547
\mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>n \<approx>ty C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>n"}}
+ − 1548
{@{text "prems(bc\<^isub>1) \<dots> prems(bc\<^isub>k)"}}}
3006
+ − 1549
\]\smallskip
2985
+ − 1550
+ − 1551
\noindent
3006
+ − 1552
The task below is to specify what the premises corresponding to a binding
3010
+ − 1553
clause are. To understand better what the general pattern is, let us first
3006
+ − 1554
treat the special instance where @{text "bc\<^isub>i"} is the empty binding clause
+ − 1555
of the form
+ − 1556
+ − 1557
\[
3004
+ − 1558
\mbox{\isacommand{binds (set)} @{term "{}"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
3006
+ − 1559
\]\smallskip
2985
+ − 1560
+ − 1561
\noindent
3010
+ − 1562
In this binding clause no atom is bound and we only have to `alpha-relate'
+ − 1563
the bodies. For this we build first the tuples @{text "D \<equiv> (d\<^isub>1,\<dots>,
+ − 1564
d\<^isub>q)"} and @{text "D' \<equiv> (d\<PRIME>\<^isub>1,\<dots>, d\<PRIME>\<^isub>q)"}
3034
+ − 1565
whereby the labels @{text "d"}$_{1..q}$ refer to some of the arguments @{text
+ − 1566
"z"}$_{1..n}$ and respectively @{text "d\<PRIME>"}$_{1..q}$ to some of @{text
3010
+ − 1567
"z\<PRIME>"}$_{1..n}$ of the term-constructor. In order to relate two such
+ − 1568
tuples we define the compound alpha-equivalence relation @{text "R"} as
+ − 1569
follows
+ − 1570
2985
+ − 1571
\begin{equation}\label{rempty}
+ − 1572
\mbox{@{text "R \<equiv> (R\<^isub>1,\<dots>, R\<^isub>q)"}}
3010
+ − 1573
\end{equation}\smallskip
2985
+ − 1574
+ − 1575
\noindent
3010
+ − 1576
with @{text "R\<^isub>i"} being @{text "\<approx>ty\<^isub>i"} if the corresponding
+ − 1577
labels @{text "d\<^isub>i"} and @{text "d\<PRIME>\<^isub>i"} refer to a
3034
+ − 1578
recursive argument of @{text C} and have type @{text "ty\<^isub>i"}; otherwise
3010
+ − 1579
we take @{text "R\<^isub>i"} to be the equality @{text "="}. Again the
+ − 1580
latter is because @{text "ty\<^isub>i"} is not part of the specified types
+ − 1581
and alpha-equivalence of any previously defined type is supposed to coincide
+ − 1582
with equality. This lets us now define the premise for an empty binding
+ − 1583
clause succinctly as @{text "prems(bc\<^isub>i) \<equiv> D R D'"}, which can be
+ − 1584
unfolded to the series of premises
2985
+ − 1585
3010
+ − 1586
\[
2985
+ − 1587
@{text "d\<^isub>1 R\<^isub>1 d\<PRIME>\<^isub>1 \<dots> d\<^isub>q R\<^isub>q d\<PRIME>\<^isub>q"}.
3010
+ − 1588
\]\smallskip
2985
+ − 1589
+ − 1590
\noindent
+ − 1591
We will use the unfolded version in the examples below.
+ − 1592
+ − 1593
Now suppose the binding clause @{text "bc\<^isub>i"} is of the general form
+ − 1594
+ − 1595
\begin{equation}\label{nonempty}
3004
+ − 1596
\mbox{\isacommand{binds (set)} @{text "b\<^isub>1\<dots>b\<^isub>p"} \isacommand{in} @{text "d\<^isub>1\<dots>d\<^isub>q"}.}
3010
+ − 1597
\end{equation}\smallskip
2985
+ − 1598
+ − 1599
\noindent
+ − 1600
In this case we define a premise @{text P} using the relation
3011
+ − 1601
$\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ given in Section~\ref{sec:binders} (similarly
+ − 1602
$\approx_{\,\textit{set+}}^{\textit{R}, \textit{fa}}$ and
+ − 1603
$\approx_{\,\textit{list}}^{\textit{R}, \textit{fa}}$ for the other
3021
+ − 1604
binding modes). As above, we first build the tuples @{text "D"} and
2985
+ − 1605
@{text "D'"} for the bodies @{text "d"}$_{1..q}$, and the corresponding
2989
+ − 1606
compound alpha-relation @{text "R"} (shown in \eqref{rempty}).
3013
+ − 1607
For $\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ we also need
2985
+ − 1608
a compound free-atom function for the bodies defined as
+ − 1609
3010
+ − 1610
\[
2985
+ − 1611
\mbox{@{text "fa \<equiv> (fa_ty\<^isub>1,\<dots>, fa_ty\<^isub>q)"}}
3010
+ − 1612
\]\smallskip
2985
+ − 1613
+ − 1614
\noindent
+ − 1615
with the assumption that the @{text "d"}$_{1..q}$ refer to arguments of types @{text "ty"}$_{1..q}$.
+ − 1616
The last ingredient we need are the sets of atoms bound in the bodies.
+ − 1617
For this we take
+ − 1618
3010
+ − 1619
\[
2985
+ − 1620
@{text "B \<equiv> bn_ty\<^isub>1 b\<^isub>1 \<union> \<dots> \<union> bn_ty\<^isub>p b\<^isub>p"}\;.\\
3010
+ − 1621
\]\smallskip
2985
+ − 1622
+ − 1623
\noindent
+ − 1624
Similarly for @{text "B'"} using the labels @{text "b\<PRIME>"}$_{1..p}$. This
+ − 1625
lets us formally define the premise @{text P} for a non-empty binding clause as:
+ − 1626
3010
+ − 1627
\[
3006
+ − 1628
\mbox{@{term "P \<equiv> alpha_set_ex (B, D) R fa (B', D')"}}\;.
3010
+ − 1629
\]\smallskip
2985
+ − 1630
+ − 1631
\noindent
2989
+ − 1632
This premise accounts for alpha-equivalence of the bodies of the binding
3010
+ − 1633
clause. However, in case the binders have non-recursive deep binders, this
3023
+ − 1634
premise is not enough: we also have to `propagate' alpha-equivalence
3010
+ − 1635
inside the structure of these binders. An example is @{text "Let"} where we
+ − 1636
have to make sure the right-hand sides of assignments are
+ − 1637
alpha-equivalent. For this we use relations @{text "\<approx>bn"}$_{1..m}$ (which we
3021
+ − 1638
will define shortly). Let us assume the non-recursive deep binders
3010
+ − 1639
in @{text "bc\<^isub>i"} are
2985
+ − 1640
3010
+ − 1641
\[
2985
+ − 1642
@{text "bn\<^isub>1 l\<^isub>1, \<dots>, bn\<^isub>r l\<^isub>r"}.
3010
+ − 1643
\]\smallskip
2985
+ − 1644
+ − 1645
\noindent
3010
+ − 1646
The tuple @{text L} consists then of all these binders @{text "(l\<^isub>1,\<dots>,l\<^isub>r)"}
+ − 1647
(similarly @{text "L'"}) and the compound equivalence relation @{text "R'"}
+ − 1648
is @{text "(\<approx>bn\<^isub>1,\<dots>,\<approx>bn\<^isub>r)"}. All premises for @{text "bc\<^isub>i"} are then given by
2985
+ − 1649
3010
+ − 1650
\[
2985
+ − 1651
@{text "prems(bc\<^isub>i) \<equiv> P \<and> L R' L'"}
3010
+ − 1652
\]\smallskip
2985
+ − 1653
+ − 1654
\noindent
2989
+ − 1655
The auxiliary alpha-equivalence relations @{text "\<approx>bn"}$_{1..m}$
2985
+ − 1656
in @{text "R'"} are defined as follows: assuming a @{text bn}-clause is of the form
+ − 1657
3010
+ − 1658
\[
2985
+ − 1659
@{text "bn (C z\<^isub>1 \<dots> z\<^isub>s) = rhs"}
3010
+ − 1660
\]\smallskip
2985
+ − 1661
+ − 1662
\noindent
+ − 1663
where the @{text "z"}$_{1..s}$ are of types @{text "ty"}$_{1..s}$,
2989
+ − 1664
then the corresponding alpha-equivalence clause for @{text "\<approx>bn"} has the form
2985
+ − 1665
3010
+ − 1666
\[
2985
+ − 1667
\mbox{\infer{@{text "C z\<^isub>1 \<dots> z\<^isub>s \<approx>bn C z\<PRIME>\<^isub>1 \<dots> z\<PRIME>\<^isub>s"}}
+ − 1668
{@{text "z\<^isub>1 R\<^isub>1 z\<PRIME>\<^isub>1 \<dots> z\<^isub>s R\<^isub>s z\<PRIME>\<^isub>s"}}}
3010
+ − 1669
\]\smallskip
2985
+ − 1670
+ − 1671
\noindent
+ − 1672
In this clause the relations @{text "R"}$_{1..s}$ are given by
+ − 1673
3010
+ − 1674
\[\mbox{
2985
+ − 1675
\begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}}
+ − 1676
$\bullet$ & @{text "z\<^isub>i \<approx>ty z\<PRIME>\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text rhs} and
3010
+ − 1677
is a recursive argument of @{text C},\smallskip\\
2985
+ − 1678
$\bullet$ & @{text "z\<^isub>i = z\<PRIME>\<^isub>i"} provided @{text "z\<^isub>i"} does not occur in @{text rhs}
3010
+ − 1679
and is a non-recursive argument of @{text C},\smallskip\\
2985
+ − 1680
$\bullet$ & @{text "z\<^isub>i \<approx>bn\<^isub>i z\<PRIME>\<^isub>i"} provided @{text "z\<^isub>i"} occurs in @{text rhs}
3010
+ − 1681
with the recursive call @{text "bn\<^isub>i x\<^isub>i"} and\smallskip\\
2985
+ − 1682
$\bullet$ & @{text True} provided @{text "z\<^isub>i"} occurs in @{text rhs} but without a
+ − 1683
recursive call.
3010
+ − 1684
\end{tabular}}
+ − 1685
\]\smallskip
2985
+ − 1686
+ − 1687
\noindent
2989
+ − 1688
This completes the definition of alpha-equivalence. As a sanity check, we can show
2985
+ − 1689
that the premises of empty binding clauses are a special case of the clauses for
3011
+ − 1690
non-empty ones (we just have to unfold the definition of
+ − 1691
$\approx_{\,\textit{set}}^{\textit{R}, \textit{fa}}$ and take @{text "0"}
2985
+ − 1692
for the existentially quantified permutation).
+ − 1693
3011
+ − 1694
Again let us take a look at a concrete example for these definitions. For
3021
+ − 1695
the specification shown in \eqref{letrecs}
2985
+ − 1696
we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and
3017
+ − 1697
$\approx_{\textit{bn}}$ with the following rules:
2985
+ − 1698
3016
+ − 1699
\begin{equation}\label{rawalpha}\mbox{
2985
+ − 1700
\begin{tabular}{@ {}c @ {}}
+ − 1701
\infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}}
3010
+ − 1702
{@{term "alpha_lst_ex (bn as, t) alpha_trm fa_trm (bn as', t')"} &
+ − 1703
\hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\\
+ − 1704
\\
2985
+ − 1705
\makebox[0mm]{\infer{@{text "Let_rec as t \<approx>\<^bsub>trm\<^esub> Let_rec as' t'"}}
3010
+ − 1706
{@{term "alpha_lst_ex (bn as, ast) alpha_trm2 fa_trm2 (bn as', ast')"}}}\\
+ − 1707
\\
2985
+ − 1708
+ − 1709
\begin{tabular}{@ {}c @ {}}
+ − 1710
\infer{@{text "ANil \<approx>\<^bsub>assn\<^esub> ANil"}}{}\hspace{9mm}
+ − 1711
\infer{@{text "ACons a t as \<approx>\<^bsub>assn\<^esub> ACons a' t' as"}}
3010
+ − 1712
{@{text "a = a'"} & \hspace{5mm}@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & \hspace{5mm}@{text "as \<approx>\<^bsub>assn\<^esub> as'"}}
+ − 1713
\end{tabular}\\
+ − 1714
\\
2985
+ − 1715
+ − 1716
\begin{tabular}{@ {}c @ {}}
+ − 1717
\infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\hspace{9mm}
+ − 1718
\infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}}
3010
+ − 1719
{@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & \hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}}
2985
+ − 1720
\end{tabular}
3010
+ − 1721
\end{tabular}}
3016
+ − 1722
\end{equation}\smallskip
2985
+ − 1723
+ − 1724
\noindent
3011
+ − 1725
Notice the difference between $\approx_{\textit{assn}}$ and
3023
+ − 1726
$\approx_{\textit{bn}}$: the latter only `tracks' alpha-equivalence of
2985
+ − 1727
the components in an assignment that are \emph{not} bound. This is needed in the
+ − 1728
clause for @{text "Let"} (which has
+ − 1729
a non-recursive binder).
+ − 1730
The underlying reason is that the terms inside an assignment are not meant
3023
+ − 1731
to be `under' the binder. Such a premise is \emph{not} needed in @{text "Let_rec"},
+ − 1732
because there all components of an assignment are `under' the binder.
3021
+ − 1733
Note also that in case of more than one body (that is in the @{text "Let_rec"}-case above)
3013
+ − 1734
we need to parametrise the relation $\approx_{\textit{list}}$ with a compound
+ − 1735
equivalence relation and a compound free-atom function. This is because the
3017
+ − 1736
corresponding binding clause specifies a binder with two bodies, namely
+ − 1737
@{text "as"} and @{text "t"}.
2985
+ − 1738
*}
+ − 1739
+ − 1740
section {* Establishing the Reasoning Infrastructure *}
+ − 1741
+ − 1742
text {*
3010
+ − 1743
Having made all necessary definitions for raw terms, we can start with
+ − 1744
establishing the reasoning infrastructure for the alpha-equated types @{text
+ − 1745
"ty\<AL>"}$_{1..n}$, that is the types the user originally specified. We
+ − 1746
give in this section and the next the proofs we need for establishing this
3012
+ − 1747
infrastructure. One point of our work is that we have completely
3010
+ − 1748
automated these proofs in Isabelle/HOL.
+ − 1749
+ − 1750
First we establish that the free-variable functions, the binding functions and the
3012
+ − 1751
alpha-equi\-va\-lences are equivariant.
2985
+ − 1752
3010
+ − 1753
\begin{lem}\mbox{}\\
+ − 1754
@{text "(i)"} The functions @{text "fa_ty"}$_{1..n}$, @{text "fa_bn"}$_{1..m}$ and
+ − 1755
@{text "bn"}$_{1..m}$ are equivariant.\\
+ − 1756
@{text "(ii)"} The relations @{text "\<approx>ty"}$_{1..n}$ and
+ − 1757
@{text "\<approx>bn"}$_{1..m}$ are equivariant.
+ − 1758
\end{lem}
+ − 1759
+ − 1760
\begin{proof}
3015
+ − 1761
The function package of Isabelle/HOL allows us to prove the first part by
+ − 1762
mutual induction over the definitions of the functions.\footnote{We have
3023
+ − 1763
that the free-atom functions are terminating. From this the function
3025
+ − 1764
package derives an induction principle~\cite{Krauss09}.} The second is by a
3015
+ − 1765
straightforward induction over the rules of @{text "\<approx>ty"}$_{1..n}$ and
+ − 1766
@{text "\<approx>bn"}$_{1..m}$ using the first part.
3010
+ − 1767
\end{proof}
+ − 1768
+ − 1769
\noindent
+ − 1770
Next we establish that the alpha-equivalence relations defined in the
3012
+ − 1771
previous section are indeed equivalence relations.
2985
+ − 1772
2989
+ − 1773
\begin{lem}\label{equiv}
3010
+ − 1774
The relations @{text "\<approx>ty"}$_{1..n}$ and @{text "\<approx>bn"}$_{1..m}$ are
+ − 1775
equivalence relations.
2989
+ − 1776
\end{lem}
2985
+ − 1777
+ − 1778
\begin{proof}
3017
+ − 1779
The proofs are by induction. The non-trivial
2985
+ − 1780
cases involve premises built up by $\approx_{\textit{set}}$,
+ − 1781
$\approx_{\textit{set+}}$ and $\approx_{\textit{list}}$. They
3010
+ − 1782
can be dealt with as in Lemma~\ref{alphaeq}. However, the transitivity
+ − 1783
case needs in addition the fact that the relations are equivariant.
2985
+ − 1784
\end{proof}
+ − 1785
+ − 1786
\noindent
3012
+ − 1787
We can feed the last lemma into our quotient package and obtain new types
+ − 1788
@{text "ty"}$^\alpha_{1..n}$ representing alpha-equated terms of types
+ − 1789
@{text "ty"}$_{1..n}$. We also obtain definitions for the term-constructors
3025
+ − 1790
@{text "C"}$^\alpha_{1..k}$ from the raw term-constructors @{text
3012
+ − 1791
"C"}$_{1..k}$, and similar definitions for the free-atom functions @{text
3010
+ − 1792
"fa_ty"}$^\alpha_{1..n}$ and @{text "fa_bn"}$^\alpha_{1..m}$ as well as the
3012
+ − 1793
binding functions @{text "bn"}$^\alpha_{1..m}$. However, these definitions
+ − 1794
are not really useful to the user, since they are given in terms of the
+ − 1795
isomorphisms we obtained by creating new types in Isabelle/HOL (recall the
+ − 1796
picture shown in the Introduction).
2985
+ − 1797
+ − 1798
The first useful property for the user is the fact that distinct
3012
+ − 1799
term-constructors are not equal, that is the property
2985
+ − 1800
3012
+ − 1801
\begin{equation}\label{distinctalpha}
2985
+ − 1802
\mbox{@{text "C"}$^\alpha$~@{text "x\<^isub>1 \<dots> x\<^isub>r"}~@{text "\<noteq>"}~%
+ − 1803
@{text "D"}$^\alpha$~@{text "y\<^isub>1 \<dots> y\<^isub>s"}}
3012
+ − 1804
\end{equation}\smallskip
2985
+ − 1805
+ − 1806
\noindent
+ − 1807
whenever @{text "C"}$^\alpha$~@{text "\<noteq>"}~@{text "D"}$^\alpha$.
3012
+ − 1808
In order to derive this property, we use the definition of alpha-equivalence
2985
+ − 1809
and establish that
+ − 1810
3012
+ − 1811
\begin{equation}\label{distinctraw}
2985
+ − 1812
\mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r"}\;$\not\approx$@{text ty}\;@{text "D y\<^isub>1 \<dots> y\<^isub>s"}}
3012
+ − 1813
\end{equation}\smallskip
2985
+ − 1814
+ − 1815
\noindent
3025
+ − 1816
holds for the corresponding raw term-constructors.
2985
+ − 1817
In order to deduce \eqref{distinctalpha} from \eqref{distinctraw}, our quotient
3025
+ − 1818
package needs to know that the raw term-constructors @{text "C"} and @{text "D"}
2989
+ − 1819
are \emph{respectful} w.r.t.~the alpha-equivalence relations (see \cite{Homeier05}).
3012
+ − 1820
Given, for example, @{text "C"} is of type @{text "ty"} with argument types
2985
+ − 1821
@{text "ty"}$_{1..r}$, respectfulness amounts to showing that
+ − 1822
3012
+ − 1823
\[\mbox{
2985
+ − 1824
@{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}
3012
+ − 1825
}\]\smallskip
2985
+ − 1826
+ − 1827
\noindent
3012
+ − 1828
holds under the assumptions \mbox{@{text
2985
+ − 1829
"x\<^isub>i \<approx>ty\<^isub>i x\<PRIME>\<^isub>i"}} whenever @{text "x\<^isub>i"}
3013
+ − 1830
and @{text "x\<PRIME>\<^isub>i"} are recursive arguments of @{text C}, and
3012
+ − 1831
@{text "x\<^isub>i = x\<PRIME>\<^isub>i"} whenever they are non-recursive arguments
+ − 1832
(similarly for @{text "D"}). For this we have to show
+ − 1833
by induction over the definitions of alpha-equivalences the following
+ − 1834
auxiliary implications
2985
+ − 1835
3012
+ − 1836
\begin{equation}\label{fnresp}\mbox{
+ − 1837
\begin{tabular}{lll}
+ − 1838
@{text "x \<approx>ty\<^isub>i x'"} & implies & @{text "fa_ty\<^isub>i x = fa_ty\<^isub>i x'"}\\
+ − 1839
@{text "x \<approx>ty\<^isub>l x'"} & implies & @{text "fa_bn\<^isub>j x = fa_bn\<^isub>j x'"}\\
+ − 1840
@{text "x \<approx>ty\<^isub>l x'"} & implies & @{text "bn\<^isub>j x = bn\<^isub>j x'"}\\
+ − 1841
@{text "x \<approx>ty\<^isub>l x'"} & implies & @{text "x \<approx>bn\<^isub>j x'"}\\
+ − 1842
\end{tabular}
+ − 1843
}\end{equation}\smallskip
+ − 1844
2985
+ − 1845
\noindent
3012
+ − 1846
whereby @{text "ty\<^isub>l"} is the type over which @{text "bn\<^isub>j"}
3013
+ − 1847
is defined. Whereas the first, second and last implication are true by
3012
+ − 1848
how we stated our definitions, the third \emph{only} holds because of our
+ − 1849
restriction imposed on the form of the binding functions---namely \emph{not}
3013
+ − 1850
to return any bound atoms. In Ott, in contrast, the user may define @{text
3012
+ − 1851
"bn"}$_{1..m}$ so that they return bound atoms and in this case the third
3013
+ − 1852
implication is \emph{not} true. A result is that in general the lifting of the
3012
+ − 1853
corresponding binding functions in Ott to alpha-equated terms is impossible.
3025
+ − 1854
Having established respectfulness for the raw term-constructors, the
2985
+ − 1855
quotient package is able to automatically deduce \eqref{distinctalpha} from
3017
+ − 1856
\eqref{distinctraw}.
+ − 1857
+ − 1858
Next we can lift the permutation operations defined in \eqref{ceqvt}. In
+ − 1859
order to make this lifting to go through, we have to show that the
+ − 1860
permutation operations are respectful. This amounts to showing that the
+ − 1861
alpha-equivalence relations are equivariant, which
+ − 1862
we already established in Lemma~\ref{equiv}. As a result we can add the
+ − 1863
equations
+ − 1864
+ − 1865
\begin{equation}\label{calphaeqvt}
+ − 1866
@{text "\<pi> \<bullet> (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r) = C\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) \<dots> (\<pi> \<bullet> x\<^isub>r)"}
+ − 1867
\end{equation}\smallskip
+ − 1868
+ − 1869
\noindent
+ − 1870
to our infrastructure. In a similar fashion we can lift the defining equations
+ − 1871
of the free-atom functions @{text "fa_ty\<AL>"}$_{1..n}$ and
+ − 1872
@{text "fa_bn\<AL>"}$_{1..m}$ as well as of the binding functions @{text
+ − 1873
"bn\<AL>"}$_{1..m}$ and size functions @{text "size_ty\<AL>"}$_{1..n}$.
3025
+ − 1874
The latter are defined automatically for the raw types @{text "ty"}$_{1..n}$
3017
+ − 1875
by the datatype package of Isabelle/HOL.
+ − 1876
3025
+ − 1877
We also need to lift the properties that characterise when two raw terms of the form
3010
+ − 1878
+ − 1879
\[
+ − 1880
\mbox{@{text "C x\<^isub>1 \<dots> x\<^isub>r \<approx>ty C x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}}
+ − 1881
\]\smallskip
2985
+ − 1882
+ − 1883
\noindent
2989
+ − 1884
are alpha-equivalent. This gives us conditions when the corresponding
+ − 1885
alpha-equated terms are \emph{equal}, namely
2985
+ − 1886
3010
+ − 1887
\[
2985
+ − 1888
@{text "C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r = C\<^sup>\<alpha> x\<PRIME>\<^isub>1 \<dots> x\<PRIME>\<^isub>r"}.
3010
+ − 1889
\]\smallskip
2985
+ − 1890
+ − 1891
\noindent
3017
+ − 1892
We call these conditions as \emph{quasi-injectivity}. They correspond to the
3021
+ − 1893
premises in our alpha-equiva\-lence relations, except that the
3017
+ − 1894
relations @{text "\<approx>ty"}$_{1..n}$ are all replaced by equality (and similarly
+ − 1895
the free-atom and binding functions are replaced by their lifted
+ − 1896
counterparts). Recall the alpha-equivalence rules for @{text "Let"} and
+ − 1897
@{text "Let_rec"} shown in \eqref{rawalpha}. For @{text "Let\<^sup>\<alpha>"} and
+ − 1898
@{text "Let_rec\<^sup>\<alpha>"} we have
3016
+ − 1899
+ − 1900
\begin{equation}\label{alphalift}\mbox{
+ − 1901
\begin{tabular}{@ {}c @ {}}
+ − 1902
\infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}}
+ − 1903
{@{term "alpha_lst_ex (bn_al as, t) equal fa_trm_al (bn as', t')"} &
+ − 1904
\hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\
+ − 1905
\\
+ − 1906
\makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}}
+ − 1907
{@{term "alpha_lst_ex (bn_al as, ast) equ2 fa_trm2_al (bn_al as', ast')"}}}\\
+ − 1908
\end{tabular}}
+ − 1909
\end{equation}\smallskip
+ − 1910
3017
+ − 1911
We can also add to our infrastructure cases lemmas and a (mutual)
3012
+ − 1912
induction principle for the types @{text "ty\<AL>"}$_{1..n}$. The cases
3015
+ − 1913
lemmas allow the user to deduce a property @{text "P"} by exhaustively
3025
+ − 1914
analysing how an element of a type, say @{text "ty\<AL>"}$_i$, can be
3015
+ − 1915
constructed (that means one case for each of the term-constructors in @{text
+ − 1916
"ty\<AL>"}$_i\,$). The lifted cases lemma for the type @{text
+ − 1917
"ty\<AL>"}$_i\,$ looks as follows
3012
+ − 1918
3015
+ − 1919
\begin{equation}\label{cases}
3012
+ − 1920
\infer{P}
+ − 1921
{\begin{array}{l}
+ − 1922
@{text "\<forall>x\<^isub>1\<dots>x\<^isub>k. y = C\<AL>\<^isub>1 x\<^isub>1 \<dots> x\<^isub>k \<Rightarrow> P"}\\
3030
+ − 1923
\hspace{5mm}\vdots\\
3012
+ − 1924
@{text "\<forall>x\<^isub>1\<dots>x\<^isub>l. y = C\<AL>\<^isub>m x\<^isub>1 \<dots> x\<^isub>l \<Rightarrow> P"}\\
+ − 1925
\end{array}}
3015
+ − 1926
\end{equation}\smallskip
3012
+ − 1927
2985
+ − 1928
\noindent
3044
+ − 1929
where @{text "y"} is a variable of type @{text "ty\<AL>"}$_i$ and @{text "P"} is the
3013
+ − 1930
property that is established by the case analysis. Similarly, we have a (mutual)
+ − 1931
induction principle for the types @{text "ty\<AL>"}$_{1..n}$, which is of the
+ − 1932
form
3012
+ − 1933
3015
+ − 1934
\begin{equation}\label{induct}
3012
+ − 1935
\infer{@{text "P\<^isub>1 y\<^isub>1 \<and> \<dots> \<and> P\<^isub>n y\<^isub>n "}}
+ − 1936
{\begin{array}{l}
+ − 1937
@{text "\<forall>x\<^isub>1\<dots>x\<^isub>k. P\<^isub>i x\<^isub>i \<and> \<dots> \<and> P\<^isub>j x\<^isub>j \<Rightarrow> P (C\<AL>\<^isub>1 x\<^isub>1 \<dots> x\<^isub>k)"}\\
3030
+ − 1938
\hspace{5mm}\vdots\\
3012
+ − 1939
@{text "\<forall>x\<^isub>1\<dots>x\<^isub>l. P\<^isub>r x\<^isub>r \<and> \<dots> \<and> P\<^isub>s x\<^isub>s \<Rightarrow> P (C\<AL>\<^isub>m x\<^isub>1 \<dots> x\<^isub>l)"}\\
+ − 1940
\end{array}}
3015
+ − 1941
\end{equation}\smallskip
+ − 1942
+ − 1943
\noindent
3021
+ − 1944
whereby the @{text P}$_{1..n}$ are the properties established by the
+ − 1945
induction, and the @{text y}$_{1..n}$ are of type @{text
+ − 1946
"ty\<AL>"}$_{1..n}$. Note that for the term constructors @{text
+ − 1947
"C"}$^\alpha_1$ the induction principle has a hypothesis of the form
3015
+ − 1948
+ − 1949
\[
+ − 1950
\mbox{@{text "\<forall>x\<^isub>1\<dots>x\<^isub>k. P\<^isub>i x\<^isub>i \<and> \<dots> \<and> P\<^isub>j x\<^isub>j \<Rightarrow> P (C\<AL>\<^sub>1 x\<^isub>1 \<dots> x\<^isub>k)"}}
+ − 1951
\]\smallskip
+ − 1952
+ − 1953
\noindent
+ − 1954
in which the @{text "x"}$_{i..j}$ @{text "\<subseteq>"} @{text "x"}$_{1..k}$ are the
+ − 1955
recursive arguments of this term constructor (similarly for the other
+ − 1956
term-constructors).
+ − 1957
+ − 1958
Recall the lambda-calculus with @{text "Let"}-patterns shown in
+ − 1959
\eqref{letpat}. The cases lemmas and the induction principle shown in
3023
+ − 1960
\eqref{cases} and \eqref{induct} boil down in that example to the following three inference
3025
+ − 1961
rules:
3015
+ − 1962
+ − 1963
\begin{equation}\label{inductex}\mbox{
3018
+ − 1964
\begin{tabular}{c}
+ − 1965
\multicolumn{1}{@ {\hspace{-5mm}}l}{cases lemmas:}\smallskip\\
3015
+ − 1966
\infer{@{text "P\<^bsub>trm\<^esub>"}}
3017
+ − 1967
{\begin{array}{@ {}l@ {}}
3015
+ − 1968
@{text "\<forall>x. y = Var\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
+ − 1969
@{text "\<forall>x\<^isub>1 x\<^isub>2. y = App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
+ − 1970
@{text "\<forall>x\<^isub>1 x\<^isub>2. y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
3018
+ − 1971
@{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"}
+ − 1972
\end{array}}\hspace{10mm}
3015
+ − 1973
+ − 1974
\infer{@{text "P\<^bsub>pat\<^esub>"}}
3017
+ − 1975
{\begin{array}{@ {}l@ {}}
3015
+ − 1976
@{text "\<forall>x. y = PVar\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>pat\<^esub>"}\\
+ − 1977
@{text "\<forall>x\<^isub>1 x\<^isub>2. y = PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub>"}
3018
+ − 1978
\end{array}}\medskip\\
+ − 1979
+ − 1980
\multicolumn{1}{@ {\hspace{-5mm}}l}{induction principle:}\smallskip\\
3015
+ − 1981
+ − 1982
\infer{@{text "P\<^bsub>trm\<^esub> y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}}
3017
+ − 1983
{\begin{array}{@ {}l@ {}}
3015
+ − 1984
@{text "\<forall>x. P\<^bsub>trm\<^esub> (Var\<^sup>\<alpha> x)"}\\
+ − 1985
@{text "\<forall>x\<^isub>1 x\<^isub>2. P\<^bsub>trm\<^esub> x\<^isub>1 \<and> P\<^bsub>trm\<^esub> x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\
+ − 1986
@{text "\<forall>x\<^isub>1 x\<^isub>2. P\<^bsub>trm\<^esub> x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\
3018
+ − 1987
@{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. P\<^bsub>pat\<^esub> x\<^isub>1 \<and> P\<^bsub>trm\<^esub> x\<^isub>2 \<and> P\<^bsub>trm\<^esub> x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub> (Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3)"}\\
3015
+ − 1988
@{text "\<forall>x. P\<^bsub>pat\<^esub> (PVar\<^sup>\<alpha> x)"}\\
+ − 1989
@{text "\<forall>x\<^isub>1 x\<^isub>2. P\<^bsub>pat\<^esub> x\<^isub>1 \<and> P\<^bsub>pat\<^esub> x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub> (PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}
+ − 1990
\end{array}}
+ − 1991
\end{tabular}}
+ − 1992
\end{equation}\smallskip
+ − 1993
+ − 1994
By working now completely on the alpha-equated level, we
3044
+ − 1995
can first show using \eqref{calphaeqvt} and Property~\ref{swapfreshfresh} that the support of each term
3015
+ − 1996
constructor is included in the support of its arguments,
+ − 1997
namely
+ − 1998
+ − 1999
\[
+ − 2000
@{text "(supp x\<^isub>1 \<union> \<dots> \<union> supp x\<^isub>r) supports (C\<^sup>\<alpha> x\<^isub>1 \<dots> x\<^isub>r)"}
3012
+ − 2001
\]\smallskip
+ − 2002
+ − 2003
\noindent
3015
+ − 2004
This allows us to prove using the induction principle for @{text "ty\<AL>"}$_{1..n}$
+ − 2005
that every element of type @{text "ty\<AL>"}$_{1..n}$ is finitely supported
3021
+ − 2006
(using Proposition~\ref{supportsprop}{\it (i)}).
3015
+ − 2007
Similarly, we can establish by induction that the free-atom functions and binding
+ − 2008
functions are equivariant, namely
2985
+ − 2009
3010
+ − 2010
\[\mbox{
+ − 2011
\begin{tabular}{rcl}
+ − 2012
@{text "\<pi> \<bullet> (fa_ty\<AL>\<^isub>i x)"} & $=$ & @{text "fa_ty\<AL>\<^isub>i (\<pi> \<bullet> x)"}\\
+ − 2013
@{text "\<pi> \<bullet> (fa_bn\<AL>\<^isub>j x)"} & $=$ & @{text "fa_bn\<AL>\<^isub>j (\<pi> \<bullet> x)"}\\
+ − 2014
@{text "\<pi> \<bullet> (bn\<AL>\<^isub>j x)"} & $=$ & @{text "bn\<AL>\<^isub>j (\<pi> \<bullet> x)"}\\
+ − 2015
\end{tabular}}
3012
+ − 2016
\]\smallskip
3010
+ − 2017
2985
+ − 2018
+ − 2019
\noindent
3015
+ − 2020
Lastly, we can show that the support of elements in @{text
3023
+ − 2021
"ty\<AL>"}$_{1..n}$ is the same as the free-atom functions @{text
3021
+ − 2022
"fa_ty\<AL>"}$_{1..n}$. This fact is important in the nominal setting where
+ − 2023
the general theory is formulated in terms of support and freshness, but also
+ − 2024
provides evidence that our notions of free-atoms and alpha-equivalence
3023
+ − 2025
`match up' correctly.
2985
+ − 2026
3017
+ − 2027
\begin{thm}\label{suppfa}
2985
+ − 2028
For @{text "x"}$_{1..n}$ with type @{text "ty\<AL>"}$_{1..n}$, we have
+ − 2029
@{text "supp x\<^isub>i = fa_ty\<AL>\<^isub>i x\<^isub>i"}.
2989
+ − 2030
\end{thm}
2985
+ − 2031
+ − 2032
\begin{proof}
3017
+ − 2033
The proof is by induction on @{text "x"}$_{1..n}$. In each case
2985
+ − 2034
we unfold the definition of @{text "supp"}, move the swapping inside the
+ − 2035
term-constructors and then use the quasi-injectivity lemmas in order to complete the
3015
+ − 2036
proof. For the abstraction cases we use then the facts derived in Theorem~\ref{suppabs},
+ − 2037
for which we have to know that every body of an abstraction is finitely supported.
3016
+ − 2038
This, we have proved earlier.
2985
+ − 2039
\end{proof}
+ − 2040
+ − 2041
\noindent
3023
+ − 2042
Consequently, we can replace the free-atom functions by @{text "supp"} in
3021
+ − 2043
our quasi-injection lemmas. In the examples shown in \eqref{alphalift}, for instance,
+ − 2044
we obtain for @{text "Let\<^sup>\<alpha>"} and @{text "Let_rec\<^sup>\<alpha>"}
3016
+ − 2045
+ − 2046
\[\mbox{
+ − 2047
\begin{tabular}{@ {}c @ {}}
+ − 2048
\infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}}
+ − 2049
{@{term "alpha_lst_ex (bn_al as, t) equal supp (bn_al as', t')"} &
+ − 2050
\hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\
+ − 2051
\\
+ − 2052
\makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}}
+ − 2053
{@{term "alpha_lst_ex (bn_al as, ast) equ2 supp2 (bn_al as', ast')"}}}\\
+ − 2054
\end{tabular}}
+ − 2055
\]\smallskip
+ − 2056
+ − 2057
\noindent
3021
+ − 2058
Taking into account that the compound equivalence relation @{term
3017
+ − 2059
"equ2"} and the compound free-atom function @{term "supp2"} are by
+ − 2060
definition equal to @{term "equal"} and @{term "supp"}, respectively, the
3021
+ − 2061
above rules simplify further to
3016
+ − 2062
+ − 2063
\[\mbox{
+ − 2064
\begin{tabular}{@ {}c @ {}}
+ − 2065
\infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}}
+ − 2066
{@{term "Abs_lst (bn_al as) t = Abs_lst (bn_al as') t'"} &
+ − 2067
\hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\
+ − 2068
\\
+ − 2069
\makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}}
+ − 2070
{@{term "Abs_lst (bn_al as) ast = Abs_lst (bn_al as') ast'"}}}\\
+ − 2071
\end{tabular}}
+ − 2072
\]\smallskip
+ − 2073
+ − 2074
\noindent
3017
+ − 2075
which means we can characterise equality between term-constructors (on the
+ − 2076
alpha-equated level) in terms of equality between the abstractions defined
+ − 2077
in Section~\ref{sec:binders}. From this we can deduce the support for @{text
+ − 2078
"Let\<^sup>\<alpha>"} and @{text "Let_rec\<^sup>\<alpha>"}, namely
+ − 2079
3016
+ − 2080
+ − 2081
\[\mbox{
+ − 2082
\begin{tabular}{l@ {\hspace{2mm}}l@ {\hspace{2mm}}l}
+ − 2083
@{text "supp (Let\<^sup>\<alpha> as t)"} & @{text "="} & @{text "(supp t - set (bn\<^sup>\<alpha> as)) \<union> fa\<AL>\<^bsub>bn\<^esub> as"}\\
+ − 2084
@{text "supp (Let_rec\<^sup>\<alpha> as t)"} & @{text "="} & @{text "(supp t \<union> supp as) - set (bn\<^sup>\<alpha> as)"}\\
+ − 2085
\end{tabular}}
+ − 2086
\]\smallskip
+ − 2087
+ − 2088
\noindent
+ − 2089
using the support of abstractions derived in Theorem~\ref{suppabs}.
+ − 2090
3021
+ − 2091
To sum up this section, we have established a reasoning infrastructure for the
3015
+ − 2092
types @{text "ty\<AL>"}$_{1..n}$ by first lifting definitions from the
3023
+ − 2093
`raw' level to the quotient level and then by proving facts about
3015
+ − 2094
these lifted definitions. All necessary proofs are generated automatically
+ − 2095
by custom ML-code.
2985
+ − 2096
*}
+ − 2097
+ − 2098
+ − 2099
section {* Strong Induction Principles *}
+ − 2100
+ − 2101
text {*
3015
+ − 2102
In the previous section we derived induction principles for alpha-equated
3017
+ − 2103
terms (see \eqref{induct} for the general form and \eqref{inductex} for an
3021
+ − 2104
example). This was done by lifting the corresponding inductions principles
3023
+ − 2105
for `raw' terms. We already employed these induction principles for
3021
+ − 2106
deriving several facts about alpha-equated terms, including the property that
3023
+ − 2107
the free-atom functions and the notion of support coincide. Still, we
3017
+ − 2108
call these induction principles \emph{weak}, because for a term-constructor,
+ − 2109
say \mbox{@{text "C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r"}}, the induction
+ − 2110
hypothesis requires us to establish (under some assumptions) a property
+ − 2111
@{text "P (C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r)"} for \emph{all} @{text
3021
+ − 2112
"x"}$_{1..r}$. The problem with this is that in the presence of binders we cannot make
3025
+ − 2113
any assumptions about the atoms that are bound---for example assuming the variable convention.
+ − 2114
One obvious way around this
3044
+ − 2115
problem is to rename bound atoms. Unfortunately, this leads to very clunky proofs
3021
+ − 2116
and makes formalisations grievous experiences (especially in the context of
3015
+ − 2117
multiple bound atoms).
+ − 2118
3021
+ − 2119
For the older versions of Nominal Isabelle we described in \cite{Urban08} a
+ − 2120
method for automatically strengthening weak induction principles. These
+ − 2121
stronger induction principles allow the user to make additional assumptions
+ − 2122
about bound atoms. The advantage of these assumptions is that they make in
+ − 2123
most cases any renaming of bound atoms unnecessary. To explain how the
+ − 2124
strengthening works, we use as running example the lambda-calculus with
+ − 2125
@{text "Let"}-patterns shown in \eqref{letpat}. Its weak induction principle
+ − 2126
is given in \eqref{inductex}. The stronger induction principle is as
+ − 2127
follows:
2985
+ − 2128
3015
+ − 2129
\begin{equation}\label{stronginduct}
+ − 2130
\mbox{
+ − 2131
\begin{tabular}{@ {}c@ {}}
+ − 2132
\infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}}
+ − 2133
{\begin{array}{l}
+ − 2134
@{text "\<forall>x c. P\<^bsub>trm\<^esub> c (Var\<^sup>\<alpha> x)"}\\
+ − 2135
@{text "\<forall>x\<^isub>1 x\<^isub>2 c. (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>2) \<Rightarrow> P\<^bsub>trm\<^esub> c (App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\
3017
+ − 2136
@{text "\<forall>x\<^isub>1 x\<^isub>2 c. atom x\<^isub>1 # c \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>2) \<Rightarrow> P\<^bsub>trm\<^esub> c (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\
+ − 2137
@{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3 c. (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c \<and>"}\\
3018
+ − 2138
\hspace{10mm}@{text "(\<forall>d. P\<^bsub>pat\<^esub> d x\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>2) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>3) \<Rightarrow> P\<^bsub>trm\<^esub> c (Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3)"}\\
3015
+ − 2139
@{text "\<forall>x c. P\<^bsub>pat\<^esub> c (PVar\<^sup>\<alpha> x)"}\\
+ − 2140
@{text "\<forall>x\<^isub>1 x\<^isub>2 c. (\<forall>d. P\<^bsub>pat\<^esub> d x\<^isub>1) \<and> (\<forall>d. P\<^bsub>pat\<^esub> d x\<^isub>2) \<Rightarrow> P\<^bsub>pat\<^esub> c (PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}
+ − 2141
\end{array}}
+ − 2142
\end{tabular}}
+ − 2143
\end{equation}\smallskip
+ − 2144
2985
+ − 2145
3015
+ − 2146
\noindent
3021
+ − 2147
Notice that instead of establishing two properties of the form @{text "
+ − 2148
P\<^bsub>trm\<^esub> y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}, as the
+ − 2149
weak one does, the stronger induction principle establishes the properties
+ − 2150
of the form @{text " P\<^bsub>trm\<^esub> c y\<^isub>1 \<and>
+ − 2151
P\<^bsub>pat\<^esub> c y\<^isub>2"} in which the additional parameter @{text
+ − 2152
c} is assumed to be of finite support. The purpose of @{text "c"} is to
3023
+ − 2153
`control' which freshness assumptions the binders should satisfy in the
3021
+ − 2154
@{text "Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"} cases: for @{text
+ − 2155
"Lam\<^sup>\<alpha>"} we can assume the bound atom @{text "x\<^isub>1"} is fresh
+ − 2156
for @{text "c"} (third line); for @{text "Let_pat\<^sup>\<alpha>"} we can assume
+ − 2157
all bound atoms from an assignment are fresh for @{text "c"} (fourth
3025
+ − 2158
line). In order to see how an instantiation for @{text "c"} in the
3036
+ − 2159
conclusion `controls' the premises, one has to take into account that
3025
+ − 2160
Isabelle/HOL is a typed logic. That means if @{text "c"} is instantiated
3044
+ − 2161
with, for example, a pair, then this type-constraint will be propagated to
3025
+ − 2162
the premises. The main point is that if @{text "c"} is instantiated
+ − 2163
appropriately, then the user can mimic the usual `pencil-and-paper'
+ − 2164
reasoning employing the variable convention about bound and free variables
+ − 2165
being distinct \cite{Urban08}.
3015
+ − 2166
3021
+ − 2167
In what follows we will show that the weak induction principle in
+ − 2168
\eqref{inductex} implies the strong one \eqref{stronginduct}. This fact was established for
3018
+ − 2169
single binders in \cite{Urban08} by some quite involved, nevertheless
3017
+ − 2170
automated, induction proof. In this paper we simplify the proof by
3023
+ − 2171
leveraging the automated proving tools from the function package of
+ − 2172
Isabelle/HOL \cite{Krauss09}. The reasoning principle behind these tools
3017
+ − 2173
is well-founded induction. To use them in our setting, we have to discharge
+ − 2174
two proof obligations: one is that we have well-founded measures (one for
+ − 2175
each type @{text "ty"}$^\alpha_{1..n}$) that decrease in every induction
3018
+ − 2176
step and the other is that we have covered all cases in the induction
+ − 2177
principle. Once these two proof obligations are discharged, the reasoning
3025
+ − 2178
infrastructure of the function package will automatically derive the
3021
+ − 2179
stronger induction principle. This way of establishing the stronger induction
3039
+ − 2180
principle is considerably simpler than the earlier work presented in \cite{Urban08}.
3015
+ − 2181
+ − 2182
As measures we can use the size functions @{text "size_ty"}$^\alpha_{1..n}$,
+ − 2183
which we lifted in the previous section and which are all well-founded. It
3017
+ − 2184
is straightforward to establish that the sizes decrease in every
3015
+ − 2185
induction step. What is left to show is that we covered all cases.
3017
+ − 2186
To do so, we have to derive stronger cases lemmas, which look in our
3018
+ − 2187
running example are as follows:
3017
+ − 2188
+ − 2189
\[\mbox{
3018
+ − 2190
\begin{tabular}{@ {}c@ {\hspace{4mm}}c@ {}}
2985
+ − 2191
\infer{@{text "P\<^bsub>trm\<^esub>"}}
3017
+ − 2192
{\begin{array}{@ {}l@ {}}
+ − 2193
@{text "\<forall>x. y = Var\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
+ − 2194
@{text "\<forall>x\<^isub>1 x\<^isub>2. y = App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
+ − 2195
@{text "\<forall>x\<^isub>1 x\<^isub>2. atom x\<^isub>1 # c \<and> y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\
3018
+ − 2196
@{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. set (bn\<^sup>\<alpha> x\<^isub>1) #\<^sup>* c \<and> y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"}
3017
+ − 2197
\end{array}} &
+ − 2198
+ − 2199
\infer{@{text "P\<^bsub>pat\<^esub>"}}
+ − 2200
{\begin{array}{@ {}l@ {}}
+ − 2201
@{text "\<forall>x. y = PVar\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>pat\<^esub>"}\\
+ − 2202
@{text "\<forall>x\<^isub>1 x\<^isub>2. y = PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub>"}
+ − 2203
\end{array}}
+ − 2204
\end{tabular}}
+ − 2205
\]\smallskip
+ − 2206
+ − 2207
\noindent
3021
+ − 2208
They are stronger in the sense that they allow us to assume in the @{text
+ − 2209
"Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"} cases that the bound atoms
3039
+ − 2210
avoid, or being fresh for, a context @{text "c"} (which is assumed to be finitely supported).
3018
+ − 2211
3023
+ − 2212
These stronger cases lemmas can be derived from the `weak' cases lemmas
3018
+ − 2213
given in \eqref{inductex}. This is trivial in case of patterns (the one on
+ − 2214
the right-hand side) since the weak and strong cases lemma coincide (there
+ − 2215
is no binding in patterns). Interesting are only the cases for @{text
+ − 2216
"Lam\<^sup>\<alpha>"} and @{text "Let_pat\<^sup>\<alpha>"}, where we have some binders and
3044
+ − 2217
therefore have an additional assumption about avoiding @{text "c"}. Let us
3021
+ − 2218
first establish the case for @{text "Lam\<^sup>\<alpha>"}. By the weak cases lemma
+ − 2219
\eqref{inductex} we can assume that
3017
+ − 2220
+ − 2221
\begin{equation}\label{assm}
+ − 2222
@{text "y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"}
+ − 2223
\end{equation}\smallskip
+ − 2224
+ − 2225
\noindent
3021
+ − 2226
holds, and need to establish @{text "P\<^bsub>trm\<^esub>"}. The stronger cases lemma has the
3018
+ − 2227
corresponding implication
3017
+ − 2228
+ − 2229
\begin{equation}\label{imp}
+ − 2230
@{text "\<forall>x\<^isub>1 x\<^isub>2. atom x\<^isub>1 # c \<and> y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}
+ − 2231
\end{equation}\smallskip
+ − 2232
+ − 2233
\noindent
3025
+ − 2234
which we must use in order to infer @{text "P\<^bsub>trm\<^esub>"}. Clearly, we cannot
3023
+ − 2235
use this implication directly, because we have no information whether or not @{text
3017
+ − 2236
"x\<^isub>1"} is fresh for @{text "c"}. However, we can use Properties
3039
+ − 2237
\ref{supppermeq} and \ref{avoiding} to rename @{text "x\<^isub>1"}. We know
3017
+ − 2238
by Theorem~\ref{suppfa} that @{text "{atom x\<^isub>1} #\<^sup>* Lam\<^sup>\<alpha>
+ − 2239
x\<^isub>1 x\<^isub>2"} (since its support is @{text "supp x\<^isub>2 -
3021
+ − 2240
{atom x\<^isub>1}"}). Property \ref{avoiding} provides us then with a
3017
+ − 2241
permutation @{text "\<pi>"}, such that @{text "{atom (\<pi> \<bullet> x\<^isub>1)} #\<^sup>*
+ − 2242
c"} and \mbox{@{text "supp (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2) #\<^sup>* \<pi>"}} hold.
3021
+ − 2243
By using Property \ref{supppermeq}, we can infer from the latter that
+ − 2244
+ − 2245
\[
+ − 2246
@{text "Lam\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"}
+ − 2247
\]\smallskip
+ − 2248
+ − 2249
\noindent
+ − 2250
holds. We can use this equation in the assumption \eqref{assm}, and hence
+ − 2251
use the implication \eqref{imp} with the renamed @{text "\<pi> \<bullet> x\<^isub>1"}
+ − 2252
and @{text "\<pi> \<bullet> x\<^isub>2"} for concluding this case.
3017
+ − 2253
3018
+ − 2254
The @{text "Let_pat\<^sup>\<alpha>"}-case involving a deep binder is slightly more complicated.
3017
+ − 2255
We have the assumption
+ − 2256
3018
+ − 2257
\begin{equation}\label{assmtwo}
+ − 2258
@{text "y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"}
3017
+ − 2259
\end{equation}\smallskip
+ − 2260
+ − 2261
\noindent
3021
+ − 2262
and the implication from the stronger cases lemma
3018
+ − 2263
3021
+ − 2264
\begin{equation}\label{impletpat}
3018
+ − 2265
@{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. set (bn\<^sup>\<alpha> x\<^isub>1) #\<^sup>* c \<and> y = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"}
3021
+ − 2266
\end{equation}\smallskip
3018
+ − 2267
+ − 2268
\noindent
3023
+ − 2269
The reason that this case is more complicated is that we cannot directly apply Property
3018
+ − 2270
\ref{avoiding} for obtaining a renaming permutation. Property \ref{avoiding} requires
+ − 2271
that the binders are fresh for the term in which we want to perform the renaming. But
3023
+ − 2272
this is not true in terms such as (using an informal notation)
3017
+ − 2273
+ − 2274
\[
3018
+ − 2275
@{text "Let (x, y) := (x, y) in (x, y)"}
+ − 2276
\]\smallskip
3017
+ − 2277
3018
+ − 2278
\noindent
3025
+ − 2279
where @{text x} and @{text y} are bound in the term, but are also free
3023
+ − 2280
in the right-hand side of the assignment. We can, however, obtain such a renaming permutation, say
3021
+ − 2281
@{text "\<pi>"}, for the abstraction @{term "Abs_lst (bn_al x\<^isub>1)
+ − 2282
x\<^isub>3"}. As a result we have \mbox{@{term "set (bn_al (\<pi> \<bullet> x\<^isub>1))
+ − 2283
\<sharp>* c"}} and @{term "Abs_lst (bn_al (\<pi> \<bullet> x\<^isub>1)) (\<pi> \<bullet> x\<^isub>3) =
+ − 2284
Abs_lst (bn_al x\<^isub>1) x\<^isub>3"} (remember @{text "set"} and @{text
+ − 2285
"bn\<^sup>\<alpha>"} are equivariant). Now the quasi-injective property for @{text
+ − 2286
"Let_pat\<^sup>\<alpha>"} states that
3018
+ − 2287
+ − 2288
\[
+ − 2289
\infer{@{text "Let_pat\<^sup>\<alpha> p t\<^isub>1 t\<^isub>2 = Let_pat\<^sup>\<alpha> p\<PRIME> t\<PRIME>\<^isub>1 t\<PRIME>\<^isub>2"}}
+ − 2290
{@{text "[bn\<^sup>\<alpha> p]\<^bsub>list\<^esub>. t\<^isub>2 = [bn\<^sup>\<alpha> p']\<^bsub>list\<^esub>. t\<PRIME>\<^isub>2"}\;\; &
+ − 2291
@{text "p \<approx>\<AL>\<^bsub>bn\<^esub> p\<PRIME>"}\;\; & @{text "t\<^isub>1 = t\<PRIME>\<^isub>1"}}
3017
+ − 2292
\]\smallskip
+ − 2293
3018
+ − 2294
\noindent
3021
+ − 2295
Since all atoms in a pattern are bound by @{text "Let_pat\<^sup>\<alpha>"}, we can infer
3023
+ − 2296
that @{text "(\<pi> \<bullet> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds for every @{text "\<pi>"}. Therefore we have that
3017
+ − 2297
3018
+ − 2298
\[
+ − 2299
@{text "Let_pat\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) x\<^isub>2 (\<pi> \<bullet> x\<^isub>3) = Let_pat\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"}
+ − 2300
\]\smallskip
+ − 2301
+ − 2302
\noindent
3023
+ − 2303
Taking the left-hand side in the assumption shown in \eqref{assmtwo}, we can use
3021
+ − 2304
the implication \eqref{impletpat} from the stronger cases lemma to infer @{text "P\<^bsub>trm\<^esub>"}, as needed.
3018
+ − 2305
3023
+ − 2306
The remaining difficulty is when a deep binder contains some atoms that are
+ − 2307
bound and some that are free. An example is @{text "Let\<^sup>\<alpha>"} in
3025
+ − 2308
\eqref{letrecs}. In such cases @{text "(\<pi> \<bullet> x\<^isub>1)
3023
+ − 2309
\<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} does not hold in general. The idea however is
+ − 2310
that @{text "\<pi>"} only renames atoms that become bound. In this way @{text "\<pi>"}
3025
+ − 2311
does not affect @{text "\<approx>\<AL>\<^bsub>bn\<^esub>"} (which only tracks alpha-equivalence of terms that are not
+ − 2312
under the binder). However, the problem is that the
3039
+ − 2313
permutation operation @{text "\<pi> \<bullet> x\<^isub>1"} applies to all atoms in @{text "x\<^isub>1"}. To avoid this
3021
+ − 2314
we introduce an auxiliary permutation operations, written @{text "_
+ − 2315
\<bullet>\<^bsub>bn\<^esub> _"}, for deep binders that only permutes bound atoms (or
+ − 2316
more precisely the atoms specified by the @{text "bn"}-functions) and leaves
3023
+ − 2317
the other atoms unchanged. Like the functions @{text "fa_bn"}$_{1..m}$, we
3025
+ − 2318
can define these permutation operations over raw terms analysing how the functions @{text
3023
+ − 2319
"bn"}$_{1..m}$ are defined. Assuming the user specified a clause
3017
+ − 2320
3019
+ − 2321
\[
+ − 2322
@{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"}
+ − 2323
\]\smallskip
3017
+ − 2324
2985
+ − 2325
\noindent
3019
+ − 2326
we define @{text "\<pi> \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>r) \<equiv> C y\<^isub>1 \<dots> y\<^isub>r"} with @{text "y\<^isub>i"} determined as follows:
+ − 2327
+ − 2328
\[\mbox{
2985
+ − 2329
\begin{tabular}{c@ {\hspace{2mm}}p{0.9\textwidth}}
+ − 2330
$\bullet$ & @{text "y\<^isub>i \<equiv> x\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text "rhs"}\\
3044
+ − 2331
$\bullet$ & @{text "y\<^isub>i \<equiv> \<pi> \<bullet>\<^bsub>bn\<^esub> x\<^isub>i"} provided @{text "bn x\<^isub>i"} is in @{text "rhs"}\\
3019
+ − 2332
$\bullet$ & @{text "y\<^isub>i \<equiv> \<pi> \<bullet> x\<^isub>i"} otherwise
+ − 2333
\end{tabular}}
+ − 2334
\]\smallskip
2985
+ − 2335
+ − 2336
\noindent
3025
+ − 2337
Using again the quotient package we can lift the auxiliary permutation operations
+ − 2338
@{text "_ \<bullet>\<^bsub>bn\<^esub> _"}
3044
+ − 2339
to alpha-equated terms. Moreover we can prove the following two properties:
2985
+ − 2340
2989
+ − 2341
\begin{lem}\label{permutebn}
3023
+ − 2342
Given a binding function @{text "bn\<^sup>\<alpha>"} and auxiliary equivalence @{text "\<approx>\<AL>\<^bsub>bn\<^esub>"}
+ − 2343
then for all @{text "\<pi>"}\smallskip\\
3019
+ − 2344
{\it (i)} @{text "\<pi> \<bullet> (bn\<^sup>\<alpha> x) = bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x)"} and\\
+ − 2345
{\it (ii)} @{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x) \<approx>\<AL>\<^bsub>bn\<^esub> x"}.
2989
+ − 2346
\end{lem}
2985
+ − 2347
+ − 2348
\begin{proof}
3021
+ − 2349
By induction on @{text x}. The properties follow by unfolding of the
+ − 2350
definitions.
2985
+ − 2351
\end{proof}
+ − 2352
+ − 2353
\noindent
3021
+ − 2354
The first property states that a permutation applied to a binding function
+ − 2355
is equivalent to first permuting the binders and then calculating the bound
3025
+ − 2356
atoms. The second states that @{text "_ \<bullet>\<AL>\<^bsub>bn\<^esub> _"} preserves
3021
+ − 2357
@{text "\<approx>\<AL>\<^bsub>bn\<^esub>"}. The main point of the auxiliary
3039
+ − 2358
permutation functions is that they allow us to rename just the bound atoms in a
3021
+ − 2359
term, without changing anything else.
2985
+ − 2360
3019
+ − 2361
Having the auxiliary permutation function in place, we can now solve all remaining cases.
3021
+ − 2362
For the @{text "Let\<^sup>\<alpha>"} term-constructor, for example, we can by Property \ref{avoiding}
3019
+ − 2363
obtain a @{text "\<pi>"} such that
+ − 2364
+ − 2365
\[
+ − 2366
@{text "(\<pi> \<bullet> (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c"} \hspace{10mm}
+ − 2367
@{text "\<pi> \<bullet> [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2 = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"}
+ − 2368
\]\smallskip
2985
+ − 2369
+ − 2370
\noindent
3023
+ − 2371
hold. Using the first part of Lemma \ref{permutebn}, we can simplify this
3019
+ − 2372
to @{text "set (bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)) #\<^sup>* c"} and
3025
+ − 2373
\mbox{@{text "[bn\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1)]\<^bsub>list\<^esub>. (\<pi> \<bullet> x\<^isub>2) = [bn\<^sup>\<alpha> x\<^isub>1]\<^bsub>list\<^esub>. x\<^isub>2"}}. Since
+ − 2374
@{text "(\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) \<approx>\<AL>\<^bsub>bn\<^esub> x\<^isub>1"} holds by the second part,
3019
+ − 2375
we can infer that
2985
+ − 2376
3019
+ − 2377
\[
+ − 2378
@{text "Let\<^sup>\<alpha> (\<pi> \<bullet>\<AL>\<^bsub>bn\<^esub> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"}
+ − 2379
\]\smallskip
+ − 2380
+ − 2381
\noindent
3021
+ − 2382
holds. This allows us to use the implication from the strong cases
3025
+ − 2383
lemma, and we are done.
3017
+ − 2384
3042
+ − 2385
Consequently, we can discharge all proof-obligations about having covered all
3023
+ − 2386
cases. This completes the proof establishing that the weak induction principles imply
3044
+ − 2387
the strong induction principles. These strong induction principles have already proved
+ − 2388
being very useful in practice, particularly for proving properties about
+ − 2389
capture-avoiding substitution \cite{Urban08}.
2985
+ − 2390
*}
+ − 2391
+ − 2392
+ − 2393
section {* Related Work\label{related} *}
+ − 2394
+ − 2395
text {*
+ − 2396
To our knowledge the earliest usage of general binders in a theorem prover
3010
+ − 2397
is described by Nara\-schew\-ski and Nipkow \cite{NaraschewskiNipkow99} with a
+ − 2398
formalisation of the algorithm W. This formalisation implements binding in
+ − 2399
type-schemes using a de-Bruijn indices representation. Since type-schemes in
+ − 2400
W contain only a single place where variables are bound, different indices
+ − 2401
do not refer to different binders (as in the usual de-Bruijn
+ − 2402
representation), but to different bound variables. A similar idea has been
3023
+ − 2403
recently explored for general binders by Chargu\'eraud \cite{chargueraud09}
+ − 2404
in the locally nameless approach to
+ − 2405
binding. There, de-Bruijn indices consist of two
3010
+ − 2406
numbers, one referring to the place where a variable is bound, and the other
+ − 2407
to which variable is bound. The reasoning infrastructure for both
+ − 2408
representations of bindings comes for free in theorem provers like
3013
+ − 2409
Isabelle/HOL and Coq, since the corresponding term-calculi can be implemented
3023
+ − 2410
as `normal' datatypes. However, in both approaches it seems difficult to
+ − 2411
achieve our fine-grained control over the `semantics' of bindings
3010
+ − 2412
(i.e.~whether the order of binders should matter, or vacuous binders should
+ − 2413
be taken into account). To do so, one would require additional predicates
+ − 2414
that filter out unwanted terms. Our guess is that such predicates result in
3013
+ − 2415
rather intricate formal reasoning. We are not aware of any formalisation of
+ − 2416
a non-trivial language that uses Chargu\'eraud's idea.
2985
+ − 2417
+ − 2418
Another technique for representing binding is higher-order abstract syntax
3023
+ − 2419
(HOAS), which for example is implemented in the Twelf system \cite{pfenningsystem}.
+ − 2420
This representation technique supports very elegantly many aspects of
3024
+ − 2421
\emph{single} binding, and impressive work by Lee et al~\cite{LeeCraryHarper07}
3023
+ − 2422
has been done that uses HOAS for mechanising the metatheory of SML. We
3010
+ − 2423
are, however, not aware how multiple binders of SML are represented in this
+ − 2424
work. Judging from the submitted Twelf-solution for the POPLmark challenge,
+ − 2425
HOAS cannot easily deal with binding constructs where the number of bound
3023
+ − 2426
variables is not fixed. For example, in the second part of this challenge,
3010
+ − 2427
@{text "Let"}s involve patterns that bind multiple variables at once. In
+ − 2428
such situations, HOAS seems to have to resort to the
+ − 2429
iterated-single-binders-approach with all the unwanted consequences when
+ − 2430
reasoning about the resulting terms.
+ − 2431
2985
+ − 2432
+ − 2433
Two formalisations involving general binders have been
+ − 2434
performed in older
+ − 2435
versions of Nominal Isabelle (one about Psi-calculi and one about algorithm W
+ − 2436
\cite{BengtsonParow09,UrbanNipkow09}). Both
+ − 2437
use the approach based on iterated single binders. Our experience with
+ − 2438
the latter formalisation has been disappointing. The major pain arose from
3023
+ − 2439
the need to `unbind' variables. This can be done in one step with our
2985
+ − 2440
general binders described in this paper, but needs a cumbersome
+ − 2441
iteration with single binders. The resulting formal reasoning turned out to
3010
+ − 2442
be rather unpleasant.
2985
+ − 2443
3010
+ − 2444
The most closely related work to the one presented here is the Ott-tool by
+ − 2445
Sewell et al \cite{ott-jfp} and the C$\alpha$ml language by Pottier
+ − 2446
\cite{Pottier06}. Ott is a nifty front-end for creating \LaTeX{} documents
+ − 2447
from specifications of term-calculi involving general binders. For a subset
3023
+ − 2448
of the specifications Ott can also generate theorem prover code using a `raw'
3010
+ − 2449
representation of terms, and in Coq also a locally nameless
+ − 2450
representation. The developers of this tool have also put forward (on paper)
+ − 2451
a definition for alpha-equivalence and free variables for terms that can be
+ − 2452
specified in Ott. This definition is rather different from ours, not using
+ − 2453
any nominal techniques. To our knowledge there is no concrete mathematical
+ − 2454
result concerning this notion of alpha-equivalence and free variables. We
+ − 2455
have proved that our definitions lead to alpha-equated terms, whose support
3025
+ − 2456
is as expected (that means bound atoms are removed from the support). We
3023
+ − 2457
also showed that our specifications lift from `raw' types to types of
3044
+ − 2458
alpha-equivalence classes. For this we have established (automatically) that every
3023
+ − 2459
term-constructor and function defined for `raw' types
+ − 2460
is respectful w.r.t.~alpha-equivalence.
2985
+ − 2461
3010
+ − 2462
Although we were heavily inspired by the syntax of Ott, its definition of
+ − 2463
alpha-equi\-valence is unsuitable for our extension of Nominal
+ − 2464
Isabelle. First, it is far too complicated to be a basis for automated
+ − 2465
proofs implemented on the ML-level of Isabelle/HOL. Second, it covers cases
+ − 2466
of binders depending on other binders, which just do not make sense for our
+ − 2467
alpha-equated terms. Third, it allows empty types that have no meaning in a
+ − 2468
HOL-based theorem prover. We also had to generalise slightly Ott's binding
+ − 2469
clauses. In Ott one specifies binding clauses with a single body; we allow
+ − 2470
more than one. We have to do this, because this makes a difference for our
+ − 2471
notion of alpha-equivalence in case of \isacommand{binds (set)} and
+ − 2472
\isacommand{binds (set+)}. Consider the examples
2985
+ − 2473
3010
+ − 2474
\[\mbox{
2985
+ − 2475
\begin{tabular}{@ {}l@ {\hspace{2mm}}l@ {}}
+ − 2476
@{text "Foo\<^isub>1 xs::name fset t::trm s::trm"} &
3004
+ − 2477
\isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "t s"}\\
2985
+ − 2478
@{text "Foo\<^isub>2 xs::name fset t::trm s::trm"} &
3004
+ − 2479
\isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "t"},
+ − 2480
\isacommand{binds (set)} @{text "xs"} \isacommand{in} @{text "s"}\\
3010
+ − 2481
\end{tabular}}
+ − 2482
\]\smallskip
2985
+ − 2483
+ − 2484
\noindent
3010
+ − 2485
In the first term-constructor we have a single body that happens to be
3023
+ − 2486
`spread' over two arguments; in the second term-constructor we have two
3010
+ − 2487
independent bodies in which the same variables are bound. As a result we
+ − 2488
have\footnote{Assuming @{term "a \<noteq> b"}, there is no permutation that can
3011
+ − 2489
make @{text "(a, b)"} equal with both @{text "(a, b)"} and @{text "(b, a)"}, but
3010
+ − 2490
there are two permutations so that we can make @{text "(a, b)"} and @{text
+ − 2491
"(a, b)"} equal with one permutation, and @{text "(a, b)"} and @{text "(b,
+ − 2492
a)"} with the other.}
+ − 2493
+ − 2494
+ − 2495
\[\mbox{
+ − 2496
\begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}l}
+ − 2497
@{text "Foo\<^isub>1 {a, b} (a, b) (a, b)"} & $\not=$ &
+ − 2498
@{text "Foo\<^isub>1 {a, b} (a, b) (b, a)"}
+ − 2499
\end{tabular}}
+ − 2500
\]\smallskip
+ − 2501
+ − 2502
\noindent
+ − 2503
but
2985
+ − 2504
3010
+ − 2505
\[\mbox{
+ − 2506
\begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}l}
+ − 2507
@{text "Foo\<^isub>2 {a, b} (a, b) (a, b)"} & $=$ &
+ − 2508
@{text "Foo\<^isub>2 {a, b} (a, b) (b, a)"}\\
+ − 2509
\end{tabular}}
+ − 2510
\]\smallskip
+ − 2511
+ − 2512
\noindent
+ − 2513
and therefore need the extra generality to be able to distinguish between
+ − 2514
both specifications. Because of how we set up our definitions, we also had
+ − 2515
to impose some restrictions (like a single binding function for a deep
+ − 2516
binder) that are not present in Ott. Our expectation is that we can still
+ − 2517
cover many interesting term-calculi from programming language research, for
3023
+ − 2518
example the Core-Haskell language from the Introduction. With the work
3025
+ − 2519
presented in this paper we can define it formally as shown in
3023
+ − 2520
Figure~\ref{nominalcorehas} and then Nominal Isabelle derives automatically
+ − 2521
a corresponding reasoning infrastructure.
3013
+ − 2522
3023
+ − 2523
\begin{figure}[p]
3013
+ − 2524
\begin{boxedminipage}{\linewidth}
+ − 2525
\small
+ − 2526
\begin{tabular}{l}
+ − 2527
\isacommand{atom\_decl}~@{text "var cvar tvar"}\\[1mm]
+ − 2528
\isacommand{nominal\_datatype}~@{text "tkind ="}~@{text "KStar"}~$|$~@{text "KFun tkind tkind"}\\
+ − 2529
\isacommand{and}~@{text "ckind ="}~@{text "CKSim ty ty"}\\
+ − 2530
\isacommand{and}~@{text "ty ="}~@{text "TVar tvar"}~$|$~@{text "T string"}~$|$~@{text "TApp ty ty"}\\
+ − 2531
$|$~@{text "TFun string ty_list"}~%
+ − 2532
$|$~@{text "TAll tv::tvar tkind ty::ty"}\hspace{3mm}\isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text ty}\\
+ − 2533
$|$~@{text "TArr ckind ty"}\\
+ − 2534
\isacommand{and}~@{text "ty_lst ="}~@{text "TNil"}~$|$~@{text "TCons ty ty_lst"}\\
+ − 2535
\isacommand{and}~@{text "cty ="}~@{text "CVar cvar"}~%
+ − 2536
$|$~@{text "C string"}~$|$~@{text "CApp cty cty"}~$|$~@{text "CFun string co_lst"}\\
+ − 2537
$|$~@{text "CAll cv::cvar ckind cty::cty"}\hspace{3mm}\isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text cty}\\
+ − 2538
$|$~@{text "CArr ckind cty"}~$|$~@{text "CRefl ty"}~$|$~@{text "CSym cty"}~$|$~@{text "CCirc cty cty"}\\
+ − 2539
$|$~@{text "CAt cty ty"}~$|$~@{text "CLeft cty"}~$|$~@{text "CRight cty"}~$|$~@{text "CSim cty cty"}\\
+ − 2540
$|$~@{text "CRightc cty"}~$|$~@{text "CLeftc cty"}~$|$~@{text "Coerce cty cty"}\\
+ − 2541
\isacommand{and}~@{text "co_lst ="}~@{text "CNil"}~$|$~@{text "CCons cty co_lst"}\\
+ − 2542
\isacommand{and}~@{text "trm ="}~@{text "Var var"}~$|$~@{text "K string"}\\
+ − 2543
$|$~@{text "LAM_ty tv::tvar tkind t::trm"}\hspace{3mm}\isacommand{binds}~@{text "tv"}~\isacommand{in}~@{text t}\\
+ − 2544
$|$~@{text "LAM_cty cv::cvar ckind t::trm"}\hspace{3mm}\isacommand{binds}~@{text "cv"}~\isacommand{in}~@{text t}\\
+ − 2545
$|$~@{text "App_ty trm ty"}~$|$~@{text "App_cty trm cty"}~$|$~@{text "App trm trm"}\\
+ − 2546
$|$~@{text "Lam v::var ty t::trm"}\hspace{3mm}\isacommand{binds}~@{text "v"}~\isacommand{in}~@{text t}\\
+ − 2547
$|$~@{text "Let x::var ty trm t::trm"}\hspace{3mm}\isacommand{binds}~@{text x}~\isacommand{in}~@{text t}\\
+ − 2548
$|$~@{text "Case trm assoc_lst"}~$|$~@{text "Cast trm co"}\\
+ − 2549
\isacommand{and}~@{text "assoc_lst ="}~@{text ANil}~%
+ − 2550
$|$~@{text "ACons p::pat t::trm assoc_lst"}\hspace{3mm}\isacommand{binds}~@{text "bv p"}~\isacommand{in}~@{text t}\\
+ − 2551
\isacommand{and}~@{text "pat ="}~@{text "Kpat string tvtk_lst tvck_lst vt_lst"}\\
+ − 2552
\isacommand{and}~@{text "vt_lst ="}~@{text VTNil}~$|$~@{text "VTCons var ty vt_lst"}\\
+ − 2553
\isacommand{and}~@{text "tvtk_lst ="}~@{text TVTKNil}~$|$~@{text "TVTKCons tvar tkind tvtk_lst"}\\
+ − 2554
\isacommand{and}~@{text "tvck_lst ="}~@{text TVCKNil}~$|$ @{text "TVCKCons cvar ckind tvck_lst"}\\
+ − 2555
\isacommand{binder}\\
+ − 2556
@{text "bv :: pat \<Rightarrow> atom list"}~\isacommand{and}\\
+ − 2557
@{text "bv\<^isub>1 :: vt_lst \<Rightarrow> atom list"}~\isacommand{and}\\
+ − 2558
@{text "bv\<^isub>2 :: tvtk_lst \<Rightarrow> atom list"}~\isacommand{and}\\
+ − 2559
@{text "bv\<^isub>3 :: tvck_lst \<Rightarrow> atom list"}\\
+ − 2560
\isacommand{where}\\
+ − 2561
\phantom{$|$}~@{text "bv (K s tvts tvcs vs) = (bv\<^isub>3 tvts) @ (bv\<^isub>2 tvcs) @ (bv\<^isub>1 vs)"}\\
+ − 2562
$|$~@{text "bv\<^isub>1 VTNil = []"}\\
+ − 2563
$|$~@{text "bv\<^isub>1 (VTCons x ty tl) = (atom x)::(bv\<^isub>1 tl)"}\\
+ − 2564
$|$~@{text "bv\<^isub>2 TVTKNil = []"}\\
+ − 2565
$|$~@{text "bv\<^isub>2 (TVTKCons a ty tl) = (atom a)::(bv\<^isub>2 tl)"}\\
+ − 2566
$|$~@{text "bv\<^isub>3 TVCKNil = []"}\\
+ − 2567
$|$~@{text "bv\<^isub>3 (TVCKCons c cty tl) = (atom c)::(bv\<^isub>3 tl)"}\\
+ − 2568
\end{tabular}
+ − 2569
\end{boxedminipage}
3023
+ − 2570
\caption{A definition for Core-Haskell in Nominal Isabelle. For the moment we
3013
+ − 2571
do not support nested types; therefore we explicitly have to unfold the
3025
+ − 2572
lists @{text "co_lst"}, @{text "assoc_lst"} and so on. Apart from that limitation, the
3023
+ − 2573
definition follows closely the original shown in Figure~\ref{corehas}. The
+ − 2574
point of our work is that having made such a definition in Nominal Isabelle,
+ − 2575
one obtains automatically a reasoning infrastructure for Core-Haskell.
3013
+ − 2576
\label{nominalcorehas}}
+ − 2577
\end{figure}
3023
+ − 2578
\afterpage{\clearpage}
3010
+ − 2579
+ − 2580
Pottier presents a programming language, called C$\alpha$ml, for
+ − 2581
representing terms with general binders inside OCaml \cite{Pottier06}. This
+ − 2582
language is implemented as a front-end that can be translated to OCaml with
+ − 2583
the help of a library. He presents a type-system in which the scope of
+ − 2584
general binders can be specified using special markers, written @{text
+ − 2585
"inner"} and @{text "outer"}. It seems our and his specifications can be
+ − 2586
inter-translated as long as ours use the binding mode \isacommand{binds}
+ − 2587
only. However, we have not proved this. Pottier gives a definition for
2989
+ − 2588
alpha-equivalence, which also uses a permutation operation (like ours).
2985
+ − 2589
Still, this definition is rather different from ours and he only proves that
3010
+ − 2590
it defines an equivalence relation. A complete reasoning infrastructure is
+ − 2591
well beyond the purposes of his language. Similar work for Haskell with
+ − 2592
similar results was reported by Cheney \cite{Cheney05a} and more recently
3011
+ − 2593
by Weirich et al \cite{WeirichYorgeySheard11}.
3010
+ − 2594
+ − 2595
In a slightly different domain (programming with dependent types),
3011
+ − 2596
Altenkirch et al \cite{Altenkirch10} present a calculus with a notion of
+ − 2597
alpha-equivalence related to our binding mode \isacommand{binds (set+)}.
3010
+ − 2598
Their definition is similar to the one by Pottier, except that it has a more
+ − 2599
operational flavour and calculates a partial (renaming) map. In this way,
+ − 2600
the definition can deal with vacuous binders. However, to our best
+ − 2601
knowledge, no concrete mathematical result concerning this definition of
+ − 2602
alpha-equivalence has been proved.
2985
+ − 2603
*}
+ − 2604
+ − 2605
section {* Conclusion *}
+ − 2606
+ − 2607
text {*
2989
+ − 2608
3010
+ − 2609
We have presented an extension of Nominal Isabelle for dealing with general
3023
+ − 2610
binders, that is where term-constructors have multiple bound atoms. For this
3010
+ − 2611
extension we introduced new definitions of alpha-equivalence and automated
+ − 2612
all necessary proofs in Isabelle/HOL. To specify general binders we used
+ − 2613
the syntax from Ott, but extended it in some places and restricted
3023
+ − 2614
it in others so that the definitions make sense in the context of alpha-equated
3010
+ − 2615
terms. We also introduced two binding modes (set and set+) that do not exist
+ − 2616
in Ott. We have tried out the extension with calculi such as Core-Haskell,
+ − 2617
type-schemes and approximately a dozen of other typical examples from
+ − 2618
programming language research~\cite{SewellBestiary}. The code will
3044
+ − 2619
eventually become part of the Isabelle distribution.\footnote{It
3023
+ − 2620
can be downloaded already from \href{http://isabelle.in.tum.de/nominal/download}
2985
+ − 2621
{http://isabelle.in.tum.de/nominal/download}.}
+ − 2622
+ − 2623
We have left out a discussion about how functions can be defined over
3013
+ − 2624
alpha-equated terms involving general binders. In earlier versions of
+ − 2625
Nominal Isabelle this turned out to be a thorny issue. We hope to do better
+ − 2626
this time by using the function package \cite{Krauss09} that has recently
2985
+ − 2627
been implemented in Isabelle/HOL and also by restricting function
3013
+ − 2628
definitions to equivariant functions (for them we can provide more
+ − 2629
automation).
2985
+ − 2630
+ − 2631
There are some restrictions we imposed in this paper that we would like to lift in
+ − 2632
future work. One is the exclusion of nested datatype definitions. Nested
3041
+ − 2633
datatype definitions would allow one to specify, for instance, the function kinds
2985
+ − 2634
in Core-Haskell as @{text "TFun string (ty list)"} instead of the unfolded
+ − 2635
version @{text "TFun string ty_list"} (see Figure~\ref{nominalcorehas}). To
3010
+ − 2636
achieve this, we need more clever implementation than we have
+ − 2637
at the moment. However, really lifting this restriction will involve major
3023
+ − 2638
work on the underlying datatype package of Isabelle/HOL.
2985
+ − 2639
+ − 2640
A more interesting line of investigation is whether we can go beyond the
+ − 2641
simple-minded form of binding functions that we adopted from Ott. At the moment, binding
+ − 2642
functions can only return the empty set, a singleton atom set or unions
+ − 2643
of atom sets (similarly for lists). It remains to be seen whether
+ − 2644
properties like
+ − 2645
3010
+ − 2646
\[
+ − 2647
\mbox{@{text "fa_ty x = bn x \<union> fa_bn x"}}
+ − 2648
\]\smallskip
2985
+ − 2649
+ − 2650
\noindent
+ − 2651
allow us to support more interesting binding functions.
+ − 2652
+ − 2653
We have also not yet played with other binding modes. For example we can
3010
+ − 2654
imagine that there is need for a binding mode where instead of usual lists,
+ − 2655
we abstract lists of distinct elements (the corresponding type @{text
+ − 2656
"dlist"} already exists in the library of Isabelle/HOL). We expect the
3039
+ − 2657
presented work can be extended to accommodate such binding modes.\medskip
2985
+ − 2658
+ − 2659
\noindent
2989
+ − 2660
{\bf Acknowledgements:} We are very grateful to Andrew Pitts for many
+ − 2661
discussions about Nominal Isabelle. We thank Peter Sewell for making the
+ − 2662
informal notes \cite{SewellBestiary} available to us and also for patiently
+ − 2663
explaining some of the finer points of the Ott-tool. Stephanie Weirich
+ − 2664
suggested to separate the subgrammars of kinds and types in our Core-Haskell
3041
+ − 2665
example. Ramana Kumar and Andrei Popescu helped us with comments about
+ − 2666
an earlier version of this paper.
2985
+ − 2667
*}
+ − 2668
+ − 2669
+ − 2670
(*<*)
+ − 2671
end
+ − 2672
(*>*)