src/HOL/subset.ML
changeset 923 ff1574a81019
child 1465 5d7a7e439cec
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/subset.ML	Fri Mar 03 12:02:25 1995 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +(*  Title: 	HOL/subset
     1.5 +    ID:         $Id$
     1.6 +    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1991  University of Cambridge
     1.8 +
     1.9 +Derived rules involving subsets
    1.10 +Union and Intersection as lattice operations
    1.11 +*)
    1.12 +
    1.13 +(*** insert ***)
    1.14 +
    1.15 +qed_goal "subset_insertI" Set.thy "B <= insert a B"
    1.16 + (fn _=> [ (rtac subsetI 1), (etac insertI2 1) ]);
    1.17 +
    1.18 +(*** Big Union -- least upper bound of a set  ***)
    1.19 +
    1.20 +val prems = goal Set.thy
    1.21 +    "B:A ==> B <= Union(A)";
    1.22 +by (REPEAT (ares_tac (prems@[subsetI,UnionI]) 1));
    1.23 +qed "Union_upper";
    1.24 +
    1.25 +val [prem] = goal Set.thy
    1.26 +    "[| !!X. X:A ==> X<=C |] ==> Union(A) <= C";
    1.27 +br subsetI 1;
    1.28 +by (REPEAT (eresolve_tac [asm_rl, UnionE, prem RS subsetD] 1));
    1.29 +qed "Union_least";
    1.30 +
    1.31 +(** General union **)
    1.32 +
    1.33 +val prems = goal Set.thy
    1.34 +    "a:A ==> B(a) <= (UN x:A. B(x))";
    1.35 +by (REPEAT (ares_tac (prems@[UN_I RS subsetI]) 1));
    1.36 +qed "UN_upper";
    1.37 +
    1.38 +val [prem] = goal Set.thy
    1.39 +    "[| !!x. x:A ==> B(x)<=C |] ==> (UN x:A. B(x)) <= C";
    1.40 +br subsetI 1;
    1.41 +by (REPEAT (eresolve_tac [asm_rl, UN_E, prem RS subsetD] 1));
    1.42 +qed "UN_least";
    1.43 +
    1.44 +goal Set.thy "B(a) <= (UN x. B(x))";
    1.45 +by (REPEAT (ares_tac [UN1_I RS subsetI] 1));
    1.46 +qed "UN1_upper";
    1.47 +
    1.48 +val [prem] = goal Set.thy "[| !!x. B(x)<=C |] ==> (UN x. B(x)) <= C";
    1.49 +br subsetI 1;
    1.50 +by (REPEAT (eresolve_tac [asm_rl, UN1_E, prem RS subsetD] 1));
    1.51 +qed "UN1_least";
    1.52 +
    1.53 +
    1.54 +(*** Big Intersection -- greatest lower bound of a set ***)
    1.55 +
    1.56 +val prems = goal Set.thy "B:A ==> Inter(A) <= B";
    1.57 +br subsetI 1;
    1.58 +by (REPEAT (resolve_tac prems 1 ORELSE etac InterD 1));
    1.59 +qed "Inter_lower";
    1.60 +
    1.61 +val [prem] = goal Set.thy
    1.62 +    "[| !!X. X:A ==> C<=X |] ==> C <= Inter(A)";
    1.63 +br (InterI RS subsetI) 1;
    1.64 +by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
    1.65 +qed "Inter_greatest";
    1.66 +
    1.67 +val prems = goal Set.thy "a:A ==> (INT x:A. B(x)) <= B(a)";
    1.68 +br subsetI 1;
    1.69 +by (REPEAT (resolve_tac prems 1 ORELSE etac INT_D 1));
    1.70 +qed "INT_lower";
    1.71 +
    1.72 +val [prem] = goal Set.thy
    1.73 +    "[| !!x. x:A ==> C<=B(x) |] ==> C <= (INT x:A. B(x))";
    1.74 +br (INT_I RS subsetI) 1;
    1.75 +by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
    1.76 +qed "INT_greatest";
    1.77 +
    1.78 +goal Set.thy "(INT x. B(x)) <= B(a)";
    1.79 +br subsetI 1;
    1.80 +by (REPEAT (resolve_tac prems 1 ORELSE etac INT1_D 1));
    1.81 +qed "INT1_lower";
    1.82 +
    1.83 +val [prem] = goal Set.thy
    1.84 +    "[| !!x. C<=B(x) |] ==> C <= (INT x. B(x))";
    1.85 +br (INT1_I RS subsetI) 1;
    1.86 +by (REPEAT (eresolve_tac [asm_rl, prem RS subsetD] 1));
    1.87 +qed "INT1_greatest";
    1.88 +
    1.89 +(*** Finite Union -- the least upper bound of 2 sets ***)
    1.90 +
    1.91 +goal Set.thy "A <= A Un B";
    1.92 +by (REPEAT (ares_tac [subsetI,UnI1] 1));
    1.93 +qed "Un_upper1";
    1.94 +
    1.95 +goal Set.thy "B <= A Un B";
    1.96 +by (REPEAT (ares_tac [subsetI,UnI2] 1));
    1.97 +qed "Un_upper2";
    1.98 +
    1.99 +val prems = goal Set.thy "[| A<=C;  B<=C |] ==> A Un B <= C";
   1.100 +by (cut_facts_tac prems 1);
   1.101 +by (DEPTH_SOLVE (ares_tac [subsetI] 1 
   1.102 +          ORELSE eresolve_tac [UnE,subsetD] 1));
   1.103 +qed "Un_least";
   1.104 +
   1.105 +(*** Finite Intersection -- the greatest lower bound of 2 sets *)
   1.106 +
   1.107 +goal Set.thy "A Int B <= A";
   1.108 +by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
   1.109 +qed "Int_lower1";
   1.110 +
   1.111 +goal Set.thy "A Int B <= B";
   1.112 +by (REPEAT (ares_tac [subsetI] 1 ORELSE etac IntE 1));
   1.113 +qed "Int_lower2";
   1.114 +
   1.115 +val prems = goal Set.thy "[| C<=A;  C<=B |] ==> C <= A Int B";
   1.116 +by (cut_facts_tac prems 1);
   1.117 +by (REPEAT (ares_tac [subsetI,IntI] 1
   1.118 +     ORELSE etac subsetD 1));
   1.119 +qed "Int_greatest";
   1.120 +
   1.121 +(*** Set difference ***)
   1.122 +
   1.123 +qed_goal "Diff_subset" Set.thy "A-B <= (A::'a set)"
   1.124 + (fn _ => [ (REPEAT (ares_tac [subsetI] 1 ORELSE etac DiffE 1)) ]);
   1.125 +
   1.126 +(*** Monotonicity ***)
   1.127 +
   1.128 +val [prem] = goal Set.thy "mono(f) ==> f(A) Un f(B) <= f(A Un B)";
   1.129 +by (rtac Un_least 1);
   1.130 +by (rtac (Un_upper1 RS (prem RS monoD)) 1);
   1.131 +by (rtac (Un_upper2 RS (prem RS monoD)) 1);
   1.132 +qed "mono_Un";
   1.133 +
   1.134 +val [prem] = goal Set.thy "mono(f) ==> f(A Int B) <= f(A) Int f(B)";
   1.135 +by (rtac Int_greatest 1);
   1.136 +by (rtac (Int_lower1 RS (prem RS monoD)) 1);
   1.137 +by (rtac (Int_lower2 RS (prem RS monoD)) 1);
   1.138 +qed "mono_Int";