src/HOL/Library/Old_Datatype.thy
 author wenzelm Sun Nov 02 17:20:45 2014 +0100 (2014-11-02) changeset 58881 b9556a055632 parent 58390 b74d8470b98e child 60500 903bb1495239 permissions -rw-r--r--
```     1 (*  Title:      HOL/Library/Old_Datatype.thy
```
```     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
```
```     3     Author:     Stefan Berghofer and Markus Wenzel, TU Muenchen
```
```     4 *)
```
```     5
```
```     6 section {* Old Datatype package: constructing datatypes from Cartesian Products and Disjoint Sums *}
```
```     7
```
```     8 theory Old_Datatype
```
```     9 imports "../Main"
```
```    10 keywords "old_datatype" :: thy_decl
```
```    11 begin
```
```    12
```
```    13 ML_file "~~/src/HOL/Tools/datatype_realizer.ML"
```
```    14
```
```    15
```
```    16 subsection {* The datatype universe *}
```
```    17
```
```    18 definition "Node = {p. EX f x k. p = (f :: nat => 'b + nat, x ::'a + nat) & f k = Inr 0}"
```
```    19
```
```    20 typedef ('a, 'b) node = "Node :: ((nat => 'b + nat) * ('a + nat)) set"
```
```    21   morphisms Rep_Node Abs_Node
```
```    22   unfolding Node_def by auto
```
```    23
```
```    24 text{*Datatypes will be represented by sets of type @{text node}*}
```
```    25
```
```    26 type_synonym 'a item        = "('a, unit) node set"
```
```    27 type_synonym ('a, 'b) dtree = "('a, 'b) node set"
```
```    28
```
```    29 consts
```
```    30   Push      :: "[('b + nat), nat => ('b + nat)] => (nat => ('b + nat))"
```
```    31
```
```    32   Push_Node :: "[('b + nat), ('a, 'b) node] => ('a, 'b) node"
```
```    33   ndepth    :: "('a, 'b) node => nat"
```
```    34
```
```    35   Atom      :: "('a + nat) => ('a, 'b) dtree"
```
```    36   Leaf      :: "'a => ('a, 'b) dtree"
```
```    37   Numb      :: "nat => ('a, 'b) dtree"
```
```    38   Scons     :: "[('a, 'b) dtree, ('a, 'b) dtree] => ('a, 'b) dtree"
```
```    39   In0       :: "('a, 'b) dtree => ('a, 'b) dtree"
```
```    40   In1       :: "('a, 'b) dtree => ('a, 'b) dtree"
```
```    41   Lim       :: "('b => ('a, 'b) dtree) => ('a, 'b) dtree"
```
```    42
```
```    43   ntrunc    :: "[nat, ('a, 'b) dtree] => ('a, 'b) dtree"
```
```    44
```
```    45   uprod     :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
```
```    46   usum      :: "[('a, 'b) dtree set, ('a, 'b) dtree set]=> ('a, 'b) dtree set"
```
```    47
```
```    48   Split     :: "[[('a, 'b) dtree, ('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
```
```    49   Case      :: "[[('a, 'b) dtree]=>'c, [('a, 'b) dtree]=>'c, ('a, 'b) dtree] => 'c"
```
```    50
```
```    51   dprod     :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
```
```    52                 => (('a, 'b) dtree * ('a, 'b) dtree)set"
```
```    53   dsum      :: "[(('a, 'b) dtree * ('a, 'b) dtree)set, (('a, 'b) dtree * ('a, 'b) dtree)set]
```
```    54                 => (('a, 'b) dtree * ('a, 'b) dtree)set"
```
```    55
```
```    56
```
```    57 defs
```
```    58
```
```    59   Push_Node_def:  "Push_Node == (%n x. Abs_Node (apfst (Push n) (Rep_Node x)))"
```
```    60
```
```    61   (*crude "lists" of nats -- needed for the constructions*)
```
```    62   Push_def:   "Push == (%b h. case_nat b h)"
```
```    63
```
```    64   (** operations on S-expressions -- sets of nodes **)
```
```    65
```
```    66   (*S-expression constructors*)
```
```    67   Atom_def:   "Atom == (%x. {Abs_Node((%k. Inr 0, x))})"
```
```    68   Scons_def:  "Scons M N == (Push_Node (Inr 1) ` M) Un (Push_Node (Inr (Suc 1)) ` N)"
```
```    69
```
```    70   (*Leaf nodes, with arbitrary or nat labels*)
```
```    71   Leaf_def:   "Leaf == Atom o Inl"
```
```    72   Numb_def:   "Numb == Atom o Inr"
```
```    73
```
```    74   (*Injections of the "disjoint sum"*)
```
```    75   In0_def:    "In0(M) == Scons (Numb 0) M"
```
```    76   In1_def:    "In1(M) == Scons (Numb 1) M"
```
```    77
```
```    78   (*Function spaces*)
```
```    79   Lim_def: "Lim f == Union {z. ? x. z = Push_Node (Inl x) ` (f x)}"
```
```    80
```
```    81   (*the set of nodes with depth less than k*)
```
```    82   ndepth_def: "ndepth(n) == (%(f,x). LEAST k. f k = Inr 0) (Rep_Node n)"
```
```    83   ntrunc_def: "ntrunc k N == {n. n:N & ndepth(n)<k}"
```
```    84
```
```    85   (*products and sums for the "universe"*)
```
```    86   uprod_def:  "uprod A B == UN x:A. UN y:B. { Scons x y }"
```
```    87   usum_def:   "usum A B == In0`A Un In1`B"
```
```    88
```
```    89   (*the corresponding eliminators*)
```
```    90   Split_def:  "Split c M == THE u. EX x y. M = Scons x y & u = c x y"
```
```    91
```
```    92   Case_def:   "Case c d M == THE u.  (EX x . M = In0(x) & u = c(x))
```
```    93                                   | (EX y . M = In1(y) & u = d(y))"
```
```    94
```
```    95
```
```    96   (** equality for the "universe" **)
```
```    97
```
```    98   dprod_def:  "dprod r s == UN (x,x'):r. UN (y,y'):s. {(Scons x y, Scons x' y')}"
```
```    99
```
```   100   dsum_def:   "dsum r s == (UN (x,x'):r. {(In0(x),In0(x'))}) Un
```
```   101                           (UN (y,y'):s. {(In1(y),In1(y'))})"
```
```   102
```
```   103
```
```   104
```
```   105 lemma apfst_convE:
```
```   106     "[| q = apfst f p;  !!x y. [| p = (x,y);  q = (f(x),y) |] ==> R
```
```   107      |] ==> R"
```
```   108 by (force simp add: apfst_def)
```
```   109
```
```   110 (** Push -- an injection, analogous to Cons on lists **)
```
```   111
```
```   112 lemma Push_inject1: "Push i f = Push j g  ==> i=j"
```
```   113 apply (simp add: Push_def fun_eq_iff)
```
```   114 apply (drule_tac x=0 in spec, simp)
```
```   115 done
```
```   116
```
```   117 lemma Push_inject2: "Push i f = Push j g  ==> f=g"
```
```   118 apply (auto simp add: Push_def fun_eq_iff)
```
```   119 apply (drule_tac x="Suc x" in spec, simp)
```
```   120 done
```
```   121
```
```   122 lemma Push_inject:
```
```   123     "[| Push i f =Push j g;  [| i=j;  f=g |] ==> P |] ==> P"
```
```   124 by (blast dest: Push_inject1 Push_inject2)
```
```   125
```
```   126 lemma Push_neq_K0: "Push (Inr (Suc k)) f = (%z. Inr 0) ==> P"
```
```   127 by (auto simp add: Push_def fun_eq_iff split: nat.split_asm)
```
```   128
```
```   129 lemmas Abs_Node_inj = Abs_Node_inject [THEN [2] rev_iffD1]
```
```   130
```
```   131
```
```   132 (*** Introduction rules for Node ***)
```
```   133
```
```   134 lemma Node_K0_I: "(%k. Inr 0, a) : Node"
```
```   135 by (simp add: Node_def)
```
```   136
```
```   137 lemma Node_Push_I: "p: Node ==> apfst (Push i) p : Node"
```
```   138 apply (simp add: Node_def Push_def)
```
```   139 apply (fast intro!: apfst_conv nat.case(2)[THEN trans])
```
```   140 done
```
```   141
```
```   142
```
```   143 subsection{*Freeness: Distinctness of Constructors*}
```
```   144
```
```   145 (** Scons vs Atom **)
```
```   146
```
```   147 lemma Scons_not_Atom [iff]: "Scons M N \<noteq> Atom(a)"
```
```   148 unfolding Atom_def Scons_def Push_Node_def One_nat_def
```
```   149 by (blast intro: Node_K0_I Rep_Node [THEN Node_Push_I]
```
```   150          dest!: Abs_Node_inj
```
```   151          elim!: apfst_convE sym [THEN Push_neq_K0])
```
```   152
```
```   153 lemmas Atom_not_Scons [iff] = Scons_not_Atom [THEN not_sym]
```
```   154
```
```   155
```
```   156 (*** Injectiveness ***)
```
```   157
```
```   158 (** Atomic nodes **)
```
```   159
```
```   160 lemma inj_Atom: "inj(Atom)"
```
```   161 apply (simp add: Atom_def)
```
```   162 apply (blast intro!: inj_onI Node_K0_I dest!: Abs_Node_inj)
```
```   163 done
```
```   164 lemmas Atom_inject = inj_Atom [THEN injD]
```
```   165
```
```   166 lemma Atom_Atom_eq [iff]: "(Atom(a)=Atom(b)) = (a=b)"
```
```   167 by (blast dest!: Atom_inject)
```
```   168
```
```   169 lemma inj_Leaf: "inj(Leaf)"
```
```   170 apply (simp add: Leaf_def o_def)
```
```   171 apply (rule inj_onI)
```
```   172 apply (erule Atom_inject [THEN Inl_inject])
```
```   173 done
```
```   174
```
```   175 lemmas Leaf_inject [dest!] = inj_Leaf [THEN injD]
```
```   176
```
```   177 lemma inj_Numb: "inj(Numb)"
```
```   178 apply (simp add: Numb_def o_def)
```
```   179 apply (rule inj_onI)
```
```   180 apply (erule Atom_inject [THEN Inr_inject])
```
```   181 done
```
```   182
```
```   183 lemmas Numb_inject [dest!] = inj_Numb [THEN injD]
```
```   184
```
```   185
```
```   186 (** Injectiveness of Push_Node **)
```
```   187
```
```   188 lemma Push_Node_inject:
```
```   189     "[| Push_Node i m =Push_Node j n;  [| i=j;  m=n |] ==> P
```
```   190      |] ==> P"
```
```   191 apply (simp add: Push_Node_def)
```
```   192 apply (erule Abs_Node_inj [THEN apfst_convE])
```
```   193 apply (rule Rep_Node [THEN Node_Push_I])+
```
```   194 apply (erule sym [THEN apfst_convE])
```
```   195 apply (blast intro: Rep_Node_inject [THEN iffD1] trans sym elim!: Push_inject)
```
```   196 done
```
```   197
```
```   198
```
```   199 (** Injectiveness of Scons **)
```
```   200
```
```   201 lemma Scons_inject_lemma1: "Scons M N <= Scons M' N' ==> M<=M'"
```
```   202 unfolding Scons_def One_nat_def
```
```   203 by (blast dest!: Push_Node_inject)
```
```   204
```
```   205 lemma Scons_inject_lemma2: "Scons M N <= Scons M' N' ==> N<=N'"
```
```   206 unfolding Scons_def One_nat_def
```
```   207 by (blast dest!: Push_Node_inject)
```
```   208
```
```   209 lemma Scons_inject1: "Scons M N = Scons M' N' ==> M=M'"
```
```   210 apply (erule equalityE)
```
```   211 apply (iprover intro: equalityI Scons_inject_lemma1)
```
```   212 done
```
```   213
```
```   214 lemma Scons_inject2: "Scons M N = Scons M' N' ==> N=N'"
```
```   215 apply (erule equalityE)
```
```   216 apply (iprover intro: equalityI Scons_inject_lemma2)
```
```   217 done
```
```   218
```
```   219 lemma Scons_inject:
```
```   220     "[| Scons M N = Scons M' N';  [| M=M';  N=N' |] ==> P |] ==> P"
```
```   221 by (iprover dest: Scons_inject1 Scons_inject2)
```
```   222
```
```   223 lemma Scons_Scons_eq [iff]: "(Scons M N = Scons M' N') = (M=M' & N=N')"
```
```   224 by (blast elim!: Scons_inject)
```
```   225
```
```   226 (*** Distinctness involving Leaf and Numb ***)
```
```   227
```
```   228 (** Scons vs Leaf **)
```
```   229
```
```   230 lemma Scons_not_Leaf [iff]: "Scons M N \<noteq> Leaf(a)"
```
```   231 unfolding Leaf_def o_def by (rule Scons_not_Atom)
```
```   232
```
```   233 lemmas Leaf_not_Scons  [iff] = Scons_not_Leaf [THEN not_sym]
```
```   234
```
```   235 (** Scons vs Numb **)
```
```   236
```
```   237 lemma Scons_not_Numb [iff]: "Scons M N \<noteq> Numb(k)"
```
```   238 unfolding Numb_def o_def by (rule Scons_not_Atom)
```
```   239
```
```   240 lemmas Numb_not_Scons [iff] = Scons_not_Numb [THEN not_sym]
```
```   241
```
```   242
```
```   243 (** Leaf vs Numb **)
```
```   244
```
```   245 lemma Leaf_not_Numb [iff]: "Leaf(a) \<noteq> Numb(k)"
```
```   246 by (simp add: Leaf_def Numb_def)
```
```   247
```
```   248 lemmas Numb_not_Leaf [iff] = Leaf_not_Numb [THEN not_sym]
```
```   249
```
```   250
```
```   251 (*** ndepth -- the depth of a node ***)
```
```   252
```
```   253 lemma ndepth_K0: "ndepth (Abs_Node(%k. Inr 0, x)) = 0"
```
```   254 by (simp add: ndepth_def  Node_K0_I [THEN Abs_Node_inverse] Least_equality)
```
```   255
```
```   256 lemma ndepth_Push_Node_aux:
```
```   257      "case_nat (Inr (Suc i)) f k = Inr 0 --> Suc(LEAST x. f x = Inr 0) <= k"
```
```   258 apply (induct_tac "k", auto)
```
```   259 apply (erule Least_le)
```
```   260 done
```
```   261
```
```   262 lemma ndepth_Push_Node:
```
```   263     "ndepth (Push_Node (Inr (Suc i)) n) = Suc(ndepth(n))"
```
```   264 apply (insert Rep_Node [of n, unfolded Node_def])
```
```   265 apply (auto simp add: ndepth_def Push_Node_def
```
```   266                  Rep_Node [THEN Node_Push_I, THEN Abs_Node_inverse])
```
```   267 apply (rule Least_equality)
```
```   268 apply (auto simp add: Push_def ndepth_Push_Node_aux)
```
```   269 apply (erule LeastI)
```
```   270 done
```
```   271
```
```   272
```
```   273 (*** ntrunc applied to the various node sets ***)
```
```   274
```
```   275 lemma ntrunc_0 [simp]: "ntrunc 0 M = {}"
```
```   276 by (simp add: ntrunc_def)
```
```   277
```
```   278 lemma ntrunc_Atom [simp]: "ntrunc (Suc k) (Atom a) = Atom(a)"
```
```   279 by (auto simp add: Atom_def ntrunc_def ndepth_K0)
```
```   280
```
```   281 lemma ntrunc_Leaf [simp]: "ntrunc (Suc k) (Leaf a) = Leaf(a)"
```
```   282 unfolding Leaf_def o_def by (rule ntrunc_Atom)
```
```   283
```
```   284 lemma ntrunc_Numb [simp]: "ntrunc (Suc k) (Numb i) = Numb(i)"
```
```   285 unfolding Numb_def o_def by (rule ntrunc_Atom)
```
```   286
```
```   287 lemma ntrunc_Scons [simp]:
```
```   288     "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)"
```
```   289 unfolding Scons_def ntrunc_def One_nat_def
```
```   290 by (auto simp add: ndepth_Push_Node)
```
```   291
```
```   292
```
```   293
```
```   294 (** Injection nodes **)
```
```   295
```
```   296 lemma ntrunc_one_In0 [simp]: "ntrunc (Suc 0) (In0 M) = {}"
```
```   297 apply (simp add: In0_def)
```
```   298 apply (simp add: Scons_def)
```
```   299 done
```
```   300
```
```   301 lemma ntrunc_In0 [simp]: "ntrunc (Suc(Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)"
```
```   302 by (simp add: In0_def)
```
```   303
```
```   304 lemma ntrunc_one_In1 [simp]: "ntrunc (Suc 0) (In1 M) = {}"
```
```   305 apply (simp add: In1_def)
```
```   306 apply (simp add: Scons_def)
```
```   307 done
```
```   308
```
```   309 lemma ntrunc_In1 [simp]: "ntrunc (Suc(Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)"
```
```   310 by (simp add: In1_def)
```
```   311
```
```   312
```
```   313 subsection{*Set Constructions*}
```
```   314
```
```   315
```
```   316 (*** Cartesian Product ***)
```
```   317
```
```   318 lemma uprodI [intro!]: "[| M:A;  N:B |] ==> Scons M N : uprod A B"
```
```   319 by (simp add: uprod_def)
```
```   320
```
```   321 (*The general elimination rule*)
```
```   322 lemma uprodE [elim!]:
```
```   323     "[| c : uprod A B;
```
```   324         !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P
```
```   325      |] ==> P"
```
```   326 by (auto simp add: uprod_def)
```
```   327
```
```   328
```
```   329 (*Elimination of a pair -- introduces no eigenvariables*)
```
```   330 lemma uprodE2: "[| Scons M N : uprod A B;  [| M:A;  N:B |] ==> P |] ==> P"
```
```   331 by (auto simp add: uprod_def)
```
```   332
```
```   333
```
```   334 (*** Disjoint Sum ***)
```
```   335
```
```   336 lemma usum_In0I [intro]: "M:A ==> In0(M) : usum A B"
```
```   337 by (simp add: usum_def)
```
```   338
```
```   339 lemma usum_In1I [intro]: "N:B ==> In1(N) : usum A B"
```
```   340 by (simp add: usum_def)
```
```   341
```
```   342 lemma usumE [elim!]:
```
```   343     "[| u : usum A B;
```
```   344         !!x. [| x:A;  u=In0(x) |] ==> P;
```
```   345         !!y. [| y:B;  u=In1(y) |] ==> P
```
```   346      |] ==> P"
```
```   347 by (auto simp add: usum_def)
```
```   348
```
```   349
```
```   350 (** Injection **)
```
```   351
```
```   352 lemma In0_not_In1 [iff]: "In0(M) \<noteq> In1(N)"
```
```   353 unfolding In0_def In1_def One_nat_def by auto
```
```   354
```
```   355 lemmas In1_not_In0 [iff] = In0_not_In1 [THEN not_sym]
```
```   356
```
```   357 lemma In0_inject: "In0(M) = In0(N) ==>  M=N"
```
```   358 by (simp add: In0_def)
```
```   359
```
```   360 lemma In1_inject: "In1(M) = In1(N) ==>  M=N"
```
```   361 by (simp add: In1_def)
```
```   362
```
```   363 lemma In0_eq [iff]: "(In0 M = In0 N) = (M=N)"
```
```   364 by (blast dest!: In0_inject)
```
```   365
```
```   366 lemma In1_eq [iff]: "(In1 M = In1 N) = (M=N)"
```
```   367 by (blast dest!: In1_inject)
```
```   368
```
```   369 lemma inj_In0: "inj In0"
```
```   370 by (blast intro!: inj_onI)
```
```   371
```
```   372 lemma inj_In1: "inj In1"
```
```   373 by (blast intro!: inj_onI)
```
```   374
```
```   375
```
```   376 (*** Function spaces ***)
```
```   377
```
```   378 lemma Lim_inject: "Lim f = Lim g ==> f = g"
```
```   379 apply (simp add: Lim_def)
```
```   380 apply (rule ext)
```
```   381 apply (blast elim!: Push_Node_inject)
```
```   382 done
```
```   383
```
```   384
```
```   385 (*** proving equality of sets and functions using ntrunc ***)
```
```   386
```
```   387 lemma ntrunc_subsetI: "ntrunc k M <= M"
```
```   388 by (auto simp add: ntrunc_def)
```
```   389
```
```   390 lemma ntrunc_subsetD: "(!!k. ntrunc k M <= N) ==> M<=N"
```
```   391 by (auto simp add: ntrunc_def)
```
```   392
```
```   393 (*A generalized form of the take-lemma*)
```
```   394 lemma ntrunc_equality: "(!!k. ntrunc k M = ntrunc k N) ==> M=N"
```
```   395 apply (rule equalityI)
```
```   396 apply (rule_tac [!] ntrunc_subsetD)
```
```   397 apply (rule_tac [!] ntrunc_subsetI [THEN [2] subset_trans], auto)
```
```   398 done
```
```   399
```
```   400 lemma ntrunc_o_equality:
```
```   401     "[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2"
```
```   402 apply (rule ntrunc_equality [THEN ext])
```
```   403 apply (simp add: fun_eq_iff)
```
```   404 done
```
```   405
```
```   406
```
```   407 (*** Monotonicity ***)
```
```   408
```
```   409 lemma uprod_mono: "[| A<=A';  B<=B' |] ==> uprod A B <= uprod A' B'"
```
```   410 by (simp add: uprod_def, blast)
```
```   411
```
```   412 lemma usum_mono: "[| A<=A';  B<=B' |] ==> usum A B <= usum A' B'"
```
```   413 by (simp add: usum_def, blast)
```
```   414
```
```   415 lemma Scons_mono: "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'"
```
```   416 by (simp add: Scons_def, blast)
```
```   417
```
```   418 lemma In0_mono: "M<=N ==> In0(M) <= In0(N)"
```
```   419 by (simp add: In0_def Scons_mono)
```
```   420
```
```   421 lemma In1_mono: "M<=N ==> In1(M) <= In1(N)"
```
```   422 by (simp add: In1_def Scons_mono)
```
```   423
```
```   424
```
```   425 (*** Split and Case ***)
```
```   426
```
```   427 lemma Split [simp]: "Split c (Scons M N) = c M N"
```
```   428 by (simp add: Split_def)
```
```   429
```
```   430 lemma Case_In0 [simp]: "Case c d (In0 M) = c(M)"
```
```   431 by (simp add: Case_def)
```
```   432
```
```   433 lemma Case_In1 [simp]: "Case c d (In1 N) = d(N)"
```
```   434 by (simp add: Case_def)
```
```   435
```
```   436
```
```   437
```
```   438 (**** UN x. B(x) rules ****)
```
```   439
```
```   440 lemma ntrunc_UN1: "ntrunc k (UN x. f(x)) = (UN x. ntrunc k (f x))"
```
```   441 by (simp add: ntrunc_def, blast)
```
```   442
```
```   443 lemma Scons_UN1_x: "Scons (UN x. f x) M = (UN x. Scons (f x) M)"
```
```   444 by (simp add: Scons_def, blast)
```
```   445
```
```   446 lemma Scons_UN1_y: "Scons M (UN x. f x) = (UN x. Scons M (f x))"
```
```   447 by (simp add: Scons_def, blast)
```
```   448
```
```   449 lemma In0_UN1: "In0(UN x. f(x)) = (UN x. In0(f(x)))"
```
```   450 by (simp add: In0_def Scons_UN1_y)
```
```   451
```
```   452 lemma In1_UN1: "In1(UN x. f(x)) = (UN x. In1(f(x)))"
```
```   453 by (simp add: In1_def Scons_UN1_y)
```
```   454
```
```   455
```
```   456 (*** Equality for Cartesian Product ***)
```
```   457
```
```   458 lemma dprodI [intro!]:
```
```   459     "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : dprod r s"
```
```   460 by (auto simp add: dprod_def)
```
```   461
```
```   462 (*The general elimination rule*)
```
```   463 lemma dprodE [elim!]:
```
```   464     "[| c : dprod r s;
```
```   465         !!x y x' y'. [| (x,x') : r;  (y,y') : s;
```
```   466                         c = (Scons x y, Scons x' y') |] ==> P
```
```   467      |] ==> P"
```
```   468 by (auto simp add: dprod_def)
```
```   469
```
```   470
```
```   471 (*** Equality for Disjoint Sum ***)
```
```   472
```
```   473 lemma dsum_In0I [intro]: "(M,M'):r ==> (In0(M), In0(M')) : dsum r s"
```
```   474 by (auto simp add: dsum_def)
```
```   475
```
```   476 lemma dsum_In1I [intro]: "(N,N'):s ==> (In1(N), In1(N')) : dsum r s"
```
```   477 by (auto simp add: dsum_def)
```
```   478
```
```   479 lemma dsumE [elim!]:
```
```   480     "[| w : dsum r s;
```
```   481         !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P;
```
```   482         !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P
```
```   483      |] ==> P"
```
```   484 by (auto simp add: dsum_def)
```
```   485
```
```   486
```
```   487 (*** Monotonicity ***)
```
```   488
```
```   489 lemma dprod_mono: "[| r<=r';  s<=s' |] ==> dprod r s <= dprod r' s'"
```
```   490 by blast
```
```   491
```
```   492 lemma dsum_mono: "[| r<=r';  s<=s' |] ==> dsum r s <= dsum r' s'"
```
```   493 by blast
```
```   494
```
```   495
```
```   496 (*** Bounding theorems ***)
```
```   497
```
```   498 lemma dprod_Sigma: "(dprod (A <*> B) (C <*> D)) <= (uprod A C) <*> (uprod B D)"
```
```   499 by blast
```
```   500
```
```   501 lemmas dprod_subset_Sigma = subset_trans [OF dprod_mono dprod_Sigma]
```
```   502
```
```   503 (*Dependent version*)
```
```   504 lemma dprod_subset_Sigma2:
```
```   505     "(dprod (Sigma A B) (Sigma C D)) <= Sigma (uprod A C) (Split (%x y. uprod (B x) (D y)))"
```
```   506 by auto
```
```   507
```
```   508 lemma dsum_Sigma: "(dsum (A <*> B) (C <*> D)) <= (usum A C) <*> (usum B D)"
```
```   509 by blast
```
```   510
```
```   511 lemmas dsum_subset_Sigma = subset_trans [OF dsum_mono dsum_Sigma]
```
```   512
```
```   513
```
```   514 (*** Domain theorems ***)
```
```   515
```
```   516 lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)"
```
```   517   by auto
```
```   518
```
```   519 lemma Domain_dsum [simp]: "Domain (dsum r s) = usum (Domain r) (Domain s)"
```
```   520   by auto
```
```   521
```
```   522
```
```   523 text {* hides popular names *}
```
```   524 hide_type (open) node item
```
```   525 hide_const (open) Push Node Atom Leaf Numb Lim Split Case
```
```   526
```
```   527 ML_file "~~/src/HOL/Tools/Old_Datatype/old_datatype.ML"
```
```   528 ML_file "~~/src/HOL/Tools/inductive_realizer.ML"
```
```   529
```
```   530 end
```