src/HOL/Set.thy
author huffman
Sun Oct 09 08:30:48 2011 +0200 (2011-10-09)
changeset 45121 5e495ccf6e56
parent 44744 bdf8eb8f126b
child 45152 e877b76c72bd
permissions -rw-r--r--
Set.thy: remove redundant [simp] declarations
haftmann@32139
     1
(*  Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel *)
clasohm@923
     2
wenzelm@11979
     3
header {* Set theory for higher-order logic *}
wenzelm@11979
     4
nipkow@15131
     5
theory Set
haftmann@30304
     6
imports Lattices
nipkow@15131
     7
begin
wenzelm@11979
     8
haftmann@32081
     9
subsection {* Sets as predicates *}
haftmann@30531
    10
bulwahn@42163
    11
type_synonym 'a set = "'a \<Rightarrow> bool"
wenzelm@3820
    12
haftmann@37677
    13
definition Collect :: "('a \<Rightarrow> bool) \<Rightarrow> 'a set" where -- "comprehension"
haftmann@37677
    14
  "Collect P = P"
haftmann@30304
    15
haftmann@37677
    16
definition member :: "'a \<Rightarrow> 'a set \<Rightarrow> bool" where -- "membership"
haftmann@37677
    17
  mem_def: "member x A = A x"
wenzelm@19656
    18
wenzelm@21210
    19
notation
haftmann@37677
    20
  member  ("op :") and
haftmann@37677
    21
  member  ("(_/ : _)" [50, 51] 50)
wenzelm@11979
    22
haftmann@37677
    23
abbreviation not_member where
haftmann@37677
    24
  "not_member x A \<equiv> ~ (x : A)" -- "non-membership"
wenzelm@19656
    25
wenzelm@21210
    26
notation
haftmann@37677
    27
  not_member  ("op ~:") and
haftmann@37677
    28
  not_member  ("(_/ ~: _)" [50, 51] 50)
wenzelm@19656
    29
wenzelm@21210
    30
notation (xsymbols)
haftmann@37677
    31
  member      ("op \<in>") and
haftmann@37677
    32
  member      ("(_/ \<in> _)" [50, 51] 50) and
haftmann@37677
    33
  not_member  ("op \<notin>") and
haftmann@37677
    34
  not_member  ("(_/ \<notin> _)" [50, 51] 50)
wenzelm@19656
    35
wenzelm@21210
    36
notation (HTML output)
haftmann@37677
    37
  member      ("op \<in>") and
haftmann@37677
    38
  member      ("(_/ \<in> _)" [50, 51] 50) and
haftmann@37677
    39
  not_member  ("op \<notin>") and
haftmann@37677
    40
  not_member  ("(_/ \<notin> _)" [50, 51] 50)
wenzelm@19656
    41
haftmann@41107
    42
haftmann@41107
    43
haftmann@32081
    44
text {* Set comprehensions *}
haftmann@32081
    45
haftmann@30531
    46
syntax
wenzelm@35115
    47
  "_Coll" :: "pttrn => bool => 'a set"    ("(1{_./ _})")
haftmann@30531
    48
translations
wenzelm@35115
    49
  "{x. P}" == "CONST Collect (%x. P)"
haftmann@30531
    50
haftmann@32081
    51
syntax
wenzelm@35115
    52
  "_Collect" :: "idt => 'a set => bool => 'a set"    ("(1{_ :/ _./ _})")
haftmann@32081
    53
syntax (xsymbols)
wenzelm@35115
    54
  "_Collect" :: "idt => 'a set => bool => 'a set"    ("(1{_ \<in>/ _./ _})")
haftmann@32081
    55
translations
wenzelm@35115
    56
  "{x:A. P}" => "{x. x:A & P}"
haftmann@32081
    57
haftmann@41107
    58
lemma mem_Collect_eq [iff]: "a \<in> {x. P x} = P a"
haftmann@32081
    59
  by (simp add: Collect_def mem_def)
haftmann@32081
    60
haftmann@41107
    61
lemma Collect_mem_eq [simp]: "{x. x \<in> A} = A"
haftmann@32081
    62
  by (simp add: Collect_def mem_def)
haftmann@32081
    63
haftmann@41107
    64
lemma CollectI: "P a \<Longrightarrow> a \<in> {x. P x}"
haftmann@32081
    65
  by simp
haftmann@32081
    66
haftmann@41107
    67
lemma CollectD: "a \<in> {x. P x} \<Longrightarrow> P a"
haftmann@32081
    68
  by simp
haftmann@32081
    69
haftmann@41107
    70
lemma Collect_cong: "(\<And>x. P x = Q x) ==> {x. P x} = {x. Q x}"
haftmann@32081
    71
  by simp
haftmann@32081
    72
haftmann@32117
    73
text {*
haftmann@32117
    74
Simproc for pulling @{text "x=t"} in @{text "{x. \<dots> & x=t & \<dots>}"}
haftmann@32117
    75
to the front (and similarly for @{text "t=x"}):
haftmann@32117
    76
*}
haftmann@32117
    77
wenzelm@42455
    78
