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