src/HOL/Datatype.thy
author haftmann
Mon, 16 Oct 2006 14:07:31 +0200
changeset 21046 fe1db2f991a7
parent 20847 7e8c724339e0
child 21060 bc1fa6f47ced
permissions -rw-r--r--
moved HOL code generator setup to Code_Generator
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Datatype.thy
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
     2
    ID:         $Id$
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
     4
    Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
     5
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
     6
Could <*> be generalized to a general summation (Sigma)?
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
     7
*)
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
     8
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
     9
header{*Analogues of the Cartesian Product and Disjoint Sum for Datatypes*}
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
    10
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14981
diff changeset
    11
theory Datatype
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    12
imports NatArith Sum_Type
15131
c69542757a4d New theory header syntax.
nipkow
parents: 14981
diff changeset
    13
begin
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
    14
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    15
typedef (Node)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    16
  ('a,'b) node = "{p. EX f x k. p = (f::nat=>'b+nat, x::'a+nat) & f k = Inr 0}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    17
    --{*it is a subtype of @{text "(nat=>'b+nat) * ('a+nat)"}*}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    18
  by auto
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    19
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    20
text{*Datatypes will be represented by sets of type @{text node}*}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    21
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    22
types 'a item        = "('a, unit) node set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    23
      ('a, 'b) dtree = "('a, 'b) node set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    24
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    25
consts
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    26
  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    27
  Push      :: "[('b + nat), nat => ('b + nat)] => (nat => ('b + nat))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    28
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    29
  Push_Node :: "[('b + nat), ('a, 'b) node] => ('a, 'b) node"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    30
  ndepth    :: "('a, 'b) node => nat"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    31
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    32
  Atom      :: "('a + nat) => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    33
  Leaf      :: "'a => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    34
  Numb      :: "nat => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    35
  Scons     :: "[('a, 'b) dtree, ('a, 'b) dtree] => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    36
  In0       :: "('a, 'b) dtree => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    37
  In1       :: "('a, 'b) dtree => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    38
  Lim       :: "('b => ('a, 'b) dtree) => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    39
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    40
  ntrunc    :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    41
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    42
  uprod     :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    43
  usum      :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    44
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    45
  Split     :: "[[('a, 'b) dtree, ('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    46
  Case      :: "[[('a, 'b) dtree]=>'c, [('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    47
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    48
  dprod     :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    49
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    50
  dsum      :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    51
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    52
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    53
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    54
defs
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    55
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    56
  Push_Node_def:  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    57
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    58
  (*crude "lists" of nats -- needed for the constructions*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    59
  apfst_def:  "apfst == (%f (x,y). (f(x),y))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    60
  Push_def:   "Push == (%b h. nat_case b h)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    61
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    62
  (** operations on S-expressions -- sets of nodes **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    63
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    64
  (*S-expression constructors*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    65
  Atom_def:   "Atom == (%x. {Abs_Node((%k. Inr 0, x))})"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    66
  Scons_def:  "Scons M N == (Push_Node (Inr 1) ` M) Un (Push_Node (Inr (Suc 1)) ` N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    67
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    68
  (*Leaf nodes, with arbitrary or nat labels*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    69
  Leaf_def:   "Leaf == Atom o Inl"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    70
  Numb_def:   "Numb == Atom o Inr"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    71
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    72
  (*Injections of the "disjoint sum"*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    73
  In0_def:    "In0(M) == Scons (Numb 0) M"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    74
  In1_def:    "In1(M) == Scons (Numb 1) M"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    75
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    76
  (*Function spaces*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    77
  Lim_def: "Lim f == Union {z. ? x. z = Push_Node (Inl x) ` (f x)}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    78
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    79
  (*the set of nodes with depth less than k*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    80
  ndepth_def: "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    81
  ntrunc_def: "ntrunc k N == {n. n:N & ndepth(n)<k}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    82
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    83
  (*products and sums for the "universe"*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    84
  uprod_def:  "uprod A B == UN x:A. UN y:B. { Scons x y }"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    85
  usum_def:   "usum A B == In0`A Un In1`B"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    86
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    87
  (*the corresponding eliminators*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    88
  Split_def:  "Split c M == THE u. EX x y. M = Scons x y & u = c x y"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    89
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    90
  Case_def:   "Case c d M == THE u.  (EX x . M = In0(x) & u = c(x))
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    91
                                  | (EX y . M = In1(y) & u = d(y))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    92
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    93
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    94
  (** equality for the "universe" **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    95
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    96
  dprod_def:  "dprod r s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    97
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    98
  dsum_def:   "dsum r s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
    99
                          (UN (y,y'):s. {(In1(y),In1(y'))})"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   100
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   101
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   102
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   103
(** apfst -- can be used in similar type definitions **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   104
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   105
lemma apfst_conv [simp]: "apfst f (a,b) = (f(a),b)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   106
by (simp add: apfst_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   107
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   108
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   109
lemma apfst_convE: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   110
    "[| q = apfst f p;  !!x y. [| p = (x,y);  q = (f(x),y) |] ==> R  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   111
     |] ==> R"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   112
by (force simp add: apfst_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   113
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   114
(** Push -- an injection, analogous to Cons on lists **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   115
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   116
lemma Push_inject1: "Push i f = Push j g  ==> i=j"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   117
apply (simp add: Push_def expand_fun_eq) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   118
apply (drule_tac x=0 in spec, simp) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   119
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   120
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   121
lemma Push_inject2: "Push i f = Push j g  ==> f=g"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   122
apply (auto simp add: Push_def expand_fun_eq) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   123
apply (drule_tac x="Suc x" in spec, simp) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   124
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   125
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   126
lemma Push_inject:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   127
    "[| Push i f =Push j g;  [| i=j;  f=g |] ==> P |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   128
by (blast dest: Push_inject1 Push_inject2) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   129
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   130
lemma Push_neq_K0: "Push (Inr (Suc k)) f = (%z. Inr 0) ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   131
by (auto simp add: Push_def expand_fun_eq split: nat.split_asm)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   132
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   133
lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   134
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   135
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   136
(*** Introduction rules for Node ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   137
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   138
lemma Node_K0_I: "(%k. Inr 0, a) : Node"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   139
by (simp add: Node_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   140
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   141
lemma Node_Push_I: "p: Node ==> apfst (Push i) p : Node"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   142
apply (simp add: Node_def Push_def) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   143
apply (fast intro!: apfst_conv nat_case_Suc [THEN trans])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   144
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   145
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   146
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   147
subsection{*Freeness: Distinctness of Constructors*}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   148
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   149
(** Scons vs Atom **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   150
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   151
lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   152
apply (simp add: Atom_def Scons_def Push_Node_def One_nat_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   153
apply (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I] 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   154
         dest!: Abs_Node_inj 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   155
         elim!: apfst_convE sym [THEN Push_neq_K0])  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   156
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   157
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   158
lemmas Atom_not_Scons = Scons_not_Atom [THEN not_sym, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   159
declare Atom_not_Scons [iff]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   160
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   161
(*** Injectiveness ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   162
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   163
(** Atomic nodes **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   164
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   165
lemma inj_Atom: "inj(Atom)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   166
apply (simp add: Atom_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   167
apply (blast intro!: inj_onI Node_K0_I dest!: Abs_Node_inj)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   168
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   169
lemmas Atom_inject = inj_Atom [THEN injD, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   170
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   171
lemma Atom_Atom_eq [iff]: "(Atom(a)=Atom(b)) = (a=b)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   172
by (blast dest!: Atom_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   173
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   174
lemma inj_Leaf: "inj(Leaf)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   175
apply (simp add: Leaf_def o_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   176
apply (rule inj_onI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   177
apply (erule Atom_inject [THEN Inl_inject])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   178
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   179
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   180
lemmas Leaf_inject = inj_Leaf [THEN injD, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   181
declare Leaf_inject [dest!]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   182
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   183
lemma inj_Numb: "inj(Numb)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   184
apply (simp add: Numb_def o_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   185
apply (rule inj_onI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   186
apply (erule Atom_inject [THEN Inr_inject])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   187
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   188
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   189
lemmas Numb_inject = inj_Numb [THEN injD, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   190
declare Numb_inject [dest!]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   191
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   192
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   193
(** Injectiveness of Push_Node **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   194
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   195
lemma Push_Node_inject:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   196
    "[| Push_Node i m =Push_Node j n;  [| i=j;  m=n |] ==> P  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   197
     |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   198
apply (simp add: Push_Node_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   199
apply (erule Abs_Node_inj [THEN apfst_convE])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   200
apply (rule Rep_Node [THEN Node_Push_I])+
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   201
apply (erule sym [THEN apfst_convE]) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   202
apply (blast intro: Rep_Node_inject [THEN iffD1] trans sym elim!: Push_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   203
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   204
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   205
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   206
(** Injectiveness of Scons **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   207
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   208
lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   209
apply (simp add: Scons_def One_nat_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   210
apply (blast dest!: Push_Node_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   211
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   212
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   213
lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   214
apply (simp add: Scons_def One_nat_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   215
apply (blast dest!: Push_Node_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   216
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   217
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   218
lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   219
apply (erule equalityE)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   220
apply (iprover intro: equalityI Scons_inject_lemma1)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   221
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   222
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   223
lemma Scons_inject2: "Scons M N = Scons M' N' ==> N=N'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   224
apply (erule equalityE)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   225
apply (iprover intro: equalityI Scons_inject_lemma2)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   226
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   227
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   228
lemma Scons_inject:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   229
    "[| Scons M N = Scons M' N';  [| M=M';  N=N' |] ==> P |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   230
by (iprover dest: Scons_inject1 Scons_inject2)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   231
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   232
lemma Scons_Scons_eq [iff]: "(Scons M N = Scons M' N') = (M=M' & N=N')"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   233
by (blast elim!: Scons_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   234
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   235
(*** Distinctness involving Leaf and Numb ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   236
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   237
(** Scons vs Leaf **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   238
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   239
lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   240
by (simp add: Leaf_def o_def Scons_not_Atom)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   241
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   242
lemmas Leaf_not_Scons = Scons_not_Leaf [THEN not_sym, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   243
declare Leaf_not_Scons [iff]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   244
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   245
(** Scons vs Numb **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   246
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   247
lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   248
by (simp add: Numb_def o_def Scons_not_Atom)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   249
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   250
lemmas Numb_not_Scons = Scons_not_Numb [THEN not_sym, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   251
declare Numb_not_Scons [iff]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   252
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   253
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   254
(** Leaf vs Numb **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   255
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   256
lemma Leaf_not_Numb [iff]: "Leaf(a) \<noteq> Numb(k)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   257
by (simp add: Leaf_def Numb_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   258
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   259
lemmas Numb_not_Leaf = Leaf_not_Numb [THEN not_sym, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   260
declare Numb_not_Leaf [iff]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   261
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   262
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   263
(*** ndepth -- the depth of a node ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   264
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   265
lemma ndepth_K0: "ndepth (Abs_Node(%k. Inr 0, x)) = 0"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   266
by (simp add: ndepth_def  Node_K0_I [THEN Abs_Node_inverse] Least_equality)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   267
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   268
lemma ndepth_Push_Node_aux:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   269
     "nat_case (Inr (Suc i)) f k = Inr 0 --> Suc(LEAST x. f x = Inr 0) <= k"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   270
apply (induct_tac "k", auto)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   271
apply (erule Least_le)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   272
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   273
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   274
lemma ndepth_Push_Node: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   275
    "ndepth (Push_Node (Inr (Suc i)) n) = Suc(ndepth(n))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   276
apply (insert Rep_Node [of n, unfolded Node_def])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   277
apply (auto simp add: ndepth_def Push_Node_def
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   278
                 Rep_Node [THEN Node_Push_I, THEN Abs_Node_inverse])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   279
apply (rule Least_equality)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   280
apply (auto simp add: Push_def ndepth_Push_Node_aux)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   281
apply (erule LeastI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   282
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   283
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   284
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   285
(*** ntrunc applied to the various node sets ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   286
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   287
lemma ntrunc_0 [simp]: "ntrunc 0 M = {}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   288
by (simp add: ntrunc_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   289
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   290
lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   291
by (auto simp add: Atom_def ntrunc_def ndepth_K0)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   292
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   293
lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   294
by (simp add: Leaf_def o_def ntrunc_Atom)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   295
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   296
lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   297
by (simp add: Numb_def o_def ntrunc_Atom)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   298
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   299
lemma ntrunc_Scons [simp]: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   300
    "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   301
by (auto simp add: Scons_def ntrunc_def One_nat_def ndepth_Push_Node) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   302
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   303
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   304
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   305
(** Injection nodes **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   306
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   307
lemma ntrunc_one_In0 [simp]: "ntrunc (Suc 0) (In0 M) = {}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   308
apply (simp add: In0_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   309
apply (simp add: Scons_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   310
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   311
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   312
lemma ntrunc_In0 [simp]: "ntrunc (Suc(Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   313
by (simp add: In0_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   314
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   315
lemma ntrunc_one_In1 [simp]: "ntrunc (Suc 0) (In1 M) = {}"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   316
apply (simp add: In1_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   317
apply (simp add: Scons_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   318
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   319
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   320
lemma ntrunc_In1 [simp]: "ntrunc (Suc(Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   321
by (simp add: In1_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   322
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   323
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   324
subsection{*Set Constructions*}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   325
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   326
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   327
(*** Cartesian Product ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   328
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   329
lemma uprodI [intro!]: "[| M:A;  N:B |] ==> Scons M N : uprod A B"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   330
by (simp add: uprod_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   331
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   332
(*The general elimination rule*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   333
lemma uprodE [elim!]:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   334
    "[| c : uprod A B;   
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   335
        !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   336
     |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   337
by (auto simp add: uprod_def) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   338
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   339
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   340
(*Elimination of a pair -- introduces no eigenvariables*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   341
lemma uprodE2: "[| Scons M N : uprod A B;  [| M:A;  N:B |] ==> P |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   342
by (auto simp add: uprod_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   343
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   344
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   345
(*** Disjoint Sum ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   346
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   347
lemma usum_In0I [intro]: "M:A ==> In0(M) : usum A B"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   348
by (simp add: usum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   349
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   350
lemma usum_In1I [intro]: "N:B ==> In1(N) : usum A B"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   351
by (simp add: usum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   352
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   353
lemma usumE [elim!]: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   354
    "[| u : usum A B;   
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   355
        !!x. [| x:A;  u=In0(x) |] ==> P;  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   356
        !!y. [| y:B;  u=In1(y) |] ==> P  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   357
     |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   358
by (auto simp add: usum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   359
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   360
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   361
(** Injection **)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   362
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   363
lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   364
by (auto simp add: In0_def In1_def One_nat_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   365
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   366
lemmas In1_not_In0 = In0_not_In1 [THEN not_sym, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   367
declare In1_not_In0 [iff]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   368
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   369
lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   370
by (simp add: In0_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   371
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   372
lemma In1_inject: "In1(M) = In1(N) ==>  M=N"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   373
by (simp add: In1_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   374
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   375
lemma In0_eq [iff]: "(In0 M = In0 N) = (M=N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   376
by (blast dest!: In0_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   377
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   378
lemma In1_eq [iff]: "(In1 M = In1 N) = (M=N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   379
by (blast dest!: In1_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   380
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   381
lemma inj_In0: "inj In0"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   382
by (blast intro!: inj_onI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   383
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   384
lemma inj_In1: "inj In1"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   385
by (blast intro!: inj_onI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   386
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   387
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   388
(*** Function spaces ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   389
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   390
lemma Lim_inject: "Lim f = Lim g ==> f = g"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   391
apply (simp add: Lim_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   392
apply (rule ext)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   393
apply (blast elim!: Push_Node_inject)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   394
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   395
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   396
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   397
(*** proving equality of sets and functions using ntrunc ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   398
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   399
lemma ntrunc_subsetI: "ntrunc k M <= M"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   400
by (auto simp add: ntrunc_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   401
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   402
lemma ntrunc_subsetD: "(!!k. ntrunc k M <= N) ==> M<=N"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   403
by (auto simp add: ntrunc_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   404
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   405
(*A generalized form of the take-lemma*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   406
lemma ntrunc_equality: "(!!k. ntrunc k M = ntrunc k N) ==> M=N"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   407
apply (rule equalityI)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   408
apply (rule_tac [!] ntrunc_subsetD)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   409
apply (rule_tac [!] ntrunc_subsetI [THEN [2] subset_trans], auto) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   410
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   411
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   412
lemma ntrunc_o_equality: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   413
    "[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   414
apply (rule ntrunc_equality [THEN ext])
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   415
apply (simp add: expand_fun_eq) 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   416
done
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   417
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   418
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   419
(*** Monotonicity ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   420
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   421
lemma uprod_mono: "[| A<=A';  B<=B' |] ==> uprod A B <= uprod A' B'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   422
by (simp add: uprod_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   423
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   424
lemma usum_mono: "[| A<=A';  B<=B' |] ==> usum A B <= usum A' B'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   425
by (simp add: usum_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   426
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   427
lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   428
by (simp add: Scons_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   429
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   430
lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   431
by (simp add: In0_def subset_refl Scons_mono)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   432
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   433
lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   434
by (simp add: In1_def subset_refl Scons_mono)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   435
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   436
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   437
(*** Split and Case ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   438
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   439
lemma Split [simp]: "Split c (Scons M N) = c M N"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   440
by (simp add: Split_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   441
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   442
lemma Case_In0 [simp]: "Case c d (In0 M) = c(M)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   443
by (simp add: Case_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   444
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   445
lemma Case_In1 [simp]: "Case c d (In1 N) = d(N)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   446
by (simp add: Case_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   447
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   448
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   449
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   450
(**** UN x. B(x) rules ****)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   451
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   452
lemma ntrunc_UN1: "ntrunc k (UN x. f(x)) = (UN x. ntrunc k (f x))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   453
by (simp add: ntrunc_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   454
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   455
lemma Scons_UN1_x: "Scons (UN x. f x) M = (UN x. Scons (f x) M)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   456
by (simp add: Scons_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   457
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   458
lemma Scons_UN1_y: "Scons M (UN x. f x) = (UN x. Scons M (f x))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   459
by (simp add: Scons_def, blast)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   460
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   461
lemma In0_UN1: "In0(UN x. f(x)) = (UN x. In0(f(x)))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   462
by (simp add: In0_def Scons_UN1_y)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   463
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   464
lemma In1_UN1: "In1(UN x. f(x)) = (UN x. In1(f(x)))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   465
by (simp add: In1_def Scons_UN1_y)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   466
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   467
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   468
(*** Equality for Cartesian Product ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   469
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   470
lemma dprodI [intro!]: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   471
    "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : dprod r s"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   472
by (auto simp add: dprod_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   473
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   474
(*The general elimination rule*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   475
lemma dprodE [elim!]: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   476
    "[| c : dprod r s;   
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   477
        !!x y x' y'. [| (x,x') : r;  (y,y') : s;  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   478
                        c = (Scons x y, Scons x' y') |] ==> P  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   479
     |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   480
by (auto simp add: dprod_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   481
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   482
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   483
(*** Equality for Disjoint Sum ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   484
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   485
lemma dsum_In0I [intro]: "(M,M'):r ==> (In0(M), In0(M')) : dsum r s"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   486
by (auto simp add: dsum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   487
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   488
lemma dsum_In1I [intro]: "(N,N'):s ==> (In1(N), In1(N')) : dsum r s"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   489
by (auto simp add: dsum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   490
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   491
lemma dsumE [elim!]: 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   492
    "[| w : dsum r s;   
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   493
        !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P;  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   494
        !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P  
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   495
     |] ==> P"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   496
by (auto simp add: dsum_def)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   497
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   498
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   499
(*** Monotonicity ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   500
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   501
lemma dprod_mono: "[| r<=r';  s<=s' |] ==> dprod r s <= dprod r' s'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   502
by blast
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   503
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   504
lemma dsum_mono: "[| r<=r';  s<=s' |] ==> dsum r s <= dsum r' s'"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   505
by blast
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   506
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   507
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   508
(*** Bounding theorems ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   509
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   510
lemma dprod_Sigma: "(dprod (A <*> B) (C <*> D)) <= (uprod A C) <*> (uprod B D)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   511
by blast
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   512
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   513
lemmas dprod_subset_Sigma = subset_trans [OF dprod_mono dprod_Sigma, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   514
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   515
(*Dependent version*)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   516
lemma dprod_subset_Sigma2:
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   517
     "(dprod (Sigma A B) (Sigma C D)) <= 
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   518
      Sigma (uprod A C) (Split (%x y. uprod (B x) (D y)))"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   519
by auto
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   520
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   521
lemma dsum_Sigma: "(dsum (A <*> B) (C <*> D)) <= (usum A C) <*> (usum B D)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   522
by blast
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   523
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   524
lemmas dsum_subset_Sigma = subset_trans [OF dsum_mono dsum_Sigma, standard]
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   525
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   526
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   527
(*** Domain ***)
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   528
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   529
lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   530
by auto
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   531
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   532
lemma Domain_dsum [simp]: "Domain (dsum r s) = usum (Domain r) (Domain s)"
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   533
by auto
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   534
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   535
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   536
subsection {* Finishing the datatype package setup *}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   537
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   538
text {* Belongs to theory @{text Datatype_Universe}; hides popular names. *}
20847
7e8c724339e0 clarified setup name
haftmann
parents: 20819
diff changeset
   539
setup "DatatypeCodegen.setup_hooks"
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   540
hide (open) const Push Node Atom Leaf Numb Lim Split Case
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   541
hide (open) type node item
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   542
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   543
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   544
section {* Datatypes *}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   545
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   546
subsection {* Representing primitive types *}
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
   547
5759
bf5d9e5b8cdf unit and bool are now represented as datatypes.
berghofe
parents: 5714
diff changeset
   548
rep_datatype bool
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   549
  distinct True_not_False False_not_True
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   550
  induction bool_induct
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   551
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   552
declare case_split [cases type: bool]
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   553
  -- "prefer plain propositional version"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   554
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   555
rep_datatype unit
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   556
  induction unit_induct
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
   557
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
   558
rep_datatype prod
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   559
  inject Pair_eq
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   560
  induction prod_induct
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   561
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   562
rep_datatype sum
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   563
  distinct Inl_not_Inr Inr_not_Inl
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   564
  inject Inl_eq Inr_eq
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   565
  induction sum_induct
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   566
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   567
lemma surjective_sum: "sum_case (%x::'a. f (Inl x)) (%y::'b. f (Inr y)) s = f(s)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   568
  apply (rule_tac s = s in sumE)
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   569
   apply (erule ssubst)
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   570
   apply (rule sum.cases(1))
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   571
  apply (erule ssubst)
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   572
  apply (rule sum.cases(2))
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   573
  done
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   574
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   575
lemma sum_case_weak_cong: "s = t ==> sum_case f g s = sum_case f g t"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   576
  -- {* Prevents simplification of @{text f} and @{text g}: much faster. *}
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   577
  by simp
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   578
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   579
lemma sum_case_inject:
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   580
  "sum_case f1 f2 = sum_case g1 g2 ==> (f1 = g1 ==> f2 = g2 ==> P) ==> P"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   581
proof -
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   582
  assume a: "sum_case f1 f2 = sum_case g1 g2"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   583
  assume r: "f1 = g1 ==> f2 = g2 ==> P"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   584
  show P
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   585
    apply (rule r)
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   586
     apply (rule ext)
14208
144f45277d5a misc tidying
paulson
parents: 14187
diff changeset
   587
     apply (cut_tac x = "Inl x" in a [THEN fun_cong], simp)
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   588
    apply (rule ext)
14208
144f45277d5a misc tidying
paulson
parents: 14187
diff changeset
   589
    apply (cut_tac x = "Inr x" in a [THEN fun_cong], simp)
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   590
    done
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   591
qed
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   592
13635
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   593
constdefs
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   594
  Suml :: "('a => 'c) => 'a + 'b => 'c"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   595
  "Suml == (%f. sum_case f arbitrary)"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   596
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   597
  Sumr :: "('b => 'c) => 'a + 'b => 'c"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   598
  "Sumr == sum_case arbitrary"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   599
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   600
lemma Suml_inject: "Suml f = Suml g ==> f = g"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   601
  by (unfold Suml_def) (erule sum_case_inject)
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   602
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   603
lemma Sumr_inject: "Sumr f = Sumr g ==> f = g"
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   604
  by (unfold Sumr_def) (erule sum_case_inject)
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   605
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   606
hide (open) const Suml Sumr
13635
c41e88151b54 Added functions Suml and Sumr which are useful for constructing
berghofe
parents: 12918
diff changeset
   607
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   608
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   609
subsection {* Further cases/induct rules for tuples *}
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   610
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   611
lemma prod_cases3 [cases type]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   612
  obtains (fields) a b c where "y = (a, b, c)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   613
  by (cases y, case_tac b) blast
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   614
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   615
lemma prod_induct3 [case_names fields, induct type]:
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   616
    "(!!a b c. P (a, b, c)) ==> P x"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   617
  by (cases x) blast
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   618
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   619
lemma prod_cases4 [cases type]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   620
  obtains (fields) a b c d where "y = (a, b, c, d)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   621
  by (cases y, case_tac c) blast
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   622
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   623
lemma prod_induct4 [case_names fields, induct type]:
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   624
    "(!!a b c d. P (a, b, c, d)) ==> P x"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   625
  by (cases x) blast
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
   626
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   627
lemma prod_cases5 [cases type]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   628
  obtains (fields) a b c d e where "y = (a, b, c, d, e)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   629
  by (cases y, case_tac d) blast
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   630
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   631
lemma prod_induct5 [case_names fields, induct type]:
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   632
    "(!!a b c d e. P (a, b, c, d, e)) ==> P x"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   633
  by (cases x) blast
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   634
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   635
lemma prod_cases6 [cases type]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   636
  obtains (fields) a b c d e f where "y = (a, b, c, d, e, f)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   637
  by (cases y, case_tac e) blast
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   638
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   639
lemma prod_induct6 [case_names fields, induct type]:
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   640
    "(!!a b c d e f. P (a, b, c, d, e, f)) ==> P x"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   641
  by (cases x) blast
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   642
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   643
lemma prod_cases7 [cases type]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   644
  obtains (fields) a b c d e f g where "y = (a, b, c, d, e, f, g)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   645
  by (cases y, case_tac f) blast
11954
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   646
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   647
lemma prod_induct7 [case_names fields, induct type]:
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   648
    "(!!a b c d e f g. P (a, b, c, d, e, f, g)) ==> P x"
3d1780208bf3 made new-style theory;
wenzelm
parents: 10212
diff changeset
   649
  by (cases x) blast
5759
bf5d9e5b8cdf unit and bool are now represented as datatypes.
berghofe
parents: 5714
diff changeset
   650
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   651
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   652
subsection {* The option type *}
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   653
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   654
datatype 'a option = None | Some 'a
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   655
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   656
lemma not_None_eq [iff]: "(x ~= None) = (EX y. x = Some y)"
18576
8d98b7711e47 Reversed Larry's option/iff change.
nipkow
parents: 18447
diff changeset
   657
  by (induct x) auto
8d98b7711e47 Reversed Larry's option/iff change.
nipkow
parents: 18447
diff changeset
   658
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   659
lemma not_Some_eq [iff]: "(ALL y. x ~= Some y) = (x = None)"
18447
da548623916a removed or modified some instances of [iff]
paulson
parents: 18230
diff changeset
   660
  by (induct x) auto
da548623916a removed or modified some instances of [iff]
paulson
parents: 18230
diff changeset
   661
18576
8d98b7711e47 Reversed Larry's option/iff change.
nipkow
parents: 18447
diff changeset
   662
text{*Although it may appear that both of these equalities are helpful
8d98b7711e47 Reversed Larry's option/iff change.
nipkow
parents: 18447
diff changeset
   663
only when applied to assumptions, in practice it seems better to give
8d98b7711e47 Reversed Larry's option/iff change.
nipkow
parents: 18447
diff changeset
   664
them the uniform iff attribute. *}
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   665
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   666
lemma option_caseE:
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   667
  assumes c: "(case x of None => P | Some y => Q y)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   668
  obtains
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   669
    (None) "x = None" and P
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   670
  | (Some) y where "x = Some y" and "Q y"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   671
  using c by (cases x) simp_all
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   672
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   673
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   674
subsubsection {* Operations *}
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   675
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   676
consts
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   677
  the :: "'a option => 'a"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   678
primrec
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   679
  "the (Some x) = x"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   680
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   681
consts
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   682
  o2s :: "'a option => 'a set"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   683
primrec
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   684
  "o2s None = {}"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   685
  "o2s (Some x) = {x}"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   686
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   687
lemma ospec [dest]: "(ALL x:o2s A. P x) ==> A = Some x ==> P x"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   688
  by simp
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   689
17876
b9c92f384109 change_claset/simpset;
wenzelm
parents: 17458
diff changeset
   690
ML_setup {* change_claset (fn cs => cs addSD2 ("ospec", thm "ospec")) *}
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   691
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   692
lemma elem_o2s [iff]: "(x : o2s xo) = (xo = Some x)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   693
  by (cases xo) auto
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   694
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   695
lemma o2s_empty_eq [simp]: "(o2s xo = {}) = (xo = None)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   696
  by (cases xo) auto
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   697
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   698
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   699
constdefs
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   700
  option_map :: "('a => 'b) => ('a option => 'b option)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   701
  "option_map == %f y. case y of None => None | Some x => Some (f x)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   702
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   703
lemma option_map_None [simp]: "option_map f None = None"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   704
  by (simp add: option_map_def)
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   705
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   706
lemma option_map_Some [simp]: "option_map f (Some x) = Some (f x)"
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   707
  by (simp add: option_map_def)
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   708
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   709
lemma option_map_is_None [iff]:
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   710
    "(option_map f opt = None) = (opt = None)"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   711
  by (simp add: option_map_def split add: option.split)
14187
26dfcd0ac436 Added new theorems
nipkow
parents: 13635
diff changeset
   712
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   713
lemma option_map_eq_Some [iff]:
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   714
    "(option_map f xo = Some y) = (EX z. xo = Some z & f z = y)"
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   715
  by (simp add: option_map_def split add: option.split)
14187
26dfcd0ac436 Added new theorems
nipkow
parents: 13635
diff changeset
   716
26dfcd0ac436 Added new theorems
nipkow
parents: 13635
diff changeset
   717
lemma option_map_comp:
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   718
    "option_map f (option_map g opt) = option_map (f o g) opt"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   719
  by (simp add: option_map_def split add: option.split)
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   720
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   721
lemma option_map_o_sum_case [simp]:
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   722
    "option_map f o sum_case g h = sum_case (option_map f o g) (option_map f o h)"
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   723
  by (rule ext) (simp split: sum.split)
12918
bca45be2d25b theory Option has been assimilated by Datatype;
wenzelm
parents: 12029
diff changeset
   724
19787
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   725
19817
bb16bf9ae3fd slight code generator cleanup
haftmann
parents: 19787
diff changeset
   726
subsubsection {* Codegenerator setup *}
bb16bf9ae3fd slight code generator cleanup
haftmann
parents: 19787
diff changeset
   727
19787
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   728
consts
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   729
  is_none :: "'a option \<Rightarrow> bool"
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   730
primrec
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   731
  "is_none None = True"
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   732
  "is_none (Some x) = False"
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   733
20105
454f4be984b7 adaptions in codegen
haftmann
parents: 19890
diff changeset
   734
lemma is_none_none [code inline]:
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   735
    "(x = None) = (is_none x)" 
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   736
  by (cases x) simp_all
19787
b949911ecff5 improved code lemmas
haftmann
parents: 19770
diff changeset
   737
17458
e42bfad176eb lemmas [code] = imp_conv_disj (from Main.thy) -- Why does it need Datatype?
wenzelm
parents: 15140
diff changeset
   738
lemmas [code] = imp_conv_disj
e42bfad176eb lemmas [code] = imp_conv_disj (from Main.thy) -- Why does it need Datatype?
wenzelm
parents: 15140
diff changeset
   739
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   740
lemma [code func]:
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   741
  "(\<not> True) = False" by (rule HOL.simp_thms)
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   742
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   743
lemma [code func]:
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   744
  "(\<not> False) = True" by (rule HOL.simp_thms)
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   745
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   746
lemma [code func]:
19179
61ef97e3f531 changed and retracted change of location of code lemmas.
nipkow
parents: 19150
diff changeset
   747
  shows "(False \<and> x) = False"
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   748
    and "(True \<and> x) = x"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   749
    and "(x \<and> False) = False"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   750
    and "(x \<and> True) = x" by simp_all
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   751
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   752
lemma [code func]:
19179
61ef97e3f531 changed and retracted change of location of code lemmas.
nipkow
parents: 19150
diff changeset
   753
  shows "(False \<or> x) = x"
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   754
    and "(True \<or> x) = True"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   755
    and "(x \<or> False) = x"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   756
    and "(x \<or> True) = True" by simp_all
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   757
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   758
declare
20523
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   759
  if_True [code func]
36a59e5d0039 Major update to function package, including new syntax and the (only theoretical)
krauss
parents: 20453
diff changeset
   760
  if_False [code func]
19179
61ef97e3f531 changed and retracted change of location of code lemmas.
nipkow
parents: 19150
diff changeset
   761
  fst_conv [code]
61ef97e3f531 changed and retracted change of location of code lemmas.
nipkow
parents: 19150
diff changeset
   762
  snd_conv [code]
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   763
20105
454f4be984b7 adaptions in codegen
haftmann
parents: 19890
diff changeset
   764
lemma split_is_prod_case [code inline]:
20798
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   765
    "split = prod_case"
3275b03e2fff removed obsolete sum_case_Inl/Inr;
wenzelm
parents: 20588
diff changeset
   766
  by (simp add: expand_fun_eq split_def prod.cases)
20105
454f4be984b7 adaptions in codegen
haftmann
parents: 19890
diff changeset
   767
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   768
code_type bool
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   769
  (SML target_atom "bool")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   770
  (Haskell target_atom "Bool")
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   771
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   772
code_const True and False and Not and "op &" and "op |" and If
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   773
  (SML target_atom "true" and target_atom "false" and target_atom "not"
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   774
    and infixl 1 "andalso" and infixl 0 "orelse"
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   775
    and target_atom "(if __/ then __/ else __)")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   776
  (Haskell target_atom "True" and target_atom "False" and target_atom "not"
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   777
    and infixl 3 "&&" and infixl 2 "||"
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   778
    and target_atom "(if __/ then __/ else __)")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   779
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   780
code_type *
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   781
  (SML infix 2 "*")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   782
  (Haskell target_atom "(__,/ __)")
19138
42ff710d432f improved codegen bootstrap
haftmann
parents: 19111
diff changeset
   783
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   784
code_const Pair
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   785
  (SML target_atom "(__,/ __)")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   786
  (Haskell target_atom "(__,/ __)")
18702
7dc7dcd63224 substantial improvements in code generator
haftmann
parents: 18576
diff changeset
   787
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   788
code_type unit
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   789
  (SML target_atom "unit")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   790
  (Haskell target_atom "()")
19150
1457d810b408 class package and codegen refinements
haftmann
parents: 19138
diff changeset
   791
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   792
code_const Unity
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   793
  (SML target_atom "()")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   794
  (Haskell target_atom "()")
19150
1457d810b408 class package and codegen refinements
haftmann
parents: 19138
diff changeset
   795
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   796
code_type option
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   797
  (SML "_ option")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   798
  (Haskell "Maybe _")
19150
1457d810b408 class package and codegen refinements
haftmann
parents: 19138
diff changeset
   799
20453
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   800
code_const None and Some
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   801
  (SML target_atom "NONE" and target_atom "SOME")
855f07fabd76 final syntax for some Isar code generator keywords
haftmann
parents: 20105
diff changeset
   802
  (Haskell target_atom "Nothing" and target_atom "Just")
19150
1457d810b408 class package and codegen refinements
haftmann
parents: 19138
diff changeset
   803
20588
c847c56edf0c added operational equality
haftmann
parents: 20523
diff changeset
   804
code_instance option :: eq
c847c56edf0c added operational equality
haftmann
parents: 20523
diff changeset
   805
  (Haskell -)
c847c56edf0c added operational equality
haftmann
parents: 20523
diff changeset
   806
21046
fe1db2f991a7 moved HOL code generator setup to Code_Generator
haftmann
parents: 20847
diff changeset
   807
code_const "Code_Generator.eq \<Colon> 'a\<Colon>eq option \<Rightarrow> 'a option \<Rightarrow> bool"
20588
c847c56edf0c added operational equality
haftmann
parents: 20523
diff changeset
   808
  (Haskell infixl 4 "==")
c847c56edf0c added operational equality
haftmann
parents: 20523
diff changeset
   809
20819
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   810
ML
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   811
{*
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   812
val apfst_conv = thm "apfst_conv";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   813
val apfst_convE = thm "apfst_convE";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   814
val Push_inject1 = thm "Push_inject1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   815
val Push_inject2 = thm "Push_inject2";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   816
val Push_inject = thm "Push_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   817
val Push_neq_K0 = thm "Push_neq_K0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   818
val Abs_Node_inj = thm "Abs_Node_inj";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   819
val Node_K0_I = thm "Node_K0_I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   820
val Node_Push_I = thm "Node_Push_I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   821
val Scons_not_Atom = thm "Scons_not_Atom";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   822
val Atom_not_Scons = thm "Atom_not_Scons";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   823
val inj_Atom = thm "inj_Atom";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   824
val Atom_inject = thm "Atom_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   825
val Atom_Atom_eq = thm "Atom_Atom_eq";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   826
val inj_Leaf = thm "inj_Leaf";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   827
val Leaf_inject = thm "Leaf_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   828
val inj_Numb = thm "inj_Numb";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   829
val Numb_inject = thm "Numb_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   830
val Push_Node_inject = thm "Push_Node_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   831
val Scons_inject1 = thm "Scons_inject1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   832
val Scons_inject2 = thm "Scons_inject2";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   833
val Scons_inject = thm "Scons_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   834
val Scons_Scons_eq = thm "Scons_Scons_eq";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   835
val Scons_not_Leaf = thm "Scons_not_Leaf";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   836
val Leaf_not_Scons = thm "Leaf_not_Scons";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   837
val Scons_not_Numb = thm "Scons_not_Numb";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   838
val Numb_not_Scons = thm "Numb_not_Scons";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   839
val Leaf_not_Numb = thm "Leaf_not_Numb";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   840
val Numb_not_Leaf = thm "Numb_not_Leaf";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   841
val ndepth_K0 = thm "ndepth_K0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   842
val ndepth_Push_Node_aux = thm "ndepth_Push_Node_aux";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   843
val ndepth_Push_Node = thm "ndepth_Push_Node";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   844
val ntrunc_0 = thm "ntrunc_0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   845
val ntrunc_Atom = thm "ntrunc_Atom";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   846
val ntrunc_Leaf = thm "ntrunc_Leaf";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   847
val ntrunc_Numb = thm "ntrunc_Numb";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   848
val ntrunc_Scons = thm "ntrunc_Scons";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   849
val ntrunc_one_In0 = thm "ntrunc_one_In0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   850
val ntrunc_In0 = thm "ntrunc_In0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   851
val ntrunc_one_In1 = thm "ntrunc_one_In1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   852
val ntrunc_In1 = thm "ntrunc_In1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   853
val uprodI = thm "uprodI";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   854
val uprodE = thm "uprodE";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   855
val uprodE2 = thm "uprodE2";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   856
val usum_In0I = thm "usum_In0I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   857
val usum_In1I = thm "usum_In1I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   858
val usumE = thm "usumE";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   859
val In0_not_In1 = thm "In0_not_In1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   860
val In1_not_In0 = thm "In1_not_In0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   861
val In0_inject = thm "In0_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   862
val In1_inject = thm "In1_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   863
val In0_eq = thm "In0_eq";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   864
val In1_eq = thm "In1_eq";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   865
val inj_In0 = thm "inj_In0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   866
val inj_In1 = thm "inj_In1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   867
val Lim_inject = thm "Lim_inject";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   868
val ntrunc_subsetI = thm "ntrunc_subsetI";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   869
val ntrunc_subsetD = thm "ntrunc_subsetD";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   870
val ntrunc_equality = thm "ntrunc_equality";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   871
val ntrunc_o_equality = thm "ntrunc_o_equality";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   872
val uprod_mono = thm "uprod_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   873
val usum_mono = thm "usum_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   874
val Scons_mono = thm "Scons_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   875
val In0_mono = thm "In0_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   876
val In1_mono = thm "In1_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   877
val Split = thm "Split";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   878
val Case_In0 = thm "Case_In0";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   879
val Case_In1 = thm "Case_In1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   880
val ntrunc_UN1 = thm "ntrunc_UN1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   881
val Scons_UN1_x = thm "Scons_UN1_x";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   882
val Scons_UN1_y = thm "Scons_UN1_y";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   883
val In0_UN1 = thm "In0_UN1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   884
val In1_UN1 = thm "In1_UN1";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   885
val dprodI = thm "dprodI";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   886
val dprodE = thm "dprodE";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   887
val dsum_In0I = thm "dsum_In0I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   888
val dsum_In1I = thm "dsum_In1I";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   889
val dsumE = thm "dsumE";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   890
val dprod_mono = thm "dprod_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   891
val dsum_mono = thm "dsum_mono";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   892
val dprod_Sigma = thm "dprod_Sigma";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   893
val dprod_subset_Sigma = thm "dprod_subset_Sigma";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   894
val dprod_subset_Sigma2 = thm "dprod_subset_Sigma2";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   895
val dsum_Sigma = thm "dsum_Sigma";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   896
val dsum_subset_Sigma = thm "dsum_subset_Sigma";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   897
val Domain_dprod = thm "Domain_dprod";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   898
val Domain_dsum = thm "Domain_dsum";
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   899
*}
cb6ae81dd0be merged with theory Datatype_Universe;
wenzelm
parents: 20798
diff changeset
   900
5181
4ba3787d9709 New theory Datatype. Needed as an ancestor when defining datatypes.
berghofe
parents:
diff changeset
   901
end