src/CCL/Set.ML
author paulson
Fri, 29 Oct 2004 15:16:02 +0200
changeset 15270 8b3f707a78a7
parent 5143 b94cd208f073
child 17456 bcf7544875b2
permissions -rw-r--r--
fixed reference to renamed theorem
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     1
(*  Title:      set/set
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
For set.thy.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
Modified version of
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     7
    Title:      HOL/set
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     8
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
For set.thy.  Set theory for higher-order logic.  A set is simply a predicate.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
open Set;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1459
diff changeset
    16
val [prem] = goal Set.thy "[| P(a) |] ==> a : {x. P(x)}";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
by (rtac (mem_Collect_iff RS iffD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    18
by (rtac prem 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    19
qed "CollectI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1459
diff changeset
    21
val prems = goal Set.thy "[| a : {x. P(x)} |] ==> P(a)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
by (resolve_tac (prems RL [mem_Collect_iff  RS iffD1]) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    23
qed "CollectD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    24
8
c3d2c6dcf3f0 Installation of new simplfier. Previously appeared to set up the old
lcp
parents: 0
diff changeset
    25
val CollectE = make_elim CollectD;
c3d2c6dcf3f0 Installation of new simplfier. Previously appeared to set up the old
lcp
parents: 0
diff changeset
    26
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
val [prem] = goal Set.thy "[| !!x. x:A <-> x:B |] ==> A = B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
by (rtac (set_extension RS iffD2) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
by (rtac (prem RS allI) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    30
qed "set_ext";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
(*** Bounded quantifiers ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
val prems = goalw Set.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
    "[| !!x. x:A ==> P(x) |] ==> ALL x:A. P(x)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
by (REPEAT (ares_tac (prems @ [allI,impI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    37
qed "ballI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    39
val [major,minor] = goalw Set.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
    "[| ALL x:A. P(x);  x:A |] ==> P(x)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
by (rtac (minor RS (major RS spec RS mp)) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    42
qed "bspec";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
val major::prems = goalw Set.thy [Ball_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    45
    "[| ALL x:A. P(x);  P(x) ==> Q;  ~ x:A ==> Q |] ==> Q";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
by (rtac (major RS spec RS impCE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
by (REPEAT (eresolve_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    48
qed "ballE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
(*Takes assumptions ALL x:A.P(x) and a:A; creates assumption P(a)*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
fun ball_tac i = etac ballE i THEN contr_tac (i+1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
val prems = goalw Set.thy [Bex_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
    "[| P(x);  x:A |] ==> EX x:A. P(x)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
by (REPEAT (ares_tac (prems @ [exI,conjI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    56
qed "bexI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    58
qed_goal "bexCI" Set.thy 
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1459
diff changeset
    59
   "[| EX x:A. ~P(x) ==> P(a);  a:A |] ==> EX x:A. P(x)"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
  [ (rtac classical 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
    (REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1))  ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
val major::prems = goalw Set.thy [Bex_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    65
    "[| EX x:A. P(x);  !!x. [| x:A; P(x) |] ==> Q  |] ==> Q";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
by (rtac (major RS exE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    68
qed "bexE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
(*Trival rewrite rule;   (! x:A.P)=P holds only if A is nonempty!*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    71
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
    "(ALL x:A. True) <-> True";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
by (REPEAT (ares_tac [TrueI,ballI,iffI] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    74
qed "ball_rew";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
(** Congruence rules **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    78
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
    "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
\    (ALL x:A. P(x)) <-> (ALL x:A'. P'(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
by (resolve_tac (prems RL [ssubst,iffD2]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
by (REPEAT (ares_tac [ballI,iffI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
     ORELSE eresolve_tac ([make_elim bspec, mp] @ (prems RL [iffE])) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    84
qed "ball_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
    "[| A=A';  !!x. x:A' ==> P(x) <-> P'(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
\    (EX x:A. P(x)) <-> (EX x:A'. P'(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
by (resolve_tac (prems RL [ssubst,iffD2]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    90
by (REPEAT (etac bexE 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
     ORELSE ares_tac ([bexI,iffI] @ (prems RL [iffD1,iffD2])) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    92
qed "bex_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
(*** Rules for subsets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1459
diff changeset
    96
val prems = goalw Set.thy [subset_def] "(!!x. x:A ==> x:B) ==> A <= B";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
by (REPEAT (ares_tac (prems @ [ballI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
    98
qed "subsetI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
(*Rule in Modus Ponens style*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
val major::prems = goalw Set.thy [subset_def] "[| A <= B;  c:A |] ==> c:B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   102
by (rtac (major RS bspec) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
by (resolve_tac prems 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   104
qed "subsetD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   105
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
(*Classical elimination rule*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
val major::prems = goalw Set.thy [subset_def] 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
    "[| A <= B;  ~(c:A) ==> P;  c:B ==> P |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
by (rtac (major RS ballE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
by (REPEAT (eresolve_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   111
qed "subsetCE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
(*Takes assumptions A<=B; c:A and creates the assumption c:B *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
fun set_mp_tac i = etac subsetCE i  THEN  mp_tac i;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   116
qed_goal "subset_refl" Set.thy "A <= A"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
 (fn _=> [ (REPEAT (ares_tac [subsetI] 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   118
5143
b94cd208f073 Removal of leading "\!\!..." from most Goal commands
paulson
parents: 5062
diff changeset
   119
Goal "[| A<=B;  B<=C |] ==> A<=C";
642
0db578095e6a CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents: 8
diff changeset
   120
by (rtac subsetI 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
by (REPEAT (eresolve_tac [asm_rl, subsetD] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   122
qed "subset_trans";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   123
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   124
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   125
(*** Rules for equality ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   126
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   127
(*Anti-symmetry of the subset relation*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   128
val prems = goal Set.thy "[| A <= B;  B <= A |] ==> A = B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   129
by (rtac (iffI RS set_ext) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   130
by (REPEAT (ares_tac (prems RL [subsetD]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   131
qed "subset_antisym";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   132
val equalityI = subset_antisym;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   133
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   134
(* Equality rules from ZF set theory -- are they appropriate here? *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   135
val prems = goal Set.thy "A = B ==> A<=B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   136
by (resolve_tac (prems RL [subst]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   137
by (rtac subset_refl 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   138
qed "equalityD1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   139
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   140
val prems = goal Set.thy "A = B ==> B<=A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   141
by (resolve_tac (prems RL [subst]) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   142
by (rtac subset_refl 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   143
qed "equalityD2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   144
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   145
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   146
    "[| A = B;  [| A<=B; B<=A |] ==> P |]  ==>  P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   147
by (resolve_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   148
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   149
qed "equalityE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   150
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   151
val major::prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   152
    "[| A = B;  [| c:A; c:B |] ==> P;  [| ~ c:A; ~ c:B |] ==> P |]  ==>  P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   153
by (rtac (major RS equalityE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   154
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   155
qed "equalityCE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   156
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   157
(*Lemma for creating induction formulae -- for "pattern matching" on p
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   158
  To make the induction hypotheses usable, apply "spec" or "bspec" to
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   159
  put universal quantifiers over the free variables in p. *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   160
val prems = goal Set.thy 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   161
    "[| p:A;  !!z. z:A ==> p=z --> R |] ==> R";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   162
by (rtac mp 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   163
by (REPEAT (resolve_tac (refl::prems) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   164
qed "setup_induction";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   165
5062
fbdb0b541314 isatool fixgoal;
wenzelm
parents: 3837
diff changeset
   166
Goal "{x. x:A} = A";
642
0db578095e6a CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents: 8
diff changeset
   167
by (REPEAT (ares_tac [equalityI,subsetI,CollectI] 1  ORELSE etac CollectD 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   168
qed "trivial_set";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   169
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   170
(*** Rules for binary union -- Un ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   171
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   172
val prems = goalw Set.thy [Un_def] "c:A ==> c : A Un B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   173
by (REPEAT (resolve_tac (prems @ [CollectI,disjI1]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   174
qed "UnI1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   175
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   176
val prems = goalw Set.thy [Un_def] "c:B ==> c : A Un B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   177
by (REPEAT (resolve_tac (prems @ [CollectI,disjI2]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   178
qed "UnI2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   179
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   180
(*Classical introduction rule: no commitment to A vs B*)
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   181
qed_goal "UnCI" Set.thy "(~c:B ==> c:A) ==> c : A Un B"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   182
 (fn prems=>
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   183
  [ (rtac classical 1),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   184
    (REPEAT (ares_tac (prems@[UnI1,notI]) 1)),
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   185
    (REPEAT (ares_tac (prems@[UnI2,notE]) 1)) ]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   186
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   187
val major::prems = goalw Set.thy [Un_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   188
    "[| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   189
by (rtac (major RS CollectD RS disjE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   190
by (REPEAT (eresolve_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   191
qed "UnE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   192
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   193
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   194
(*** Rules for small intersection -- Int ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   195
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   196
val prems = goalw Set.thy [Int_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   197
    "[| c:A;  c:B |] ==> c : A Int B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   198
by (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   199
qed "IntI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   200
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   201
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   202
by (rtac (major RS CollectD RS conjunct1) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   203
qed "IntD1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   204
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   205
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   206
by (rtac (major RS CollectD RS conjunct2) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   207
qed "IntD2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   208
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   209
val [major,minor] = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   210
    "[| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   211
by (rtac minor 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   212
by (rtac (major RS IntD1) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   213
by (rtac (major RS IntD2) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   214
qed "IntE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   215
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   216
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   217
(*** Rules for set complement -- Compl ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   218
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   219
val prems = goalw Set.thy [Compl_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   220
    "[| c:A ==> False |] ==> c : Compl(A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   221
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   222
qed "ComplI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   223
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   224
(*This form, with negated conclusion, works well with the Classical prover.
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   225
  Negated assumptions behave like formulae on the right side of the notional
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   226
  turnstile...*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   227
val major::prems = goalw Set.thy [Compl_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   228
    "[| c : Compl(A) |] ==> ~c:A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   229
by (rtac (major RS CollectD) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   230
qed "ComplD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   231
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   232
val ComplE = make_elim ComplD;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   233
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   234
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   235
(*** Empty sets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   236
5062
fbdb0b541314 isatool fixgoal;
wenzelm
parents: 3837
diff changeset
   237
Goalw [empty_def] "{x. False} = {}";
642
0db578095e6a CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents: 8
diff changeset
   238
by (rtac refl 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   239
qed "empty_eq";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   240
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   241
val [prem] = goalw Set.thy [empty_def] "a : {} ==> P";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   242
by (rtac (prem RS CollectD RS FalseE) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   243
qed "emptyD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   244
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   245
val emptyE = make_elim emptyD;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   246
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 1459
diff changeset
   247
val [prem] = goal Set.thy "~ A={} ==> (EX x. x:A)";
642
0db578095e6a CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents: 8
diff changeset
   248
by (rtac (prem RS swap) 1);
0db578095e6a CCL/Gfp/coinduct2, coinduct3: modified proofs to suppress deep unification
lcp
parents: 8
diff changeset
   249
by (rtac equalityI 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   250
by (ALLGOALS (fast_tac (FOL_cs addSIs [subsetI] addSEs [emptyD])));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   251
qed "not_emptyD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   252
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   253
(*** Singleton sets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   254
5062
fbdb0b541314 isatool fixgoal;
wenzelm
parents: 3837
diff changeset
   255
Goalw [singleton_def] "a : {a}";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   256
by (rtac CollectI 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   257
by (rtac refl 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   258
qed "singletonI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   259
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   260
val [major] = goalw Set.thy [singleton_def] "b : {a} ==> b=a"; 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   261
by (rtac (major RS CollectD) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   262
qed "singletonD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   263
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   264
val singletonE = make_elim singletonD;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   265
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   266
(*** Unions of families ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   267
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   268
(*The order of the premises presupposes that A is rigid; b may be flexible*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   269
val prems = goalw Set.thy [UNION_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   270
    "[| a:A;  b: B(a) |] ==> b: (UN x:A. B(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   271
by (REPEAT (resolve_tac (prems @ [bexI,CollectI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   272
qed "UN_I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   273
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   274
val major::prems = goalw Set.thy [UNION_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   275
    "[| b : (UN x:A. B(x));  !!x.[| x:A;  b: B(x) |] ==> R |] ==> R";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   276
by (rtac (major RS CollectD RS bexE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   277
by (REPEAT (ares_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   278
qed "UN_E";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   279
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   280
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   281
    "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   282
\    (UN x:A. C(x)) = (UN x:B. D(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   283
by (REPEAT (etac UN_E 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   284
     ORELSE ares_tac ([UN_I,equalityI,subsetI] @ 
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
   285
                      (prems RL [equalityD1,equalityD2] RL [subsetD])) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   286
qed "UN_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   287
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   288
(*** Intersections of families -- INTER x:A. B(x) is Inter(B)``A ) *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   289
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   290
val prems = goalw Set.thy [INTER_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   291
    "(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   292
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   293
qed "INT_I";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   294
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   295
val major::prems = goalw Set.thy [INTER_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   296
    "[| b : (INT x:A. B(x));  a:A |] ==> b: B(a)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   297
by (rtac (major RS CollectD RS bspec) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   298
by (resolve_tac prems 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   299
qed "INT_D";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   300
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   301
(*"Classical" elimination rule -- does not require proving X:C *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   302
val major::prems = goalw Set.thy [INTER_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   303
    "[| b : (INT x:A. B(x));  b: B(a) ==> R;  ~ a:A ==> R |] ==> R";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   304
by (rtac (major RS CollectD RS ballE) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   305
by (REPEAT (eresolve_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   306
qed "INT_E";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   307
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   308
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   309
    "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==> \
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   310
\    (INT x:A. C(x)) = (INT x:B. D(x))";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   311
by (REPEAT_FIRST (resolve_tac [INT_I,equalityI,subsetI]));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   312
by (REPEAT (dtac INT_D 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   313
     ORELSE ares_tac (prems RL [equalityD1,equalityD2] RL [subsetD]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   314
qed "INT_cong";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   315
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   316
(*** Rules for Unions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   317
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   318
(*The order of the premises presupposes that C is rigid; A may be flexible*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   319
val prems = goalw Set.thy [Union_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   320
    "[| X:C;  A:X |] ==> A : Union(C)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   321
by (REPEAT (resolve_tac (prems @ [UN_I]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   322
qed "UnionI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   323
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   324
val major::prems = goalw Set.thy [Union_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   325
    "[| A : Union(C);  !!X.[| A:X;  X:C |] ==> R |] ==> R";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   326
by (rtac (major RS UN_E) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   327
by (REPEAT (ares_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   328
qed "UnionE";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   329
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   330
(*** Rules for Inter ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   331
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   332
val prems = goalw Set.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   333
    "[| !!X. X:C ==> A:X |] ==> A : Inter(C)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   334
by (REPEAT (ares_tac ([INT_I] @ prems) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   335
qed "InterI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   336
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   337
(*A "destruct" rule -- every X in C contains A as an element, but
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   338
  A:X can hold when X:C does not!  This rule is analogous to "spec". *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   339
val major::prems = goalw Set.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   340
    "[| A : Inter(C);  X:C |] ==> A:X";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   341
by (rtac (major RS INT_D) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   342
by (resolve_tac prems 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   343
qed "InterD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   344
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   345
(*"Classical" elimination rule -- does not require proving X:C *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   346
val major::prems = goalw Set.thy [Inter_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   347
    "[| A : Inter(C);  A:X ==> R;  ~ X:C ==> R |] ==> R";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   348
by (rtac (major RS INT_E) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   349
by (REPEAT (eresolve_tac prems 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 642
diff changeset
   350
qed "InterE";