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