Minor changes; addition of counit.ML
authorlcp
Mon, 08 Nov 1993 17:52:24 +0100
changeset 95 2246a80b1cb5
parent 94 40f292719398
child 96 91e8875e9c45
Minor changes; addition of counit.ML
src/ZF/ex/Acc.ML
src/ZF/ex/LList_Eq.ML
src/ZF/ex/ROOT.ML
src/ZF/ex/acc.ML
src/ZF/ex/counit.ML
src/ZF/ex/llist_eq.ML
--- a/src/ZF/ex/Acc.ML	Fri Nov 05 18:49:22 1993 +0100
+++ b/src/ZF/ex/Acc.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -13,7 +13,7 @@
  (val thy = WF.thy addconsts [(["acc"],"i=>i")];
   val rec_doms = [("acc", "field(r)")];
   val sintrs = 
-      ["[| r-``{b} : Pow(acc(r));  b : field(r) |] ==> b : acc(r)"];
+      ["[| r-``{a} : Pow(acc(r));  a : field(r) |] ==> a : acc(r)"];
   val monos = [Pow_mono];
   val con_defs = [];
   val type_intrs = [];
--- a/src/ZF/ex/LList_Eq.ML	Fri Nov 05 18:49:22 1993 +0100
+++ b/src/ZF/ex/LList_Eq.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -30,6 +30,8 @@
 		QPair_Int_Vset_succ_subset_trans,
 		QPair_Int_Vset_subset_trans];
 
+(** Some key feature of this proof needs to be made a general theorem! **)
+
 (*Keep unfolding the lazy list until the induction hypothesis applies*)
 goal LList_Eq.thy
    "!!i. Ord(i) ==> ALL l l'. <l;l'> : lleq(A) --> l Int Vset(i) <= l'";
--- a/src/ZF/ex/ROOT.ML	Fri Nov 05 18:49:22 1993 +0100
+++ b/src/ZF/ex/ROOT.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -55,6 +55,6 @@
 time_use_thy "ex/LList";
 time_use     "ex/llist_eq.ML";
 time_use_thy "ex/llistfn";
-
+time_use     "ex/counit.ML";
 
 maketest"END: Root file for ZF Set Theory examples";
