227 for alpha-\emph{equated} terms. In contrast, Ott produces a reasoning |
227 for alpha-\emph{equated} terms. In contrast, Ott produces a reasoning |
228 infrastructure in Isabelle/HOL for |
228 infrastructure in Isabelle/HOL for |
229 \emph{non}-alpha-equated, or ``raw'', terms. While our alpha-equated terms |
229 \emph{non}-alpha-equated, or ``raw'', terms. While our alpha-equated terms |
230 and the raw terms produced by Ott use names for bound variables, |
230 and the raw terms produced by Ott use names for bound variables, |
231 there is a key difference: working with alpha-equated terms means, for example, |
231 there is a key difference: working with alpha-equated terms means, for example, |
232 that the two type-schemes (with $x$, $y$ and $z$ being distinct) |
232 that the two type-schemes |
233 |
233 |
234 \begin{center} |
234 \begin{center} |
235 @{text "\<forall>{x}. x \<rightarrow> y = \<forall>{x, z}. x \<rightarrow> y"} |
235 @{text "\<forall>{x}. x \<rightarrow> y = \<forall>{x, z}. x \<rightarrow> y"} |
236 \end{center} |
236 \end{center} |
237 |
237 |
327 |
327 |
328 \noindent |
328 \noindent |
329 (Note that this means also the term-constructors for variables, applications |
329 (Note that this means also the term-constructors for variables, applications |
330 and lambda are lifted to the quotient level.) This construction, of course, |
330 and lambda are lifted to the quotient level.) This construction, of course, |
331 only works if alpha-equivalence is indeed an equivalence relation, and the lifted |
331 only works if alpha-equivalence is indeed an equivalence relation, and the lifted |
332 definitions and theorems are respectful w.r.t.~alpha-equivalence. For exmple, we |
332 definitions and theorems are respectful w.r.t.~alpha-equivalence. For example, we |
333 will not be able to lift a bound-variable function, which can be defined for |
333 will not be able to lift a bound-variable function, which can be defined for |
334 raw terms. The reason is that this function does not respect alpha-equivalence. |
334 raw terms. The reason is that this function does not respect alpha-equivalence. |
335 To sum up, every lifting of |
335 To sum up, every lifting of |
336 theorems to the quotient level needs proofs of some respectfulness |
336 theorems to the quotient level needs proofs of some respectfulness |
337 properties (see \cite{Homeier05}). In the paper we show that we are able to |
337 properties (see \cite{Homeier05}). In the paper we show that we are able to |
361 have the variable convention already built in. |
361 have the variable convention already built in. |
362 |
362 |
363 \begin{figure} |
363 \begin{figure} |
364 \begin{boxedminipage}{\linewidth} |
364 \begin{boxedminipage}{\linewidth} |
365 \begin{center} |
365 \begin{center} |
366 \begin{tabular}{rcl} |
366 \begin{tabular}{r@ {\hspace{2mm}}cl} |
367 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
367 \multicolumn{3}{@ {}l}{Type Kinds}\\ |
368 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\medskip\\ |
368 @{text "\<kappa>"} & @{text "::="} & @{text "\<star> | \<kappa>\<^isub>1 \<rightarrow> \<kappa>\<^isub>2"}\medskip\\ |
369 \multicolumn{3}{@ {}l}{Coercion Kinds}\\ |
369 \multicolumn{3}{@ {}l}{Coercion Kinds}\\ |
370 @{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\medskip\\ |
370 @{text "\<iota>"} & @{text "::="} & @{text "\<sigma>\<^isub>1 \<sim> \<sigma>\<^isub>2"}\medskip\\ |
371 \multicolumn{3}{@ {}l}{Types}\\ |
371 \multicolumn{3}{@ {}l}{Types}\\ |
381 \multicolumn{3}{@ {}l}{Terms}\\ |
381 \multicolumn{3}{@ {}l}{Terms}\\ |
382 @{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>a:\<iota>. e | e \<sigma> | e \<gamma> |"}\\ |
382 @{text "e"} & @{text "::="} & @{text "x | K | \<Lambda>a:\<kappa>. e | \<Lambda>a:\<iota>. e | e \<sigma> | e \<gamma> |"}\\ |
383 & & @{text "\<lambda>x:\<sigma>.e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2 |"}\\ |
383 & & @{text "\<lambda>x:\<sigma>.e | e\<^isub>1 e\<^isub>2 | \<LET> x:\<sigma> = e\<^isub>1 \<IN> e\<^isub>2 |"}\\ |
384 & & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\medskip\\ |
384 & & @{text "\<CASE> e\<^isub>1 \<OF>"}$\;\overline{@{text "p \<rightarrow> e\<^isub>2"}}$ @{text "| e \<triangleright> \<gamma>"}\medskip\\ |
385 \multicolumn{3}{@ {}l}{Patterns}\\ |
385 \multicolumn{3}{@ {}l}{Patterns}\\ |
386 @{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "x:\<sigma>"}}$\medskip\\ |
386 @{text "p"} & @{text "::="} & @{text "K"}$\;\overline{@{text "a:\<kappa>"}}\;\overline{@{text "a:\<iota>"}}\;\overline{@{text "x:\<sigma>"}}$\medskip\\ |
387 \multicolumn{3}{@ {}l}{Constants}\\ |
387 \multicolumn{3}{@ {}l}{Constants}\\ |
388 @{text C} & & coercion constant\\ |
388 @{text C} & & coercion constant\\ |
389 @{text T} & & value type constructor\\ |
389 @{text T} & & value type constructor\\ |
390 @{text "S\<^isub>n"} & & n-ary type function\\ |
390 @{text "S\<^isub>n"} & & n-ary type function\\ |
391 @{text K} & & data constructor\medskip\\ |
391 @{text K} & & data constructor\medskip\\ |
394 @{text x} & & term variable\\ |
394 @{text x} & & term variable\\ |
395 \end{tabular} |
395 \end{tabular} |
396 \end{center} |
396 \end{center} |
397 \end{boxedminipage} |
397 \end{boxedminipage} |
398 \caption{The term-language of System @{text "F\<^isub>C"}, also often referred to as Core-Haskell, |
398 \caption{The term-language of System @{text "F\<^isub>C"}, also often referred to as Core-Haskell, |
399 according to \cite{CoreHaskell}. We only made an issential modification by |
399 according to \cite{CoreHaskell}. We only made an inessential modification by |
400 separating the grammars for type kinds and coercion types.\label{corehas}} |
400 separating the grammars for type kinds and coercion types.\label{corehas}} |
401 \end{figure} |
401 \end{figure} |
402 *} |
402 *} |
403 |
403 |
404 section {* A Short Review of the Nominal Logic Work *} |
404 section {* A Short Review of the Nominal Logic Work *} |
493 |
493 |
494 \noindent |
494 \noindent |
495 it can sometimes be difficult to establish the support precisely, |
495 it can sometimes be difficult to establish the support precisely, |
496 and only give an over approximation (see functions above). This |
496 and only give an over approximation (see functions above). This |
497 over approximation can be formalised with the notions \emph{supports}, |
497 over approximation can be formalised with the notions \emph{supports}, |
498 defined as follows: |
498 defined as follows. |
499 |
499 |
500 |
500 \begin{defn} |
|
501 A set @{text S} \emph{supports} @{text x} if for all atoms @{text a} and @{text b} |
|
502 not in @{text S} we have @{term "(a \<rightleftharpoons> b) \<bullet> x = x"}. |
|
503 \end{defn} |
|
504 |
|
505 \noindent |
|
506 The point of this definitions is that we can show: |
|
507 |
|
508 \begin{property} |
|
509 {\it i)} @{thm[mode=IfThen] supp_is_subset[no_vars]} |
|
510 {\it ii)} @{thm supp_supports[no_vars]}. |
|
511 \end{property} |
|
512 |
|
513 \noindent |
|
514 Another important notion in the nominal logic work is \emph{equivariance}. |
501 |
515 |
502 %\begin{property} |
516 %\begin{property} |
503 %@{thm[mode=IfThen] at_set_avoiding[no_vars]} |
517 %@{thm[mode=IfThen] at_set_avoiding[no_vars]} |
504 %\end{property} |
518 %\end{property} |
505 |
519 |
747 $supp ([as]set. x) = supp x - as$ |
761 $supp ([as]set. x) = supp x - as$ |
748 \end{lemma} |
762 \end{lemma} |
749 |
763 |
750 \noindent |
764 \noindent |
751 The point of these general lemmas about pairs is that we can define and prove properties |
765 The point of these general lemmas about pairs is that we can define and prove properties |
752 about them conveninently on the Isabelle level, and in addition can use them in what |
766 about them conveniently on the Isabelle level, and in addition can use them in what |
753 follows next when we have to deal with specific instances of term-specification. |
767 follows next when we have to deal with specific instances of term-specification. |
754 *} |
768 *} |
755 |
769 |
756 section {* Alpha-Equivalence and Free Variables *} |
770 section {* Alpha-Equivalence and Free Variables *} |
757 |
771 |
761 \cite{ott-jfp}. A specification is a collection of (possibly mutual |
775 \cite{ott-jfp}. A specification is a collection of (possibly mutual |
762 recursive) type declarations, say @{text "ty"}$^\alpha_1$, \ldots, |
776 recursive) type declarations, say @{text "ty"}$^\alpha_1$, \ldots, |
763 @{text ty}$^\alpha_n$, and an associated collection |
777 @{text ty}$^\alpha_n$, and an associated collection |
764 of binding functions, say @{text bn}$^\alpha_1$, \ldots, @{text |
778 of binding functions, say @{text bn}$^\alpha_1$, \ldots, @{text |
765 bn}$^\alpha_m$. The syntax in Nominal Isabelle for such specifications is |
779 bn}$^\alpha_m$. The syntax in Nominal Isabelle for such specifications is |
766 rougly as follows: |
780 roughly as follows: |
767 % |
781 % |
768 \begin{equation}\label{scheme} |
782 \begin{equation}\label{scheme} |
769 \mbox{\begin{tabular}{@ {\hspace{-5mm}}p{1.8cm}l} |
783 \mbox{\begin{tabular}{@ {\hspace{-5mm}}p{1.8cm}l} |
770 type \mbox{declaration part} & |
784 type \mbox{declaration part} & |
771 $\begin{cases} |
785 $\begin{cases} |
928 In the first case we bind all atoms from the pattern @{text p} in @{text t} |
942 In the first case we bind all atoms from the pattern @{text p} in @{text t} |
929 and also all atoms from @{text q} in @{text t}. As a result we have no way |
943 and also all atoms from @{text q} in @{text t}. As a result we have no way |
930 to determine whether the binder came from the binding function @{text |
944 to determine whether the binder came from the binding function @{text |
931 "bn(p)"} or @{text "bn(q)"}. Similarly in the second case. There the binder |
945 "bn(p)"} or @{text "bn(q)"}. Similarly in the second case. There the binder |
932 @{text "bn(p)"} overlaps with the shallow binder @{text x}. The reason why |
946 @{text "bn(p)"} overlaps with the shallow binder @{text x}. The reason why |
933 we must exclude such specifiactions is that they cannot be represent by |
947 we must exclude such specifications is that they cannot be represent by |
934 the general binders described in Section \ref{sec:binders}. However |
948 the general binders described in Section \ref{sec:binders}. However |
935 the following two term-constructors are allowed |
949 the following two term-constructors are allowed |
936 |
950 |
937 \begin{center} |
951 \begin{center} |
938 \begin{tabular}{ll} |
952 \begin{tabular}{ll} |
945 |
959 |
946 \noindent |
960 \noindent |
947 since there is no overlap of binders. |
961 since there is no overlap of binders. |
948 |
962 |
949 Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}. |
963 Note that in the last example we wrote {\it\isacommand{bind}\;bn(p)\;\isacommand{in}\;p}. |
950 Whenver such a binding clause is present, we will call the binder \emph{recursive}. |
964 Whenever such a binding clause is present, we will call the binder \emph{recursive}. |
951 To see the purpose for this, consider ``plain'' Lets and Let\_recs: |
965 To see the purpose for this, consider ``plain'' Lets and Let\_recs: |
952 |
966 |
953 \begin{center} |
967 \begin{center} |
954 \begin{tabular}{@ {}l@ {}} |
968 \begin{tabular}{@ {}l@ {}} |
955 \isacommand{nominal\_datatype} {\it trm} =\\ |
969 \isacommand{nominal\_datatype} {\it trm} =\\ |
981 Pottier and Cheney pointed out, we cannot in general re-arrange arguments of |
995 Pottier and Cheney pointed out, we cannot in general re-arrange arguments of |
982 term-constructors so that binders and their bodies are next to each other, and |
996 term-constructors so that binders and their bodies are next to each other, and |
983 then use the type constructors @{text "abs_set"}, @{text "abs_res"} and |
997 then use the type constructors @{text "abs_set"}, @{text "abs_res"} and |
984 @{text "abs_list"} from Section \ref{sec:binders}. Therefore we will first |
998 @{text "abs_list"} from Section \ref{sec:binders}. Therefore we will first |
985 extract datatype definitions from the specification and then define an |
999 extract datatype definitions from the specification and then define an |
986 alpha-equiavlence relation over them. |
1000 alpha-equivalence relation over them. |
987 |
1001 |
988 |
1002 |
989 The datatype definition can be obtained by just stripping off the |
1003 The datatype definition can be obtained by just stripping off the |
990 binding clauses and the labels on the types. We also have to invent |
1004 binding clauses and the labels on the types. We also have to invent |
991 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
1005 new names for the types @{text "ty\<^sup>\<alpha>"} and term-constructors @{text "C\<^sup>\<alpha>"} |
996 \end{center} |
1010 \end{center} |
997 |
1011 |
998 \noindent |
1012 \noindent |
999 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1013 The resulting datatype definition is legal in Isabelle/HOL provided the datatypes are |
1000 non-empty and the types in the constructors only occur in positive |
1014 non-empty and the types in the constructors only occur in positive |
1001 position (see \cite{} for an indepth explanataion of the datatype package |
1015 position (see \cite{} for an indepth explanation of the datatype package |
1002 in Isabelle/HOL). We then define the user-specified binding |
1016 in Isabelle/HOL). We then define the user-specified binding |
1003 functions by primitive recursion over the raw datatypes. We can also |
1017 functions by primitive recursion over the raw datatypes. We can also |
1004 easily define a permutation operation by primitive recursion so that for each |
1018 easily define a permutation operation by primitive recursion so that for each |
1005 term constructor @{text "C_raw ty\<^isub>1 \<dots> ty\<^isub>n"} we have that |
1019 term constructor @{text "C_raw ty\<^isub>1 \<dots> ty\<^isub>n"} we have that |
1006 |
1020 |
1011 \noindent |
1025 \noindent |
1012 From this definition we can easily show that the raw datatypes are |
1026 From this definition we can easily show that the raw datatypes are |
1013 all permutation types (Def ??) by a simple structural induction over |
1027 all permutation types (Def ??) by a simple structural induction over |
1014 the @{text "ty_raw"}s. |
1028 the @{text "ty_raw"}s. |
1015 |
1029 |
1016 The first non-trivial step we have to perform is the generatation free-variable |
1030 The first non-trivial step we have to perform is the generation free-variable |
1017 functions from the specifications. Given types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} |
1031 functions from the specifications. Given types @{text "ty\<^isub>1, \<dots>, ty\<^isub>n"} |
1018 we need to define the free-variable functions |
1032 we need to define the free-variable functions |
1019 |
1033 |
1020 \begin{center} |
1034 \begin{center} |
1021 @{text "fv_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_ty\<^isub>n :: ty\<^isub>n \<Rightarrow> atom set"} |
1035 @{text "fv_ty\<^isub>1 :: ty\<^isub>1 \<Rightarrow> atom set \<dots> fv_ty\<^isub>n :: ty\<^isub>n \<Rightarrow> atom set"} |
1042 whether it is a recursive or non-recursive of a binder. In these cases the value is: |
1056 whether it is a recursive or non-recursive of a binder. In these cases the value is: |
1043 |
1057 |
1044 \begin{center} |
1058 \begin{center} |
1045 \begin{tabular}{cp{7cm}} |
1059 \begin{tabular}{cp{7cm}} |
1046 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1060 $\bullet$ & @{term "{}"} provided @{text "x\<^isub>i"} is a shallow binder\\ |
1047 $\bullet$ & @{text "fv_bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep non-recursive binder\\ |
1061 $\bullet$ & @{text "ft_bn_by\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep non-recursive binder\\ |
1048 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep recursive binder\\ |
1062 $\bullet$ & @{text "fv_ty\<^isub>i x\<^isub>i - bn_ty\<^isub>i x\<^isub>i"} provided @{text "x\<^isub>i"} is a deep recursive binder\\ |
1049 \end{tabular} |
1063 \end{tabular} |
1050 \end{center} |
1064 \end{center} |
1051 |
1065 |
1052 \noindent |
1066 \noindent |