src/HOL/Set.thy
author kleing
Wed Apr 14 14:13:05 2004 +0200 (2004-04-14)
changeset 14565 c6dc17aab88a
parent 14551 2cb6ff394bfb
child 14692 b8d6c395c9e2
permissions -rw-r--r--
use more symbols in HTML output
clasohm@923
     1
(*  Title:      HOL/Set.thy
clasohm@923
     2
    ID:         $Id$
wenzelm@12257
     3
    Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel
wenzelm@12020
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
clasohm@923
     5
*)
clasohm@923
     6
wenzelm@11979
     7
header {* Set theory for higher-order logic *}
wenzelm@11979
     8
wenzelm@12897
     9
theory Set = HOL:
wenzelm@11979
    10
wenzelm@11979
    11
text {* A set in HOL is simply a predicate. *}
clasohm@923
    12
wenzelm@2261
    13
wenzelm@11979
    14
subsection {* Basic syntax *}
wenzelm@2261
    15
wenzelm@3947
    16
global
wenzelm@3947
    17
wenzelm@11979
    18
typedecl 'a set
wenzelm@12338
    19
arities set :: (type) type
wenzelm@3820
    20
clasohm@923
    21
consts
wenzelm@11979
    22
  "{}"          :: "'a set"                             ("{}")
wenzelm@11979
    23
  UNIV          :: "'a set"
wenzelm@11979
    24
  insert        :: "'a => 'a set => 'a set"
wenzelm@11979
    25
  Collect       :: "('a => bool) => 'a set"              -- "comprehension"
wenzelm@11979
    26
  Int           :: "'a set => 'a set => 'a set"          (infixl 70)
wenzelm@11979
    27
  Un            :: "'a set => 'a set => 'a set"          (infixl 65)
wenzelm@11979
    28
  UNION         :: "'a set => ('a => 'b set) => 'b set"  -- "general union"
wenzelm@11979
    29
  INTER         :: "'a set => ('a => 'b set) => 'b set"  -- "general intersection"
wenzelm@11979
    30
  Union         :: "'a set set => 'a set"                -- "union of a set"
wenzelm@11979
    31
  Inter         :: "'a set set => 'a set"                -- "intersection of a set"
wenzelm@11979
    32
  Pow           :: "'a set => 'a set set"                -- "powerset"
wenzelm@11979
    33
  Ball          :: "'a set => ('a => bool) => bool"      -- "bounded universal quantifiers"
wenzelm@11979
    34
  Bex           :: "'a set => ('a => bool) => bool"      -- "bounded existential quantifiers"
wenzelm@11979
    35
  image         :: "('a => 'b) => 'a set => 'b set"      (infixr "`" 90)
wenzelm@11979
    36
wenzelm@11979
    37
syntax
wenzelm@11979
    38
  "op :"        :: "'a => 'a set => bool"                ("op :")
wenzelm@11979
    39
consts
wenzelm@11979
    40
  "op :"        :: "'a => 'a set => bool"                ("(_/ : _)" [50, 51] 50)  -- "membership"
wenzelm@11979
    41
wenzelm@11979
    42
local
wenzelm@11979
    43
wenzelm@12338
    44
instance set :: (type) ord ..
wenzelm@12338
    45
instance set :: (type) minus ..
clasohm@923
    46
clasohm@923
    47
wenzelm@11979
    48
subsection {* Additional concrete syntax *}
wenzelm@2261
    49
clasohm@923
    50
syntax
wenzelm@11979
    51
  range         :: "('a => 'b) => 'b set"             -- "of function"
clasohm@923
    52
wenzelm@11979
    53
  "op ~:"       :: "'a => 'a set => bool"                 ("op ~:")  -- "non-membership"
wenzelm@11979
    54
  "op ~:"       :: "'a => 'a set => bool"                 ("(_/ ~: _)" [50, 51] 50)
wenzelm@7238
    55
wenzelm@11979
    56
  "@Finset"     :: "args => 'a set"                       ("{(_)}")
wenzelm@11979
    57
  "@Coll"       :: "pttrn => bool => 'a set"              ("(1{_./ _})")
wenzelm@11979
    58
  "@SetCompr"   :: "'a => idts => bool => 'a set"         ("(1{_ |/_./ _})")
clasohm@923
    59
wenzelm@11979
    60
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" 10)
wenzelm@11979
    61
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" 10)
wenzelm@11979
    62
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" 10)
wenzelm@11979
    63
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" 10)
clasohm@923
    64
wenzelm@11979
    65
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3ALL _:_./ _)" [0, 0, 10] 10)
wenzelm@11979
    66
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3EX _:_./ _)" [0, 0, 10] 10)
clasohm@923
    67
wenzelm@7238
    68
syntax (HOL)
wenzelm@11979
    69
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3! _:_./ _)" [0, 0, 10] 10)
wenzelm@11979
    70
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3? _:_./ _)" [0, 0, 10] 10)
clasohm@923
    71
clasohm@923
    72
translations
nipkow@10832
    73
  "range f"     == "f`UNIV"
clasohm@923
    74
  "x ~: y"      == "~ (x : y)"
clasohm@923
    75
  "{x, xs}"     == "insert x {xs}"
clasohm@923
    76
  "{x}"         == "insert x {}"
nipkow@13764
    77
  "{x. P}"      == "Collect (%x. P)"
paulson@4159
    78
  "UN x y. B"   == "UN x. UN y. B"
paulson@4159
    79
  "UN x. B"     == "UNION UNIV (%x. B)"
nipkow@13858
    80
  "UN x. B"     == "UN x:UNIV. B"
wenzelm@7238
    81
  "INT x y. B"  == "INT x. INT y. B"
paulson@4159
    82
  "INT x. B"    == "INTER UNIV (%x. B)"
nipkow@13858
    83
  "INT x. B"    == "INT x:UNIV. B"
nipkow@13764
    84
  "UN x:A. B"   == "UNION A (%x. B)"
nipkow@13764
    85
  "INT x:A. B"  == "INTER A (%x. B)"
nipkow@13764
    86
  "ALL x:A. P"  == "Ball A (%x. P)"
nipkow@13764
    87
  "EX x:A. P"   == "Bex A (%x. P)"
clasohm@923
    88
wenzelm@12633
    89
syntax (output)
wenzelm@11979
    90
  "_setle"      :: "'a set => 'a set => bool"             ("op <=")
wenzelm@11979
    91
  "_setle"      :: "'a set => 'a set => bool"             ("(_/ <= _)" [50, 51] 50)
wenzelm@11979
    92
  "_setless"    :: "'a set => 'a set => bool"             ("op <")
wenzelm@11979
    93
  "_setless"    :: "'a set => 'a set => bool"             ("(_/ < _)" [50, 51] 50)
clasohm@923
    94
wenzelm@12114
    95
syntax (xsymbols)
wenzelm@11979
    96
  "_setle"      :: "'a set => 'a set => bool"             ("op \<subseteq>")
wenzelm@11979
    97
  "_setle"      :: "'a set => 'a set => bool"             ("(_/ \<subseteq> _)" [50, 51] 50)
wenzelm@11979
    98
  "_setless"    :: "'a set => 'a set => bool"             ("op \<subset>")
wenzelm@11979
    99
  "_setless"    :: "'a set => 'a set => bool"             ("(_/ \<subset> _)" [50, 51] 50)
wenzelm@11979
   100
  "op Int"      :: "'a set => 'a set => 'a set"           (infixl "\<inter>" 70)
wenzelm@11979
   101
  "op Un"       :: "'a set => 'a set => 'a set"           (infixl "\<union>" 65)
wenzelm@11979
   102
  "op :"        :: "'a => 'a set => bool"                 ("op \<in>")
wenzelm@11979
   103
  "op :"        :: "'a => 'a set => bool"                 ("(_/ \<in> _)" [50, 51] 50)
wenzelm@11979
   104
  "op ~:"       :: "'a => 'a set => bool"                 ("op \<notin>")
wenzelm@11979
   105
  "op ~:"       :: "'a => 'a set => bool"                 ("(_/ \<notin> _)" [50, 51] 50)
nipkow@14381
   106
  Union         :: "'a set set => 'a set"                 ("\<Union>_" [90] 90)
nipkow@14381
   107
  Inter         :: "'a set set => 'a set"                 ("\<Inter>_" [90] 90)
nipkow@14381
   108
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
nipkow@14381
   109
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
nipkow@14381
   110
kleing@14565
   111
syntax (HTML output)
kleing@14565
   112
  "_setle"      :: "'a set => 'a set => bool"             ("op \<subseteq>")
kleing@14565
   113
  "_setle"      :: "'a set => 'a set => bool"             ("(_/ \<subseteq> _)" [50, 51] 50)
kleing@14565
   114
  "_setless"    :: "'a set => 'a set => bool"             ("op \<subset>")
kleing@14565
   115
  "_setless"    :: "'a set => 'a set => bool"             ("(_/ \<subset> _)" [50, 51] 50)
kleing@14565
   116
  "op Int"      :: "'a set => 'a set => 'a set"           (infixl "\<inter>" 70)
kleing@14565
   117
  "op Un"       :: "'a set => 'a set => 'a set"           (infixl "\<union>" 65)
kleing@14565
   118
  "op :"        :: "'a => 'a set => bool"                 ("op \<in>")
kleing@14565
   119
  "op :"        :: "'a => 'a set => bool"                 ("(_/ \<in> _)" [50, 51] 50)
kleing@14565
   120
  "op ~:"       :: "'a => 'a set => bool"                 ("op \<notin>")
kleing@14565
   121
  "op ~:"       :: "'a => 'a set => bool"                 ("(_/ \<notin> _)" [50, 51] 50)
kleing@14565
   122
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
kleing@14565
   123
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
kleing@14565
   124
nipkow@14381
   125
syntax (input)
wenzelm@11979
   126
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" 10)
wenzelm@11979
   127
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" 10)
wenzelm@11979
   128
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" 10)
wenzelm@11979
   129
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" 10)
nipkow@14381
   130
nipkow@14381
   131
syntax (xsymbols)
nipkow@14381
   132
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>\<^bsub>_\<^esub>/ _)" 10)
nipkow@14381
   133
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>\<^bsub>_\<^esub>/ _)" 10)
nipkow@14381
   134
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>\<^bsub>_\<in>_\<^esub>/ _)" 10)
nipkow@14381
   135
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>\<^bsub>_\<in>_\<^esub>/ _)" 10)
wenzelm@2261
   136
kleing@14565
   137
wenzelm@2412
   138
translations
wenzelm@11979
   139
  "op \<subseteq>" => "op <= :: _ set => _ set => bool"
wenzelm@11979
   140
  "op \<subset>" => "op <  :: _ set => _ set => bool"
wenzelm@2261
   141
wenzelm@2261
   142
wenzelm@11979
   143
typed_print_translation {*
wenzelm@11979
   144
  let
wenzelm@11979
   145
    fun le_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
wenzelm@11979
   146
          list_comb (Syntax.const "_setle", ts)
wenzelm@11979
   147
      | le_tr' _ _ _ = raise Match;
wenzelm@11979
   148
wenzelm@11979
   149
    fun less_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
wenzelm@11979
   150
          list_comb (Syntax.const "_setless", ts)
wenzelm@11979
   151
      | less_tr' _ _ _ = raise Match;
wenzelm@11979
   152
  in [("op <=", le_tr'), ("op <", less_tr')] end
wenzelm@11979
   153
*}
wenzelm@2261
   154
wenzelm@11979
   155
text {*
wenzelm@11979
   156
  \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
wenzelm@11979
   157
  "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
wenzelm@11979
   158
  only translated if @{text "[0..n] subset bvs(e)"}.
wenzelm@11979
   159
*}
wenzelm@11979
   160
wenzelm@11979
   161
parse_translation {*
wenzelm@11979
   162
  let
wenzelm@11979
   163
    val ex_tr = snd (mk_binder_tr ("EX ", "Ex"));
wenzelm@3947
   164
wenzelm@11979
   165
    fun nvars (Const ("_idts", _) $ _ $ idts) = nvars idts + 1
wenzelm@11979
   166
      | nvars _ = 1;
wenzelm@11979
   167
wenzelm@11979
   168
    fun setcompr_tr [e, idts, b] =
wenzelm@11979
   169
      let
wenzelm@11979
   170
        val eq = Syntax.const "op =" $ Bound (nvars idts) $ e;
wenzelm@11979
   171
        val P = Syntax.const "op &" $ eq $ b;
wenzelm@11979
   172
        val exP = ex_tr [idts, P];
wenzelm@11979
   173
      in Syntax.const "Collect" $ Abs ("", dummyT, exP) end;
wenzelm@11979
   174
wenzelm@11979
   175
  in [("@SetCompr", setcompr_tr)] end;
wenzelm@11979
   176
*}
clasohm@923
   177
nipkow@13763
   178
(* To avoid eta-contraction of body: *)
wenzelm@11979
   179
print_translation {*
nipkow@13763
   180
let
nipkow@13763
   181
  fun btr' syn [A,Abs abs] =
nipkow@13763
   182
    let val (x,t) = atomic_abs_tr' abs
nipkow@13763
   183
    in Syntax.const syn $ x $ A $ t end
nipkow@13763
   184
in
nipkow@13858
   185
[("Ball", btr' "_Ball"),("Bex", btr' "_Bex"),
nipkow@13858
   186
 ("UNION", btr' "@UNION"),("INTER", btr' "@INTER")]
nipkow@13763
   187
end
nipkow@13763
   188
*}
nipkow@13763
   189
nipkow@13763
   190
print_translation {*
nipkow@13763
   191
let
nipkow@13763
   192
  val ex_tr' = snd (mk_binder_tr' ("Ex", "DUMMY"));
nipkow@13763
   193
nipkow@13763
   194
  fun setcompr_tr' [Abs (abs as (_, _, P))] =
nipkow@13763
   195
    let
nipkow@13763
   196
      fun check (Const ("Ex", _) $ Abs (_, _, P), n) = check (P, n + 1)
nipkow@13763
   197
        | check (Const ("op &", _) $ (Const ("op =", _) $ Bound m $ e) $ P, n) =
nipkow@13763
   198
            n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso
nipkow@13763
   199
            ((0 upto (n - 1)) subset add_loose_bnos (e, 0, []))
nipkow@13764
   200
        | check _ = false
clasohm@923
   201
wenzelm@11979
   202
        fun tr' (_ $ abs) =
wenzelm@11979
   203
          let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' [abs]
wenzelm@11979
   204
          in Syntax.const "@SetCompr" $ e $ idts $ Q end;
nipkow@13763
   205
    in if check (P, 0) then tr' P
nipkow@13763
   206
       else let val (x,t) = atomic_abs_tr' abs
nipkow@13763
   207
            in Syntax.const "@Coll" $ x $ t end
nipkow@13763
   208
    end;