simproc_setup defined_Collect ("{x. P x & Q x}") = {*
wenzelm@42459
    79
  fn _ =>
wenzelm@42459
    80
    Quantifier1.rearrange_Collect
wenzelm@42459
    81
     (rtac @{thm Collect_cong} 1 THEN
wenzelm@42455
    82
      rtac @{thm iffI} 1 THEN
wenzelm@42459
    83
      ALLGOALS
wenzelm@42459
    84
        (EVERY' [REPEAT_DETERM o etac @{thm conjE}, DEPTH_SOLVE_1 o ares_tac @{thms conjI}]))
haftmann@32117
    85
*}
haftmann@32117
    86
haftmann@32081
    87
lemmas CollectE = CollectD [elim_format]
haftmann@32081
    88
haftmann@41107
    89
lemma set_eqI:
haftmann@41107
    90
  assumes "\<And>x. x \<in> A \<longleftrightarrow> x \<in> B"
haftmann@41107
    91
  shows "A = B"
haftmann@41107
    92
proof -
haftmann@41107
    93
  from assms have "{x. x \<in> A} = {x. x \<in> B}" by simp
haftmann@41107
    94
  then show ?thesis by simp
haftmann@41107
    95
qed
haftmann@41107
    96
haftmann@41107
    97
lemma set_eq_iff [no_atp]:
haftmann@41107
    98
  "A = B \<longleftrightarrow> (\<forall>x. x \<in> A \<longleftrightarrow> x \<in> B)"
haftmann@41107
    99
  by (auto intro:set_eqI)
haftmann@41107
   100
haftmann@32081
   101
text {* Set enumerations *}
haftmann@30531
   102
haftmann@32264
   103
abbreviation empty :: "'a set" ("{}") where
haftmann@32264
   104
  "{} \<equiv> bot"
haftmann@31456
   105
haftmann@31456
   106
definition insert :: "'a \<Rightarrow> 'a set \<Rightarrow> 'a set" where
haftmann@32081
   107
  insert_compr: "insert a B = {x. x = a \<or> x \<in> B}"
haftmann@31456
   108
haftmann@31456
   109
syntax
wenzelm@35115
   110
  "_Finset" :: "args => 'a set"    ("{(_)}")
haftmann@31456
   111
translations
wenzelm@35115
   112
  "{x, xs}" == "CONST insert x {xs}"
wenzelm@35115
   113
  "{x}" == "CONST insert x {}"
haftmann@31456
   114
haftmann@32081
   115
haftmann@32081
   116
subsection {* Subsets and bounded quantifiers *}
haftmann@32081
   117
haftmann@32081
   118
abbreviation
haftmann@32081
   119
  subset :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@32081
   120
  "subset \<equiv> less"
haftmann@32081
   121
haftmann@32081
   122
abbreviation
haftmann@32081
   123
  subset_eq :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@32081
   124
  "subset_eq \<equiv> less_eq"
haftmann@32081
   125
haftmann@32081
   126
notation (output)
haftmann@32081
   127
  subset  ("op <") and
haftmann@32081
   128
  subset  ("(_/ < _)" [50, 51] 50) and
haftmann@32081
   129
  subset_eq  ("op <=") and
haftmann@32081
   130
  subset_eq  ("(_/ <= _)" [50, 51] 50)
haftmann@32081
   131
haftmann@32081
   132
notation (xsymbols)
haftmann@32081
   133
  subset  ("op \<subset>") and
haftmann@32081
   134
  subset  ("(_/ \<subset> _)" [50, 51] 50) and
haftmann@32081
   135
  subset_eq  ("op \<subseteq>") and
haftmann@32081
   136
  subset_eq  ("(_/ \<subseteq> _)" [50, 51] 50)
haftmann@32081
   137
haftmann@32081
   138
notation (HTML output)
haftmann@32081
   139
  subset  ("op \<subset>") and
haftmann@32081
   140
  subset  ("(_/ \<subset> _)" [50, 51] 50) and
haftmann@32081
   141
  subset_eq  ("op \<subseteq>") and
haftmann@32081
   142
  subset_eq  ("(_/ \<subseteq> _)" [50, 51] 50)
haftmann@32081
   143
haftmann@32081
   144
abbreviation (input)
haftmann@32081
   145
  supset :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@32081
   146
  "supset \<equiv> greater"
haftmann@32081
   147
haftmann@32081
   148
abbreviation (input)
haftmann@32081
   149
  supset_eq :: "'a set \<Rightarrow> 'a set \<Rightarrow> bool" where
haftmann@32081
   150
  "supset_eq \<equiv> greater_eq"
haftmann@32081
   151
haftmann@32081
   152
notation (xsymbols)
haftmann@32081
   153
  supset  ("op \<supset>") and
haftmann@32081
   154
  supset  ("(_/ \<supset> _)" [50, 51] 50) and
haftmann@32081
   155
  supset_eq  ("op \<supseteq>") and
haftmann@32081
   156
  supset_eq  ("(_/ \<supseteq> _)" [50, 51] 50)
haftmann@32081
   157
haftmann@37387
   158
definition Ball :: "'a set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
haftmann@37387
   159
  "Ball A P \<longleftrightarrow> (\<forall>x. x \<in> A \<longrightarrow> P x)"   -- "bounded universal quantifiers"
haftmann@32077
   160
haftmann@37387
   161
definition Bex :: "'a set \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where
haftmann@37387
   162
  "Bex A P \<longleftrightarrow> (\<exists>x. x \<in> A \<and> P x)"   -- "bounded existential quantifiers"
haftmann@32077
   163
haftmann@30531
   164
syntax
haftmann@30531
   165
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3ALL _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   166
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3EX _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   167
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3EX! _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   168
  "_Bleast"     :: "id => 'a set => bool => 'a"           ("(3LEAST _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   169
haftmann@30531
   170
syntax (HOL)
haftmann@30531
   171
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3! _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   172
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3? _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   173
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3?! _:_./ _)" [0, 0, 10] 10)
haftmann@30531
   174
haftmann@30531
   175
syntax (xsymbols)
haftmann@30531
   176
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   177
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   178
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3\<exists>!_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   179
  "_Bleast"     :: "id => 'a set => bool => 'a"           ("(3LEAST_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   180
haftmann@30531
   181
syntax (HTML output)
haftmann@30531
   182
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   183
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   184
  "_Bex1"       :: "pttrn => 'a set => bool => bool"      ("(3\<exists>!_\<in>_./ _)" [0, 0, 10] 10)
haftmann@30531
   185
haftmann@30531
   186
translations
wenzelm@35115
   187
  "ALL x:A. P" == "CONST Ball A (%x. P)"
wenzelm@35115
   188
  "EX x:A. P" == "CONST Bex A (%x. P)"
wenzelm@35115
   189
  "EX! x:A. P" => "EX! x. x:A & P"
haftmann@30531
   190
  "LEAST x:A. P" => "LEAST x. x:A & P"
haftmann@30531
   191
wenzelm@19656
   192
syntax (output)
nipkow@14804
   193
  "_setlessAll" :: "[idt, 'a, bool] => bool"  ("(3ALL _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   194
  "_setlessEx"  :: "[idt, 'a, bool] => bool"  ("(3EX _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   195
  "_setleAll"   :: "[idt, 'a, bool] => bool"  ("(3ALL _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   196
  "_setleEx"    :: "[idt, 'a, bool] => bool"  ("(3EX _<=_./ _)" [0, 0, 10] 10)
webertj@20217
   197
  "_setleEx1"   :: "[idt, 'a, bool] => bool"  ("(3EX! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   198
nipkow@14804
   199
syntax (xsymbols)
nipkow@14804
   200
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   201
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   202
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   203
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
webertj@20217
   204
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3\<exists>!_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   205
wenzelm@19656
   206
syntax (HOL output)
nipkow@14804
   207
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3! _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   208
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3? _<_./ _)"  [0, 0, 10] 10)
nipkow@14804
   209
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   210
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3? _<=_./ _)" [0, 0, 10] 10)
webertj@20217
   211
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3?! _<=_./ _)" [0, 0, 10] 10)
nipkow@14804
   212
nipkow@14804
   213
syntax (HTML output)
nipkow@14804
   214
  "_setlessAll" :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   215
  "_setlessEx"  :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subset>_./ _)"  [0, 0, 10] 10)
nipkow@14804
   216
  "_setleAll"   :: "[idt, 'a, bool] => bool"   ("(3\<forall>_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   217
  "_setleEx"    :: "[idt, 'a, bool] => bool"   ("(3\<exists>_\<subseteq>_./ _)" [0, 0, 10] 10)
webertj@20217
   218
  "_setleEx1"   :: "[idt, 'a, bool] => bool"   ("(3\<exists>!_\<subseteq>_./ _)" [0, 0, 10] 10)
nipkow@14804
   219
nipkow@14804
   220
translations
haftmann@30531
   221
 "\<forall>A\<subset>B. P"   =>  "ALL A. A \<subset> B --> P"
haftmann@30531
   222
 "\<exists>A\<subset>B. P"   =>  "EX A. A \<subset> B & P"
haftmann@30531
   223
 "\<forall>A\<subseteq>B. P"   =>  "ALL A. A \<subseteq> B --> P"
haftmann@30531
   224
 "\<exists>A\<subseteq>B. P"   =>  "EX A. A \<subseteq> B & P"
haftmann@30531
   225
 "\<exists>!A\<subseteq>B. P"  =>  "EX! A. A \<subseteq> B & P"
nipkow@14804
   226
nipkow@14804
   227
print_translation {*
nipkow@14804
   228
let
wenzelm@35115
   229
  val Type (set_type, _) = @{typ "'a set"};   (* FIXME 'a => bool (!?!) *)
wenzelm@42287
   230
  val All_binder = Mixfix.binder_name @{const_syntax All};
wenzelm@42287
   231
  val Ex_binder = Mixfix.binder_name @{const_syntax Ex};
haftmann@38786
   232
  val impl = @{const_syntax HOL.implies};
haftmann@38795
   233
  val conj = @{const_syntax HOL.conj};
wenzelm@35115
   234
  val sbset = @{const_syntax subset};
wenzelm@35115
   235
  val sbset_eq = @{const_syntax subset_eq};
haftmann@21819
   236
haftmann@21819
   237
  val trans =
wenzelm@35115
   238
   [((All_binder, impl, sbset), @{syntax_const "_setlessAll"}),
wenzelm@35115
   239
    ((All_binder, impl, sbset_eq), @{syntax_const "_setleAll"}),
wenzelm@35115
   240
    ((Ex_binder, conj, sbset), @{syntax_const "_setlessEx"}),
wenzelm@35115
   241
    ((Ex_binder, conj, sbset_eq), @{syntax_const "_setleEx"})];
haftmann@21819
   242
haftmann@21819
   243
  fun mk v v' c n P =
haftmann@21819
   244
    if v = v' andalso not (Term.exists_subterm (fn Free (x, _) => x = v | _ => false) n)
wenzelm@42284
   245
    then Syntax.const c $ Syntax_Trans.mark_bound v' $ n $ P else raise Match;
haftmann@21819
   246
haftmann@21819
   247
  fun tr' q = (q,
wenzelm@35115
   248
        fn [Const (@{syntax_const "_bound"}, _) $ Free (v, Type (T, _)),
wenzelm@35115
   249
            Const (c, _) $
wenzelm@35115
   250
              (Const (d, _) $ (Const (@{syntax_const "_bound"}, _) $ Free (v', _)) $ n) $ P] =>
wenzelm@35115
   251
            if T = set_type then
wenzelm@35115
   252
              (case AList.lookup (op =) trans (q, c, d) of
wenzelm@35115
   253
                NONE => raise Match
wenzelm@35115
   254
              | SOME l => mk v v' l n P)
wenzelm@35115
   255
            else raise Match
wenzelm@35115
   256
         | _ => raise Match);
nipkow@14804
   257
in
haftmann@21819
   258
  [tr' All_binder, tr' Ex_binder]
nipkow@14804
   259
end
nipkow@14804
   260
*}
nipkow@14804
   261
haftmann@30531
   262
wenzelm@11979
   263
text {*
wenzelm@11979
   264
  \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
wenzelm@11979
   265
  "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
wenzelm@11979
   266
  only translated if @{text "[0..n] subset bvs(e)"}.
wenzelm@11979
   267
*}
wenzelm@11979
   268
wenzelm@35115
   269
syntax
wenzelm@35115
   270
  "_Setcompr" :: "'a => idts => bool => 'a set"    ("(1{_ |/_./ _})")
wenzelm@35115
   271
wenzelm@11979
   272
parse_translation {*
wenzelm@11979
   273
  let
wenzelm@42284
   274
    val ex_tr = snd (Syntax_Trans.mk_binder_tr ("EX ", @{const_syntax Ex}));
wenzelm@3947
   275
wenzelm@35115
   276
    fun nvars (Const (@{syntax_const "_idts"}, _) $ _ $ idts) = nvars idts + 1
wenzelm@11979
   277
      | nvars _ = 1;
wenzelm@11979
   278
wenzelm@11979
   279
    fun setcompr_tr [e, idts, b] =
wenzelm@11979
   280
      let
haftmann@38864
   281
        val eq = Syntax.const @{const_syntax HOL.eq} $ Bound (nvars idts) $ e;
haftmann@38795
   282
        val P = Syntax.const @{const_syntax HOL.conj} $ eq $ b;
wenzelm@11979
   283
        val exP = ex_tr [idts, P];
wenzelm@44241
   284
      in Syntax.const @{const_syntax Collect} $ absdummy dummyT exP end;
wenzelm@11979
   285
wenzelm@35115
   286
  in [(@{syntax_const "_Setcompr"}, setcompr_tr)] end;
wenzelm@11979
   287
*}
clasohm@923
   288
wenzelm@35115
   289
print_translation {*
wenzelm@42284
   290
 [Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax Ball} @{syntax_const "_Ball"},
wenzelm@42284
   291
  Syntax_Trans.preserve_binder_abs2_tr' @{const_syntax Bex} @{syntax_const "_Bex"}]
wenzelm@35115
   292
*} -- {* to avoid eta-contraction of body *}
haftmann@30531
   293
nipkow@13763
   294
print_translation {*
nipkow@13763
   295
let
wenzelm@42284
   296
  val ex_tr' = snd (Syntax_Trans.mk_binder_tr' (@{const_syntax Ex}, "DUMMY"));
nipkow@13763
   297
nipkow@13763
   298
  fun setcompr_tr' [Abs (abs as (_, _, P))] =
nipkow@13763
   299
    let
wenzelm@35115
   300
      fun check (Const (@{const_syntax Ex}, _) $ Abs (_, _, P), n) = check (P, n + 1)
haftmann@38795
   301
        | check (Const (@{const_syntax HOL.conj}, _) $
haftmann@38864
   302
              (Const (@{const_syntax HOL.eq}, _) $ Bound m $ e) $ P, n) =
nipkow@13763
   303
            n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso
haftmann@33038
   304
            subset (op =) (0 upto (n - 1), add_loose_bnos (e, 0, []))
wenzelm@35115
   305
        | check _ = false;
clasohm@923
   306
wenzelm@11979
   307
        fun tr' (_ $ abs) =
wenzelm@11979
   308
          let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' [abs]
wenzelm@35115
   309
          in Syntax.const @{syntax_const "_Setcompr"} $ e $ idts $ Q end;
wenzelm@35115
   310
    in
wenzelm@35115
   311
      if check (P, 0) then tr' P
wenzelm@35115
   312
      else
wenzelm@35115
   313
        let
wenzelm@42284
   314
          val (x as _ $ Free(xN, _), t) = Syntax_Trans.atomic_abs_tr' abs;
wenzelm@35115
   315
          val M = Syntax.const @{syntax_const "_Coll"} $ x $ t;
wenzelm@35115
   316
        in
wenzelm@35115
   317
          case t of
haftmann@38795
   318
            Const (@{const_syntax HOL.conj}, _) $
haftmann@37677
   319
              (Const (@{const_syntax Set.member}, _) $
wenzelm@35115
   320
                (Const (@{syntax_const "_bound"}, _) $ Free (yN, _)) $ A) $ P =>
wenzelm@35115
   321
            if xN = yN then Syntax.const @{syntax_const "_Collect"} $ x $ A $ P else M
wenzelm@35115
   322
          | _ => M
wenzelm@35115
   323
        end
nipkow@13763
   324
    end;
wenzelm@35115
   325
  in [(@{const_syntax Collect}, setcompr_tr')] end;
wenzelm@11979
   326
*}
wenzelm@11979
   327
wenzelm@42455
   328
simproc_setup defined_Bex ("EX x:A. P x & Q x") = {*
wenzelm@42455
   329
  let
wenzelm@42455
   330
    val unfold_bex_tac = unfold_tac @{thms Bex_def};
wenzelm@42455
   331
    fun prove_bex_tac ss = unfold_bex_tac ss THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@42459
   332
  in fn _ => fn ss => Quantifier1.rearrange_bex (prove_bex_tac ss) ss end
wenzelm@42455
   333
*}
wenzelm@42455
   334
wenzelm@42455
   335
simproc_setup defined_All ("ALL x:A. P x --> Q x") = {*
wenzelm@42455
   336
  let
wenzelm@42455
   337
    val unfold_ball_tac = unfold_tac @{thms Ball_def};
wenzelm@42455
   338
    fun prove_ball_tac ss = unfold_ball_tac ss THEN Quantifier1.prove_one_point_all_tac;
wenzelm@42459
   339
  in fn _ => fn ss => Quantifier1.rearrange_ball (prove_ball_tac ss) ss end
haftmann@32117
   340
*}
haftmann@32117
   341
wenzelm@11979
   342
lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x"
wenzelm@11979
   343
  by (simp add: Ball_def)
wenzelm@11979
   344
wenzelm@11979
   345
lemmas strip = impI allI ballI
wenzelm@11979
   346
wenzelm@11979
   347
lemma bspec [dest?]: "ALL x:A. P x ==> x:A ==> P x"
wenzelm@11979
   348
  by (simp add: Ball_def)
wenzelm@11979
   349
wenzelm@11979
   350
text {*
wenzelm@11979
   351
  Gives better instantiation for bound:
wenzelm@11979
   352
*}
wenzelm@11979
   353
wenzelm@26339
   354
declaration {* fn _ =>
wenzelm@26339
   355
  Classical.map_cs (fn cs => cs addbefore ("bspec", datac @{thm bspec} 1))
wenzelm@11979
   356
*}
wenzelm@11979
   357
haftmann@32117
   358
ML {*
haftmann@32117
   359
structure Simpdata =
haftmann@32117
   360
struct
haftmann@32117
   361
haftmann@32117
   362
open Simpdata;
haftmann@32117
   363
haftmann@32117
   364
val mksimps_pairs = [(@{const_name Ball}, @{thms bspec})] @ mksimps_pairs;
haftmann@32117
   365
haftmann@32117
   366
end;
haftmann@32117
   367
haftmann@32117
   368
open Simpdata;
haftmann@32117
   369
*}
haftmann@32117
   370
haftmann@32117
   371
declaration {* fn _ =>
haftmann@32117
   372
  Simplifier.map_ss (fn ss => ss setmksimps (mksimps mksimps_pairs))
haftmann@32117
   373
*}
haftmann@32117
   374
haftmann@32117
   375
lemma ballE [elim]: "ALL x:A. P x ==> (P x ==> Q) ==> (x ~: A ==> Q) ==> Q"
haftmann@32117
   376
  by (unfold Ball_def) blast
haftmann@32117
   377
wenzelm@11979
   378
lemma bexI [intro]: "P x ==> x:A ==> EX x:A. P x"
wenzelm@11979
   379
  -- {* Normally the best argument order: @{prop "P x"} constrains the
wenzelm@11979
   380
    choice of @{prop "x:A"}. *}
wenzelm@11979
   381
  by (unfold Bex_def) blast
wenzelm@11979
   382
wenzelm@13113
   383
lemma rev_bexI [intro?]: "x:A ==> P x ==> EX x:A. P x"
wenzelm@11979
   384
  -- {* The best argument order when there is only one @{prop "x:A"}. *}
wenzelm@11979
   385
  by (unfold Bex_def) blast
wenzelm@11979
   386
wenzelm@11979
   387
lemma bexCI: "(ALL x:A. ~P x ==> P a) ==> a:A ==> EX x:A. P x"
wenzelm@11979
   388
  by (unfold Bex_def) blast
wenzelm@11979
   389
wenzelm@11979
   390
lemma bexE [elim!]: "EX x:A. P x ==> (!!x. x:A ==> P x ==> Q) ==> Q"
wenzelm@11979
   391
  by (unfold Bex_def) blast
wenzelm@11979
   392
wenzelm@11979
   393
lemma ball_triv [simp]: "(ALL x:A. P) = ((EX x. x:A) --> P)"
wenzelm@11979
   394
  -- {* Trival rewrite rule. *}
wenzelm@11979
   395
  by (simp add: Ball_def)
wenzelm@11979
   396
wenzelm@11979
   397
lemma bex_triv [simp]: "(EX x:A. P) = ((EX x. x:A) & P)"
wenzelm@11979
   398
  -- {* Dual form for existentials. *}
wenzelm@11979
   399
  by (simp add: Bex_def)
wenzelm@11979
   400
wenzelm@11979
   401
lemma bex_triv_one_point1 [simp]: "(EX x:A. x = a) = (a:A)"
wenzelm@11979
   402
  by blast
wenzelm@11979
   403
wenzelm@11979
   404
lemma bex_triv_one_point2 [simp]: "(EX x:A. a = x) = (a:A)"
wenzelm@11979
   405
  by blast
wenzelm@11979
   406
wenzelm@11979
   407
lemma bex_one_point1 [simp]: "(EX x:A. x = a & P x) = (a:A & P a)"
wenzelm@11979
   408
  by blast
wenzelm@11979
   409
wenzelm@11979
   410
lemma bex_one_point2 [simp]: "(EX x:A. a = x & P x) = (a:A & P a)"
wenzelm@11979
   411
  by blast
wenzelm@11979
   412
wenzelm@11979
   413
lemma ball_one_point1 [simp]: "(ALL x:A. x = a --> P x) = (a:A --> P a)"
wenzelm@11979
   414
  by blast
wenzelm@11979
   415
wenzelm@11979
   416
lemma ball_one_point2 [simp]: "(ALL x:A. a = x --> P x) = (a:A --> P a)"
wenzelm@11979
   417
  by blast
wenzelm@11979
   418
haftmann@43818
   419
lemma ball_conj_distrib:
haftmann@43818
   420
  "(\<forall>x\<in>A. P x \<and> Q x) \<longleftrightarrow> ((\<forall>x\<in>A. P x) \<and> (\<forall>x\<in>A. Q x))"
haftmann@43818
   421
  by blast
haftmann@43818
   422
haftmann@43818
   423
lemma bex_disj_distrib:
haftmann@43818
   424
  "(\<exists>x\<in>A. P x \<or> Q x) \<longleftrightarrow> ((\<exists>x\<in>A. P x) \<or> (\<exists>x\<in>A. Q x))"
haftmann@43818
   425
  by blast
haftmann@43818
   426
wenzelm@11979
   427
haftmann@32081
   428
text {* Congruence rules *}
wenzelm@11979
   429
berghofe@16636
   430
lemma ball_cong:
wenzelm@11979
   431
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   432
    (ALL x:A. P x) = (ALL x:B. Q x)"
wenzelm@11979
   433
  by (simp add: Ball_def)
wenzelm@11979
   434
berghofe@16636
   435
lemma strong_ball_cong [cong]:
berghofe@16636
   436
  "A = B ==> (!!x. x:B =simp=> P x = Q x) ==>
berghofe@16636
   437
    (ALL x:A. P x) = (ALL x:B. Q x)"
berghofe@16636
   438
  by (simp add: simp_implies_def Ball_def)
berghofe@16636
   439
berghofe@16636
   440
lemma bex_cong:
wenzelm@11979
   441
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   442
    (EX x:A. P x) = (EX x:B. Q x)"
wenzelm@11979
   443
  by (simp add: Bex_def cong: conj_cong)
regensbu@1273
   444
berghofe@16636
   445
lemma strong_bex_cong [cong]:
berghofe@16636
   446
  "A = B ==> (!!x. x:B =simp=> P x = Q x) ==>
berghofe@16636
   447
    (EX x:A. P x) = (EX x:B. Q x)"
berghofe@16636
   448
  by (simp add: simp_implies_def Bex_def cong: conj_cong)
berghofe@16636
   449
haftmann@30531
   450
haftmann@32081
   451
subsection {* Basic operations *}
haftmann@32081
   452
haftmann@30531
   453
subsubsection {* Subsets *}
haftmann@30531
   454
paulson@33022
   455
lemma subsetI [intro!]: "(\<And>x. x \<in> A \<Longrightarrow> x \<in> B) \<Longrightarrow> A \<subseteq> B"
haftmann@32888
   456
  unfolding mem_def by (rule le_funI, rule le_boolI)
haftmann@30352
   457
wenzelm@11979
   458
text {*
haftmann@30531
   459
  \medskip Map the type @{text "'a set => anything"} to just @{typ
haftmann@30531
   460
  'a}; for overloading constants whose first argument has type @{typ
haftmann@30531
   461
  "'a set"}.
wenzelm@11979
   462
*}
wenzelm@11979
   463
haftmann@30596
   464
lemma subsetD [elim, intro?]: "A \<subseteq> B ==> c \<in> A ==> c \<in> B"
haftmann@32888
   465
  unfolding mem_def by (erule le_funE, erule le_boolE)
haftmann@30531
   466
  -- {* Rule in Modus Ponens style. *}
haftmann@30531
   467
blanchet@35828
   468
lemma rev_subsetD [no_atp,intro?]: "c \<in> A ==> A \<subseteq> B ==> c \<in> B"
haftmann@30531
   469
  -- {* The same, with reversed premises for use with @{text erule} --
haftmann@30531
   470
      cf @{text rev_mp}. *}
haftmann@30531
   471
  by (rule subsetD)
haftmann@30531
   472
wenzelm@11979
   473
text {*
haftmann@30531
   474
  \medskip Converts @{prop "A \<subseteq> B"} to @{prop "x \<in> A ==> x \<in> B"}.
haftmann@30531
   475
*}
haftmann@30531
   476
blanchet@35828
   477
lemma subsetCE [no_atp,elim]: "A \<subseteq> B ==> (c \<notin> A ==> P) ==> (c \<in> B ==> P) ==> P"
haftmann@30531
   478
  -- {* Classical elimination rule. *}
haftmann@32888
   479
  unfolding mem_def by (blast dest: le_funE le_boolE)
haftmann@30531
   480
blanchet@35828
   481
lemma subset_eq [no_atp]: "A \<le> B = (\<forall>x\<in>A. x \<in> B)" by blast
wenzelm@2388
   482
blanchet@35828
   483
lemma contra_subsetD [no_atp]: "A \<subseteq> B ==> c \<notin> B ==> c \<notin> A"
haftmann@30531
   484
  by blast
haftmann@30531
   485
huffman@45121
   486
lemma subset_refl: "A \<subseteq> A"
huffman@45121
   487
  by (fact order_refl) (* already [iff] *)
haftmann@30531
   488
haftmann@30531
   489
lemma subset_trans: "A \<subseteq> B ==> B \<subseteq> C ==> A \<subseteq> C"
haftmann@32081
   490
  by (fact order_trans)
haftmann@32081
   491
haftmann@32081
   492
lemma set_rev_mp: "x:A ==> A \<subseteq> B ==> x:B"
haftmann@32081
   493
  by (rule subsetD)
haftmann@32081
   494
haftmann@32081
   495
lemma set_mp: "A \<subseteq> B ==> x:A ==> x:B"
haftmann@32081
   496
  by (rule subsetD)
haftmann@32081
   497
paulson@33044
   498
lemma eq_mem_trans: "a=b ==> b \<in> A ==> a \<in> A"
paulson@33044
   499
  by simp
paulson@33044
   500
haftmann@32081
   501
lemmas basic_trans_rules [trans] =
paulson@33044
   502
  order_trans_rules set_rev_mp set_mp eq_mem_trans
haftmann@30531
   503
haftmann@30531
   504
haftmann@30531
   505
subsubsection {* Equality *}
haftmann@30531
   506
haftmann@30531
   507
lemma subset_antisym [intro!]: "A \<subseteq> B ==> B \<subseteq> A ==> A = B"
haftmann@30531
   508
  -- {* Anti-symmetry of the subset relation. *}
nipkow@39302
   509
  by (iprover intro: set_eqI subsetD)
haftmann@30531
   510
haftmann@30531
   511
text {*
haftmann@30531
   512
  \medskip Equality rules from ZF set theory -- are they appropriate
haftmann@30531
   513
  here?
haftmann@30531
   514
*}
haftmann@30531
   515
haftmann@30531
   516
lemma equalityD1: "A = B ==> A \<subseteq> B"
krauss@34209
   517
  by simp
haftmann@30531
   518
haftmann@30531
   519
lemma equalityD2: "A = B ==> B \<subseteq> A"
krauss@34209
   520
  by simp
haftmann@30531
   521
haftmann@30531
   522
text {*
haftmann@30531
   523
  \medskip Be careful when adding this to the claset as @{text
haftmann@30531
   524
  subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{}
haftmann@30531
   525
  \<subseteq> A"} and @{prop "A \<subseteq> {}"} and then back to @{prop "A = {}"}!
haftmann@30352
   526
*}
haftmann@30352
   527
haftmann@30531
   528
lemma equalityE: "A = B ==> (A \<subseteq> B ==> B \<subseteq> A ==> P) ==> P"
krauss@34209
   529
  by simp
haftmann@30531
   530
haftmann@30531
   531
lemma equalityCE [elim]:
haftmann@30531
   532
    "A = B ==> (c \<in> A ==> c \<in> B ==> P) ==> (c \<notin> A ==> c \<notin> B ==> P) ==> P"
haftmann@30531
   533
  by blast
haftmann@30531
   534
haftmann@30531
   535
lemma eqset_imp_iff: "A = B ==> (x : A) = (x : B)"
haftmann@30531
   536
  by simp
haftmann@30531
   537
haftmann@30531
   538
lemma eqelem_imp_iff: "x = y ==> (x : A) = (y : A)"
haftmann@30531
   539
  by simp
haftmann@30531
   540
haftmann@30531
   541
haftmann@41082
   542
subsubsection {* The empty set *}
haftmann@41082
   543
haftmann@41082
   544
lemma empty_def:
haftmann@41082
   545
  "{} = {x. False}"
haftmann@43818
   546
  by (simp add: bot_fun_def Collect_def)
haftmann@41082
   547
haftmann@41082
   548
lemma empty_iff [simp]: "(c : {}) = False"
haftmann@41082
   549
  by (simp add: empty_def)
haftmann@41082
   550
haftmann@41082
   551
lemma emptyE [elim!]: "a : {} ==> P"
haftmann@41082
   552
  by simp
haftmann@41082
   553
haftmann@41082
   554
lemma empty_subsetI [iff]: "{} \<subseteq> A"
haftmann@41082
   555
    -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *}
haftmann@41082
   556
  by blast
haftmann@41082
   557
haftmann@41082
   558
lemma equals0I: "(!!y. y \<in> A ==> False) ==> A = {}"
haftmann@41082
   559
  by blast
haftmann@41082
   560
haftmann@41082
   561
lemma equals0D: "A = {} ==> a \<notin> A"
haftmann@41082
   562
    -- {* Use for reasoning about disjointness: @{text "A Int B = {}"} *}
haftmann@41082
   563
  by blast
haftmann@41082
   564
haftmann@41082
   565
lemma ball_empty [simp]: "Ball {} P = True"
haftmann@41082
   566
  by (simp add: Ball_def)
haftmann@41082
   567
haftmann@41082
   568
lemma bex_empty [simp]: "Bex {} P = False"
haftmann@41082
   569
  by (simp add: Bex_def)
haftmann@41082
   570
haftmann@41082
   571
haftmann@30531
   572
subsubsection {* The universal set -- UNIV *}
haftmann@30531
   573
haftmann@32264
   574
abbreviation UNIV :: "'a set" where
haftmann@32264
   575
  "UNIV \<equiv> top"
haftmann@32135
   576
haftmann@32135
   577
lemma UNIV_def:
haftmann@32117
   578
  "UNIV = {x. True}"
haftmann@43818
   579
  by (simp add: top_fun_def Collect_def)
haftmann@32081
   580
haftmann@30531
   581
lemma UNIV_I [simp]: "x : UNIV"
haftmann@30531
   582
  by (simp add: UNIV_def)
haftmann@30531
   583
haftmann@30531
   584
declare UNIV_I [intro]  -- {* unsafe makes it less likely to cause problems *}
haftmann@30531
   585
haftmann@30531
   586
lemma UNIV_witness [intro?]: "EX x. x : UNIV"
haftmann@30531
   587
  by simp
haftmann@30531
   588
huffman@45121
   589
lemma subset_UNIV: "A \<subseteq> UNIV"
huffman@45121
   590
  by (fact top_greatest) (* already simp *)
haftmann@30531
   591
haftmann@30531
   592
text {*
haftmann@30531
   593
  \medskip Eta-contracting these two rules (to remove @{text P})
haftmann@30531
   594
  causes them to be ignored because of their interaction with
haftmann@30531
   595
  congruence rules.
haftmann@30531
   596
*}
haftmann@30531
   597
haftmann@30531
   598
lemma ball_UNIV [simp]: "Ball UNIV P = All P"
haftmann@30531
   599
  by (simp add: Ball_def)
haftmann@30531
   600
haftmann@30531
   601
lemma bex_UNIV [simp]: "Bex UNIV P = Ex P"
haftmann@30531
   602
  by (simp add: Bex_def)
haftmann@30531
   603
haftmann@30531
   604
lemma UNIV_eq_I: "(\<And>x. x \<in> A) \<Longrightarrow> UNIV = A"
haftmann@30531
   605
  by auto
haftmann@30531
   606
haftmann@30531
   607
lemma UNIV_not_empty [iff]: "UNIV ~= {}"
haftmann@30531
   608
  by (blast elim: equalityE)
haftmann@30531
   609
haftmann@30531
   610
haftmann@30531
   611
subsubsection {* The Powerset operator -- Pow *}
haftmann@30531
   612
haftmann@32077
   613
definition Pow :: "'a set => 'a set set" where
haftmann@32077
   614
  Pow_def: "Pow A = {B. B \<le> A}"
haftmann@32077
   615
haftmann@30531
   616
lemma Pow_iff [iff]: "(A \<in> Pow B) = (A \<subseteq> B)"
haftmann@30531
   617
  by (simp add: Pow_def)
haftmann@30531
   618
haftmann@30531
   619
lemma PowI: "A \<subseteq> B ==> A \<in> Pow B"
haftmann@30531
   620
  by (simp add: Pow_def)
haftmann@30531
   621
haftmann@30531
   622
lemma PowD: "A \<in> Pow B ==> A \<subseteq> B"
haftmann@30531
   623
  by (simp add: Pow_def)
haftmann@30531
   624
haftmann@30531
   625
lemma Pow_bottom: "{} \<in> Pow B"
haftmann@30531
   626
  by simp
haftmann@30531
   627
haftmann@30531
   628
lemma Pow_top: "A \<in> Pow A"
krauss@34209
   629
  by simp
haftmann@30531
   630
hoelzl@40703
   631
lemma Pow_not_empty: "Pow A \<noteq> {}"
hoelzl@40703
   632
  using Pow_top by blast
haftmann@30531
   633
haftmann@41076
   634
haftmann@30531
   635
subsubsection {* Set complement *}
haftmann@30531
   636
haftmann@30531
   637
lemma Compl_iff [simp]: "(c \<in> -A) = (c \<notin> A)"
haftmann@43818
   638
  by (simp add: mem_def fun_Compl_def)
haftmann@30531
   639
haftmann@30531
   640
lemma ComplI [intro!]: "(c \<in> A ==> False) ==> c \<in> -A"
haftmann@30531
   641
  by (unfold mem_def fun_Compl_def bool_Compl_def) blast
clasohm@923
   642
wenzelm@11979
   643
text {*
haftmann@30531
   644
  \medskip This form, with negated conclusion, works well with the
haftmann@30531
   645
  Classical prover.  Negated assumptions behave like formulae on the
haftmann@30531
   646
  right side of the notional turnstile ... *}
haftmann@30531
   647
haftmann@30531
   648
lemma ComplD [dest!]: "c : -A ==> c~:A"
haftmann@43818
   649
  by (simp add: mem_def fun_Compl_def)
haftmann@30531
   650
haftmann@30531
   651
lemmas ComplE = ComplD [elim_format]
haftmann@30531
   652
haftmann@30531
   653
lemma Compl_eq: "- A = {x. ~ x : A}" by blast
haftmann@30531
   654
haftmann@30531
   655
haftmann@41082
   656
subsubsection {* Binary intersection *}
haftmann@41082
   657
haftmann@41082
   658
abbreviation inter :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "Int" 70) where
haftmann@41082
   659
  "op Int \<equiv> inf"
haftmann@41082
   660
haftmann@41082
   661
notation (xsymbols)
haftmann@41082
   662
  inter  (infixl "\<inter>" 70)
haftmann@41082
   663
haftmann@41082
   664
notation (HTML output)
haftmann@41082
   665
  inter  (infixl "\<inter>" 70)
haftmann@41082
   666
haftmann@41082
   667
lemma Int_def:
haftmann@41082
   668
  "A \<inter> B = {x. x \<in> A \<and> x \<in> B}"
haftmann@43818
   669
  by (simp add: inf_fun_def Collect_def mem_def)
haftmann@41082
   670
haftmann@41082
   671
lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)"
haftmann@41082
   672
  by (unfold Int_def) blast
haftmann@41082
   673
haftmann@41082
   674
lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B"
haftmann@41082
   675
  by simp
haftmann@41082
   676
haftmann@41082
   677
lemma IntD1: "c : A Int B ==> c:A"
haftmann@41082
   678
  by simp
haftmann@41082
   679
haftmann@41082
   680
lemma IntD2: "c : A Int B ==> c:B"
haftmann@41082
   681
  by simp
haftmann@41082
   682
haftmann@41082
   683
lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P"
haftmann@41082
   684
  by simp
haftmann@41082
   685
haftmann@41082
   686
lemma mono_Int: "mono f \<Longrightarrow> f (A \<inter> B) \<subseteq> f A \<inter> f B"
haftmann@41082
   687
  by (fact mono_inf)
haftmann@41082
   688
haftmann@41082
   689
haftmann@41082
   690
subsubsection {* Binary union *}
haftmann@30531
   691
haftmann@32683
   692
abbreviation union :: "'a set \<Rightarrow> 'a set \<Rightarrow> 'a set" (infixl "Un" 65) where
haftmann@41076
   693
  "union \<equiv> sup"
haftmann@32081
   694
haftmann@32081
   695
notation (xsymbols)
haftmann@32135
   696
  union  (infixl "\<union>" 65)
haftmann@32081
   697
haftmann@32081
   698
notation (HTML output)
haftmann@32135
   699
  union  (infixl "\<union>" 65)
haftmann@32135
   700
haftmann@32135
   701
lemma Un_def:
haftmann@32135
   702
  "A \<union> B = {x. x \<in> A \<or> x \<in> B}"
haftmann@43818
   703
  by (simp add: sup_fun_def Collect_def mem_def)
haftmann@32081
   704
haftmann@30531
   705
lemma Un_iff [simp]: "(c : A Un B) = (c:A | c:B)"
haftmann@30531
   706
  by (unfold Un_def) blast
haftmann@30531
   707
haftmann@30531
   708
lemma UnI1 [elim?]: "c:A ==> c : A Un B"
haftmann@30531
   709
  by simp
haftmann@30531
   710
haftmann@30531
   711
lemma UnI2 [elim?]: "c:B ==> c : A Un B"
haftmann@30531
   712
  by simp
haftmann@30531
   713
haftmann@30531
   714
text {*
haftmann@30531
   715
  \medskip Classical introduction rule: no commitment to @{prop A} vs
haftmann@30531
   716
  @{prop B}.
wenzelm@11979
   717
*}
wenzelm@11979
   718
haftmann@30531
   719
lemma UnCI [intro!]: "(c~:B ==> c:A) ==> c : A Un B"
haftmann@30531
   720
  by auto
haftmann@30531
   721
haftmann@30531
   722
lemma UnE [elim!]: "c : A Un B ==> (c:A ==> P) ==> (c:B ==> P) ==> P"
haftmann@30531
   723
  by (unfold Un_def) blast
haftmann@30531
   724
haftmann@32117
   725
lemma insert_def: "insert a B = {x. x = a} \<union> B"
haftmann@32081
   726
  by (simp add: Collect_def mem_def insert_compr Un_def)
haftmann@32081
   727
haftmann@32081
   728
lemma mono_Un: "mono f \<Longrightarrow> f A \<union> f B \<subseteq> f (A \<union> B)"
haftmann@32683
   729
  by (fact mono_sup)
haftmann@32081
   730
haftmann@30531
   731
haftmann@30531
   732
subsubsection {* Set difference *}
haftmann@30531
   733
haftmann@30531
   734
lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)"
haftmann@43818
   735
  by (simp add: mem_def fun_diff_def)
haftmann@30531
   736
haftmann@30531
   737
lemma DiffI [intro!]: "c : A ==> c ~: B ==> c : A - B"
haftmann@30531
   738
  by simp
haftmann@30531
   739
haftmann@30531
   740
lemma DiffD1: "c : A - B ==> c : A"
haftmann@30531
   741
  by simp
haftmann@30531
   742
haftmann@30531
   743
lemma DiffD2: "c : A - B ==> c : B ==> P"
haftmann@30531
   744
  by simp
haftmann@30531
   745
haftmann@30531
   746
lemma DiffE [elim!]: "c : A - B ==> (c:A ==> c~:B ==> P) ==> P"
haftmann@30531
   747
  by simp
haftmann@30531
   748
haftmann@30531
   749
lemma set_diff_eq: "A - B = {x. x : A & ~ x : B}" by blast
haftmann@30531
   750
haftmann@30531
   751
lemma Compl_eq_Diff_UNIV: "-A = (UNIV - A)"
haftmann@30531
   752
by blast
haftmann@30531
   753
haftmann@30531
   754
haftmann@31456
   755
subsubsection {* Augmenting a set -- @{const insert} *}
haftmann@30531
   756
haftmann@30531
   757
lemma insert_iff [simp]: "(a : insert b A) = (a = b | a:A)"
haftmann@30531
   758
  by (unfold insert_def) blast
haftmann@30531
   759
haftmann@30531
   760
lemma insertI1: "a : insert a B"
haftmann@30531
   761
  by simp
haftmann@30531
   762
haftmann@30531
   763
lemma insertI2: "a : B ==> a : insert b B"
haftmann@30531
   764
  by simp
haftmann@30531
   765
haftmann@30531
   766
lemma insertE [elim!]: "a : insert b A ==> (a = b ==> P) ==> (a:A ==> P) ==> P"
haftmann@30531
   767
  by (unfold insert_def) blast
haftmann@30531
   768
haftmann@30531
   769
lemma insertCI [intro!]: "(a~:B ==> a = b) ==> a: insert b B"
haftmann@30531
   770
  -- {* Classical introduction rule. *}
haftmann@30531
   771
  by auto
haftmann@30531
   772
haftmann@30531
   773
lemma subset_insert_iff: "(A \<subseteq> insert x B) = (if x:A then A - {x} \<subseteq> B else A \<subseteq> B)"
haftmann@30531
   774
  by auto
haftmann@30531
   775
haftmann@30531
   776
lemma set_insert:
haftmann@30531
   777
  assumes "x \<in> A"
haftmann@30531
   778
  obtains B where "A = insert x B" and "x \<notin> B"
haftmann@30531
   779
proof
haftmann@30531
   780
  from assms show "A = insert x (A - {x})" by blast
haftmann@30531
   781
next
haftmann@30531
   782
  show "x \<notin> A - {x}" by blast
haftmann@30531
   783
qed
haftmann@30531
   784
haftmann@30531
   785
lemma insert_ident: "x ~: A ==> x ~: B ==> (insert x A = insert x B) = (A = B)"
haftmann@30531
   786
by auto
haftmann@30531
   787
nipkow@44744
   788
lemma insert_eq_iff: assumes "a \<notin> A" "b \<notin> B"
nipkow@44744
   789
shows "insert a A = insert b B \<longleftrightarrow>
nipkow@44744
   790
  (if a=b then A=B else \<exists>C. A = insert b C \<and> b \<notin> C \<and> B = insert a C \<and> a \<notin> C)"
nipkow@44744
   791
  (is "?L \<longleftrightarrow> ?R")
nipkow@44744
   792
proof
nipkow@44744
   793
  assume ?L
nipkow@44744
   794
  show ?R
nipkow@44744
   795
  proof cases
nipkow@44744
   796
    assume "a=b" with assms `?L` show ?R by (simp add: insert_ident)
nipkow@44744
   797
  next
nipkow@44744
   798
    assume "a\<noteq>b"
nipkow@44744
   799
    let ?C = "A - {b}"
nipkow@44744
   800
    have "A = insert b ?C \<and> b \<notin> ?C \<and> B = insert a ?C \<and> a \<notin> ?C"
nipkow@44744
   801
      using assms `?L` `a\<noteq>b` by auto
nipkow@44744
   802
    thus ?R using `a\<noteq>b` by auto
nipkow@44744
   803
  qed
nipkow@44744
   804
next
nipkow@44744
   805
  assume ?R thus ?L by(auto split: if_splits)
nipkow@44744
   806
qed
nipkow@44744
   807
haftmann@30531
   808
subsubsection {* Singletons, using insert *}
haftmann@30531
   809
blanchet@35828
   810
lemma singletonI [intro!,no_atp]: "a : {a}"
haftmann@30531
   811
    -- {* Redundant? But unlike @{text insertCI}, it proves the subgoal immediately! *}
haftmann@30531
   812
  by (rule insertI1)
haftmann@30531
   813
blanchet@35828
   814
lemma singletonD [dest!,no_atp]: "b : {a} ==> b = a"
haftmann@30531
   815
  by blast
haftmann@30531
   816
haftmann@30531
   817
lemmas singletonE = singletonD [elim_format]
haftmann@30531
   818
haftmann@30531
   819
lemma singleton_iff: "(b : {a}) = (b = a)"
haftmann@30531
   820
  by blast
haftmann@30531
   821
haftmann@30531
   822
lemma singleton_inject [dest!]: "{a} = {b} ==> a = b"
haftmann@30531
   823
  by blast
haftmann@30531
   824
blanchet@35828
   825
lemma singleton_insert_inj_eq [iff,no_atp]:
haftmann@30531
   826
     "({b} = insert a A) = (a = b & A \<subseteq> {b})"
haftmann@30531
   827
  by blast
haftmann@30531
   828
blanchet@35828
   829
lemma singleton_insert_inj_eq' [iff,no_atp]:
haftmann@30531
   830
     "(insert a A = {b}) = (a = b & A \<subseteq> {b})"
haftmann@30531
   831
  by blast
haftmann@30531
   832
haftmann@30531
   833
lemma subset_singletonD: "A \<subseteq> {x} ==> A = {} | A = {x}"
haftmann@30531
   834
  by fast
haftmann@30531
   835
haftmann@30531
   836
lemma singleton_conv [simp]: "{x. x = a} = {a}"
haftmann@30531
   837
  by blast
haftmann@30531
   838
haftmann@30531
   839
lemma singleton_conv2 [simp]: "{x. a = x} = {a}"
haftmann@30531
   840
  by blast
haftmann@30531
   841
haftmann@30531
   842
lemma diff_single_insert: "A - {x} \<subseteq> B ==> x \<in> A ==> A \<subseteq> insert x B"
haftmann@30531
   843
  by blast
haftmann@30531
   844
haftmann@30531
   845
lemma doubleton_eq_iff: "({a,b} = {c,d}) = (a=c & b=d | a=d & b=c)"
haftmann@30531
   846
  by (blast elim: equalityE)
haftmann@30531
   847
wenzelm@11979
   848
haftmann@32077
   849
subsubsection {* Image of a set under a function *}
haftmann@32077
   850
haftmann@32077
   851
text {*
haftmann@32077
   852
  Frequently @{term b} does not have the syntactic form of @{term "f x"}.
haftmann@32077
   853
*}
haftmann@32077
   854
haftmann@32077
   855
definition image :: "('a => 'b) => 'a set => 'b set" (infixr "`" 90) where
blanchet@35828
   856
  image_def [no_atp]: "f ` A = {y. EX x:A. y = f(x)}"
haftmann@32077
   857
haftmann@32077
   858
abbreviation
haftmann@32077
   859
  range :: "('a => 'b) => 'b set" where -- "of function"
haftmann@32077
   860
  "range f == f ` UNIV"
haftmann@32077
   861
haftmann@32077
   862
lemma image_eqI [simp, intro]: "b = f x ==> x:A ==> b : f`A"
haftmann@32077
   863
  by (unfold image_def) blast
haftmann@32077
   864
haftmann@32077
   865
lemma imageI: "x : A ==> f x : f ` A"
haftmann@32077
   866
  by (rule image_eqI) (rule refl)
haftmann@32077
   867
haftmann@32077
   868
lemma rev_image_eqI: "x:A ==> b = f x ==> b : f`A"
haftmann@32077
   869
  -- {* This version's more effective when we already have the
haftmann@32077
   870
    required @{term x}. *}
haftmann@32077
   871
  by (unfold image_def) blast
haftmann@32077
   872
haftmann@32077
   873
lemma imageE [elim!]:
haftmann@32077
   874
  "b : (%x. f x)`A ==> (!!x. b = f x ==> x:A ==> P) ==> P"
haftmann@32077
   875
  -- {* The eta-expansion gives variable-name preservation. *}
haftmann@32077
   876
  by (unfold image_def) blast
haftmann@32077
   877
haftmann@32077
   878
lemma image_Un: "f`(A Un B) = f`A Un f`B"
haftmann@32077
   879
  by blast
haftmann@32077
   880
haftmann@32077
   881
lemma image_iff: "(z : f`A) = (EX x:A. z = f x)"
haftmann@32077
   882
  by blast
haftmann@32077
   883
blanchet@38648
   884
lemma image_subset_iff [no_atp]: "(f`A \<subseteq> B) = (\<forall>x\<in>A. f x \<in> B)"
haftmann@32077
   885
  -- {* This rewrite rule would confuse users if made default. *}
haftmann@32077
   886
  by blast
haftmann@32077
   887
haftmann@32077
   888
lemma subset_image_iff: "(B \<subseteq> f`A) = (EX AA. AA \<subseteq> A & B = f`AA)"
haftmann@32077
   889
  apply safe
haftmann@32077
   890
   prefer 2 apply fast
haftmann@32077
   891
  apply (rule_tac x = "{a. a : A & f a : B}" in exI, fast)
haftmann@32077
   892
  done
haftmann@32077
   893
haftmann@32077
   894
lemma image_subsetI: "(!!x. x \<in> A ==> f x \<in> B) ==> f`A \<subseteq> B"
haftmann@32077
   895
  -- {* Replaces the three steps @{text subsetI}, @{text imageE},
haftmann@32077
   896
    @{text hypsubst}, but breaks too many existing proofs. *}
haftmann@32077
   897
  by blast
wenzelm@11979
   898
wenzelm@11979
   899
text {*
haftmann@32077
   900
  \medskip Range of a function -- just a translation for image!
haftmann@32077
   901
*}
haftmann@32077
   902
haftmann@43898
   903
lemma image_ident [simp]: "(%x. x) ` Y = Y"
haftmann@43898
   904
  by blast
haftmann@43898
   905
haftmann@32077
   906
lemma range_eqI: "b = f x ==> b \<in> range f"
haftmann@32077
   907
  by simp
haftmann@32077
   908
haftmann@32077
   909
lemma rangeI: "f x \<in> range f"
haftmann@32077
   910
  by simp
haftmann@32077
   911
haftmann@32077
   912
lemma rangeE [elim?]: "b \<in> range (\<lambda>x. f x) ==> (!!x. b = f x ==> P) ==> P"
haftmann@32077
   913
  by blast
haftmann@32077
   914
haftmann@32117
   915
subsubsection {* Some rules with @{text "if"} *}
haftmann@32081
   916
haftmann@32081
   917
text{* Elimination of @{text"{x. \<dots> & x=t & \<dots>}"}. *}
haftmann@32081
   918
haftmann@32081
   919
lemma Collect_conv_if: "{x. x=a & P x} = (if P a then {a} else {})"
haftmann@32117
   920
  by auto
haftmann@32081
   921
haftmann@32081
   922
lemma Collect_conv_if2: "{x. a=x & P x} = (if P a then {a} else {})"
haftmann@32117
   923
  by auto
haftmann@32081
   924
haftmann@32081
   925
text {*
haftmann@32081
   926
  Rewrite rules for boolean case-splitting: faster than @{text
haftmann@32081
   927
  "split_if [split]"}.
haftmann@32081
   928
*}
haftmann@32081
   929
haftmann@32081
   930
lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))"
haftmann@32081
   931
  by (rule split_if)
haftmann@32081
   932
haftmann@32081
   933
lemma split_if_eq2: "(a = (if Q then x else y)) = ((Q --> a = x) & (~ Q --> a = y))"
haftmann@32081
   934
  by (rule split_if)
haftmann@32081
   935
haftmann@32081
   936
text {*
haftmann@32081
   937
  Split ifs on either side of the membership relation.  Not for @{text
haftmann@32081
   938
  "[simp]"} -- can cause goals to blow up!
haftmann@32081
   939
*}
haftmann@32081
   940
haftmann@32081
   941
lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))"
haftmann@32081
   942
  by (rule split_if)
haftmann@32081
   943
haftmann@32081
   944
lemma split_if_mem2: "(a : (if Q then x else y)) = ((Q --> a : x) & (~ Q --> a : y))"
haftmann@32081
   945
  by (rule split_if [where P="%S. a : S"])
haftmann@32081
   946
haftmann@32081
   947
lemmas split_ifs = if_bool_eq_conj split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
haftmann@32081
   948
haftmann@32081
   949
(*Would like to add these, but the existing code only searches for the
haftmann@37677
   950
  outer-level constant, which in this case is just Set.member; we instead need
haftmann@32081
   951
  to use term-nets to associate patterns with rules.  Also, if a rule fails to
haftmann@32081
   952
  apply, then the formula should be kept.
haftmann@34974
   953
  [("uminus", Compl_iff RS iffD1), ("minus", [Diff_iff RS iffD1]),
haftmann@32081
   954
   ("Int", [IntD1,IntD2]),
haftmann@32081
   955
   ("Collect", [CollectD]), ("Inter", [InterD]), ("INTER", [INT_D])]
haftmann@32081
   956
 *)
haftmann@32081
   957
haftmann@32081
   958
haftmann@32135
   959
subsection {* Further operations and lemmas *}
haftmann@32135
   960
haftmann@32135
   961
subsubsection {* The ``proper subset'' relation *}
haftmann@32135
   962
blanchet@35828
   963
lemma psubsetI [intro!,no_atp]: "A \<subseteq> B ==> A \<noteq> B ==> A \<subset> B"
haftmann@32135
   964
  by (unfold less_le) blast
haftmann@32135
   965
blanchet@35828
   966
lemma psubsetE [elim!,no_atp]: 
haftmann@32135
   967
    "[|A \<subset> B;  [|A \<subseteq> B; ~ (B\<subseteq>A)|] ==> R|] ==> R"
haftmann@32135
   968
  by (unfold less_le) blast
haftmann@32135
   969
haftmann@32135
   970
lemma psubset_insert_iff:
haftmann@32135
   971
  "(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)"
haftmann@32135
   972
  by (auto simp add: less_le subset_insert_iff)
haftmann@32135
   973
haftmann@32135
   974
lemma psubset_eq: "(A \<subset> B) = (A \<subseteq> B & A \<noteq> B)"
haftmann@32135
   975
  by (simp only: less_le)
haftmann@32135
   976
haftmann@32135
   977
lemma psubset_imp_subset: "A \<subset> B ==> A \<subseteq> B"
haftmann@32135
   978
  by (simp add: psubset_eq)
haftmann@32135
   979
haftmann@32135
   980
lemma psubset_trans: "[| A \<subset> B; B \<subset> C |] ==> A \<subset> C"
haftmann@32135
   981
apply (unfold less_le)
haftmann@32135
   982
apply (auto dest: subset_antisym)
haftmann@32135
   983
done
haftmann@32135
   984
haftmann@32135
   985
lemma psubsetD: "[| A \<subset> B; c \<in> A |] ==> c \<in> B"
haftmann@32135
   986
apply (unfold less_le)
haftmann@32135
   987
apply (auto dest: subsetD)
haftmann@32135
   988
done
haftmann@32135
   989
haftmann@32135
   990
lemma psubset_subset_trans: "A \<subset> B ==> B \<subseteq> C ==> A \<subset> C"
haftmann@32135
   991
  by (auto simp add: psubset_eq)
haftmann@32135
   992
haftmann@32135
   993
lemma subset_psubset_trans: "A \<subseteq> B ==> B \<subset> C ==> A \<subset> C"
haftmann@32135
   994
  by (auto simp add: psubset_eq)
haftmann@32135
   995
haftmann@32135
   996
lemma psubset_imp_ex_mem: "A \<subset> B ==> \<exists>b. b \<in> (B - A)"
haftmann@32135
   997
  by (unfold less_le) blast
haftmann@32135
   998
haftmann@32135
   999
lemma atomize_ball:
haftmann@32135
  1000
    "(!!x. x \<in> A ==> P x) == Trueprop (\<forall>x\<in>A. P x)"
haftmann@32135
  1001
  by (simp only: Ball_def atomize_all atomize_imp)
haftmann@32135
  1002
haftmann@32135
  1003
lemmas [symmetric, rulify] = atomize_ball
haftmann@32135
  1004
  and [symmetric, defn] = atomize_ball
haftmann@32135
  1005
hoelzl@40703
  1006
lemma image_Pow_mono:
hoelzl@40703
  1007
  assumes "f ` A \<le> B"
hoelzl@40703
  1008
  shows "(image f) ` (Pow A) \<le> Pow B"
hoelzl@40703
  1009
using assms by blast
hoelzl@40703
  1010
hoelzl@40703
  1011
lemma image_Pow_surj:
hoelzl@40703
  1012
  assumes "f ` A = B"
hoelzl@40703
  1013
  shows "(image f) ` (Pow A) = Pow B"
hoelzl@40703
  1014
using assms unfolding Pow_def proof(auto)
hoelzl@40703
  1015
  fix Y assume *: "Y \<le> f ` A"
hoelzl@40703
  1016
  obtain X where X_def: "X = {x \<in> A. f x \<in> Y}" by blast
hoelzl@40703
  1017
  have "f ` X = Y \<and> X \<le> A" unfolding X_def using * by auto
hoelzl@40703
  1018
  thus "Y \<in> (image f) ` {X. X \<le> A}" by blast
hoelzl@40703
  1019
qed
hoelzl@40703
  1020
haftmann@32135
  1021
subsubsection {* Derived rules involving subsets. *}
haftmann@32135
  1022
haftmann@32135
  1023
text {* @{text insert}. *}
haftmann@32135
  1024
haftmann@32135
  1025
lemma subset_insertI: "B \<subseteq> insert a B"
haftmann@32135
  1026
  by (rule subsetI) (erule insertI2)
haftmann@32135
  1027
haftmann@32135
  1028
lemma subset_insertI2: "A \<subseteq> B \<Longrightarrow> A \<subseteq> insert b B"
haftmann@32135
  1029
  by blast
haftmann@32135
  1030
haftmann@32135
  1031
lemma subset_insert: "x \<notin> A ==> (A \<subseteq> insert x B) = (A \<subseteq> B)"
haftmann@32135
  1032
  by blast
haftmann@32135
  1033
haftmann@32135
  1034
haftmann@32135
  1035
text {* \medskip Finite Union -- the least upper bound of two sets. *}
haftmann@32135
  1036
haftmann@32135
  1037
lemma Un_upper1: "A \<subseteq> A \<union> B"
huffman@36009
  1038
  by (fact sup_ge1)
haftmann@32135
  1039
haftmann@32135
  1040
lemma Un_upper2: "B \<subseteq> A \<union> B"
huffman@36009
  1041
  by (fact sup_ge2)
haftmann@32135
  1042
haftmann@32135
  1043
lemma Un_least: "A \<subseteq> C ==> B \<subseteq> C ==> A \<union> B \<subseteq> C"
huffman@36009
  1044
  by (fact sup_least)
haftmann@32135
  1045
haftmann@32135
  1046
haftmann@32135
  1047
text {* \medskip Finite Intersection -- the greatest lower bound of two sets. *}
haftmann@32135
  1048
haftmann@32135
  1049
lemma Int_lower1: "A \<inter> B \<subseteq> A"
huffman@36009
  1050
  by (fact inf_le1)
haftmann@32135
  1051
haftmann@32135
  1052
lemma Int_lower2: "A \<inter> B \<subseteq> B"
huffman@36009
  1053
  by (fact inf_le2)
haftmann@32135
  1054
haftmann@32135
  1055
lemma Int_greatest: "C \<subseteq> A ==> C \<subseteq> B ==> C \<subseteq> A \<inter> B"
huffman@36009
  1056
  by (fact inf_greatest)
haftmann@32135
  1057
haftmann@32135
  1058
haftmann@32135
  1059
text {* \medskip Set difference. *}
haftmann@32135
  1060
haftmann@32135
  1061
lemma Diff_subset: "A - B \<subseteq> A"
haftmann@32135
  1062
  by blast
haftmann@32135
  1063
haftmann@32135
  1064
lemma Diff_subset_conv: "(A - B \<subseteq> C) = (A \<subseteq> B \<union> C)"
haftmann@32135
  1065
by blast
haftmann@32135
  1066
haftmann@32135
  1067
haftmann@32135
  1068
subsubsection {* Equalities involving union, intersection, inclusion, etc. *}
haftmann@32135
  1069
haftmann@32135
  1070
text {* @{text "{}"}. *}
haftmann@32135
  1071
haftmann@32135
  1072
lemma Collect_const [simp]: "{s. P} = (if P then UNIV else {})"
haftmann@32135
  1073
  -- {* supersedes @{text "Collect_False_empty"} *}
haftmann@32135
  1074
  by auto
haftmann@32135
  1075
haftmann@32135
  1076
lemma subset_empty [simp]: "(A \<subseteq> {}) = (A = {})"
huffman@45121
  1077
  by (fact bot_unique)
haftmann@32135
  1078
haftmann@32135
  1079
lemma not_psubset_empty [iff]: "\<not> (A < {})"
huffman@45121
  1080
  by (fact not_less_bot) (* FIXME: already simp *)
haftmann@32135
  1081
haftmann@32135
  1082
lemma Collect_empty_eq [simp]: "(Collect P = {}) = (\<forall>x. \<not> P x)"
haftmann@32135
  1083
by blast
haftmann@32135
  1084
haftmann@32135
  1085
lemma empty_Collect_eq [simp]: "({} = Collect P) = (\<forall>x. \<not> P x)"
haftmann@32135
  1086
by blast
haftmann@32135
  1087
haftmann@32135
  1088
lemma Collect_neg_eq: "{x. \<not> P x} = - {x. P x}"
haftmann@32135
  1089
  by blast
haftmann@32135
  1090
haftmann@32135
  1091
lemma Collect_disj_eq: "{x. P x | Q x} = {x. P x} \<union> {x. Q x}"
haftmann@32135
  1092
  by blast
haftmann@32135
  1093
haftmann@32135
  1094
lemma Collect_imp_eq: "{x. P x --> Q x} = -{x. P x} \<union> {x. Q x}"
haftmann@32135
  1095
  by blast
haftmann@32135
  1096
haftmann@32135
  1097
lemma Collect_conj_eq: "{x. P x & Q x} = {x. P x} \<inter> {x. Q x}"
haftmann@32135
  1098
  by blast
haftmann@32135
  1099
haftmann@32135
  1100
haftmann@32135
  1101
text {* \medskip @{text insert}. *}
haftmann@32135
  1102
haftmann@32135
  1103
lemma insert_is_Un: "insert a A = {a} Un A"
haftmann@32135
  1104
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a {}"} *}
haftmann@32135
  1105
  by blast
haftmann@32135
  1106
haftmann@32135
  1107
lemma insert_not_empty [simp]: "insert a A \<noteq> {}"
haftmann@32135
  1108
  by blast
haftmann@32135
  1109
haftmann@32135
  1110
lemmas empty_not_insert = insert_not_empty [symmetric, standard]
haftmann@32135
  1111
declare empty_not_insert [simp]
haftmann@32135
  1112
haftmann@32135
  1113
lemma insert_absorb: "a \<in> A ==> insert a A = A"
haftmann@32135
  1114
  -- {* @{text "[simp]"} causes recursive calls when there are nested inserts *}
haftmann@32135
  1115
  -- {* with \emph{quadratic} running time *}
haftmann@32135
  1116
  by blast
haftmann@32135
  1117
haftmann@32135
  1118
lemma insert_absorb2 [simp]: "insert x (insert x A) = insert x A"
haftmann@32135
  1119
  by blast
haftmann@32135
  1120
haftmann@32135
  1121
lemma insert_commute: "insert x (insert y A) = insert y (insert x A)"
haftmann@32135
  1122
  by blast
haftmann@32135
  1123
haftmann@32135
  1124
lemma insert_subset [simp]: "(insert x A \<subseteq> B) = (x \<in> B & A \<subseteq> B)"
haftmann@32135
  1125
  by blast
haftmann@32135
  1126
haftmann@32135
  1127
lemma mk_disjoint_insert: "a \<in> A ==> \<exists>B. A = insert a B & a \<notin> B"
haftmann@32135
  1128
  -- {* use new @{text B} rather than @{text "A - {a}"} to avoid infinite unfolding *}
haftmann@32135
  1129
  apply (rule_tac x = "A - {a}" in exI, blast)
haftmann@32135
  1130
  done
haftmann@32135
  1131
haftmann@32135
  1132
lemma insert_Collect: "insert a (Collect P) = {u. u \<noteq> a --> P u}"
haftmann@32135
  1133
  by auto
haftmann@32135
  1134
haftmann@32135
  1135
lemma insert_inter_insert[simp]: "insert a A \<inter> insert a B = insert a (A \<inter> B)"
haftmann@32135
  1136
  by blast
haftmann@32135
  1137
blanchet@35828
  1138
lemma insert_disjoint [simp,no_atp]:
haftmann@32135
  1139
 "(insert a A \<inter> B = {}) = (a \<notin> B \<and> A \<inter> B = {})"
haftmann@32135
  1140
 "({} = insert a A \<inter> B) = (a \<notin> B \<and> {} = A \<inter> B)"
haftmann@32135
  1141
  by auto
haftmann@32135
  1142
blanchet@35828
  1143
lemma disjoint_insert [simp,no_atp]:
haftmann@32135
  1144
 "(B \<inter> insert a A = {}) = (a \<notin> B \<and> B \<inter> A = {})"
haftmann@32135
  1145
 "({} = A \<inter> insert b B) = (b \<notin> A \<and> {} = A \<inter> B)"
haftmann@32135
  1146
  by auto
haftmann@32135
  1147
haftmann@32135
  1148
text {* \medskip @{text image}. *}
haftmann@32135
  1149
haftmann@32135
  1150
lemma image_empty [simp]: "f`{} = {}"
haftmann@32135
  1151
  by blast
haftmann@32135
  1152
haftmann@32135
  1153
lemma image_insert [simp]: "f ` insert a B = insert (f a) (f`B)"
haftmann@32135
  1154
  by blast
haftmann@32135
  1155
haftmann@32135
  1156
lemma image_constant: "x \<in> A ==> (\<lambda>x. c) ` A = {c}"
haftmann@32135
  1157
  by auto
haftmann@32135
  1158
haftmann@32135
  1159
lemma image_constant_conv: "(%x. c) ` A = (if A = {} then {} else {c})"
haftmann@32135
  1160
by auto
haftmann@32135
  1161
haftmann@32135
  1162
lemma image_image: "f ` (g ` A) = (\<lambda>x. f (g x)) ` A"
haftmann@32135
  1163
by blast
haftmann@32135
  1164
haftmann@32135
  1165
lemma insert_image [simp]: "x \<in> A ==> insert (f x) (f`A) = f`A"
haftmann@32135
  1166
by blast
haftmann@32135
  1167
haftmann@32135
  1168
lemma image_is_empty [iff]: "(f`A = {}) = (A = {})"
haftmann@32135
  1169
by blast
haftmann@32135
  1170
haftmann@32135
  1171
lemma empty_is_image[iff]: "({} = f ` A) = (A = {})"
haftmann@32135
  1172
by blast
haftmann@32135
  1173
haftmann@32135
  1174
blanchet@35828
  1175
lemma image_Collect [no_atp]: "f ` {x. P x} = {f x | x. P x}"
haftmann@32135
  1176
  -- {* NOT suitable as a default simprule: the RHS isn't simpler than the LHS,
haftmann@32135
  1177
      with its implicit quantifier and conjunction.  Also image enjoys better
haftmann@32135
  1178
      equational properties than does the RHS. *}
haftmann@32135
  1179
  by blast
haftmann@32135
  1180
haftmann@32135
  1181
lemma if_image_distrib [simp]:
haftmann@32135
  1182
  "(\<lambda>x. if P x then f x else g x) ` S
haftmann@32135
  1183
    = (f ` (S \<inter> {x. P x})) \<union> (g ` (S \<inter> {x. \<not> P x}))"
haftmann@32135
  1184
  by (auto simp add: image_def)
haftmann@32135
  1185
haftmann@32135
  1186
lemma image_cong: "M = N ==> (!!x. x \<in> N ==> f x = g x) ==> f`M = g`N"
haftmann@32135
  1187
  by (simp add: image_def)
haftmann@32135
  1188
haftmann@43898
  1189
lemma image_Int_subset: "f`(A Int B) <= f`A Int f`B"
haftmann@43898
  1190
by blast
haftmann@43898
  1191
haftmann@43898
  1192
lemma image_diff_subset: "f`A - f`B <= f`(A - B)"
haftmann@43898
  1193
by blast
haftmann@43898
  1194
haftmann@32135
  1195
haftmann@32135
  1196
text {* \medskip @{text range}. *}
haftmann@32135
  1197
blanchet@35828
  1198
lemma full_SetCompr_eq [no_atp]: "{u. \<exists>x. u = f x} = range f"
haftmann@32135
  1199
  by auto
haftmann@32135
  1200
haftmann@32135
  1201
lemma range_composition: "range (\<lambda>x. f (g x)) = f`range g"
haftmann@32135
  1202
by (subst image_image, simp)
haftmann@32135
  1203
haftmann@32135
  1204
haftmann@32135
  1205
text {* \medskip @{text Int} *}
haftmann@32135
  1206
huffman@45121
  1207
lemma Int_absorb: "A \<inter> A = A"
huffman@45121
  1208
  by (fact inf_idem) (* already simp *)
haftmann@32135
  1209
haftmann@32135
  1210
lemma Int_left_absorb: "A \<inter> (A \<inter> B) = A \<inter> B"
huffman@36009
  1211
  by (fact inf_left_idem)
haftmann@32135
  1212
haftmann@32135
  1213
lemma Int_commute: "A \<inter> B = B \<inter> A"
huffman@36009
  1214
  by (fact inf_commute)
haftmann@32135
  1215
haftmann@32135
  1216
lemma Int_left_commute: "A \<inter> (B \<inter> C) = B \<inter> (A \<inter> C)"
huffman@36009
  1217
  by (fact inf_left_commute)
haftmann@32135
  1218
haftmann@32135
  1219
lemma Int_assoc: "(A \<inter> B) \<inter> C = A \<inter> (B \<inter> C)"
huffman@36009
  1220
  by (fact inf_assoc)
haftmann@32135
  1221
haftmann@32135
  1222
lemmas Int_ac = Int_assoc Int_left_absorb Int_commute Int_left_commute
haftmann@32135
  1223
  -- {* Intersection is an AC-operator *}
haftmann@32135
  1224
haftmann@32135
  1225
lemma Int_absorb1: "B \<subseteq> A ==> A \<inter> B = B"
huffman@36009
  1226
  by (fact inf_absorb2)
haftmann@32135
  1227
haftmann@32135
  1228
lemma Int_absorb2: "A \<subseteq> B ==> A \<inter> B = A"
huffman@36009
  1229
  by (fact inf_absorb1)
haftmann@32135
  1230
huffman@45121
  1231
lemma Int_empty_left: "{} \<inter> B = {}"
huffman@45121
  1232
  by (fact inf_bot_left) (* already simp *)
haftmann@32135
  1233
huffman@45121
  1234
lemma Int_empty_right: "A \<inter> {} = {}"
huffman@45121
  1235
  by (fact inf_bot_right) (* already simp *)
haftmann@32135
  1236
haftmann@32135
  1237
lemma disjoint_eq_subset_Compl: "(A \<inter> B = {}) = (A \<subseteq> -B)"
haftmann@32135
  1238
  by blast
haftmann@32135
  1239
haftmann@32135
  1240
lemma disjoint_iff_not_equal: "(A \<inter> B = {}) = (\<forall>x\<in>A. \<forall>y\<in>B. x \<noteq> y)"
haftmann@32135
  1241
  by blast
haftmann@32135
  1242
huffman@45121
  1243
lemma Int_UNIV_left: "UNIV \<inter> B = B"
huffman@45121
  1244
  by (fact inf_top_left) (* already simp *)
haftmann@32135
  1245
huffman@45121
  1246
lemma Int_UNIV_right: "A \<inter> UNIV = A"
huffman@45121
  1247
  by (fact inf_top_right) (* already simp *)
haftmann@32135
  1248
haftmann@32135
  1249
lemma Int_Un_distrib: "A \<inter> (B \<union> C) = (A \<inter> B) \<union> (A \<inter> C)"
huffman@36009
  1250
  by (fact inf_sup_distrib1)
haftmann@32135
  1251
haftmann@32135
  1252
lemma Int_Un_distrib2: "(B \<union> C) \<inter> A = (B \<inter> A) \<union> (C \<inter> A)"
huffman@36009
  1253
  by (fact inf_sup_distrib2)
haftmann@32135
  1254
blanchet@35828
  1255
lemma Int_UNIV [simp,no_atp]: "(A \<inter> B = UNIV) = (A = UNIV & B = UNIV)"
huffman@45121
  1256
  by (fact inf_eq_top_iff) (* already simp *)
haftmann@32135
  1257
blanchet@38648
  1258
lemma Int_subset_iff [no_atp, simp]: "(C \<subseteq> A \<inter> B) = (C \<subseteq> A & C \<subseteq> B)"
huffman@36009
  1259
  by (fact le_inf_iff)
haftmann@32135
  1260
haftmann@32135
  1261
lemma Int_Collect: "(x \<in> A \<inter> {x. P x}) = (x \<in> A & P x)"
haftmann@32135
  1262
  by blast
haftmann@32135
  1263
haftmann@32135
  1264
haftmann@32135
  1265
text {* \medskip @{text Un}. *}
haftmann@32135
  1266
huffman@45121
  1267
lemma Un_absorb: "A \<union> A = A"
huffman@45121
  1268
  by (fact sup_idem) (* already simp *)
haftmann@32135
  1269
haftmann@32135
  1270
lemma Un_left_absorb: "A \<union> (A \<union> B) = A \<union> B"
huffman@36009
  1271
  by (fact sup_left_idem)
haftmann@32135
  1272
haftmann@32135
  1273
lemma Un_commute: "A \<union> B = B \<union> A"
huffman@36009
  1274
  by (fact sup_commute)
haftmann@32135
  1275
haftmann@32135
  1276
lemma Un_left_commute: "A \<union> (B \<union> C) = B \<union> (A \<union> C)"
huffman@36009
  1277
  by (fact sup_left_commute)
haftmann@32135
  1278
haftmann@32135
  1279
lemma Un_assoc: "(A \<union> B) \<union> C = A \<union> (B \<union> C)"
huffman@36009
  1280
  by (fact sup_assoc)
haftmann@32135
  1281
haftmann@32135
  1282
lemmas Un_ac = Un_assoc Un_left_absorb Un_commute Un_left_commute
haftmann@32135
  1283
  -- {* Union is an AC-operator *}
haftmann@32135
  1284
haftmann@32135
  1285
lemma Un_absorb1: "A \<subseteq> B ==> A \<union> B = B"
huffman@36009
  1286
  by (fact sup_absorb2)
haftmann@32135
  1287
haftmann@32135
  1288
lemma Un_absorb2: "B \<subseteq> A ==> A \<union> B = A"
huffman@36009
  1289
  by (fact sup_absorb1)
haftmann@32135
  1290
huffman@45121
  1291
lemma Un_empty_left: "{} \<union> B = B"
huffman@45121
  1292
  by (fact sup_bot_left) (* already simp *)
haftmann@32135
  1293
huffman@45121
  1294
lemma Un_empty_right: "A \<union> {} = A"
huffman@45121
  1295
  by (fact sup_bot_right) (* already simp *)
haftmann@32135
  1296
huffman@45121
  1297
lemma Un_UNIV_left: "UNIV \<union> B = UNIV"
huffman@45121
  1298
  by (fact sup_top_left) (* already simp *)
haftmann@32135
  1299
huffman@45121
  1300
lemma Un_UNIV_right: "A \<union> UNIV = UNIV"
huffman@45121
  1301
  by (fact sup_top_right) (* already simp *)
haftmann@32135
  1302
haftmann@32135
  1303
lemma Un_insert_left [simp]: "(insert a B) \<union> C = insert a (B \<union> C)"
haftmann@32135
  1304
  by blast
haftmann@32135
  1305
haftmann@32135
  1306
lemma Un_insert_right [simp]: "A \<union> (insert a B) = insert a (A \<union> B)"
haftmann@32135
  1307
  by blast
haftmann@32135
  1308
haftmann@32135
  1309
lemma Int_insert_left:
haftmann@32135
  1310
    "(insert a B) Int C = (if a \<in> C then insert a (B \<inter> C) else B \<inter> C)"
haftmann@32135
  1311
  by auto
haftmann@32135
  1312
nipkow@32456
  1313
lemma Int_insert_left_if0[simp]:
nipkow@32456
  1314
    "a \<notin> C \<Longrightarrow> (insert a B) Int C = B \<inter> C"
nipkow@32456
  1315
  by auto
nipkow@32456
  1316
nipkow@32456
  1317
lemma Int_insert_left_if1[simp]:
nipkow@32456
  1318
    "a \<in> C \<Longrightarrow> (insert a B) Int C = insert a (B Int C)"
nipkow@32456
  1319
  by auto
nipkow@32456
  1320
haftmann@32135
  1321
lemma Int_insert_right:
haftmann@32135
  1322
    "A \<inter> (insert a B) = (if a \<in> A then insert a (A \<inter> B) else A \<inter> B)"
haftmann@32135
  1323
  by auto
haftmann@32135
  1324
nipkow@32456
  1325
lemma Int_insert_right_if0[simp]:
nipkow@32456
  1326
    "a \<notin> A \<Longrightarrow> A Int (insert a B) = A Int B"
nipkow@32456
  1327
  by auto
nipkow@32456
  1328
nipkow@32456
  1329
lemma Int_insert_right_if1[simp]:
nipkow@32456
  1330
    "a \<in> A \<Longrightarrow> A Int (insert a B) = insert a (A Int B)"
nipkow@32456
  1331
  by auto
nipkow@32456
  1332
haftmann@32135
  1333
lemma Un_Int_distrib: "A \<union> (B \<inter> C) = (A \<union> B) \<inter> (A \<union> C)"
huffman@36009
  1334
  by (fact sup_inf_distrib1)
haftmann@32135
  1335
haftmann@32135
  1336
lemma Un_Int_distrib2: "(B \<inter> C) \<union> A = (B \<union> A) \<inter> (C \<union> A)"
huffman@36009
  1337
  by (fact sup_inf_distrib2)
haftmann@32135
  1338
haftmann@32135
  1339
lemma Un_Int_crazy:
haftmann@32135
  1340
    "(A \<inter> B) \<union> (B \<inter> C) \<union> (C \<inter> A) = (A \<union> B) \<inter> (B \<union> C) \<inter> (C \<union> A)"
haftmann@32135
  1341
  by blast
haftmann@32135
  1342
haftmann@32135
  1343
lemma subset_Un_eq: "(A \<subseteq> B) = (A \<union> B = B)"
huffman@36009
  1344
  by (fact le_iff_sup)
haftmann@32135
  1345
haftmann@32135
  1346
lemma Un_empty [iff]: "(A \<union> B = {}) = (A = {} & B = {})"
huffman@45121
  1347
  by (fact sup_eq_bot_iff) (* FIXME: already simp *)
haftmann@32135
  1348
blanchet@38648
  1349
lemma Un_subset_iff [no_atp, simp]: "(A \<union> B \<subseteq> C) = (A \<subseteq> C & B \<subseteq> C)"
huffman@36009
  1350
  by (fact le_sup_iff)
haftmann@32135
  1351
haftmann@32135
  1352
lemma Un_Diff_Int: "(A - B) \<union> (A \<inter> B) = A"
haftmann@32135
  1353
  by blast
haftmann@32135
  1354
haftmann@32135
  1355
lemma Diff_Int2: "A \<inter> C - B \<inter> C = A \<inter> C - B"
haftmann@32135
  1356
  by blast
haftmann@32135
  1357
haftmann@32135
  1358
haftmann@32135
  1359
text {* \medskip Set complement *}
haftmann@32135
  1360
haftmann@32135
  1361
lemma Compl_disjoint [simp]: "A \<inter> -A = {}"
huffman@36009
  1362
  by (fact inf_compl_bot)
haftmann@32135
  1363
haftmann@32135
  1364
lemma Compl_disjoint2 [simp]: "-A \<inter> A = {}"
huffman@36009
  1365
  by (fact compl_inf_bot)
haftmann@32135
  1366
haftmann@32135
  1367
lemma Compl_partition: "A \<union> -A = UNIV"
huffman@36009
  1368
  by (fact sup_compl_top)
haftmann@32135
  1369
haftmann@32135
  1370
lemma Compl_partition2: "-A \<union> A = UNIV"
huffman@36009
  1371
  by (fact compl_sup_top)
haftmann@32135
  1372
huffman@45121
  1373
lemma double_complement: "- (-A) = (A::'a set)"
huffman@45121
  1374
  by (fact double_compl) (* already simp *)
haftmann@32135
  1375
huffman@45121
  1376
lemma Compl_Un: "-(A \<union> B) = (-A) \<inter> (-B)"
huffman@45121
  1377
  by (fact compl_sup) (* already simp *)
haftmann@32135
  1378
huffman@45121
  1379
lemma Compl_Int: "-(A \<inter> B) = (-A) \<union> (-B)"
huffman@45121
  1380
  by (fact compl_inf) (* already simp *)
haftmann@32135
  1381
haftmann@32135
  1382
lemma subset_Compl_self_eq: "(A \<subseteq> -A) = (A = {})"
haftmann@32135
  1383
  by blast
haftmann@32135
  1384
haftmann@32135
  1385
lemma Un_Int_assoc_eq: "((A \<inter> B) \<union> C = A \<inter> (B \<union> C)) = (C \<subseteq> A)"
haftmann@32135
  1386
  -- {* Halmos, Naive Set Theory, page 16. *}
haftmann@32135
  1387
  by blast
haftmann@32135
  1388
huffman@45121
  1389
lemma Compl_UNIV_eq: "-UNIV = {}"
huffman@45121
  1390
  by (fact compl_top_eq) (* already simp *)
haftmann@32135
  1391
huffman@45121
  1392
lemma Compl_empty_eq: "-{} = UNIV"
huffman@45121
  1393
  by (fact compl_bot_eq) (* already simp *)
haftmann@32135
  1394
haftmann@32135
  1395
lemma Compl_subset_Compl_iff [iff]: "(-A \<subseteq> -B) = (B \<subseteq> A)"
huffman@45121
  1396
  by (fact compl_le_compl_iff) (* FIXME: already simp *)
haftmann@32135
  1397
haftmann@32135
  1398
lemma Compl_eq_Compl_iff [iff]: "(-A = -B) = (A = (B::'a set))"
huffman@45121
  1399
  by (fact compl_eq_compl_iff) (* FIXME: already simp *)
haftmann@32135
  1400
krauss@44490
  1401
lemma Compl_insert: "- insert x A = (-A) - {x}"
krauss@44490
  1402
  by blast
krauss@44490
  1403
haftmann@32135
  1404
text {* \medskip Bounded quantifiers.
haftmann@32135
  1405
haftmann@32135
  1406
  The following are not added to the default simpset because
haftmann@32135
  1407
  (a) they duplicate the body and (b) there are no similar rules for @{text Int}. *}
haftmann@32135
  1408
haftmann@32135
  1409
lemma ball_Un: "(\<forall>x \<in> A \<union> B. P x) = ((\<forall>x\<in>A. P x) & (\<forall>x\<in>B. P x))"
haftmann@32135
  1410
  by blast
haftmann@32135
  1411
haftmann@32135
  1412
lemma bex_Un: "(\<exists>x \<in> A \<union> B. P x) = ((\<exists>x\<in>A. P x) | (\<exists>x\<in>B. P x))"
haftmann@32135
  1413
  by blast
haftmann@32135
  1414
haftmann@32135
  1415
haftmann@32135
  1416
text {* \medskip Set difference. *}
haftmann@32135
  1417
haftmann@32135
  1418
lemma Diff_eq: "A - B = A \<inter> (-B)"
haftmann@32135
  1419
  by blast
haftmann@32135
  1420
blanchet@35828
  1421
lemma Diff_eq_empty_iff [simp,no_atp]: "(A - B = {}) = (A \<subseteq> B)"
haftmann@32135
  1422
  by blast
haftmann@32135
  1423
haftmann@32135
  1424
lemma Diff_cancel [simp]: "A - A = {}"
haftmann@32135
  1425
  by blast
haftmann@32135
  1426
haftmann@32135
  1427
lemma Diff_idemp [simp]: "(A - B) - B = A - (B::'a set)"
haftmann@32135
  1428
by blast
haftmann@32135
  1429
haftmann@32135
  1430
lemma Diff_triv: "A \<inter> B = {} ==> A - B = A"
haftmann@32135
  1431
  by (blast elim: equalityE)
haftmann@32135
  1432
haftmann@32135
  1433
lemma empty_Diff [simp]: "{} - A = {}"
haftmann@32135
  1434
  by blast
haftmann@32135
  1435
haftmann@32135
  1436
lemma Diff_empty [simp]: "A - {} = A"
haftmann@32135
  1437
  by blast
haftmann@32135
  1438
haftmann@32135
  1439
lemma Diff_UNIV [simp]: "A - UNIV = {}"
haftmann@32135
  1440
  by blast
haftmann@32135
  1441
blanchet@35828
  1442
lemma Diff_insert0 [simp,no_atp]: "x \<notin> A ==> A - insert x B = A - B"
haftmann@32135
  1443
  by blast
haftmann@32135
  1444
haftmann@32135
  1445
lemma Diff_insert: "A - insert a B = A - B - {a}"
haftmann@32135
  1446
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
haftmann@32135
  1447
  by blast
haftmann@32135
  1448
haftmann@32135
  1449
lemma Diff_insert2: "A - insert a B = A - {a} - B"
haftmann@32135
  1450
  -- {* NOT SUITABLE FOR REWRITING since @{text "{a} == insert a 0"} *}
haftmann@32135
  1451
  by blast
haftmann@32135
  1452
haftmann@32135
  1453
lemma insert_Diff_if: "insert x A - B = (if x \<in> B then A - B else insert x (A - B))"
haftmann@32135
  1454
  by auto
haftmann@32135
  1455
haftmann@32135
  1456
lemma insert_Diff1 [simp]: "x \<in> B ==> insert x A - B = A - B"
haftmann@32135
  1457
  by blast
haftmann@32135
  1458
haftmann@32135
  1459
lemma insert_Diff_single[simp]: "insert a (A - {a}) = insert a A"
haftmann@32135
  1460
by blast
haftmann@32135
  1461
haftmann@32135
  1462
lemma insert_Diff: "a \<in> A ==> insert a (A - {a}) = A"
haftmann@32135
  1463
  by blast
haftmann@32135
  1464
haftmann@32135
  1465
lemma Diff_insert_absorb: "x \<notin> A ==> (insert x A) - {x} = A"
haftmann@32135
  1466
  by auto
haftmann@32135
  1467
haftmann@32135
  1468
lemma Diff_disjoint [simp]: "A \<inter> (B - A) = {}"
haftmann@32135
  1469
  by blast
haftmann@32135
  1470
haftmann@32135
  1471
lemma Diff_partition: "A \<subseteq> B ==> A \<union> (B - A) = B"
haftmann@32135
  1472
  by blast
haftmann@32135
  1473
haftmann@32135
  1474
lemma double_diff: "A \<subseteq> B ==> B \<subseteq> C ==> B - (C - A) = A"
haftmann@32135
  1475
  by blast
haftmann@32135
  1476
haftmann@32135
  1477
lemma Un_Diff_cancel [simp]: "A \<union> (B - A) = A \<union> B"
haftmann@32135
  1478
  by blast
haftmann@32135
  1479
haftmann@32135
  1480
lemma Un_Diff_cancel2 [simp]: "(B - A) \<union> A = B \<union> A"
haftmann@32135
  1481
  by blast
haftmann@32135
  1482
haftmann@32135
  1483
lemma Diff_Un: "A - (B \<union> C) = (A - B) \<inter> (A - C)"
haftmann@32135
  1484
  by blast
haftmann@32135
  1485
haftmann@32135
  1486
lemma Diff_Int: "A - (B \<inter> C) = (A - B) \<union> (A - C)"
haftmann@32135
  1487
  by blast
haftmann@32135
  1488
haftmann@32135
  1489
lemma Un_Diff: "(A \<union> B) - C = (A - C) \<union> (B - C)"
haftmann@32135
  1490
  by blast
haftmann@32135
  1491
haftmann@32135
  1492
lemma Int_Diff: "(A \<inter> B) - C = A \<inter> (B - C)"
haftmann@32135
  1493
  by blast
haftmann@32135
  1494
haftmann@32135
  1495
lemma Diff_Int_distrib: "C \<inter> (A - B) = (C \<inter> A) - (C \<inter> B)"
haftmann@32135
  1496
  by blast
haftmann@32135
  1497
haftmann@32135
  1498
lemma Diff_Int_distrib2: "(A - B) \<inter> C = (A \<inter> C) - (B \<inter> C)"
haftmann@32135
  1499
  by blast
haftmann@32135
  1500
haftmann@32135
  1501
lemma Diff_Compl [simp]: "A - (- B) = A \<inter> B"
haftmann@32135
  1502
  by auto
haftmann@32135
  1503
haftmann@32135
  1504
lemma Compl_Diff_eq [simp]: "- (A - B) = -A \<union> B"
haftmann@32135
  1505
  by blast
haftmann@32135
  1506
haftmann@32135
  1507
haftmann@32135
  1508
text {* \medskip Quantification over type @{typ bool}. *}
haftmann@32135
  1509
haftmann@32135
  1510
lemma bool_induct: "P True \<Longrightarrow> P False \<Longrightarrow> P x"
haftmann@32135
  1511
  by (cases x) auto
haftmann@32135
  1512
haftmann@32135
  1513
lemma all_bool_eq: "(\<forall>b. P b) \<longleftrightarrow> P True \<and> P False"
haftmann@32135
  1514
  by (auto intro: bool_induct)
haftmann@32135
  1515
haftmann@32135
  1516
lemma bool_contrapos: "P x \<Longrightarrow> \<not> P False \<Longrightarrow> P True"
haftmann@32135
  1517
  by (cases x) auto
haftmann@32135
  1518
haftmann@32135
  1519
lemma ex_bool_eq: "(\<exists>b. P b) \<longleftrightarrow> P True \<or> P False"
haftmann@32135
  1520
  by (auto intro: bool_contrapos)
haftmann@32135
  1521
haftmann@43866
  1522
lemma UNIV_bool [no_atp]: "UNIV = {False, True}"
haftmann@43866
  1523
  by (auto intro: bool_induct)
haftmann@43866
  1524
haftmann@32135
  1525
text {* \medskip @{text Pow} *}
haftmann@32135
  1526
haftmann@32135
  1527
lemma Pow_empty [simp]: "Pow {} = {{}}"
haftmann@32135
  1528
  by (auto simp add: Pow_def)
haftmann@32135
  1529
haftmann@32135
  1530
lemma Pow_insert: "Pow (insert a A) = Pow A \<union> (insert a ` Pow A)"
haftmann@32135
  1531
  by (blast intro: image_eqI [where ?x = "u - {a}", standard])
haftmann@32135
  1532
haftmann@32135
  1533
lemma Pow_Compl: "Pow (- A) = {-B | B. A \<in> Pow B}"
haftmann@32135
  1534
  by (blast intro: exI [where ?x = "- u", standard])
haftmann@32135
  1535
haftmann@32135
  1536
lemma Pow_UNIV [simp]: "Pow UNIV = UNIV"
haftmann@32135
  1537
  by blast
haftmann@32135
  1538
haftmann@32135
  1539
lemma Un_Pow_subset: "Pow A \<union> Pow B \<subseteq> Pow (A \<union> B)"
haftmann@32135
  1540
  by blast
haftmann@32135
  1541
haftmann@32135
  1542
lemma Pow_Int_eq [simp]: "Pow (A \<inter> B) = Pow A \<inter> Pow B"
haftmann@32135
  1543
  by blast
haftmann@32135
  1544
haftmann@32135
  1545
haftmann@32135
  1546
text {* \medskip Miscellany. *}
haftmann@32135
  1547
haftmann@32135
  1548
lemma set_eq_subset: "(A = B) = (A \<subseteq> B & B \<subseteq> A)"
haftmann@32135
  1549
  by blast
haftmann@32135
  1550
blanchet@38648
  1551
lemma subset_iff [no_atp]: "(A \<subseteq> B) = (\<forall>t. t \<in> A --> t \<in> B)"
haftmann@32135
  1552
  by blast
haftmann@32135
  1553
haftmann@32135
  1554
lemma subset_iff_psubset_eq: "(A \<subseteq> B) = ((A \<subset> B) | (A = B))"
haftmann@32135
  1555
  by (unfold less_le) blast
haftmann@32135
  1556
haftmann@32135
  1557
lemma all_not_in_conv [simp]: "(\<forall>x. x \<notin> A) = (A = {})"
haftmann@32135
  1558
  by blast
haftmann@32135
  1559
haftmann@32135
  1560
lemma ex_in_conv: "(\<exists>x. x \<in> A) = (A \<noteq> {})"
haftmann@32135
  1561
  by blast
haftmann@32135
  1562
haftmann@32135
  1563
lemma distinct_lemma: "f x \<noteq> f y ==> x \<noteq> y"
haftmann@32135
  1564
  by iprover
haftmann@32135
  1565
haftmann@43967
  1566
lemma ball_simps [simp, no_atp]:
haftmann@43967
  1567
  "\<And>A P Q. (\<forall>x\<in>A. P x \<or> Q) \<longleftrightarrow> ((\<forall>x\<in>A. P x) \<or> Q)"
haftmann@43967
  1568
  "\<And>A P Q. (\<forall>x\<in>A. P \<or> Q x) \<longleftrightarrow> (P \<or> (\<forall>x\<in>A. Q x))"
haftmann@43967
  1569
  "\<And>A P Q. (\<forall>x\<in>A. P \<longrightarrow> Q x) \<longleftrightarrow> (P \<longrightarrow> (\<forall>x\<in>A. Q x))"
haftmann@43967
  1570
  "\<And>A P Q. (\<forall>x\<in>A. P x \<longrightarrow> Q) \<longleftrightarrow> ((\<exists>x\<in>A. P x) \<longrightarrow> Q)"
haftmann@43967
  1571
  "\<And>P. (\<forall>x\<in>{}. P x) \<longleftrightarrow> True"
haftmann@43967
  1572
  "\<And>P. (\<forall>x\<in>UNIV. P x) \<longleftrightarrow> (\<forall>x. P x)"
haftmann@43967
  1573
  "\<And>a B P. (\<forall>x\<in>insert a B. P x) \<longleftrightarrow> (P a \<and> (\<forall>x\<in>B. P x))"
haftmann@43967
  1574
  "\<And>P Q. (\<forall>x\<in>Collect Q. P x) \<longleftrightarrow> (\<forall>x. Q x \<longrightarrow> P x)"
haftmann@43967
  1575
  "\<And>A P f. (\<forall>x\<in>f`A. P x) \<longleftrightarrow> (\<forall>x\<in>A. P (f x))"
haftmann@43967
  1576
  "\<And>A P. (\<not> (\<forall>x\<in>A. P x)) \<longleftrightarrow> (\<exists>x\<in>A. \<not> P x)"
haftmann@43967
  1577
  by auto
haftmann@43967
  1578
haftmann@43967
  1579
lemma bex_simps [simp, no_atp]:
haftmann@43967
  1580
  "\<And>A P Q. (\<exists>x\<in>A. P x \<and> Q) \<longleftrightarrow> ((\<exists>x\<in>A. P x) \<and> Q)"
haftmann@43967
  1581
  "\<And>A P Q. (\<exists>x\<in>A. P \<and> Q x) \<longleftrightarrow> (P \<and> (\<exists>x\<in>A. Q x))"
haftmann@43967
  1582
  "\<And>P. (\<exists>x\<in>{}. P x) \<longleftrightarrow> False"
haftmann@43967
  1583
  "\<And>P. (\<exists>x\<in>UNIV. P x) \<longleftrightarrow> (\<exists>x. P x)"
haftmann@43967
  1584
  "\<And>a B P. (\<exists>x\<in>insert a B. P x) \<longleftrightarrow> (P a | (\<exists>x\<in>B. P x))"
haftmann@43967
  1585
  "\<And>P Q. (\<exists>x\<in>Collect Q. P x) \<longleftrightarrow> (\<exists>x. Q x \<and> P x)"
haftmann@43967
  1586
  "\<And>A P f. (\<exists>x\<in>f`A. P x) \<longleftrightarrow> (\<exists>x\<in>A. P (f x))"
haftmann@43967
  1587
  "\<And>A P. (\<not>(\<exists>x\<in>A. P x)) \<longleftrightarrow> (\<forall>x\<in>A. \<not> P x)"
haftmann@43967
  1588
  by auto
haftmann@43967
  1589
haftmann@32135
  1590
haftmann@32135
  1591
subsubsection {* Monotonicity of various operations *}
haftmann@32135
  1592
haftmann@32135
  1593
lemma image_mono: "A \<subseteq> B ==> f`A \<subseteq> f`B"
haftmann@32135
  1594
  by blast
haftmann@32135
  1595
haftmann@32135
  1596
lemma Pow_mono: "A \<subseteq> B ==> Pow A \<subseteq> Pow B"
haftmann@32135
  1597
  by blast
haftmann@32135
  1598
haftmann@32135
  1599
lemma insert_mono: "C \<subseteq> D ==> insert a C \<subseteq> insert a D"
haftmann@32135
  1600
  by blast
haftmann@32135
  1601
haftmann@32135
  1602
lemma Un_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<union> B \<subseteq> C \<union> D"
huffman@36009
  1603
  by (fact sup_mono)
haftmann@32135
  1604
haftmann@32135
  1605
lemma Int_mono: "A \<subseteq> C ==> B \<subseteq> D ==> A \<inter> B \<subseteq> C \<inter> D"
huffman@36009
  1606
  by (fact inf_mono)
haftmann@32135
  1607
haftmann@32135
  1608
lemma Diff_mono: "A \<subseteq> C ==> D \<subseteq> B ==> A - B \<subseteq> C - D"
haftmann@32135
  1609
  by blast
haftmann@32135
  1610
haftmann@32135
  1611
lemma Compl_anti_mono: "A \<subseteq> B ==> -B \<subseteq> -A"
huffman@36009
  1612
  by (fact compl_mono)
haftmann@32135
  1613
haftmann@32135
  1614
text {* \medskip Monotonicity of implications. *}
haftmann@32135
  1615
haftmann@32135
  1616
lemma in_mono: "A \<subseteq> B ==> x \<in> A --> x \<in> B"
haftmann@32135
  1617
  apply (rule impI)
haftmann@32135
  1618
  apply (erule subsetD, assumption)
haftmann@32135
  1619
  done
haftmann@32135
  1620
haftmann@32135
  1621
lemma conj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 & P2) --> (Q1 & Q2)"
haftmann@32135
  1622
  by iprover
haftmann@32135
  1623
haftmann@32135
  1624
lemma disj_mono: "P1 --> Q1 ==> P2 --> Q2 ==> (P1 | P2) --> (Q1 | Q2)"
haftmann@32135
  1625
  by iprover
haftmann@32135
  1626
haftmann@32135
  1627
lemma imp_mono: "Q1 --> P1 ==> P2 --> Q2 ==> (P1 --> P2) --> (Q1 --> Q2)"
haftmann@32135
  1628
  by iprover
haftmann@32135
  1629
haftmann@32135
  1630
lemma imp_refl: "P --> P" ..
haftmann@32135
  1631
berghofe@33935
  1632
lemma not_mono: "Q --> P ==> ~ P --> ~ Q"
berghofe@33935
  1633
  by iprover
berghofe@33935
  1634
haftmann@32135
  1635
lemma ex_mono: "(!!x. P x --> Q x) ==> (EX x. P x) --> (EX x. Q x)"
haftmann@32135
  1636
  by iprover
haftmann@32135
  1637
haftmann@32135
  1638
lemma all_mono: "(!!x. P x --> Q x) ==> (ALL x. P x) --> (ALL x. Q x)"
haftmann@32135
  1639
  by iprover
haftmann@32135
  1640
haftmann@32135
  1641
lemma Collect_mono: "(!!x. P x --> Q x) ==> Collect P \<subseteq> Collect Q"
haftmann@32135
  1642
  by blast
haftmann@32135
  1643
haftmann@32135
  1644
lemma Int_Collect_mono:
haftmann@32135
  1645
    "A \<subseteq> B ==> (!!x. x \<in> A ==> P x --> Q x) ==> A \<inter> Collect P \<subseteq> B \<inter> Collect Q"
haftmann@32135
  1646
  by blast
haftmann@32135
  1647
haftmann@32135
  1648
lemmas basic_monos =
haftmann@32135
  1649
  subset_refl imp_refl disj_mono conj_mono
haftmann@32135
  1650
  ex_mono Collect_mono in_mono
haftmann@32135
  1651
haftmann@32135
  1652
lemma eq_to_mono: "a = b ==> c = d ==> b --> d ==> a --> c"
haftmann@32135
  1653
  by iprover
haftmann@32135
  1654
haftmann@32135
  1655
haftmann@32135
  1656
subsubsection {* Inverse image of a function *}
haftmann@32135
  1657
haftmann@35416
  1658
definition vimage :: "('a => 'b) => 'b set => 'a set" (infixr "-`" 90) where
haftmann@37767
  1659
  "f -` B == {x. f x : B}"
haftmann@32135
  1660
haftmann@32135
  1661
lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)"
haftmann@32135
  1662
  by (unfold vimage_def) blast
haftmann@32135
  1663
haftmann@32135
  1664
lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)"
haftmann@32135
  1665
  by simp
