src/CCL/subset.ML
author gagern
Wed, 20 Apr 2005 14:18:33 +0200
changeset 15778 98af3693f6b3
parent 4347 d683b7898c61
child 17456 bcf7544875b2
permissions -rw-r--r--
Allow symlinks to shell scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     1
(*  Title:      CCL/subset
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
Modified version of
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     5
    Title:      HOL/subset
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
     6
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
    Copyright   1991  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     9
Derived rules involving subsets
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
Union and Intersection as lattice operations
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    12
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
(*** Big Union -- least upper bound of a set  ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    16
    "B:A ==> B <= Union(A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
by (REPEAT (ares_tac (prems@[subsetI,UnionI]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    18
qed "Union_upper";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    19
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    20
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    21
    "[| !!X. X:A ==> X<=C |] ==> Union(A) <= C";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    22
by (REPEAT (ares_tac [subsetI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    23
     ORELSE eresolve_tac ([UnionE] @ (prems RL [subsetD])) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    24
qed "Union_least";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    27
(*** Big Intersection -- greatest lower bound of a set ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    29
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
    "B:A ==> Inter(A) <= B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
by (REPEAT (resolve_tac (prems@[subsetI]) 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
     ORELSE etac InterD 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    33
qed "Inter_lower";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    35
val prems = goal Set.thy
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    36
    "[| !!X. X:A ==> C<=X |] ==> C <= Inter(A)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    37
by (REPEAT (ares_tac [subsetI,InterI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    38
     ORELSE eresolve_tac (prems RL [subsetD]) 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    39
qed "Inter_greatest";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    40
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
(*** Finite Union -- the least upper bound of 2 sets ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    43
goal Set.thy "A <= A Un B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    44
by (REPEAT (ares_tac [subsetI,UnI1] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    45
qed "Un_upper1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    46
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    47
goal Set.thy "B <= A Un B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    48
by (REPEAT (ares_tac [subsetI,UnI2] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    49
qed "Un_upper2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    50
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    51
val prems = goal Set.thy "[| A<=C;  B<=C |] ==> A Un B <= C";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    52
by (cut_facts_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
by (DEPTH_SOLVE (ares_tac [subsetI] 1 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
          ORELSE eresolve_tac [UnE,subsetD] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    55
qed "Un_least";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    56
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    57
(*** Finite Intersection -- the greatest lower bound of 2 sets *)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
goal Set.thy "A Int B <= A";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    61
qed "Int_lower1";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
goal Set.thy "A Int B <= B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    64
by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    65
qed "Int_lower2";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    66
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    67
val prems = goal Set.thy "[| C<=A;  C<=B |] ==> C <= A Int B";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    68
by (cut_facts_tac prems 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    69
by (REPEAT (ares_tac [subsetI,IntI] 1
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    70
     ORELSE etac subsetD 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    71
qed "Int_greatest";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    72
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    73
(*** Monotonicity ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    74
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    75
val [prem] = goalw Set.thy [mono_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    76
    "[| !!A B. A <= B ==> f(A) <= f(B) |] ==> mono(f)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    77
by (REPEAT (ares_tac [allI, impI, prem] 1));
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    78
qed "monoI";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    79
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    80
val [major,minor] = goalw Set.thy [mono_def]
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    81
    "[| mono(f);  A <= B |] ==> f(A) <= f(B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    82
by (rtac (major RS spec RS spec RS mp) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    83
by (rtac minor 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    84
qed "monoD";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    85
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    86
val [prem] = goal Set.thy "mono(f) ==> f(A) Un f(B) <= f(A Un B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    87
by (rtac Un_least 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    88
by (rtac (Un_upper1 RS (prem RS monoD)) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    89
by (rtac (Un_upper2 RS (prem RS monoD)) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    90
qed "mono_Un";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    91
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    92
val [prem] = goal Set.thy "mono(f) ==> f(A Int B) <= f(A) Int f(B)";
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    93
by (rtac Int_greatest 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    94
by (rtac (Int_lower1 RS (prem RS monoD)) 1);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    95
by (rtac (Int_lower2 RS (prem RS monoD)) 1);
757
2ca12511676d added qed and qed_goal[w]
clasohm
parents: 8
diff changeset
    96
qed "mono_Int";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    97
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    98
(****)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    99
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   100
val set_cs = FOL_cs 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   101
    addSIs [ballI, subsetI, InterI, INT_I, CollectI, 
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
   102
            ComplI, IntI, UnCI, singletonI] 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   103
    addIs  [bexI, UnionI, UN_I] 
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   104
    addSEs [bexE, UnionE, UN_E,
1459
d12da312eff4 expanded tabs
clasohm
parents: 757
diff changeset
   105
            CollectE, ComplE, IntE, UnE, emptyE, singletonE] 
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   106
    addEs  [ballE, InterD, InterE, INT_D, INT_E, subsetD, subsetCE];
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   107
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   108
fun cfast_tac prems = cut_facts_tac prems THEN' fast_tac set_cs;
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   109
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   110
fun prover s = prove_goal Set.thy s (fn _=>[fast_tac set_cs 1]);
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   111
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   112
val mem_rews = [trivial_set,empty_eq] @ (map prover
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   113
 [ "(a : A Un B)   <->  (a:A | a:B)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   114
   "(a : A Int B)  <->  (a:A & a:B)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   115
   "(a : Compl(B)) <->  (~a:B)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   116
   "(a : {b})      <->  (a=b)",
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   117
   "(a : {})       <->   False",
3837
d7f033c74b38 fixed dots;
wenzelm
parents: 2035
diff changeset
   118
   "(a : {x. P(x)}) <->  P(a)" ]);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   119
8
c3d2c6dcf3f0 Installation of new simplfier. Previously appeared to set up the old
lcp
parents: 0
diff changeset
   120
val set_congs = [ball_cong, bex_cong, INT_cong, UN_cong];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   121
1963
a4abf41134e2 These simpsets must not use miniscoping
paulson
parents: 1459
diff changeset
   122
val set_ss = FOL_ss addcongs set_congs
2035
e329b36d9136 Ran expandshort; used stac instead of ssubst
paulson
parents: 1963
diff changeset
   123
                    addsimps mem_rews;