1932 %These additional assumptions amount to a formal |
1932 %These additional assumptions amount to a formal |
1933 %version of the informal variable convention for binders. |
1933 %version of the informal variable convention for binders. |
1934 To sketch how this strengthening extends to the case of multiple binders, we use as |
1934 To sketch how this strengthening extends to the case of multiple binders, we use as |
1935 running example the term-constructors @{text "Lam"} and @{text "Let"} |
1935 running example the term-constructors @{text "Lam"} and @{text "Let"} |
1936 from example \eqref{letpat}. Instead of establishing @{text " P\<^bsub>trm\<^esub> t \<and> P\<^bsub>pat\<^esub> p"}, |
1936 from example \eqref{letpat}. Instead of establishing @{text " P\<^bsub>trm\<^esub> t \<and> P\<^bsub>pat\<^esub> p"}, |
1937 the stronger induction principles establish properties @{text " P\<^bsub>trm\<^esub> c t \<and> P\<^bsub>pat\<^esub> c p"} |
1937 the stronger induction principle for \eqref{letpat} establishes properties @{text " P\<^bsub>trm\<^esub> c t \<and> P\<^bsub>pat\<^esub> c p"} |
1938 where the additional parameter @{text c} controls |
1938 where the additional parameter @{text c} controls |
1939 which freshness assumptions the binders should satisfy. For the two term constructors |
1939 which freshness assumptions the binders should satisfy. For the two term constructors |
1940 this means that the user has to establish in inductions the implications |
1940 this means that the user has to establish in inductions the implications |
1941 % |
1941 % |
1942 \begin{center} |
1942 \begin{center} |
1943 \begin{tabular}{l} |
1943 \begin{tabular}{l} |
1944 @{text "\<forall>a t c. {atom a} \<FRESH>\<^sup>* c \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t) \<Rightarrow> P\<^bsub>trm\<^esub> c (Lam a t)"}\\ |
1944 @{text "\<forall>a t c. {atom a} \<FRESH>\<^sup>* c \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t) \<Rightarrow> P\<^bsub>trm\<^esub> c (Lam a t)"}\\ |
1945 @{text "\<forall>p t c. (set (bn p)) \<FRESH>\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t) \<and> \<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t)"} |
1945 @{text "\<forall>p t c. (set (bn p)) \<FRESH>\<^sup>* c \<and> (\<forall>d. P\<^bsub>pat\<^esub> d p) \<and> (\<forall>d. P\<^bsub>trm\<^esub> d t) \<and> \<Rightarrow> P\<^bsub>trm\<^esub> c (Let p t)"}\\%[-0mm] |
1946 \end{tabular} |
1946 \end{tabular} |
1947 \end{center} |
1947 \end{center} |
1948 |
1948 |
1949 In \cite{UrbanTasson05} we showed how the weaker induction principles imply |
1949 In \cite{UrbanTasson05} we showed how the weaker induction principles imply |
1950 the stronger ones. This was done by some quite complicated, nevertheless automated, |
1950 the stronger ones. This was done by some quite complicated, nevertheless automated, |
1951 induction proofs. In this paper we simplify this work by leveraging the automated proof |
1951 induction proofs. In this paper we simplify this work by leveraging the automated proof |
1952 methods from the function package of Isabelle/HOL generates. |
1952 methods from the function package of Isabelle/HOL generates. |
1953 |
1953 The reasoning principle these methods employ is well-founded induction. |
1954 The reasoning principle we employ here is well-founded induction. For this we have to discharge |
1954 To use them in our setting, we have to discharge |
1955 two proof obligations: one is that we have |
1955 two proof obligations: one is that we have |
1956 well-founded measures (for each type @{text "ty"}$^\alpha_{1..n}$) that decrease in |
1956 well-founded measures (for each type @{text "ty"}$^\alpha_{1..n}$) that decrease in |
1957 every induction step and the other is that we have covered all cases. |
1957 every induction step and the other is that we have covered all cases. |
1958 As measures we use are the size functions |
1958 As measures we use the size functions |
1959 @{text "size_ty"}$^\alpha_{1..n}$, which we lifted in the previous section and which are |
1959 @{text "size_ty"}$^\alpha_{1..n}$, which we lifted in the previous section and which are |
1960 all well-founded. It is straightforward to establish that these measures decrease |
1960 all well-founded. It is straightforward to establish that these measures decrease |
1961 in every induction step. |
1961 in every induction step. |
1962 |
1962 |
1963 What is left to show is that we covered all cases. To do so, we use |
1963 What is left to show is that we covered all cases. To do so, we use |
1964 a cases lemma derived for each type, which for the terms in \eqref{letpat} |
1964 a cases lemma derived for each type. For the terms in \eqref{letpat} |
1965 is of the form |
1965 this lemma is of the form |
1966 % |
1966 % |
1967 \begin{equation}\label{weakcases} |
1967 \begin{equation}\label{weakcases} |
1968 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
1968 \infer{@{text "P\<^bsub>trm\<^esub>"}} |
1969 {\begin{array}{l@ {\hspace{9mm}}l} |
1969 {\begin{array}{l@ {\hspace{9mm}}l} |
1970 @{text "\<forall>x. t = Var x \<Rightarrow> P\<^bsub>trm\<^esub>"} & @{text "\<forall>a t'. t = Lam a t' \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1970 @{text "\<forall>x. t = Var x \<Rightarrow> P\<^bsub>trm\<^esub>"} & @{text "\<forall>a t'. t = Lam a t' \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1971 @{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>"}\\ |
1971 @{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>"}\\ |
1972 \end{array}} |
1972 \end{array}}\\[-1mm] |
1973 \end{equation} |
1973 \end{equation} |
1974 % |
1974 % |
1975 These cases lemmas have a premise for each term-constructor. |
1975 where we have a premise for each term-constructor. |
1976 The idea behind them is that we can conclude with a property @{text "P\<^bsub>trm\<^esub>"}, |
1976 The idea behind such cases lemmas is that we can conclude with a property @{text "P\<^bsub>trm\<^esub>"}, |
1977 provided we can show that this property holds if we substitute for @{text "t"} all |
1977 provided we can show that this property holds if we substitute for @{text "t"} all |
1978 possible term-constructors. |
1978 possible term-constructors. |
1979 |
1979 |
1980 The only remaining difficulty is that in order to derive the stronger induction |
1980 The only remaining difficulty is that in order to derive the stronger induction |
1981 principles conveniently, the cases lemma in \eqref{weakcases} is too weak. For this note that |
1981 principles conveniently, the cases lemma in \eqref{weakcases} is too weak. For this note that |
1982 in order to apply this lemma, we have to establish @{text "P\<^bsub>trm\<^esub>"} for \emph{all} @{text Lam}- and |
1982 in order to apply this lemma, we have to establish @{text "P\<^bsub>trm\<^esub>"} for \emph{all} @{text Lam}- and |
1983 \emph{all} @{text Let}-terms. |
1983 \emph{all} @{text Let}-terms. |
1984 What we need instead is a cases rule where we only have to consider terms that have |
1984 What we need instead is a cases rule where we only have to consider terms that have |
1985 binders being fresh w.r.t.~a context @{text "c"}, namely |
1985 binders that are fresh w.r.t.~a context @{text "c"}. This gives the implications |
1986 % |
1986 % |
1987 \begin{center} |
1987 \begin{center} |
1988 \begin{tabular}{l} |
1988 \begin{tabular}{l} |
1989 @{text "\<forall>a t'. t = Lam a t' \<and> {atom a} \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1989 @{text "\<forall>a t'. t = Lam a t' \<and> {atom a} \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"}\\ |
1990 @{text "\<forall>p t'. t = Let p t' \<and> (set (bn p)) \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"} |
1990 @{text "\<forall>p t'. t = Let p t' \<and> (set (bn p)) \<FRESH>\<^sup>* c \<Rightarrow> P\<^bsub>trm\<^esub>"}\\%[-2mm] |
1991 \end{tabular} |
1991 \end{tabular} |
1992 \end{center} |
1992 \end{center} |
1993 % |
1993 % |
1994 However, this can be relatively easily be derived from the implications in \eqref{weakcases} |
1994 \noindent |
|
1995 which however can be relatively easily be derived from the implications in \eqref{weakcases} |
1995 by a renaming using Properties \ref{supppermeq} and \ref{avoiding}. In the first case we know |
1996 by a renaming using Properties \ref{supppermeq} and \ref{avoiding}. In the first case we know |
1996 that @{text "{atom a} \<FRESH>\<^sup>* Lam a t"}. Property \eqref{avoiding} provides us therefore with |
1997 that @{text "{atom a} \<FRESH>\<^sup>* Lam a t"}. Property \eqref{avoiding} provides us therefore with |
1997 a permutation @{text q}, such that @{text "{atom (q \<bullet> a)} \<FRESH>\<^sup>* c"} and |
1998 a permutation @{text q}, such that @{text "{atom (q \<bullet> a)} \<FRESH>\<^sup>* c"} and |
1998 @{text "supp (Lam a t) \<FRESH>\<^sup>* q"} hold. |
1999 @{text "supp (Lam a t) \<FRESH>\<^sup>* q"} hold. |
1999 By using Property \ref{supppermeq}, we can infer that @{text "Lam (q \<bullet> a) (q \<bullet> t) = Lam a t"} |
2000 By using Property \ref{supppermeq}, we can infer from the latter |
|
2001 that @{text "Lam (q \<bullet> a) (q \<bullet> t) = Lam a t"} |
2000 and we are done with this case. |
2002 and we are done with this case. |
2001 |
2003 |
2002 The @{text Let}-case involving a (non-recursive) deep binder is a bit more complicated. |
2004 The @{text Let}-case involving a (non-recursive) deep binder is a bit more complicated. |
2003 The reason is that the we cannot apply Property \ref{avoiding} to the whole term @{text "Let p t"}, |
2005 The reason is that the we cannot apply Property \ref{avoiding} to the whole term @{text "Let p t"}, |
2004 because @{text p} might contain names that are bound (by @{text bn}) and that are |
2006 because @{text p} might contain names that are bound (by @{text bn}) and so are |
2005 free. To solve this problem we have to introduce a permutation functions that only |
2007 free. To solve this problem we have to introduce a permutation function that only |
2006 permutes names bound by @{text bn} and leaves the other names unchanged. We do this again |
2008 permutes names bound by @{text bn} and leaves the other names unchanged. We do this again |
2007 by lifting. Assuming a |
2009 by lifting. For a |
2008 clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"}, we define |
2010 clause @{text "bn (C x\<^isub>1 \<dots> x\<^isub>r) = rhs"}, we define |
2009 % |
2011 % |
2010 \begin{center} |
2012 \begin{center} |
2011 @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>r) \<equiv> C y\<^isub>1 \<dots> y\<^isub>r"} \;\; with |
2013 @{text "p \<bullet>\<^bsub>bn\<^esub> (C x\<^isub>1 \<dots> x\<^isub>r) \<equiv> C y\<^isub>1 \<dots> y\<^isub>r"} \;\; with |
2012 $\begin{cases} |
2014 $\begin{cases} |