haftmann@32135
  1666
haftmann@32135
  1667
lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B"
haftmann@32135
  1668
  by (unfold vimage_def) blast
haftmann@32135
  1669
haftmann@32135
  1670
lemma vimageI2: "f a : A ==> a : f -` A"
haftmann@32135
  1671
  by (unfold vimage_def) fast
haftmann@32135
  1672
haftmann@32135
  1673
lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P"
haftmann@32135
  1674
  by (unfold vimage_def) blast
haftmann@32135
  1675
haftmann@32135
  1676
lemma vimageD: "a : f -` A ==> f a : A"
haftmann@32135
  1677
  by (unfold vimage_def) fast
haftmann@32135
  1678
haftmann@32135
  1679
lemma vimage_empty [simp]: "f -` {} = {}"
haftmann@32135
  1680
  by blast
haftmann@32135
  1681
haftmann@32135
  1682
lemma vimage_Compl: "f -` (-A) = -(f -` A)"
haftmann@32135
  1683
  by blast
haftmann@32135
  1684
haftmann@32135
  1685
lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)"
haftmann@32135
  1686
  by blast
haftmann@32135
  1687
haftmann@32135
  1688
lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)"
haftmann@32135
  1689
  by fast
haftmann@32135
  1690
haftmann@32135
  1691
lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}"
haftmann@32135
  1692
  by blast
haftmann@32135
  1693
haftmann@32135
  1694
lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q"
haftmann@32135
  1695
  by blast
haftmann@32135
  1696
haftmann@32135
  1697
lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)"
haftmann@32135
  1698
  -- {* NOT suitable for rewriting because of the recurrence of @{term "{a}"}. *}
haftmann@32135
  1699
  by blast
haftmann@32135
  1700
haftmann@32135
  1701
lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)"
haftmann@32135
  1702
  by blast
haftmann@32135
  1703
haftmann@32135
  1704
lemma vimage_UNIV [simp]: "f -` UNIV = UNIV"
haftmann@32135
  1705
  by blast
haftmann@32135
  1706
haftmann@32135
  1707
lemma vimage_mono: "A \<subseteq> B ==> f -` A \<subseteq> f -` B"
haftmann@32135
  1708
  -- {* monotonicity *}
haftmann@32135
  1709
  by blast
haftmann@32135
  1710
blanchet@35828
  1711
lemma vimage_image_eq [no_atp]: "f -` (f ` A) = {y. EX x:A. f x = f y}"
haftmann@32135
  1712
by (blast intro: sym)
haftmann@32135
  1713
haftmann@32135
  1714
lemma image_vimage_subset: "f ` (f -` A) <= A"
haftmann@32135
  1715