--- a/src/ZF/ex/acc.ML	Fri Nov 05 18:49:22 1993 +0100
+++ b/src/ZF/ex/acc.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -13,7 +13,7 @@
  (val thy = WF.thy addconsts [(["acc"],"i=>i")];
   val rec_doms = [("acc", "field(r)")];
   val sintrs = 
-      ["[| r-``{b} : Pow(acc(r));  b : field(r) |] ==> b : acc(r)"];
+      ["[| r-``{a} : Pow(acc(r));  a : field(r) |] ==> a : acc(r)"];
   val monos = [Pow_mono];
   val con_defs = [];
   val type_intrs = [];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ZF/ex/counit.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -0,0 +1,122 @@
+(*  Title: 	ZF/ex/counit.ML
+    ID:         $Id$
+    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
+    Copyright   1993  University of Cambridge
+
+Trivial co-datatype definitions, one of which goes wrong!
+
+Need to find sufficient conditions for co-datatypes to work correctly!
+*)
+
+(*This degenerate definition does not work well because the one constructor's
+  definition is trivial!
+*)
+structure CoUnit = Co_Datatype_Fun
+ (val thy = QUniv.thy;
+  val rec_specs = 
+      [("counit", "quniv(0)",
+	  [(["Con"],	"i=>i")])];
+  val rec_styp = "i";
+  val ext = None
+  val sintrs = ["x: counit ==> Con(x) : counit"];
+  val monos = [];
+  val type_intrs = co_datatype_intrs
+  val type_elims = co_datatype_elims);
+  
+val [ConI] = CoUnit.intrs;
+
+(*USELESS because folding on Con(?xa) == ?xa fails*)
+val ConE = CoUnit.mk_cases CoUnit.con_defs "Con(x) : counit";
+
+(*Proving freeness results*)
+val Con_iff = CoUnit.mk_free "Con(x)=Con(y) <-> x=y";
+
+(*Should be a singleton, not everything!*)
+goal CoUnit.thy "counit = quniv(0)";
+by (rtac (CoUnit.dom_subset RS equalityI) 1);
+by (rtac subsetI 1);
+by (etac CoUnit.co_induct 1);
+by (rtac subset_refl 1);
+by (rewrite_goals_tac CoUnit.con_defs);
+by (fast_tac ZF_cs 1);
+val counit_eq_univ = result();
+
+
+(*****************************************************************)
+
+(*A similar example, but the constructor is non-degenerate and it works!
+  The resulting set is a singleton.
+*)
+
+structure CoUnit2 = Co_Datatype_Fun
+ (val thy = QUniv.thy;
+  val rec_specs = 
+      [("counit2", "quniv(0)",
+	  [(["Con2"],	"[i,i]=>i")])];
+  val rec_styp = "i";
+  val ext = None
+  val sintrs = ["[| x: counit2;  y: counit2 |] ==> Con2(x,y) : counit2"];
+  val monos = [];
+  val type_intrs = co_datatype_intrs
+  val type_elims = co_datatype_elims);
+
+val [Con2I] = CoUnit2.intrs;
+
+val Con2E = CoUnit2.mk_cases CoUnit2.con_defs "Con2(x,y) : counit2";
+
+(*Proving freeness results*)
+val Con2_iff = CoUnit2.mk_free "Con2(x,y)=Con2(x',y') <-> x=x' & y=y'";
+
+goalw CoUnit2.thy CoUnit2.con_defs "bnd_mono(univ(0), %x. Con2(x,x))";
+by (rtac bnd_monoI 1);
+by (REPEAT (ares_tac [subset_refl, QPair_subset_univ, QPair_mono] 1));
+val Con2_bnd_mono = result();
+
+goal CoUnit2.thy "lfp(univ(0), %x. Con2(x,x)) : counit2";
+by (rtac (singletonI RS CoUnit2.co_induct) 1);
+by (rtac (qunivI RS singleton_subsetI) 1);
+by (rtac ([lfp_subset, empty_subsetI RS univ_mono] MRS subset_trans) 1);
+by (fast_tac (ZF_cs addSIs [Con2_bnd_mono RS lfp_Tarski]) 1);
+val lfp_Con2_in_counit2 = result();
+
+(*borrowed from ex/llist_eq.ML! the proofs are almost identical!*)
+val lleq_cs = subset_cs
+	addSIs [succI1, Int_Vset_0_subset,
+		QPair_Int_Vset_succ_subset_trans,
+		QPair_Int_Vset_subset_trans];
+
+goal CoUnit2.thy
+    "!!i. Ord(i) ==> ALL x y. x: counit2 & y: counit2 --> x Int Vset(i) <= y";
+by (etac trans_induct 1);
+by (safe_tac subset_cs);
+by (etac CoUnit2.elim 1);
+by (etac CoUnit2.elim 1);
+by (safe_tac subset_cs);
+by (rewrite_goals_tac CoUnit2.con_defs);
+by (etac Ord_cases 1 THEN REPEAT_FIRST hyp_subst_tac);
+(*0 case*)
+by (fast_tac lleq_cs 1);
+(*succ(j) case*)
+by (fast_tac lleq_cs 1);
+(*Limit(i) case*)
+by (etac (Limit_Vfrom_eq RS ssubst) 1);
+by (rtac (Int_UN_distrib RS ssubst) 1);
+by (fast_tac lleq_cs 1);
+val counit2_Int_Vset_subset_lemma = result();
+
+val counit2_Int_Vset_subset = standard
+	(counit2_Int_Vset_subset_lemma RS spec RS spec RS mp);
+
+goal CoUnit2.thy "!!x y. [| x: counit2;  y: counit2 |] ==> x=y";
+by (rtac equalityI 1);
+by (REPEAT (ares_tac [conjI, counit2_Int_Vset_subset RS Int_Vset_subset] 1));
+val counit2_implies_equal = result();
+
+goal CoUnit2.thy "counit2 = {lfp(univ(0), %x. Con2(x,x))}";
+by (rtac equalityI 1);
+by (rtac (lfp_Con2_in_counit2 RS singleton_subsetI) 2);
+by (rtac subsetI 1);
+by (dtac (lfp_Con2_in_counit2 RS counit2_implies_equal) 1);
+by (etac subst 1);
+by (rtac singletonI 1);
+val counit2_eq_univ = result();
--- a/src/ZF/ex/llist_eq.ML	Fri Nov 05 18:49:22 1993 +0100
+++ b/src/ZF/ex/llist_eq.ML	Mon Nov 08 17:52:24 1993 +0100
@@ -30,6 +30,8 @@
 		QPair_Int_Vset_succ_subset_trans,
 		QPair_Int_Vset_subset_trans];
 
+(** Some key feature of this proof needs to be made a general theorem! **)
+
 (*Keep unfolding the lazy list until the induction hypothesis applies*)
 goal LList_Eq.thy
    "!!i. Ord(i) ==> ALL l l'. <l;l'> : lleq(A) --> l Int Vset(i) <= l'";