src/HOL/Univ.ML
author paulson
Thu Aug 06 15:48:13 1998 +0200 (1998-08-06)
changeset 5278 a903b66822e2
parent 5191 8ceaa19f7717
child 5316 7a8975451a89
permissions -rw-r--r--
even more tidying of Goal commands
     1 (*  Title:      HOL/Univ
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1991  University of Cambridge
     5 
     6 For univ.thy
     7 *)
     8 
     9 open Univ;
    10 
    11 (** apfst -- can be used in similar type definitions **)
    12 
    13 Goalw [apfst_def] "apfst f (a,b) = (f(a),b)";
    14 by (rtac split 1);
    15 qed "apfst_conv";
    16 
    17 val [major,minor] = goal Univ.thy
    18     "[| q = apfst f p;  !!x y. [| p = (x,y);  q = (f(x),y) |] ==> R \
    19 \    |] ==> R";
    20 by (rtac PairE 1);
    21 by (rtac minor 1);
    22 by (assume_tac 1);
    23 by (rtac (major RS trans) 1);
    24 by (etac ssubst 1);
    25 by (rtac apfst_conv 1);
    26 qed "apfst_convE";
    27 
    28 (** Push -- an injection, analogous to Cons on lists **)
    29 
    30 val [major] = goalw Univ.thy [Push_def] "Push i f = Push j g  ==> i=j";
    31 by (rtac (major RS fun_cong RS box_equals RS Suc_inject) 1);
    32 by (rtac nat_case_0 1);
    33 by (rtac nat_case_0 1);
    34 qed "Push_inject1";
    35 
    36 val [major] = goalw Univ.thy [Push_def] "Push i f = Push j g  ==> f=g";
    37 by (rtac (major RS fun_cong RS ext RS box_equals) 1);
    38 by (rtac (nat_case_Suc RS ext) 1);
    39 by (rtac (nat_case_Suc RS ext) 1);
    40 qed "Push_inject2";
    41 
    42 val [major,minor] = goal Univ.thy
    43     "[| Push i f =Push j g;  [| i=j;  f=g |] ==> P \
    44 \    |] ==> P";
    45 by (rtac ((major RS Push_inject2) RS ((major RS Push_inject1) RS minor)) 1);
    46 qed "Push_inject";
    47 
    48 val [major] = goalw Univ.thy [Push_def] "Push k f =(%z.0) ==> P";
    49 by (rtac (major RS fun_cong RS box_equals RS Suc_neq_Zero) 1);
    50 by (rtac nat_case_0 1);
    51 by (rtac refl 1);
    52 qed "Push_neq_K0";
    53 
    54 (*** Isomorphisms ***)
    55 
    56 Goal "inj(Rep_Node)";
    57 by (rtac inj_inverseI 1);       (*cannot combine by RS: multiple unifiers*)
    58 by (rtac Rep_Node_inverse 1);
    59 qed "inj_Rep_Node";
    60 
    61 Goal "inj_on Abs_Node Node";
    62 by (rtac inj_on_inverseI 1);
    63 by (etac Abs_Node_inverse 1);
    64 qed "inj_on_Abs_Node";
    65 
    66 val Abs_Node_inject = inj_on_Abs_Node RS inj_onD;
    67 
    68 
    69 (*** Introduction rules for Node ***)
    70 
    71 Goalw [Node_def] "(%k. 0,a) : Node";
    72 by (Blast_tac 1);
    73 qed "Node_K0_I";
    74 
    75 Goalw [Node_def,Push_def]
    76     "p: Node ==> apfst (Push i) p : Node";
    77 by (blast_tac (claset() addSIs [apfst_conv, nat_case_Suc RS trans]) 1);
    78 qed "Node_Push_I";
    79 
    80 
    81 (*** Distinctness of constructors ***)
    82 
    83 (** Scons vs Atom **)
    84 
    85 Goalw [Atom_def,Scons_def,Push_Node_def] "Scons M N ~= Atom(a)";
    86 by (rtac notI 1);
    87 by (etac (equalityD2 RS subsetD RS UnE) 1);
    88 by (rtac singletonI 1);
    89 by (REPEAT (eresolve_tac [imageE, Abs_Node_inject RS apfst_convE, 
    90                           Pair_inject, sym RS Push_neq_K0] 1
    91      ORELSE resolve_tac [Node_K0_I, Rep_Node RS Node_Push_I] 1));
    92 qed "Scons_not_Atom";
    93 bind_thm ("Atom_not_Scons", Scons_not_Atom RS not_sym);
    94 
    95 
    96 (*** Injectiveness ***)
    97 
    98 (** Atomic nodes **)
    99 
   100 Goalw [Atom_def, inj_def] "inj(Atom)";
   101 by (blast_tac (claset() addSIs [Node_K0_I] addSDs [Abs_Node_inject]) 1);
   102 qed "inj_Atom";
   103 val Atom_inject = inj_Atom RS injD;
   104 
   105 Goal "(Atom(a)=Atom(b)) = (a=b)";
   106 by (blast_tac (claset() addSDs [Atom_inject]) 1);
   107 qed "Atom_Atom_eq";
   108 AddIffs [Atom_Atom_eq];
   109 
   110 Goalw [Leaf_def,o_def] "inj(Leaf)";
   111 by (rtac injI 1);
   112 by (etac (Atom_inject RS Inl_inject) 1);
   113 qed "inj_Leaf";
   114 
   115 bind_thm ("Leaf_inject", inj_Leaf RS injD);
   116 AddSDs [Leaf_inject];
   117 
   118 Goalw [Numb_def,o_def] "inj(Numb)";
   119 by (rtac injI 1);
   120 by (etac (Atom_inject RS Inr_inject) 1);
   121 qed "inj_Numb";
   122 
   123 val Numb_inject = inj_Numb RS injD;
   124 AddSDs [Numb_inject];
   125 
   126 (** Injectiveness of Push_Node **)
   127 
   128 val [major,minor] = goalw Univ.thy [Push_Node_def]
   129     "[| Push_Node i m =Push_Node j n;  [| i=j;  m=n |] ==> P \
   130 \    |] ==> P";
   131 by (rtac (major RS Abs_Node_inject RS apfst_convE) 1);
   132 by (REPEAT (resolve_tac [Rep_Node RS Node_Push_I] 1));
   133 by (etac (sym RS apfst_convE) 1);
   134 by (rtac minor 1);
   135 by (etac Pair_inject 1);
   136 by (etac (Push_inject1 RS sym) 1);
   137 by (rtac (inj_Rep_Node RS injD) 1);
   138 by (etac trans 1);
   139 by (safe_tac (claset() addSEs [Push_inject,sym]));
   140 qed "Push_Node_inject";
   141 
   142 
   143 (** Injectiveness of Scons **)
   144 
   145 Goalw [Scons_def] "Scons M N <= Scons M' N' ==> M<=M'";
   146 by (blast_tac (claset() addSDs [Push_Node_inject]) 1);
   147 qed "Scons_inject_lemma1";
   148 
   149 Goalw [Scons_def] "Scons M N <= Scons M' N' ==> N<=N'";
   150 by (blast_tac (claset() addSDs [Push_Node_inject]) 1);
   151 qed "Scons_inject_lemma2";
   152 
   153 val [major] = goal Univ.thy "Scons M N = Scons M' N' ==> M=M'";
   154 by (rtac (major RS equalityE) 1);
   155 by (REPEAT (ares_tac [equalityI, Scons_inject_lemma1] 1));
   156 qed "Scons_inject1";
   157 
   158 val [major] = goal Univ.thy "Scons M N = Scons M' N' ==> N=N'";
   159 by (rtac (major RS equalityE) 1);
   160 by (REPEAT (ares_tac [equalityI, Scons_inject_lemma2] 1));
   161 qed "Scons_inject2";
   162 
   163 val [major,minor] = goal Univ.thy
   164     "[| Scons M N = Scons M' N';  [| M=M';  N=N' |] ==> P \
   165 \    |] ==> P";
   166 by (rtac ((major RS Scons_inject2) RS ((major RS Scons_inject1) RS minor)) 1);
   167 qed "Scons_inject";
   168 
   169 Goal "(Scons M N = Scons M' N') = (M=M' & N=N')";
   170 by (blast_tac (claset() addSEs [Scons_inject]) 1);
   171 qed "Scons_Scons_eq";
   172 
   173 (*** Distinctness involving Leaf and Numb ***)
   174 
   175 (** Scons vs Leaf **)
   176 
   177 Goalw [Leaf_def,o_def] "Scons M N ~= Leaf(a)";
   178 by (rtac Scons_not_Atom 1);
   179 qed "Scons_not_Leaf";
   180 bind_thm ("Leaf_not_Scons", Scons_not_Leaf RS not_sym);
   181 
   182 AddIffs [Scons_not_Leaf, Leaf_not_Scons];
   183 
   184 
   185 (** Scons vs Numb **)
   186 
   187 Goalw [Numb_def,o_def] "Scons M N ~= Numb(k)";
   188 by (rtac Scons_not_Atom 1);
   189 qed "Scons_not_Numb";
   190 bind_thm ("Numb_not_Scons", Scons_not_Numb RS not_sym);
   191 
   192 AddIffs [Scons_not_Numb, Numb_not_Scons];
   193 
   194 
   195 (** Leaf vs Numb **)
   196 
   197 Goalw [Leaf_def,Numb_def] "Leaf(a) ~= Numb(k)";
   198 by (simp_tac (simpset() addsimps [Inl_not_Inr]) 1);
   199 qed "Leaf_not_Numb";
   200 bind_thm ("Numb_not_Leaf", Leaf_not_Numb RS not_sym);
   201 
   202 AddIffs [Leaf_not_Numb, Numb_not_Leaf];
   203 
   204 
   205 (*** ndepth -- the depth of a node ***)
   206 
   207 Addsimps [apfst_conv];
   208 AddIffs  [Scons_not_Atom, Atom_not_Scons, Scons_Scons_eq];
   209 
   210 
   211 Goalw [ndepth_def] "ndepth (Abs_Node((%k.0, x))) = 0";
   212 by (EVERY1[stac (Node_K0_I RS Abs_Node_inverse), stac split]);
   213 by (rtac Least_equality 1);
   214 by (rtac refl 1);
   215 by (etac less_zeroE 1);
   216 qed "ndepth_K0";
   217 
   218 Goal "k < Suc(LEAST x. f(x)=0) --> 0 < nat_case (Suc i) f k";
   219 by (nat_ind_tac "k" 1);
   220 by (ALLGOALS Simp_tac);
   221 by (rtac impI 1);
   222 by (dtac not_less_Least 1);
   223 by (Asm_full_simp_tac 1);
   224 val lemma = result();
   225 
   226 Goalw [ndepth_def,Push_Node_def]
   227     "ndepth (Push_Node i n) = Suc(ndepth(n))";
   228 by (stac (Rep_Node RS Node_Push_I RS Abs_Node_inverse) 1);
   229 by (cut_facts_tac [rewrite_rule [Node_def] Rep_Node] 1);
   230 by Safe_tac;
   231 by (etac ssubst 1);  (*instantiates type variables!*)
   232 by (Simp_tac 1);
   233 by (rtac Least_equality 1);
   234 by (rewtac Push_def);
   235 by (rtac (nat_case_Suc RS trans) 1);
   236 by (etac LeastI 1);
   237 by (asm_simp_tac (simpset() addsimps [lemma]) 1);
   238 qed "ndepth_Push_Node";
   239 
   240 
   241 (*** ntrunc applied to the various node sets ***)
   242 
   243 Goalw [ntrunc_def] "ntrunc 0 M = {}";
   244 by (Blast_tac 1);
   245 qed "ntrunc_0";
   246 
   247 Goalw [Atom_def,ntrunc_def] "ntrunc (Suc k) (Atom a) = Atom(a)";
   248 by (fast_tac (claset() addss (simpset() addsimps [ndepth_K0])) 1);
   249 qed "ntrunc_Atom";
   250 
   251 Goalw [Leaf_def,o_def] "ntrunc (Suc k) (Leaf a) = Leaf(a)";
   252 by (rtac ntrunc_Atom 1);
   253 qed "ntrunc_Leaf";
   254 
   255 Goalw [Numb_def,o_def] "ntrunc (Suc k) (Numb i) = Numb(i)";
   256 by (rtac ntrunc_Atom 1);
   257 qed "ntrunc_Numb";
   258 
   259 Goalw [Scons_def,ntrunc_def]
   260     "ntrunc (Suc k) (Scons M N) = Scons (ntrunc k M) (ntrunc k N)";
   261 by (safe_tac (claset() addSIs [imageI]));
   262 by (REPEAT (stac ndepth_Push_Node 3 THEN etac Suc_mono 3));
   263 by (REPEAT (rtac Suc_less_SucD 1 THEN 
   264             rtac (ndepth_Push_Node RS subst) 1 THEN 
   265             assume_tac 1));
   266 qed "ntrunc_Scons";
   267 
   268 Addsimps [ntrunc_0, ntrunc_Atom, ntrunc_Leaf, ntrunc_Numb, ntrunc_Scons];
   269 
   270 
   271 (** Injection nodes **)
   272 
   273 Goalw [In0_def] "ntrunc (Suc 0) (In0 M) = {}";
   274 by (Simp_tac 1);
   275 by (rewtac Scons_def);
   276 by (Blast_tac 1);
   277 qed "ntrunc_one_In0";
   278 
   279 Goalw [In0_def]
   280     "ntrunc (Suc (Suc k)) (In0 M) = In0 (ntrunc (Suc k) M)";
   281 by (Simp_tac 1);
   282 qed "ntrunc_In0";
   283 
   284 Goalw [In1_def] "ntrunc (Suc 0) (In1 M) = {}";
   285 by (Simp_tac 1);
   286 by (rewtac Scons_def);
   287 by (Blast_tac 1);
   288 qed "ntrunc_one_In1";
   289 
   290 Goalw [In1_def]
   291     "ntrunc (Suc (Suc k)) (In1 M) = In1 (ntrunc (Suc k) M)";
   292 by (Simp_tac 1);
   293 qed "ntrunc_In1";
   294 
   295 Addsimps [ntrunc_one_In0, ntrunc_In0, ntrunc_one_In1, ntrunc_In1];
   296 
   297 
   298 (*** Cartesian Product ***)
   299 
   300 Goalw [uprod_def] "[| M:A;  N:B |] ==> Scons M N : A<*>B";
   301 by (REPEAT (ares_tac [singletonI,UN_I] 1));
   302 qed "uprodI";
   303 
   304 (*The general elimination rule*)
   305 val major::prems = goalw Univ.thy [uprod_def]
   306     "[| c : A<*>B;  \
   307 \       !!x y. [| x:A;  y:B;  c = Scons x y |] ==> P \
   308 \    |] ==> P";
   309 by (cut_facts_tac [major] 1);
   310 by (REPEAT (eresolve_tac [asm_rl,singletonE,UN_E] 1
   311      ORELSE resolve_tac prems 1));
   312 qed "uprodE";
   313 
   314 (*Elimination of a pair -- introduces no eigenvariables*)
   315 val prems = goal Univ.thy
   316     "[| Scons M N : A<*>B;      [| M:A;  N:B |] ==> P   \
   317 \    |] ==> P";
   318 by (rtac uprodE 1);
   319 by (REPEAT (ares_tac prems 1 ORELSE eresolve_tac [Scons_inject,ssubst] 1));
   320 qed "uprodE2";
   321 
   322 
   323 (*** Disjoint Sum ***)
   324 
   325 Goalw [usum_def] "M:A ==> In0(M) : A<+>B";
   326 by (Blast_tac 1);
   327 qed "usum_In0I";
   328 
   329 Goalw [usum_def] "N:B ==> In1(N) : A<+>B";
   330 by (Blast_tac 1);
   331 qed "usum_In1I";
   332 
   333 val major::prems = goalw Univ.thy [usum_def]
   334     "[| u : A<+>B;  \
   335 \       !!x. [| x:A;  u=In0(x) |] ==> P; \
   336 \       !!y. [| y:B;  u=In1(y) |] ==> P \
   337 \    |] ==> P";
   338 by (rtac (major RS UnE) 1);
   339 by (REPEAT (rtac refl 1 
   340      ORELSE eresolve_tac (prems@[imageE,ssubst]) 1));
   341 qed "usumE";
   342 
   343 
   344 (** Injection **)
   345 
   346 Goalw [In0_def,In1_def] "In0(M) ~= In1(N)";
   347 by (rtac notI 1);
   348 by (etac (Scons_inject1 RS Numb_inject RS Zero_neq_Suc) 1);
   349 qed "In0_not_In1";
   350 
   351 bind_thm ("In1_not_In0", In0_not_In1 RS not_sym);
   352 
   353 AddIffs [In0_not_In1, In1_not_In0];
   354 
   355 val [major] = goalw Univ.thy [In0_def] "In0(M) = In0(N) ==>  M=N";
   356 by (rtac (major RS Scons_inject2) 1);
   357 qed "In0_inject";
   358 
   359 val [major] = goalw Univ.thy [In1_def] "In1(M) = In1(N) ==>  M=N";
   360 by (rtac (major RS Scons_inject2) 1);
   361 qed "In1_inject";
   362 
   363 Goal "(In0 M = In0 N) = (M=N)";
   364 by (blast_tac (claset() addSDs [In0_inject]) 1);
   365 qed "In0_eq";
   366 
   367 Goal "(In1 M = In1 N) = (M=N)";
   368 by (blast_tac (claset() addSDs [In1_inject]) 1);
   369 qed "In1_eq";
   370 
   371 AddIffs [In0_eq, In1_eq];
   372 
   373 Goalw [inj_def] "inj In0";
   374 by (Blast_tac 1);
   375 qed "inj_In0";
   376 
   377 Goalw [inj_def] "inj In1";
   378 by (Blast_tac 1);
   379 qed "inj_In1";
   380 
   381 
   382 (*** proving equality of sets and functions using ntrunc ***)
   383 
   384 Goalw [ntrunc_def] "ntrunc k M <= M";
   385 by (Blast_tac 1);
   386 qed "ntrunc_subsetI";
   387 
   388 val [major] = goalw Univ.thy [ntrunc_def]
   389     "(!!k. ntrunc k M <= N) ==> M<=N";
   390 by (blast_tac (claset() addIs [less_add_Suc1, less_add_Suc2, 
   391 			       major RS subsetD]) 1);
   392 qed "ntrunc_subsetD";
   393 
   394 (*A generalized form of the take-lemma*)
   395 val [major] = goal Univ.thy "(!!k. ntrunc k M = ntrunc k N) ==> M=N";
   396 by (rtac equalityI 1);
   397 by (ALLGOALS (rtac ntrunc_subsetD));
   398 by (ALLGOALS (rtac (ntrunc_subsetI RSN (2, subset_trans))));
   399 by (rtac (major RS equalityD1) 1);
   400 by (rtac (major RS equalityD2) 1);
   401 qed "ntrunc_equality";
   402 
   403 val [major] = goalw Univ.thy [o_def]
   404     "[| !!k. (ntrunc(k) o h1) = (ntrunc(k) o h2) |] ==> h1=h2";
   405 by (rtac (ntrunc_equality RS ext) 1);
   406 by (rtac (major RS fun_cong) 1);
   407 qed "ntrunc_o_equality";
   408 
   409 (*** Monotonicity ***)
   410 
   411 Goalw [uprod_def] "[| A<=A';  B<=B' |] ==> A<*>B <= A'<*>B'";
   412 by (Blast_tac 1);
   413 qed "uprod_mono";
   414 
   415 Goalw [usum_def] "[| A<=A';  B<=B' |] ==> A<+>B <= A'<+>B'";
   416 by (Blast_tac 1);
   417 qed "usum_mono";
   418 
   419 Goalw [Scons_def] "[| M<=M';  N<=N' |] ==> Scons M N <= Scons M' N'";
   420 by (Blast_tac 1);
   421 qed "Scons_mono";
   422 
   423 Goalw [In0_def] "M<=N ==> In0(M) <= In0(N)";
   424 by (REPEAT (ares_tac [subset_refl,Scons_mono] 1));
   425 qed "In0_mono";
   426 
   427 Goalw [In1_def] "M<=N ==> In1(M) <= In1(N)";
   428 by (REPEAT (ares_tac [subset_refl,Scons_mono] 1));
   429 qed "In1_mono";
   430 
   431 
   432 (*** Split and Case ***)
   433 
   434 Goalw [Split_def] "Split c (Scons M N) = c M N";
   435 by (Blast_tac  1);
   436 qed "Split";
   437 
   438 Goalw [Case_def] "Case c d (In0 M) = c(M)";
   439 by (Blast_tac 1);
   440 qed "Case_In0";
   441 
   442 Goalw [Case_def] "Case c d (In1 N) = d(N)";
   443 by (Blast_tac 1);
   444 qed "Case_In1";
   445 
   446 Addsimps [Split, Case_In0, Case_In1];
   447 
   448 
   449 (**** UN x. B(x) rules ****)
   450 
   451 Goalw [ntrunc_def] "ntrunc k (UN x. f(x)) = (UN x. ntrunc k (f x))";
   452 by (Blast_tac 1);
   453 qed "ntrunc_UN1";
   454 
   455 Goalw [Scons_def] "Scons (UN x. f x) M = (UN x. Scons (f x) M)";
   456 by (Blast_tac 1);
   457 qed "Scons_UN1_x";
   458 
   459 Goalw [Scons_def] "Scons M (UN x. f x) = (UN x. Scons M (f x))";
   460 by (Blast_tac 1);
   461 qed "Scons_UN1_y";
   462 
   463 Goalw [In0_def] "In0(UN x. f(x)) = (UN x. In0(f(x)))";
   464 by (rtac Scons_UN1_y 1);
   465 qed "In0_UN1";
   466 
   467 Goalw [In1_def] "In1(UN x. f(x)) = (UN x. In1(f(x)))";
   468 by (rtac Scons_UN1_y 1);
   469 qed "In1_UN1";
   470 
   471 
   472 (*** Equality : the diagonal relation ***)
   473 
   474 Goalw [diag_def] "[| a=b;  a:A |] ==> (a,b) : diag(A)";
   475 by (Blast_tac 1);
   476 qed "diag_eqI";
   477 
   478 val diagI = refl RS diag_eqI |> standard;
   479 
   480 (*The general elimination rule*)
   481 val major::prems = goalw Univ.thy [diag_def]
   482     "[| c : diag(A);  \
   483 \       !!x y. [| x:A;  c = (x,x) |] ==> P \
   484 \    |] ==> P";
   485 by (rtac (major RS UN_E) 1);
   486 by (REPEAT (eresolve_tac [asm_rl,singletonE] 1 ORELSE resolve_tac prems 1));
   487 qed "diagE";
   488 
   489 (*** Equality for Cartesian Product ***)
   490 
   491 Goalw [dprod_def]
   492     "[| (M,M'):r;  (N,N'):s |] ==> (Scons M N, Scons M' N') : r<**>s";
   493 by (Blast_tac 1);
   494 qed "dprodI";
   495 
   496 (*The general elimination rule*)
   497 val major::prems = goalw Univ.thy [dprod_def]
   498     "[| c : r<**>s;  \
   499 \       !!x y x' y'. [| (x,x') : r;  (y,y') : s;  c = (Scons x y, Scons x' y') |] ==> P \
   500 \    |] ==> P";
   501 by (cut_facts_tac [major] 1);
   502 by (REPEAT_FIRST (eresolve_tac [asm_rl, UN_E, mem_splitE, singletonE]));
   503 by (REPEAT (ares_tac prems 1 ORELSE hyp_subst_tac 1));
   504 qed "dprodE";
   505 
   506 
   507 (*** Equality for Disjoint Sum ***)
   508 
   509 Goalw [dsum_def]  "(M,M'):r ==> (In0(M), In0(M')) : r<++>s";
   510 by (Blast_tac 1);
   511 qed "dsum_In0I";
   512 
   513 Goalw [dsum_def]  "(N,N'):s ==> (In1(N), In1(N')) : r<++>s";
   514 by (Blast_tac 1);
   515 qed "dsum_In1I";
   516 
   517 val major::prems = goalw Univ.thy [dsum_def]
   518     "[| w : r<++>s;  \
   519 \       !!x x'. [| (x,x') : r;  w = (In0(x), In0(x')) |] ==> P; \
   520 \       !!y y'. [| (y,y') : s;  w = (In1(y), In1(y')) |] ==> P \
   521 \    |] ==> P";
   522 by (cut_facts_tac [major] 1);
   523 by (REPEAT_FIRST (eresolve_tac [asm_rl, UN_E, UnE, mem_splitE, singletonE]));
   524 by (DEPTH_SOLVE (ares_tac prems 1 ORELSE hyp_subst_tac 1));
   525 qed "dsumE";
   526 
   527 
   528 AddSIs [diagI, uprodI, dprodI];
   529 AddIs  [usum_In0I, usum_In1I, dsum_In0I, dsum_In1I];
   530 AddSEs [diagE, uprodE, dprodE, usumE, dsumE];
   531 
   532 (*** Monotonicity ***)
   533 
   534 Goal "[| r<=r';  s<=s' |] ==> r<**>s <= r'<**>s'";
   535 by (Blast_tac 1);
   536 qed "dprod_mono";
   537 
   538 Goal "[| r<=r';  s<=s' |] ==> r<++>s <= r'<++>s'";
   539 by (Blast_tac 1);
   540 qed "dsum_mono";
   541 
   542 
   543 (*** Bounding theorems ***)
   544 
   545 Goal "diag(A) <= A Times A";
   546 by (Blast_tac 1);
   547 qed "diag_subset_Sigma";
   548 
   549 Goal "((A Times B) <**> (C Times D)) <= (A<*>C) Times (B<*>D)";
   550 by (Blast_tac 1);
   551 qed "dprod_Sigma";
   552 
   553 val dprod_subset_Sigma = [dprod_mono, dprod_Sigma] MRS subset_trans |>standard;
   554 
   555 (*Dependent version*)
   556 Goal "(Sigma A B <**> Sigma C D) <= Sigma (A<*>C) (Split(%x y. B(x)<*>D(y)))";
   557 by Safe_tac;
   558 by (stac Split 1);
   559 by (Blast_tac 1);
   560 qed "dprod_subset_Sigma2";
   561 
   562 Goal "(A Times B <++> C Times D) <= (A<+>C) Times (B<+>D)";
   563 by (Blast_tac 1);
   564 qed "dsum_Sigma";
   565 
   566 val dsum_subset_Sigma = [dsum_mono, dsum_Sigma] MRS subset_trans |> standard;
   567 
   568 
   569 (*** Domain ***)
   570 
   571 Goal "fst `` diag(A) = A";
   572 by Auto_tac;
   573 qed "fst_image_diag";
   574 
   575 Goal "fst `` (r<**>s) = (fst``r) <*> (fst``s)";
   576 by Auto_tac;
   577 qed "fst_image_dprod";
   578 
   579 Goal "fst `` (r<++>s) = (fst``r) <+> (fst``s)";
   580 by Auto_tac;
   581 qed "fst_image_dsum";
   582 
   583 Addsimps [fst_image_diag, fst_image_dprod, fst_image_dsum];