wenzelm@11979
   209
  in [("Collect", setcompr_tr')] end;
wenzelm@11979
   210
*}
wenzelm@11979
   211
wenzelm@11979
   212
wenzelm@11979
   213
subsection {* Rules and definitions *}
wenzelm@11979
   214
wenzelm@11979
   215
text {* Isomorphisms between predicates and sets. *}
clasohm@923
   216
wenzelm@11979
   217
axioms
wenzelm@11979
   218
  mem_Collect_eq [iff]: "(a : {x. P(x)}) = P(a)"
wenzelm@11979
   219
  Collect_mem_eq [simp]: "{x. x:A} = A"
wenzelm@11979
   220
wenzelm@11979
   221
defs
wenzelm@11979
   222
  Ball_def:     "Ball A P       == ALL x. x:A --> P(x)"
wenzelm@11979
   223
  Bex_def:      "Bex A P        == EX x. x:A & P(x)"
wenzelm@11979
   224
wenzelm@11979
   225
defs (overloaded)
wenzelm@11979
   226
  subset_def:   "A <= B         == ALL x:A. x:B"
wenzelm@11979
   227
  psubset_def:  "A < B          == (A::'a set) <= B & ~ A=B"
wenzelm@11979
   228
  Compl_def:    "- A            == {x. ~x:A}"
wenzelm@12257
   229
  set_diff_def: "A - B          == {x. x:A & ~x:B}"
clasohm@923
   230
clasohm@923
   231
defs
wenzelm@11979
   232
  Un_def:       "A Un B         == {x. x:A | x:B}"
wenzelm@11979
   233
  Int_def:      "A Int B        == {x. x:A & x:B}"
wenzelm@11979
   234
  INTER_def:    "INTER A B      == {y. ALL x:A. y: B(x)}"
wenzelm@11979
   235
  UNION_def:    "UNION A B      == {y. EX x:A. y: B(x)}"
wenzelm@11979
   236
  Inter_def:    "Inter S        == (INT x:S. x)"
wenzelm@11979
   237
  Union_def:    "Union S        == (UN x:S. x)"
wenzelm@11979
   238
  Pow_def:      "Pow A          == {B. B <= A}"
wenzelm@11979
   239
  empty_def:    "{}             == {x. False}"
wenzelm@11979
   240
  UNIV_def:     "UNIV           == {x. True}"
wenzelm@11979
   241
  insert_def:   "insert a B     == {x. x=a} Un B"
wenzelm@11979
   242
  image_def:    "f`A            == {y. EX x:A. y = f(x)}"
wenzelm@11979
   243
wenzelm@11979
   244
wenzelm@11979
   245
subsection {* Lemmas and proof tool setup *}
wenzelm@11979
   246
wenzelm@11979
   247
subsubsection {* Relating predicates and sets *}
wenzelm@11979
   248
wenzelm@12257
   249
lemma CollectI: "P(a) ==> a : {x. P(x)}"
wenzelm@11979
   250
  by simp
wenzelm@11979
   251
wenzelm@11979
   252
lemma CollectD: "a : {x. P(x)} ==> P(a)"
wenzelm@11979
   253
  by simp
wenzelm@11979
   254
wenzelm@11979
   255
lemma Collect_cong: "(!!x. P x = Q x) ==> {x. P(x)} = {x. Q(x)}"
wenzelm@11979
   256
  by simp
wenzelm@11979
   257
wenzelm@12257
   258
lemmas CollectE = CollectD [elim_format]
wenzelm@11979
   259
wenzelm@11979
   260
wenzelm@11979
   261
subsubsection {* Bounded quantifiers *}
wenzelm@11979
   262
wenzelm@11979
   263
lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x"
wenzelm@11979
   264
  by (simp add: Ball_def)
wenzelm@11979
   265
wenzelm@11979
   266
lemmas strip = impI allI ballI
wenzelm@11979
   267
wenzelm@11979
   268
lemma bspec [dest?]: "ALL x:A. P x ==> x:A ==> P x"
wenzelm@11979
   269
  by (simp add: Ball_def)
wenzelm@11979
   270
wenzelm@11979
   271
lemma ballE [elim]: "ALL x:A. P x ==> (P x ==> Q) ==> (x ~: A ==> Q) ==> Q"
wenzelm@11979
   272
  by (unfold Ball_def) blast
oheimb@14098
   273
ML {* bind_thm("rev_ballE",permute_prems 1 1 (thm "ballE")) *}
wenzelm@11979
   274
wenzelm@11979
   275
text {*
wenzelm@11979
   276
  \medskip This tactic takes assumptions @{prop "ALL x:A. P x"} and
wenzelm@11979
   277
  @{prop "a:A"}; creates assumption @{prop "P a"}.
wenzelm@11979
   278
*}
wenzelm@11979
   279
wenzelm@11979
   280
ML {*
wenzelm@11979
   281
  local val ballE = thm "ballE"
wenzelm@11979
   282
  in fun ball_tac i = etac ballE i THEN contr_tac (i + 1) end;
wenzelm@11979
   283
*}
wenzelm@11979
   284
wenzelm@11979
   285
text {*
wenzelm@11979
   286
  Gives better instantiation for bound:
wenzelm@11979
   287
*}
wenzelm@11979
   288
wenzelm@11979
   289
ML_setup {*
wenzelm@11979
   290
  claset_ref() := claset() addbefore ("bspec", datac (thm "bspec") 1);
wenzelm@11979
   291
*}
wenzelm@11979
   292
wenzelm@11979
   293
lemma bexI [intro]: "P x ==> x:A ==> EX x:A. P x"
wenzelm@11979
   294
  -- {* Normally the best argument order: @{prop "P x"} constrains the
wenzelm@11979
   295
    choice of @{prop "x:A"}. *}
wenzelm@11979
   296
  by (unfold Bex_def) blast
wenzelm@11979
   297
wenzelm@13113
   298
lemma rev_bexI [intro?]: "x:A ==> P x ==> EX x:A. P x"
wenzelm@11979
   299
  -- {* The best argument order when there is only one @{prop "x:A"}. *}
wenzelm@11979
   300
  by (unfold Bex_def) blast
wenzelm@11979
   301
wenzelm@11979
   302
lemma bexCI: "(ALL x:A. ~P x ==> P a) ==> a:A ==> EX x:A. P x"
wenzelm@11979
   303
  by (unfold Bex_def) blast
wenzelm@11979
   304
wenzelm@11979
   305
lemma bexE [elim!]: "EX x:A. P x ==> (!!x. x:A ==> P x ==> Q) ==> Q"
wenzelm@11979
   306
  by (unfold Bex_def) blast
wenzelm@11979
   307
wenzelm@11979
   308
lemma ball_triv [simp]: "(ALL x:A. P) = ((EX x. x:A) --> P)"
wenzelm@11979
   309
  -- {* Trival rewrite rule. *}
wenzelm@11979
   310
  by (simp add: Ball_def)
wenzelm@11979
   311
wenzelm@11979
   312
lemma bex_triv [simp]: "(EX x:A. P) = ((EX x. x:A) & P)"
wenzelm@11979
   313
  -- {* Dual form for existentials. *}
wenzelm@11979
   314
  by (simp add: Bex_def)
wenzelm@11979
   315
wenzelm@11979
   316
lemma bex_triv_one_point1 [simp]: "(EX x:A. x = a) = (a:A)"
wenzelm@11979
   317
  by blast
wenzelm@11979
   318
wenzelm@11979
   319
lemma bex_triv_one_point2 [simp]: "(EX x:A. a = x) = (a:A)"
wenzelm@11979
   320
  by blast
wenzelm@11979
   321
wenzelm@11979
   322
lemma bex_one_point1 [simp]: "(EX x:A. x = a & P x) = (a:A & P a)"
wenzelm@11979
   323
  by blast
wenzelm@11979
   324
wenzelm@11979
   325
lemma bex_one_point2 [simp]: "(EX x:A. a = x & P x) = (a:A & P a)"
wenzelm@11979
   326
  by blast
wenzelm@11979
   327
wenzelm@11979
   328
lemma ball_one_point1 [simp]: "(ALL x:A. x = a --> P x) = (a:A --> P a)"
wenzelm@11979
   329
  by blast
wenzelm@11979
   330
wenzelm@11979
   331
lemma ball_one_point2 [simp]: "(ALL x:A. a = x --> P x) = (a:A --> P a)"
wenzelm@11979
   332
  by blast
wenzelm@11979
   333
wenzelm@11979
   334
ML_setup {*
wenzelm@13462
   335
  local
wenzelm@11979
   336
    val Ball_def = thm "Ball_def";
wenzelm@11979
   337
    val Bex_def = thm "Bex_def";
wenzelm@11979
   338
wenzelm@11979
   339
    val prove_bex_tac =
wenzelm@11979
   340
      rewrite_goals_tac [Bex_def] THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@11979
   341
    val rearrange_bex = Quantifier1.rearrange_bex prove_bex_tac;
wenzelm@11979
   342
wenzelm@11979
   343
    val prove_ball_tac =
wenzelm@11979
   344
      rewrite_goals_tac [Ball_def] THEN Quantifier1.prove_one_point_all_tac;
wenzelm@11979
   345
    val rearrange_ball = Quantifier1.rearrange_ball prove_ball_tac;
wenzelm@11979
   346
  in
wenzelm@13462
   347
    val defBEX_regroup = Simplifier.simproc (Theory.sign_of (the_context ()))
wenzelm@13462
   348
      "defined BEX" ["EX x:A. P x & Q x"] rearrange_bex;
wenzelm@13462
   349
    val defBALL_regroup = Simplifier.simproc (Theory.sign_of (the_context ()))
wenzelm@13462
   350
      "defined BALL" ["ALL x:A. P x --> Q x"] rearrange_ball;
wenzelm@11979
   351
  end;
wenzelm@13462
   352
wenzelm@13462
   353
  Addsimprocs [defBALL_regroup, defBEX_regroup];
wenzelm@11979
   354
*}
wenzelm@11979
   355
wenzelm@11979
   356
wenzelm@11979
   357
subsubsection {* Congruence rules *}
wenzelm@11979
   358
wenzelm@11979
   359
lemma ball_cong [cong]:
wenzelm@11979
   360
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   361
    (ALL x:A. P x) = (ALL x:B. Q x)"
wenzelm@11979
   362
  by (simp add: Ball_def)
wenzelm@11979
   363
wenzelm@11979
   364
lemma bex_cong [cong]:
wenzelm@11979
   365
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   366
    (EX x:A. P x) = (EX x:B. Q x)"
wenzelm@11979
   367
  by (simp add: Bex_def cong: conj_cong)
regensbu@1273
   368
wenzelm@7238
   369
wenzelm@11979
   370
subsubsection {* Subsets *}
wenzelm@11979
   371
wenzelm@12897
   372
lemma subsetI [intro!]: "(!!x. x:A ==> x:B) ==> A \<subseteq> B"
wenzelm@11979
   373
  by (simp add: subset_def)
wenzelm@11979
   374
wenzelm@11979
   375
text {*
wenzelm@11979
   376
  \medskip Map the type @{text "'a set => anything"} to just @{typ
wenzelm@11979
   377
  'a}; for overloading constants whose first argument has type @{typ
wenzelm@11979
   378
  "'a set"}.
wenzelm@11979
   379
*}
wenzelm@11979
   380
wenzelm@12897
   381
lemma subsetD [elim]: "A \<subseteq> B ==> c \<in> A ==> c \<in> B"
wenzelm@11979
   382
  -- {* Rule in Modus Ponens style. *}
wenzelm@11979
   383
  by (unfold subset_def) blast
wenzelm@11979
   384
wenzelm@11979
   385
declare subsetD [intro?] -- FIXME
wenzelm@11979
   386
wenzelm@12897
   387
lemma rev_subsetD: "c \<in> A ==> A \<subseteq> B ==> c \<in> B"
wenzelm@11979
   388
  -- {* The same, with reversed premises for use with @{text erule} --
wenzelm@11979
   389
      cf @{text rev_mp}. *}
wenzelm@11979
   390
  by (rule subsetD)
wenzelm@11979
   391
wenzelm@11979
   392
declare rev_subsetD [intro?] -- FIXME
wenzelm@11979
   393
wenzelm@11979
   394
text {*
wenzelm@12897
   395
  \medskip Converts @{prop "A \<subseteq> B"} to @{prop "x \<in> A ==> x \<in> B"}.
wenzelm@11979
   396
*}
wenzelm@11979
   397
wenzelm@11979
   398
ML {*
wenzelm@11979
   399
  local val rev_subsetD = thm "rev_subsetD"
wenzelm@11979
   400
  in fun impOfSubs th = th RSN (2, rev_subsetD) end;
wenzelm@11979
   401
*}
wenzelm@11979
   402
wenzelm@12897
   403
lemma subsetCE [elim]: "A \<subseteq>  B ==> (c \<notin> A ==> P) ==> (c \<in> B ==> P) ==> P"
wenzelm@11979
   404
  -- {* Classical elimination rule. *}
wenzelm@11979
   405
  by (unfold subset_def) blast
wenzelm@11979
   406
wenzelm@11979
   407
text {*
wenzelm@12897
   408
  \medskip Takes assumptions @{prop "A \<subseteq> B"}; @{prop "c \<in> A"} and
wenzelm@12897
   409
  creates the assumption @{prop "c \<in> B"}.
wenzelm@11979
   410
*}
wenzelm@11979
   411
wenzelm@11979
   412
ML {*
wenzelm@11979
   413
  local val subsetCE = thm "subsetCE"
wenzelm@11979
   414
  in fun set_mp_tac i = etac subsetCE i THEN mp_tac i end;
wenzelm@11979
   415
*}
wenzelm@11979
   416
wenzelm@12897
   417
lemma contra_subsetD: "A \<subseteq> B ==> c \<notin> B ==> c \<notin> A"
wenzelm@11979
   418
  by blast
wenzelm@11979
   419
wenzelm@12897
   420
lemma subset_refl: "A \<subseteq> A"
wenzelm@11979
   421
  by fast
wenzelm@11979
   422
wenzelm@12897
   423
lemma subset_trans: "A \<subseteq> B ==> B \<subseteq> C ==> A \<subseteq> C"
wenzelm@11979
   424
  by blast
clasohm@923
   425
wenzelm@2261
   426
wenzelm@11979
   427
subsubsection {* Equality *}
wenzelm@11979
   428
paulson@13865
   429
lemma set_ext: assumes prem: "(!!x. (x:A) = (x:B))" shows "A = B"
paulson@13865
   430
  apply (rule prem [THEN ext, THEN arg_cong, THEN box_equals])
paulson@13865
   431
   apply (rule Collect_mem_eq)
paulson@13865
   432
  apply (rule Collect_mem_eq)
paulson@13865
   433
  done
paulson@13865
   434
wenzelm@12897
   435
lemma subset_antisym [intro!]: "A \<subseteq> B ==> B \<subseteq> A ==> A = B"
wenzelm@11979
   436
  -- {* Anti-symmetry of the subset relation. *}
wenzelm@12897
   437
  by (rules intro: set_ext subsetD)
wenzelm@12897
   438
wenzelm@12897
   439
lemmas equalityI [intro!] = subset_antisym
wenzelm@11979
   440
wenzelm@11979
   441
text {*
wenzelm@11979
   442
  \medskip Equality rules from ZF set theory -- are they appropriate
wenzelm@11979
   443
  here?
wenzelm@11979
   444
*}
wenzelm@11979
   445
wenzelm@12897
   446
lemma equalityD1: "A = B ==> A \<subseteq> B"
wenzelm@11979
   447
  by (simp add: subset_refl)
wenzelm@11979
   448
wenzelm@12897
   449
lemma equalityD2: "A = B ==> B \<subseteq> A"
wenzelm@11979
   450
  by (simp add: subset_refl)
wenzelm@11979
   451
wenzelm@11979
   452
text {*
wenzelm@11979
   453
  \medskip Be careful when adding this to the claset as @{text
wenzelm@11979
   454
  subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{}
wenzelm@12897
   455
  \<subseteq> A"} and @{prop "A \<subseteq> {}"} and then back to @{prop "A = {}"}!
wenzelm@11979
   456
*}
wenzelm@11979
   457
wenzelm@12897
   458
lemma equalityE: "A = B ==> (A \<subseteq> B ==> B \<subseteq> A ==> P) ==> P"
wenzelm@11979
   459
  by (simp add: subset_refl)
clasohm@923
   460
wenzelm@11979
   461
lemma equalityCE [elim]:
wenzelm@12897
   462
    "A = B ==> (c \<in> A ==> c \<in> B ==> P) ==> (c \<notin> A ==> c \<notin> B ==> P) ==> P"
wenzelm@11979
   463
  by blast
wenzelm@11979
   464
wenzelm@11979
   465
text {*
wenzelm@11979
   466
  \medskip Lemma for creating induction formulae -- for "pattern
wenzelm@11979
   467
  matching" on @{text p}.  To make the induction hypotheses usable,
wenzelm@11979
   468
  apply @{text spec} or @{text bspec} to put universal quantifiers over the free
wenzelm@11979
   469
  variables in @{text p}.
wenzelm@11979
   470
*}
wenzelm@11979
   471
wenzelm@11979
   472
lemma setup_induction: "p:A ==> (!!z. z:A ==> p = z --> R) ==> R"
wenzelm@11979
   473
  by simp
clasohm@923
   474
wenzelm@11979
   475
lemma eqset_imp_iff: "A = B ==> (x : A) = (x : B)"
wenzelm@11979
   476
  by simp
wenzelm@11979
   477
paulson@13865
   478
lemma eqelem_imp_iff: "x = y ==> (x : A) = (y : A)"
paulson@13865
   479
  by simp
paulson@13865
   480
wenzelm@11979
   481
wenzelm@11979
   482
subsubsection {* The universal set -- UNIV *}
wenzelm@11979
   483
wenzelm@11979
   484
lemma UNIV_I [simp]: "x : UNIV"
wenzelm@11979
   485
  by (simp add: UNIV_def)
wenzelm@11979
   486
wenzelm@11979
   487
declare UNIV_I [intro]  -- {* unsafe makes it less likely to cause problems *}
wenzelm@11979
   488
wenzelm@11979
   489
lemma UNIV_witness [intro?]: "EX x. x : UNIV"
wenzelm@11979
   490
  by simp
wenzelm@11979
   491
wenzelm@12897
   492
lemma subset_UNIV: "A \<subseteq> UNIV"
wenzelm@11979
   493
  by (rule subsetI) (rule UNIV_I)
wenzelm@2388
   494
wenzelm@11979
   495
text {*
wenzelm@11979
   496
  \medskip Eta-contracting these two rules (to remove @{text P})
wenzelm@11979
   497
  causes them to be ignored because of their interaction with
wenzelm@11979
   498
  congruence rules.
wenzelm@11979
   499
*}
wenzelm@11979
   500
wenzelm@11979
   501
lemma ball_UNIV [simp]: "Ball UNIV P = All P"
wenzelm@11979
   502
  by (simp add: Ball_def)
wenzelm@11979
   503
wenzelm@11979
   504
lemma bex_UNIV [simp]: "Bex UNIV P = Ex P"
wenzelm@11979
   505
  by (simp add: Bex_def)
wenzelm@11979
   506
wenzelm@11979
   507
wenzelm@11979
   508
subsubsection {* The empty set *}
wenzelm@11979
   509
wenzelm@11979
   510
lemma empty_iff [simp]: "(c : {}) = False"
wenzelm@11979
   511
  by (simp add: empty_def)
wenzelm@11979
   512
wenzelm@11979
   513
lemma emptyE [elim!]: "a : {} ==> P"
wenzelm@11979
   514
  by simp
wenzelm@11979
   515
wenzelm@12897
   516
lemma empty_subsetI [iff]: "{} \<subseteq> A"
wenzelm@11979
   517
    -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *}
wenzelm@11979
   518
  by blast
wenzelm@11979
   519
wenzelm@12897
   520
lemma equals0I: "(!!y. y \<in> A ==> False) ==> A = {}"
wenzelm@11979
   521
  by blast
wenzelm@2388
   522
wenzelm@12897
   523
lemma equals0D: "A = {} ==> a \<notin> A"
wenzelm@11979
   524
    -- {* Use for reasoning about disjointness: @{prop "A Int B = {}"} *}
wenzelm@11979
   525
  by blast
wenzelm@11979
   526
wenzelm@11979
   527
lemma ball_empty [simp]: "Ball {} P = True"
wenzelm@11979
   528
  by (simp add: Ball_def)
wenzelm@11979
   529
wenzelm@11979
   530
lemma bex_empty [simp]: "Bex {} P = False"
wenzelm@11979
   531
  by (simp add: Bex_def)
wenzelm@11979
   532
wenzelm@11979
   533
lemma UNIV_not_empty [iff]: "UNIV ~= {}"
wenzelm@11979
   534
  by (blast elim: equalityE)
wenzelm@11979
   535
wenzelm@11979
   536
wenzelm@12023
   537
subsubsection {* The Powerset operator -- Pow *}
wenzelm@11979
   538
wenzelm@12897
   539
lemma Pow_iff [iff]: "(A \<in> Pow B) = (A \<subseteq> B)"
wenzelm@11979
   540
  by (simp add: Pow_def)
wenzelm@11979
   541
wenzelm@12897
   542
lemma PowI: "A \<subseteq> B ==> A \<in> Pow B"
wenzelm@11979
   543
  by (simp add: Pow_def)
wenzelm@11979
   544
wenzelm@12897
   545
lemma PowD: "A \<in> Pow B ==> A \<subseteq> B"
wenzelm@11979
   546
  by (simp add: Pow_def)
wenzelm@11979
   547
wenzelm@12897
   548
lemma Pow_bottom: "{} \<in> Pow B"
wenzelm@11979
   549
  by simp
wenzelm@11979
   550
wenzelm@12897
   551
lemma Pow_top: "A \<in> Pow A"
wenzelm@11979
   552
  by (simp add: subset_refl)
wenzelm@2684
   553
wenzelm@2388
   554
wenzelm@11979
   555
subsubsection {* Set complement *}
wenzelm@11979
   556
wenzelm@12897
   557
lemma Compl_iff [simp]: "(c \<in> -A) = (c \<notin> A)"
wenzelm@11979
   558
  by (unfold Compl_def) blast
wenzelm@11979
   559
wenzelm@12897
   560
lemma ComplI [intro!]: "(c \<in> A ==> False) ==> c \<in> -A"
wenzelm@11979
   561
  by (unfold Compl_def) blast
wenzelm@11979
   562
wenzelm@11979
   563
text {*
wenzelm@11979
   564
  \medskip This form, with negated conclusion, works well with the
wenzelm@11979
   565
  Classical prover.  Negated assumptions behave like formulae on the
wenzelm@11979
   566
  right side of the notional turnstile ... *}
wenzelm@11979
   567
wenzelm@11979
   568
lemma ComplD: "c : -A ==> c~:A"
wenzelm@11979
   569
  by (unfold Compl_def) blast
wenzelm@11979
   570
wenzelm@11979
   571
lemmas ComplE [elim!] = ComplD [elim_format]
wenzelm@11979
   572
wenzelm@11979
   573
wenzelm@11979
   574
subsubsection {* Binary union -- Un *}
clasohm@923
   575
wenzelm@11979
   576
lemma Un_iff [simp]: "(c : A Un B) = (c:A | c:B)"
wenzelm@11979
   577
  by (unfold Un_def) blast
wenzelm@11979
   578
wenzelm@11979
   579
lemma UnI1 [elim?]: "c:A ==> c : A Un B"
wenzelm@11979
   580
  by simp
wenzelm@11979
   581
wenzelm@11979
   582
lemma UnI2 [elim?]: "c:B ==> c : A Un B"
wenzelm@11979
   583
  by simp
clasohm@923
   584
wenzelm@11979
   585
text {*
wenzelm@11979
   586
  \medskip Classical introduction rule: no commitment to @{prop A} vs
wenzelm@11979
   587
  @{prop B}.
wenzelm@11979
   588
*}
wenzelm@11979
   589
wenzelm@11979
   590
lemma UnCI [intro!]: "(c~:B ==> c:A) ==> c : A Un B"
wenzelm@11979
   591
  by auto
wenzelm@11979
   592
wenzelm@11979
   593
lemma UnE [elim!]: "c : A Un B ==> (c:A ==> P) ==> (c:B ==> P) ==> P"
wenzelm@11979
   594
  by (unfold Un_def) blast
wenzelm@11979
   595
wenzelm@11979
   596
wenzelm@12023
   597
subsubsection {* Binary intersection -- Int *}
clasohm@923
   598
wenzelm@11979
   599
lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)"
wenzelm@11979
   600
  by (unfold Int_def) blast
