1954 \eqref{cases} and \eqref{induct} boil down to the following three inference |
1955 \eqref{cases} and \eqref{induct} boil down to the following three inference |
1955 rules (the cases lemmas are on the left-hand side; the induction principle |
1956 rules (the cases lemmas are on the left-hand side; the induction principle |
1956 on the right): |
1957 on the right): |
1957 |
1958 |
1958 \begin{equation}\label{inductex}\mbox{ |
1959 \begin{equation}\label{inductex}\mbox{ |
1959 \begin{tabular}{c@ {\hspace{10mm}}c} |
1960 \begin{tabular}{@ {}c@ {\hspace{3mm}}c@ {}} |
1960 \begin{tabular}{@ {}c@ {}} |
1961 \begin{tabular}{@ {}c@ {}} |
1961 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
1962 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
1962 {\begin{array}{l} |
1963 {\begin{array}{@ {}l@ {}} |
1963 @{text "\<forall>x. y = Var\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1964 @{text "\<forall>x. y = Var\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1964 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1965 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1965 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1966 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1966 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
1967 @{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. y = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
1967 \end{array}}\medskip\\ |
1968 \end{array}}\medskip\\ |
1968 |
1969 |
1969 \infer{@{text "P\<^bsub>pat\<^esub>"}} |
1970 \infer{@{text "P\<^bsub>pat\<^esub>"}} |
1970 {\begin{array}{l} |
1971 {\begin{array}{@ {}l@ {}} |
1971 @{text "y = PNil\<^sup>\<alpha> \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
1972 @{text "y = PNil\<^sup>\<alpha> \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
1972 @{text "\<forall>x. y = PVar\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
1973 @{text "\<forall>x. y = PVar\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
1973 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub>"} |
1974 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub>"} |
1974 \end{array}} |
1975 \end{array}} |
1975 \end{tabular} |
1976 \end{tabular} |
1976 & |
1977 & |
1977 |
1978 |
1978 \begin{tabular}{@ {}c@ {}} |
1979 \begin{tabular}{@ {}c@ {}} |
1979 \infer{@{text "P\<^bsub>trm\<^esub> y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}} |
1980 \infer{@{text "P\<^bsub>trm\<^esub> y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}} |
1980 {\begin{array}{l} |
1981 {\begin{array}{@ {}l@ {}} |
1981 @{text "\<forall>x. P\<^bsub>trm\<^esub> (Var\<^sup>\<alpha> x)"}\\ |
1982 @{text "\<forall>x. P\<^bsub>trm\<^esub> (Var\<^sup>\<alpha> x)"}\\ |
1982 @{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)"}\\ |
1983 @{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)"}\\ |
1983 @{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)"}\\ |
1984 @{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)"}\\ |
1984 @{text "\<forall>x\<^isub>1 x\<^isub>2. P\<^bsub>pat\<^esub> x\<^isub>1 \<and> P\<^bsub>trm\<^esub> x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2)"}\\ |
1985 @{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\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3)"}\\ |
1985 @{text "P\<^bsub>pat\<^esub> (PNil\<^sup>\<alpha>)"}\\ |
1986 @{text "P\<^bsub>pat\<^esub> (PNil\<^sup>\<alpha>)"}\\ |
1986 @{text "\<forall>x. P\<^bsub>pat\<^esub> (PVar\<^sup>\<alpha> x)"}\\ |
1987 @{text "\<forall>x. P\<^bsub>pat\<^esub> (PVar\<^sup>\<alpha> x)"}\\ |
1987 @{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)"} |
1988 @{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)"} |
1988 \end{array}} |
1989 \end{array}} |
1989 \end{tabular} |
1990 \end{tabular} |
2094 |
2098 |
2095 section {* Strong Induction Principles *} |
2099 section {* Strong Induction Principles *} |
2096 |
2100 |
2097 text {* |
2101 text {* |
2098 In the previous section we derived induction principles for alpha-equated |
2102 In the previous section we derived induction principles for alpha-equated |
2099 terms (see \eqref{induct} and \eqref{inductex}). This was done by lifting |
2103 terms (see \eqref{induct} for the general form and \eqref{inductex} for an |
2100 the corresponding inductions principles for ``raw'' terms. We already |
2104 instance). This was done by lifting the corresponding inductions principles |
2101 employed these induction principles in order to derive several facts for |
2105 for ``raw'' terms. We already employed these induction principles for |
2102 alpha-equated terms, including the property that the free-variable functions |
2106 deriving several facts for alpha-equated terms, including the property that |
2103 and the notion of support coincide. Still, we call these induction |
2107 the free-variable functions and the notion of support coincide. Still, we |
2104 principles \emph{weak}, because for a term-constructor, say \mbox{@{text |
2108 call these induction principles \emph{weak}, because for a term-constructor, |
2105 "C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r"}}, the induction hypothesis requires us to |
2109 say \mbox{@{text "C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r"}}, the induction |
2106 establish (under some assumptions) a property @{text "P (C\<^sup>\<alpha> |
2110 hypothesis requires us to establish (under some assumptions) a property |
2107 x\<^isub>1\<dots>x\<^isub>r)"} for \emph{all} @{text "x"}$_{1..r}$. The problem is that in the |
2111 @{text "P (C\<^sup>\<alpha> x\<^isub>1\<dots>x\<^isub>r)"} for \emph{all} @{text |
2108 presence of binders we cannot make any assumptions about the atoms that are |
2112 "x"}$_{1..r}$. The problem is that in the presence of binders we cannot make |
2109 bound, and we have to potentially rename them. This renaming has to be |
2113 any assumptions about the atoms that are bound. One obvious way around this |
2110 done manually and is often very cumbersome (especially in the case for |
2114 problem is to rename them. Unfortunately, this leads to very clunky proofs |
|
2115 and makes formalisations grievous experiences (especially in the case for |
2111 multiple bound atoms). |
2116 multiple bound atoms). |
|
2117 |
2112 |
2118 |
2113 For the older versions of Nominal Isabelle we introduced in |
2119 For the older versions of Nominal Isabelle we introduced in |
2114 \cite{UrbanTasson05} a method for automatically strengthening weak induction |
2120 \cite{UrbanTasson05} a method for automatically strengthening weak induction |
2115 principles in case of single binders. These stronger induction principles |
2121 principles. These stronger induction principles allow the user to make |
2116 allow the user to make additional assumptions about bound atoms. The main |
2122 additional assumptions about bound atoms. The advantage of these assumptions |
2117 point is that these additional assumptions amount to a formal version of the |
2123 is that they make in most cases any renaming of bound atoms unnecessary. To |
2118 informal variable convention for binders and nearly always make manual |
2124 explain how the strengthening works in the presence of multiple binders, we |
2119 renaming of binders unnecessary. |
2125 use as running example the lambda-calculus with @{text "Let"}-patterns shown |
2120 |
2126 in \eqref{letpat}. Its weak induction principle is given in |
2121 To explain how the strengthening works in the presence of multiple binders, |
2127 \eqref{inductex}. The stronger induction principle is as follows: |
2122 we use as running example the lambda-calculus with @{text "Let"}-patterns |
|
2123 shown in \eqref{letpat}. Its weak induction principle is given in \eqref{inductex}. |
|
2124 The stronger induction principle is as follows |
|
2125 |
2128 |
2126 \begin{equation}\label{stronginduct} |
2129 \begin{equation}\label{stronginduct} |
2127 \mbox{ |
2130 \mbox{ |
2128 \begin{tabular}{@ {}c@ {}} |
2131 \begin{tabular}{@ {}c@ {}} |
2129 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2132 \infer{@{text "P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"}} |
2130 {\begin{array}{l} |
2133 {\begin{array}{l} |
2131 @{text "\<forall>x c. P\<^bsub>trm\<^esub> c (Var\<^sup>\<alpha> x)"}\\ |
2134 @{text "\<forall>x c. P\<^bsub>trm\<^esub> c (Var\<^sup>\<alpha> x)"}\\ |
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)"}\\ |
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)"}\\ |
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)"}\\ |
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)"}\\ |
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)"}\\ |
2137 @{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3 c. (set (bn\<^sup>\<alpha> x\<^isub>1)) #\<^sup>* c \<and>"}\\ |
|
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\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3)"}\\ |
2135 @{text "\<forall>c. P\<^bsub>pat\<^esub> c (PNil\<^sup>\<alpha>)"}\\ |
2139 @{text "\<forall>c. P\<^bsub>pat\<^esub> c (PNil\<^sup>\<alpha>)"}\\ |
2136 @{text "\<forall>x c. P\<^bsub>pat\<^esub> c (PVar\<^sup>\<alpha> x)"}\\ |
2140 @{text "\<forall>x c. P\<^bsub>pat\<^esub> c (PVar\<^sup>\<alpha> x)"}\\ |
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)"} |
2141 @{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)"} |
2138 \end{array}} |
2142 \end{array}} |
2139 \end{tabular}} |
2143 \end{tabular}} |
2140 \end{equation}\smallskip |
2144 \end{equation}\smallskip |
2141 |
2145 |
2142 |
2146 |
2143 \noindent |
2147 \noindent |
2144 Instead of establishing the two properties @{text " P\<^bsub>trm\<^esub> y\<^isub>1 \<and> |
2148 Instead of establishing the two properties @{text " P\<^bsub>trm\<^esub> |
2145 P\<^bsub>pat\<^esub> y\<^isub>2"}, as the weak one does, the stronger |
2149 y\<^isub>1 \<and> P\<^bsub>pat\<^esub> y\<^isub>2"}, as the weak one does, the |
2146 induction principle establishes the properties @{text " P\<^bsub>trm\<^esub> c |
2150 stronger induction principle establishes the properties @{text " |
2147 y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"} in which the additional |
2151 P\<^bsub>trm\<^esub> c y\<^isub>1 \<and> P\<^bsub>pat\<^esub> c y\<^isub>2"} in |
2148 parameter @{text c} is assumed to be of finite support. The purpose of |
2152 which the additional parameter @{text c} is assumed to be of finite |
2149 @{text "c"} is to ``control'' which freshness assumptions the binders should |
2153 support. The purpose of @{text "c"} is to ``control'' which freshness |
2150 satisfy in the @{text "Lam\<^sup>\<alpha>"} and @{text "Let\<^sup>\<alpha>"} cases (these are the cases |
2154 assumptions the binders should satisfy in the @{text "Lam\<^sup>\<alpha>"} and |
2151 where the user specified some binding clauses). |
2155 @{text "Let\<^sup>\<alpha>"} cases: for @{text "Lam\<^sup>\<alpha>"} we can assume the |
|
2156 bound atom @{text "x\<^isub>1"} is fresh for @{text "c"}; for @{text |
|
2157 "Let\<^sup>\<alpha>"} we can assume all bound atoms from an assignment are fresh |
|
2158 for @{text "c"}. If @{text "c"} is instantiated appropriately, the user can |
|
2159 mimic the ``pencil-and-paper'' reasoning employing the usual variable |
|
2160 convention. |
2152 |
2161 |
2153 In what follows we will show that the induction principle in |
2162 In what follows we will show that the induction principle in |
2154 \eqref{inductex} implies \eqref{stronginduct}. This fact was established in |
2163 \eqref{inductex} implies \eqref{stronginduct}. This fact was established for |
2155 \cite{UrbanTasson05} by some quite involved, nevertheless automated, |
2164 single binders in \cite{UrbanTasson05} by some quite involved, nevertheless |
2156 induction proof. In this paper we simplify the proof by leveraging the |
2165 automated, induction proof. In this paper we simplify the proof by |
2157 automated proof methods from the function package of Isabelle/HOL |
2166 leveraging the automated proof methods from the function package of |
2158 \cite{Krauss09}. The reasoning principle behind these methods is |
2167 Isabelle/HOL \cite{Krauss09}. The reasoning principle behind these methods |
2159 well-founded induction. To use them in our setting, we have to discharge two |
2168 is well-founded induction. To use them in our setting, we have to discharge |
2160 proof obligations: one is that we have well-founded measures (one for each type |
2169 two proof obligations: one is that we have well-founded measures (one for |
2161 @{text "ty"}$^\alpha_{1..n}$) that decrease in every induction step and the |
2170 each type @{text "ty"}$^\alpha_{1..n}$) that decrease in every induction |
2162 other is that we have covered all cases. |
2171 step and the other is that we have covered all cases. Once these two |
|
2172 proof obligations are discharged, the reasoning infrastructure in |
|
2173 the function package will automatically derive the stronger induction |
|
2174 principle. This considerably simplifies the work we have to do. |
2163 |
2175 |
2164 As measures we can use the size functions @{text "size_ty"}$^\alpha_{1..n}$, |
2176 As measures we can use the size functions @{text "size_ty"}$^\alpha_{1..n}$, |
2165 which we lifted in the previous section and which are all well-founded. It |
2177 which we lifted in the previous section and which are all well-founded. It |
2166 is straightforward to establish that these measures decrease in every |
2178 is straightforward to establish that the sizes decrease in every |
2167 induction step. What is left to show is that we covered all cases. |
2179 induction step. What is left to show is that we covered all cases. |
2168 To do so, we use a \emph{cases lemma} derived for each type. For the terms in \eqref{letpat} |
2180 To do so, we have to derive stronger cases lemmas, which look in our |
2169 this lemma is of the form |
2181 running example as follows: |
2170 |
2182 |
2171 \begin{equation}\label{weakcases} |
2183 \[\mbox{ |
|
2184 \begin{tabular}{@ {}c@ {\hspace{6mm}}c@ {}} |
2172 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
2185 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
2173 {\begin{array}{l@ {\hspace{9mm}}l} |
2186 {\begin{array}{@ {}l@ {}} |
2174 @{text "\<forall>x. t = Var x \<Rightarrow> P\<^bsub>trm\<^esub>"} & @{text "\<forall>a t'. t = Lam a t' \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
2187 @{text "\<forall>x. y = Var\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
2175 @{text "\<forall>t\<^isub>1 t\<^isub>2. t = App t\<^isub>1 t\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"} & @{text "\<forall>p t'. t = Let p t' \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
2188 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = App\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
2176 \end{array}}\\[-1mm] |
2189 @{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>"}\\ |
2177 \end{equation} |
2190 @{text "\<forall>x\<^isub>1 x\<^isub>2 x\<^isub>3. set (bn\<^sup>\<alpha> x\<^isub>1) #\<^sup>* c \<and> y = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3 \<Rightarrow> P\<^bsub>trm\<^esub>"} |
2178 |
2191 \end{array}} & |
2179 where we have a premise for each term-constructor. |
2192 |
2180 The idea behind such cases lemmas is that we can conclude with a property @{text "P\<^bsub>trm\<^esub>"}, |
2193 \infer{@{text "P\<^bsub>pat\<^esub>"}} |
2181 provided we can show that this property holds if we substitute for @{text "t"} all |
2194 {\begin{array}{@ {}l@ {}} |
2182 possible term-constructors. |
2195 @{text "y = PNil\<^sup>\<alpha> \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
|
2196 @{text "\<forall>x. y = PVar\<^sup>\<alpha> x \<Rightarrow> P\<^bsub>pat\<^esub>"}\\ |
|
2197 @{text "\<forall>x\<^isub>1 x\<^isub>2. y = PTup\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 \<Rightarrow> P\<^bsub>pat\<^esub>"} |
|
2198 \end{array}} |
|
2199 \end{tabular}} |
|
2200 \]\smallskip |
|
2201 |
|
2202 \noindent |
|
2203 These stronger cases lemmas need to be derived from the `weak' cases lemmas given |
|
2204 in \eqref{inductex}. This is trivial in case of patterns (the one on the right-hand side) |
|
2205 since weak and strong cases lemma coincide (there is no binding in patterns). |
|
2206 Interesting are only the cases for @{text "Lam\<^sup>\<alpha>"} and @{text "Let\<^sup>\<alpha>"}. There the |
|
2207 stronger cases lemma allow us to assume that the bound atoms avoid the context @{text "c"} |
|
2208 (which is assumed to be finitely supported). |
|
2209 |
|
2210 Let us show first establish the simpler case for @{text "Lam\<^sup>\<alpha>"}. By the weak cases lemma |
|
2211 \eqref{inductex} we can assume that |
|
2212 |
|
2213 \begin{equation}\label{assm} |
|
2214 @{text "y = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"} |
|
2215 \end{equation}\smallskip |
|
2216 |
|
2217 \noindent |
|
2218 holds and need to establish @{text "P\<^bsub>trm\<^esub>"}. The stronger cases lemma has the implication |
|
2219 |
|
2220 \begin{equation}\label{imp} |
|
2221 @{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>"} |
|
2222 \end{equation}\smallskip |
|
2223 |
|
2224 \noindent |
|
2225 which we can use to infer @{text "P\<^bsub>trm\<^esub>"}. Clearly, we cannot |
|
2226 use this implication directly, because we have no information whether @{text |
|
2227 "x\<^isub>1"} is fresh for @{text "c"}. However, we can use Properties |
|
2228 \ref{supppermeq} and \ref{avoiding} to rename @{text "x\<^isub>1"}. We know |
|
2229 by Theorem~\ref{suppfa} that @{text "{atom x\<^isub>1} #\<^sup>* Lam\<^sup>\<alpha> |
|
2230 x\<^isub>1 x\<^isub>2"} (since its support is @{text "supp x\<^isub>2 - |
|
2231 {atom x\<^isub>1}"}). Property \ref{avoiding} provides us therefore with a |
|
2232 permutation @{text "\<pi>"}, such that @{text "{atom (\<pi> \<bullet> x\<^isub>1)} #\<^sup>* |
|
2233 c"} and \mbox{@{text "supp (Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2) #\<^sup>* \<pi>"}} hold. |
|
2234 By using Property \ref{supppermeq}, we can infer from the latter that @{text |
|
2235 "Lam\<^sup>\<alpha> (\<pi> \<bullet> x\<^isub>1) (\<pi> \<bullet> x\<^isub>2) = Lam\<^sup>\<alpha> x\<^isub>1 x\<^isub>2"}. We can use this in the assumption |
|
2236 \eqref{assm} and then use \eqref{imp} to conclude this case. |
|
2237 |
|
2238 The @{text "Let\<^sup>\<alpha>"}-case involving a (non-recursive) deep binder is more complicated. |
|
2239 We have the assumption |
|
2240 |
|
2241 \begin{equation}\label{assm} |
|
2242 @{text "y = Let\<^sup>\<alpha> x\<^isub>1 x\<^isub>2 x\<^isub>3"} |
|
2243 \end{equation}\smallskip |
|
2244 |
|
2245 \noindent |
|
2246 and as implication |
|
2247 |
|
2248 \[ |
|
2249 |
|
2250 \]\smallskip |
|
2251 |
|
2252 |
|
2253 The reason is that the we cannot apply Property \ref{avoiding} to the whole term @{text "Let p t"}, |
|
2254 because @{text p} might contain names bound by @{text bn}, but also some that are |
|
2255 free. To solve this problem we have to introduce a permutation function that only |
|
2256 permutes names bound by @{text bn} and leaves the other names unchanged. We do this again |
|
2257 by lifting. For a |
|
2258 clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"}, we define |
|
2259 |
|
2260 |
|
2261 {\bf NOT DONE YET} |
|
2262 |
|
2263 {\it |
2183 |
2264 |
2184 The only remaining difficulty is that in order to derive the stronger induction |
2265 The only remaining difficulty is that in order to derive the stronger induction |
2185 principles conveniently, the cases lemma in \eqref{weakcases} is too weak. For this note that |
2266 principles conveniently, the cases lemma in \eqref{weakcases} is too weak. For this note that |
2186 in order to apply this lemma, we have to establish @{text "P\<^bsub>trm\<^esub>"} for \emph{all} @{text Lam}- and |
2267 in order to apply this lemma, we have to establish @{text "P\<^bsub>trm\<^esub>"} for \emph{all} @{text Lam}- and |
2187 \emph{all} @{text Let}-terms. |
2268 \emph{all} @{text Let}-terms. |
2188 What we need instead is a cases lemma where we only have to consider terms that have |
2269 What we need instead is a cases lemma where we only have to consider terms that have |
2189 binders that are fresh w.r.t.~a context @{text "c"}. This gives the implications |
2270 binders that are fresh w.r.t.~a context @{text "c"}. This gives the implications |
2190 |
2271 |
2191 \begin{center} |
2272 |
2192 \begin{tabular}{l} |
|
2193 @{text "\<forall>a t'. t = Lam a t' \<and> {atom a} \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
|
2194 @{text "\<forall>p t'. t = Let p t' \<and> (set (bn p)) \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"}\\[-2mm] |
|
2195 \end{tabular} |
|
2196 \end{center} |
|
2197 |
|
2198 \noindent |
|
2199 which however can be relatively easily be derived from the implications in \eqref{weakcases} |
|
2200 by a renaming using Properties \ref{supppermeq} and \ref{avoiding}. In the first case we know |
|
2201 that @{text "{atom a} \<FRESH>\<^sup>* Lam a t"}. Property \eqref{avoiding} provides us therefore with |
|
2202 a permutation @{text q}, such that @{text "{atom (q \<bullet> a)} \<FRESH>\<^sup>* c"} and |
|
2203 @{text "supp (Lam a t) \<FRESH>\<^sup>* q"} hold. |
|
2204 By using Property \ref{supppermeq}, we can infer from the latter |
|
2205 that @{text "Lam (q \<bullet> a) (q \<bullet> t) = Lam a t"} |
|
2206 and we are done with this case. |
|
2207 |
|
2208 The @{text Let}-case involving a (non-recursive) deep binder is a bit more complicated. |
|
2209 The reason is that the we cannot apply Property \ref{avoiding} to the whole term @{text "Let p t"}, |
|
2210 because @{text p} might contain names bound by @{text bn}, but also some that are |
|
2211 free. To solve this problem we have to introduce a permutation function that only |
|
2212 permutes names bound by @{text bn} and leaves the other names unchanged. We do this again |
|
2213 by lifting. For a |
|
2214 clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"}, we define |
|
2215 |
2273 |
2216 \begin{center} |
2274 \begin{center} |
2217 @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>r) \<equiv> C y\<^isub>1 \<dots> y\<^isub>r"} with |
2275 @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>r) \<equiv> C y\<^isub>1 \<dots> y\<^isub>r"} with |
2218 $\begin{cases} |
2276 $\begin{cases} |
2219 \text{@{text "y\<^isub>i \<equiv> x\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text "rhs"}}\\ |
2277 \text{@{text "y\<^isub>i \<equiv> x\<^isub>i"} provided @{text "x\<^isub>i"} does not occur in @{text "rhs"}}\\ |
2309 |
2361 |
2310 \noindent |
2362 \noindent |
2311 This fact will be crucial when establishing the strong induction principles below. |
2363 This fact will be crucial when establishing the strong induction principles below. |
2312 |
2364 |
2313 |
2365 |
2314 In our running example about @{text "Let"}, the strong induction |
2366 |
2315 principle means that instead |
|
2316 of establishing the implication |
|
2317 |
|
2318 \begin{center} |
|
2319 @{text "\<forall>p t\<^isub>1 t\<^isub>2. P\<^bsub>pat\<^esub> p \<and> P\<^bsub>trm\<^esub> t\<^isub>1 \<and> P\<^bsub>trm\<^esub> t\<^isub>2 \<Rightarrow> P\<^bsub>trm\<^esub> (Let p t\<^isub>1 t\<^isub>2)"} |
|
2320 \end{center} |
|
2321 |
|
2322 \noindent |
|
2323 it is sufficient to establish the following implication |
|
2324 |
|
2325 \begin{equation}\label{strong} |
|
2326 \mbox{\begin{tabular}{l} |
|
2327 @{text "\<forall>p t\<^isub>1 t\<^isub>2 c."}\\ |
|
2328 \hspace{5mm}@{text "set (bn p) #\<^sup>* c \<and>"}\\ |
|
2329 \hspace{5mm}@{text "(\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>1) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t\<^isub>2)"}\\ |
|
2330 \hspace{15mm}@{text "\<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t\<^isub>1 t\<^isub>2)"} |
|
2331 \end{tabular}} |
|
2332 \end{equation} |
|
2333 |
|
2334 \noindent |
|
2335 While this implication contains an additional argument, namely @{text c}, and |
|
2336 also additional universal quantifications, it is usually easier to establish. |
|
2337 The reason is that we have the freshness |
|
2338 assumption @{text "set (bn\<^sup>\<alpha> p) #\<^sup>* c"}, whereby @{text c} can be arbitrarily |
|
2339 chosen by the user as long as it has finite support. |
|
2340 |
|
2341 Let us now show how we derive the strong induction principles from the |
|
2342 weak ones. In case of the @{text "Let"}-example we derive by the weak |
|
2343 induction the following two properties |
|
2344 |
|
2345 \begin{equation}\label{hyps} |
|
2346 @{text "\<forall>q c. P\<^bsub>trm\<^esub> c (q \<bullet> t)"} \hspace{4mm} |
|
2347 @{text "\<forall>q\<^isub>1 q\<^isub>2 c. P\<^bsub>pat\<^esub> (q\<^isub>1 \<bullet>\<AL>\<^bsub>bn\<^esub> (q\<^isub>2 \<bullet> p))"} |
|
2348 \end{equation} |
|
2349 |
|
2350 \noindent |
|
2351 For the @{text Let} term-constructor we therefore have to establish @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"} |
|
2352 assuming \eqref{hyps} as induction hypotheses (the first for @{text t\<^isub>1} and @{text t\<^isub>2}). |
|
2353 By Property~\ref{avoiding} we |
|
2354 obtain a permutation @{text "r"} such that |
|
2355 |
|
2356 \begin{equation}\label{rprops} |
|
2357 @{term "(r \<bullet> set (bn (q \<bullet> p))) \<sharp>* c "}\hspace{4mm} |
|
2358 @{term "supp (Abs_lst (bn (q \<bullet> p)) (q \<bullet> t\<^isub>2)) \<sharp>* r"} |
|
2359 \end{equation} |
|
2360 |
|
2361 \noindent |
|
2362 hold. The latter fact and \eqref{renaming} give us |
|
2363 |
|
2364 \begin{center} |
|
2365 \begin{tabular}{l} |
|
2366 @{text "Let (q \<bullet> p) (q \<bullet> t\<^isub>1) (q \<bullet> t\<^isub>2) ="} \\ |
|
2367 \hspace{15mm}@{text "Let (r \<bullet>\<AL>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2))"} |
|
2368 \end{tabular} |
|
2369 \end{center} |
|
2370 |
|
2371 \noindent |
|
2372 So instead of proving @{text "P\<^bsub>trm\<^esub> c (q \<bullet> Let p t\<^isub>1 t\<^isub>2)"}, we can equally |
|
2373 establish @{text "P\<^bsub>trm\<^esub> c (Let (r \<bullet>\<AL>\<^bsub>bn\<^esub> (q \<bullet> p)) (q \<bullet> t\<^isub>1) (r \<bullet> (q \<bullet> t\<^isub>2)))"}. |
|
2374 To do so, we will use the implication \eqref{strong} of the strong induction |
|
2375 principle, which requires us to discharge |
|
2376 the following four proof obligations: |
|
2377 |
|
2378 \begin{center} |
|
2379 \begin{tabular}{rl} |
|
2380 {\it (i)} & @{text "set (bn (r \<bullet>\<AL>\<^bsub>bn\<^esub> (q \<bullet> p))) #\<^sup>* c"}\\ |
|
2381 {\it (ii)} & @{text "\<forall>d. P\<^bsub>pat\<^esub> d (r \<bullet>\<AL>\<^bsub>bn\<^esub> (q \<bullet> p))"}\\ |
|
2382 {\it (iii)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (q \<bullet> t\<^isub>1)"}\\ |
|
2383 {\it (iv)} & @{text "\<forall>d. P\<^bsub>trm\<^esub> d (r \<bullet> (q \<bullet> t\<^isub>2))"}\\ |
|
2384 \end{tabular} |
|
2385 \end{center} |
|
2386 |
|
2387 \noindent |
|
2388 The first follows from \eqref{rprops} and Lemma~\ref{permutebn}.{\it (i)}; the |
|
2389 others from the induction hypotheses in \eqref{hyps} (in the fourth case |
|
2390 we have to use the fact that @{term "(r \<bullet> (q \<bullet> t\<^isub>2)) = (r + q) \<bullet> t\<^isub>2"}). |
|
2391 |
|
2392 Taking now the identity permutation @{text 0} for the permutations in \eqref{hyps}, |
|
2393 we can establish our original goals, namely @{text "P\<^bsub>trm\<^esub> c t"} and \mbox{@{text "P\<^bsub>pat\<^esub> c p"}}. |
|
2394 This completes the proof showing that the weak induction principles imply |
2367 This completes the proof showing that the weak induction principles imply |
2395 the strong induction principles. |
2368 the strong induction principles. |
|
2369 } |
2396 *} |
2370 *} |
2397 |
2371 |
2398 |
2372 |
2399 section {* Related Work\label{related} *} |
2373 section {* Related Work\label{related} *} |
2400 |
2374 |