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