| author | wenzelm | 
| Mon, 09 Sep 2024 22:04:46 +0200 | |
| changeset 80832 | 2e3e2ec20e87 | 
| parent 76217 | 8655344f1cf6 | 
| permissions | -rw-r--r-- | 
| 35762 | 1 | (* Title: ZF/ex/CoUnit.thy | 
| 1478 | 2 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | 
| 515 | 3 | Copyright 1994 University of Cambridge | 
| 4 | *) | |
| 5 | ||
| 60770 | 6 | section \<open>Trivial codatatype definitions, one of which goes wrong!\<close> | 
| 12228 | 7 | |
| 65449 
c82e63b11b8b
clarified main ZF.thy / ZFC.thy, and avoid name clash with global HOL/Main.thy;
 wenzelm parents: 
61798diff
changeset | 8 | theory CoUnit imports ZF begin | 
| 515 | 9 | |
| 60770 | 10 | text \<open> | 
| 12228 | 11 | See discussion in: L C Paulson. A Concrete Final Coalgebra Theorem | 
| 12 | for ZF Set Theory. Report 334, Cambridge University Computer | |
| 13 | Laboratory. 1994. | |
| 14 | ||
| 15 | \bigskip | |
| 16 | ||
| 17 | This degenerate definition does not work well because the one | |
| 18 | constructor's definition is trivial! The same thing occurs with | |
| 19 | Aczel's Special Final Coalgebra Theorem. | |
| 60770 | 20 | \<close> | 
| 12228 | 21 | |
| 515 | 22 | consts | 
| 1401 | 23 | counit :: i | 
| 515 | 24 | codatatype | 
| 12228 | 25 |   "counit" = Con ("x \<in> counit")
 | 
| 26 | ||
| 27 | inductive_cases ConE: "Con(x) \<in> counit" | |
| 76213 
e44d86131648
Removal of obsolete ASCII syntax
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 28 | \<comment> \<open>USELESS because folding on \<^term>\<open>Con(xa) \<equiv> xa\<close> fails.\<close> | 
| 12228 | 29 | |
| 46822 
95f1e700b712
 mathematical symbols for Isabelle/ZF example theories
 paulson parents: 
42793diff
changeset | 30 | lemma Con_iff: "Con(x) = Con(y) \<longleftrightarrow> x = y" | 
| 61798 | 31 | \<comment> \<open>Proving freeness results.\<close> | 
| 12228 | 32 | by (auto elim!: counit.free_elims) | 
| 33 | ||
| 34 | lemma counit_eq_univ: "counit = quniv(0)" | |
| 61798 | 35 | \<comment> \<open>Should be a singleton, not everything!\<close> | 
| 12228 | 36 | apply (rule counit.dom_subset [THEN equalityI]) | 
| 37 | apply (rule subsetI) | |
| 38 | apply (erule counit.coinduct) | |
| 39 | apply (rule subset_refl) | |
| 76217 | 40 | unfolding counit.con_defs | 
| 12228 | 41 | apply fast | 
| 42 | done | |
| 515 | 43 | |
| 44 | ||
| 60770 | 45 | text \<open> | 
| 12228 | 46 | \medskip A similar example, but the constructor is non-degenerate | 
| 47 | and it works! The resulting set is a singleton. | |
| 60770 | 48 | \<close> | 
| 515 | 49 | |
| 50 | consts | |
| 1401 | 51 | counit2 :: i | 
| 515 | 52 | codatatype | 
| 12228 | 53 |   "counit2" = Con2 ("x \<in> counit2", "y \<in> counit2")
 | 
| 54 | ||
| 55 | ||
| 56 | inductive_cases Con2E: "Con2(x, y) \<in> counit2" | |
| 57 | ||
| 76214 | 58 | lemma Con2_iff: "Con2(x, y) = Con2(x', y') \<longleftrightarrow> x = x' \<and> y = y'" | 
| 61798 | 59 | \<comment> \<open>Proving freeness results.\<close> | 
| 12228 | 60 | by (fast elim!: counit2.free_elims) | 
| 61 | ||
| 76215 
a642599ffdea
More syntactic cleanup. LaTeX markup working
 paulson <lp15@cam.ac.uk> parents: 
