src/HOL/Set.ML
author paulson
Mon, 07 Oct 1996 10:28:44 +0200
changeset 2056 93c093620c28
parent 2031 03a843f0f447
child 2499 0bc87b063447
permissions -rw-r--r--
Removed commands made redundant by new one-point rules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1465
5d7a7e439cec expanded tabs
clasohm
parents: 923
diff changeset
     1
(*  Title:      HOL/set
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1465
5d7a7e439cec expanded tabs
clasohm
parents: 923
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1991  University of Cambridge
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     5
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents: 1937
diff changeset
     6
Set theory for higher-order logic.  A set is simply a predicate.
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
open Set;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
    11
section "Relating predicates and sets";
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
    12
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
    13
val [prem] = goal Set.thy "P(a) ==> a : {x.P(x)}";
2031
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
    14
by (stac mem_Collect_eq 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
by (rtac prem 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
qed "CollectI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
val prems = goal Set.thy "[| a : {x.P(x)} |] ==> P(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
by (resolve_tac (prems RL [mem_Collect_eq  RS subst]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
qed "CollectD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
val [prem] = goal Set.thy "[| !!x. (x:A) = (x:B) |] ==> A = B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
by (rtac (prem RS ext RS arg_cong RS box_equals) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
by (rtac Collect_mem_eq 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
by (rtac Collect_mem_eq 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
qed "set_ext";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
val [prem] = goal Set.thy "[| !!x. P(x)=Q(x) |] ==> {x. P(x)} = {x. Q(x)}";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
by (rtac (prem RS ext RS arg_cong) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
qed "Collect_cong";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
val CollectE = make_elim CollectD;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
    34
section "Bounded quantifiers";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
val prems = goalw Set.thy [Ball_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
    "[| !!x. x:A ==> P(x) |] ==> ! x:A. P(x)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
by (REPEAT (ares_tac (prems @ [allI,impI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
qed "ballI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
val [major,minor] = goalw Set.thy [Ball_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
    "[| ! x:A. P(x);  x:A |] ==> P(x)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
by (rtac (minor RS (major RS spec RS mp)) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
qed "bspec";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
val major::prems = goalw Set.thy [Ball_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
    "[| ! x:A. P(x);  P(x) ==> Q;  x~:A ==> Q |] ==> Q";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
by (rtac (major RS spec RS impCE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
by (REPEAT (eresolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
qed "ballE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
(*Takes assumptions ! x:A.P(x) and a:A; creates assumption P(a)*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
fun ball_tac i = etac ballE i THEN contr_tac (i+1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
val prems = goalw Set.thy [Bex_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
    "[| P(x);  x:A |] ==> ? x:A. P(x)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
by (REPEAT (ares_tac (prems @ [exI,conjI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
qed "bexI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
qed_goal "bexCI" Set.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
   "[| ! x:A. ~P(x) ==> P(a);  a:A |] ==> ? x:A.P(x)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
 (fn prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
  [ (rtac classical 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
    (REPEAT (ares_tac (prems@[bexI,ballI,notI,notE]) 1))  ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    65
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
val major::prems = goalw Set.thy [Bex_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
    "[| ? x:A. P(x);  !!x. [| x:A; P(x) |] ==> Q  |] ==> Q";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
by (rtac (major RS exE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
by (REPEAT (eresolve_tac (prems @ [asm_rl,conjE]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
qed "bexE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    72
(*Trival rewrite rule;   (! x:A.P)=P holds only if A is nonempty!*)
1882
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    73
goalw Set.thy [Ball_def] "(! x:A. True) = True";
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    74
by (Simp_tac 1);
1816
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
    75
qed "ball_True";
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
    76
1882
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    77
(*Dual form for existentials*)
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    78
goalw Set.thy [Bex_def] "(? x:A. False) = False";
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    79
by (Simp_tac 1);
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    80
qed "bex_False";
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    81
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
    82
Addsimps [ball_True, bex_False];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
(** Congruence rules **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
val prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
    "[| A=B;  !!x. x:B ==> P(x) = Q(x) |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
\    (! x:A. P(x)) = (! x:B. Q(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
by (resolve_tac (prems RL [ssubst]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
by (REPEAT (ares_tac [ballI,iffI] 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
     ORELSE eresolve_tac ([make_elim bspec, mp] @ (prems RL [iffE])) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
qed "ball_cong";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
val prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
    "[| A=B;  !!x. x:B ==> P(x) = Q(x) |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
\    (? x:A. P(x)) = (? x:B. Q(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
by (resolve_tac (prems RL [ssubst]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
by (REPEAT (etac bexE 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    99
     ORELSE ares_tac ([bexI,iffI] @ (prems RL [iffD1,iffD2])) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
qed "bex_cong";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   102
section "Subsets";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
val prems = goalw Set.thy [subset_def] "(!!x.x:A ==> x:B) ==> A <= B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
by (REPEAT (ares_tac (prems @ [ballI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
qed "subsetI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
(*Rule in Modus Ponens style*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
val major::prems = goalw Set.thy [subset_def] "[| A <= B;  c:A |] ==> c:B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
by (rtac (major RS bspec) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
qed "subsetD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
(*The same, with reversed premises for use with etac -- cf rev_mp*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
qed_goal "rev_subsetD" Set.thy "[| c:A;  A <= B |] ==> c:B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
 (fn prems=>  [ (REPEAT (resolve_tac (prems@[subsetD]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
1920
df683ce7aad8 Added impOfSubs
paulson
parents: 1882
diff changeset
   118
(*Converts A<=B to x:A ==> x:B*)
df683ce7aad8 Added impOfSubs
paulson
parents: 1882
diff changeset
   119
fun impOfSubs th = th RSN (2, rev_subsetD);
df683ce7aad8 Added impOfSubs
paulson
parents: 1882
diff changeset
   120
1841
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   121
qed_goal "contra_subsetD" Set.thy "!!c. [| A <= B; c ~: B |] ==> c ~: A"
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   122
 (fn prems=>  [ (REPEAT (eresolve_tac [asm_rl, contrapos, subsetD] 1)) ]);
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   123
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   124
qed_goal "rev_contra_subsetD" Set.thy "!!c. [| c ~: B;  A <= B |] ==> c ~: A"
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   125
 (fn prems=>  [ (REPEAT (eresolve_tac [asm_rl, contrapos, subsetD] 1)) ]);
8e5e2fef6d26 Added contra_subsetD and rev_contra_subsetD
paulson
parents: 1816
diff changeset
   126
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
(*Classical elimination rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
val major::prems = goalw Set.thy [subset_def] 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
    "[| A <= B;  c~:A ==> P;  c:B ==> P |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
by (rtac (major RS ballE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
by (REPEAT (eresolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
qed "subsetCE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
(*Takes assumptions A<=B; c:A and creates the assumption c:B *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
fun set_mp_tac i = etac subsetCE i  THEN  mp_tac i;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
qed_goal "subset_refl" Set.thy "A <= (A::'a set)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
 (fn _=> [ (REPEAT (ares_tac [subsetI] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
val prems = goal Set.thy "[| A<=B;  B<=C |] ==> A<=(C::'a set)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
by (cut_facts_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
by (REPEAT (ares_tac [subsetI] 1 ORELSE set_mp_tac 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
qed "subset_trans";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   146
section "Equality";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
(*Anti-symmetry of the subset relation*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
val prems = goal Set.thy "[| A <= B;  B <= A |] ==> A = (B::'a set)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
by (rtac (iffI RS set_ext) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
by (REPEAT (ares_tac (prems RL [subsetD]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
qed "subset_antisym";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
val equalityI = subset_antisym;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
1762
6e481897a811 equalityI is now added to default claset
berghofe
parents: 1760
diff changeset
   155
AddSIs [equalityI];
6e481897a811 equalityI is now added to default claset
berghofe
parents: 1760
diff changeset
   156
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
(* Equality rules from ZF set theory -- are they appropriate here? *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
val prems = goal Set.thy "A = B ==> A<=(B::'a set)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
by (resolve_tac (prems RL [subst]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
by (rtac subset_refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
qed "equalityD1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
val prems = goal Set.thy "A = B ==> B<=(A::'a set)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
by (resolve_tac (prems RL [subst]) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
by (rtac subset_refl 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
qed "equalityD2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
val prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
    "[| A = B;  [| A<=B; B<=(A::'a set) |] ==> P |]  ==>  P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
by (REPEAT (resolve_tac (prems RL [equalityD1,equalityD2]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
qed "equalityE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   173
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
val major::prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
    "[| A = B;  [| c:A; c:B |] ==> P;  [| c~:A; c~:B |] ==> P |]  ==>  P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
by (rtac (major RS equalityE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
by (REPEAT (contr_tac 1 ORELSE eresolve_tac ([asm_rl,subsetCE]@prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
qed "equalityCE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
(*Lemma for creating induction formulae -- for "pattern matching" on p
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
  To make the induction hypotheses usable, apply "spec" or "bspec" to
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
  put universal quantifiers over the free variables in p. *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
val prems = goal Set.thy 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
    "[| p:A;  !!z. z:A ==> p=z --> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
by (rtac mp 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
by (REPEAT (resolve_tac (refl::prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
qed "setup_induction";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   190
section "Set complement -- Compl";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
val prems = goalw Set.thy [Compl_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
    "[| c:A ==> False |] ==> c : Compl(A)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
by (REPEAT (ares_tac (prems @ [CollectI,notI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
qed "ComplI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   197
(*This form, with negated conclusion, works well with the Classical prover.
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
  Negated assumptions behave like formulae on the right side of the notional
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
  turnstile...*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
val major::prems = goalw Set.thy [Compl_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
    "[| c : Compl(A) |] ==> c~:A";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   202
by (rtac (major RS CollectD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   203
qed "ComplD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   204
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   205
val ComplE = make_elim ComplD;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   206
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   207
qed_goal "Compl_iff" Set.thy "(c : Compl(A)) = (c~:A)"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   208
 (fn _ => [ (fast_tac (!claset addSIs [ComplI] addSEs [ComplE]) 1) ]);
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   209
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   210
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   211
section "Binary union -- Un";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   212
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   213
val prems = goalw Set.thy [Un_def] "c:A ==> c : A Un B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   214
by (REPEAT (resolve_tac (prems @ [CollectI,disjI1]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   215
qed "UnI1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   216
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   217
val prems = goalw Set.thy [Un_def] "c:B ==> c : A Un B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   218
by (REPEAT (resolve_tac (prems @ [CollectI,disjI2]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   219
qed "UnI2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   220
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   221
(*Classical introduction rule: no commitment to A vs B*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   222
qed_goal "UnCI" Set.thy "(c~:B ==> c:A) ==> c : A Un B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   223
 (fn prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   224
  [ (rtac classical 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   225
    (REPEAT (ares_tac (prems@[UnI1,notI]) 1)),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   226
    (REPEAT (ares_tac (prems@[UnI2,notE]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   227
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   228
val major::prems = goalw Set.thy [Un_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   229
    "[| c : A Un B;  c:A ==> P;  c:B ==> P |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   230
by (rtac (major RS CollectD RS disjE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   231
by (REPEAT (eresolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   232
qed "UnE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   233
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   234
qed_goal "Un_iff" Set.thy "(c : A Un B) = (c:A | c:B)"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   235
 (fn _ => [ (fast_tac (!claset addSIs [UnCI] addSEs [UnE]) 1) ]);
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   236
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   237
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   238
section "Binary intersection -- Int";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   239
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   240
val prems = goalw Set.thy [Int_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   241
    "[| c:A;  c:B |] ==> c : A Int B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   242
by (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   243
qed "IntI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   244
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   245
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:A";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   246
by (rtac (major RS CollectD RS conjunct1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   247
qed "IntD1";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   248
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   249
val [major] = goalw Set.thy [Int_def] "c : A Int B ==> c:B";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   250
by (rtac (major RS CollectD RS conjunct2) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   251
qed "IntD2";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   252
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   253
val [major,minor] = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   254
    "[| c : A Int B;  [| c:A; c:B |] ==> P |] ==> P";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   255
by (rtac minor 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   256
by (rtac (major RS IntD1) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   257
by (rtac (major RS IntD2) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   258
qed "IntE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   259
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   260
qed_goal "Int_iff" Set.thy "(c : A Int B) = (c:A & c:B)"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   261
 (fn _ => [ (fast_tac (!claset addSIs [IntI] addSEs [IntE]) 1) ]);
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   262
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   263
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   264
section "Set difference";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   265
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   266
qed_goalw "DiffI" Set.thy [set_diff_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   267
    "[| c : A;  c ~: B |] ==> c : A - B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   268
 (fn prems=> [ (REPEAT (resolve_tac (prems @ [CollectI,conjI]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   269
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   270
qed_goalw "DiffD1" Set.thy [set_diff_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   271
    "c : A - B ==> c : A"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   272
 (fn [major]=> [ (rtac (major RS CollectD RS conjunct1) 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   273
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   274
qed_goalw "DiffD2" Set.thy [set_diff_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   275
    "[| c : A - B;  c : B |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   276
 (fn [major,minor]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   277
     [rtac (minor RS (major RS CollectD RS conjunct2 RS notE)) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   278
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   279
qed_goal "DiffE" Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   280
    "[| c : A - B;  [| c:A; c~:B |] ==> P |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   281
 (fn prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   282
  [ (resolve_tac prems 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   283
    (REPEAT (ares_tac (prems RL [DiffD1, DiffD2 RS notI]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   284
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   285
qed_goal "Diff_iff" Set.thy "(c : A-B) = (c:A & c~:B)"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   286
 (fn _ => [ (fast_tac (!claset addSIs [DiffI] addSEs [DiffE]) 1) ]);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   287
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   288
section "The empty set -- {}";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   289
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   290
qed_goalw "emptyE" Set.thy [empty_def] "a:{} ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   291
 (fn [prem] => [rtac (prem RS CollectD RS FalseE) 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   292
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   293
qed_goal "empty_subsetI" Set.thy "{} <= A"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   294
 (fn _ => [ (REPEAT (ares_tac [equalityI,subsetI,emptyE] 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   295
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   296
qed_goal "equals0I" Set.thy "[| !!y. y:A ==> False |] ==> A={}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   297
 (fn prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   298
  [ (REPEAT (ares_tac (prems@[empty_subsetI,subsetI,equalityI]) 1 
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   299
      ORELSE eresolve_tac (prems RL [FalseE]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   300
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   301
qed_goal "equals0D" Set.thy "[| A={};  a:A |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   302
 (fn [major,minor]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   303
  [ (rtac (minor RS (major RS equalityD1 RS subsetD RS emptyE)) 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   304
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   305
qed_goal "empty_iff" Set.thy "(c : {}) = False"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   306
 (fn _ => [ (fast_tac (!claset addSEs [emptyE]) 1) ]);
1640
581165679095 Added more _iff rewrites for Compl, Un, Int
paulson
parents: 1618
diff changeset
   307
1816
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   308
goal Set.thy "Ball {} P = True";
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   309
by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Ball_def, empty_def]) 1);
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   310
qed "ball_empty";
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   311
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   312
goal Set.thy "Bex {} P = False";
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   313
by (simp_tac (HOL_ss addsimps [mem_Collect_eq, Bex_def, empty_def]) 1);
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   314
qed "bex_empty";
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   315
Addsimps [ball_empty, bex_empty];
b03dba9116d4 New rewrites for vacuous quantification
paulson
parents: 1776
diff changeset
   316
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   317
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   318
section "Augmenting a set -- insert";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   319
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   320
qed_goalw "insertI1" Set.thy [insert_def] "a : insert a B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   321
 (fn _ => [rtac (CollectI RS UnI1) 1, rtac refl 1]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   322
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   323
qed_goalw "insertI2" Set.thy [insert_def] "a : B ==> a : insert b B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   324
 (fn [prem]=> [ (rtac (prem RS UnI2) 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   325
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   326
qed_goalw "insertE" Set.thy [insert_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   327
    "[| a : insert b A;  a=b ==> P;  a:A ==> P |] ==> P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   328
 (fn major::prems=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   329
  [ (rtac (major RS UnE) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   330
    (REPEAT (eresolve_tac (prems @ [CollectE]) 1)) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   331
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   332
qed_goal "insert_iff" Set.thy "a : insert b A = (a=b | a:A)"
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   333
 (fn _ => [fast_tac (!claset addIs [insertI1,insertI2] addSEs [insertE]) 1]);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   334
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   335
(*Classical introduction rule*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   336
qed_goal "insertCI" Set.thy "(a~:B ==> a=b) ==> a: insert b B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   337
 (fn [prem]=>
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   338
  [ (rtac (disjCI RS (insert_iff RS iffD2)) 1),
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   339
    (etac prem 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   340
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   341
section "Singletons, using insert";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   342
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   343
qed_goal "singletonI" Set.thy "a : {a}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   344
 (fn _=> [ (rtac insertI1 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   345
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   346
goalw Set.thy [insert_def] "!!a. b : {a} ==> b=a";
1760
6f41a494f3b1 Replaced fast_tac by Fast_tac (which uses default claset)
berghofe
parents: 1640
diff changeset
   347
by (fast_tac (!claset addSEs [emptyE,CollectE,UnE]) 1);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   348
qed "singletonD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   349
1776
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   350
bind_thm ("singletonE", make_elim singletonD);
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   351
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   352
qed_goal "singleton_iff" thy "(b : {a}) = (b=a)" (fn _ => [
2031
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
   353
        rtac iffI 1,
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
   354
        etac singletonD 1,
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
   355
        hyp_subst_tac 1,
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
   356
        rtac singletonI 1]);
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   357
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   358
val [major] = goal Set.thy "{a}={b} ==> a=b";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   359
by (rtac (major RS equalityD1 RS subsetD RS singletonD) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   360
by (rtac singletonI 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   361
qed "singleton_inject";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   362
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1465
diff changeset
   363
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   364
section "The universal set -- UNIV";
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1465
diff changeset
   365
1882
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
   366
qed_goal "UNIV_I" Set.thy "x : UNIV"
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
   367
  (fn _ => [rtac ComplI 1, etac emptyE 1]);
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
   368
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1465
diff changeset
   369
qed_goal "subset_UNIV" Set.thy "A <= UNIV"
1882
67f49e8c4355 Proved bex_False
paulson
parents: 1841
diff changeset
   370
  (fn _ => [rtac subsetI 1, rtac UNIV_I 1]);
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1465
diff changeset
   371
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1465
diff changeset
   372
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   373
section "Unions of families -- UNION x:A. B(x) is Union(B``A)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   374
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   375
(*The order of the premises presupposes that A is rigid; b may be flexible*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   376
val prems = goalw Set.thy [UNION_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   377
    "[| a:A;  b: B(a) |] ==> b: (UN x:A. B(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   378
by (REPEAT (resolve_tac (prems @ [bexI,CollectI]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   379
qed "UN_I";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   380
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   381
val major::prems = goalw Set.thy [UNION_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   382
    "[| b : (UN x:A. B(x));  !!x.[| x:A;  b: B(x) |] ==> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   383
by (rtac (major RS CollectD RS bexE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   384
by (REPEAT (ares_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   385
qed "UN_E";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   386
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   387
val prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   388
    "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   389
\    (UN x:A. C(x)) = (UN x:B. D(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   390
by (REPEAT (etac UN_E 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   391
     ORELSE ares_tac ([UN_I,equalityI,subsetI] @ 
1465
5d7a7e439cec expanded tabs
clasohm
parents: 923
diff changeset
   392
                      (prems RL [equalityD1,equalityD2] RL [subsetD])) 1));
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   393
qed "UN_cong";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   394
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   395
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   396
section "Intersections of families -- INTER x:A. B(x) is Inter(B``A)";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   397
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   398
val prems = goalw Set.thy [INTER_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   399
    "(!!x. x:A ==> b: B(x)) ==> b : (INT x:A. B(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   400
by (REPEAT (ares_tac ([CollectI,ballI] @ prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   401
qed "INT_I";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   402
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   403
val major::prems = goalw Set.thy [INTER_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   404
    "[| b : (INT x:A. B(x));  a:A |] ==> b: B(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   405
by (rtac (major RS CollectD RS bspec) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   406
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   407
qed "INT_D";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   408
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   409
(*"Classical" elimination -- by the Excluded Middle on a:A *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   410
val major::prems = goalw Set.thy [INTER_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   411
    "[| b : (INT x:A. B(x));  b: B(a) ==> R;  a~:A ==> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   412
by (rtac (major RS CollectD RS ballE) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   413
by (REPEAT (eresolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   414
qed "INT_E";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   415
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   416
val prems = goal Set.thy
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   417
    "[| A=B;  !!x. x:B ==> C(x) = D(x) |] ==> \
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   418
\    (INT x:A. C(x)) = (INT x:B. D(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   419
by (REPEAT_FIRST (resolve_tac [INT_I,equalityI,subsetI]));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   420
by (REPEAT (dtac INT_D 1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   421
     ORELSE ares_tac (prems RL [equalityD1,equalityD2] RL [subsetD]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   422
qed "INT_cong";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   423
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   424
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   425
section "Unions over a type; UNION1(B) = Union(range(B))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   426
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   427
(*The order of the premises presupposes that A is rigid; b may be flexible*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   428
val prems = goalw Set.thy [UNION1_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   429
    "b: B(x) ==> b: (UN x. B(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   430
by (REPEAT (resolve_tac (prems @ [TrueI, CollectI RS UN_I]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   431
qed "UN1_I";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   432
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   433
val major::prems = goalw Set.thy [UNION1_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   434
    "[| b : (UN x. B(x));  !!x. b: B(x) ==> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   435
by (rtac (major RS UN_E) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   436
by (REPEAT (ares_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   437
qed "UN1_E";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   438
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   439
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   440
section "Intersections over a type; INTER1(B) = Inter(range(B))";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   441
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   442
val prems = goalw Set.thy [INTER1_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   443
    "(!!x. b: B(x)) ==> b : (INT x. B(x))";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   444
by (REPEAT (ares_tac (INT_I::prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   445
qed "INT1_I";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   446
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   447
val [major] = goalw Set.thy [INTER1_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   448
    "b : (INT x. B(x)) ==> b: B(a)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   449
by (rtac (TrueI RS (CollectI RS (major RS INT_D))) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   450
qed "INT1_D";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   451
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   452
section "Union";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   453
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   454
(*The order of the premises presupposes that C is rigid; A may be flexible*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   455
val prems = goalw Set.thy [Union_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   456
    "[| X:C;  A:X |] ==> A : Union(C)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   457
by (REPEAT (resolve_tac (prems @ [UN_I]) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   458
qed "UnionI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   459
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   460
val major::prems = goalw Set.thy [Union_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   461
    "[| A : Union(C);  !!X.[| A:X;  X:C |] ==> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   462
by (rtac (major RS UN_E) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   463
by (REPEAT (ares_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   464
qed "UnionE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   465
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   466
section "Inter";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   467
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   468
val prems = goalw Set.thy [Inter_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   469
    "[| !!X. X:C ==> A:X |] ==> A : Inter(C)";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   470
by (REPEAT (ares_tac ([INT_I] @ prems) 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   471
qed "InterI";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   472
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   473
(*A "destruct" rule -- every X in C contains A as an element, but
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   474
  A:X can hold when X:C does not!  This rule is analogous to "spec". *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   475
val major::prems = goalw Set.thy [Inter_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   476
    "[| A : Inter(C);  X:C |] ==> A:X";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   477
by (rtac (major RS INT_D) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   478
by (resolve_tac prems 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   479
qed "InterD";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   480
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   481
(*"Classical" elimination rule -- does not require proving X:C *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   482
val major::prems = goalw Set.thy [Inter_def]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   483
    "[| A : Inter(C);  A:X ==> R;  X~:C ==> R |] ==> R";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   484
by (rtac (major RS INT_E) 1);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   485
by (REPEAT (eresolve_tac prems 1));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   486
qed "InterE";
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   487
1548
afe750876848 Added 'section' commands
nipkow
parents: 1531
diff changeset
   488
section "The Powerset operator -- Pow";
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   489
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   490
qed_goalw "PowI" Set.thy [Pow_def] "!!A B. A <= B ==> A : Pow(B)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   491
 (fn _ => [ (etac CollectI 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   492
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   493
qed_goalw "PowD" Set.thy [Pow_def] "!!A B. A : Pow(B)  ==>  A<=B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   494
 (fn _=> [ (etac CollectD 1) ]);
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   495
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   496
val Pow_bottom = empty_subsetI RS PowI;        (* {}: Pow(B) *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   497
val Pow_top = subset_refl RS PowI;             (* A : Pow(A) *)
1776
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   498
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   499
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   500
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   501
(*** Set reasoning tools ***)
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   502
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   503
2024
909153d8318f Rationalized the rewriting of membership for {} and insert
paulson
parents: 1985
diff changeset
   504
val mem_simps = [insert_iff, empty_iff, Un_iff, Int_iff, Compl_iff, Diff_iff, 
2031
03a843f0f447 Ran expandshort
paulson
parents: 2024
diff changeset
   505
                 mem_Collect_eq];
1776
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   506
1937
e59ff0eb1e91 Proved mem_if
paulson
parents: 1920
diff changeset
   507
(*Not for Addsimps -- it can cause goals to blow up!*)
e59ff0eb1e91 Proved mem_if
paulson
parents: 1920
diff changeset
   508
goal Set.thy "(a : (if Q then x else y)) = ((Q --> a:x) & (~Q --> a : y))";
e59ff0eb1e91 Proved mem_if
paulson
parents: 1920
diff changeset
   509
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
e59ff0eb1e91 Proved mem_if
paulson
parents: 1920
diff changeset
   510
qed "mem_if";
e59ff0eb1e91 Proved mem_if
paulson
parents: 1920
diff changeset
   511
1776
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   512
val mksimps_pairs = ("Ball",[bspec]) :: mksimps_pairs;
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   513
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   514
simpset := !simpset addsimps mem_simps
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   515
                    addcongs [ball_cong,bex_cong]
d7e77cb8ce5c moved mem_simps and the corresponding update of !simpset from Fun.ML to Set.ML,
oheimb
parents: 1762
diff changeset
   516
                    setmksimps (mksimps mksimps_pairs);