wenzelm@11979
   601
wenzelm@11979
   602
lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B"
wenzelm@11979
   603
  by simp
wenzelm@11979
   604
wenzelm@11979
   605
lemma IntD1: "c : A Int B ==> c:A"
wenzelm@11979
   606
  by simp
wenzelm@11979
   607
wenzelm@11979
   608
lemma IntD2: "c : A Int B ==> c:B"
wenzelm@11979
   609
  by simp
wenzelm@11979
   610
wenzelm@11979
   611
lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P"
wenzelm@11979
   612
  by simp
wenzelm@11979
   613
wenzelm@11979
   614
wenzelm@12023
   615
subsubsection {* Set difference *}
wenzelm@11979
   616
wenzelm@11979
   617
lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)"
wenzelm@11979
   618
  by (unfold set_diff_def) blast
clasohm@923
   619
wenzelm@11979
   620
lemma DiffI [intro!]: "c : A ==> c ~: B ==> c : A - B"
wenzelm@11979
   621
  by simp
wenzelm@11979
   622
wenzelm@11979
   623
lemma DiffD1: "c : A - B ==> c : A"
wenzelm@11979
   624
  by simp
wenzelm@11979
   625
wenzelm@11979
   626
lemma DiffD2: "c : A - B ==> c : B ==> P"
wenzelm@11979
   627
  by simp
wenzelm@11979
   628
wenzelm@11979
   629
lemma DiffE [elim!]: "c : A - B ==> (c:A ==> c~:B ==> P) ==> P"
wenzelm@11979
   630
  by simp
wenzelm@11979
   631
wenzelm@11979
   632
wenzelm@11979
   633
subsubsection {* Augmenting a set -- insert *}
wenzelm@11979
   634
wenzelm@11979
   635
lemma insert_iff [simp]: "(a : insert b A) = (a = b | a:A)"
wenzelm@11979
   636
  by (unfold insert_def) blast
wenzelm@11979
   637
wenzelm@11979
   638
lemma insertI1: "a : insert a B"
wenzelm@11979
   639
  by simp
wenzelm@11979
   640
wenzelm@11979
   641
lemma insertI2: "a : B ==> a : insert b B"
wenzelm@11979
   642
  by simp
clasohm@923
   643
wenzelm@11979
   644
lemma insertE [elim!]: "a : insert b A ==> (a = b ==> P) ==> (a:A ==> P) ==> P"
wenzelm@11979
   645
  by (unfold insert_def) blast
wenzelm@11979
   646
wenzelm@11979
   647
lemma insertCI [intro!]: "(a~:B ==> a = b) ==> a: insert b B"
wenzelm@11979
   648
  -- {* Classical introduction rule. *}
wenzelm@11979
   649
  by auto
wenzelm@11979
   650
wenzelm@12897
   651
lemma subset_insert_iff: "(A \<subseteq> insert x B) = (if x:A then A - {x} \<subseteq> B else A \<subseteq> B)"
wenzelm@11979
   652
  by auto
wenzelm@11979
   653
wenzelm@11979
   654
wenzelm@11979
   655
subsubsection {* Singletons, using insert *}
wenzelm@11979
   656
wenzelm@11979
   657
lemma singletonI [intro!]: "a : {a}"
wenzelm@11979
   658
    -- {* Redundant? But unlike @{text insertCI}, it proves the subgoal immediately! *}
wenzelm@11979
   659
  by (rule insertI1)
wenzelm@11979
   660
wenzelm@11979
   661
lemma singletonD: "b : {a} ==> b = a"
wenzelm@11979
   662
  by blast
wenzelm@11979
   663
wenzelm@11979
   664
lemmas singletonE [elim!] = singletonD [elim_format]
wenzelm@11979
   665
wenzelm@11979
   666
lemma singleton_iff: "(b : {a}) = (b = a)"
wenzelm@11979
   667
  by blast
wenzelm@11979
   668
wenzelm@11979
   669
lemma singleton_inject [dest!]: "{a} = {b} ==> a = b"
wenzelm@11979
   670
  by blast
wenzelm@11979
   671
wenzelm@12897
   672
lemma singleton_insert_inj_eq [iff]: "({b} = insert a A) = (a = b & A \<subseteq> {b})"
wenzelm@11979
   673
  by blast
wenzelm@11979
   674
wenzelm@12897
   675
lemma singleton_insert_inj_eq' [iff]: "(insert a A = {b}) = (a = b & A \<subseteq> {b})"
wenzelm@11979
   676
  by blast
wenzelm@11979
   677
wenzelm@12897
   678
lemma subset_singletonD: "A \<subseteq> {x} ==> A = {} | A = {x}"
wenzelm@11979
   679
  by fast
wenzelm@11979
   680
wenzelm@11979
   681
lemma singleton_conv [simp]: "{x. x = a} = {a}"
wenzelm@11979
   682
  by blast
wenzelm@11979
   683
wenzelm@11979
   684
lemma singleton_conv2 [simp]: "{x. a = x} = {a}"
wenzelm@11979
   685
  by blast
clasohm@923
   686
wenzelm@12897
   687
lemma diff_single_insert: "A - {x} \<subseteq> B ==> x \<in> A ==> A \<subseteq> insert x B"
wenzelm@11979
   688
  by blast
wenzelm@11979
   689
wenzelm@11979
   690
wenzelm@11979
   691
subsubsection {* Unions of families *}
wenzelm@11979
   692
wenzelm@11979
   693
text {*
wenzelm@11979
   694
  @{term [source] "UN x:A. B x"} is @{term "Union (B`A)"}.
wenzelm@11979
   695
*}
wenzelm@11979
   696
wenzelm@11979
   697
lemma UN_iff [simp]: "(b: (UN x:A. B x)) = (EX x:A. b: B x)"
wenzelm@11979
   698
  by (unfold UNION_def) blast
wenzelm@11979
   699
wenzelm@11979
   700
lemma UN_I [intro]: "a:A ==> b: B a ==> b: (UN x:A. B x)"
wenzelm@11979
   701
  -- {* The order of the premises presupposes that @{term A} is rigid;
wenzelm@11979
   702
    @{term b} may be flexible. *}
wenzelm@11979
   703
  by auto
wenzelm@11979
   704
wenzelm@11979
   705
lemma UN_E [elim!]: "b : (UN x:A. B x) ==> (!!x. x:A ==> b: B x ==> R) ==> R"
wenzelm@11979
   706
  by (unfold UNION_def) blast
clasohm@923
   707
wenzelm@11979
   708
lemma UN_cong [cong]:
wenzelm@11979
   709
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
wenzelm@11979
   710
  by (simp add: UNION_def)
wenzelm@11979
   711
wenzelm@11979
   712
wenzelm@11979
   713
subsubsection {* Intersections of families *}
wenzelm@11979
   714
wenzelm@11979
   715
text {* @{term [source] "INT x:A. B x"} is @{term "Inter (B`A)"}. *}
wenzelm@11979
   716
wenzelm@11979
   717
lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)"
wenzelm@11979
   718
  by (unfold INTER_def) blast
clasohm@923
   719
wenzelm@11979
   720
lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)"
wenzelm@11979
   721
  by (unfold INTER_def) blast
wenzelm@11979
   722
wenzelm@11979
   723
lemma INT_D [elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a"
wenzelm@11979
   724
  by auto
wenzelm@11979
   725
wenzelm@11979
   726
lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R"
wenzelm@11979
   727
  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *}
wenzelm@11979
   728
  by (unfold INTER_def) blast
wenzelm@11979
   729
wenzelm@11979
   730
lemma INT_cong [cong]:
wenzelm@11979
   731
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)"
wenzelm@11979
   732
  by (simp add: INTER_def)
wenzelm@7238
   733
clasohm@923
   734
wenzelm@11979
   735
subsubsection {* Union *}
wenzelm@11979
   736
wenzelm@11979
   737
lemma Union_iff [simp]: "(A : Union C) = (EX X:C. A:X)"
wenzelm@11979
   738
  by (unfold Union_def) blast
wenzelm@11979
   739
wenzelm@11979
   740
lemma UnionI [intro]: "X:C ==> A:X ==> A : Union C"
wenzelm@11979
   741
  -- {* The order of the premises presupposes that @{term C} is rigid;
wenzelm@11979
   742
    @{term A} may be flexible. *}
wenzelm@11979
   743
  by auto
wenzelm@11979
   744
wenzelm@11979
   745
lemma UnionE [elim!]: "A : Union C ==> (!!X. A:X ==> X:C ==> R) ==> R"
wenzelm@11979
   746
  by (unfold Union_def) blast
wenzelm@11979
   747
wenzelm@11979
   748
wenzelm@11979
   749
subsubsection {* Inter *}
wenzelm@11979
   750
wenzelm@11979
   751
lemma Inter_iff [simp]: "(A : Inter C) = (ALL X:C. A:X)"
wenzelm@11979
   752
  by (unfold Inter_def) blast
wenzelm@11979
   753
wenzelm@11979
   754
lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C"
wenzelm@11979
   755
  by (simp add: Inter_def)
wenzelm@11979
   756
wenzelm@11979
   757
text {*
wenzelm@11979
   758
  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
wenzelm@11979
   759
  contains @{term A} as an element, but @{prop "A:X"} can hold when
wenzelm@11979
   760
  @{prop "X:C"} does not!  This rule is analogous to @{text spec}.
wenzelm@11979
   761
*}
wenzelm@11979
   762
wenzelm@11979
   763
lemma InterD [elim]: "A : Inter C ==> X:C ==> A:X"
wenzelm@11979
   764
  by auto
wenzelm@11979
   765
wenzelm@11979
   766
lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R"
wenzelm@11979
   767
  -- {* ``Classical'' elimination rule -- does not require proving
wenzelm@11979
   768
    @{prop "X:C"}. *}
wenzelm@11979
   769
  by (unfold Inter_def) blast
wenzelm@11979
   770
wenzelm@11979
   771
text {*
wenzelm@11979
   772
  \medskip Image of a set under a function.  Frequently @{term b} does
wenzelm@11979
   773
  not have the syntactic form of @{term "f x"}.
wenzelm@11979
   774
*}
wenzelm@11979
   775
wenzelm@11979
   776
lemma image_eqI [simp, intro]: "b = f x ==> x:A ==> b : f`A"
wenzelm@11979
   777
  by (unfold image_def) blast
wenzelm@11979
   778
wenzelm@11979
   779
lemma imageI: "x : A ==> f x : f ` A"
wenzelm@11979
   780
  by (rule image_eqI) (rule refl)
wenzelm@11979
   781
wenzelm@11979
   782
lemma rev_image_eqI: "x:A ==> b = f x ==> b : f`A"
wenzelm@11979
   783
  -- {* This version's more effective when we already have the
wenzelm@11979
   784
    required @{term x}. *}
wenzelm@11979
   785
  by (unfold image_def) blast
wenzelm@11979
   786
wenzelm@11979
   787
lemma imageE [elim!]:
wenzelm@11979
   788
  "b : (%x. f x)`A ==> (!!x. b = f x ==> x:A ==> P) ==> P"
wenzelm@11979
   789
  -- {* The eta-expansion gives variable-name preservation. *}
wenzelm@11979
   790
  by (unfold image_def) blast
wenzelm@11979
   791
wenzelm@11979
   792
lemma image_Un: "f`(A Un B) = f`A Un f`B"
wenzelm@11979
   793
  by blast
wenzelm@11979
   794
wenzelm@11979
   795
lemma image_iff: "(z : f`A) = (EX x:A. z = f x)"
wenzelm@11979
   796
  by blast
wenzelm@11979
   797
wenzelm@12897
   798
lemma image_subset_iff: "(f`A \<subseteq> B) = (\<forall>x\<in>A. f x \<in> B)"
wenzelm@11979
   799
  -- {* This rewrite rule would confuse users if made default. *}
wenzelm@11979
   800
  by blast
wenzelm@11979
   801
wenzelm@12897
   802
lemma subset_image_iff: "(B \<subseteq> f`A) = (EX AA. AA \<subseteq> A & B = f`AA)"
wenzelm@11979
   803
  apply safe
wenzelm@11979
   804
   prefer 2 apply fast
paulson@14208
   805
  apply (rule_tac x = "{a. a : A & f a : B}" in exI, fast)
wenzelm@11979
   806
  done
wenzelm@11979
   807
wenzelm@12897
   808