by blast
haftmann@32135
  1716
haftmann@32135
  1717
lemma image_vimage_eq [simp]: "f ` (f -` A) = A Int range f"
haftmann@32135
  1718
by blast
haftmann@32135
  1719
paulson@33533
  1720
lemma vimage_const [simp]: "((\<lambda>x. c) -` A) = (if c \<in> A then UNIV else {})"
paulson@33533
  1721
  by auto
paulson@33533
  1722
paulson@33533
  1723
lemma vimage_if [simp]: "((\<lambda>x. if x \<in> B then c else d) -` A) = 
paulson@33533
  1724
   (if c \<in> A then (if d \<in> A then UNIV else B)
paulson@33533
  1725
    else if d \<in> A then -B else {})"  
paulson@33533
  1726
  by (auto simp add: vimage_def) 
paulson@33533
  1727
hoelzl@35576
  1728
lemma vimage_inter_cong:
hoelzl@35576
  1729
  "(\<And> w. w \<in> S \<Longrightarrow> f w = g w) \<Longrightarrow> f -` y \<inter> S = g -` y \<inter> S"
hoelzl@35576
  1730
  by auto
hoelzl@35576
  1731
haftmann@43898
  1732
lemma vimage_ident [simp]: "(%x. x) -` Y = Y"
haftmann@43898
  1733
  by blast