76214diff
changeset | 62 | lemma Con2_bnd_mono: "bnd_mono(univ(0), \<lambda>x. Con2(x, x))" | 
| 76217 | 63 | unfolding counit2.con_defs | 
| 12228 | 64 | apply (rule bnd_monoI) | 
| 65 | apply (assumption | rule subset_refl QPair_subset_univ QPair_mono)+ | |
| 66 | done | |
| 67 | ||
| 76215 
a642599ffdea
More syntactic cleanup. LaTeX markup working
 paulson <lp15@cam.ac.uk> parents: 
76214diff
changeset | 68 | lemma lfp_Con2_in_counit2: "lfp(univ(0), \<lambda>x. Con2(x,x)) \<in> counit2" | 
| 12228 | 69 | apply (rule singletonI [THEN counit2.coinduct]) | 
| 70 | apply (rule qunivI [THEN singleton_subsetI]) | |
| 71 | apply (rule subset_trans [OF lfp_subset empty_subsetI [THEN univ_mono]]) | |
| 72 | apply (fast intro!: Con2_bnd_mono [THEN lfp_unfold]) | |
| 73 | done | |
| 74 | ||
| 75 | lemma counit2_Int_Vset_subset [rule_format]: | |
| 76213 
e44d86131648
Removal of obsolete ASCII syntax
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 76 | "Ord(i) \<Longrightarrow> \<forall>x y. x \<in> counit2 \<longrightarrow> y \<in> counit2 \<longrightarrow> x \<inter> Vset(i) \<subseteq> y" | 
| 61798 | 77 | \<comment> \<open>Lemma for proving finality.\<close> | 
| 12228 | 78 | apply (erule trans_induct) | 
| 69593 | 79 | apply (tactic "safe_tac (put_claset subset_cs \<^context>)") | 
| 12228 | 80 | apply (erule counit2.cases) | 
| 81 | apply (erule counit2.cases) | |
| 76217 | 82 | unfolding counit2.con_defs | 
| 69593 | 83 | apply (tactic \<open>fast_tac (put_claset subset_cs \<^context> | 
| 24893 | 84 |     addSIs [@{thm QPair_Int_Vset_subset_UN} RS @{thm subset_trans}, @{thm QPair_mono}]
 | 
| 60770 | 85 |     addSEs [@{thm Ord_in_Ord}, @{thm Pair_inject}]) 1\<close>)
 | 
| 12228 | 86 | done | 
| 87 | ||
| 76213 
e44d86131648
Removal of obsolete ASCII syntax
 paulson <lp15@cam.ac.uk> parents: 
69593diff
changeset | 88 | lemma counit2_implies_equal: "\<lbrakk>x \<in> counit2; y \<in> counit2\<rbrakk> \<Longrightarrow> x = y" | 
| 12228 | 89 | apply (rule equalityI) | 
| 90 | apply (assumption | rule conjI counit2_Int_Vset_subset [THEN Int_Vset_subset])+ | |
| 91 | done | |
| 92 | ||
| 76215 
a642599ffdea
More syntactic cleanup. LaTeX markup working
 paulson <lp15@cam.ac.uk> parents: 
76214diff
changeset | 93 | lemma counit2_eq_univ: "counit2 = {lfp(univ(0), \<lambda>x. Con2(x,x))}"
 | 
| 12228 | 94 | apply (rule equalityI) | 
| 95 | apply (rule_tac [2] lfp_Con2_in_counit2 [THEN singleton_subsetI]) | |
| 96 | apply (rule subsetI) | |
| 97 | apply (drule lfp_Con2_in_counit2 [THEN counit2_implies_equal]) | |
| 98 | apply (erule subst) | |
| 99 | apply (rule singletonI) | |
| 100 | done | |
| 515 | 101 | |
| 102 | end |