lemma image_subsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f`A \<subseteq> B"
wenzelm@11979
   809
  -- {* Replaces the three steps @{text subsetI}, @{text imageE},
wenzelm@11979
   810
    @{text hypsubst}, but breaks too many existing proofs. *}
wenzelm@11979
   811
  by blast
wenzelm@11979
   812
wenzelm@11979
   813
text {*
wenzelm@11979
   814
  \medskip Range of a function -- just a translation for image!
wenzelm@11979
   815
*}
wenzelm@11979
   816
wenzelm@12897
   817
lemma range_eqI: "b = f x ==> b \<in> range f"
wenzelm@11979
   818
  by simp
wenzelm@11979
   819
wenzelm@12897
   820
lemma rangeI: "f x \<in> range f"
wenzelm@11979
   821
  by simp
wenzelm@11979
   822
wenzelm@12897
   823
lemma rangeE [elim?]: "b \<in> range (\<lambda>x. f x) ==> (!!x. b = f x ==> P) ==> P"
wenzelm@11979
   824
  by blast
wenzelm@11979
   825
wenzelm@11979
   826
wenzelm@11979
   827
subsubsection {* Set reasoning tools *}
wenzelm@11979
   828
wenzelm@11979
   829
text {*
wenzelm@11979
   830
  Rewrite rules for boolean case-splitting: faster than @{text
wenzelm@11979
   831
  "split_if [split]"}.
wenzelm@11979
   832
*}
wenzelm@11979
   833
wenzelm@11979
   834
lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))"
wenzelm@11979
   835
  by (rule split_if)
wenzelm@11979
   836
wenzelm@11979
   837
lemma split_if_eq2: "(a = (if Q then x else y)) = ((Q --> a = x) & (~ Q --> a = y))"
wenzelm@11979
   838
  by (rule split_if)
wenzelm@11979
   839
wenzelm@11979
   840
text {*
wenzelm@11979
   841
  Split ifs on either side of the membership relation.  Not for @{text
wenzelm@11979
   842
  "[simp]"} -- can cause goals to blow up!
wenzelm@11979
   843
*}
wenzelm@11979
   844
wenzelm@11979
   845
lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))"
wenzelm@11979
   846
  by (rule split_if)
wenzelm@11979
   847
wenzelm@11979
   848
lemma split_if_mem2: "(a : (if Q then x else y)) = ((Q --> a : x) & (~ Q --> a : y))"
wenzelm@11979
   849
  by (rule split_if)
wenzelm@11979
   850
wenzelm@11979
   851
lemmas split_ifs = if_bool_eq_conj split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
wenzelm@11979
   852
wenzelm@11979
   853
lemmas mem_simps =
wenzelm@11979
   854
  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
wenzelm@11979
   855
  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
wenzelm@11979
   856
  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
wenzelm@11979
   857
wenzelm@11979
   858
(*Would like to add these, but the existing code only searches for the
wenzelm@11979
   859
  outer-level constant, which in this case is just "op :"; we instead need
wenzelm@11979
   860
  to use term-nets to associate patterns with rules.  Also, if a rule fails to
wenzelm@11979
   861
  apply, then the formula should be kept.
wenzelm@11979
   862
  [("uminus", Compl_iff RS iffD1), ("op -", [Diff_iff RS iffD1]),
wenzelm@11979
   863
   ("op Int", [IntD1,IntD2]),
wenzelm@11979
   864
   ("Collect", [CollectD]), ("Inter", [InterD]), ("INTER", [INT_D])]
wenzelm@11979
   865
 *)
wenzelm@11979
   866
wenzelm@11979
   867
ML_setup {*
wenzelm@11979
   868
  val mksimps_pairs = [("Ball", [thm "bspec"])] @ mksimps_pairs;
wenzelm@11979
   869
  simpset_ref() := simpset() setmksimps (mksimps mksimps_pairs);
wenzelm@11979
   870
*}
wenzelm@11979
   871
wenzelm@11979
   872
declare subset_UNIV [simp] subset_refl [simp]
wenzelm@11979
   873
wenzelm@11979
   874
wenzelm@11979
   875
subsubsection {* The ``proper subset'' relation *}
wenzelm@11979
   876
wenzelm@12897
   877
lemma psubsetI [intro!]: "A \<subseteq> B ==> A \<noteq> B ==> A \<subset> B"
wenzelm@11979
   878
  by (unfold psubset_def) blast
wenzelm@11979
   879
paulson@13624
   880
lemma psubsetE [elim!]: 
paulson@13624
   881
    "[|A \<subset> B;  [|A \<subseteq> B; ~ (B\<subseteq>A)|] ==> R|] ==> R"
paulson@13624
   882
  by (unfold psubset_def) blast
paulson@13624
   883
wenzelm@11979
   884
lemma psubset_insert_iff:
wenzelm@12897
   885
  "(A \<subset> insert x B) = (if x \<in> B then A \<subset> B else if x \<in> A then A - {x} \<subset> B else A \<subseteq> B)"
wenzelm@12897
   886
  by (auto simp add: psubset_def subset_insert_iff)
wenzelm@12897
   887
wenzelm@12897
   888
lemma psubset_eq: "(A \<subset> B) = (A \<subseteq> B & A \<noteq> B)"
wenzelm@11979
   889
  by (simp only: psubset_def)
wenzelm@11979
   890
wenzelm@12897
   891
lemma psubset_imp_subset: "A \<subset> B ==> A \<subseteq> B"
wenzelm@11979
   892
  by (simp add: psubset_eq)
wenzelm@11979
   893
paulson@14335
   894
lemma psubset_trans: "[| A \<subset> B; B \<subset> C |] ==> A \<subset> C"
paulson@14335
   895
apply (unfold psubset_def)
paulson@14335
   896
apply (auto dest: subset_antisym)
paulson@14335
   897
done
paulson@14335
   898
paulson@14335
   899
lemma psubsetD: "[| A \<subset> B; c \<in> A |] ==> c \<in> B"
paulson@14335
   900
apply (unfold psubset_def)
paulson@14335
   901
apply (auto dest: subsetD)
paulson@14335
   902
done
paulson@14335
   903
wenzelm@12897
   904
lemma psubset_subset_trans: "A \<subset> B ==> B \<subseteq> C ==> A \<subset> C"
wenzelm@11979
   905
  by (auto simp add: psubset_eq)
wenzelm@11979
   906
wenzelm@12897
   907
lemma subset_psubset_trans: "A \<subseteq> B ==> B \<subset> C ==> A \<subset> C"
wenzelm@11979
   908
  by (auto simp add: psubset_eq)
wenzelm@11979
   909
wenzelm@12897
   910
lemma psubset_imp_ex_mem: "A \<subset> B ==> \<exists>b. b \<in> (B - A)"
wenzelm@11979
   911
  by (unfold psubset_def) blast
wenzelm@11979
   912
wenzelm@11979
   913
lemma atomize_ball:
wenzelm@12897
   914
    "(!!x. x \<in> A ==> P x) == Trueprop (\<forall>x\<in>A. P x)"
wenzelm@11979
   915
  by (simp only: Ball_def atomize_all atomize_imp)
wenzelm@11979
   916
wenzelm@11979
   917
declare atomize_ball [symmetric, rulify]
wenzelm@11979
   918
wenzelm@11979
   919
wenzelm@11979
   920
subsection {* Further set-theory lemmas *}
wenzelm@11979
   921
wenzelm@12897
   922
subsubsection {* Derived rules involving subsets. *}
wenzelm@12897
   923
wenzelm@12897
   924
text {* @{text insert}. *}
wenzelm@12897
   925
wenzelm@12897
   926
lemma subset_insertI: "B \<subseteq> insert a B"
wenzelm@12897
   927
  apply (rule subsetI)
wenzelm@12897
   928
  apply (erule insertI2)
wenzelm@12897
   929
  done
wenzelm@12897
   930
nipkow@14302
   931
lemma subset_insertI2: "A \<subseteq> B \<Longrightarrow> A \<subseteq> insert b B"
nipkow@14302
   932
by blast
nipkow@14302
   933
wenzelm@12897
   934
lemma subset_insert: "x \<notin> A ==> (A \<subseteq> insert x B) = (A \<subseteq> B)"
wenzelm@12897
   935
  by blast
wenzelm@12897
   936
wenzelm@12897
   937
wenzelm@12897
   938
text {* \medskip Big Union -- least upper bound of a set. *}
wenzelm@12897
   939
wenzelm@12897
   940
lemma Union_upper: "B \<in> A ==> B \<subseteq> Union A"
wenzelm@12897
   941
  by (rules intro: subsetI UnionI)
wenzelm@12897
   942
wenzelm@12897
   943
lemma Union_least: "(!!X. X \<in> A ==> X \<subseteq> C) ==> Union A \<subseteq> C"
wenzelm@12897
   944
  by (rules intro: subsetI elim: UnionE dest: subsetD)
wenzelm@12897
   945
wenzelm@12897
   946
wenzelm@12897
   947
text {* \medskip General union. *}
wenzelm@12897
   948
wenzelm@12897
   949
lemma UN_upper: "a \<in> A ==> B a \<subseteq> (\<Union>x\<in>A. B x)"
wenzelm@12897
   950
  by blast
wenzelm@12897
   951
wenzelm@12897
   952
lemma UN_least: "(!!x. x \<in> A ==> B x \<subseteq> C) ==> (\<Union>x\<in>A. B x) \<subseteq> C"
wenzelm@12897
   953
  by (rules intro: subsetI elim: UN_E dest: subsetD)
wenzelm@12897
   954
wenzelm@12897
   955
wenzelm@12897
   956
text {* \medskip Big Intersection -- greatest lower bound of a set. *}
wenzelm@12897
   957
wenzelm@12897
   958
lemma Inter_lower: "B \<in> A ==> Inter A \<subseteq> B"
wenzelm@12897
   959
  by blast
wenzelm@12897
   960
ballarin@14551
   961
lemma Inter_subset:
ballarin@14551
   962
  "[| !!X. X \<in> A ==> X \<subseteq> B; A ~= {} |] ==> \<Inter>A \<subseteq> B"
ballarin@14551
   963
  by blast
ballarin@14551
   964
wenzelm@12897
   965
lemma Inter_greatest: "(!!X. X \<in> A ==> C \<subseteq> X) ==> C \<subseteq> Inter A"
wenzelm@12897
   966
  by (rules intro: InterI subsetI dest: subsetD)
wenzelm@12897
   967
wenzelm@12897
   968
lemma INT_lower: "a \<in> A ==> (\<Inter>x\<in>A. B x) \<subseteq> B a"
wenzelm@12897
   969
  by blast
wenzelm@12897
   970
wenzelm@12897
   971
lemma INT_greatest: "(!!x. x \<in> A ==> C \<subseteq> B x) ==> C \<subseteq> (\<Inter>x\<in>A. B x)"
wenzelm@12897
   972
  by (rules intro: INT_I subsetI dest: subsetD)
wenzelm@12897
   973
wenzelm@12897
   974
wenzelm@12897
   975
text {* \medskip Finite Union -- the least upper bound of two sets. *}
wenzelm@12897
   976
wenzelm@12897
   977
lemma Un_upper1: "A \<subseteq> A \<union> B"
wenzelm@12897
   978
  by blast
wenzelm@12897
   979
wenzelm@12897
   980
lemma Un_upper2: "B \<subseteq> A \<union> B"
wenzelm@12897
   981
  by blast
wenzelm@12897
   982
wenzelm@12897
   983
lemma Un_least: "A \<subseteq> C ==> B \<subseteq> C ==> A \<union> B \<subseteq> C"
wenzelm@12897
   984
  by blast
wenzelm@12897
   985
wenzelm@12897
   986
wenzelm@12897
   987
text {* \medskip Finite Intersection -- the greatest lower bound of two sets. *}
wenzelm@12897
   988
wenzelm@12897
   989
lemma Int_lower1: "A \<inter> B \<subseteq> A"
wenzelm@12897
   990
  by blast
wenzelm@12897
   991
wenzelm@12897
   992
lemma Int_lower2: "A \<inter> B \<subseteq> B"
wenzelm@12897
   993
  by blast
wenzelm@12897
   994
wenzelm@12897
   995
lemma Int_greatest: "C \<subseteq> A ==> C \<subseteq> B ==> C \<subseteq> A \<inter> B"
wenzelm@12897
   996
  by blast
wenzelm@12897
   997
wenzelm@12897
   998
wenzelm@12897
   999
text {* \medskip Set difference. *}
wenzelm@12897
  1000
wenzelm@12897
  1001
lemma Diff_subset: "A - B \<subseteq> A"
wenzelm@12897
  1002
  by blast
wenzelm@12897
  1003
nipkow@14302
  1004
lemma Diff_subset_conv: "(A - B \<subseteq> C) = (A \<subseteq> B \<union> C)"
nipkow@14302
  1005
by blast
nipkow@14302
  1006
wenzelm@12897
  1007
wenzelm@12897
  1008
text {* \medskip Monotonicity. *}
wenzelm@12897
  1009
wenzelm@13421
  1010
lemma mono_Un: includes mono shows "f A \<union> f B \<subseteq> f (A \<union> B)"
wenzelm@12897
  1011
  apply (rule Un_least)
wenzelm@13421
  1012
   apply (rule Un_upper1 [THEN mono])
wenzelm@13421
  1013
  apply (rule Un_upper2 [THEN mono])
wenzelm@12897
  1014
  done
wenzelm@12897
  1015
wenzelm@13421
  1016
lemma mono_Int: includes mono shows "f (A \<inter> B) \<subseteq> f A \<inter> f B"
wenzelm@12897
  1017
  apply (rule Int_greatest)
wenzelm@13421
  1018
   apply (rule Int_lower1 [THEN mono])
wenzelm@13421
  1019
  apply (rule Int_lower2 [THEN mono])
wenzelm@12897
  1020
  done
wenzelm@12897
  1021
wenzelm@12897
  1022
wenzelm@12897
  1023
subsubsection {* Equalities involving union, intersection, inclusion, etc. *}
wenzelm@12897
  1024
wenzelm@12897
  1025
text {* @{text "{}"}. *}
wenzelm@12897
  1026
wenzelm@12897
  1027
lemma Collect_const [simp]: "{s. P} = (if P then UNIV else {})"
wenzelm@12897
  1028
  -- {* supersedes @{text "Collect_False_empty"} *}
wenzelm@12897
  1029
  by auto
wenzelm@12897
  1030
wenzelm@12897
  1031
lemma subset_empty [simp]: "(A \<subseteq> {}) = (A = {})"
wenzelm@12897
  1032
  by blast
wenzelm@12897
  1033
wenzelm@12897
  1034
lemma not_psubset_empty [iff]: "\<not> (A < {})"
wenzelm@12897
  1035
  by (unfold psubset_def) blast
wenzelm@12897
  1036
wenzelm@12897
  1037
lemma Collect_empty_eq [simp]: "(Collect P = {}) = (\<forall>x. \<not> P x)"
wenzelm@12897
  1038
  by auto
wenzelm@12897
  1039
wenzelm@12897
  1040
lemma Collect_neg_eq: "{x. \<not> P x} = - {x. P x}"
wenzelm@12897
  1041
  by blast
wenzelm@12897
  1042
wenzelm@12897
  1043
lemma Collect_disj_eq: "{x. P x | Q x} = {x. P x} \<union> {x. Q x}"
wenzelm@12897
  1044
  by blast
wenzelm@12897
  1045
wenzelm@12897
  1046
lemma Collect_conj_eq: "{x. P x & Q x} = {x. P x} \<inter> {x. Q x}"
wenzelm@12897
  1047
  by blast
wenzelm@12897
  1048
wenzelm@12897
  1049
lemma Collect_all_eq: "{x. \<forall>y. P x y} = (\<Inter>y. {x. P x y})"
wenzelm@12897
  1050
  by blast
wenzelm@12897
  1051
wenzelm@12897
  1052
lemma Collect_ball_eq: "{x. \<forall>y\<in>A. P x y} = (\<Inter>y\<in>A. {x. P x y})"
wenzelm@12897
  1053
  by blast
wenzelm@12897
  1054
wenzelm@12897
  1055
lemma Collect_ex_eq: "{x. \<exists>y. P x y} = (\<Union>y. {x. P x y})"
wenzelm@12897
  1056
  by blast
wenzelm@12897
  1057
wenzelm@12897
  1058
lemma Collect_bex_eq: "{x. \<exists>y\<in>A. P x y} = (\<Union>y\<in>A. {x. P x y})"
wenzelm@12897
  1059
  by blast
wenzelm@12897
  1060
wenzelm@12897
  1061
wenzelm@12897
  1062
text {* \medskip @{text insert}. *}
wenzelm@12897
  1063
wenzelm@12897
  1064
lemma insert_is_Un: "insert a A = {a} Un A"
wenzelm@12897
  1065
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"} *}
wenzelm@12897
  1066
  by blast
wenzelm@12897
  1067
wenzelm@12897
  1068
lemma insert_not_empty [simp]: "insert a A \<noteq> {}"
wenzelm@12897
  1069
  by blast
wenzelm@12897
  1070
wenzelm@12897
  1071
lemmas empty_not_insert [simp] = insert_not_empty [symmetric, standard]
wenzelm@12897
  1072
wenzelm@12897
  1073
lemma insert_absorb: "a \<in> A ==> insert a A = A"
wenzelm@12897
  1074
  -- {* @{text "[simp]"} causes recursive calls when there are nested inserts *}
wenzelm@12897
  1075
  -- {* with \emph{quadratic} running time *}
wenzelm@12897
  1076
  by blast
wenzelm@12897
  1077
wenzelm@12897
  1078
lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A"
wenzelm@12897
  1079
  by blast
wenzelm@12897
  1080
wenzelm@12897
  1081
lemma insert_commute: "insert x (insert y A) = insert y (insert x A)"
wenzelm@12897
  1082
  by blast
wenzelm@12897
  1083
wenzelm@12897
  1084
lemma insert_subset [simp]: "(insert x A \<subseteq> B) = (x \<in> B & A \<subseteq> B)"
wenzelm@12897
  1085
  by blast
wenzelm@12897
  1086
wenzelm@12897
  1087
lemma mk_disjoint_insert: "a \<in> A ==> \<exists>B. A = insert a B & a \<notin> B"
wenzelm@12897
  1088
  -- {* use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding *}
paulson@14208
  1089
  apply (rule_tac x = "A - {a}" in exI, blast)
wenzelm@12897
  1090
  done
wenzelm@12897
  1091
wenzelm@12897
  1092
lemma insert_Collect: "insert a (Collect P) = {u. u \<noteq> a --> P u}"
wenzelm@12897
  1093
  by auto
wenzelm@12897
  1094
wenzelm@12897
  1095
lemma UN_insert_distrib: "u \<in> A ==> (\<Union>x\<in>A. insert a (B x)) = insert a (\<Union>x\<in>A. B x)"
wenzelm@12897
  1096
  by blast
wenzelm@12897
  1097
nipkow@14302
  1098
lemma insert_inter_insert[simp]: "insert a A \<inter> insert a B = insert a (A \<inter> B)"
nipkow@14302
  1099
by blast
nipkow@14302
  1100
nipkow@13103
  1101
lemma insert_disjoint[simp]:
nipkow@13103
  1102
 "(insert a A \<inter> B = {}) = (a \<notin> B \<and> A \<inter> B = {})"
nipkow@13103
  1103
by blast
nipkow@13103
  1104
nipkow@13103
  1105
lemma disjoint_insert[simp]:
nipkow@13103
  1106
 "(B \<inter> insert a A = {}) = (a \<notin> B \<and> B \<inter> A = {})"
nipkow@13103
  1107
by blast
wenzelm@12897
  1108
wenzelm@12897
  1109
text {* \medskip @{text image}. *}
wenzelm@12897
  1110
wenzelm@12897
  1111
lemma image_empty [simp]: "f`{} = {}"
wenzelm@12897
  1112
  by blast