haftmann@32135
  1734
haftmann@32135
  1735
haftmann@32135
  1736
subsubsection {* Getting the Contents of a Singleton Set *}
haftmann@32135
  1737
haftmann@39910
  1738
definition the_elem :: "'a set \<Rightarrow> 'a" where
haftmann@39910
  1739
  "the_elem X = (THE x. X = {x})"
haftmann@32135
  1740
haftmann@39910
  1741
lemma the_elem_eq [simp]: "the_elem {x} = x"
haftmann@39910
  1742
  by (simp add: the_elem_def)
haftmann@32135
  1743
haftmann@32135
  1744
haftmann@32135
  1745
subsubsection {* Least value operator *}
haftmann@32135
  1746
haftmann@32135
  1747
lemma Least_mono:
haftmann@32135
  1748
  "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
haftmann@32135
  1749
    ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
haftmann@32135
  1750
    -- {* Courtesy of Stephan Merz *}
haftmann@32135
  1751
  apply clarify
haftmann@32135
  1752
  apply (erule_tac P = "%x. x : S" in LeastI2_order, fast)
haftmann@32135
  1753
  apply (rule LeastI2_order)
haftmann@32135
  1754
  apply (auto elim: monoD intro!: order_antisym)
haftmann@32135
  1755
  done
haftmann@32135
  1756
