src/HOL/subset.ML
author clasohm
Wed Mar 13 11:55:25 1996 +0100 (1996-03-13 ago)
changeset 1574 5a63ab90ee8a
parent 1552 6f71b5d46700
child 1631 26570790f089
permissions -rw-r--r--
modified primrec so it can be used in MiniML/Type.thy
clasohm@1465
     1
(*  Title:      HOL/subset
clasohm@923
     2
    ID:         $Id$
clasohm@1465
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@923
     4
    Copyright   1991  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Derived rules involving subsets
clasohm@923
     7
Union and Intersection as lattice operations
clasohm@923
     8
*)
clasohm@923
     9
clasohm@923
    10
(*** insert ***)
clasohm@923
    11
clasohm@923
    12
qed_goal "subset_insertI" Set.thy "B <= insert a B"
clasohm@923
    13
 (fn _=> [ (rtac subsetI 1), (etac insertI2 1) ]);
clasohm@923
    14
nipkow@1531
    15
goal Set.thy "!!x. x ~: A ==> (A <= insert x B) = (A <= B)";
paulson@1552
    16
by (fast_tac set_cs 1);
nipkow@1531
    17
qed "subset_insert";
nipkow@1531
    18
clasohm@923
    19
(*** Big Union -- least upper bound of a set  ***)
clasohm@923
    20
clasohm@923
    21
val prems = goal Set.thy
clasohm@923
    22
    "B:A ==> B <= Union(A)";
clasohm@923
    23
by (REPEAT (ares_tac (prems@[subsetI,UnionI]) 1));
clasohm@923
    24
qed "Union_upper";
clasohm@923
    25
clasohm@923
    26
val [prem] = goal Set.thy
clasohm@923
    27
    "[| !!X. X:A ==> X<=C |] ==> Union(A) <= C";
clasohm@1465
    28
by (rtac subsetI 1);
clasohm@923
    29
by (REPEAT (eresolve_tac [asm_rl, UnionE, prem RS subsetD] 1));
clasohm@923
    30
qed "Union_least";
clasohm@923
    31
clasohm@923
    32
(** General union **)
clasohm@923
    33
clasohm@923
    34
val prems = goal Set.thy
clasohm@923
    35
    "a:A ==> B(a) <= (UN x:A. B(x))";
clasohm@923
    36
by (REPEAT (ares_tac (prems@[UN_I RS subsetI]) 1));
clasohm@923
    37
qed "UN_upper";
clasohm@923
    38
clasohm@923
    39
val [prem] = goal Set.thy
clasohm@923
    40
    "[| !!x. x:A ==> B(x)<=C |] ==> (UN x:A. B(x)) <= C";
clasohm@1465
    41
by (rtac subsetI 1);
clasohm@923
    42
by (REPEAT (eresolve_tac [asm_rl, UN_E, prem RS subsetD] 1));
clasohm@923
    43
qed "UN_least";
clasohm@923
    44
clasohm@923
    45
goal Set.thy "B(a) <= (UN x. B(x))";
clasohm@923
    46
by (REPEAT (ares_tac [UN1_I RS subsetI] 1));
clasohm@923
    47
qed "UN1_upper";
clasohm@923
    48
clasohm@923
    49
val [prem] = goal Set.thy "[| !!x. B(x)<=C |] ==> (UN x. B(x)) <= C";
clasohm@1465
    50
by (rtac subsetI 1);
clasohm@923
    51
by (REPEAT (eresolve_tac [asm_rl, UN1_E, prem RS subsetD] 1));
clasohm@923
    52
qed "UN1_least";
clasohm@923
    53
clasohm@923
    54
clasohm@923
    55
(*** Big Intersection -- greatest lower bound of a set ***)
clasohm@923
    56
clasohm@923
    57
val prems = goal Set.thy "B:A ==> Inter(A) <= B";
clasohm@1465
    58
by (rtac subsetI 1);
clasohm@923
    59
by (REPEAT (resolve_tac prems 1 ORELSE etac InterD 1));
clasohm@923
    60
qed "Inter_lower";
clasohm@923
    61
clasohm@923
    62
val [prem] = goal Set.thy
clasohm@923
    63
    "[| !!X. X:A ==> C<=X |] ==> C <= Inter(A)";
clasohm@1465
    64
by (rtac (InterI RS subsetI) 1);
clasohm@923
    65
by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
clasohm@923
    66
qed "Inter_greatest";
clasohm@923
    67
clasohm@923
    68
val prems = goal Set.thy "a:A ==> (INT x:A. B(x)) <= B(a)";
clasohm@1465
    69