wenzelm@12897
  1113
wenzelm@12897
  1114
lemma image_insert [simp]: "f ` insert a B = insert (f a) (f`B)"
wenzelm@12897
  1115
  by blast
wenzelm@12897
  1116
wenzelm@12897
  1117
lemma image_constant: "x \<in> A ==> (\<lambda>x. c) ` A = {c}"
wenzelm@12897
  1118
  by blast
wenzelm@12897
  1119
wenzelm@12897
  1120
lemma image_image: "f ` (g ` A) = (\<lambda>x. f (g x)) ` A"
wenzelm@12897
  1121
  by blast
wenzelm@12897
  1122
wenzelm@12897
  1123
lemma insert_image [simp]: "x \<in> A ==> insert (f x) (f`A) = f`A"
wenzelm@12897
  1124
  by blast
wenzelm@12897
  1125
wenzelm@12897
  1126
lemma image_is_empty [iff]: "(f`A = {}) = (A = {})"
wenzelm@12897
  1127
  by blast
wenzelm@12897
  1128
wenzelm@12897
  1129
lemma image_Collect: "f ` {x. P x} = {f x | x. P x}"
wenzelm@12897
  1130
  -- {* NOT suitable as a default simprule: the RHS isn't simpler than the LHS, *}
wenzelm@12897
  1131
  -- {* with its implicit quantifier and conjunction.  Also image enjoys better *}
wenzelm@12897
  1132
  -- {* equational properties than does the RHS. *}
wenzelm@12897
  1133
  by blast
wenzelm@12897
  1134
wenzelm@12897
  1135
lemma if_image_distrib [simp]:
wenzelm@12897
  1136
  "(\<lambda>x. if P x then f x else g x) ` S
wenzelm@12897
  1137
    = (f ` (S \<inter> {x. P x})) \<union> (g ` (S \<inter> {x. \<not> P x}))"
wenzelm@12897
  1138
  by (auto simp add: image_def)
wenzelm@12897
  1139
wenzelm@12897
  1140
lemma image_cong: "M = N ==> (!!x. x \<in> N ==> f x = g x) ==> f`M = g`N"
wenzelm@12897
  1141
  by (simp add: image_def)
wenzelm@12897
  1142
wenzelm@12897
  1143
wenzelm@12897
  1144
text {* \medskip @{text range}. *}
wenzelm@12897
  1145
wenzelm@12897
  1146
lemma full_SetCompr_eq: "{u. \<exists>x. u = f x} = range f"
wenzelm@12897
  1147
  by auto
wenzelm@12897
  1148
wenzelm@12897
  1149
lemma range_composition [simp]: "range (\<lambda>x. f (g x)) = f`range g"
paulson@14208
  1150
by (subst image_image, simp)
wenzelm@12897
  1151
wenzelm@12897
  1152
wenzelm@12897
  1153
text {* \medskip @{text Int} *}
wenzelm@12897
  1154
wenzelm@12897
  1155
lemma Int_absorb [simp]: "A \<inter> A = A"
wenzelm@12897
  1156
  by blast
wenzelm@12897
  1157
wenzelm@12897
  1158
lemma Int_left_absorb: "A \<inter> (A \<inter> B) = A \<inter> B"
wenzelm@12897
  1159
  by blast
wenzelm@12897
  1160
wenzelm@12897
  1161
lemma Int_commute: "A \<inter> B = B \<inter> A"
wenzelm@12897
  1162
  by blast
wenzelm@12897
  1163
wenzelm@12897
  1164
lemma Int_left_commute: "A \<inter> (B \<inter> C) = B \<inter> (A \<inter> C)"
wenzelm@12897
  1165
  by blast
wenzelm@12897
  1166
wenzelm@12897
  1167
lemma Int_assoc: "(A \<inter> B) \<inter> C = A \<inter> (B \<inter> C)"
wenzelm@12897
  1168
  by blast
wenzelm@12897
  1169
wenzelm@12897
  1170
lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute
wenzelm@12897
  1171
  -- {* Intersection is an AC-operator *}
wenzelm@12897
  1172
wenzelm@12897
  1173
lemma Int_absorb1: "B \<subseteq> A ==> A \<inter> B = B"
wenzelm@12897
  1174
  by blast
wenzelm@12897
  1175
wenzelm@12897
  1176
lemma Int_absorb2: "A \<subseteq> B ==> A \<inter> B = A"
wenzelm@12897
  1177
  by blast
wenzelm@12897
  1178
wenzelm@12897
  1179
lemma Int_empty_left [simp]: "{} \<inter> B = {}"
wenzelm@12897
  1180
  by blast
wenzelm@12897
  1181
wenzelm@12897
  1182
lemma Int_empty_right [simp]: "A \<inter> {} = {}"
wenzelm@12897
  1183
  by blast
wenzelm@12897
  1184
wenzelm@12897
  1185
lemma disjoint_eq_subset_Compl: "(A \<inter> B = {}) = (A \<subseteq> -B)"
wenzelm@12897
  1186
  by blast
wenzelm@12897
  1187
wenzelm@12897
  1188
lemma disjoint_iff_not_equal: "(A \<inter> B = {}) = (\<forall>x\<in>A. \<forall>y\<in>B. x \<noteq> y)"
wenzelm@12897
  1189
  by blast
wenzelm@12897
  1190
wenzelm@12897
  1191
lemma Int_UNIV_left [simp]: "UNIV \<inter> B = B"
wenzelm@12897
  1192
  by blast
wenzelm@12897
  1193
wenzelm@12897
  1194
lemma Int_UNIV_right [simp]: "A \<inter> UNIV = A"
wenzelm@12897
  1195
  by blast
wenzelm@12897
  1196
wenzelm@12897
  1197
lemma Int_eq_Inter: "A \<inter> B = \<Inter>{A, B}"
wenzelm@12897
  1198
  by blast
wenzelm@12897
  1199
wenzelm@12897
  1200
lemma Int_Un_distrib: "A \<inter> (B \<union> C) = (A \<inter> B) \<union> (A \<inter> C)"
wenzelm@12897
  1201
  by blast
wenzelm@12897
  1202
wenzelm@12897
  1203
lemma Int_Un_distrib2: "(B \<union> C) \<inter> A = (B \<inter> A) \<union> (C \<inter> A)"
wenzelm@12897
  1204
  by blast
wenzelm@12897
  1205
wenzelm@12897
  1206
lemma Int_UNIV [simp]: "(A \<inter> B = UNIV) = (A = UNIV & B = UNIV)"
wenzelm@12897
  1207
  by blast
wenzelm@12897
  1208
wenzelm@12897
  1209
lemma Int_subset_iff: "(C \<subseteq> A \<inter> B) = (C \<subseteq> A & C \<subseteq> B)"
wenzelm@12897
  1210
  by blast
wenzelm@12897
  1211
wenzelm@12897
  1212
lemma Int_Collect: "(x \<in> A \<inter> {x. P x}) = (x \<in> A & P x)"
wenzelm@12897
  1213
  by blast
wenzelm@12897
  1214
wenzelm@12897
  1215
wenzelm@12897
  1216
text {* \medskip @{text Un}. *}
wenzelm@12897
  1217
wenzelm@12897
  1218
lemma Un_absorb [simp]: "A \<union> A = A"
wenzelm@12897
  1219
  by blast
wenzelm@12897
  1220
wenzelm@12897
  1221
lemma Un_left_absorb: "A \<union> (A \<union> B) = A \<union> B"
wenzelm@12897
  1222
  by blast
wenzelm@12897
  1223
wenzelm@12897
  1224
lemma Un_commute: "A \<union> B = B \<union> A"
wenzelm@12897
  1225
  by blast
wenzelm@12897
  1226
wenzelm@12897
  1227
lemma Un_left_commute: "A \<union> (B \<union> C) = B \<union> (A \<union> C)"
wenzelm@12897
  1228
  by blast
wenzelm@12897
  1229
wenzelm@12897
  1230
lemma Un_assoc: "(A \<union> B) \<union> C = A \<union> (B \<union> C)"
wenzelm@12897
  1231
  by blast
wenzelm@12897
  1232
wenzelm@12897
  1233
lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute
wenzelm@12897
  1234
  -- {* Union is an AC-operator *}
wenzelm@12897
  1235
wenzelm@12897
  1236
lemma Un_absorb1: "A \<subseteq> B ==> A \<union> B = B"
wenzelm@12897
  1237
  by blast
wenzelm@12897
  1238
wenzelm@12897
  1239
lemma Un_absorb2: "B \<subseteq> A ==> A \<union> B = A"
wenzelm@12897
  1240
  by blast
wenzelm@12897
  1241
wenzelm@12897
  1242
lemma Un_empty_left [simp]: "{} \<union> B = B"
wenzelm@12897
  1243
  by blast
wenzelm@12897
  1244
wenzelm@12897
  1245
lemma Un_empty_right [simp]: "A \<union> {} = A"
wenzelm@12897
  1246
  by blast
wenzelm@12897
  1247
wenzelm@12897
  1248
lemma Un_UNIV_left [simp]: "UNIV \<union> B = UNIV"
wenzelm@12897
  1249
  by blast
wenzelm@12897
  1250
wenzelm@12897
  1251
lemma Un_UNIV_right [simp]: "A \<union> UNIV = UNIV"
wenzelm@12897
  1252
  by blast
wenzelm@12897
  1253
wenzelm@12897
  1254
lemma Un_eq_Union: "A \<union> B = \<Union>{A, B}"
wenzelm@12897
  1255
  by blast
wenzelm@12897
  1256
wenzelm@12897
  1257
lemma Un_insert_left [simp]: "(insert a B) \<union> C = insert a (B \<union> C)"
wenzelm@12897
  1258
  by blast
wenzelm@12897
  1259
wenzelm@12897
  1260
lemma Un_insert_right [simp]: "A \<union> (insert a B) = insert a (A \<union> B)"
wenzelm@12897
  1261
  by blast
wenzelm@12897
  1262
wenzelm@12897
  1263
lemma Int_insert_left:
wenzelm@12897
  1264
    "(insert a B) Int C = (if a \<in> C then insert a (B \<inter> C) else B \<inter> C)"
wenzelm@12897
  1265
  by auto
wenzelm@12897
  1266
wenzelm@12897
  1267
lemma Int_insert_right:
wenzelm@12897
  1268
    "A \<inter> (insert a B) = (if a \<in> A then insert a (A \<inter> B) else A \<inter> B)"
wenzelm@12897
  1269
  by auto
wenzelm@12897
  1270
wenzelm@12897
  1271
lemma Un_Int_distrib: "A \<union> (B \<inter> C) = (A \<union> B) \<inter> (A \<union> C)"
wenzelm@12897
  1272
  by blast
wenzelm@12897
  1273
wenzelm@12897
  1274
lemma Un_Int_distrib2: "(B \<inter> C) \<union> A = (B \<union> A) \<inter> (C \<union> A)"
wenzelm@12897
  1275
  by blast
wenzelm@12897
  1276
wenzelm@12897
  1277
lemma Un_Int_crazy:
wenzelm@12897
  1278
    "(A \<inter> B) \<union> (B \<inter> C) \<union> (C \<inter> A) = (A \<union> B) \<inter> (B \<union> C) \<inter> (C \<union> A)"
wenzelm@12897
  1279
  by blast
wenzelm@12897
  1280
wenzelm@12897
  1281
lemma subset_Un_eq: "(A \<subseteq> B) = (A \<union> B = B)"
wenzelm@12897
  1282
  by blast
wenzelm@12897
  1283
wenzelm@12897
  1284
lemma Un_empty [iff]: "(A \<union> B = {}) = (A = {} & B = {})"
wenzelm@12897
  1285
  by blast
wenzelm@12897
  1286
wenzelm@12897
  1287
lemma Un_subset_iff: "(A \<union> B \<subseteq> C) = (A \<subseteq> C & B \<subseteq> C)"
wenzelm@12897
  1288
  by blast
wenzelm@12897
  1289
wenzelm@12897
  1290
lemma Un_Diff_Int: "(A - B) \<union> (A \<inter> B) = A"
wenzelm@12897
  1291
  by blast
wenzelm@12897
  1292
wenzelm@12897
  1293
wenzelm@12897
  1294
text {* \medskip Set complement *}
wenzelm@12897
  1295
wenzelm@12897
  1296
lemma Compl_disjoint [simp]: "A \<inter> -A = {}"
wenzelm@12897
  1297
  by blast
wenzelm@12897
  1298
wenzelm@12897
  1299
lemma Compl_disjoint2 [simp]: "-A \<inter> A = {}"
wenzelm@12897
  1300
  by blast
wenzelm@12897
  1301
paulson@13818
  1302
lemma Compl_partition: "A \<union> -A = UNIV"
paulson@13818
  1303
  by blast
paulson@13818
  1304
paulson@13818
  1305
lemma Compl_partition2: "-A \<union> A = UNIV"
wenzelm@12897
  1306
  by blast
wenzelm@12897
  1307
wenzelm@12897
  1308
lemma double_complement [simp]: "- (-A) = (A::'a set)"
wenzelm@12897
  1309
  by blast
wenzelm@12897
  1310
wenzelm@12897
  1311
lemma Compl_Un [simp]: "-(A \<union> B) = (-A) \<inter> (-B)"
wenzelm@12897
  1312
  by blast
wenzelm@12897
  1313
wenzelm@12897
  1314
lemma Compl_Int [simp]: "-(A \<inter> B) = (-A) \<union> (-B)"
wenzelm@12897
  1315
  by blast
wenzelm@12897
  1316
wenzelm@12897
  1317
lemma Compl_UN [simp]: "-(\<Union>x\<in>A. B x) = (\<Inter>x\<in>A. -B x)"
wenzelm@12897
  1318
  by blast
wenzelm@12897
  1319
wenzelm@12897
  1320
lemma Compl_INT [simp]: "-(\<Inter>x\<in>A. B x) = (\<Union>x\<in>A. -B x)"
wenzelm@12897
  1321
  by blast
wenzelm@12897
  1322
wenzelm@12897
  1323
lemma subset_Compl_self_eq: "(A \<subseteq> -A) = (A = {})"
wenzelm@12897
  1324
  by blast
wenzelm@12897
  1325
wenzelm@12897
  1326
lemma Un_Int_assoc_eq: "((A \<inter> B) \<union> C = A \<inter> (B \<union> C)) = (C \<subseteq> A)"
wenzelm@12897
  1327
  -- {* Halmos, Naive Set Theory, page 16. *}
wenzelm@12897
  1328
  by blast
wenzelm@12897
  1329
wenzelm@12897
  1330
lemma Compl_UNIV_eq [simp]: "-UNIV = {}"
wenzelm@12897
  1331
  by blast
wenzelm@12897
  1332
wenzelm@12897
  1333
lemma Compl_empty_eq [simp]: "-{} = UNIV"
wenzelm@12897
  1334
  by blast
wenzelm@12897
  1335
wenzelm@12897
  1336
lemma Compl_subset_Compl_iff [iff]: "(-A \<subseteq> -B) = (B \<subseteq> A)"
wenzelm@12897
  1337
  by blast
wenzelm@12897
  1338
wenzelm@12897
  1339
lemma Compl_eq_Compl_iff [iff]: "(-A = -B) = (A = (B::'a set))"
wenzelm@12897
  1340
  by blast
wenzelm@12897
  1341
wenzelm@12897
  1342
wenzelm@12897
  1343
text {* \medskip @{text Union}. *}
wenzelm@12897
  1344
wenzelm@12897
  1345
lemma Union_empty [simp]: "Union({}) = {}"
wenzelm@12897
  1346
  by blast
wenzelm@12897
  1347
wenzelm@12897
  1348
lemma Union_UNIV [simp]: "Union UNIV = UNIV"
wenzelm@12897
  1349
  by blast
wenzelm@12897
  1350
wenzelm@12897
  1351
lemma Union_insert [simp]: "Union (insert a B) = a \<union> \<Union>B"
wenzelm@12897
  1352
  by blast
wenzelm@12897
  1353
wenzelm@12897
  1354
lemma Union_Un_distrib [simp]: "\<Union>(A Un B) = \<Union>A \<union> \<Union>B"
wenzelm@12897
  1355
  by blast
wenzelm@12897
  1356
wenzelm@12897
  1357
lemma Union_Int_subset: "\<Union>(A \<inter> B) \<subseteq> \<Union>A \<inter> \<Union>B"
wenzelm@12897
  1358
  by blast
wenzelm@12897
  1359
wenzelm@12897
  1360
lemma Union_empty_conv [iff]: "(\<Union>A = {}) = (\<forall>x\<in>A. x = {})"
nipkow@13653
  1361
  by blast
nipkow@13653
  1362
nipkow@13653
  1363
lemma empty_Union_conv [iff]: "({} = \<Union>A) = (\<forall>x\<in>A. x = {})"
nipkow@13653
  1364
  by blast
wenzelm@12897
  1365
wenzelm@12897
  1366
lemma Union_disjoint: "(\<Union>C \<inter> A = {}) = (\<forall>B\<in>C. B \<inter> A = {})"
wenzelm@12897
  1367
  by blast
wenzelm@12897
  1368
wenzelm@12897
  1369
wenzelm@12897
  1370
text {* \medskip @{text Inter}. *}
wenzelm@12897
  1371
wenzelm@12897
  1372
lemma Inter_empty [simp]: "\<Inter>{} = UNIV"
wenzelm@12897
  1373
  by blast
wenzelm@12897
  1374
wenzelm@12897
  1375
lemma Inter_UNIV [simp]: "\<Inter>UNIV = {}"
wenzelm@12897
  1376
  by blast
wenzelm@12897
  1377
wenzelm@12897
  1378
lemma Inter_insert [simp]: "\<Inter>(insert a B) = a \<inter> \<Inter>B"
wenzelm@12897
  1379
  by blast
wenzelm@12897
  1380
wenzelm@12897
  1381
lemma Inter_Un_subset: "\<Inter>A \<union> \<Inter>B \<subseteq> \<Inter>(A \<inter> B)"
wenzelm@12897
  1382
  by blast
wenzelm@12897
  1383
wenzelm@12897
  1384
lemma Inter_Un_distrib: "\<Inter>(A \<union> B) = \<Inter>A \<inter> \<Inter>B"
wenzelm@12897
  1385
  by blast
wenzelm@12897
  1386
nipkow@13653
  1387
lemma Inter_UNIV_conv [iff]:
nipkow@13653
  1388
  "(\<Inter>A = UNIV) = (\<forall>x\<in>A. x = UNIV)"
nipkow@13653
  1389
  "(UNIV = \<Inter>A) = (\<forall>x\<in>A. x = UNIV)"
paulson@14208
  1390
  by blast+
nipkow@13653
  1391
wenzelm@12897
  1392
wenzelm@12897
  1393
text {*
wenzelm@12897
  1394
  \medskip @{text UN} and @{text INT}.
wenzelm@12897
  1395
wenzelm@12897
  1396
  Basic identities: *}
wenzelm@12897
  1397
wenzelm@12897
  1398
lemma UN_empty [simp]: "(\<Union>x\<in>{}. B x) = {}"
wenzelm@12897
  1399
  by blast
wenzelm@12897
  1400
wenzelm@12897
  1401
lemma UN_empty2 [simp]: "(\<Union>x\<in>A. {}) = {}"
wenzelm@12897
  1402
  by blast
wenzelm@12897
  1403
wenzelm@12897
  1404
lemma UN_singleton [simp]: "(\<Union>x\<in>A. {x}) = A"
wenzelm@12897
  1405
  by blast
wenzelm@12897
  1406
wenzelm@12897
  1407
lemma UN_absorb: "k \<in> I ==> A k \<union> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. A i)"
wenzelm@12897
  1408
  by blast
wenzelm@12897
  1409
wenzelm@12897
  1410
lemma INT_empty [simp]: "(\<Inter>x\<in>{}. B x) = UNIV"
wenzelm@12897
  1411
  by blast
wenzelm@12897
  1412
wenzelm@12897
  1413
lemma INT_absorb: "k \<in> I ==> A k \<inter> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. A i)"
wenzelm@12897
  1414
  by blast
wenzelm@12897
  1415
wenzelm@12897
  1416
lemma UN_insert [simp]: "(\<Union>x\<in>insert a A. B x) = B a \<union> UNION A B"
wenzelm@12897
  1417
  by blast
wenzelm@12897
  1418
wenzelm@12897
  1419
lemma UN_Un: "(\<Union>i \<in> A \<union> B. M i) = (\<Union>i\<in>A. M i) \<union> (\<Union>i\<in>B. M i)"
wenzelm@12897
  1420
  by blast
wenzelm@12897
  1421
wenzelm@12897
  1422
lemma UN_UN_flatten: "(\<Union>x \<in> (\<Union>y\<in>A. B y). C x) = (\<Union>y\<in>A. \<Union>x\<in>B y. C x)"
wenzelm@12897
  1423
  by blast
wenzelm@12897
  1424
wenzelm@12897
  1425
lemma UN_subset_iff: "((\<Union>i\<in>I. A i) \<subseteq> B) = (\<forall>i\<in>I. A i \<subseteq> B)"
wenzelm@12897
  1426
  by blast
wenzelm@12897
  1427
wenzelm@12897
  1428
lemma INT_subset_iff: "(B \<subseteq> (\<Inter>i\<in>I. A i)) = (\<forall>i\<in>I. B \<subseteq> A i)"
wenzelm@12897
  1429
  by blast
wenzelm@12897
  1430
wenzelm@12897
  1431
lemma INT_insert [simp]: "(\<Inter>x \<in> insert a A. B x) = B a \<inter> INTER A B"
wenzelm@12897
  1432
  by blast
wenzelm@12897
  1433
wenzelm@12897
  1434
lemma INT_Un: "(\<Inter>i \<in> A \<union> B. M i) = (\<Inter>i \<in> A. M i) \<inter> (\<Inter>i\<in>B. M i)"
wenzelm@12897
  1435
  by blast
wenzelm@12897
  1436
wenzelm@12897
  1437
lemma INT_insert_distrib:
wenzelm@12897
  1438
    "u \<in> A ==> (\<Inter>x\<in>A. insert a (B x)) = insert a (\<Inter>x\<in>A. B x)"
wenzelm@12897
  1439
  by blast
wenzelm@12897
  1440
wenzelm@12897
  1441
lemma Union_image_eq [simp]: "\<Union>(B`A) = (\<Union>x\<in>A. B x)"
wenzelm@12897
  1442
  by blast
wenzelm@12897
  1443
wenzelm@12897
  1444
lemma image_Union: "f ` \<Union>S = (\<Union>x\<in>S. f ` x)"
wenzelm@12897
  1445
  by blast
wenzelm@12897
  1446
wenzelm@12897
  1447
lemma Inter_image_eq [simp]: "\<Inter>(B`A) = (\<Inter>x\<in>A. B x)"
wenzelm@12897
  1448
  by blast
wenzelm@12897
  1449
wenzelm@12897
  1450
lemma UN_constant [simp]: "(\<Union>y\<in>A. c) = (if A = {} then {} else c)"
wenzelm@12897
  1451
  by auto
wenzelm@12897
  1452
wenzelm@12897
  1453
lemma INT_constant [simp]: "(\<Inter>y\<in>A. c) = (if A = {} then UNIV else c)"
wenzelm@12897
  1454
  by auto
wenzelm@12897
  1455
wenzelm@12897
  1456
lemma UN_eq: "(\<Union>x\<in>A. B x) = \<Union>({Y. \<exists>x\<in>A. Y = B x})"
wenzelm@12897
  1457
  by blast
wenzelm@12897
  1458
wenzelm@12897
  1459
lemma INT_eq: "(\<Inter>x\<in>A. B x) = \<Inter>({Y. \<exists>x\<in>A. Y = B x})"
wenzelm@12897
  1460
  -- {* Look: it has an \emph{existential} quantifier *}
wenzelm@12897
  1461
  by blast
wenzelm@12897
  1462
nipkow@13653
  1463
lemma UNION_empty_conv[iff]:
nipkow@13653
  1464
  "({} = (UN x:A. B x)) = (\<forall>x\<in>A. B x = {})"
nipkow@13653
  1465
  "((UN x:A. B x) = {}) = (\<forall>x\<in>A. B x = {})"
nipkow@13653
  1466
by blast+
nipkow@13653
  1467
nipkow@13653
  1468
lemma INTER_UNIV_conv[iff]:
nipkow@13653
  1469
 "(UNIV = (INT x:A. B x)) = (\<forall>x\<in>A. B x = UNIV)"
nipkow@13653
  1470
 "((INT x:A. B x) = UNIV) = (\<forall>x\<in>A. B x = UNIV)"
nipkow@13653
  1471
by blast+
wenzelm@12897
  1472
wenzelm@12897
  1473
wenzelm@12897
  1474
text {* \medskip Distributive laws: *}
wenzelm@12897
  1475
wenzelm@12897
  1476
lemma Int_Union: "A \<inter> \<Union>B = (\<Union>C\<in>B. A \<inter> C)"
wenzelm@12897
  1477
  by blast
wenzelm@12897
  1478
wenzelm@12897
  1479
lemma Int_Union2: "\<Union>B \<inter> A = (\<Union>C\<in>B. C \<inter> A)"
wenzelm@12897
  1480
  by blast
wenzelm@12897
  1481
wenzelm@12897
  1482
lemma Un_Union_image: "(\<Union>x\<in>C. A x \<union> B x) = \<Union>(A`C) \<union> \<Union>(B`C)"
wenzelm@12897
  1483
  -- {* Devlin, Fundamentals of Contemporary Set Theory, page 12, exercise 5: *}
wenzelm@12897
  1484
  -- {* Union of a family of unions *}
wenzelm@12897
  1485
  by blast
wenzelm@12897
  1486
wenzelm@12897
  1487
lemma UN_Un_distrib: "(\<Union>i\<in>I. A i \<union> B i) = (\<Union>i\<in>I. A i) \<union> (\<Union>i\<in>I. B i)"
wenzelm@12897
  1488
  -- {* Equivalent version *}
wenzelm@12897
  1489
  by blast
wenzelm@12897
  1490
wenzelm@12897
  1491
lemma Un_Inter: "A \<union> \<Inter>B = (\<Inter>C\<in>B. A \<union> C)"
wenzelm@12897
  1492
  by blast
wenzelm@12897
  1493
wenzelm@12897
  1494
lemma Int_Inter_image: "(\<Inter>x\<in>C. A x \<inter> B x) = \<Inter>(A`C) \<inter> \<Inter>(B`C)"
wenzelm@12897
  1495
  by blast
wenzelm@12897
  1496
wenzelm@12897
  1497
lemma INT_Int_distrib: "(\<Inter>i\<in>I. A i \<inter> B i) = (\<Inter>i\<in>I. A i) \<inter> (\<Inter>i\<in>I. B i)"
wenzelm@12897
  1498
  -- {* Equivalent version *}
wenzelm@12897
  1499
  by blast
wenzelm@12897
  1500
wenzelm@12897
  1501
lemma Int_UN_distrib: "B \<inter> (\<Union>i\<in>I. A i) = (\<Union>i\<in>I. B \<inter> A i)"
wenzelm@12897
  1502
  -- {* Halmos, Naive Set Theory, page 35. *}
wenzelm@12897
  1503
  by blast
wenzelm@12897
  1504
wenzelm@12897
  1505
lemma Un_INT_distrib: "B \<union> (\<Inter>i\<in>I. A i) = (\<Inter>i\<in>I. B \<union> A i)"
wenzelm@12897
  1506
  by blast
wenzelm@12897
  1507
wenzelm@12897
  1508
lemma Int_UN_distrib2: "(\<Union>i\<in>I. A i) \<inter> (\<Union>j\<in>J. B j) = (\<Union>i\<in>I. \<Union>j\<in>J. A i \<inter> B j)"
wenzelm@12897
  1509
  by blast
wenzelm@12897
  1510
wenzelm@12897
  1511
lemma Un_INT_distrib2: "(\<Inter>i\<in>I. A i) \<union> (\<Inter>j\<in>J. B j) = (\<Inter>i\<in>I. \<Inter>j\<in>J. A i \<union> B j)"
wenzelm@12897
  1512
  by blast
wenzelm@12897
  1513
wenzelm@12897
  1514
wenzelm@12897
  1515
text {* \medskip Bounded quantifiers.
wenzelm@12897
  1516
wenzelm@12897
  1517
  The following are not added to the default simpset because
wenzelm@12897
  1518
  (a) they duplicate the body and (b) there are no similar rules for @{text Int}. *}
wenzelm@12897
  1519
wenzelm@12897
  1520
lemma ball_Un: "(\<forall>x \<in> A \<union> B. P x) = ((\<forall>x\<in>A. P x) & (\<forall>x\<in>B. P x))"
wenzelm@12897
  1521
  by blast
wenzelm@12897
  1522
wenzelm@12897
  1523
lemma bex_Un: "(\<exists>x \<in> A \<union> B. P x) = ((\<exists>x\<in>A. P x) | (\<exists>x\<in>B. P x))"
wenzelm@12897
  1524
  by blast
wenzelm@12897
  1525
wenzelm@12897
  1526
lemma ball_UN: "(\<forall>z \<in> UNION A B. P z) = (\<forall>x\<in>A. \<forall>z \<in> B x. P z)"
wenzelm@12897
  1527
  by blast
wenzelm@12897
  1528
wenzelm@12897
  1529
lemma bex_UN: "(\<exists>z \<in> UNION A B. P z) = (\<exists>x\<in>A. \<exists>z\<in>B x. P z)"
wenzelm@12897
  1530
  by blast
wenzelm@12897
  1531
wenzelm@12897
  1532
wenzelm@12897
  1533
text {* \medskip Set difference. *}
wenzelm@12897
  1534
wenzelm@12897
  1535
lemma Diff_eq: "A - B = A \<inter> (-B)"
wenzelm@12897
  1536
  by blast
wenzelm@12897
  1537
wenzelm@12897
  1538
lemma Diff_eq_empty_iff [simp]: "(A - B = {}) = (A \<subseteq> B)"
wenzelm@12897
  1539
  by blast
wenzelm@12897
  1540
wenzelm@12897
  1541
lemma Diff_cancel [simp]: "A - A = {}"
wenzelm@12897
  1542
  by blast
wenzelm@12897
  1543
nipkow@14302
  1544
lemma Diff_idemp [simp]: "(A - B) - B = A - (B::'a set)"
nipkow@14302
  1545
by blast
nipkow@14302
  1546
wenzelm@12897
  1547
lemma Diff_triv: "A \<inter> B = {} ==> A - B = A"
wenzelm@12897
  1548
  by (blast elim: equalityE)
wenzelm@12897
  1549
wenzelm@12897
  1550
lemma empty_Diff [simp]: "{} - A = {}"
wenzelm@12897
  1551
  by blast
wenzelm@12897
  1552
wenzelm@12897
  1553
lemma Diff_empty [simp]: "A - {} = A"
wenzelm@12897
  1554
  by blast
wenzelm@12897
  1555
wenzelm@12897
  1556
lemma Diff_UNIV [simp]: "A - UNIV = {}"
wenzelm@12897
  1557
  by blast
wenzelm@12897
  1558
wenzelm@12897
  1559
lemma Diff_insert0 [simp]: "x \<notin> A ==> A - insert x B = A - B"
wenzelm@12897
  1560
  by blast
wenzelm@12897
  1561
wenzelm@12897
  1562
lemma Diff_insert: "A - insert a B = A - B - {a}"
wenzelm@12897
  1563
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
wenzelm@12897
  1564
  by blast
wenzelm@12897
  1565
wenzelm@12897
  1566
lemma Diff_insert2: "A - insert a B = A - {a} - B"
wenzelm@12897
  1567
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
wenzelm@12897
  1568
  by blast
wenzelm@12897
  1569
wenzelm@12897
  1570
lemma insert_Diff_if: "insert x A - B = (if x \<in> B then A - B else insert x (A - B))"
wenzelm@12897
  1571
  by auto
wenzelm@12897
  1572
wenzelm@12897
  1573
lemma insert_Diff1 [simp]: "x \<in> B ==> insert x A - B = A - B"
wenzelm@12897
  1574
  by blast
wenzelm@12897
  1575
nipkow@14302
  1576
lemma insert_Diff_single[simp]: "insert a (A - {a}) = insert a A"
nipkow@14302
  1577
by blast
nipkow@14302
  1578
wenzelm@12897
  1579
lemma insert_Diff: "a \<in> A ==> insert a (A - {a}) = A"
wenzelm@12897
  1580
  by blast
wenzelm@12897
  1581
wenzelm@12897
  1582
lemma Diff_insert_absorb: "x \<notin> A ==> (insert x A) - {x} = A"
wenzelm@12897
  1583
  by auto
wenzelm@12897
  1584
wenzelm@12897
  1585
lemma Diff_disjoint [simp]: "A \<inter> (B - A) = {}"
wenzelm@12897
  1586
  by blast
wenzelm@12897
  1587
wenzelm@12897
  1588
lemma Diff_partition: "A \<subseteq> B ==> A \<union> (B - A) = B"
wenzelm@12897
  1589
  by blast
wenzelm@12897
  1590
wenzelm@12897
  1591
lemma double_diff: "A \<subseteq> B ==> B \<subseteq> C ==> B - (C - A) = A"
wenzelm@12897
  1592
  by blast
wenzelm@12897
  1593
wenzelm@12897
  1594
lemma Un_Diff_cancel [simp]: "A \<union> (B - A) = A \<union> B"
wenzelm@12897
  1595
  by blast
wenzelm@12897
  1596
wenzelm@12897
  1597
lemma Un_Diff_cancel2 [simp]: "(B - A) \<union> A = B \<union> A"
wenzelm@12897
  1598
  by blast
wenzelm@12897
  1599
wenzelm@12897
  1600
lemma Diff_Un: "A - (B \<union> C) = (A - B) \<inter> (A - C)"
wenzelm@12897
  1601
  by blast
wenzelm@12897
  1602
wenzelm@12897
  1603
lemma Diff_Int: "A - (B \<inter> C) = (A - B) \<union> (A - C)"
wenzelm@12897
  1604
  by blast
wenzelm@12897
  1605
wenzelm@12897
  1606
lemma Un_Diff: "(A \<union> B) - C = (A - C) \<union> (B - C)"
wenzelm@12897
  1607
  by blast
wenzelm@12897
  1608
wenzelm@12897
  1609
lemma Int_Diff: "(A \<inter> B) - C = A \<inter> (B - C)"
wenzelm@12897
  1610
  by blast
wenzelm@12897
  1611
wenzelm@12897
  1612
lemma Diff_Int_distrib: "C \<inter> (A - B) = (C \<inter> A) - (C \<inter> B)"
wenzelm@12897
  1613
  by blast
wenzelm@12897
  1614
wenzelm@12897
  1615
lemma Diff_Int_distrib2: "(A - B) \<inter> C = (A \<inter> C) - (B \<inter> C)"
wenzelm@12897
  1616
  by blast
wenzelm@12897
  1617
wenzelm@12897
  1618
lemma Diff_Compl [simp]: "A - (- B) = A \<inter> B"
wenzelm@12897
  1619
  by auto
wenzelm@12897
  1620
wenzelm@12897
  1621
lemma Compl_Diff_eq [simp]: "- (A - B) = -A \<union> B"
wenzelm@12897
  1622
  by blast
wenzelm@12897
  1623
wenzelm@12897
  1624
wenzelm@12897
  1625
text {* \medskip Quantification over type @{typ bool}. *}
wenzelm@12897
  1626
wenzelm@12897
  1627
lemma all_bool_eq: "(\<forall>b::bool. P b) = (P True & P False)"
wenzelm@12897
  1628
  apply auto
paulson@14208
  1629
  apply (tactic {* case_tac "b" 1 *}, auto)
wenzelm@12897
  1630
  done
wenzelm@12897
  1631
wenzelm@12897
  1632
lemma bool_induct: "P True \<Longrightarrow> P False \<Longrightarrow> P x"
wenzelm@12897
  1633
  by (rule conjI [THEN all_bool_eq [THEN iffD2], THEN spec])
wenzelm@12897
  1634
wenzelm@12897
  1635
lemma ex_bool_eq: "(\<exists>b::bool. P b) = (P True | P False)"
wenzelm@12897
  1636
  apply auto
paulson@14208
  1637
  apply (tactic {* case_tac "b" 1 *}, auto)
wenzelm@12897
  1638
  done
wenzelm@12897
  1639
wenzelm@12897
  1640
lemma Un_eq_UN: "A \<union> B = (\<Union>b. if b then A else B)"
wenzelm@12897
  1641
  by (auto simp add: split_if_mem2)
wenzelm@12897
  1642
wenzelm@12897
  1643
lemma UN_bool_eq: "(\<Union>b::bool. A b) = (A True \<union> A False)"
wenzelm@12897
  1644
  apply auto
paulson@14208
  1645
  apply (tactic {* case_tac "b" 1 *}, auto)
wenzelm@12897
  1646
  done
wenzelm@12897
  1647
wenzelm@12897
  1648
lemma INT_bool_eq: "(\<Inter>b::bool. A b) = (A True \<inter> A False)"
wenzelm@12897
  1649
  apply auto
paulson@14208
  1650
  apply (tactic {* case_tac "b" 1 *}, auto)
wenzelm@12897
  1651
  done
wenzelm@12897
  1652
wenzelm@12897
  1653
wenzelm@12897
  1654
text {* \medskip @{text Pow} *}
wenzelm@12897
  1655
wenzelm@12897
  1656
lemma Pow_empty [simp]: "Pow {} = {{}}"
wenzelm@12897
  1657
  by (auto simp add: Pow_def)
wenzelm@12897
  1658
wenzelm@12897
  1659
lemma Pow_insert: "Pow (insert a A) = Pow A \<union> (insert a ` Pow A)"
wenzelm@12897
  1660
  by (blast intro: image_eqI [where ?x = "u - {a}", standard])
wenzelm@12897
  1661
wenzelm@12897
  1662
lemma Pow_Compl: "Pow (- A) = {-B | B. A \<in> Pow B}"
wenzelm@12897
  1663
  by (blast intro: exI [where ?x = "- u", standard])
wenzelm@12897
  1664
wenzelm@12897
  1665
lemma Pow_UNIV [simp]: "Pow UNIV = UNIV"
wenzelm@12897
  1666
  by blast
wenzelm@12897
  1667
wenzelm@12897
  1668
lemma Un_Pow_subset: "Pow A \<union> Pow B \<subseteq> Pow (A \<union> B)"
wenzelm@12897
  1669
  by blast
wenzelm@12897
  1670
wenzelm@12897
  1671
lemma UN_Pow_subset: "(\<Union>x\<in>A. Pow (B x)) \<subseteq> Pow (\<Union>x\<in>A. B x)"
wenzelm@12897
  1672
  by blast
wenzelm@12897
  1673
wenzelm@12897
  1674
lemma subset_Pow_Union: "A \<subseteq> Pow (\<Union>A)"
wenzelm@12897
  1675
  by blast
wenzelm@12897
  1676
wenzelm@12897
  1677
lemma Union_Pow_eq [simp]: "\<Union>(Pow A) = A"
wenzelm@12897
  1678
  by blast
wenzelm@12897
  1679
wenzelm@12897
  1680
lemma Pow_Int_eq [simp]: "Pow (A \<inter> B) = Pow A \<inter> Pow B"
wenzelm@12897
  1681
  by blast
wenzelm@12897
  1682
wenzelm@12897
  1683
lemma Pow_INT_eq: "Pow (\<Inter>x\<in>A. B x) = (\<Inter>x\<in>A. Pow (B x))"
wenzelm@12897
  1684
  by blast
wenzelm@12897
  1685
wenzelm@12897
  1686
wenzelm@12897
  1687
text {* \medskip Miscellany. *}
wenzelm@12897
  1688
wenzelm@12897
  1689
lemma set_eq_subset: "(A = B) = (A \<subseteq> B & B \<subseteq> A)"
wenzelm@12897
  1690
  by blast
wenzelm@12897
  1691
wenzelm@12897
  1692
lemma subset_iff: "(A \<subseteq> B) = (\<forall>t. t \<in> A --> t \<in> B)"
wenzelm@12897
  1693
  by blast
wenzelm@12897
  1694
wenzelm@12897
  1695
lemma subset_iff_psubset_eq: "(A \<subseteq> B) = ((A \<subset> B) | (A = B))"
wenzelm@12897
  1696
  by (unfold psubset_def) blast
wenzelm@12897
  1697
wenzelm@12897
  1698
lemma all_not_in_conv [iff]: "(\<forall>x. x \<notin> A) = (A = {})"
wenzelm@12897
  1699
  by blast
wenzelm@12897
  1700
paulson@13831
  1701
lemma ex_in_conv: "(\<exists>x. x \<in> A) = (A \<noteq> {})"
paulson@13831
  1702
  by blast
paulson@13831
  1703
wenzelm@12897
  1704
lemma distinct_lemma: "f x \<noteq> f y ==> x \<noteq> y"
wenzelm@12897
  1705
  by rules
wenzelm@12897
  1706
wenzelm@12897
  1707
paulson@13860
  1708
text {* \medskip Miniscoping: pushing in quantifiers and big Unions
paulson@13860
  1709
           and Intersections. *}
wenzelm@12897
  1710
wenzelm@12897
  1711
lemma UN_simps [simp]:
wenzelm@12897
  1712
  "!!a B C. (UN x:C. insert a (B x)) = (if C={} then {} else insert a (UN x:C. B x))"
wenzelm@12897
  1713
  "!!A B C. (UN x:C. A x Un B)   = ((if C={} then {} else (UN x:C. A x) Un B))"
wenzelm@12897
  1714
  "!!A B C. (UN x:C. A Un B x)   = ((if C={} then {} else A Un (UN x:C. B x)))"
wenzelm@12897
  1715
  "!!A B C. (UN x:C. A x Int B)  = ((UN x:C. A x) Int B)"
wenzelm@12897
  1716
  "!!A B C. (UN x:C. A Int B x)  = (A Int (UN x:C. B x))"
wenzelm@12897
  1717
  "!!A B C. (UN x:C. A x - B)    = ((UN x:C. A x) - B)"
wenzelm@12897
  1718
  "!!A B C. (UN x:C. A - B x)    = (A - (INT x:C. B x))"
wenzelm@12897
  1719
  "!!A B. (UN x: Union A. B x) = (UN y:A. UN x:y. B x)"
wenzelm@12897
  1720
  "!!A B C. (UN z: UNION A B. C z) = (UN  x:A. UN z: B(x). C z)"
wenzelm@12897
  1721
  "!!A B f. (UN x:f`A. B x)     = (UN a:A. B (f a))"
wenzelm@12897
  1722
  by auto
wenzelm@12897
  1723
wenzelm@12897
  1724
lemma INT_simps [simp]:
wenzelm@12897
  1725
  "!!A B C. (INT x:C. A x Int B) = (if C={} then UNIV else (INT x:C. A x) Int B)"
wenzelm@12897
  1726
  "!!A B C. (INT x:C. A Int B x) = (if C={} then UNIV else A Int (INT x:C. B x))"
wenzelm@12897
  1727
  "!!A B C. (INT x:C. A x - B)   = (if C={} then UNIV else (INT x:C. A x) - B)"
wenzelm@12897
  1728
  "!!A B C. (INT x:C. A - B x)   = (if C={} then UNIV else A - (UN x:C. B x))"
wenzelm@12897
  1729
  "!!a B C. (INT x:C. insert a (B x)) = insert a (INT x:C. B x)"
wenzelm@12897
  1730
  "!!A B C. (INT x:C. A x Un B)  = ((INT x:C. A x) Un B)"
wenzelm@12897
  1731
  "!!A B C. (INT x:C. A Un B x)  = (A Un (INT x:C. B x))"
wenzelm@12897
  1732
  "!!A B. (INT x: Union A. B x) = (INT y:A. INT x:y. B x)"
wenzelm@12897
  1733
  "!!A B C. (INT z: UNION A B. C z) = (INT x:A. INT z: B(x). C z)"
wenzelm@12897
  1734
  "!!A B f. (INT x:f`A. B x)    = (INT a:A. B (f a))"
wenzelm@12897
  1735
  by auto
wenzelm@12897
  1736
wenzelm@12897
  1737
lemma ball_simps [simp]:
wenzelm@12897
  1738
  "!!A P Q. (ALL x:A. P x | Q) = ((ALL x:A. P x) | Q)"
wenzelm@12897
  1739
  "!!A P Q. (ALL x:A. P | Q x) = (P | (ALL x:A. Q x))"
wenzelm@12897
  1740
  "!!A P Q. (ALL x:A. P --> Q x) = (P --> (ALL x:A. Q x))"
wenzelm@12897
  1741
  "!!A P Q. (ALL x:A. P x --> Q) = ((EX x:A. P x) --> Q)"
wenzelm@12897
  1742
  "!!P. (ALL x:{}. P x) = True"
wenzelm@12897
  1743
  "!!P. (ALL x:UNIV. P x) = (ALL x. P x)"
wenzelm@12897
  1744
  "!!a B P. (ALL x:insert a B. P x) = (P a & (ALL x:B. P x))"
wenzelm@12897
  1745
  "!!A P. (ALL x:Union A. P x) = (ALL y:A. ALL x:y. P x)"
wenzelm@12897
  1746
  "!!A B P. (ALL x: UNION A B. P x) = (ALL a:A. ALL x: B a. P x)"
wenzelm@12897
  1747
  "!!P Q. (ALL x:Collect Q. P x) = (ALL x. Q x --> P x)"
wenzelm@12897
  1748
  "!!A P f. (ALL x:f`A. P x) = (ALL x:A. P (f x))"
wenzelm@12897
  1749
  "!!A P. (~(ALL x:A. P x)) = (EX x:A. ~P x)"
wenzelm@12897
  1750
  by auto
wenzelm@12897
  1751
wenzelm@12897
  1752
lemma bex_simps [simp]:
wenzelm@12897
  1753
  "!!A P Q. (EX x:A. P x & Q) = ((EX x:A. P x) & Q)"
wenzelm@12897
  1754
  "!!A P Q. (EX x:A. P & Q x) = (P & (EX x:A. Q x))"
wenzelm@12897
  1755
  "!!P. (EX x:{}. P x) = False"
wenzelm@12897
  1756
  "!!P. (EX x:UNIV. P x) = (EX x. P x)"
wenzelm@12897
  1757
  "!!a B P. (EX x:insert a B. P x) = (P(a) | (EX x:B. P x))"
wenzelm@12897
  1758
  "!!A P. (EX x:Union A. P x) = (EX y:A. EX x:y. P x)"
wenzelm@12897
  1759
  "!!A B P. (EX x: UNION A B. P x) = (EX a:A. EX x:B a. P x)"
wenzelm@12897
  1760
  "!!P Q. (EX x:Collect Q. P x) = (EX x. Q x & P x)"
wenzelm@12897
  1761
  "!!A P f. (EX x:f`A. P x) = (EX x:A. P (f x))"
wenzelm@12897
  1762
  "!!A P. (~(EX x:A. P x)) = (ALL x:A. ~P x)"
wenzelm@12897
  1763
  by auto
wenzelm@12897
  1764
wenzelm@12897
  1765
lemma ball_conj_distrib:
wenzelm@12897
  1766
  "(ALL x:A. P x & Q x) = ((ALL x:A. P x) & (ALL x:A. Q x))"
wenzelm@12897
  1767
  by blast
wenzelm@12897
  1768
wenzelm@12897
  1769
lemma bex_disj_distrib:
wenzelm@12897
  1770
  "(EX x:A. P x | Q x) = ((EX x:A. P x) | (EX x:A. Q x))"
wenzelm@12897
  1771
  by blast
wenzelm@12897
  1772
wenzelm@12897
  1773
paulson@13860
  1774
text {* \medskip Maxiscoping: pulling out big Unions and Intersections. *}
paulson@13860
  1775
paulson@13860
  1776
lemma UN_extend_simps:
paulson@13860
  1777
  "!!a B C. insert a (UN x:C. B x) = (if C={} then {a} else (UN x:C. insert a (B x)))"
paulson@13860
  1778
  "!!A B C. (UN x:C. A x) Un B    = (if C={} then B else (UN x:C. A x Un B))"
paulson@13860
  1779
  "!!A B C. A Un (UN x:C. B x)   = (if C={} then A else (UN x:C. A Un B x))"
paulson@13860
  1780
  "!!A B C. ((UN x:C. A x) Int B) = (UN x:C. A x Int B)"
paulson@13860
  1781
  "!!A B C. (A Int (UN x:C. B x)) = (UN x:C. A Int B x)"
paulson@13860
  1782
  "!!A B C. ((UN x:C. A x) - B) = (UN x:C. A x - B)"
paulson@13860
  1783
  "!!A B C. (A - (INT x:C. B x)) = (UN x:C. A - B x)"
paulson@13860
  1784
  "!!A B. (UN y:A. UN x:y. B x) = (UN x: Union A. B x)"
paulson@13860
  1785
  "!!A B C. (UN  x:A. UN z: B(x). C z) = (UN z: UNION A B. C z)"
paulson@13860
  1786
  "!!A B f. (UN a:A. B (f a)) = (UN x:f`A. B x)"
paulson@13860
  1787
  by auto
paulson@13860
  1788
paulson@13860
  1789
lemma INT_extend_simps:
paulson@13860
  1790
  "!!A B C. (INT x:C. A x) Int B = (if C={} then B else (INT x:C. A x Int B))"
paulson@13860
  1791
  "!!A B C. A Int (INT x:C. B x) = (if C={} then A else (INT x:C. A Int B x))"
paulson@13860
  1792
  "!!A B C. (INT x:C. A x) - B   = (if C={} then UNIV-B else (INT x:C. A x - B))"
paulson@13860
  1793
  "!!A B C. A - (UN x:C. B x)   = (if C={} then A else (INT x:C. A - B x))"
paulson@13860
  1794
  "!!a B C. insert a (INT x:C. B x) = (INT x:C. insert a (B x))"
paulson@13860
  1795
  "!!A B C. ((INT x:C. A x) Un B)  = (INT x:C. A x Un B)"
paulson@13860
  1796
  "!!A B C. A Un (INT x:C. B x)  = (INT x:C. A Un B x)"
paulson@13860
  1797
  "!!A B. (INT y:A. INT x:y. B x) = (INT x: Union A. B x)"
paulson@13860
  1798
  "!!A B C. (INT x:A. INT z: B(x). C z) = (INT z: UNION A B. C z)"
paulson@13860
  1799
  "!!A B f. (INT a:A. B (f a))    = (INT x:f`A. B x)"
paulson@13860
  1800
  by auto
paulson@13860
  1801
paulson@13860
  1802
wenzelm@12897
  1803
subsubsection {* Monotonicity of various operations *}
wenzelm@12897
  1804
wenzelm@12897
  1805
lemma image_mono: "A \<subseteq> B ==> f`A \<subseteq> f`B"
wenzelm@12897
  1806
  by blast
wenzelm@12897
  1807
wenzelm@12897
  1808
lemma Pow_mono: "A \<subseteq> B ==> Pow A \<subseteq> Pow B"
wenzelm@12897
  1809
  by blast
wenzelm@12897
  1810
wenzelm@12897
  1811
lemma Union_mono: "A \<subseteq> B ==> \<Union>A \<subseteq> \<Union>B"
wenzelm@12897
  1812
  by blast
wenzelm@12897
  1813
wenzelm@12897
  1814
lemma Inter_anti_mono: "B \<subseteq> A ==> \<Inter>A \<subseteq> \<Inter>B"
wenzelm@12897
  1815
  by blast
wenzelm@12897
  1816
wenzelm@12897
  1817
lemma UN_mono:
wenzelm@12897
  1818
  "A \<subseteq> B ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
wenzelm@12897
  1819
    (\<Union>x\<in>A. f x) \<subseteq> (\<Union>x\<in>B. g x)"
wenzelm@12897
  1820
  by (blast dest: subsetD)
wenzelm@12897
  1821
wenzelm@12897
  1822
lemma INT_anti_mono:
wenzelm@12897
  1823
  "B \<subseteq> A ==> (!!x. x \<in> A ==> f x \<subseteq> g x) ==>
wenzelm@12897
  1824
    (\<Inter>x\<in>A. f x) \<subseteq> (\<Inter>x\<in>A. g x)"
wenzelm@12897
  1825
  -- {* The last inclusion is POSITIVE! *}
wenzelm@12897
  1826
  by (blast dest: subsetD)
wenzelm@12897
  1827
wenzelm@12897
  1828
lemma insert_mono: "C \<subseteq> D ==> insert a C \<subseteq> insert a D"
wenzelm@12897
  1829
  by blast
wenzelm@12897
  1830
wenzelm@12897
  1831
lemma Un_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<union> B \<subseteq> C \<union> D"
wenzelm@12897
  1832
  by blast
wenzelm@12897
  1833
wenzelm@12897
  1834
lemma Int_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<inter> B \<subseteq> C \<inter> D"
wenzelm@12897
  1835
  by blast
wenzelm@12897
  1836
wenzelm@12897
  1837
lemma Diff_mono: "A \<subseteq> C ==> D \<subseteq> B ==> A - B \<subseteq> C - D"
wenzelm@12897
  1838
  by blast
wenzelm@12897
  1839
wenzelm@12897
  1840
lemma Compl_anti_mono: "A \<subseteq> B ==> -B \<subseteq> -A"
wenzelm@12897
  1841
  by blast
wenzelm@12897
  1842
wenzelm@12897
  1843
text {* \medskip Monotonicity of implications. *}
wenzelm@12897
  1844
wenzelm@12897
  1845
lemma in_mono: "A \<subseteq> B ==> x \<in> A --> x \<in> B"
wenzelm@12897
  1846
  apply (rule impI)
paulson@14208
  1847
  apply (erule subsetD, assumption)
wenzelm@12897
  1848
  done
wenzelm@12897
  1849
wenzelm@12897
  1850
lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)"
wenzelm@12897
  1851
  by rules
