7 consts |
7 consts |
8 fv :: "'a \<Rightarrow> 'b" |
8 fv :: "'a \<Rightarrow> 'b" |
9 abs_set :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
9 abs_set :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
10 alpha_bn :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
10 alpha_bn :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
11 abs_set2 :: "'a \<Rightarrow> perm \<Rightarrow> 'b \<Rightarrow> 'c" |
11 abs_set2 :: "'a \<Rightarrow> perm \<Rightarrow> 'b \<Rightarrow> 'c" |
|
12 equ2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
12 Abs_dist :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
13 Abs_dist :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
13 Abs_print :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
14 Abs_print :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" |
14 |
15 |
15 definition |
16 definition |
16 "equal \<equiv> (op =)" |
17 "equal \<equiv> (op =)" |
52 supp_set ("aux _" [1000] 10) and |
53 supp_set ("aux _" [1000] 10) and |
53 alpha_bn ("_ \<approx>bn _") |
54 alpha_bn ("_ \<approx>bn _") |
54 |
55 |
55 consts alpha_trm ::'a |
56 consts alpha_trm ::'a |
56 consts fa_trm :: 'a |
57 consts fa_trm :: 'a |
|
58 consts fa_trm_al :: 'a |
57 consts alpha_trm2 ::'a |
59 consts alpha_trm2 ::'a |
58 consts fa_trm2 :: 'a |
60 consts fa_trm2 :: 'a |
|
61 consts fa_trm2_al :: 'a |
|
62 consts supp2 :: 'a |
59 consts ast :: 'a |
63 consts ast :: 'a |
60 consts ast' :: 'a |
64 consts ast' :: 'a |
|
65 consts bn_al :: "'b \<Rightarrow> 'a" |
61 notation (latex output) |
66 notation (latex output) |
62 alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and |
67 alpha_trm ("\<approx>\<^bsub>trm\<^esub>") and |
63 fa_trm ("fa\<^bsub>trm\<^esub>") and |
68 fa_trm ("fa\<^bsub>trm\<^esub>") and |
|
69 fa_trm_al ("fa\<AL>\<^bsub>trm\<^esub>") and |
64 alpha_trm2 ("'(\<approx>\<^bsub>assn\<^esub>, \<approx>\<^bsub>trm\<^esub>')") and |
70 alpha_trm2 ("'(\<approx>\<^bsub>assn\<^esub>, \<approx>\<^bsub>trm\<^esub>')") and |
65 fa_trm2 ("'(fa\<^bsub>assn\<^esub>, fa\<^bsub>trm\<^esub>')") and |
71 fa_trm2 ("'(fa\<^bsub>assn\<^esub>, fa\<^bsub>trm\<^esub>')") and |
|
72 fa_trm2_al ("'(fa\<AL>\<^bsub>assn\<^esub>, fa\<AL>\<^bsub>trm\<^esub>')") and |
66 ast ("'(as, t')") and |
73 ast ("'(as, t')") and |
67 ast' ("'(as', t\<PRIME> ')") |
74 ast' ("'(as', t\<PRIME> ')") and |
68 |
75 equ2 ("'(=, =')") and |
|
76 supp2 ("'(supp, supp')") and |
|
77 bn_al ("bn\<^sup>\<alpha> _") |
69 (*>*) |
78 (*>*) |
70 |
79 |
71 |
80 |
72 section {* Introduction *} |
81 section {* Introduction *} |
73 |
82 |
638 use of these properties in order to define alpha-equivalence in |
647 use of these properties in order to define alpha-equivalence in |
639 the presence of multiple binders. |
648 the presence of multiple binders. |
640 *} |
649 *} |
641 |
650 |
642 |
651 |
643 section {* General Bindings\label{sec:binders} *} |
652 section {* Abstractions\label{sec:binders} *} |
644 |
653 |
645 text {* |
654 text {* |
646 In Nominal Isabelle, the user is expected to write down a specification of a |
655 In Nominal Isabelle, the user is expected to write down a specification of a |
647 term-calculus and then a reasoning infrastructure is automatically derived |
656 term-calculus and then a reasoning infrastructure is automatically derived |
648 from this specification (remember that Nominal Isabelle is a definitional |
657 from this specification (remember that Nominal Isabelle is a definitional |
1678 Again let us take a look at a concrete example for these definitions. For |
1687 Again let us take a look at a concrete example for these definitions. For |
1679 the specification given in \eqref{letrecs} |
1688 the specification given in \eqref{letrecs} |
1680 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1689 we have three relations $\approx_{\textit{trm}}$, $\approx_{\textit{assn}}$ and |
1681 $\approx_{\textit{bn}}$ with the following clauses: |
1690 $\approx_{\textit{bn}}$ with the following clauses: |
1682 |
1691 |
1683 \[\mbox{ |
1692 \begin{equation}\label{rawalpha}\mbox{ |
1684 \begin{tabular}{@ {}c @ {}} |
1693 \begin{tabular}{@ {}c @ {}} |
1685 \infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}} |
1694 \infer{@{text "Let as t \<approx>\<^bsub>trm\<^esub> Let as' t'"}} |
1686 {@{term "alpha_lst_ex (bn as, t) alpha_trm fa_trm (bn as', t')"} & |
1695 {@{term "alpha_lst_ex (bn as, t) alpha_trm fa_trm (bn as', t')"} & |
1687 \hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\\ |
1696 \hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}}\\ |
1688 \\ |
1697 \\ |
1701 \infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\hspace{9mm} |
1710 \infer{@{text "ANil \<approx>\<^bsub>bn\<^esub> ANil"}}{}\hspace{9mm} |
1702 \infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}} |
1711 \infer{@{text "ACons a t as \<approx>\<^bsub>bn\<^esub> ACons a' t' as"}} |
1703 {@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & \hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}} |
1712 {@{text "t \<approx>\<^bsub>trm\<^esub> t'"} & \hspace{5mm}@{text "as \<approx>\<^bsub>bn\<^esub> as'"}} |
1704 \end{tabular} |
1713 \end{tabular} |
1705 \end{tabular}} |
1714 \end{tabular}} |
1706 \]\smallskip |
1715 \end{equation}\smallskip |
1707 |
1716 |
1708 \noindent |
1717 \noindent |
1709 Notice the difference between $\approx_{\textit{assn}}$ and |
1718 Notice the difference between $\approx_{\textit{assn}}$ and |
1710 $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of |
1719 $\approx_{\textit{bn}}$: the latter only ``tracks'' alpha-equivalence of |
1711 the components in an assignment that are \emph{not} bound. This is needed in the |
1720 the components in an assignment that are \emph{not} bound. This is needed in the |
1853 \]\smallskip |
1862 \]\smallskip |
1854 |
1863 |
1855 \noindent |
1864 \noindent |
1856 We call these conditions as \emph{quasi-injectivity}. They correspond to |
1865 We call these conditions as \emph{quasi-injectivity}. They correspond to |
1857 the premises in our alpha-equiva\-lence relations, with the exception that |
1866 the premises in our alpha-equiva\-lence relations, with the exception that |
1858 in case of binders the relations $\approx_{\textit{set}}^{\textit{R}, \textit{fa}}$ |
1867 in case of binders the relations @{text "\<approx>ty"}$_{1..n}$ are all replaced |
1859 are replaced by $\approx_{\textit{set}}^{=, \textit{fa}}$ (similarly for the |
1868 by equality. Recall the alpha-equivalence rules for @{text "Let"} and @{text "Let_rec"} |
1860 other binding modes). |
1869 shown in \eqref{rawalpha}. For @{text "Let\<^sup>\<alpha>"} and @{text "Let_rec\<^sup>\<alpha>"} we have |
|
1870 |
|
1871 \begin{equation}\label{alphalift}\mbox{ |
|
1872 \begin{tabular}{@ {}c @ {}} |
|
1873 \infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}} |
|
1874 {@{term "alpha_lst_ex (bn_al as, t) equal fa_trm_al (bn as', t')"} & |
|
1875 \hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\ |
|
1876 \\ |
|
1877 \makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}} |
|
1878 {@{term "alpha_lst_ex (bn_al as, ast) equ2 fa_trm2_al (bn_al as', ast')"}}}\\ |
|
1879 \end{tabular}} |
|
1880 \end{equation}\smallskip |
|
1881 |
|
1882 \noindent |
|
1883 where @{text "\<approx>\<^bsub>trm\<^esub>"} and @{text "\<approx>\<^bsub>assn\<^esub>"} are replaced by @{text "="} (and similarly |
|
1884 the free-atom and binding functions are replaced by their lifted counterparts). |
1861 |
1885 |
1862 Next we can lift the permutation operations defined in \eqref{ceqvt}. In |
1886 Next we can lift the permutation operations defined in \eqref{ceqvt}. In |
1863 order to make this lifting to go through, we have to show that the |
1887 order to make this lifting to go through, we have to show that the |
1864 permutation operations are respectful. This amounts to showing that the |
1888 permutation operations are respectful. This amounts to showing that the |
1865 alpha-equivalence relations are equivariant, which |
1889 alpha-equivalence relations are equivariant, which |
2007 The proof is by induction. In each case |
2031 The proof is by induction. In each case |
2008 we unfold the definition of @{text "supp"}, move the swapping inside the |
2032 we unfold the definition of @{text "supp"}, move the swapping inside the |
2009 term-constructors and then use the quasi-injectivity lemmas in order to complete the |
2033 term-constructors and then use the quasi-injectivity lemmas in order to complete the |
2010 proof. For the abstraction cases we use then the facts derived in Theorem~\ref{suppabs}, |
2034 proof. For the abstraction cases we use then the facts derived in Theorem~\ref{suppabs}, |
2011 for which we have to know that every body of an abstraction is finitely supported. |
2035 for which we have to know that every body of an abstraction is finitely supported. |
2012 This we have proved earlier. |
2036 This, we have proved earlier. |
2013 \end{proof} |
2037 \end{proof} |
2014 |
2038 |
2015 \noindent |
2039 \noindent |
|
2040 Consequently we can simplify the quasi-injection lemmas, for example the ones |
|
2041 given in \eqref{alphalift} for @{text "Let\<^sup>\<alpha>"} and @{text "Let_rec\<^sup>\<alpha>"} to |
|
2042 |
|
2043 \[\mbox{ |
|
2044 \begin{tabular}{@ {}c @ {}} |
|
2045 \infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}} |
|
2046 {@{term "alpha_lst_ex (bn_al as, t) equal supp (bn_al as', t')"} & |
|
2047 \hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\ |
|
2048 \\ |
|
2049 \makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}} |
|
2050 {@{term "alpha_lst_ex (bn_al as, ast) equ2 supp2 (bn_al as', ast')"}}}\\ |
|
2051 \end{tabular}} |
|
2052 \]\smallskip |
|
2053 |
|
2054 \noindent |
|
2055 Taking the fact into account that @{term "equ2"} and @{term "supp2"} are |
|
2056 by definition equal to @{term "equal"} and @{term "supp"}, respectively, |
|
2057 the above rules simplify even further to |
|
2058 |
|
2059 \[\mbox{ |
|
2060 \begin{tabular}{@ {}c @ {}} |
|
2061 \infer{@{text "Let\<^sup>\<alpha> as t = Let\<^sup>\<alpha> as' t'"}} |
|
2062 {@{term "Abs_lst (bn_al as) t = Abs_lst (bn_al as') t'"} & |
|
2063 \hspace{5mm}@{text "as \<approx>\<AL>\<^bsub>bn\<^esub> as'"}}\\ |
|
2064 \\ |
|
2065 \makebox[0mm]{\infer{@{text "Let_rec\<^sup>\<alpha> as t = Let_rec\<^sup>\<alpha> as' t'"}} |
|
2066 {@{term "Abs_lst (bn_al as) ast = Abs_lst (bn_al as') ast'"}}}\\ |
|
2067 \end{tabular}} |
|
2068 \]\smallskip |
|
2069 |
|
2070 \noindent |
|
2071 which means we can characterise equality between term-constructors in terms |
|
2072 of equality between the abstractions defined in Section~\ref{sec:binders}. From this |
|
2073 we can derive the support for @{text "Let\<^sup>\<alpha>"} and |
|
2074 @{text "Let_rec\<^sup>\<alpha>"}, namely |
|
2075 |
|
2076 \[\mbox{ |
|
2077 \begin{tabular}{l@ {\hspace{2mm}}l@ {\hspace{2mm}}l} |
|
2078 @{text "supp (Let\<^sup>\<alpha> as t)"} & @{text "="} & @{text "(supp t - set (bn\<^sup>\<alpha> as)) \<union> fa\<AL>\<^bsub>bn\<^esub> as"}\\ |
|
2079 @{text "supp (Let_rec\<^sup>\<alpha> as t)"} & @{text "="} & @{text "(supp t \<union> supp as) - set (bn\<^sup>\<alpha> as)"}\\ |
|
2080 \end{tabular}} |
|
2081 \]\smallskip |
|
2082 |
|
2083 \noindent |
|
2084 using the support of abstractions derived in Theorem~\ref{suppabs}. |
|
2085 |
|
2086 |
2016 To sum up this section, we can establish a reasoning infrastructure for the |
2087 To sum up this section, we can establish a reasoning infrastructure for the |
2017 types @{text "ty\<AL>"}$_{1..n}$ by first lifting definitions from the |
2088 types @{text "ty\<AL>"}$_{1..n}$ by first lifting definitions from the |
2018 ``raw'' level to the quotient level and then by proving facts about |
2089 ``raw'' level to the quotient level and then by proving facts about |
2019 these lifted definitions. All necessary proofs are generated automatically |
2090 these lifted definitions. All necessary proofs are generated automatically |
2020 by custom ML-code. |
2091 by custom ML-code. |
2058 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2129 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2059 {\begin{array}{l} |
2130 {\begin{array}{l} |
2060 @{text "\<forall>x c. P\<^bsub>trm\<^esub> c (Var\<^sup>\<alpha> x)"}\\ |
2131 @{text "\<forall>x c. P\<^bsub>trm\<^esub> c (Var\<^sup>\<alpha> x)"}\\ |
2061 @{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)"}\\ |
2132 @{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)"}\\ |
2062 @{text "\<forall>x\<^isub>1 x\<^isub>2 c. {atom x\<^isub>1} #\<^sup>* 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)"}\\ |
2133 @{text "\<forall>x\<^isub>1 x\<^isub>2 c. {atom x\<^isub>1} #\<^sup>* 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)"}\\ |
2063 @{text "\<forall>x\<^isub>1 x\<^isub>2 c. (set (bn x\<^isub>1)) #\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d x\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>2) \<Rightarrow> P\<^bsub>trm\<^esub> c (Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\ |
2134 @{text "\<forall>x\<^isub>1 x\<^isub>2 c. (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d x\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d x\<^isub>2) \<Rightarrow> P\<^bsub>trm\<^esub> c (Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\ |
2064 @{text "\<forall>c. P\<^bsub>pat\<^esub> c (PNil\<^sup>\<alpha>)"}\\ |
2135 @{text "\<forall>c. P\<^bsub>pat\<^esub> c (PNil\<^sup>\<alpha>)"}\\ |
2065 @{text "\<forall>x c. P\<^bsub>pat\<^esub> c (PVar\<^sup>\<alpha> x)"}\\ |
2136 @{text "\<forall>x c. P\<^bsub>pat\<^esub> c (PVar\<^sup>\<alpha> x)"}\\ |
2066 @{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)"} |
2137 @{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)"} |
2067 \end{array}} |
2138 \end{array}} |
2068 \end{tabular}} |
2139 \end{tabular}} |