by (rtac subsetI 1);
clasohm@923
    70
by (REPEAT (resolve_tac prems 1 ORELSE etac INT_D 1));
clasohm@923
    71
qed "INT_lower";
clasohm@923
    72
clasohm@923
    73
val [prem] = goal Set.thy
clasohm@923
    74
    "[| !!x. x:A ==> C<=B(x) |] ==> C <= (INT x:A. B(x))";
clasohm@1465
    75
by (rtac (INT_I RS subsetI) 1);
clasohm@923
    76
by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
clasohm@923
    77
qed "INT_greatest";
clasohm@923
    78
clasohm@923
    79
goal Set.thy "(INT x. B(x)) <= B(a)";
clasohm@1465
    80
by (rtac subsetI 1);
clasohm@923
    81
by (REPEAT (resolve_tac prems 1 ORELSE etac INT1_D 1));
clasohm@923
    82
qed "INT1_lower";
clasohm@923
    83
clasohm@923
    84
val [prem] = goal Set.thy
clasohm@923
    85
    "[| !!x. C<=B(x) |] ==> C <= (INT x. B(x))";
clasohm@1465
    86
by (rtac (INT1_I RS subsetI) 1);
clasohm@923
    87
by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
clasohm@923
    88
qed "INT1_greatest";
clasohm@923
    89
clasohm@923
    90
(*** Finite Union -- the least upper bound of 2 sets ***)
clasohm@923
    91
clasohm@923
    92
goal Set.thy "A <= A Un B";
clasohm@923
    93
by (REPEAT (ares_tac [subsetI,UnI1] 1));
clasohm@923
    94
qed "Un_upper1";
clasohm@923
    95
clasohm@923
    96
goal Set.thy "B <= A Un B";
clasohm@923
    97
by (REPEAT (ares_tac [subsetI,UnI2] 1));
clasohm@923
    98
qed "Un_upper2";
clasohm@923
    99
clasohm@923
   100
val prems = goal Set.thy "[| A<=C;  B<=C |] ==> A Un B <= C";
clasohm@923
   101
by (cut_facts_tac prems 1);
clasohm@923
   102
by (DEPTH_SOLVE (ares_tac [subsetI] 1 
clasohm@923
   103
          ORELSE eresolve_tac [UnE,subsetD] 1));
clasohm@923
   104
qed "Un_least";
clasohm@923
   105
clasohm@923
   106
(*** Finite Intersection -- the greatest lower bound of 2 sets *)
clasohm@923
   107
clasohm@923
   108
goal Set.thy "A Int B <= A";
clasohm@923
   109
by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
clasohm@923
   110
qed "Int_lower1";
clasohm@923
   111
clasohm@923
   112
goal Set.thy "A Int B <= B";
clasohm@923
   113
by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
clasohm@923
   114
qed "Int_lower2";
clasohm@923
   115
clasohm@923
   116
val prems = goal Set.thy "[| C<=A;  C<=B |] ==> C <= A Int B";
clasohm@923
   117
by (cut_facts_tac prems 1);
clasohm@923
   118
by (REPEAT (ares_tac [subsetI,IntI] 1
clasohm@923
   119
     ORELSE etac subsetD 1));
clasohm@923
   120
qed "Int_greatest";
clasohm@923
   121
clasohm@923
   122
(*** Set difference ***)
clasohm@923
   123
clasohm@923
   124
qed_goal "Diff_subset" Set.thy "A-B <= (A::'a set)"
clasohm@923
   125
 (fn _ => [ (REPEAT (ares_tac [subsetI] 1 ORELSE etac DiffE 1)) ]);
clasohm@923
   126
clasohm@923
   127
(*** Monotonicity ***)
clasohm@923
   128
clasohm@923
   129
val [prem] = goal Set.thy "mono(f) ==> f(A) Un f(B) <= f(A Un B)";
clasohm@923
   130
by (rtac Un_least 1);
clasohm@923
   131
by (rtac (Un_upper1 RS (prem RS monoD)) 1);
clasohm@923
   132
by (rtac (Un_upper2 RS (prem RS monoD)) 1);
clasohm@923
   133
qed "mono_Un";
clasohm@923
   134
clasohm@923
   135
val [prem] = goal Set.thy "mono(f) ==> f(A Int B) <= f(A) Int f(B)";
clasohm@923
   136
by (rtac Int_greatest 1);
clasohm@923
   137
by (rtac (Int_lower1 RS (prem RS monoD)) 1);
clasohm@923
   138
by (rtac (Int_lower2 RS (prem RS monoD)) 1);
clasohm@923
   139
qed "mono_Int";