wenzelm@12897
  1852
wenzelm@12897
  1853
lemma disj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 | P2) --> (Q1 | Q2)"
wenzelm@12897
  1854
  by rules
wenzelm@12897
  1855
wenzelm@12897
  1856
lemma imp_mono: "Q1 --> P1 ==> P2 --> Q2 ==> (P1 --> P2) --> (Q1 --> Q2)"
wenzelm@12897
  1857
  by rules
wenzelm@12897
  1858
wenzelm@12897
  1859
lemma imp_refl: "P --> P" ..
wenzelm@12897
  1860
wenzelm@12897
  1861
lemma ex_mono: "(!!x. P x --> Q x) ==> (EX x. P x) --> (EX x. Q x)"
wenzelm@12897
  1862
  by rules
wenzelm@12897
  1863
wenzelm@12897
  1864
lemma all_mono: "(!!x. P x --> Q x) ==> (ALL x. P x) --> (ALL x. Q x)"
wenzelm@12897
  1865
  by rules
wenzelm@12897
  1866
wenzelm@12897
  1867
lemma Collect_mono: "(!!x. P x --> Q x) ==> Collect P \<subseteq> Collect Q"
wenzelm@12897
  1868
  by blast
wenzelm@12897
  1869
wenzelm@12897
  1870
