Added weak congruence rules to HOL: if_weak_cong, case_weak_cong,
split_weak_cong, nat_case_weak_cong, nat_rec_weak_cong. Used in llist.ML
to make simplifications faster.
HOL/gfp: re-ordered premises to put mono(f) early (first or right after
A==gfp(f) in the def_ rules). Renamed some variables in rules, A to X and
h to A. Renamed coinduct to weak_coinduct, coinduct2 to coinduct.
Strengthened coinduct as suggested by j. Frost, to have the premise X <= f(X
Un gfp(f)).
HOL/llist: used stronger coinduct rule to strengthen LList_coinduct,
LList_equalityI, llist_equalityI, llist_fun_equalityI and to delete the "2"
form of those rules. Proved List_Fun_LList_I, LListD_Fun_diag_I and
llistD_Fun_range_I to help use the new coinduction rules; most proofs
involving them required small changes. Proved prod_fun_range_eq_diag as
lemma for llist_equalityI.
--- a/Gfp.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/Gfp.ML Wed Sep 22 15:43:05 1993 +0200
@@ -12,13 +12,13 @@
(* gfp(f) is the least upper bound of {u. u <= f(u)} *)
-val prems = goalw Gfp.thy [gfp_def] "[| A <= f(A) |] ==> A <= gfp(f)";
+val prems = goalw Gfp.thy [gfp_def] "[| X <= f(X) |] ==> X <= gfp(f)";
by (rtac (CollectI RS Union_upper) 1);
by (resolve_tac prems 1);
val gfp_upperbound = result();
val prems = goalw Gfp.thy [gfp_def]
- "[| !!u. u <= f(u) ==> u<=A |] ==> gfp(f) <= A";
+ "[| !!u. u <= f(u) ==> u<=X |] ==> gfp(f) <= X";
by (REPEAT (ares_tac ([Union_least]@prems) 1));
by (etac CollectD 1);
val gfp_least = result();
@@ -41,39 +41,45 @@
(*weak version*)
val prems = goal Gfp.thy
- "[| a: A; A <= f(A) |] ==> a : gfp(f)";
+ "[| a: X; X <= f(X) |] ==> a : gfp(f)";
by (rtac (gfp_upperbound RS subsetD) 1);
by (REPEAT (ares_tac prems 1));
-val coinduct = result();
+val weak_coinduct = result();
val [prem,mono] = goal Gfp.thy
- "[| A <= f(A) Un gfp(f); mono(f) |] ==> \
-\ A Un gfp(f) <= f(A Un gfp(f))";
-by (rtac subset_trans 1);
-by (rtac (mono RS mono_Un) 2);
-by (rtac (mono RS gfp_Tarski RS subst) 1);
+ "[| X <= f(X Un gfp(f)); mono(f) |] ==> \
+\ X Un gfp(f) <= f(X Un gfp(f))";
by (rtac (prem RS Un_least) 1);
-by (rtac Un_upper2 1);
-val coinduct2_lemma = result();
+by (rtac (mono RS gfp_lemma2 RS subset_trans) 1);
+by (rtac (Un_upper2 RS subset_trans) 1);
+by (rtac (mono RS mono_Un) 1);
+val coinduct_lemma = result();
-(*strong version, thanks to Martin Coen*)
-val prems = goal Gfp.thy
- "[| a: A; A <= f(A) Un gfp(f); mono(f) |] ==> a : gfp(f)";
-by (rtac (coinduct2_lemma RSN (2,coinduct)) 1);
-by (REPEAT (resolve_tac (prems@[UnI1]) 1));
-val coinduct2 = result();
+(*strong version, thanks to Coen & Frost*)
+goal Gfp.thy
+ "!!X. [| mono(f); a: X; X <= f(X Un gfp(f)) |] ==> a : gfp(f)";
+by (rtac (coinduct_lemma RSN (2, weak_coinduct)) 1);
+by (REPEAT (ares_tac [UnI1, Un_least] 1));
+val coinduct = result();
+
+val [mono,prem] = goal Gfp.thy
+ "[| mono(f); a: gfp(f) |] ==> a: f(X Un gfp(f))";
+br (mono RS mono_Un RS subsetD) 1;
+br (mono RS gfp_lemma2 RS subsetD RS UnI2) 1;
+by (rtac prem 1);
+val gfp_fun_UnI2 = result();
(*** Even Stronger version of coinduct [by Martin Coen]
- - instead of the condition A <= f(A)
- consider A <= (f(A) Un f(f(A)) ...) Un gfp(A) ***)
+ - instead of the condition X <= f(X)
+ consider X <= (f(X) Un f(f(X)) ...) Un gfp(X) ***)
-val [prem] = goal Gfp.thy "mono(f) ==> mono(%x.f(x) Un A Un B)";
+val [prem] = goal Gfp.thy "mono(f) ==> mono(%x.f(x) Un X Un B)";
by (REPEAT (ares_tac [subset_refl, monoI, Un_mono, prem RS monoD] 1));
val coinduct3_mono_lemma= result();
val [prem,mono] = goal Gfp.thy
- "[| A <= f(lfp(%x.f(x) Un A Un gfp(f))); mono(f) |] ==> \
-\ lfp(%x.f(x) Un A Un gfp(f)) <= f(lfp(%x.f(x) Un A Un gfp(f)))";
+ "[| X <= f(lfp(%x.f(x) Un X Un gfp(f))); mono(f) |] ==> \
+\ lfp(%x.f(x) Un X Un gfp(f)) <= f(lfp(%x.f(x) Un X Un gfp(f)))";
by (rtac subset_trans 1);
by (rtac (mono RS coinduct3_mono_lemma RS lfp_lemma3) 1);
by (rtac (Un_least RS Un_least) 1);
@@ -86,8 +92,8 @@
val coinduct3_lemma = result();
val prems = goal Gfp.thy
- "[| a:A; A <= f(lfp(%x.f(x) Un A Un gfp(f))); mono(f) |] ==> a : gfp(f)";
-by (rtac (coinduct3_lemma RSN (2,coinduct)) 1);
+ "[| mono(f); a:X; X <= f(lfp(%x.f(x) Un X Un gfp(f))) |] ==> a : gfp(f)";
+by (rtac (coinduct3_lemma RSN (2,weak_coinduct)) 1);
by (resolve_tac (prems RL [coinduct3_mono_lemma RS lfp_Tarski RS ssubst]) 1);
by (rtac (UnI2 RS UnI1) 1);
by (REPEAT (resolve_tac prems 1));
@@ -96,25 +102,19 @@
(** Definition forms of gfp_Tarski and coinduct, to control unfolding **)
-val [rew,mono] = goal Gfp.thy "[| h==gfp(f); mono(f) |] ==> h = f(h)";
+val [rew,mono] = goal Gfp.thy "[| A==gfp(f); mono(f) |] ==> A = f(A)";
by (rewtac rew);
by (rtac (mono RS gfp_Tarski) 1);
val def_gfp_Tarski = result();
val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(A) |] ==> a: h";
+ "[| A==gfp(f); mono(f); a:X; X <= f(X Un A) |] ==> a: A";
by (rewtac rew);
-by (REPEAT (ares_tac (prems @ [coinduct]) 1));
+by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct]) 1));
val def_coinduct = result();
val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(A) Un h; mono(f) |] ==> a: h";
-by (rewtac rew);
-by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct2]) 1));
-val def_coinduct2 = result();
-
-val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(lfp(%x.f(x) Un A Un h)); mono(f) |] ==> a: h";
+ "[| A==gfp(f); mono(f); a:X; X <= f(lfp(%x.f(x) Un X Un A)) |] ==> a: A";
by (rewtac rew);
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct3]) 1));
val def_coinduct3 = result();
--- a/LList.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/LList.ML Wed Sep 22 15:43:05 1993 +0200
@@ -5,7 +5,9 @@
For llist.thy.
-SHOULD LListD_Fun_CONS_I, etc., be equations (for rewriting)
+SHOULD LListD_Fun_CONS_I, etc., be equations (for rewriting)?
+
+TOO LONG! needs splitting up
*)
open LList;
@@ -14,7 +16,8 @@
val llist_simps = [case_Inl, case_Inr];
val llist_ss = univ_ss addsimps llist_simps
- setloop (split_tac [expand_split,expand_case]);
+ addcongs [split_weak_cong, case_weak_cong]
+ setloop (split_tac [expand_split, expand_case]);
(** the llist functional **)
@@ -45,16 +48,10 @@
(*** Type checking by co-induction, using List_Fun ***)
val prems = goalw LList.thy [LList_def]
- "[| M: X; X <= List_Fun(A,X) |] ==> M: LList(A)";
-by (REPEAT (resolve_tac (prems@[coinduct]) 1));
+ "[| M : X; X <= List_Fun(A, X Un LList(A)) |] ==> M : LList(A)";
+by (REPEAT (resolve_tac (prems@[List_Fun_mono RS coinduct]) 1));
val LList_coinduct = result();
-(*stronger version*)
-val prems = goalw LList.thy [LList_def]
- "[| M : X; X <= List_Fun(A, X) Un LList(A) |] ==> M : LList(A)";
-by (REPEAT (resolve_tac (prems@[coinduct2,List_Fun_mono]) 1));
-val LList_coinduct2 = result();
-
(** Rules to prove the 2nd premise of LList_coinduct **)
goalw LList.thy [List_Fun_def,NIL_def] "NIL: List_Fun(A,X)";
@@ -66,19 +63,25 @@
by (REPEAT (ares_tac [uprodI RS usum_In1I] 1));
val List_Fun_CONS_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goalw LList.thy [LList_def]
+ "!!M N. M: LList(A) ==> M : List_Fun(A, X Un LList(A))";
+by (etac (List_Fun_mono RS gfp_fun_UnI2) 1);
+val List_Fun_LList_I = result();
+
(*** LList_corec satisfies the desired recurion equation ***)
(*A continuity result?*)
goalw LList.thy [CONS_def] "CONS(M, UN x.f(x)) = (UN x. CONS(M, f(x)))";
-by(simp_tac (univ_ss addsimps [In1_UN1, Scons_UN1_y]) 1);
+by (simp_tac (univ_ss addsimps [In1_UN1, Scons_UN1_y]) 1);
val CONS_UN1 = result();
goal Prod.thy "split(p, %x y.UN z.f(x,y,z)) = (UN z. split(p, %x y.f(x,y,z)))";
-by(simp_tac (pair_ss setloop (split_tac [expand_split])) 1);
+by (simp_tac (pair_ss setloop (split_tac [expand_split])) 1);
val split_UN1 = result();
goal Sum.thy "case(s, f, %y. UN z.g(y,z)) = (UN z. case(s, f, %y. g(y,z)))";
-by(simp_tac (sum_ss setloop (split_tac [expand_case])) 1);
+by (simp_tac (sum_ss setloop (split_tac [expand_case])) 1);
val case2_UN1 = result();
val prems = goalw LList.thy [CONS_def]
@@ -97,7 +100,7 @@
\ %v. split(v, %z w. CONS(z, LList_corec(w,f))))";
by (rtac UN1_least 1);
by (nat_ind_tac "k" 1);
-by(ALLGOALS(simp_tac corec_fun_ss));
+by (ALLGOALS(simp_tac corec_fun_ss));
by (REPEAT (resolve_tac [allI, impI, subset_refl RS CONS_mono, UN1_upper] 1));
val LList_corec_subset1 = result();
@@ -133,8 +136,8 @@
by (rtac rangeI 1);
by (safe_tac set_cs);
by (stac LList_corec 1);
-by(simp_tac (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
- CollectI, range_eqI]) 1);
+by (simp_tac (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
+ CollectI, range_eqI]) 1);
(* 6.7 vs 3.4 !!!
by (ASM_SIMP_TAC (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
CollectI, rangeI]) 1);
@@ -151,8 +154,8 @@
by (stac LList_corec 1);
(*nested "case"; requires an explicit split*)
by (res_inst_tac [("s", "f(xa)")] sumE 1);
-by(asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_NIL_I])) 1);
-by(asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_CONS_I, range_eqI])
+by (asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_NIL_I])) 1);
+by (asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_CONS_I, range_eqI])
setloop (split_tac [expand_split])) 1);
(* FIXME: can the selection of the case split be automated?
by (ASM_SIMP_TAC (llist_ss addsimps [List_Fun_CONS_I, rangeI]) 1);*)
@@ -162,10 +165,10 @@
goalw LList.thy [LListD_Fun_def] "mono(LListD_Fun(r))";
by (REPEAT (ares_tac [monoI, subset_refl, dsum_mono, dprod_mono] 1));
-val LListD_fun_mono = result();
+val LListD_Fun_mono = result();
val LListD_unfold = rewrite_rule [LListD_Fun_def]
- (LListD_fun_mono RS (LListD_def RS def_gfp_Tarski));
+ (LListD_Fun_mono RS (LListD_def RS def_gfp_Tarski));
goal LList.thy "!M N. <M,N> : LListD(diag(A)) --> ntrunc(k,M) = ntrunc(k,N)";
by (res_inst_tac [("n", "k")] less_induct 1);
@@ -173,16 +176,16 @@
by (etac (LListD_unfold RS equalityD1 RS subsetD RS dsumE) 1);
by (safe_tac (set_cs addSEs [Pair_inject, dprodE, diagE]));
by (res_inst_tac [("n", "n")] natE 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_0]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_0]) 1);
by (res_inst_tac [("n", "xb")] natE 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_one_In1]) 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_In1, ntrunc_Scons]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_one_In1]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_In1, ntrunc_Scons]) 1);
val LListD_implies_ntrunc_equality = result();
goalw LList.thy [LList_def,List_Fun_def] "fst``LListD(diag(A)) <= LList(A)";
by (rtac gfp_upperbound 1);
by (res_inst_tac [("P", "%x. fst``x <= ?B")] (LListD_unfold RS ssubst) 1);
-by(simp_tac fst_image_ss 1);
+by (simp_tac fst_image_ss 1);
val fst_image_LListD = result();
(*This inclusion justifies the use of coinduction to show M=N*)
@@ -215,27 +218,19 @@
diag_subset_LListD] 1));
val LListD_eq_diag = result();
-(** To show two LLists are equal, exhibit a bisimulation! **)
-(* Replace "A" by some particular set, like {x.True}??? *)
-val prems = goal LList.thy
- "[| <M,N> : r; r <= LListD_Fun(diag(A), r) |] ==> M=N";
+(** To show two LLists are equal, exhibit a bisimulation!
+ [also admits true equality]
+ Replace "A" by some particular set, like {x.True}??? *)
+goal LList.thy
+ "!!r. [| <M,N> : r; r <= LListD_Fun(diag(A), r Un diag(LList(A))) \
+\ |] ==> M=N";
by (rtac (rewrite_rule [LListD_def]
(LListD_subset_diag RS subsetD RS diagE)) 1);
-by (REPEAT (resolve_tac (prems@[coinduct]) 1));
+by (etac (LListD_Fun_mono RS coinduct) 1);
+by (etac (rewrite_rule [LListD_def] LListD_eq_diag RS ssubst) 1);
by (safe_tac (set_cs addSEs [Pair_inject]));
val LList_equalityI = result();
-(*Stronger notion of bisimulation -- also admits true equality*)
-val prems = goal LList.thy
- "[| <M,N> : r; r <= LListD_Fun(diag(A), r) Un diag(LList(A)) |] ==> M=N";
-by (rtac (rewrite_rule [LListD_def]
- (LListD_subset_diag RS subsetD RS diagE)) 1);
-by (rtac coinduct2 1);
-by (stac (rewrite_rule [LListD_def] LListD_eq_diag) 2);
-by (REPEAT (resolve_tac (prems@[LListD_fun_mono]) 1));
-by (safe_tac (set_cs addSEs [Pair_inject]));
-val LList_equalityI2 = result();
-
(** Rules to prove the 2nd premise of LList_equalityI **)
goalw LList.thy [LListD_Fun_def,NIL_def] "<NIL,NIL> : LListD_Fun(r,s)";
@@ -248,6 +243,15 @@
by (REPEAT (resolve_tac (diagI::prems) 1));
val LListD_Fun_CONS_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goal LList.thy
+ "!!M N. M: LList(A) ==> <M,M> : LListD_Fun(diag(A), X Un diag(LList(A)))";
+br (rewrite_rule [LListD_def] LListD_eq_diag RS subst) 1;
+br (LListD_Fun_mono RS gfp_fun_UnI2) 1;
+br (rewrite_rule [LListD_def] LListD_eq_diag RS ssubst) 1;
+be diagI 1;
+val LListD_Fun_diag_I = result();
+
(*** Finality of LList(A): Uniqueness of functions defined by corecursion ***)
@@ -264,8 +268,8 @@
by (safe_tac set_cs);
by (stac prem1 1);
by (stac prem2 1);
-by(simp_tac (llist_ss addsimps [LListD_Fun_NIL_I, range_eqI,
- CollectI RS LListD_Fun_CONS_I]) 1);
+by (simp_tac (llist_ss addsimps [LListD_Fun_NIL_I, range_eqI,
+ CollectI RS LListD_Fun_CONS_I]) 1);
(* 9.5 vs 9.2/4.1/4.3
by (ASM_SIMP_TAC (llist_ss addsimps [LListD_Fun_NIL_I, rangeI,
CollectI RS LListD_Fun_CONS_I]) 1);*)
@@ -286,7 +290,7 @@
goalw LList.thy [CONS_def]
"ntrunc(Suc(Suc(k)), CONS(M,N)) = CONS (ntrunc(k,M), ntrunc(k,N))";
-by(simp_tac (HOL_ss addsimps [ntrunc_Scons,ntrunc_In1]) 1);
+by (simp_tac (HOL_ss addsimps [ntrunc_Scons,ntrunc_In1]) 1);
val ntrunc_CONS = result();
val [prem1,prem2] = goal LList.thy
@@ -299,11 +303,11 @@
by (rtac allI 1);
by (stac prem1 1);
by (stac prem2 1);
-by(simp_tac (sum_ss setloop (split_tac [expand_split,expand_case])) 1);
+by (simp_tac (sum_ss setloop (split_tac [expand_split,expand_case])) 1);
by (strip_tac 1);
by (res_inst_tac [("n", "n")] natE 1);
by (res_inst_tac [("n", "xc")] natE 2);
-by(ALLGOALS(asm_simp_tac(nat_ss addsimps
+by (ALLGOALS(asm_simp_tac(nat_ss addsimps
[ntrunc_0,ntrunc_one_CONS,ntrunc_CONS])));
val LList_corec_unique = result();
@@ -323,19 +327,19 @@
by (rtac (singletonI RS LList_coinduct) 1);
by (safe_tac set_cs);
by (res_inst_tac [("P", "%u. u: ?A")] (Lconst RS ssubst) 1);
-by (REPEAT (ares_tac [List_Fun_CONS_I, singletonI] 1));
+by (REPEAT (ares_tac [List_Fun_CONS_I, singletonI, UnI1] 1));
val Lconst_type = result();
goal LList.thy "Lconst(M) = LList_corec(M, %x.Inr(<x,x>))";
by (rtac (equals_LList_corec RS fun_cong) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
by (rtac Lconst 1);
val Lconst_eq_LList_corec = result();
(*Thus we could have used gfp in the definition of Lconst*)
goal LList.thy "gfp(%N. CONS(M, N)) = LList_corec(M, %x.Inr(<x,x>))";
by (rtac (equals_LList_corec RS fun_cong) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
by (rtac (Lconst_fun_mono RS gfp_Tarski) 1);
val gfp_Lconst_eq_LList_corec = result();
@@ -431,10 +435,10 @@
\ f(NIL)=g(NIL); \
\ !!x l. [| x:A; l: LList(A) |] ==> \
\ <f(CONS(x,l)),g(CONS(x,l))> : \
-\ LListD_Fun(diag(A), (%u.<f(u),g(u)>)``LList(A)) Un \
-\ diag(LList(A)) \
+\ LListD_Fun(diag(A), (%u.<f(u),g(u)>)``LList(A) Un \
+\ diag(LList(A))) \
\ |] ==> f(M) = g(M)";
-by (rtac LList_equalityI2 1);
+by (rtac LList_equalityI 1);
br (MList RS imageI) 1;
by (rtac subsetI 1);
by (etac imageE 1);
@@ -442,7 +446,7 @@
by (etac LListE 1);
by (etac ssubst 1);
by (stac NILcase 1);
-br (gMList RS diagI RS UnI2) 1;
+br (gMList RS LListD_Fun_diag_I) 1;
by (etac ssubst 1);
by (REPEAT (ares_tac [CONScase] 1));
val LList_fun_equalityI = result();
@@ -452,12 +456,12 @@
goal LList.thy "Lmap(f,NIL) = NIL";
by (rtac (Lmap_def RS def_LList_corec RS trans) 1);
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
val Lmap_NIL = result();
goal LList.thy "Lmap(f, CONS(M,N)) = CONS(f(M), Lmap(f,N))";
by (rtac (Lmap_def RS def_LList_corec RS trans) 1);
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
val Lmap_CONS = result();
(*Another type-checking proof by coinduction*)
@@ -466,8 +470,9 @@
by (rtac (major RS imageI RS LList_coinduct) 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [List_Fun_NIL_I, List_Fun_CONS_I, minor, imageI] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [List_Fun_NIL_I, List_Fun_CONS_I,
+ minor, imageI, UnI1] 1));
val Lmap_type = result();
(*This type checking rule synthesises a sufficiently large set for f*)
@@ -484,18 +489,18 @@
by (stac o_def 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI,
- rangeI RS LListD_Fun_CONS_I] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI, UnI1,
+ rangeI RS LListD_Fun_CONS_I] 1));
val Lmap_compose = result();
val [prem] = goal LList.thy "M: LList(A) ==> Lmap(%x.x, M) = M";
by (rtac (prem RS imageI RS LList_equalityI) 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI,
- rangeI RS LListD_Fun_CONS_I] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI RS UnI1,
+ rangeI RS LListD_Fun_CONS_I] 1));
val Lmap_ident = result();
@@ -504,7 +509,7 @@
goalw LList.thy [Lappend_def] "Lappend(NIL,NIL) = NIL";
by (rtac (LList_corec RS trans) 1);
(* takes 2.4(3.4 w NORM) vs 0.9 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_NIL_NIL = result();
@@ -512,7 +517,7 @@
"Lappend(NIL,CONS(N,N')) = CONS(N, Lappend(NIL,N'))";
by (rtac (LList_corec RS trans) 1);
(* takes 5(7 w NORM) vs 2.1 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_NIL_CONS = result();
@@ -520,7 +525,7 @@
"Lappend(CONS(M,M'), N) = CONS(M, Lappend(M',N))";
by (rtac (LList_corec RS trans) 1);
(* takes 4.9(6.7) vs 2.2 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_CONS = result();
@@ -563,12 +568,12 @@
(*strong co-induction: bisimulation and case analysis on one variable*)
goal LList.thy
"!!M N. [| M: LList(A); N: LList(A) |] ==> Lappend(M,N): LList(A)";
-by (res_inst_tac [("X", "(%u.Lappend(u,N))``LList(A)")] LList_coinduct2 1);
-fe imageI;
+by (res_inst_tac [("X", "(%u.Lappend(u,N))``LList(A)")] LList_coinduct 1);
+be imageI 1;
br subsetI 1;
be imageE 1;
by (eres_inst_tac [("L", "u")] LListE 1);
-by (asm_simp_tac (Lappend_ss addsimps [Lappend_NIL]) 1);
+by (asm_simp_tac (Lappend_ss addsimps [Lappend_NIL, List_Fun_LList_I]) 1);
by (asm_simp_tac Lappend_ss 1);
by (fast_tac (set_cs addSIs [List_Fun_CONS_I]) 1);
val Lappend_type = result();
@@ -584,12 +589,12 @@
val Rep_LList_ss = llist_ss addsimps Rep_LList_simps;
goalw LList.thy [llist_case_def,LNil_def] "llist_case(LNil, c, d) = c";
-by(simp_tac Rep_LList_ss 1);
+by (simp_tac Rep_LList_ss 1);
val llist_case_LNil = result();
goalw LList.thy [llist_case_def,LCons_def]
"llist_case(LCons(M,N), c, d) = d(M,N)";
-by(simp_tac Rep_LList_ss 1);
+by (simp_tac Rep_LList_ss 1);
val llist_case_LCons = result();
(*Elimination is case analysis, not induction.*)
@@ -602,7 +607,7 @@
by (assume_tac 1);
by (etac rangeE 1);
by (rtac (inj_Rep_LList RS injD RS prem2) 1);
-by(asm_simp_tac (HOL_ss addsimps [Rep_LList_LCons]) 1);
+by (asm_simp_tac (HOL_ss addsimps [Rep_LList_LCons]) 1);
by (etac (Abs_LList_inverse RS ssubst) 1);
by (rtac refl 1);
val llistE = result();
@@ -613,12 +618,12 @@
"llist_corec(a,f) = case(f(a), %u. LNil, \
\ %v. split(v, %z w. LCons(z, llist_corec(w,f))))";
by (stac LList_corec 1);
-by(res_inst_tac [("s","f(a)")] sumE 1);
-by(asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
-by(res_inst_tac [("p","y")] PairE 1);
-by(asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
+by (res_inst_tac [("s","f(a)")] sumE 1);
+by (asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
+by (res_inst_tac [("p","y")] PairE 1);
+by (asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
(*FIXME: correct case splits usd to be found automatically:
-by(ASM_SIMP_TAC(llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);*)
+by (ASM_SIMP_TAC(llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);*)
val llist_corec = result();
(*definitional version of same*)
@@ -653,44 +658,38 @@
by (safe_tac (set_cs addSEs [prod_fun_imageE]));
by (rtac (prem RS subsetD RS SigmaE2) 1);
by (assume_tac 1);
-by(asm_simp_tac (HOL_ss addsimps [o_def,prod_fun,Abs_LList_inverse]) 1);
+by (asm_simp_tac (HOL_ss addsimps [o_def,prod_fun,Abs_LList_inverse]) 1);
val prod_fun_lemma = result();
-(** To show two llists are equal, exhibit a bisimulation! **)
+goal LList.thy
+ "prod_fun(Rep_LList, Rep_LList) `` range(%x. <x, x>) = \
+\ diag(LList(range(Leaf)))";
+br equalityI 1;
+by (fast_tac (set_cs addIs [diagI, Rep_LList]
+ addSEs [prod_fun_imageE, Pair_inject]) 1);
+by (fast_tac (set_cs addIs [prod_fun_imageI, rangeI]
+ addSEs [diagE, Abs_LList_inverse RS subst]) 1);
+val prod_fun_range_eq_diag = result();
+
+(** To show two llists are equal, exhibit a bisimulation!
+ [also admits true equality] **)
val [prem1,prem2] = goalw LList.thy [llistD_Fun_def]
- "[| <l1,l2> : r; r <= llistD_Fun(r) |] ==> l1=l2";
+ "[| <l1,l2> : r; r <= llistD_Fun(r Un range(%x.<x,x>)) |] ==> l1=l2";
by (rtac (inj_Rep_LList RS injD) 1);
-by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r")]
+by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r"),
+ ("A", "range(Leaf)")]
LList_equalityI 1);
by (rtac (prem1 RS prod_fun_imageI) 1);
by (rtac (prem2 RS image_mono RS subset_trans) 1);
by (rtac (image_compose RS subst) 1);
by (rtac (prod_fun_compose RS subst) 1);
-by (rtac (subset_Sigma_LList RS LListD_Fun_subset_Sigma_LList RS
- prod_fun_lemma) 1);
+by (rtac (image_Un RS ssubst) 1);
+by (stac prod_fun_range_eq_diag 1);
+by (rtac (LListD_Fun_subset_Sigma_LList RS prod_fun_lemma) 1);
+by (rtac (subset_Sigma_LList RS Un_least) 1);
+by (rtac diag_subset_Sigma 1);
val llist_equalityI = result();
-
-(*Stronger notion of bisimulation -- also admits true equality*)
-val [prem1,prem2] = goalw LList.thy [llistD_Fun_def]
- "[| <l1,l2> : r; r <= llistD_Fun(r) Un range(%x.<x,x>) |] ==> l1=l2";
-by (rtac (inj_Rep_LList RS injD) 1);
-by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r"),
- ("A", "range(Leaf)")]
- LList_equalityI2 1);
-by (rtac (prem1 RS prod_fun_imageI) 1);
-by (rtac (prem2 RS image_mono RS subset_trans) 1);
-by (rtac (image_Un RS ssubst) 1);
-by (rtac Un_least 1);
-by (rtac (image_compose RS subst) 1);
-by (rtac (prod_fun_compose RS subst) 1);
-by (rtac (subset_Sigma_LList RS LListD_Fun_subset_Sigma_LList RS
- prod_fun_lemma RS subset_trans) 1);
-by (rtac Un_upper1 1);
-by (fast_tac (set_cs addSEs [prod_fun_imageE, Pair_inject]
- addIs [diagI,Rep_LList]) 1);
-val llist_equalityI2 = result();
-
(** Rules to prove the 2nd premise of llist_equalityI **)
goalw LList.thy [llistD_Fun_def,LNil_def] "<LNil,LNil> : llistD_Fun(r)";
by (rtac (LListD_Fun_NIL_I RS prod_fun_imageI) 1);
@@ -702,14 +701,23 @@
by (rtac (prem RS prod_fun_imageI) 1);
val llistD_Fun_LCons_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goalw LList.thy [llistD_Fun_def]
+ "!!l. <l,l> : llistD_Fun(r Un range(%x.<x,x>))";
+br (Rep_LList_inverse RS subst) 1;
+br prod_fun_imageI 1;
+by (rtac (image_Un RS ssubst) 1);
+by (stac prod_fun_range_eq_diag 1);
+br (Rep_LList RS LListD_Fun_diag_I) 1;
+val llistD_Fun_range_I = result();
(*A special case of list_equality for functions over lazy lists*)
val [prem1,prem2] = goal LList.thy
"[| f(LNil)=g(LNil); \
\ !!x l. <f(LCons(x,l)),g(LCons(x,l))> : \
-\ llistD_Fun(range(%u. <f(u),g(u)>)) Un range(%v. <v,v>) \
+\ llistD_Fun(range(%u. <f(u),g(u)>) Un range(%v. <v,v>)) \
\ |] ==> f(l) = g(l :: 'a llist) :: 'b llist";
-by (res_inst_tac [("r", "range(%u. <f(u),g(u)>)")] llist_equalityI2 1);
+by (res_inst_tac [("r", "range(%u. <f(u),g(u)>)")] llist_equalityI 1);
by (rtac rangeI 1);
by (rtac subsetI 1);
by (etac rangeE 1);
@@ -717,7 +725,7 @@
by (res_inst_tac [("l", "u")] llistE 1);
by (etac ssubst 1);
by (stac prem1 1);
-by (fast_tac set_cs 1);
+by (rtac llistD_Fun_range_I 1);
by (etac ssubst 1);
by (rtac prem2 1);
val llist_fun_equalityI = result();
@@ -732,12 +740,12 @@
goal LList.thy "lmap(f,LNil) = LNil";
by (rtac (lmap_def RS def_llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lmap_LNil = result();
goal LList.thy "lmap(f, LCons(M,N)) = LCons(f(M), lmap(f,N))";
by (rtac (lmap_def RS def_llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lmap_LCons = result();
@@ -758,7 +766,7 @@
goal LList.thy "iterates(f,x) = LCons(x, iterates(f,f(x)))";
by (rtac (iterates_def RS def_llist_corec RS trans) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
val iterates = result();
goal LList.thy "lmap(f, iterates(f,x)) = iterates(f,f(x))";
@@ -784,12 +792,12 @@
"nat_rec(n, LCons(b, l), %m. lmap(f)) = \
\ LCons(nat_rec(n, b, %m. f), nat_rec(n, l, %m. lmap(f)))";
by (nat_ind_tac "n" 1);
-by(ALLGOALS (asm_simp_tac (nat_ss addsimps [lmap_LCons])));
+by (ALLGOALS (asm_simp_tac (nat_ss addsimps [lmap_LCons])));
val fun_power_lmap = result();
goal Nat.thy "nat_rec(n, g(x), %m. g) = nat_rec(Suc(n), x, %m. g)";
by (nat_ind_tac "n" 1);
-by(ALLGOALS (asm_simp_tac nat_ss));
+by (ALLGOALS (asm_simp_tac nat_ss));
val fun_power_Suc = result();
val Pair_cong = read_instantiate_sg (sign_of Prod.thy)
@@ -814,7 +822,7 @@
by (rtac (lmap_iterates RS subst) 1);
by (stac fun_power_Suc 1);
by (stac fun_power_Suc 1);
-br UN1_I 1;
+br (UN1_I RS UnI1) 1;
br rangeI 1;
val iterates_equality = result();
@@ -823,20 +831,20 @@
goalw LList.thy [lappend_def] "lappend(LNil,LNil) = LNil";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lappend_LNil_LNil = result();
goalw LList.thy [lappend_def]
"lappend(LNil,LCons(l,l')) = LCons(l, lappend(LNil,l'))";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
(* 3.3(5.7) vs 1.3 !by (SIMP_TAC llistD_ss 1);*)
val lappend_LNil_LCons = result();
goalw LList.thy [lappend_def]
"lappend(LCons(l,l'), N) = LCons(l, lappend(l',N))";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
(* 5(5.5) vs 1.3 !by (SIMP_TAC llistD_ss 1);*)
val lappend_LCons = result();
@@ -877,21 +885,21 @@
by (ALLGOALS (asm_simp_tac (llistD_ss addsimps
[lappend_LNil_LNil,lappend_LCons,lappend_LNil_LCons,
lmap_LNil,lmap_LCons])));
-by (REPEAT_SOME (ares_tac [llistD_Fun_LCons_I, UN1_I, rangeI]));
+by (REPEAT_SOME (ares_tac [llistD_Fun_LCons_I, UN1_I RS UnI1, rangeI]));
by (rtac range_eqI 1);
by (rtac (refl RS Pair_cong) 1);
by (stac lmap_LNil 1);
by (rtac refl 1);
val lmap_lappend_distrib = result();
-(*Shorter proof of the theorem above using llist_equalityI2*)
+(*Shorter proof of theorem above using llist_equalityI as strong coinduction*)
goal LList.thy "lmap(f, lappend(l,n)) = lappend(lmap(f,l), lmap(f,n))";
by (res_inst_tac [("l","l")] llist_fun_equalityI 1);
by (simp_tac (llistD_ss addsimps [lappend_LNil, lmap_LNil])1);
by (simp_tac (llistD_ss addsimps [lappend_LCons, lmap_LCons]) 1);
val lmap_lappend_distrib = result();
-(*Without llist_equalityI2, three case analyses might be needed*)
+(*Without strong coinduction, three case analyses might be needed*)
goal LList.thy "lappend(lappend(l1,l2) ,l3) = lappend(l1, lappend(l2,l3))";
by (res_inst_tac [("l","l1")] llist_fun_equalityI 1);
by (simp_tac (llistD_ss addsimps [lappend_LNil])1);
--- a/Nat.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/Nat.ML Wed Sep 22 15:43:05 1993 +0200
@@ -351,6 +351,15 @@
val nat_ss = pair_ss addsimps nat_simps;
+(*Prevents simplification of f and g: much faster*)
+val nat_case_weak_cong = prove_goal Nat.thy
+ "m=n ==> nat_case(m,a,f) = nat_case(n,a,f)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
+val nat_rec_weak_cong = prove_goal Nat.thy
+ "m=n ==> nat_rec(m,a,f) = nat_rec(n,a,f)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
val prems = goalw Nat.thy [le_def] "~(n<m) ==> m<=n::nat";
by (resolve_tac prems 1);
val leI = result();
--- a/Prod.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/Prod.ML Wed Sep 22 15:43:05 1993 +0200
@@ -58,17 +58,21 @@
by (rtac refl 1);
val split = result();
-(*FIXME: split's congruence rule should only simplifies the pair*)
val pair_ss = set_ss addsimps [fst_conv, snd_conv, split];
+(*Prevents simplification of c: much faster*)
+val split_weak_cong = prove_goal Prod.thy
+ "p=q ==> split(p,c) = split(q,c)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
goal Prod.thy "p = <fst(p),snd(p)>";
by (res_inst_tac [("p","p")] PairE 1);
-by(asm_simp_tac pair_ss 1);
+by (asm_simp_tac pair_ss 1);
val surjective_pairing = result();
goal Prod.thy "p = split(p, %x y.<x,y>)";
by (res_inst_tac [("p","p")] PairE 1);
-by(asm_simp_tac pair_ss 1);
+by (asm_simp_tac pair_ss 1);
val surjective_pairing2 = result();
(** split used as a logical connective, with result type bool **)
@@ -99,13 +103,13 @@
"prod_fun(f1 o f2, g1 o g2) = (prod_fun(f1,g1) o prod_fun(f2,g2))";
by (rtac ext 1);
by (res_inst_tac [("p","x")] PairE 1);
-by(asm_simp_tac (pair_ss addsimps [prod_fun,o_def]) 1);
+by (asm_simp_tac (pair_ss addsimps [prod_fun,o_def]) 1);
val prod_fun_compose = result();
goal Prod.thy "prod_fun(%x.x, %y.y) = (%z.z)";
by (rtac ext 1);
by (res_inst_tac [("p","z")] PairE 1);
-by(asm_simp_tac (pair_ss addsimps [prod_fun]) 1);
+by (asm_simp_tac (pair_ss addsimps [prod_fun]) 1);
val prod_fun_ident = result();
val prems = goal Prod.thy "<a,b>:r ==> <f(a),g(b)> : prod_fun(f,g)``r";
--- a/Sum.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/Sum.ML Wed Sep 22 15:43:05 1993 +0200
@@ -126,5 +126,9 @@
by (fast_tac (set_cs addSEs [make_elim Inr_inject, Inr_neq_Inl]) 1);
val expand_case = result();
-(*FIXME: case's congruence rule only should simplifies the first argument*)
val sum_ss = pair_ss addsimps [case_Inl, case_Inr];
+
+(*Prevents simplification of f and g: much faster*)
+val case_weak_cong = prove_goal Sum.thy
+ "s=t ==> case(s,f,g) = case(t,f,g)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
--- a/gfp.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/gfp.ML Wed Sep 22 15:43:05 1993 +0200
@@ -12,13 +12,13 @@
(* gfp(f) is the least upper bound of {u. u <= f(u)} *)
-val prems = goalw Gfp.thy [gfp_def] "[| A <= f(A) |] ==> A <= gfp(f)";
+val prems = goalw Gfp.thy [gfp_def] "[| X <= f(X) |] ==> X <= gfp(f)";
by (rtac (CollectI RS Union_upper) 1);
by (resolve_tac prems 1);
val gfp_upperbound = result();
val prems = goalw Gfp.thy [gfp_def]
- "[| !!u. u <= f(u) ==> u<=A |] ==> gfp(f) <= A";
+ "[| !!u. u <= f(u) ==> u<=X |] ==> gfp(f) <= X";
by (REPEAT (ares_tac ([Union_least]@prems) 1));
by (etac CollectD 1);
val gfp_least = result();
@@ -41,39 +41,45 @@
(*weak version*)
val prems = goal Gfp.thy
- "[| a: A; A <= f(A) |] ==> a : gfp(f)";
+ "[| a: X; X <= f(X) |] ==> a : gfp(f)";
by (rtac (gfp_upperbound RS subsetD) 1);
by (REPEAT (ares_tac prems 1));
-val coinduct = result();
+val weak_coinduct = result();
val [prem,mono] = goal Gfp.thy
- "[| A <= f(A) Un gfp(f); mono(f) |] ==> \
-\ A Un gfp(f) <= f(A Un gfp(f))";
-by (rtac subset_trans 1);
-by (rtac (mono RS mono_Un) 2);
-by (rtac (mono RS gfp_Tarski RS subst) 1);
+ "[| X <= f(X Un gfp(f)); mono(f) |] ==> \
+\ X Un gfp(f) <= f(X Un gfp(f))";
by (rtac (prem RS Un_least) 1);
-by (rtac Un_upper2 1);
-val coinduct2_lemma = result();
+by (rtac (mono RS gfp_lemma2 RS subset_trans) 1);
+by (rtac (Un_upper2 RS subset_trans) 1);
+by (rtac (mono RS mono_Un) 1);
+val coinduct_lemma = result();
-(*strong version, thanks to Martin Coen*)
-val prems = goal Gfp.thy
- "[| a: A; A <= f(A) Un gfp(f); mono(f) |] ==> a : gfp(f)";
-by (rtac (coinduct2_lemma RSN (2,coinduct)) 1);
-by (REPEAT (resolve_tac (prems@[UnI1]) 1));
-val coinduct2 = result();
+(*strong version, thanks to Coen & Frost*)
+goal Gfp.thy
+ "!!X. [| mono(f); a: X; X <= f(X Un gfp(f)) |] ==> a : gfp(f)";
+by (rtac (coinduct_lemma RSN (2, weak_coinduct)) 1);
+by (REPEAT (ares_tac [UnI1, Un_least] 1));
+val coinduct = result();
+
+val [mono,prem] = goal Gfp.thy
+ "[| mono(f); a: gfp(f) |] ==> a: f(X Un gfp(f))";
+br (mono RS mono_Un RS subsetD) 1;
+br (mono RS gfp_lemma2 RS subsetD RS UnI2) 1;
+by (rtac prem 1);
+val gfp_fun_UnI2 = result();
(*** Even Stronger version of coinduct [by Martin Coen]
- - instead of the condition A <= f(A)
- consider A <= (f(A) Un f(f(A)) ...) Un gfp(A) ***)
+ - instead of the condition X <= f(X)
+ consider X <= (f(X) Un f(f(X)) ...) Un gfp(X) ***)
-val [prem] = goal Gfp.thy "mono(f) ==> mono(%x.f(x) Un A Un B)";
+val [prem] = goal Gfp.thy "mono(f) ==> mono(%x.f(x) Un X Un B)";
by (REPEAT (ares_tac [subset_refl, monoI, Un_mono, prem RS monoD] 1));
val coinduct3_mono_lemma= result();
val [prem,mono] = goal Gfp.thy
- "[| A <= f(lfp(%x.f(x) Un A Un gfp(f))); mono(f) |] ==> \
-\ lfp(%x.f(x) Un A Un gfp(f)) <= f(lfp(%x.f(x) Un A Un gfp(f)))";
+ "[| X <= f(lfp(%x.f(x) Un X Un gfp(f))); mono(f) |] ==> \
+\ lfp(%x.f(x) Un X Un gfp(f)) <= f(lfp(%x.f(x) Un X Un gfp(f)))";
by (rtac subset_trans 1);
by (rtac (mono RS coinduct3_mono_lemma RS lfp_lemma3) 1);
by (rtac (Un_least RS Un_least) 1);
@@ -86,8 +92,8 @@
val coinduct3_lemma = result();
val prems = goal Gfp.thy
- "[| a:A; A <= f(lfp(%x.f(x) Un A Un gfp(f))); mono(f) |] ==> a : gfp(f)";
-by (rtac (coinduct3_lemma RSN (2,coinduct)) 1);
+ "[| mono(f); a:X; X <= f(lfp(%x.f(x) Un X Un gfp(f))) |] ==> a : gfp(f)";
+by (rtac (coinduct3_lemma RSN (2,weak_coinduct)) 1);
by (resolve_tac (prems RL [coinduct3_mono_lemma RS lfp_Tarski RS ssubst]) 1);
by (rtac (UnI2 RS UnI1) 1);
by (REPEAT (resolve_tac prems 1));
@@ -96,25 +102,19 @@
(** Definition forms of gfp_Tarski and coinduct, to control unfolding **)
-val [rew,mono] = goal Gfp.thy "[| h==gfp(f); mono(f) |] ==> h = f(h)";
+val [rew,mono] = goal Gfp.thy "[| A==gfp(f); mono(f) |] ==> A = f(A)";
by (rewtac rew);
by (rtac (mono RS gfp_Tarski) 1);
val def_gfp_Tarski = result();
val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(A) |] ==> a: h";
+ "[| A==gfp(f); mono(f); a:X; X <= f(X Un A) |] ==> a: A";
by (rewtac rew);
-by (REPEAT (ares_tac (prems @ [coinduct]) 1));
+by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct]) 1));
val def_coinduct = result();
val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(A) Un h; mono(f) |] ==> a: h";
-by (rewtac rew);
-by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct2]) 1));
-val def_coinduct2 = result();
-
-val rew::prems = goal Gfp.thy
- "[| h==gfp(f); a:A; A <= f(lfp(%x.f(x) Un A Un h)); mono(f) |] ==> a: h";
+ "[| A==gfp(f); mono(f); a:X; X <= f(lfp(%x.f(x) Un X Un A)) |] ==> a: A";
by (rewtac rew);
by (REPEAT (ares_tac (map (rewrite_rule [rew]) prems @ [coinduct3]) 1));
val def_coinduct3 = result();
--- a/llist.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/llist.ML Wed Sep 22 15:43:05 1993 +0200
@@ -5,7 +5,9 @@
For llist.thy.
-SHOULD LListD_Fun_CONS_I, etc., be equations (for rewriting)
+SHOULD LListD_Fun_CONS_I, etc., be equations (for rewriting)?
+
+TOO LONG! needs splitting up
*)
open LList;
@@ -14,7 +16,8 @@
val llist_simps = [case_Inl, case_Inr];
val llist_ss = univ_ss addsimps llist_simps
- setloop (split_tac [expand_split,expand_case]);
+ addcongs [split_weak_cong, case_weak_cong]
+ setloop (split_tac [expand_split, expand_case]);
(** the llist functional **)
@@ -45,16 +48,10 @@
(*** Type checking by co-induction, using List_Fun ***)
val prems = goalw LList.thy [LList_def]
- "[| M: X; X <= List_Fun(A,X) |] ==> M: LList(A)";
-by (REPEAT (resolve_tac (prems@[coinduct]) 1));
+ "[| M : X; X <= List_Fun(A, X Un LList(A)) |] ==> M : LList(A)";
+by (REPEAT (resolve_tac (prems@[List_Fun_mono RS coinduct]) 1));
val LList_coinduct = result();
-(*stronger version*)
-val prems = goalw LList.thy [LList_def]
- "[| M : X; X <= List_Fun(A, X) Un LList(A) |] ==> M : LList(A)";
-by (REPEAT (resolve_tac (prems@[coinduct2,List_Fun_mono]) 1));
-val LList_coinduct2 = result();
-
(** Rules to prove the 2nd premise of LList_coinduct **)
goalw LList.thy [List_Fun_def,NIL_def] "NIL: List_Fun(A,X)";
@@ -66,19 +63,25 @@
by (REPEAT (ares_tac [uprodI RS usum_In1I] 1));
val List_Fun_CONS_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goalw LList.thy [LList_def]
+ "!!M N. M: LList(A) ==> M : List_Fun(A, X Un LList(A))";
+by (etac (List_Fun_mono RS gfp_fun_UnI2) 1);
+val List_Fun_LList_I = result();
+
(*** LList_corec satisfies the desired recurion equation ***)
(*A continuity result?*)
goalw LList.thy [CONS_def] "CONS(M, UN x.f(x)) = (UN x. CONS(M, f(x)))";
-by(simp_tac (univ_ss addsimps [In1_UN1, Scons_UN1_y]) 1);
+by (simp_tac (univ_ss addsimps [In1_UN1, Scons_UN1_y]) 1);
val CONS_UN1 = result();
goal Prod.thy "split(p, %x y.UN z.f(x,y,z)) = (UN z. split(p, %x y.f(x,y,z)))";
-by(simp_tac (pair_ss setloop (split_tac [expand_split])) 1);
+by (simp_tac (pair_ss setloop (split_tac [expand_split])) 1);
val split_UN1 = result();
goal Sum.thy "case(s, f, %y. UN z.g(y,z)) = (UN z. case(s, f, %y. g(y,z)))";
-by(simp_tac (sum_ss setloop (split_tac [expand_case])) 1);
+by (simp_tac (sum_ss setloop (split_tac [expand_case])) 1);
val case2_UN1 = result();
val prems = goalw LList.thy [CONS_def]
@@ -97,7 +100,7 @@
\ %v. split(v, %z w. CONS(z, LList_corec(w,f))))";
by (rtac UN1_least 1);
by (nat_ind_tac "k" 1);
-by(ALLGOALS(simp_tac corec_fun_ss));
+by (ALLGOALS(simp_tac corec_fun_ss));
by (REPEAT (resolve_tac [allI, impI, subset_refl RS CONS_mono, UN1_upper] 1));
val LList_corec_subset1 = result();
@@ -133,8 +136,8 @@
by (rtac rangeI 1);
by (safe_tac set_cs);
by (stac LList_corec 1);
-by(simp_tac (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
- CollectI, range_eqI]) 1);
+by (simp_tac (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
+ CollectI, range_eqI]) 1);
(* 6.7 vs 3.4 !!!
by (ASM_SIMP_TAC (llist_ss addsimps [List_Fun_NIL_I,List_Fun_CONS_I,
CollectI, rangeI]) 1);
@@ -151,8 +154,8 @@
by (stac LList_corec 1);
(*nested "case"; requires an explicit split*)
by (res_inst_tac [("s", "f(xa)")] sumE 1);
-by(asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_NIL_I])) 1);
-by(asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_CONS_I, range_eqI])
+by (asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_NIL_I])) 1);
+by (asm_simp_tac (univ_ss addsimps (llist_simps@[List_Fun_CONS_I, range_eqI])
setloop (split_tac [expand_split])) 1);
(* FIXME: can the selection of the case split be automated?
by (ASM_SIMP_TAC (llist_ss addsimps [List_Fun_CONS_I, rangeI]) 1);*)
@@ -162,10 +165,10 @@
goalw LList.thy [LListD_Fun_def] "mono(LListD_Fun(r))";
by (REPEAT (ares_tac [monoI, subset_refl, dsum_mono, dprod_mono] 1));
-val LListD_fun_mono = result();
+val LListD_Fun_mono = result();
val LListD_unfold = rewrite_rule [LListD_Fun_def]
- (LListD_fun_mono RS (LListD_def RS def_gfp_Tarski));
+ (LListD_Fun_mono RS (LListD_def RS def_gfp_Tarski));
goal LList.thy "!M N. <M,N> : LListD(diag(A)) --> ntrunc(k,M) = ntrunc(k,N)";
by (res_inst_tac [("n", "k")] less_induct 1);
@@ -173,16 +176,16 @@
by (etac (LListD_unfold RS equalityD1 RS subsetD RS dsumE) 1);
by (safe_tac (set_cs addSEs [Pair_inject, dprodE, diagE]));
by (res_inst_tac [("n", "n")] natE 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_0]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_0]) 1);
by (res_inst_tac [("n", "xb")] natE 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_one_In1]) 1);
-by(asm_simp_tac (univ_ss addsimps [ntrunc_In1, ntrunc_Scons]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_one_In1]) 1);
+by (asm_simp_tac (univ_ss addsimps [ntrunc_In1, ntrunc_Scons]) 1);
val LListD_implies_ntrunc_equality = result();
goalw LList.thy [LList_def,List_Fun_def] "fst``LListD(diag(A)) <= LList(A)";
by (rtac gfp_upperbound 1);
by (res_inst_tac [("P", "%x. fst``x <= ?B")] (LListD_unfold RS ssubst) 1);
-by(simp_tac fst_image_ss 1);
+by (simp_tac fst_image_ss 1);
val fst_image_LListD = result();
(*This inclusion justifies the use of coinduction to show M=N*)
@@ -215,27 +218,19 @@
diag_subset_LListD] 1));
val LListD_eq_diag = result();
-(** To show two LLists are equal, exhibit a bisimulation! **)
-(* Replace "A" by some particular set, like {x.True}??? *)
-val prems = goal LList.thy
- "[| <M,N> : r; r <= LListD_Fun(diag(A), r) |] ==> M=N";
+(** To show two LLists are equal, exhibit a bisimulation!
+ [also admits true equality]
+ Replace "A" by some particular set, like {x.True}??? *)
+goal LList.thy
+ "!!r. [| <M,N> : r; r <= LListD_Fun(diag(A), r Un diag(LList(A))) \
+\ |] ==> M=N";
by (rtac (rewrite_rule [LListD_def]
(LListD_subset_diag RS subsetD RS diagE)) 1);
-by (REPEAT (resolve_tac (prems@[coinduct]) 1));
+by (etac (LListD_Fun_mono RS coinduct) 1);
+by (etac (rewrite_rule [LListD_def] LListD_eq_diag RS ssubst) 1);
by (safe_tac (set_cs addSEs [Pair_inject]));
val LList_equalityI = result();
-(*Stronger notion of bisimulation -- also admits true equality*)
-val prems = goal LList.thy
- "[| <M,N> : r; r <= LListD_Fun(diag(A), r) Un diag(LList(A)) |] ==> M=N";
-by (rtac (rewrite_rule [LListD_def]
- (LListD_subset_diag RS subsetD RS diagE)) 1);
-by (rtac coinduct2 1);
-by (stac (rewrite_rule [LListD_def] LListD_eq_diag) 2);
-by (REPEAT (resolve_tac (prems@[LListD_fun_mono]) 1));
-by (safe_tac (set_cs addSEs [Pair_inject]));
-val LList_equalityI2 = result();
-
(** Rules to prove the 2nd premise of LList_equalityI **)
goalw LList.thy [LListD_Fun_def,NIL_def] "<NIL,NIL> : LListD_Fun(r,s)";
@@ -248,6 +243,15 @@
by (REPEAT (resolve_tac (diagI::prems) 1));
val LListD_Fun_CONS_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goal LList.thy
+ "!!M N. M: LList(A) ==> <M,M> : LListD_Fun(diag(A), X Un diag(LList(A)))";
+br (rewrite_rule [LListD_def] LListD_eq_diag RS subst) 1;
+br (LListD_Fun_mono RS gfp_fun_UnI2) 1;
+br (rewrite_rule [LListD_def] LListD_eq_diag RS ssubst) 1;
+be diagI 1;
+val LListD_Fun_diag_I = result();
+
(*** Finality of LList(A): Uniqueness of functions defined by corecursion ***)
@@ -264,8 +268,8 @@
by (safe_tac set_cs);
by (stac prem1 1);
by (stac prem2 1);
-by(simp_tac (llist_ss addsimps [LListD_Fun_NIL_I, range_eqI,
- CollectI RS LListD_Fun_CONS_I]) 1);
+by (simp_tac (llist_ss addsimps [LListD_Fun_NIL_I, range_eqI,
+ CollectI RS LListD_Fun_CONS_I]) 1);
(* 9.5 vs 9.2/4.1/4.3
by (ASM_SIMP_TAC (llist_ss addsimps [LListD_Fun_NIL_I, rangeI,
CollectI RS LListD_Fun_CONS_I]) 1);*)
@@ -286,7 +290,7 @@
goalw LList.thy [CONS_def]
"ntrunc(Suc(Suc(k)), CONS(M,N)) = CONS (ntrunc(k,M), ntrunc(k,N))";
-by(simp_tac (HOL_ss addsimps [ntrunc_Scons,ntrunc_In1]) 1);
+by (simp_tac (HOL_ss addsimps [ntrunc_Scons,ntrunc_In1]) 1);
val ntrunc_CONS = result();
val [prem1,prem2] = goal LList.thy
@@ -299,11 +303,11 @@
by (rtac allI 1);
by (stac prem1 1);
by (stac prem2 1);
-by(simp_tac (sum_ss setloop (split_tac [expand_split,expand_case])) 1);
+by (simp_tac (sum_ss setloop (split_tac [expand_split,expand_case])) 1);
by (strip_tac 1);
by (res_inst_tac [("n", "n")] natE 1);
by (res_inst_tac [("n", "xc")] natE 2);
-by(ALLGOALS(asm_simp_tac(nat_ss addsimps
+by (ALLGOALS(asm_simp_tac(nat_ss addsimps
[ntrunc_0,ntrunc_one_CONS,ntrunc_CONS])));
val LList_corec_unique = result();
@@ -323,19 +327,19 @@
by (rtac (singletonI RS LList_coinduct) 1);
by (safe_tac set_cs);
by (res_inst_tac [("P", "%u. u: ?A")] (Lconst RS ssubst) 1);
-by (REPEAT (ares_tac [List_Fun_CONS_I, singletonI] 1));
+by (REPEAT (ares_tac [List_Fun_CONS_I, singletonI, UnI1] 1));
val Lconst_type = result();
goal LList.thy "Lconst(M) = LList_corec(M, %x.Inr(<x,x>))";
by (rtac (equals_LList_corec RS fun_cong) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
by (rtac Lconst 1);
val Lconst_eq_LList_corec = result();
(*Thus we could have used gfp in the definition of Lconst*)
goal LList.thy "gfp(%N. CONS(M, N)) = LList_corec(M, %x.Inr(<x,x>))";
by (rtac (equals_LList_corec RS fun_cong) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
by (rtac (Lconst_fun_mono RS gfp_Tarski) 1);
val gfp_Lconst_eq_LList_corec = result();
@@ -431,10 +435,10 @@
\ f(NIL)=g(NIL); \
\ !!x l. [| x:A; l: LList(A) |] ==> \
\ <f(CONS(x,l)),g(CONS(x,l))> : \
-\ LListD_Fun(diag(A), (%u.<f(u),g(u)>)``LList(A)) Un \
-\ diag(LList(A)) \
+\ LListD_Fun(diag(A), (%u.<f(u),g(u)>)``LList(A) Un \
+\ diag(LList(A))) \
\ |] ==> f(M) = g(M)";
-by (rtac LList_equalityI2 1);
+by (rtac LList_equalityI 1);
br (MList RS imageI) 1;
by (rtac subsetI 1);
by (etac imageE 1);
@@ -442,7 +446,7 @@
by (etac LListE 1);
by (etac ssubst 1);
by (stac NILcase 1);
-br (gMList RS diagI RS UnI2) 1;
+br (gMList RS LListD_Fun_diag_I) 1;
by (etac ssubst 1);
by (REPEAT (ares_tac [CONScase] 1));
val LList_fun_equalityI = result();
@@ -452,12 +456,12 @@
goal LList.thy "Lmap(f,NIL) = NIL";
by (rtac (Lmap_def RS def_LList_corec RS trans) 1);
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
val Lmap_NIL = result();
goal LList.thy "Lmap(f, CONS(M,N)) = CONS(f(M), Lmap(f,N))";
by (rtac (Lmap_def RS def_LList_corec RS trans) 1);
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
val Lmap_CONS = result();
(*Another type-checking proof by coinduction*)
@@ -466,8 +470,9 @@
by (rtac (major RS imageI RS LList_coinduct) 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [List_Fun_NIL_I, List_Fun_CONS_I, minor, imageI] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [List_Fun_NIL_I, List_Fun_CONS_I,
+ minor, imageI, UnI1] 1));
val Lmap_type = result();
(*This type checking rule synthesises a sufficiently large set for f*)
@@ -484,18 +489,18 @@
by (stac o_def 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI,
- rangeI RS LListD_Fun_CONS_I] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI, UnI1,
+ rangeI RS LListD_Fun_CONS_I] 1));
val Lmap_compose = result();
val [prem] = goal LList.thy "M: LList(A) ==> Lmap(%x.x, M) = M";
by (rtac (prem RS imageI RS LList_equalityI) 1);
by (safe_tac set_cs);
by (etac LListE 1);
-by(ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
-by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI,
- rangeI RS LListD_Fun_CONS_I] 1));
+by (ALLGOALS (asm_simp_tac (HOL_ss addsimps [Lmap_NIL,Lmap_CONS])));
+by (REPEAT (ares_tac [LListD_Fun_NIL_I, imageI RS UnI1,
+ rangeI RS LListD_Fun_CONS_I] 1));
val Lmap_ident = result();
@@ -504,7 +509,7 @@
goalw LList.thy [Lappend_def] "Lappend(NIL,NIL) = NIL";
by (rtac (LList_corec RS trans) 1);
(* takes 2.4(3.4 w NORM) vs 0.9 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_NIL_NIL = result();
@@ -512,7 +517,7 @@
"Lappend(NIL,CONS(N,N')) = CONS(N, Lappend(NIL,N'))";
by (rtac (LList_corec RS trans) 1);
(* takes 5(7 w NORM) vs 2.1 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_NIL_CONS = result();
@@ -520,7 +525,7 @@
"Lappend(CONS(M,M'), N) = CONS(M, Lappend(M',N))";
by (rtac (LList_corec RS trans) 1);
(* takes 4.9(6.7) vs 2.2 w/o NORM terms *)
-by(simp_tac List_case_ss 1);
+by (simp_tac List_case_ss 1);
(*by (SIMP_TAC List_case_ss 1);*)
val Lappend_CONS = result();
@@ -563,12 +568,12 @@
(*strong co-induction: bisimulation and case analysis on one variable*)
goal LList.thy
"!!M N. [| M: LList(A); N: LList(A) |] ==> Lappend(M,N): LList(A)";
-by (res_inst_tac [("X", "(%u.Lappend(u,N))``LList(A)")] LList_coinduct2 1);
-fe imageI;
+by (res_inst_tac [("X", "(%u.Lappend(u,N))``LList(A)")] LList_coinduct 1);
+be imageI 1;
br subsetI 1;
be imageE 1;
by (eres_inst_tac [("L", "u")] LListE 1);
-by (asm_simp_tac (Lappend_ss addsimps [Lappend_NIL]) 1);
+by (asm_simp_tac (Lappend_ss addsimps [Lappend_NIL, List_Fun_LList_I]) 1);
by (asm_simp_tac Lappend_ss 1);
by (fast_tac (set_cs addSIs [List_Fun_CONS_I]) 1);
val Lappend_type = result();
@@ -584,12 +589,12 @@
val Rep_LList_ss = llist_ss addsimps Rep_LList_simps;
goalw LList.thy [llist_case_def,LNil_def] "llist_case(LNil, c, d) = c";
-by(simp_tac Rep_LList_ss 1);
+by (simp_tac Rep_LList_ss 1);
val llist_case_LNil = result();
goalw LList.thy [llist_case_def,LCons_def]
"llist_case(LCons(M,N), c, d) = d(M,N)";
-by(simp_tac Rep_LList_ss 1);
+by (simp_tac Rep_LList_ss 1);
val llist_case_LCons = result();
(*Elimination is case analysis, not induction.*)
@@ -602,7 +607,7 @@
by (assume_tac 1);
by (etac rangeE 1);
by (rtac (inj_Rep_LList RS injD RS prem2) 1);
-by(asm_simp_tac (HOL_ss addsimps [Rep_LList_LCons]) 1);
+by (asm_simp_tac (HOL_ss addsimps [Rep_LList_LCons]) 1);
by (etac (Abs_LList_inverse RS ssubst) 1);
by (rtac refl 1);
val llistE = result();
@@ -613,12 +618,12 @@
"llist_corec(a,f) = case(f(a), %u. LNil, \
\ %v. split(v, %z w. LCons(z, llist_corec(w,f))))";
by (stac LList_corec 1);
-by(res_inst_tac [("s","f(a)")] sumE 1);
-by(asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
-by(res_inst_tac [("p","y")] PairE 1);
-by(asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
+by (res_inst_tac [("s","f(a)")] sumE 1);
+by (asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
+by (res_inst_tac [("p","y")] PairE 1);
+by (asm_simp_tac (llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);
(*FIXME: correct case splits usd to be found automatically:
-by(ASM_SIMP_TAC(llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);*)
+by (ASM_SIMP_TAC(llist_ss addsimps [LList_corec_type2,Abs_LList_inverse]) 1);*)
val llist_corec = result();
(*definitional version of same*)
@@ -653,44 +658,38 @@
by (safe_tac (set_cs addSEs [prod_fun_imageE]));
by (rtac (prem RS subsetD RS SigmaE2) 1);
by (assume_tac 1);
-by(asm_simp_tac (HOL_ss addsimps [o_def,prod_fun,Abs_LList_inverse]) 1);
+by (asm_simp_tac (HOL_ss addsimps [o_def,prod_fun,Abs_LList_inverse]) 1);
val prod_fun_lemma = result();
-(** To show two llists are equal, exhibit a bisimulation! **)
+goal LList.thy
+ "prod_fun(Rep_LList, Rep_LList) `` range(%x. <x, x>) = \
+\ diag(LList(range(Leaf)))";
+br equalityI 1;
+by (fast_tac (set_cs addIs [diagI, Rep_LList]
+ addSEs [prod_fun_imageE, Pair_inject]) 1);
+by (fast_tac (set_cs addIs [prod_fun_imageI, rangeI]
+ addSEs [diagE, Abs_LList_inverse RS subst]) 1);
+val prod_fun_range_eq_diag = result();
+
+(** To show two llists are equal, exhibit a bisimulation!
+ [also admits true equality] **)
val [prem1,prem2] = goalw LList.thy [llistD_Fun_def]
- "[| <l1,l2> : r; r <= llistD_Fun(r) |] ==> l1=l2";
+ "[| <l1,l2> : r; r <= llistD_Fun(r Un range(%x.<x,x>)) |] ==> l1=l2";
by (rtac (inj_Rep_LList RS injD) 1);
-by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r")]
+by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r"),
+ ("A", "range(Leaf)")]
LList_equalityI 1);
by (rtac (prem1 RS prod_fun_imageI) 1);
by (rtac (prem2 RS image_mono RS subset_trans) 1);
by (rtac (image_compose RS subst) 1);
by (rtac (prod_fun_compose RS subst) 1);
-by (rtac (subset_Sigma_LList RS LListD_Fun_subset_Sigma_LList RS
- prod_fun_lemma) 1);
+by (rtac (image_Un RS ssubst) 1);
+by (stac prod_fun_range_eq_diag 1);
+by (rtac (LListD_Fun_subset_Sigma_LList RS prod_fun_lemma) 1);
+by (rtac (subset_Sigma_LList RS Un_least) 1);
+by (rtac diag_subset_Sigma 1);
val llist_equalityI = result();
-
-(*Stronger notion of bisimulation -- also admits true equality*)
-val [prem1,prem2] = goalw LList.thy [llistD_Fun_def]
- "[| <l1,l2> : r; r <= llistD_Fun(r) Un range(%x.<x,x>) |] ==> l1=l2";
-by (rtac (inj_Rep_LList RS injD) 1);
-by (res_inst_tac [("r", "prod_fun(Rep_LList,Rep_LList)``r"),
- ("A", "range(Leaf)")]
- LList_equalityI2 1);
-by (rtac (prem1 RS prod_fun_imageI) 1);
-by (rtac (prem2 RS image_mono RS subset_trans) 1);
-by (rtac (image_Un RS ssubst) 1);
-by (rtac Un_least 1);
-by (rtac (image_compose RS subst) 1);
-by (rtac (prod_fun_compose RS subst) 1);
-by (rtac (subset_Sigma_LList RS LListD_Fun_subset_Sigma_LList RS
- prod_fun_lemma RS subset_trans) 1);
-by (rtac Un_upper1 1);
-by (fast_tac (set_cs addSEs [prod_fun_imageE, Pair_inject]
- addIs [diagI,Rep_LList]) 1);
-val llist_equalityI2 = result();
-
(** Rules to prove the 2nd premise of llist_equalityI **)
goalw LList.thy [llistD_Fun_def,LNil_def] "<LNil,LNil> : llistD_Fun(r)";
by (rtac (LListD_Fun_NIL_I RS prod_fun_imageI) 1);
@@ -702,14 +701,23 @@
by (rtac (prem RS prod_fun_imageI) 1);
val llistD_Fun_LCons_I = result();
+(*Utilise the "strong" part, i.e. gfp(f)*)
+goalw LList.thy [llistD_Fun_def]
+ "!!l. <l,l> : llistD_Fun(r Un range(%x.<x,x>))";
+br (Rep_LList_inverse RS subst) 1;
+br prod_fun_imageI 1;
+by (rtac (image_Un RS ssubst) 1);
+by (stac prod_fun_range_eq_diag 1);
+br (Rep_LList RS LListD_Fun_diag_I) 1;
+val llistD_Fun_range_I = result();
(*A special case of list_equality for functions over lazy lists*)
val [prem1,prem2] = goal LList.thy
"[| f(LNil)=g(LNil); \
\ !!x l. <f(LCons(x,l)),g(LCons(x,l))> : \
-\ llistD_Fun(range(%u. <f(u),g(u)>)) Un range(%v. <v,v>) \
+\ llistD_Fun(range(%u. <f(u),g(u)>) Un range(%v. <v,v>)) \
\ |] ==> f(l) = g(l :: 'a llist) :: 'b llist";
-by (res_inst_tac [("r", "range(%u. <f(u),g(u)>)")] llist_equalityI2 1);
+by (res_inst_tac [("r", "range(%u. <f(u),g(u)>)")] llist_equalityI 1);
by (rtac rangeI 1);
by (rtac subsetI 1);
by (etac rangeE 1);
@@ -717,7 +725,7 @@
by (res_inst_tac [("l", "u")] llistE 1);
by (etac ssubst 1);
by (stac prem1 1);
-by (fast_tac set_cs 1);
+by (rtac llistD_Fun_range_I 1);
by (etac ssubst 1);
by (rtac prem2 1);
val llist_fun_equalityI = result();
@@ -732,12 +740,12 @@
goal LList.thy "lmap(f,LNil) = LNil";
by (rtac (lmap_def RS def_llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lmap_LNil = result();
goal LList.thy "lmap(f, LCons(M,N)) = LCons(f(M), lmap(f,N))";
by (rtac (lmap_def RS def_llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lmap_LCons = result();
@@ -758,7 +766,7 @@
goal LList.thy "iterates(f,x) = LCons(x, iterates(f,f(x)))";
by (rtac (iterates_def RS def_llist_corec RS trans) 1);
-by(simp_tac sum_ss 1);
+by (simp_tac sum_ss 1);
val iterates = result();
goal LList.thy "lmap(f, iterates(f,x)) = iterates(f,f(x))";
@@ -784,12 +792,12 @@
"nat_rec(n, LCons(b, l), %m. lmap(f)) = \
\ LCons(nat_rec(n, b, %m. f), nat_rec(n, l, %m. lmap(f)))";
by (nat_ind_tac "n" 1);
-by(ALLGOALS (asm_simp_tac (nat_ss addsimps [lmap_LCons])));
+by (ALLGOALS (asm_simp_tac (nat_ss addsimps [lmap_LCons])));
val fun_power_lmap = result();
goal Nat.thy "nat_rec(n, g(x), %m. g) = nat_rec(Suc(n), x, %m. g)";
by (nat_ind_tac "n" 1);
-by(ALLGOALS (asm_simp_tac nat_ss));
+by (ALLGOALS (asm_simp_tac nat_ss));
val fun_power_Suc = result();
val Pair_cong = read_instantiate_sg (sign_of Prod.thy)
@@ -814,7 +822,7 @@
by (rtac (lmap_iterates RS subst) 1);
by (stac fun_power_Suc 1);
by (stac fun_power_Suc 1);
-br UN1_I 1;
+br (UN1_I RS UnI1) 1;
br rangeI 1;
val iterates_equality = result();
@@ -823,20 +831,20 @@
goalw LList.thy [lappend_def] "lappend(LNil,LNil) = LNil";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
val lappend_LNil_LNil = result();
goalw LList.thy [lappend_def]
"lappend(LNil,LCons(l,l')) = LCons(l, lappend(LNil,l'))";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
(* 3.3(5.7) vs 1.3 !by (SIMP_TAC llistD_ss 1);*)
val lappend_LNil_LCons = result();
goalw LList.thy [lappend_def]
"lappend(LCons(l,l'), N) = LCons(l, lappend(l',N))";
by (rtac (llist_corec RS trans) 1);
-by(simp_tac llistD_ss 1);
+by (simp_tac llistD_ss 1);
(* 5(5.5) vs 1.3 !by (SIMP_TAC llistD_ss 1);*)
val lappend_LCons = result();
@@ -877,21 +885,21 @@
by (ALLGOALS (asm_simp_tac (llistD_ss addsimps
[lappend_LNil_LNil,lappend_LCons,lappend_LNil_LCons,
lmap_LNil,lmap_LCons])));
-by (REPEAT_SOME (ares_tac [llistD_Fun_LCons_I, UN1_I, rangeI]));
+by (REPEAT_SOME (ares_tac [llistD_Fun_LCons_I, UN1_I RS UnI1, rangeI]));
by (rtac range_eqI 1);
by (rtac (refl RS Pair_cong) 1);
by (stac lmap_LNil 1);
by (rtac refl 1);
val lmap_lappend_distrib = result();
-(*Shorter proof of the theorem above using llist_equalityI2*)
+(*Shorter proof of theorem above using llist_equalityI as strong coinduction*)
goal LList.thy "lmap(f, lappend(l,n)) = lappend(lmap(f,l), lmap(f,n))";
by (res_inst_tac [("l","l")] llist_fun_equalityI 1);
by (simp_tac (llistD_ss addsimps [lappend_LNil, lmap_LNil])1);
by (simp_tac (llistD_ss addsimps [lappend_LCons, lmap_LCons]) 1);
val lmap_lappend_distrib = result();
-(*Without llist_equalityI2, three case analyses might be needed*)
+(*Without strong coinduction, three case analyses might be needed*)
goal LList.thy "lappend(lappend(l1,l2) ,l3) = lappend(l1, lappend(l2,l3))";
by (res_inst_tac [("l","l1")] llist_fun_equalityI 1);
by (simp_tac (llistD_ss addsimps [lappend_LNil])1);
--- a/nat.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/nat.ML Wed Sep 22 15:43:05 1993 +0200
@@ -351,6 +351,15 @@
val nat_ss = pair_ss addsimps nat_simps;
+(*Prevents simplification of f and g: much faster*)
+val nat_case_weak_cong = prove_goal Nat.thy
+ "m=n ==> nat_case(m,a,f) = nat_case(n,a,f)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
+val nat_rec_weak_cong = prove_goal Nat.thy
+ "m=n ==> nat_rec(m,a,f) = nat_rec(n,a,f)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
val prems = goalw Nat.thy [le_def] "~(n<m) ==> m<=n::nat";
by (resolve_tac prems 1);
val leI = result();
--- a/prod.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/prod.ML Wed Sep 22 15:43:05 1993 +0200
@@ -58,17 +58,21 @@
by (rtac refl 1);
val split = result();
-(*FIXME: split's congruence rule should only simplifies the pair*)
val pair_ss = set_ss addsimps [fst_conv, snd_conv, split];
+(*Prevents simplification of c: much faster*)
+val split_weak_cong = prove_goal Prod.thy
+ "p=q ==> split(p,c) = split(q,c)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);
+
goal Prod.thy "p = <fst(p),snd(p)>";
by (res_inst_tac [("p","p")] PairE 1);
-by(asm_simp_tac pair_ss 1);
+by (asm_simp_tac pair_ss 1);
val surjective_pairing = result();
goal Prod.thy "p = split(p, %x y.<x,y>)";
by (res_inst_tac [("p","p")] PairE 1);
-by(asm_simp_tac pair_ss 1);
+by (asm_simp_tac pair_ss 1);
val surjective_pairing2 = result();
(** split used as a logical connective, with result type bool **)
@@ -99,13 +103,13 @@
"prod_fun(f1 o f2, g1 o g2) = (prod_fun(f1,g1) o prod_fun(f2,g2))";
by (rtac ext 1);
by (res_inst_tac [("p","x")] PairE 1);
-by(asm_simp_tac (pair_ss addsimps [prod_fun,o_def]) 1);
+by (asm_simp_tac (pair_ss addsimps [prod_fun,o_def]) 1);
val prod_fun_compose = result();
goal Prod.thy "prod_fun(%x.x, %y.y) = (%z.z)";
by (rtac ext 1);
by (res_inst_tac [("p","z")] PairE 1);
-by(asm_simp_tac (pair_ss addsimps [prod_fun]) 1);
+by (asm_simp_tac (pair_ss addsimps [prod_fun]) 1);
val prod_fun_ident = result();
val prems = goal Prod.thy "<a,b>:r ==> <f(a),g(b)> : prod_fun(f,g)``r";
--- a/sum.ML Thu Sep 16 14:29:14 1993 +0200
+++ b/sum.ML Wed Sep 22 15:43:05 1993 +0200
@@ -126,5 +126,9 @@
by (fast_tac (set_cs addSEs [make_elim Inr_inject, Inr_neq_Inl]) 1);
val expand_case = result();
-(*FIXME: case's congruence rule only should simplifies the first argument*)
val sum_ss = pair_ss addsimps [case_Inl, case_Inr];
+
+(*Prevents simplification of f and g: much faster*)
+val case_weak_cong = prove_goal Sum.thy
+ "s=t ==> case(s,f,g) = case(t,f,g)"
+ (fn [prem] => [rtac (prem RS arg_cong) 1]);