haftmann@32135
  1757
subsection {* Misc *}
haftmann@32135
  1758
haftmann@32135
  1759
text {* Rudimentary code generation *}
haftmann@32135
  1760
haftmann@32135
  1761
lemma insert_code [code]: "insert y A x \<longleftrightarrow> y = x \<or> A x"
haftmann@32135
  1762
  by (auto simp add: insert_compr Collect_def mem_def)
haftmann@32135
  1763
haftmann@32135
  1764
lemma vimage_code [code]: "(f -` A) x = A (f x)"
haftmann@32135
  1765
  by (simp add: vimage_def Collect_def mem_def)
haftmann@32135
  1766
haftmann@37677
  1767
hide_const (open) member
haftmann@32135
  1768
haftmann@32135
  1769
text {* Misc theorem and ML bindings *}
haftmann@32135
  1770
haftmann@32135
  1771
lemmas equalityI = subset_antisym
haftmann@32135
  1772
haftmann@32135
  1773
ML {*
haftmann@32135
  1774
val Ball_def = @{thm Ball_def}
haftmann@32135
  1775
val Bex_def = @{thm Bex_def}
haftmann@32135
  1776
val CollectD = @{thm CollectD}
haftmann@32135
  1777
val CollectE = @{thm CollectE}
haftmann@32135
  1778
val CollectI = @{thm CollectI}
haftmann@32135
  1779
val Collect_conj_eq = @{thm Collect_conj_eq}
haftmann@32135
  1780
val Collect_mem_eq = @{thm Collect_mem_eq}
haftmann@32135
  1781
val IntD1 = @{thm IntD1}
haftmann@32135
  1782
val IntD2 = @{thm IntD2}
haftmann@32135
  1783
val IntE = @{thm IntE}
haftmann@32135
  1784
val IntI = @{thm IntI}
haftmann@32135
  1785
val Int_Collect = @{thm Int_Collect}
haftmann@32135
  1786
val UNIV_I = @{thm UNIV_I}
haftmann@32135
  1787
val UNIV_witness = @{thm UNIV_witness}
haftmann@32135
  1788
val UnE = @{thm UnE}
haftmann@32135
  1789
val UnI1 = @{thm UnI1}
haftmann@32135
  1790
val UnI2 = @{thm UnI2}
haftmann@32135
  1791
val ballE = @{thm ballE}
haftmann@32135
  1792
val ballI = @{thm ballI}
haftmann@32135
  1793
val bexCI = @{thm bexCI}
haftmann@32135
  1794
val bexE = @{thm bexE}
haftmann@32135
  1795
val bexI = @{thm bexI}
haftmann@32135
  1796
val bex_triv = @{thm bex_triv}
haftmann@32135
  1797
val bspec = @{thm bspec}
haftmann@32135
  1798
val contra_subsetD = @{thm contra_subsetD}
haftmann@32135
  1799
val distinct_lemma = @{thm distinct_lemma}
haftmann@32135
  1800
val eq_to_mono = @{thm eq_to_mono}
haftmann@32135
  1801
val equalityCE = @{thm equalityCE}
haftmann@32135
  1802
val equalityD1 = @{thm equalityD1}
haftmann@32135
  1803
val equalityD2 = @{thm equalityD2}
haftmann@32135
  1804
val equalityE = @{thm equalityE}
haftmann@32135
  1805
val equalityI = @{thm equalityI}
haftmann@32135
  1806
val imageE = @{thm imageE}
haftmann@32135
  1807
val imageI = @{thm imageI}
haftmann@32135
  1808
val image_Un = @{thm image_Un}
haftmann@32135
  1809
val image_insert = @{thm image_insert}
haftmann@32135
  1810
val insert_commute = @{thm insert_commute}
haftmann@32135
  1811
val insert_iff = @{thm insert_iff}
haftmann@32135
  1812
val mem_Collect_eq = @{thm mem_Collect_eq}
haftmann@32135
  1813
val rangeE = @{thm rangeE}
haftmann@32135
  1814
val rangeI = @{thm rangeI}
haftmann@32135
  1815
val range_eqI = @{thm range_eqI}
haftmann@32135
  1816
val subsetCE = @{thm subsetCE}
haftmann@32135
  1817
val subsetD = @{thm subsetD}
haftmann@32135
  1818
val subsetI = @{thm subsetI}
haftmann@32135
  1819
val subset_refl = @{thm subset_refl}
haftmann@32135
  1820
val subset_trans = @{thm subset_trans}
haftmann@32135
  1821
val vimageD = @{thm vimageD}
haftmann@32135
  1822
val vimageE = @{thm vimageE}
haftmann@32135
  1823
val vimageI = @{thm vimageI}
haftmann@32135
  1824
val vimageI2 = @{thm vimageI2}
haftmann@32135
  1825
val vimage_Collect = @{thm vimage_Collect}
haftmann@32135
  1826
val vimage_Int = @{thm vimage_Int}
haftmann@32135
  1827
val vimage_Un = @{thm vimage_Un}
haftmann@32135
  1828
*}
haftmann@32135
  1829
haftmann@32077
  1830
end