lemma Int_Collect_mono:
wenzelm@12897
  1871
    "A \<subseteq> B ==> (!!x. x \<in> A ==> P x --> Q x) ==> A \<inter> Collect P \<subseteq> B \<inter> Collect Q"
wenzelm@12897
  1872
  by blast
wenzelm@12897
  1873
wenzelm@12897
  1874
lemmas basic_monos =
wenzelm@12897
  1875
  subset_refl imp_refl disj_mono conj_mono
wenzelm@12897
  1876
  ex_mono Collect_mono in_mono
wenzelm@12897
  1877
wenzelm@12897
  1878
lemma eq_to_mono: "a = b ==> c = d ==> b --> d ==> a --> c"
wenzelm@12897
  1879
  by rules
wenzelm@12897
  1880
wenzelm@12897
  1881
lemma eq_to_mono2: "a = b ==> c = d ==> ~ b --> ~ d ==> ~ a --> ~ c"
wenzelm@12897
  1882
  by rules
wenzelm@11979
  1883
wenzelm@11982
  1884
lemma Least_mono:
wenzelm@11982
  1885
  "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
wenzelm@11982
  1886
    ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
wenzelm@11982
  1887
    -- {* Courtesy of Stephan Merz *}
wenzelm@11982
  1888
  apply clarify
