146 \end{center} |
146 \end{center} |
147 |
147 |
148 \noindent |
148 \noindent |
149 As a result, we provide three general binding mechanisms each of which binds |
149 As a result, we provide three general binding mechanisms each of which binds |
150 multiple variables at once, and let the user chose which one is intended |
150 multiple variables at once, and let the user chose which one is intended |
151 when formalising a programming language calculus. |
151 when formalising a term-calculus. |
152 |
152 |
153 By providing these general binding mechanisms, however, we have to work |
153 By providing these general binding mechanisms, however, we have to work |
154 around a problem that has been pointed out by Pottier \cite{Pottier06} and |
154 around a problem that has been pointed out by Pottier \cite{Pottier06} and |
155 Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form |
155 Cheney \cite{Cheney05}: in @{text "\<LET>"}-constructs of the form |
156 % |
156 % |
340 for alpha-equated terms. |
340 for alpha-equated terms. |
341 |
341 |
342 The examples we have in mind where our reasoning infrastructure will be |
342 The examples we have in mind where our reasoning infrastructure will be |
343 helpful includes the term language of System @{text "F\<^isub>C"}, also |
343 helpful includes the term language of System @{text "F\<^isub>C"}, also |
344 known as Core-Haskell (see Figure~\ref{corehas}). This term language |
344 known as Core-Haskell (see Figure~\ref{corehas}). This term language |
345 involves patterns that have lists of type-, coercion- and term-variables |
345 involves patterns that have lists of type-, coercion- and term-variables, |
346 all of which are bound in @{text "\<CASE>"}-expressions. One |
346 all of which are bound in @{text "\<CASE>"}-expressions. One |
347 difficulty is that each of these variables come with a kind or type |
347 difficulty is that each of these variables come with a kind or type |
348 annotation. Representing such binders with single binders and reasoning |
348 annotation. Representing such binders with single binders and reasoning |
349 about them in a theorem prover would be a major pain. \medskip |
349 about them in a theorem prover would be a major pain. \medskip |
350 |
350 |
393 \end{center} |
393 \end{center} |
394 \end{boxedminipage} |
394 \end{boxedminipage} |
395 \caption{The term-language of System @{text "F\<^isub>C"} |
395 \caption{The term-language of System @{text "F\<^isub>C"} |
396 \cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this |
396 \cite{CoreHaskell}, also often referred to as \emph{Core-Haskell}. In this |
397 version of the term-language we made a modification by separating the |
397 version of the term-language we made a modification by separating the |
398 grammars for type and coercion kinds, as well as for types and coercion |
398 grammars for type kinds and coercion kinds, as well as for types and coercion |
399 types. For this paper the interesting term-constructor is @{text "\<CASE>"}, |
399 types. For this paper the interesting term-constructor is @{text "\<CASE>"}, |
400 which binds multiple type-, coercion- and term-variables.\label{corehas}} |
400 which binds multiple type-, coercion- and term-variables.\label{corehas}} |
401 \end{figure} |
401 \end{figure} |
402 *} |
402 *} |
403 |
403 |
407 At its core, Nominal Isabelle is an adaption of the nominal logic work by |
407 At its core, Nominal Isabelle is an adaption of the nominal logic work by |
408 Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in |
408 Pitts \cite{Pitts03}. This adaptation for Isabelle/HOL is described in |
409 \cite{HuffmanUrban10} (including proofs). We shall briefly review this work |
409 \cite{HuffmanUrban10} (including proofs). We shall briefly review this work |
410 to aid the description of what follows. |
410 to aid the description of what follows. |
411 |
411 |
412 Two central notions in the nominal |
412 Two central notions in the nominal logic work are sorted atoms and |
413 logic work are sorted atoms and sort-respecting permutations of atoms. The |
413 sort-respecting permutations of atoms. We will use the variables @{text "a, |
414 sorts can be used to represent different kinds of variables, such as the |
414 b, c, \<dots>"} to stand for atoms and @{text "p, q, \<dots>"} to stand for |
415 term-, coercion- and type-variables in Core-Haskell, and it is assumed that there is an |
415 permutations. The sorts of atoms can be used to represent different kinds of |
416 infinite supply of atoms for each sort. However, in order to simplify the |
416 variables, such as the term-, coercion- and type-variables in Core-Haskell, |
417 description, we shall assume in what follows that there is only one sort of |
417 and it is assumed that there is an infinite supply of atoms for each |
418 atoms. |
418 sort. However, in order to simplify the description, we shall assume in what |
|
419 follows that there is only one sort of atoms. |
419 |
420 |
420 Permutations are bijective functions from atoms to atoms that are |
421 Permutations are bijective functions from atoms to atoms that are |
421 the identity everywhere except on a finite number of atoms. There is a |
422 the identity everywhere except on a finite number of atoms. There is a |
422 two-place permutation operation written |
423 two-place permutation operation written |
423 % |
424 % |
484 A striking consequence of these definitions is that we can prove |
485 A striking consequence of these definitions is that we can prove |
485 without knowing anything about the structure of @{term x} that |
486 without knowing anything about the structure of @{term x} that |
486 swapping two fresh atoms, say @{text a} and @{text b}, leave |
487 swapping two fresh atoms, say @{text a} and @{text b}, leave |
487 @{text x} unchanged. |
488 @{text x} unchanged. |
488 |
489 |
489 \begin{property} |
490 \begin{property}\label{swapfreshfresh} |
490 @{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
491 @{thm[mode=IfThen] swap_fresh_fresh[no_vars]} |
491 \end{property} |
492 \end{property} |
492 |
493 |
493 \noindent |
494 While often the support of an object can be relatively easily |
494 While often the support of an object can be easily described, for |
495 described, for example\\[-6mm] |
495 example\\[-6mm] |
|
496 % |
496 % |
497 \begin{eqnarray} |
497 \begin{eqnarray} |
498 @{term "supp a"} & = & @{term "{a}"}\\ |
498 @{term "supp a"} & = & @{term "{a}"}\\ |
499 @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\ |
499 @{term "supp (x, y)"} & = & @{term "supp x \<union> supp y"}\\ |
500 @{term "supp []"} & = & @{term "{}"}\\ |
500 @{term "supp []"} & = & @{term "{}"}\\ |
501 @{term "supp (x#xs)"} & = & @{term "supp (x, xs)"}\\ |
501 @{term "supp (x#xs)"} & = & @{term "supp x \<union> supp xs"}\\ |
502 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp (f, x)"}\label{suppfun}\\ |
502 @{text "supp (f x)"} & @{text "\<subseteq>"} & @{term "supp (f, x)"}\label{suppfun}\\ |
503 @{term "supp b"} & = & @{term "{}"}\\ |
503 @{term "supp b"} & = & @{term "{}"}\\ |
504 @{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"} |
504 @{term "supp p"} & = & @{term "{a. p \<bullet> a \<noteq> a}"} |
505 \end{eqnarray} |
505 \end{eqnarray} |
506 |
506 |
507 \noindent |
507 \noindent |
508 in some cases it can be difficult to establish the support precisely, and |
508 in some cases it can be difficult to establish the support precisely, and |
509 only give an approximation (see the case for function applications |
509 only give an approximation (see the case for function applications |
510 above). Such approximations can be made precise with the notion |
510 above). Such approximations can be calculated with the notion |
511 \emph{supports}, defined as follows |
511 \emph{supports}, defined as follows |
512 |
512 |
513 \begin{defn} |
513 \begin{defn} |
514 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
514 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
515 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
515 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
523 {\it ii)} @{thm supp_supports[no_vars]}. |
523 {\it ii)} @{thm supp_supports[no_vars]}. |
524 \end{property} |
524 \end{property} |
525 |
525 |
526 Another important notion in the nominal logic work is \emph{equivariance}. |
526 Another important notion in the nominal logic work is \emph{equivariance}. |
527 For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant |
527 For a function @{text f}, say of type @{text "\<alpha> \<Rightarrow> \<beta>"}, to be equivariant |
528 requires that every permutation leaves @{text f} unchanged, or equivalently that |
528 requires that every permutation leaves @{text f} unchanged, that is |
529 a permutation applied to the application @{text "f x"} can be moved to its |
529 % |
530 arguments. That is |
530 \begin{equation}\label{equivariancedef} |
|
531 @{term "\<forall>p. p \<bullet> f = f"} |
|
532 \end{equation} |
|
533 |
|
534 \noindent or equivalently that a permutation applied to the application |
|
535 @{text "f x"} can be moved to the argument @{text x}. That means we have for |
|
536 all permutations @{text p} |
531 % |
537 % |
532 \begin{equation}\label{equivariance} |
538 \begin{equation}\label{equivariance} |
533 @{text "\<forall>p. p \<bullet> f = f"} \;\;if and only if\;\; |
539 @{text "p \<bullet> f = f"} \;\;\;\textit{if and only if}\;\;\; |
534 @{text "\<forall>p. p \<bullet> (f x) = f (p \<bullet> x)"} |
540 @{text "p \<bullet> (f x) = f (p \<bullet> x)"} |
535 \end{equation} |
541 \end{equation} |
536 |
542 |
537 \noindent |
543 \noindent |
538 From the first equation and the definition of support shown in \eqref{suppdef}, |
544 From equation \eqref{equivariancedef} and the definition of support shown in |
539 we can be easily deduce that an equivariant function has empty support. |
545 \eqref{suppdef}, we can be easily deduce that an equivariant function has |
540 |
546 empty support. |
541 In the next section we use @{text "supp"} and permutations for characterising |
547 |
542 alpha-equivalence in the presence of multiple binders. |
548 Finally, the nominal logic work provides us with elegant means to rename |
|
549 binders. While in the older version of Nominal Isabelle, we used extensively |
|
550 Property~\ref{swapfreshfresh} for renaming single binders, this property |
|
551 proved unwieldy for dealing with multiple binders. For this the following |
|
552 generalisations turned out to be easier to use. |
|
553 |
|
554 \begin{property}\label{supppermeq} |
|
555 @{thm[mode=IfThen] supp_perm_eq[no_vars]} |
|
556 \end{property} |
|
557 |
|
558 \begin{property} |
|
559 For a finite set @{text xs} and a finitely supported @{text x} with |
|
560 @{term "xs \<sharp>* x"} and also a finitely supported @{text c}, there |
|
561 exists a permutation @{text p} such that @{term "(p \<bullet> xs) \<sharp>* c"} and |
|
562 @{term "supp x \<sharp>* p"}. |
|
563 \end{property} |
|
564 |
|
565 \noindent |
|
566 The idea behind the second property is that given a finite set @{text xs} |
|
567 of binders (being bound in @{text x} which is ensured by the |
|
568 assumption @{term "xs \<sharp>* x"}), then there exists a permutation @{text p} such that |
|
569 the renamed binders @{term "p \<bullet> xs"} avoid the @{text c} (which can be arbitrarily chosen |
|
570 as long as it is finitely supported) and also does not affect anything |
|
571 in the support of @{text x} (that is @{term "supp x \<sharp>* p"}). The last |
|
572 fact and Property~\ref{supppermeq} allow us to ``rename'' just the binders |
|
573 in @{text x}, because @{term "p \<bullet> x = x"}. |
|
574 |
|
575 All properties given in this section are formalised in Isabelle/HOL and also |
|
576 most of them are described with proofs in \cite{HuffmanUrban10}. In the next section |
|
577 we make extensively use of the properties of @{text "supp"} and permutations |
|
578 for characterising alpha-equivalence in the presence of multiple binders. |
543 |
579 |
544 *} |
580 *} |
545 |
581 |
546 |
582 |
547 section {* General Binders\label{sec:binders} *} |
583 section {* General Binders\label{sec:binders} *} |