src/HOL/Datatype_Universe.thy
author nipkow
Fri, 04 Feb 2005 17:14:42 +0100
changeset 15497 53bca254719a
parent 15413 901d1bfedf09
child 17084 fb0a80aef0be
permissions -rw-r--r--
Added semi-lattice locales and reorganized fold1 lemmas
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/Datatype_Universe.thy
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     5
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     6
Could <*> be generalized to a general summation (Sigma)?
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     7
*)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
     8
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
     9
header{*Analogues of the Cartesian Product and Disjoint Sum for Datatypes*}
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    10
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    11
theory Datatype_Universe
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    12
imports NatArith Sum_Type
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    13
begin
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    14
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    15
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    16
typedef (Node)
11483
f4d10044a2cd Hilbert_Choice is needed only in Main itself
paulson
parents: 11451
diff changeset
    17
  ('a,'b) node = "{p. EX f x k. p = (f::nat=>'b+nat, x::'a+nat) & f k = Inr 0}"
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    18
    --{*it is a subtype of @{text "(nat=>'b+nat) * ('a+nat)"}*}
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    19
  by auto
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    20
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    21
text{*Datatypes will be represented by sets of type @{text node}*}
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    22
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    23
types 'a item        = "('a, unit) node set"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    24
      ('a, 'b) dtree = "('a, 'b) node set"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    25
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    26
consts
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    27
  apfst     :: "['a=>'c, 'a*'b] => 'c*'b"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    28
  Push      :: "[('b + nat), nat => ('b + nat)] => (nat => ('b + nat))"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    29
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    30
  Push_Node :: "[('b + nat), ('a, 'b) node] => ('a, 'b) node"
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    31
  ndepth    :: "('a, 'b) node => nat"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    32
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    33
  Atom      :: "('a + nat) => ('a, 'b) dtree"
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    34
  Leaf      :: "'a => ('a, 'b) dtree"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    35
  Numb      :: "nat => ('a, 'b) dtree"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    36
  Scons     :: "[('a, 'b) dtree, ('a, 'b) dtree] => ('a, 'b) dtree"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    37
  In0       :: "('a, 'b) dtree => ('a, 'b) dtree"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    38
  In1       :: "('a, 'b) dtree => ('a, 'b) dtree"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    39
  Lim       :: "('b => ('a, 'b) dtree) => ('a, 'b) dtree"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    40
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    41
  ntrunc    :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    42
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    43
  uprod     :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    44
  usum      :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    45
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    46
  Split     :: "[[('a, 'b) dtree, ('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    47
  Case      :: "[[('a, 'b) dtree]=>'c, [('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    48
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    49
  dprod     :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    50
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    51
  dsum      :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    52
                => (('a, 'b) dtree * ('a, 'b) dtree)set"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    53
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    54
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    55
defs
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    56
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    57
  Push_Node_def:  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    58
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    59
  (*crude "lists" of nats -- needed for the constructions*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    60
  apfst_def:  "apfst == (%f (x,y). (f(x),y))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    61
  Push_def:   "Push == (%b h. nat_case b h)"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    62
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    63
  (** operations on S-expressions -- sets of nodes **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    64
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    65
  (*S-expression constructors*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    66
  Atom_def:   "Atom == (%x. {Abs_Node((%k. Inr 0, x))})"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    67
  Scons_def:  "Scons M N == (Push_Node (Inr 1) ` M) Un (Push_Node (Inr (Suc 1)) ` N)"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    68
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    69
  (*Leaf nodes, with arbitrary or nat labels*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    70
  Leaf_def:   "Leaf == Atom o Inl"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    71
  Numb_def:   "Numb == Atom o Inr"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    72
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    73
  (*Injections of the "disjoint sum"*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    74
  In0_def:    "In0(M) == Scons (Numb 0) M"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    75
  In1_def:    "In1(M) == Scons (Numb 1) M"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    76
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    77
  (*Function spaces*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    78
  Lim_def: "Lim f == Union {z. ? x. z = Push_Node (Inl x) ` (f x)}"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    79
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    80
  (*the set of nodes with depth less than k*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    81
  ndepth_def: "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    82
  ntrunc_def: "ntrunc k N == {n. n:N & ndepth(n)<k}"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    83
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    84
  (*products and sums for the "universe"*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    85
  uprod_def:  "uprod A B == UN x:A. UN y:B. { Scons x y }"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    86
  usum_def:   "usum A B == In0`A Un In1`B"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    87
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    88
  (*the corresponding eliminators*)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    89
  Split_def:  "Split c M == THE u. EX x y. M = Scons x y & u = c x y"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    90
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    91
  Case_def:   "Case c d M == THE u.  (EX x . M = In0(x) & u = c(x))
11451
8abfb4f7bd02 partial restructuring to reduce dependence on Axiom of Choice
paulson
parents: 10832
diff changeset
    92
                                  | (EX y . M = In1(y) & u = d(y))"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    93
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    94
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    95
  (** equality for the "universe" **)
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    96
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    97
  dprod_def:  "dprod r s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
    98
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
    99
  dsum_def:   "dsum r s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   100
                          (UN (y,y'):s. {(In1(y),In1(y'))})"
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   101
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   102
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   103
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   104
(** apfst -- can be used in similar type definitions **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   105
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   106
lemma apfst_conv [simp]: "apfst f (a,b) = (f(a),b)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   107
by (simp add: apfst_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   108
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   109
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   110
lemma apfst_convE: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   111
    "[| q = apfst f p;  !!x y. [| p = (x,y);  q = (f(x),y) |] ==> R  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   112
     |] ==> R"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   113
by (force simp add: apfst_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   114
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   115
(** Push -- an injection, analogous to Cons on lists **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   116
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   117
lemma Push_inject1: "Push i f = Push j g  ==> i=j"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   118
apply (simp add: Push_def expand_fun_eq) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   119
apply (drule_tac x=0 in spec, simp) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   120
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   121
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   122
lemma Push_inject2: "Push i f = Push j g  ==> f=g"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   123
apply (auto simp add: Push_def expand_fun_eq) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   124
apply (drule_tac x="Suc x" in spec, simp) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   125
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   126
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   127
lemma Push_inject:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   128
    "[| Push i f =Push j g;  [| i=j;  f=g |] ==> P |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   129
by (blast dest: Push_inject1 Push_inject2) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   130
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   131
lemma Push_neq_K0: "Push (Inr (Suc k)) f = (%z. Inr 0) ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   132
by (auto simp add: Push_def expand_fun_eq split: nat.split_asm)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   133
15413
901d1bfedf09 removal of archaic Abs/Rep proofs
paulson
parents: 15388
diff changeset
   134
lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1, standard]
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   135
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   136
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   137
(*** Introduction rules for Node ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   138
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   139
lemma Node_K0_I: "(%k. Inr 0, a) : Node"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   140
by (simp add: Node_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   141
15413
901d1bfedf09 removal of archaic Abs/Rep proofs
paulson
parents: 15388
diff changeset
   142
lemma Node_Push_I: "p: Node ==> apfst (Push i) p : Node"
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   143
apply (simp add: Node_def Push_def) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   144
apply (fast intro!: apfst_conv nat_case_Suc [THEN trans])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   145
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   146
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   147
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   148
subsubsection{*Freeness: Distinctness of Constructors*}
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   149
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   150
(** Scons vs Atom **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   151
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   152
lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   153
apply (simp add: Atom_def Scons_def Push_Node_def One_nat_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   154
apply (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I] 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   155
         dest!: Abs_Node_inj 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   156
         elim!: apfst_convE sym [THEN Push_neq_K0])  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   157
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   158
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   159
lemmas Atom_not_Scons = Scons_not_Atom [THEN not_sym, standard, iff]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   160
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   161
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   162
(*** Injectiveness ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   163
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   164
(** Atomic nodes **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   165
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   166
lemma inj_Atom: "inj(Atom)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   167
apply (simp add: Atom_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   168
apply (blast intro!: inj_onI Node_K0_I dest!: Abs_Node_inj)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   169
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   170
lemmas Atom_inject = inj_Atom [THEN injD, standard]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   171
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   172
lemma Atom_Atom_eq [iff]: "(Atom(a)=Atom(b)) = (a=b)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   173
by (blast dest!: Atom_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   174
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   175
lemma inj_Leaf: "inj(Leaf)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   176
apply (simp add: Leaf_def o_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   177
apply (rule inj_onI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   178
apply (erule Atom_inject [THEN Inl_inject])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   179
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   180
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   181
lemmas Leaf_inject = inj_Leaf [THEN injD, standard, dest!]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   182
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   183
lemma inj_Numb: "inj(Numb)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   184
apply (simp add: Numb_def o_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   185
apply (rule inj_onI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   186
apply (erule Atom_inject [THEN Inr_inject])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   187
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   188
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   189
lemmas Numb_inject = inj_Numb [THEN injD, standard, dest!]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   190
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   191
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   192
(** Injectiveness of Push_Node **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   193
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   194
lemma Push_Node_inject:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   195
    "[| Push_Node i m =Push_Node j n;  [| i=j;  m=n |] ==> P  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   196
     |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   197
apply (simp add: Push_Node_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   198
apply (erule Abs_Node_inj [THEN apfst_convE])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   199
apply (rule Rep_Node [THEN Node_Push_I])+
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   200
apply (erule sym [THEN apfst_convE]) 
15413
901d1bfedf09 removal of archaic Abs/Rep proofs
paulson
parents: 15388
diff changeset
   201
apply (blast intro: Rep_Node_inject [THEN iffD1] trans sym elim!: Push_inject)
15388
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   202
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   203
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   204
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   205
(** Injectiveness of Scons **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   206
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   207
lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   208
apply (simp add: Scons_def One_nat_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   209
apply (blast dest!: Push_Node_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   210
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   211
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   212
lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   213
apply (simp add: Scons_def One_nat_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   214
apply (blast dest!: Push_Node_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   215
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   216
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   217
lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   218
apply (erule equalityE)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   219
apply (rules intro: equalityI Scons_inject_lemma1)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   220
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   221
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   222
lemma Scons_inject2: "Scons M N = Scons M' N' ==> N=N'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   223
apply (erule equalityE)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   224
apply (rules intro: equalityI Scons_inject_lemma2)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   225
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   226
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   227
lemma Scons_inject:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   228
    "[| Scons M N = Scons M' N';  [| M=M';  N=N' |] ==> P |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   229
by (rules dest: Scons_inject1 Scons_inject2)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   230
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   231
lemma Scons_Scons_eq [iff]: "(Scons M N = Scons M' N') = (M=M' & N=N')"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   232
by (blast elim!: Scons_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   233
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   234
(*** Distinctness involving Leaf and Numb ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   235
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   236
(** Scons vs Leaf **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   237
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   238
lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   239
by (simp add: Leaf_def o_def Scons_not_Atom)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   240
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   241
lemmas Leaf_not_Scons = Scons_not_Leaf [THEN not_sym, standard, iff]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   242
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   243
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   244
(** Scons vs Numb **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   245
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   246
lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   247
by (simp add: Numb_def o_def Scons_not_Atom)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   248
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   249
lemmas Numb_not_Scons = Scons_not_Numb [THEN not_sym, standard, iff]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   250
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   251
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   252
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   253
(** Leaf vs Numb **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   254
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   255
lemma Leaf_not_Numb [iff]: "Leaf(a) \<noteq> Numb(k)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   256
by (simp add: Leaf_def Numb_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   257
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   258
lemmas Numb_not_Leaf = Leaf_not_Numb [THEN not_sym, standard, iff]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   259
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   260
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   261
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   262
(*** ndepth -- the depth of a node ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   263
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   264
lemma ndepth_K0: "ndepth (Abs_Node(%k. Inr 0, x)) = 0"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   265
by (simp add: ndepth_def  Node_K0_I [THEN Abs_Node_inverse] Least_equality)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   266
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   267
lemma ndepth_Push_Node_aux:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   268
     "nat_case (Inr (Suc i)) f k = Inr 0 --> Suc(LEAST x. f x = Inr 0) <= k"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   269
apply (induct_tac "k", auto)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   270
apply (erule Least_le)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   271
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   272
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   273
lemma ndepth_Push_Node: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   274
    "ndepth (Push_Node (Inr (Suc i)) n) = Suc(ndepth(n))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   275
apply (insert Rep_Node [of n, unfolded Node_def])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   276
apply (auto simp add: ndepth_def Push_Node_def
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   277
                 Rep_Node [THEN Node_Push_I, THEN Abs_Node_inverse])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   278
apply (rule Least_equality)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   279
apply (auto simp add: Push_def ndepth_Push_Node_aux)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   280
apply (erule LeastI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   281
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   282
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   283
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   284
(*** ntrunc applied to the various node sets ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   285
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   286
lemma ntrunc_0 [simp]: "ntrunc 0 M = {}"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   287
by (simp add: ntrunc_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   288
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   289
lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   290
by (auto simp add: Atom_def ntrunc_def ndepth_K0)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   291
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   292
lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   293
by (simp add: Leaf_def o_def ntrunc_Atom)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   294
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   295
lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   296
by (simp add: Numb_def o_def ntrunc_Atom)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   297
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   298
lemma ntrunc_Scons [simp]: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   299
    "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   300
by (auto simp add: Scons_def ntrunc_def One_nat_def ndepth_Push_Node) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   301
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   302
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   303
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   304
(** Injection nodes **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   305
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   306
lemma ntrunc_one_In0 [simp]: "ntrunc (Suc 0) (In0 M) = {}"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   307
apply (simp add: In0_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   308
apply (simp add: Scons_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   309
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   310
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   311
lemma ntrunc_In0 [simp]: "ntrunc (Suc(Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   312
by (simp add: In0_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   313
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   314
lemma ntrunc_one_In1 [simp]: "ntrunc (Suc 0) (In1 M) = {}"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   315
apply (simp add: In1_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   316
apply (simp add: Scons_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   317
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   318
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   319
lemma ntrunc_In1 [simp]: "ntrunc (Suc(Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   320
by (simp add: In1_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   321
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   322
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   323
subsection{*Set Constructions*}
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   324
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   325
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   326
(*** Cartesian Product ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   327
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   328
lemma uprodI [intro!]: "[| M:A;  N:B |] ==> Scons M N : uprod A B"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   329
by (simp add: uprod_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   330
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   331
(*The general elimination rule*)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   332
lemma uprodE [elim!]:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   333
    "[| c : uprod A B;   
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   334
        !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   335
     |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   336
by (auto simp add: uprod_def) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   337
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   338
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   339
(*Elimination of a pair -- introduces no eigenvariables*)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   340
lemma uprodE2: "[| Scons M N : uprod A B;  [| M:A;  N:B |] ==> P |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   341
by (auto simp add: uprod_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   342
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   343
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   344
(*** Disjoint Sum ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   345
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   346
lemma usum_In0I [intro]: "M:A ==> In0(M) : usum A B"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   347
by (simp add: usum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   348
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   349
lemma usum_In1I [intro]: "N:B ==> In1(N) : usum A B"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   350
by (simp add: usum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   351
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   352
lemma usumE [elim!]: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   353
    "[| u : usum A B;   
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   354
        !!x. [| x:A;  u=In0(x) |] ==> P;  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   355
        !!y. [| y:B;  u=In1(y) |] ==> P  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   356
     |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   357
by (auto simp add: usum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   358
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   359
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   360
(** Injection **)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   361
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   362
lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   363
by (auto simp add: In0_def In1_def One_nat_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   364
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   365
lemmas In1_not_In0 = In0_not_In1 [THEN not_sym, standard, iff]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   366
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   367
lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   368
by (simp add: In0_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   369
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   370
lemma In1_inject: "In1(M) = In1(N) ==>  M=N"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   371
by (simp add: In1_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   372
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   373
lemma In0_eq [iff]: "(In0 M = In0 N) = (M=N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   374
by (blast dest!: In0_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   375
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   376
lemma In1_eq [iff]: "(In1 M = In1 N) = (M=N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   377
by (blast dest!: In1_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   378
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   379
lemma inj_In0: "inj In0"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   380
by (blast intro!: inj_onI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   381
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   382
lemma inj_In1: "inj In1"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   383
by (blast intro!: inj_onI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   384
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   385
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   386
(*** Function spaces ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   387
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   388
lemma Lim_inject: "Lim f = Lim g ==> f = g"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   389
apply (simp add: Lim_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   390
apply (rule ext)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   391
apply (blast elim!: Push_Node_inject)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   392
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   393
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   394
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   395
(*** proving equality of sets and functions using ntrunc ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   396
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   397
lemma ntrunc_subsetI: "ntrunc k M <= M"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   398
by (auto simp add: ntrunc_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   399
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   400
lemma ntrunc_subsetD: "(!!k. ntrunc k M <= N) ==> M<=N"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   401
by (auto simp add: ntrunc_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   402
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   403
(*A generalized form of the take-lemma*)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   404
lemma ntrunc_equality: "(!!k. ntrunc k M = ntrunc k N) ==> M=N"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   405
apply (rule equalityI)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   406
apply (rule_tac [!] ntrunc_subsetD)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   407
apply (rule_tac [!] ntrunc_subsetI [THEN [2] subset_trans], auto) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   408
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   409
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   410
lemma ntrunc_o_equality: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   411
    "[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   412
apply (rule ntrunc_equality [THEN ext])
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   413
apply (simp add: expand_fun_eq) 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   414
done
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   415
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   416
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   417
(*** Monotonicity ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   418
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   419
lemma uprod_mono: "[| A<=A';  B<=B' |] ==> uprod A B <= uprod A' B'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   420
by (simp add: uprod_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   421
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   422
lemma usum_mono: "[| A<=A';  B<=B' |] ==> usum A B <= usum A' B'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   423
by (simp add: usum_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   424
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   425
lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   426
by (simp add: Scons_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   427
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   428
lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   429
by (simp add: In0_def subset_refl Scons_mono)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   430
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   431
lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   432
by (simp add: In1_def subset_refl Scons_mono)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   433
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   434
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   435
(*** Split and Case ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   436
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   437
lemma Split [simp]: "Split c (Scons M N) = c M N"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   438
by (simp add: Split_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   439
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   440
lemma Case_In0 [simp]: "Case c d (In0 M) = c(M)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   441
by (simp add: Case_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   442
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   443
lemma Case_In1 [simp]: "Case c d (In1 N) = d(N)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   444
by (simp add: Case_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   445
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   446
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   447
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   448
(**** UN x. B(x) rules ****)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   449
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   450
lemma ntrunc_UN1: "ntrunc k (UN x. f(x)) = (UN x. ntrunc k (f x))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   451
by (simp add: ntrunc_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   452
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   453
lemma Scons_UN1_x: "Scons (UN x. f x) M = (UN x. Scons (f x) M)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   454
by (simp add: Scons_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   455
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   456
lemma Scons_UN1_y: "Scons M (UN x. f x) = (UN x. Scons M (f x))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   457
by (simp add: Scons_def, blast)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   458
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   459
lemma In0_UN1: "In0(UN x. f(x)) = (UN x. In0(f(x)))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   460
by (simp add: In0_def Scons_UN1_y)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   461
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   462
lemma In1_UN1: "In1(UN x. f(x)) = (UN x. In1(f(x)))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   463
by (simp add: In1_def Scons_UN1_y)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   464
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   465
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   466
(*** Equality for Cartesian Product ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   467
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   468
lemma dprodI [intro!]: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   469
    "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : dprod r s"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   470
by (auto simp add: dprod_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   471
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   472
(*The general elimination rule*)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   473
lemma dprodE [elim!]: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   474
    "[| c : dprod r s;   
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   475
        !!x y x' y'. [| (x,x') : r;  (y,y') : s;  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   476
                        c = (Scons x y, Scons x' y') |] ==> P  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   477
     |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   478
by (auto simp add: dprod_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   479
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   480
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   481
(*** Equality for Disjoint Sum ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   482
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   483
lemma dsum_In0I [intro]: "(M,M'):r ==> (In0(M), In0(M')) : dsum r s"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   484
by (auto simp add: dsum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   485
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   486
lemma dsum_In1I [intro]: "(N,N'):s ==> (In1(N), In1(N')) : dsum r s"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   487
by (auto simp add: dsum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   488
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   489
lemma dsumE [elim!]: 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   490
    "[| w : dsum r s;   
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   491
        !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P;  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   492
        !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P  
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   493
     |] ==> P"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   494
by (auto simp add: dsum_def)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   495
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   496
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   497
(*** Monotonicity ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   498
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   499
lemma dprod_mono: "[| r<=r';  s<=s' |] ==> dprod r s <= dprod r' s'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   500
by blast
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   501
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   502
lemma dsum_mono: "[| r<=r';  s<=s' |] ==> dsum r s <= dsum r' s'"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   503
by blast
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   504
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   505
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   506
(*** Bounding theorems ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   507
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   508
lemma dprod_Sigma: "(dprod (A <*> B) (C <*> D)) <= (uprod A C) <*> (uprod B D)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   509
by blast
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   510
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   511
lemmas dprod_subset_Sigma = subset_trans [OF dprod_mono dprod_Sigma, standard]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   512
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   513
(*Dependent version*)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   514
lemma dprod_subset_Sigma2:
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   515
     "(dprod (Sigma A B) (Sigma C D)) <= 
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   516
      Sigma (uprod A C) (Split (%x y. uprod (B x) (D y)))"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   517
by auto
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   518
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   519
lemma dsum_Sigma: "(dsum (A <*> B) (C <*> D)) <= (usum A C) <*> (usum B D)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   520
by blast
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   521
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   522
lemmas dsum_subset_Sigma = subset_trans [OF dsum_mono dsum_Sigma, standard]
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   523
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   524
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   525
(*** Domain ***)
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   526
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   527
lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   528
by auto
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   529
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   530
lemma Domain_dsum [simp]: "Domain (dsum r s) = usum (Domain r) (Domain s)"
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   531
by auto
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   532
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   533
ML
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   534
{*
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   535
val apfst_conv = thm "apfst_conv";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   536
val apfst_convE = thm "apfst_convE";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   537
val Push_inject1 = thm "Push_inject1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   538
val Push_inject2 = thm "Push_inject2";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   539
val Push_inject = thm "Push_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   540
val Push_neq_K0 = thm "Push_neq_K0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   541
val Abs_Node_inj = thm "Abs_Node_inj";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   542
val Node_K0_I = thm "Node_K0_I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   543
val Node_Push_I = thm "Node_Push_I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   544
val Scons_not_Atom = thm "Scons_not_Atom";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   545
val Atom_not_Scons = thm "Atom_not_Scons";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   546
val inj_Atom = thm "inj_Atom";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   547
val Atom_inject = thm "Atom_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   548
val Atom_Atom_eq = thm "Atom_Atom_eq";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   549
val inj_Leaf = thm "inj_Leaf";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   550
val Leaf_inject = thm "Leaf_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   551
val inj_Numb = thm "inj_Numb";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   552
val Numb_inject = thm "Numb_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   553
val Push_Node_inject = thm "Push_Node_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   554
val Scons_inject1 = thm "Scons_inject1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   555
val Scons_inject2 = thm "Scons_inject2";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   556
val Scons_inject = thm "Scons_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   557
val Scons_Scons_eq = thm "Scons_Scons_eq";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   558
val Scons_not_Leaf = thm "Scons_not_Leaf";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   559
val Leaf_not_Scons = thm "Leaf_not_Scons";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   560
val Scons_not_Numb = thm "Scons_not_Numb";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   561
val Numb_not_Scons = thm "Numb_not_Scons";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   562
val Leaf_not_Numb = thm "Leaf_not_Numb";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   563
val Numb_not_Leaf = thm "Numb_not_Leaf";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   564
val ndepth_K0 = thm "ndepth_K0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   565
val ndepth_Push_Node_aux = thm "ndepth_Push_Node_aux";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   566
val ndepth_Push_Node = thm "ndepth_Push_Node";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   567
val ntrunc_0 = thm "ntrunc_0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   568
val ntrunc_Atom = thm "ntrunc_Atom";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   569
val ntrunc_Leaf = thm "ntrunc_Leaf";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   570
val ntrunc_Numb = thm "ntrunc_Numb";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   571
val ntrunc_Scons = thm "ntrunc_Scons";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   572
val ntrunc_one_In0 = thm "ntrunc_one_In0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   573
val ntrunc_In0 = thm "ntrunc_In0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   574
val ntrunc_one_In1 = thm "ntrunc_one_In1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   575
val ntrunc_In1 = thm "ntrunc_In1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   576
val uprodI = thm "uprodI";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   577
val uprodE = thm "uprodE";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   578
val uprodE2 = thm "uprodE2";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   579
val usum_In0I = thm "usum_In0I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   580
val usum_In1I = thm "usum_In1I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   581
val usumE = thm "usumE";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   582
val In0_not_In1 = thm "In0_not_In1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   583
val In1_not_In0 = thm "In1_not_In0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   584
val In0_inject = thm "In0_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   585
val In1_inject = thm "In1_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   586
val In0_eq = thm "In0_eq";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   587
val In1_eq = thm "In1_eq";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   588
val inj_In0 = thm "inj_In0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   589
val inj_In1 = thm "inj_In1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   590
val Lim_inject = thm "Lim_inject";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   591
val ntrunc_subsetI = thm "ntrunc_subsetI";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   592
val ntrunc_subsetD = thm "ntrunc_subsetD";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   593
val ntrunc_equality = thm "ntrunc_equality";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   594
val ntrunc_o_equality = thm "ntrunc_o_equality";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   595
val uprod_mono = thm "uprod_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   596
val usum_mono = thm "usum_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   597
val Scons_mono = thm "Scons_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   598
val In0_mono = thm "In0_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   599
val In1_mono = thm "In1_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   600
val Split = thm "Split";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   601
val Case_In0 = thm "Case_In0";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   602
val Case_In1 = thm "Case_In1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   603
val ntrunc_UN1 = thm "ntrunc_UN1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   604
val Scons_UN1_x = thm "Scons_UN1_x";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   605
val Scons_UN1_y = thm "Scons_UN1_y";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   606
val In0_UN1 = thm "In0_UN1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   607
val In1_UN1 = thm "In1_UN1";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   608
val dprodI = thm "dprodI";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   609
val dprodE = thm "dprodE";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   610
val dsum_In0I = thm "dsum_In0I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   611
val dsum_In1I = thm "dsum_In1I";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   612
val dsumE = thm "dsumE";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   613
val dprod_mono = thm "dprod_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   614
val dsum_mono = thm "dsum_mono";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   615
val dprod_Sigma = thm "dprod_Sigma";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   616
val dprod_subset_Sigma = thm "dprod_subset_Sigma";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   617
val dprod_subset_Sigma2 = thm "dprod_subset_Sigma2";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   618
val dsum_Sigma = thm "dsum_Sigma";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   619
val dsum_subset_Sigma = thm "dsum_subset_Sigma";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   620
val Domain_dprod = thm "Domain_dprod";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   621
val Domain_dsum = thm "Domain_dsum";
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   622
*}
aa785cea8fff converted Datatype_Universe to new-style theory
paulson
parents: 13636
diff changeset
   623
10213
01c2744a3786 *** empty log message ***
nipkow
parents:
diff changeset
   624
end