paulson@14208
  1889
  apply (erule_tac P = "%x. x : S" in LeastI2, fast)
wenzelm@11982
  1890
  apply (rule LeastI2)
wenzelm@11982
  1891
  apply (auto elim: monoD intro!: order_antisym)
wenzelm@11982
  1892
  done
wenzelm@11982
  1893
wenzelm@12020
  1894
wenzelm@12257
  1895
subsection {* Inverse image of a function *}
wenzelm@12257
  1896
wenzelm@12257
  1897
constdefs
wenzelm@12257
  1898
  vimage :: "('a => 'b) => 'b set => 'a set"    (infixr "-`" 90)
wenzelm@12257
  1899
  "f -` B == {x. f x : B}"
wenzelm@12257
  1900
wenzelm@12257
  1901
wenzelm@12257
  1902
subsubsection {* Basic rules *}
wenzelm@12257
  1903
wenzelm@12257
  1904
lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)"
wenzelm@12257
  1905
  by (unfold vimage_def) blast
wenzelm@12257
  1906
wenzelm@12257
  1907
lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)"
wenzelm@12257
  1908
  by simp
wenzelm@12257
  1909
wenzelm@12257
  1910
lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B"
wenzelm@12257
  1911
  by (unfold vimage_def) blast
wenzelm@12257
  1912
wenzelm@12257
  1913
lemma vimageI2: "f a : A ==> a : f -` A"
wenzelm@12257
  1914
  by (unfold vimage_def) fast
wenzelm@12257
  1915
wenzelm@12257
  1916
lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P"
wenzelm@12257
  1917
  by (unfold vimage_def) blast
wenzelm@12257
  1918
wenzelm@12257
  1919
lemma vimageD: "a : f -` A ==> f a : A"
wenzelm@12257
  1920
  by (unfold vimage_def) fast
wenzelm@12257
  1921
wenzelm@12257
  1922
wenzelm@12257
  1923
subsubsection {* Equations *}
wenzelm@12257
  1924
wenzelm@12257
  1925
lemma vimage_empty [simp]: "f -` {} = {}"
wenzelm@12257
  1926
  by blast
wenzelm@12257
  1927
wenzelm@12257
  1928
lemma vimage_Compl: "f -` (-A) = -(f -` A)"
wenzelm@12257
  1929
  by blast
wenzelm@12257
  1930
wenzelm@12257
  1931
lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)"
wenzelm@12257
  1932
  by blast
wenzelm@12257
  1933
wenzelm@12257
  1934
lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)"
wenzelm@12257
  1935
  by fast
wenzelm@12257
  1936
wenzelm@12257
  1937
lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)"
wenzelm@12257
  1938
  by blast
wenzelm@12257
  1939
wenzelm@12257
  1940
lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)"
wenzelm@12257
  1941
  by blast
wenzelm@12257
  1942
wenzelm@12257
  1943
lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)"
wenzelm@12257
  1944
  by blast
wenzelm@12257
  1945
wenzelm@12257
  1946
lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}"
wenzelm@12257
  1947
  by blast
wenzelm@12257
  1948
wenzelm@12257
  1949
lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q"
wenzelm@12257
  1950
  by blast
wenzelm@12257
  1951
wenzelm@12257
  1952
lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)"
wenzelm@12257
  1953
  -- {* NOT suitable for rewriting because of the recurrence of @{term "{a}"}. *}
wenzelm@12257
  1954
  by blast
wenzelm@12257
  1955
wenzelm@12257
  1956
lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)"
wenzelm@12257
  1957
  by blast
wenzelm@12257
  1958
wenzelm@12257
  1959
lemma vimage_UNIV [simp]: "f -` UNIV = UNIV"
wenzelm@12257
  1960
  by blast
wenzelm@12257
  1961
wenzelm@12257
  1962
lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})"
wenzelm@12257
  1963
  -- {* NOT suitable for rewriting *}
wenzelm@12257
  1964
  by blast
wenzelm@12257
  1965
wenzelm@12897
  1966
lemma vimage_mono: "A \<subseteq> B ==> f -` A \<subseteq> f -` B"
wenzelm@12257
  1967
  -- {* monotonicity *}
wenzelm@12257
  1968
  by blast
wenzelm@12257
  1969
wenzelm@12257
  1970
paulson@14479
  1971
subsection {* Getting the Contents of a Singleton Set *}
paulson@14479
  1972
paulson@14479
  1973
constdefs
paulson@14479
  1974
  contents :: "'a set => 'a"
paulson@14479
  1975
   "contents X == THE x. X = {x}"
paulson@14479
  1976
paulson@14479
  1977
lemma contents_eq [simp]: "contents {x} = x"
paulson@14479
  1978
by (simp add: contents_def)
paulson@14479
  1979
paulson@14479
  1980
wenzelm@12023
  1981
subsection {* Transitivity rules for calculational reasoning *}
wenzelm@12020
  1982
wenzelm@12020
  1983
lemma forw_subst: "a = b ==> P b ==> P a"
wenzelm@12020
  1984
  by (rule ssubst)
wenzelm@12020
  1985
wenzelm@12020
  1986
lemma back_subst: "P a ==> a = b ==> P b"
wenzelm@12020
  1987
  by (rule subst)
wenzelm@12020
  1988
wenzelm@12897
  1989
lemma set_rev_mp: "x:A ==> A \<subseteq> B ==> x:B"
wenzelm@12020
  1990
  by (rule subsetD)
wenzelm@12020
  1991
wenzelm@12897
  1992
lemma set_mp: "A \<subseteq> B ==> x:A ==> x:B"
wenzelm@12020
  1993
  by (rule subsetD)
wenzelm@12020
  1994
wenzelm@12020
  1995
lemma ord_le_eq_trans: "a <= b ==> b = c ==> a <= c"
wenzelm@12020
  1996
  by (rule subst)
wenzelm@12020
  1997
wenzelm@12020
  1998
lemma ord_eq_le_trans: "a = b ==> b <= c ==> a <= c"
wenzelm@12020
  1999
  by (rule ssubst)
wenzelm@12020
  2000
wenzelm@12020
  2001
lemma ord_less_eq_trans: "a < b ==> b = c ==> a < c"
wenzelm@12020
  2002
  by (rule subst)
wenzelm@12020
  2003
wenzelm@12020
  2004
lemma ord_eq_less_trans: "a = b ==> b < c ==> a < c"
wenzelm@12020
  2005
  by (rule ssubst)
wenzelm@12020
  2006
wenzelm@12020
  2007
lemma order_less_subst2: "(a::'a::order) < b ==> f b < (c::'c::order) ==>
wenzelm@12020
  2008
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  2009
proof -
wenzelm@12020
  2010
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2011
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  2012
  also assume "f b < c"
wenzelm@12020
  2013
  finally (order_less_trans) show ?thesis .
wenzelm@12020
  2014
qed
wenzelm@12020
  2015
wenzelm@12020
  2016
lemma order_less_subst1: "(a::'a::order) < f b ==> (b::'b::order) < c ==>
wenzelm@12020
  2017
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  2018
proof -
wenzelm@12020
  2019
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2020
  assume "a < f b"
wenzelm@12020
  2021
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  2022
  finally (order_less_trans) show ?thesis .
wenzelm@12020
  2023
qed
wenzelm@12020
  2024
wenzelm@12020
  2025
lemma order_le_less_subst2: "(a::'a::order) <= b ==> f b < (c::'c::order) ==>
wenzelm@12020
  2026
  (!!x y. x <= y ==> f x <= f y) ==> f a < c"
wenzelm@12020
  2027
proof -
wenzelm@12020
  2028
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2029
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  2030
  also assume "f b < c"
wenzelm@12020
  2031
  finally (order_le_less_trans) show ?thesis .
wenzelm@12020
  2032
qed
wenzelm@12020
  2033
wenzelm@12020
  2034
lemma order_le_less_subst1: "(a::'a::order) <= f b ==> (b::'b::order) < c ==>
wenzelm@12020
  2035
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  2036
proof -
wenzelm@12020
  2037
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2038
  assume "a <= f b"
wenzelm@12020
  2039
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  2040
  finally (order_le_less_trans) show ?thesis .
wenzelm@12020
  2041
qed
wenzelm@12020
  2042
wenzelm@12020
  2043
lemma order_less_le_subst2: "(a::'a::order) < b ==> f b <= (c::'c::order) ==>
wenzelm@12020
  2044
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  2045
proof -
wenzelm@12020
  2046
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2047
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  2048
  also assume "f b <= c"
wenzelm@12020
  2049
  finally (order_less_le_trans) show ?thesis .
wenzelm@12020
  2050
qed
wenzelm@12020
  2051
wenzelm@12020
  2052
lemma order_less_le_subst1: "(a::'a::order) < f b ==> (b::'b::order) <= c ==>
wenzelm@12020
  2053
  (!!x y. x <= y ==> f x <= f y) ==> a < f c"
wenzelm@12020
  2054
proof -
wenzelm@12020
  2055
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2056
  assume "a < f b"
wenzelm@12020
  2057
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  2058
  finally (order_less_le_trans) show ?thesis .
wenzelm@12020
  2059
qed
wenzelm@12020
  2060
wenzelm@12020
  2061
lemma order_subst1: "(a::'a::order) <= f b ==> (b::'b::order) <= c ==>
wenzelm@12020
  2062
  (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
wenzelm@12020
  2063
proof -
wenzelm@12020
  2064
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2065
  assume "a <= f b"
wenzelm@12020
  2066
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  2067
  finally (order_trans) show ?thesis .
wenzelm@12020
  2068
qed
wenzelm@12020
  2069
wenzelm@12020
  2070
lemma order_subst2: "(a::'a::order) <= b ==> f b <= (c::'c::order) ==>
wenzelm@12020
  2071
  (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
wenzelm@12020
  2072
proof -
wenzelm@12020
  2073
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2074
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  2075
  also assume "f b <= c"
wenzelm@12020
  2076
  finally (order_trans) show ?thesis .
wenzelm@12020
  2077
qed
wenzelm@12020
  2078
wenzelm@12020
  2079
lemma ord_le_eq_subst: "a <= b ==> f b = c ==>
wenzelm@12020
  2080
  (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
wenzelm@12020
  2081
proof -
wenzelm@12020
  2082
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2083
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  2084
  also assume "f b = c"
wenzelm@12020
  2085
  finally (ord_le_eq_trans) show ?thesis .
wenzelm@12020
  2086
qed
wenzelm@12020
  2087
wenzelm@12020
  2088
lemma ord_eq_le_subst: "a = f b ==> b <= c ==>
wenzelm@12020
  2089
  (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
wenzelm@12020
  2090
proof -
wenzelm@12020
  2091
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  2092
  assume "a = f b"
wenzelm@12020
  2093
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  2094
  finally (ord_eq_le_trans) show ?thesis .
wenzelm@12020
  2095
qed
wenzelm@12020
  2096
wenzelm@12020
  2097
lemma ord_less_eq_subst: "a < b ==> f b = c ==>
wenzelm@12020
  2098
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  2099
proof -
wenzelm@12020
  2100
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2101
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  2102
  also assume "f b = c"
wenzelm@12020
  2103
  finally (ord_less_eq_trans) show ?thesis .
wenzelm@12020
  2104
qed
wenzelm@12020
  2105
wenzelm@12020
  2106
lemma ord_eq_less_subst: "a = f b ==> b < c ==>
wenzelm@12020
  2107
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  2108
proof -
wenzelm@12020
  2109
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  2110
  assume "a = f b"
wenzelm@12020
  2111
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  2112
  finally (ord_eq_less_trans) show ?thesis .
wenzelm@12020
  2113
qed
wenzelm@12020
  2114
wenzelm@12020
  2115
text {*
wenzelm@12020
  2116
  Note that this list of rules is in reverse order of priorities.
wenzelm@12020
  2117
*}
wenzelm@12020
  2118
wenzelm@12020
  2119
lemmas basic_trans_rules [trans] =
wenzelm@12020
  2120
  order_less_subst2
wenzelm@12020
  2121
  order_less_subst1
wenzelm@12020
  2122
  order_le_less_subst2
wenzelm@12020
  2123
  order_le_less_subst1
wenzelm@12020
  2124
  order_less_le_subst2
wenzelm@12020
  2125
  order_less_le_subst1
wenzelm@12020
  2126
  order_subst2
wenzelm@12020
  2127
  order_subst1
wenzelm@12020
  2128
  ord_le_eq_subst
wenzelm@12020
  2129
  ord_eq_le_subst
wenzelm@12020
  2130
  ord_less_eq_subst
wenzelm@12020
  2131
  ord_eq_less_subst
wenzelm@12020
  2132
  forw_subst
wenzelm@12020
  2133
  back_subst
wenzelm@12020
  2134
  rev_mp
wenzelm@12020
  2135
  mp
wenzelm@12020
  2136
  set_rev_mp
wenzelm@12020
  2137
  set_mp
wenzelm@12020
  2138
  order_neq_le_trans
wenzelm@12020
  2139
  order_le_neq_trans
wenzelm@12020
  2140
  order_less_trans
wenzelm@12020
  2141
  order_less_asym'
wenzelm@12020
  2142
  order_le_less_trans
wenzelm@12020
  2143
  order_less_le_trans
wenzelm@12020
  2144
  order_trans
wenzelm@12020
  2145
  order_antisym
wenzelm@12020
  2146
  ord_le_eq_trans
wenzelm@12020
  2147
  ord_eq_le_trans
wenzelm@12020
  2148
  ord_less_eq_trans
wenzelm@12020
  2149
  ord_eq_less_trans
wenzelm@12020
  2150
  trans
wenzelm@12020
  2151
wenzelm@11979
  2152
end