| author | wenzelm | 
| Sat, 15 Oct 2005 00:08:05 +0200 | |
| changeset 17856 | 0551978bfda5 | 
| parent 17456 | bcf7544875b2 | 
| child 17955 | 3b34516662c6 | 
| permissions | -rw-r--r-- | 
| 17456 | 1  | 
(* Title: CCL/Fix.ML  | 
| 0 | 2  | 
ID: $Id$  | 
| 1459 | 3  | 
Author: Martin Coen, Cambridge University Computer Laboratory  | 
| 0 | 4  | 
Copyright 1993 University of Cambridge  | 
5  | 
*)  | 
|
6  | 
||
7  | 
(*** Fixed Point Induction ***)  | 
|
8  | 
||
| 17456 | 9  | 
val [base,step,incl] = goalw (the_context ()) [INCL_def]  | 
| 3837 | 10  | 
"[| P(bot); !!x. P(x) ==> P(f(x)); INCL(P) |] ==> P(fix(f))";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
11  | 
by (rtac (incl RS spec RS mp) 1);  | 
| 0 | 12  | 
by (rtac (Nat_ind RS ballI) 1 THEN atac 1);  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
13  | 
by (ALLGOALS (simp_tac term_ss));  | 
| 0 | 14  | 
by (REPEAT (ares_tac [base,step] 1));  | 
| 757 | 15  | 
qed "fix_ind";  | 
| 0 | 16  | 
|
17  | 
(*** Inclusive Predicates ***)  | 
|
18  | 
||
| 17456 | 19  | 
val prems = goalw (the_context ()) [INCL_def]  | 
| 0 | 20  | 
"INCL(P) <-> (ALL f. (ALL n:Nat. P(f ^ n ` bot)) --> P(fix(f)))";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
21  | 
by (rtac iff_refl 1);  | 
| 757 | 22  | 
qed "inclXH";  | 
| 0 | 23  | 
|
| 17456 | 24  | 
val prems = goal (the_context ())  | 
| 3837 | 25  | 
"[| !!f. ALL n:Nat. P(f^n`bot) ==> P(fix(f)) |] ==> INCL(%x. P(x))";  | 
| 0 | 26  | 
by (fast_tac (term_cs addIs (prems @ [XH_to_I inclXH])) 1);  | 
| 757 | 27  | 
qed "inclI";  | 
| 0 | 28  | 
|
| 17456 | 29  | 
val incl::prems = goal (the_context ())  | 
| 3837 | 30  | 
"[| INCL(P); !!n. n:Nat ==> P(f^n`bot) |] ==> P(fix(f))";  | 
| 17456 | 31  | 
by (fast_tac (term_cs addIs ([ballI RS (incl RS (XH_to_D inclXH) RS spec RS mp)]  | 
| 0 | 32  | 
@ prems)) 1);  | 
| 757 | 33  | 
qed "inclD";  | 
| 0 | 34  | 
|
| 17456 | 35  | 
val incl::prems = goal (the_context ())  | 
| 3837 | 36  | 
"[| INCL(P); (ALL n:Nat. P(f^n`bot))-->P(fix(f)) ==> R |] ==> R";  | 
| 0 | 37  | 
by (fast_tac (term_cs addIs ([incl RS inclD] @ prems)) 1);  | 
| 757 | 38  | 
qed "inclE";  | 
| 0 | 39  | 
|
40  | 
||
41  | 
(*** Lemmas for Inclusive Predicates ***)  | 
|
42  | 
||
| 5062 | 43  | 
Goal "INCL(%x.~ a(x) [= t)";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
44  | 
by (rtac inclI 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
45  | 
by (dtac bspec 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
46  | 
by (rtac zeroT 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
47  | 
by (etac contrapos 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
48  | 
by (rtac po_trans 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
49  | 
by (assume_tac 2);  | 
| 2035 | 50  | 
by (stac napplyBzero 1);  | 
| 0 | 51  | 
by (rtac po_cong 1 THEN rtac po_bot 1);  | 
| 757 | 52  | 
qed "npo_INCL";  | 
| 0 | 53  | 
|
| 17456 | 54  | 
val prems = goal (the_context ()) "[| INCL(P); INCL(Q) |] ==> INCL(%x. P(x) & Q(x))";  | 
| 0 | 55  | 
by (fast_tac (set_cs addSIs ([inclI] @ (prems RL [inclD]))) 1);;  | 
| 757 | 56  | 
qed "conj_INCL";  | 
| 0 | 57  | 
|
| 17456 | 58  | 
val prems = goal (the_context ()) "[| !!a. INCL(P(a)) |] ==> INCL(%x. ALL a. P(a,x))";  | 
| 0 | 59  | 
by (fast_tac (set_cs addSIs ([inclI] @ (prems RL [inclD]))) 1);;  | 
| 757 | 60  | 
qed "all_INCL";  | 
| 0 | 61  | 
|
| 17456 | 62  | 
val prems = goal (the_context ()) "[| !!a. a:A ==> INCL(P(a)) |] ==> INCL(%x. ALL a:A. P(a,x))";  | 
| 0 | 63  | 
by (fast_tac (set_cs addSIs ([inclI] @ (prems RL [inclD]))) 1);;  | 
| 757 | 64  | 
qed "ball_INCL";  | 
| 0 | 65  | 
|
| 5062 | 66  | 
Goal "INCL(%x. a(x) = (b(x)::'a::prog))";  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
67  | 
by (simp_tac (term_ss addsimps [eq_iff]) 1);  | 
| 0 | 68  | 
by (REPEAT (resolve_tac [conj_INCL,po_INCL] 1));  | 
| 757 | 69  | 
qed "eq_INCL";  | 
| 0 | 70  | 
|
71  | 
(*** Derivation of Reachability Condition ***)  | 
|
72  | 
||
73  | 
(* Fixed points of idgen *)  | 
|
74  | 
||
| 5062 | 75  | 
Goal "idgen(fix(idgen)) = fix(idgen)";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
76  | 
by (rtac (fixB RS sym) 1);  | 
| 757 | 77  | 
qed "fix_idgenfp";  | 
| 0 | 78  | 
|
| 5062 | 79  | 
Goalw [idgen_def] "idgen(lam x. x) = lam x. x";  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
80  | 
by (simp_tac term_ss 1);  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
81  | 
by (rtac (term_case RS allI) 1);  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
82  | 
by (ALLGOALS (simp_tac term_ss));  | 
| 757 | 83  | 
qed "id_idgenfp";  | 
| 0 | 84  | 
|
85  | 
(* All fixed points are lam-expressions *)  | 
|
86  | 
||
| 17456 | 87  | 
val [prem] = goal (the_context ()) "idgen(d) = d ==> d = lam x.?f(x)";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
88  | 
by (rtac (prem RS subst) 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
89  | 
by (rewtac idgen_def);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
90  | 
by (rtac refl 1);  | 
| 757 | 91  | 
qed "idgenfp_lam";  | 
| 0 | 92  | 
|
93  | 
(* Lemmas for rewriting fixed points of idgen *)  | 
|
94  | 
||
| 17456 | 95  | 
val prems = goalw (the_context ()) [idgen_def]  | 
| 0 | 96  | 
"[| a = b; a ` t = u |] ==> b ` t = u";  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
97  | 
by (simp_tac (term_ss addsimps (prems RL [sym])) 1);  | 
| 757 | 98  | 
qed "l_lemma";  | 
| 0 | 99  | 
|
100  | 
val idgen_lemmas =  | 
|
| 17456 | 101  | 
let fun mk_thm s = prove_goalw (the_context ()) [idgen_def] s  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
102  | 
(fn [prem] => [rtac (prem RS l_lemma) 1,simp_tac term_ss 1])  | 
| 0 | 103  | 
in map mk_thm  | 
104  | 
[ "idgen(d) = d ==> d ` bot = bot",  | 
|
105  | 
"idgen(d) = d ==> d ` true = true",  | 
|
106  | 
"idgen(d) = d ==> d ` false = false",  | 
|
107  | 
"idgen(d) = d ==> d ` <a,b> = <d ` a,d ` b>",  | 
|
| 3837 | 108  | 
"idgen(d) = d ==> d ` (lam x. f(x)) = lam x. d ` f(x)"]  | 
| 0 | 109  | 
end;  | 
110  | 
||
| 17456 | 111  | 
(* Proof of Reachability law - show that fix and lam x.x both give LEAST fixed points  | 
| 0 | 112  | 
of idgen and hence are they same *)  | 
113  | 
||
| 17456 | 114  | 
val [p1,p2,p3] = goal (the_context ())  | 
| 3837 | 115  | 
"[| ALL x. t ` x [= u ` x; EX f. t=lam x. f(x); EX f. u=lam x. f(x) |] ==> t [= u";  | 
| 2035 | 116  | 
by (stac (p2 RS cond_eta) 1);  | 
117  | 
by (stac (p3 RS cond_eta) 1);  | 
|
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
118  | 
by (rtac (p1 RS (po_lam RS iffD2)) 1);  | 
| 757 | 119  | 
qed "po_eta";  | 
| 0 | 120  | 
|
| 17456 | 121  | 
val [prem] = goalw (the_context ()) [idgen_def] "idgen(d) = d ==> d = lam x.?f(x)";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
122  | 
by (rtac (prem RS subst) 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
123  | 
by (rtac refl 1);  | 
| 757 | 124  | 
qed "po_eta_lemma";  | 
| 0 | 125  | 
|
| 17456 | 126  | 
val [prem] = goal (the_context ())  | 
| 0 | 127  | 
"idgen(d) = d ==> \  | 
| 3837 | 128  | 
\      {p. EX a b. p=<a,b> & (EX t. a=fix(idgen) ` t & b = d ` t)} <=   \
 | 
129  | 
\      POgen({p. EX a b. p=<a,b> & (EX t. a=fix(idgen) ` t  & b = d ` t)})";
 | 
|
| 0 | 130  | 
by (REPEAT (step_tac term_cs 1));  | 
131  | 
by (term_case_tac "t" 1);  | 
|
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
132  | 
by (ALLGOALS (simp_tac (term_ss addsimps (POgenXH::([prem,fix_idgenfp] RL idgen_lemmas)))));  | 
| 0 | 133  | 
by (ALLGOALS (fast_tac set_cs));  | 
| 757 | 134  | 
qed "lemma1";  | 
| 0 | 135  | 
|
| 17456 | 136  | 
val [prem] = goal (the_context ())  | 
| 0 | 137  | 
"idgen(d) = d ==> fix(idgen) [= d";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
138  | 
by (rtac (allI RS po_eta) 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
139  | 
by (rtac (lemma1 RSN(2,po_coinduct)) 1);  | 
| 0 | 140  | 
by (ALLGOALS (fast_tac (term_cs addIs [prem,po_eta_lemma,fix_idgenfp])));  | 
| 757 | 141  | 
qed "fix_least_idgen";  | 
| 0 | 142  | 
|
| 17456 | 143  | 
val [prem] = goal (the_context ())  | 
| 0 | 144  | 
"idgen(d) = d ==> \  | 
| 3837 | 145  | 
\      {p. EX a b. p=<a,b> & b = d ` a} <= POgen({p. EX a b. p=<a,b> & b = d ` a})";
 | 
| 0 | 146  | 
by (REPEAT (step_tac term_cs 1));  | 
147  | 
by (term_case_tac "a" 1);  | 
|
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
148  | 
by (ALLGOALS (simp_tac (term_ss addsimps (POgenXH::([prem] RL idgen_lemmas)))));  | 
| 0 | 149  | 
by (ALLGOALS (fast_tac set_cs));  | 
| 757 | 150  | 
qed "lemma2";  | 
| 0 | 151  | 
|
| 17456 | 152  | 
val [prem] = goal (the_context ())  | 
| 3837 | 153  | 
"idgen(d) = d ==> lam x. x [= d";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
154  | 
by (rtac (allI RS po_eta) 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
155  | 
by (rtac (lemma2 RSN(2,po_coinduct)) 1);  | 
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
156  | 
by (simp_tac term_ss 1);  | 
| 0 | 157  | 
by (ALLGOALS (fast_tac (term_cs addIs [prem,po_eta_lemma,fix_idgenfp])));  | 
| 757 | 158  | 
qed "id_least_idgen";  | 
| 0 | 159  | 
|
| 5062 | 160  | 
Goal "fix(idgen) = lam x. x";  | 
| 0 | 161  | 
by (fast_tac (term_cs addIs [eq_iff RS iffD2,  | 
162  | 
id_idgenfp RS fix_least_idgen,  | 
|
163  | 
fix_idgenfp RS id_least_idgen]) 1);  | 
|
| 757 | 164  | 
qed "reachability";  | 
| 0 | 165  | 
|
166  | 
(********)  | 
|
167  | 
||
| 17456 | 168  | 
val [prem] = goal (the_context ()) "f = lam x. x ==> f`t = t";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
169  | 
by (rtac (prem RS sym RS subst) 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
170  | 
by (rtac applyB 1);  | 
| 757 | 171  | 
qed "id_apply";  | 
| 0 | 172  | 
|
| 17456 | 173  | 
val prems = goal (the_context ())  | 
| 0 | 174  | 
"[| P(bot); P(true); P(false); \  | 
175  | 
\ !!x y.[| P(x); P(y) |] ==> P(<x,y>); \  | 
|
| 3837 | 176  | 
\ !!u.(!!x. P(u(x))) ==> P(lam x. u(x)); INCL(P) |] ==> \  | 
| 0 | 177  | 
\ P(t)";  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
178  | 
by (rtac (reachability RS id_apply RS subst) 1);  | 
| 0 | 179  | 
by (res_inst_tac [("x","t")] spec 1);
 | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
180  | 
by (rtac fix_ind 1);  | 
| 
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
181  | 
by (rewtac idgen_def);  | 
| 0 | 182  | 
by (REPEAT_SOME (ares_tac [allI]));  | 
| 2035 | 183  | 
by (stac applyBbot 1);  | 
| 
642
 
0db578095e6a
CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
 
lcp 
parents: 
442 
diff
changeset
 | 
184  | 
by (resolve_tac prems 1);  | 
| 0 | 185  | 
br (applyB RS ssubst )1;  | 
186  | 
by (res_inst_tac [("t","xa")] term_case 1);
 | 
|
| 
8
 
c3d2c6dcf3f0
Installation of new simplfier.  Previously appeared to set up the old
 
lcp 
parents: 
0 
diff
changeset
 | 
187  | 
by (ALLGOALS (simp_tac term_ss));  | 
| 0 | 188  | 
by (ALLGOALS (fast_tac (term_cs addIs ([all_INCL,INCL_subst] @ prems))));  | 
| 757 | 189  | 
qed "term_ind";  |