src/ZF/ex/CoUnit.thy
author paulson
Tue, 27 May 2003 11:39:03 +0200
changeset 14046 6616e6c53d48
parent 12228 9e5d3c96111a
child 16417 9bc16273c2d4
permissions -rw-r--r--
updating ZF-UNITY with Sidi's new material
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      ZF/ex/CoUnit.ML
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     5
*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     6
12228
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
     7
header {* Trivial codatatype definitions, one of which goes wrong! *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
     8
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
     9
theory CoUnit = Main:
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    10
12228
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    11
text {*
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    12
  See discussion in: L C Paulson.  A Concrete Final Coalgebra Theorem
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    13
  for ZF Set Theory.  Report 334, Cambridge University Computer
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    14
  Laboratory.  1994.
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    15
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    16
  \bigskip
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    17
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    18
  This degenerate definition does not work well because the one
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    19
  constructor's definition is trivial!  The same thing occurs with
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    20
  Aczel's Special Final Coalgebra Theorem.
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    21
*}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    22
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    23
consts
1401
0c439768f45c removed quotes from consts and syntax sections
clasohm
parents: 810
diff changeset
    24
  counit :: i
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    25
codatatype
12228
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    26
  "counit" = Con ("x \<in> counit")
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    27
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    28
inductive_cases ConE: "Con(x) \<in> counit"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    29
  -- {* USELESS because folding on @{term "Con(xa) == xa"} fails. *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    30
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    31
lemma Con_iff: "Con(x) = Con(y) <-> x = y"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    32
  -- {* Proving freeness results. *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    33
  by (auto elim!: counit.free_elims)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    34
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    35
lemma counit_eq_univ: "counit = quniv(0)"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    36
  -- {* Should be a singleton, not everything! *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    37
  apply (rule counit.dom_subset [THEN equalityI])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    38
  apply (rule subsetI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    39
  apply (erule counit.coinduct)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    40
   apply (rule subset_refl)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    41
  apply (unfold counit.con_defs)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    42
  apply fast
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    43
  done
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    44
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    45
12228
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    46
text {*
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    47
  \medskip A similar example, but the constructor is non-degenerate
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    48
  and it works!  The resulting set is a singleton.
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    49
*}
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    50
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    51
consts
1401
0c439768f45c removed quotes from consts and syntax sections
clasohm
parents: 810
diff changeset
    52
  counit2 :: i
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    53
codatatype
12228
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    54
  "counit2" = Con2 ("x \<in> counit2", "y \<in> counit2")
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    55
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    56
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    57
inductive_cases Con2E: "Con2(x, y) \<in> counit2"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    58
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    59
lemma Con2_iff: "Con2(x, y) = Con2(x', y') <-> x = x' & y = y'"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    60
  -- {* Proving freeness results. *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    61
  by (fast elim!: counit2.free_elims)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    62
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    63
lemma Con2_bnd_mono: "bnd_mono(univ(0), %x. Con2(x, x))"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    64
  apply (unfold counit2.con_defs)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    65
  apply (rule bnd_monoI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    66
   apply (assumption | rule subset_refl QPair_subset_univ QPair_mono)+
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    67
  done
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    68
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    69
lemma lfp_Con2_in_counit2: "lfp(univ(0), %x. Con2(x,x)) \<in> counit2"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    70
  apply (rule singletonI [THEN counit2.coinduct])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    71
  apply (rule qunivI [THEN singleton_subsetI])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    72
  apply (rule subset_trans [OF lfp_subset empty_subsetI [THEN univ_mono]])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    73
  apply (fast intro!: Con2_bnd_mono [THEN lfp_unfold])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    74
  done
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    75
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    76
lemma counit2_Int_Vset_subset [rule_format]:
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    77
  "Ord(i) ==> \<forall>x y. x \<in> counit2 --> y \<in> counit2 --> x Int Vset(i) \<subseteq> y"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    78
  -- {* Lemma for proving finality. *}
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    79
  apply (erule trans_induct)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    80
  apply (tactic "safe_tac subset_cs")
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    81
  apply (erule counit2.cases)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    82
  apply (erule counit2.cases)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    83
  apply (unfold counit2.con_defs)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    84
  apply (tactic {* fast_tac (subset_cs
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    85
    addSIs [QPair_Int_Vset_subset_UN RS subset_trans, QPair_mono]
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    86
    addSEs [Ord_in_Ord, Pair_inject]) 1 *})
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    87
  done
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    88
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    89
lemma counit2_implies_equal: "[| x \<in> counit2;  y \<in> counit2 |] ==> x = y"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    90
  apply (rule equalityI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    91
  apply (assumption | rule conjI counit2_Int_Vset_subset [THEN Int_Vset_subset])+
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    92
  done
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    93
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    94
lemma counit2_eq_univ: "counit2 = {lfp(univ(0), %x. Con2(x,x))}"
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    95
  apply (rule equalityI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    96
   apply (rule_tac [2] lfp_Con2_in_counit2 [THEN singleton_subsetI])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    97
  apply (rule subsetI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    98
  apply (drule lfp_Con2_in_counit2 [THEN counit2_implies_equal])
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
    99
  apply (erule subst)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
   100
  apply (rule singletonI)
9e5d3c96111a converted;
wenzelm
parents: 11354
diff changeset
   101
  done
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   102
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   103
end