src/HOL/Set.thy
author wenzelm
Fri Jan 04 19:29:30 2002 +0100 (2002-01-04)
changeset 12633 ad9277743664
parent 12338 de0f4a63baa5
child 12897 f4d10ad0ea7b
permissions -rw-r--r--
tuned ``syntax (output)'';
clasohm@923
     1
(*  Title:      HOL/Set.thy
clasohm@923
     2
    ID:         $Id$
wenzelm@12257
     3
    Author:     Tobias Nipkow, Lawrence C Paulson and Markus Wenzel
wenzelm@12020
     4
    License:    GPL (GNU GENERAL PUBLIC LICENSE)
clasohm@923
     5
*)
clasohm@923
     6
wenzelm@11979
     7
header {* Set theory for higher-order logic *}
wenzelm@11979
     8
wenzelm@11979
     9
theory Set = HOL
wenzelm@11979
    10
files ("subset.ML") ("equalities.ML") ("mono.ML"):
wenzelm@11979
    11
wenzelm@11979
    12
text {* A set in HOL is simply a predicate. *}
clasohm@923
    13
wenzelm@2261
    14
wenzelm@11979
    15
subsection {* Basic syntax *}
wenzelm@2261
    16
wenzelm@3947
    17
global
wenzelm@3947
    18
wenzelm@11979
    19
typedecl 'a set
wenzelm@12338
    20
arities set :: (type) type
wenzelm@3820
    21
clasohm@923
    22
consts
wenzelm@11979
    23
  "{}"          :: "'a set"                             ("{}")
wenzelm@11979
    24
  UNIV          :: "'a set"
wenzelm@11979
    25
  insert        :: "'a => 'a set => 'a set"
wenzelm@11979
    26
  Collect       :: "('a => bool) => 'a set"              -- "comprehension"
wenzelm@11979
    27
  Int           :: "'a set => 'a set => 'a set"          (infixl 70)
wenzelm@11979
    28
  Un            :: "'a set => 'a set => 'a set"          (infixl 65)
wenzelm@11979
    29
  UNION         :: "'a set => ('a => 'b set) => 'b set"  -- "general union"
wenzelm@11979
    30
  INTER         :: "'a set => ('a => 'b set) => 'b set"  -- "general intersection"
wenzelm@11979
    31
  Union         :: "'a set set => 'a set"                -- "union of a set"
wenzelm@11979
    32
  Inter         :: "'a set set => 'a set"                -- "intersection of a set"
wenzelm@11979
    33
  Pow           :: "'a set => 'a set set"                -- "powerset"
wenzelm@11979
    34
  Ball          :: "'a set => ('a => bool) => bool"      -- "bounded universal quantifiers"
wenzelm@11979
    35
  Bex           :: "'a set => ('a => bool) => bool"      -- "bounded existential quantifiers"
wenzelm@11979
    36
  image         :: "('a => 'b) => 'a set => 'b set"      (infixr "`" 90)
wenzelm@11979
    37
wenzelm@11979
    38
syntax
wenzelm@11979
    39
  "op :"        :: "'a => 'a set => bool"                ("op :")
wenzelm@11979
    40
consts
wenzelm@11979
    41
  "op :"        :: "'a => 'a set => bool"                ("(_/ : _)" [50, 51] 50)  -- "membership"
wenzelm@11979
    42
wenzelm@11979
    43
local
wenzelm@11979
    44
wenzelm@12338
    45
instance set :: (type) ord ..
wenzelm@12338
    46
instance set :: (type) minus ..
clasohm@923
    47
clasohm@923
    48
wenzelm@11979
    49
subsection {* Additional concrete syntax *}
wenzelm@2261
    50
clasohm@923
    51
syntax
wenzelm@11979
    52
  range         :: "('a => 'b) => 'b set"             -- "of function"
clasohm@923
    53
wenzelm@11979
    54
  "op ~:"       :: "'a => 'a set => bool"                 ("op ~:")  -- "non-membership"
wenzelm@11979
    55
  "op ~:"       :: "'a => 'a set => bool"                 ("(_/ ~: _)" [50, 51] 50)
wenzelm@7238
    56
wenzelm@11979
    57
  "@Finset"     :: "args => 'a set"                       ("{(_)}")
wenzelm@11979
    58
  "@Coll"       :: "pttrn => bool => 'a set"              ("(1{_./ _})")
wenzelm@11979
    59
  "@SetCompr"   :: "'a => idts => bool => 'a set"         ("(1{_ |/_./ _})")
clasohm@923
    60
wenzelm@11979
    61
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3INT _./ _)" 10)
wenzelm@11979
    62
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3UN _./ _)" 10)
wenzelm@11979
    63
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3INT _:_./ _)" 10)
wenzelm@11979
    64
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3UN _:_./ _)" 10)
clasohm@923
    65
wenzelm@11979
    66
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3ALL _:_./ _)" [0, 0, 10] 10)
wenzelm@11979
    67
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3EX _:_./ _)" [0, 0, 10] 10)
clasohm@923
    68
wenzelm@7238
    69
syntax (HOL)
wenzelm@11979
    70
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3! _:_./ _)" [0, 0, 10] 10)
wenzelm@11979
    71
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3? _:_./ _)" [0, 0, 10] 10)
clasohm@923
    72
clasohm@923
    73
translations
nipkow@10832
    74
  "range f"     == "f`UNIV"
clasohm@923
    75
  "x ~: y"      == "~ (x : y)"
clasohm@923
    76
  "{x, xs}"     == "insert x {xs}"
clasohm@923
    77
  "{x}"         == "insert x {}"
clasohm@923
    78
  "{x. P}"      == "Collect (%x. P)"
paulson@4159
    79
  "UN x y. B"   == "UN x. UN y. B"
paulson@4159
    80
  "UN x. B"     == "UNION UNIV (%x. B)"
wenzelm@7238
    81
  "INT x y. B"  == "INT x. INT y. B"
paulson@4159
    82
  "INT x. B"    == "INTER UNIV (%x. B)"
paulson@4159
    83
  "UN x:A. B"   == "UNION A (%x. B)"
clasohm@923
    84
  "INT x:A. B"  == "INTER A (%x. B)"
wenzelm@7238
    85
  "ALL x:A. P"  == "Ball A (%x. P)"
wenzelm@7238
    86
  "EX x:A. P"   == "Bex A (%x. P)"
clasohm@923
    87
wenzelm@12633
    88
syntax (output)
wenzelm@11979
    89
  "_setle"      :: "'a set => 'a set => bool"             ("op <=")
wenzelm@11979
    90
  "_setle"      :: "'a set => 'a set => bool"             ("(_/ <= _)" [50, 51] 50)
wenzelm@11979
    91
  "_setless"    :: "'a set => 'a set => bool"             ("op <")
wenzelm@11979
    92
  "_setless"    :: "'a set => 'a set => bool"             ("(_/ < _)" [50, 51] 50)
clasohm@923
    93
wenzelm@12114
    94
syntax (xsymbols)
wenzelm@11979
    95
  "_setle"      :: "'a set => 'a set => bool"             ("op \<subseteq>")
wenzelm@11979
    96
  "_setle"      :: "'a set => 'a set => bool"             ("(_/ \<subseteq> _)" [50, 51] 50)
wenzelm@11979
    97
  "_setless"    :: "'a set => 'a set => bool"             ("op \<subset>")
wenzelm@11979
    98
  "_setless"    :: "'a set => 'a set => bool"             ("(_/ \<subset> _)" [50, 51] 50)
wenzelm@11979
    99
  "op Int"      :: "'a set => 'a set => 'a set"           (infixl "\<inter>" 70)
wenzelm@11979
   100
  "op Un"       :: "'a set => 'a set => 'a set"           (infixl "\<union>" 65)
wenzelm@11979
   101
  "op :"        :: "'a => 'a set => bool"                 ("op \<in>")
wenzelm@11979
   102
  "op :"        :: "'a => 'a set => bool"                 ("(_/ \<in> _)" [50, 51] 50)
wenzelm@11979
   103
  "op ~:"       :: "'a => 'a set => bool"                 ("op \<notin>")
wenzelm@11979
   104
  "op ~:"       :: "'a => 'a set => bool"                 ("(_/ \<notin> _)" [50, 51] 50)
wenzelm@11979
   105
  "@UNION1"     :: "pttrns => 'b set => 'b set"           ("(3\<Union>_./ _)" 10)
wenzelm@11979
   106
  "@INTER1"     :: "pttrns => 'b set => 'b set"           ("(3\<Inter>_./ _)" 10)
wenzelm@11979
   107
  "@UNION"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Union>_\<in>_./ _)" 10)
wenzelm@11979
   108
  "@INTER"      :: "pttrn => 'a set => 'b set => 'b set"  ("(3\<Inter>_\<in>_./ _)" 10)
wenzelm@11979
   109
  Union         :: "'a set set => 'a set"                 ("\<Union>_" [90] 90)
wenzelm@11979
   110
  Inter         :: "'a set set => 'a set"                 ("\<Inter>_" [90] 90)
wenzelm@11979
   111
  "_Ball"       :: "pttrn => 'a set => bool => bool"      ("(3\<forall>_\<in>_./ _)" [0, 0, 10] 10)
wenzelm@11979
   112
  "_Bex"        :: "pttrn => 'a set => bool => bool"      ("(3\<exists>_\<in>_./ _)" [0, 0, 10] 10)
wenzelm@2261
   113
wenzelm@2412
   114
translations
wenzelm@11979
   115
  "op \<subseteq>" => "op <= :: _ set => _ set => bool"
wenzelm@11979
   116
  "op \<subset>" => "op <  :: _ set => _ set => bool"
wenzelm@2261
   117
wenzelm@2261
   118
wenzelm@11979
   119
typed_print_translation {*
wenzelm@11979
   120
  let
wenzelm@11979
   121
    fun le_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
wenzelm@11979
   122
          list_comb (Syntax.const "_setle", ts)
wenzelm@11979
   123
      | le_tr' _ _ _ = raise Match;
wenzelm@11979
   124
wenzelm@11979
   125
    fun less_tr' _ (Type ("fun", (Type ("set", _) :: _))) ts =
wenzelm@11979
   126
          list_comb (Syntax.const "_setless", ts)
wenzelm@11979
   127
      | less_tr' _ _ _ = raise Match;
wenzelm@11979
   128
  in [("op <=", le_tr'), ("op <", less_tr')] end
wenzelm@11979
   129
*}
wenzelm@2261
   130
wenzelm@11979
   131
text {*
wenzelm@11979
   132
  \medskip Translate between @{text "{e | x1...xn. P}"} and @{text
wenzelm@11979
   133
  "{u. EX x1..xn. u = e & P}"}; @{text "{y. EX x1..xn. y = e & P}"} is
wenzelm@11979
   134
  only translated if @{text "[0..n] subset bvs(e)"}.
wenzelm@11979
   135
*}
wenzelm@11979
   136
wenzelm@11979
   137
parse_translation {*
wenzelm@11979
   138
  let
wenzelm@11979
   139
    val ex_tr = snd (mk_binder_tr ("EX ", "Ex"));
wenzelm@3947
   140
wenzelm@11979
   141
    fun nvars (Const ("_idts", _) $ _ $ idts) = nvars idts + 1
wenzelm@11979
   142
      | nvars _ = 1;
wenzelm@11979
   143
wenzelm@11979
   144
    fun setcompr_tr [e, idts, b] =
wenzelm@11979
   145
      let
wenzelm@11979
   146
        val eq = Syntax.const "op =" $ Bound (nvars idts) $ e;
wenzelm@11979
   147
        val P = Syntax.const "op &" $ eq $ b;
wenzelm@11979
   148
        val exP = ex_tr [idts, P];
wenzelm@11979
   149
      in Syntax.const "Collect" $ Abs ("", dummyT, exP) end;
wenzelm@11979
   150
wenzelm@11979
   151
  in [("@SetCompr", setcompr_tr)] end;
wenzelm@11979
   152
*}
clasohm@923
   153
wenzelm@11979
   154
print_translation {*
wenzelm@11979
   155
  let
wenzelm@11979
   156
    val ex_tr' = snd (mk_binder_tr' ("Ex", "DUMMY"));
wenzelm@11979
   157
wenzelm@11979
   158
    fun setcompr_tr' [Abs (_, _, P)] =
wenzelm@11979
   159
      let
wenzelm@11979
   160
        fun check (Const ("Ex", _) $ Abs (_, _, P), n) = check (P, n + 1)
wenzelm@11979
   161
          | check (Const ("op &", _) $ (Const ("op =", _) $ Bound m $ e) $ P, n) =
wenzelm@11979
   162
              if n > 0 andalso m = n andalso not (loose_bvar1 (P, n)) andalso
wenzelm@11979
   163
                ((0 upto (n - 1)) subset add_loose_bnos (e, 0, [])) then ()
wenzelm@11979
   164
              else raise Match;
clasohm@923
   165
wenzelm@11979
   166
        fun tr' (_ $ abs) =
wenzelm@11979
   167
          let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr' [abs]
wenzelm@11979
   168
          in Syntax.const "@SetCompr" $ e $ idts $ Q end;
wenzelm@11979
   169
      in check (P, 0); tr' P end;
wenzelm@11979
   170
  in [("Collect", setcompr_tr')] end;
wenzelm@11979
   171
*}
wenzelm@11979
   172
wenzelm@11979
   173
wenzelm@11979
   174
subsection {* Rules and definitions *}
wenzelm@11979
   175
wenzelm@11979
   176
text {* Isomorphisms between predicates and sets. *}
clasohm@923
   177
wenzelm@11979
   178
axioms
wenzelm@11979
   179
  mem_Collect_eq [iff]: "(a : {x. P(x)}) = P(a)"
wenzelm@11979
   180
  Collect_mem_eq [simp]: "{x. x:A} = A"
wenzelm@11979
   181
wenzelm@11979
   182
defs
wenzelm@11979
   183
  Ball_def:     "Ball A P       == ALL x. x:A --> P(x)"
wenzelm@11979
   184
  Bex_def:      "Bex A P        == EX x. x:A & P(x)"
wenzelm@11979
   185
wenzelm@11979
   186
defs (overloaded)
wenzelm@11979
   187
  subset_def:   "A <= B         == ALL x:A. x:B"
wenzelm@11979
   188
  psubset_def:  "A < B          == (A::'a set) <= B & ~ A=B"
wenzelm@11979
   189
  Compl_def:    "- A            == {x. ~x:A}"
wenzelm@12257
   190
  set_diff_def: "A - B          == {x. x:A & ~x:B}"
clasohm@923
   191
clasohm@923
   192
defs
wenzelm@11979
   193
  Un_def:       "A Un B         == {x. x:A | x:B}"
wenzelm@11979
   194
  Int_def:      "A Int B        == {x. x:A & x:B}"
wenzelm@11979
   195
  INTER_def:    "INTER A B      == {y. ALL x:A. y: B(x)}"
wenzelm@11979
   196
  UNION_def:    "UNION A B      == {y. EX x:A. y: B(x)}"
wenzelm@11979
   197
  Inter_def:    "Inter S        == (INT x:S. x)"
wenzelm@11979
   198
  Union_def:    "Union S        == (UN x:S. x)"
wenzelm@11979
   199
  Pow_def:      "Pow A          == {B. B <= A}"
wenzelm@11979
   200
  empty_def:    "{}             == {x. False}"
wenzelm@11979
   201
  UNIV_def:     "UNIV           == {x. True}"
wenzelm@11979
   202
  insert_def:   "insert a B     == {x. x=a} Un B"
wenzelm@11979
   203
  image_def:    "f`A            == {y. EX x:A. y = f(x)}"
wenzelm@11979
   204
wenzelm@11979
   205
wenzelm@11979
   206
subsection {* Lemmas and proof tool setup *}
wenzelm@11979
   207
wenzelm@11979
   208
subsubsection {* Relating predicates and sets *}
wenzelm@11979
   209
wenzelm@12257
   210
lemma CollectI: "P(a) ==> a : {x. P(x)}"
wenzelm@11979
   211
  by simp
wenzelm@11979
   212
wenzelm@11979
   213
lemma CollectD: "a : {x. P(x)} ==> P(a)"
wenzelm@11979
   214
  by simp
wenzelm@11979
   215
wenzelm@12257
   216
lemma set_ext: (assumes prem: "(!!x. (x:A) = (x:B))") "A = B"
wenzelm@12257
   217
  apply (rule prem [THEN ext, THEN arg_cong, THEN box_equals])
wenzelm@12257
   218
   apply (rule Collect_mem_eq)
wenzelm@12257
   219
  apply (rule Collect_mem_eq)
wenzelm@12257
   220
  done
wenzelm@11979
   221
wenzelm@11979
   222
lemma Collect_cong: "(!!x. P x = Q x) ==> {x. P(x)} = {x. Q(x)}"
wenzelm@11979
   223
  by simp
wenzelm@11979
   224
wenzelm@12257
   225
lemmas CollectE = CollectD [elim_format]
wenzelm@11979
   226
wenzelm@11979
   227
wenzelm@11979
   228
subsubsection {* Bounded quantifiers *}
wenzelm@11979
   229
wenzelm@11979
   230
lemma ballI [intro!]: "(!!x. x:A ==> P x) ==> ALL x:A. P x"
wenzelm@11979
   231
  by (simp add: Ball_def)
wenzelm@11979
   232
wenzelm@11979
   233
lemmas strip = impI allI ballI
wenzelm@11979
   234
wenzelm@11979
   235
lemma bspec [dest?]: "ALL x:A. P x ==> x:A ==> P x"
wenzelm@11979
   236
  by (simp add: Ball_def)
wenzelm@11979
   237
wenzelm@11979
   238
lemma ballE [elim]: "ALL x:A. P x ==> (P x ==> Q) ==> (x ~: A ==> Q) ==> Q"
wenzelm@11979
   239
  by (unfold Ball_def) blast
wenzelm@11979
   240
wenzelm@11979
   241
text {*
wenzelm@11979
   242
  \medskip This tactic takes assumptions @{prop "ALL x:A. P x"} and
wenzelm@11979
   243
  @{prop "a:A"}; creates assumption @{prop "P a"}.
wenzelm@11979
   244
*}
wenzelm@11979
   245
wenzelm@11979
   246
ML {*
wenzelm@11979
   247
  local val ballE = thm "ballE"
wenzelm@11979
   248
  in fun ball_tac i = etac ballE i THEN contr_tac (i + 1) end;
wenzelm@11979
   249
*}
wenzelm@11979
   250
wenzelm@11979
   251
text {*
wenzelm@11979
   252
  Gives better instantiation for bound:
wenzelm@11979
   253
*}
wenzelm@11979
   254
wenzelm@11979
   255
ML_setup {*
wenzelm@11979
   256
  claset_ref() := claset() addbefore ("bspec", datac (thm "bspec") 1);
wenzelm@11979
   257
*}
wenzelm@11979
   258
wenzelm@11979
   259
lemma bexI [intro]: "P x ==> x:A ==> EX x:A. P x"
wenzelm@11979
   260
  -- {* Normally the best argument order: @{prop "P x"} constrains the
wenzelm@11979
   261
    choice of @{prop "x:A"}. *}
wenzelm@11979
   262
  by (unfold Bex_def) blast
wenzelm@11979
   263
wenzelm@11979
   264
lemma rev_bexI: "x:A ==> P x ==> EX x:A. P x"
wenzelm@11979
   265
  -- {* The best argument order when there is only one @{prop "x:A"}. *}
wenzelm@11979
   266
  by (unfold Bex_def) blast
wenzelm@11979
   267
wenzelm@11979
   268
lemma bexCI: "(ALL x:A. ~P x ==> P a) ==> a:A ==> EX x:A. P x"
wenzelm@11979
   269
  by (unfold Bex_def) blast
wenzelm@11979
   270
wenzelm@11979
   271
lemma bexE [elim!]: "EX x:A. P x ==> (!!x. x:A ==> P x ==> Q) ==> Q"
wenzelm@11979
   272
  by (unfold Bex_def) blast
wenzelm@11979
   273
wenzelm@11979
   274
lemma ball_triv [simp]: "(ALL x:A. P) = ((EX x. x:A) --> P)"
wenzelm@11979
   275
  -- {* Trival rewrite rule. *}
wenzelm@11979
   276
  by (simp add: Ball_def)
wenzelm@11979
   277
wenzelm@11979
   278
lemma bex_triv [simp]: "(EX x:A. P) = ((EX x. x:A) & P)"
wenzelm@11979
   279
  -- {* Dual form for existentials. *}
wenzelm@11979
   280
  by (simp add: Bex_def)
wenzelm@11979
   281
wenzelm@11979
   282
lemma bex_triv_one_point1 [simp]: "(EX x:A. x = a) = (a:A)"
wenzelm@11979
   283
  by blast
wenzelm@11979
   284
wenzelm@11979
   285
lemma bex_triv_one_point2 [simp]: "(EX x:A. a = x) = (a:A)"
wenzelm@11979
   286
  by blast
wenzelm@11979
   287
wenzelm@11979
   288
lemma bex_one_point1 [simp]: "(EX x:A. x = a & P x) = (a:A & P a)"
wenzelm@11979
   289
  by blast
wenzelm@11979
   290
wenzelm@11979
   291
lemma bex_one_point2 [simp]: "(EX x:A. a = x & P x) = (a:A & P a)"
wenzelm@11979
   292
  by blast
wenzelm@11979
   293
wenzelm@11979
   294
lemma ball_one_point1 [simp]: "(ALL x:A. x = a --> P x) = (a:A --> P a)"
wenzelm@11979
   295
  by blast
wenzelm@11979
   296
wenzelm@11979
   297
lemma ball_one_point2 [simp]: "(ALL x:A. a = x --> P x) = (a:A --> P a)"
wenzelm@11979
   298
  by blast
wenzelm@11979
   299
wenzelm@11979
   300
ML_setup {*
wenzelm@11979
   301
  let
wenzelm@11979
   302
    val Ball_def = thm "Ball_def";
wenzelm@11979
   303
    val Bex_def = thm "Bex_def";
wenzelm@11979
   304
wenzelm@11979
   305
    val ex_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
wenzelm@11979
   306
      ("EX x:A. P x & Q x", HOLogic.boolT);
wenzelm@11979
   307
wenzelm@11979
   308
    val prove_bex_tac =
wenzelm@11979
   309
      rewrite_goals_tac [Bex_def] THEN Quantifier1.prove_one_point_ex_tac;
wenzelm@11979
   310
    val rearrange_bex = Quantifier1.rearrange_bex prove_bex_tac;
wenzelm@11979
   311
wenzelm@11979
   312
    val all_pattern = Thm.read_cterm (Theory.sign_of (the_context ()))
wenzelm@11979
   313
      ("ALL x:A. P x --> Q x", HOLogic.boolT);
wenzelm@11979
   314
wenzelm@11979
   315
    val prove_ball_tac =
wenzelm@11979
   316
      rewrite_goals_tac [Ball_def] THEN Quantifier1.prove_one_point_all_tac;
wenzelm@11979
   317
    val rearrange_ball = Quantifier1.rearrange_ball prove_ball_tac;
wenzelm@11979
   318
wenzelm@11979
   319
    val defBEX_regroup = mk_simproc "defined BEX" [ex_pattern] rearrange_bex;
wenzelm@11979
   320
    val defBALL_regroup = mk_simproc "defined BALL" [all_pattern] rearrange_ball;
wenzelm@11979
   321
  in
wenzelm@11979
   322
    Addsimprocs [defBALL_regroup, defBEX_regroup]
wenzelm@11979
   323
  end;
wenzelm@11979
   324
*}
wenzelm@11979
   325
wenzelm@11979
   326
wenzelm@11979
   327
subsubsection {* Congruence rules *}
wenzelm@11979
   328
wenzelm@11979
   329
lemma ball_cong [cong]:
wenzelm@11979
   330
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   331
    (ALL x:A. P x) = (ALL x:B. Q x)"
wenzelm@11979
   332
  by (simp add: Ball_def)
wenzelm@11979
   333
wenzelm@11979
   334
lemma bex_cong [cong]:
wenzelm@11979
   335
  "A = B ==> (!!x. x:B ==> P x = Q x) ==>
wenzelm@11979
   336
    (EX x:A. P x) = (EX x:B. Q x)"
wenzelm@11979
   337
  by (simp add: Bex_def cong: conj_cong)
regensbu@1273
   338
wenzelm@7238
   339
wenzelm@11979
   340
subsubsection {* Subsets *}
wenzelm@11979
   341
wenzelm@11979
   342
lemma subsetI [intro!]: "(!!x. x:A ==> x:B) ==> A <= B"
wenzelm@11979
   343
  by (simp add: subset_def)
wenzelm@11979
   344
wenzelm@11979
   345
text {*
wenzelm@11979
   346
  \medskip Map the type @{text "'a set => anything"} to just @{typ
wenzelm@11979
   347
  'a}; for overloading constants whose first argument has type @{typ
wenzelm@11979
   348
  "'a set"}.
wenzelm@11979
   349
*}
wenzelm@11979
   350
wenzelm@11979
   351
ML {*
wenzelm@11979
   352
  fun overload_1st_set s = Blast.overloaded (s, HOLogic.dest_setT o domain_type);
wenzelm@11979
   353
*}
wenzelm@11979
   354
wenzelm@11979
   355
ML "
wenzelm@11979
   356
  (* While (:) is not, its type must be kept
wenzelm@11979
   357
    for overloading of = to work. *)
wenzelm@11979
   358
  Blast.overloaded (\"op :\", domain_type);
wenzelm@11979
   359
wenzelm@11979
   360
  overload_1st_set \"Ball\";            (*need UNION, INTER also?*)
wenzelm@11979
   361
  overload_1st_set \"Bex\";
wenzelm@11979
   362
wenzelm@11979
   363
  (*Image: retain the type of the set being expressed*)
wenzelm@11979
   364
  Blast.overloaded (\"image\", domain_type);
wenzelm@11979
   365
"
wenzelm@11979
   366
wenzelm@11979
   367
lemma subsetD [elim]: "A <= B ==> c:A ==> c:B"
wenzelm@11979
   368
  -- {* Rule in Modus Ponens style. *}
wenzelm@11979
   369
  by (unfold subset_def) blast
wenzelm@11979
   370
wenzelm@11979
   371
declare subsetD [intro?] -- FIXME
wenzelm@11979
   372
wenzelm@11979
   373
lemma rev_subsetD: "c:A ==> A <= B ==> c:B"
wenzelm@11979
   374
  -- {* The same, with reversed premises for use with @{text erule} --
wenzelm@11979
   375
      cf @{text rev_mp}. *}
wenzelm@11979
   376
  by (rule subsetD)
wenzelm@11979
   377
wenzelm@11979
   378
declare rev_subsetD [intro?] -- FIXME
wenzelm@11979
   379
wenzelm@11979
   380
text {*
wenzelm@11979
   381
  \medskip Converts @{prop "A <= B"} to @{prop "x:A ==> x:B"}.
wenzelm@11979
   382
*}
wenzelm@11979
   383
wenzelm@11979
   384
ML {*
wenzelm@11979
   385
  local val rev_subsetD = thm "rev_subsetD"
wenzelm@11979
   386
  in fun impOfSubs th = th RSN (2, rev_subsetD) end;
wenzelm@11979
   387
*}
wenzelm@11979
   388
wenzelm@11979
   389
lemma subsetCE [elim]: "A <= B ==> (c~:A ==> P) ==> (c:B ==> P) ==> P"
wenzelm@11979
   390
  -- {* Classical elimination rule. *}
wenzelm@11979
   391
  by (unfold subset_def) blast
wenzelm@11979
   392
wenzelm@11979
   393
text {*
wenzelm@11979
   394
  \medskip Takes assumptions @{prop "A <= B"}; @{prop "c:A"} and
wenzelm@11979
   395
  creates the assumption @{prop "c:B"}.
wenzelm@11979
   396
*}
wenzelm@11979
   397
wenzelm@11979
   398
ML {*
wenzelm@11979
   399
  local val subsetCE = thm "subsetCE"
wenzelm@11979
   400
  in fun set_mp_tac i = etac subsetCE i THEN mp_tac i end;
wenzelm@11979
   401
*}
wenzelm@11979
   402
wenzelm@11979
   403
lemma contra_subsetD: "A <= B ==> c ~: B ==> c ~: A"
wenzelm@11979
   404
  by blast
wenzelm@11979
   405
wenzelm@11979
   406
lemma subset_refl: "A <= (A::'a set)"
wenzelm@11979
   407
  by fast
wenzelm@11979
   408
wenzelm@11979
   409
lemma subset_trans: "A <= B ==> B <= C ==> A <= (C::'a set)"
wenzelm@11979
   410
  by blast
clasohm@923
   411
wenzelm@2261
   412
wenzelm@11979
   413
subsubsection {* Equality *}
wenzelm@11979
   414
wenzelm@11979
   415
lemma subset_antisym [intro!]: "A <= B ==> B <= A ==> A = (B::'a set)"
wenzelm@11979
   416
  -- {* Anti-symmetry of the subset relation. *}
wenzelm@11979
   417
  by (rule set_ext) (blast intro: subsetD)
wenzelm@11979
   418
wenzelm@11979
   419
lemmas equalityI = subset_antisym
wenzelm@11979
   420
wenzelm@11979
   421
text {*
wenzelm@11979
   422
  \medskip Equality rules from ZF set theory -- are they appropriate
wenzelm@11979
   423
  here?
wenzelm@11979
   424
*}
wenzelm@11979
   425
wenzelm@11979
   426
lemma equalityD1: "A = B ==> A <= (B::'a set)"
wenzelm@11979
   427
  by (simp add: subset_refl)
wenzelm@11979
   428
wenzelm@11979
   429
lemma equalityD2: "A = B ==> B <= (A::'a set)"
wenzelm@11979
   430
  by (simp add: subset_refl)
wenzelm@11979
   431
wenzelm@11979
   432
text {*
wenzelm@11979
   433
  \medskip Be careful when adding this to the claset as @{text
wenzelm@11979
   434
  subset_empty} is in the simpset: @{prop "A = {}"} goes to @{prop "{}
wenzelm@11979
   435
  <= A"} and @{prop "A <= {}"} and then back to @{prop "A = {}"}!
wenzelm@11979
   436
*}
wenzelm@11979
   437
wenzelm@11979
   438
lemma equalityE: "A = B ==> (A <= B ==> B <= (A::'a set) ==> P) ==> P"
wenzelm@11979
   439
  by (simp add: subset_refl)
clasohm@923
   440
wenzelm@11979
   441
lemma equalityCE [elim]:
wenzelm@11979
   442
    "A = B ==> (c:A ==> c:B ==> P) ==> (c~:A ==> c~:B ==> P) ==> P"
wenzelm@11979
   443
  by blast
wenzelm@11979
   444
wenzelm@11979
   445
text {*
wenzelm@11979
   446
  \medskip Lemma for creating induction formulae -- for "pattern
wenzelm@11979
   447
  matching" on @{text p}.  To make the induction hypotheses usable,
wenzelm@11979
   448
  apply @{text spec} or @{text bspec} to put universal quantifiers over the free
wenzelm@11979
   449
  variables in @{text p}.
wenzelm@11979
   450
*}
wenzelm@11979
   451
wenzelm@11979
   452
lemma setup_induction: "p:A ==> (!!z. z:A ==> p = z --> R) ==> R"
wenzelm@11979
   453
  by simp
clasohm@923
   454
wenzelm@11979
   455
lemma eqset_imp_iff: "A = B ==> (x : A) = (x : B)"
wenzelm@11979
   456
  by simp
wenzelm@11979
   457
wenzelm@11979
   458
wenzelm@11979
   459
subsubsection {* The universal set -- UNIV *}
wenzelm@11979
   460
wenzelm@11979
   461
lemma UNIV_I [simp]: "x : UNIV"
wenzelm@11979
   462
  by (simp add: UNIV_def)
wenzelm@11979
   463
wenzelm@11979
   464
declare UNIV_I [intro]  -- {* unsafe makes it less likely to cause problems *}
wenzelm@11979
   465
wenzelm@11979
   466
lemma UNIV_witness [intro?]: "EX x. x : UNIV"
wenzelm@11979
   467
  by simp
wenzelm@11979
   468
wenzelm@11979
   469
lemma subset_UNIV: "A <= UNIV"
wenzelm@11979
   470
  by (rule subsetI) (rule UNIV_I)
wenzelm@2388
   471
wenzelm@11979
   472
text {*
wenzelm@11979
   473
  \medskip Eta-contracting these two rules (to remove @{text P})
wenzelm@11979
   474
  causes them to be ignored because of their interaction with
wenzelm@11979
   475
  congruence rules.
wenzelm@11979
   476
*}
wenzelm@11979
   477
wenzelm@11979
   478
lemma ball_UNIV [simp]: "Ball UNIV P = All P"
wenzelm@11979
   479
  by (simp add: Ball_def)
wenzelm@11979
   480
wenzelm@11979
   481
lemma bex_UNIV [simp]: "Bex UNIV P = Ex P"
wenzelm@11979
   482
  by (simp add: Bex_def)
wenzelm@11979
   483
wenzelm@11979
   484
wenzelm@11979
   485
subsubsection {* The empty set *}
wenzelm@11979
   486
wenzelm@11979
   487
lemma empty_iff [simp]: "(c : {}) = False"
wenzelm@11979
   488
  by (simp add: empty_def)
wenzelm@11979
   489
wenzelm@11979
   490
lemma emptyE [elim!]: "a : {} ==> P"
wenzelm@11979
   491
  by simp
wenzelm@11979
   492
wenzelm@11979
   493
lemma empty_subsetI [iff]: "{} <= A"
wenzelm@11979
   494
    -- {* One effect is to delete the ASSUMPTION @{prop "{} <= A"} *}
wenzelm@11979
   495
  by blast
wenzelm@11979
   496
wenzelm@11979
   497
lemma equals0I: "(!!y. y:A ==> False) ==> A = {}"
wenzelm@11979
   498
  by blast
wenzelm@2388
   499
wenzelm@11979
   500
lemma equals0D: "A={} ==> a ~: A"
wenzelm@11979
   501
    -- {* Use for reasoning about disjointness: @{prop "A Int B = {}"} *}
wenzelm@11979
   502
  by blast
wenzelm@11979
   503
wenzelm@11979
   504
lemma ball_empty [simp]: "Ball {} P = True"
wenzelm@11979
   505
  by (simp add: Ball_def)
wenzelm@11979
   506
wenzelm@11979
   507
lemma bex_empty [simp]: "Bex {} P = False"
wenzelm@11979
   508
  by (simp add: Bex_def)
wenzelm@11979
   509
wenzelm@11979
   510
lemma UNIV_not_empty [iff]: "UNIV ~= {}"
wenzelm@11979
   511
  by (blast elim: equalityE)
wenzelm@11979
   512
wenzelm@11979
   513
wenzelm@12023
   514
subsubsection {* The Powerset operator -- Pow *}
wenzelm@11979
   515
wenzelm@11979
   516
lemma Pow_iff [iff]: "(A : Pow B) = (A <= B)"
wenzelm@11979
   517
  by (simp add: Pow_def)
wenzelm@11979
   518
wenzelm@11979
   519
lemma PowI: "A <= B ==> A : Pow B"
wenzelm@11979
   520
  by (simp add: Pow_def)
wenzelm@11979
   521
wenzelm@11979
   522
lemma PowD: "A : Pow B ==> A <= B"
wenzelm@11979
   523
  by (simp add: Pow_def)
wenzelm@11979
   524
wenzelm@11979
   525
lemma Pow_bottom: "{}: Pow B"
wenzelm@11979
   526
  by simp
wenzelm@11979
   527
wenzelm@11979
   528
lemma Pow_top: "A : Pow A"
wenzelm@11979
   529
  by (simp add: subset_refl)
wenzelm@2684
   530
wenzelm@2388
   531
wenzelm@11979
   532
subsubsection {* Set complement *}
wenzelm@11979
   533
wenzelm@11979
   534
lemma Compl_iff [simp]: "(c : -A) = (c~:A)"
wenzelm@11979
   535
  by (unfold Compl_def) blast
wenzelm@11979
   536
wenzelm@11979
   537
lemma ComplI [intro!]: "(c:A ==> False) ==> c : -A"
wenzelm@11979
   538
  by (unfold Compl_def) blast
wenzelm@11979
   539
wenzelm@11979
   540
text {*
wenzelm@11979
   541
  \medskip This form, with negated conclusion, works well with the
wenzelm@11979
   542
  Classical prover.  Negated assumptions behave like formulae on the
wenzelm@11979
   543
  right side of the notional turnstile ... *}
wenzelm@11979
   544
wenzelm@11979
   545
lemma ComplD: "c : -A ==> c~:A"
wenzelm@11979
   546
  by (unfold Compl_def) blast
wenzelm@11979
   547
wenzelm@11979
   548
lemmas ComplE [elim!] = ComplD [elim_format]
wenzelm@11979
   549
wenzelm@11979
   550
wenzelm@11979
   551
subsubsection {* Binary union -- Un *}
clasohm@923
   552
wenzelm@11979
   553
lemma Un_iff [simp]: "(c : A Un B) = (c:A | c:B)"
wenzelm@11979
   554
  by (unfold Un_def) blast
wenzelm@11979
   555
wenzelm@11979
   556
lemma UnI1 [elim?]: "c:A ==> c : A Un B"
wenzelm@11979
   557
  by simp
wenzelm@11979
   558
wenzelm@11979
   559
lemma UnI2 [elim?]: "c:B ==> c : A Un B"
wenzelm@11979
   560
  by simp
clasohm@923
   561
wenzelm@11979
   562
text {*
wenzelm@11979
   563
  \medskip Classical introduction rule: no commitment to @{prop A} vs
wenzelm@11979
   564
  @{prop B}.
wenzelm@11979
   565
*}
wenzelm@11979
   566
wenzelm@11979
   567
lemma UnCI [intro!]: "(c~:B ==> c:A) ==> c : A Un B"
wenzelm@11979
   568
  by auto
wenzelm@11979
   569
wenzelm@11979
   570
lemma UnE [elim!]: "c : A Un B ==> (c:A ==> P) ==> (c:B ==> P) ==> P"
wenzelm@11979
   571
  by (unfold Un_def) blast
wenzelm@11979
   572
wenzelm@11979
   573
wenzelm@12023
   574
subsubsection {* Binary intersection -- Int *}
clasohm@923
   575
wenzelm@11979
   576
lemma Int_iff [simp]: "(c : A Int B) = (c:A & c:B)"
wenzelm@11979
   577
  by (unfold Int_def) blast
wenzelm@11979
   578
wenzelm@11979
   579
lemma IntI [intro!]: "c:A ==> c:B ==> c : A Int B"
wenzelm@11979
   580
  by simp
wenzelm@11979
   581
wenzelm@11979
   582
lemma IntD1: "c : A Int B ==> c:A"
wenzelm@11979
   583
  by simp
wenzelm@11979
   584
wenzelm@11979
   585
lemma IntD2: "c : A Int B ==> c:B"
wenzelm@11979
   586
  by simp
wenzelm@11979
   587
wenzelm@11979
   588
lemma IntE [elim!]: "c : A Int B ==> (c:A ==> c:B ==> P) ==> P"
wenzelm@11979
   589
  by simp
wenzelm@11979
   590
wenzelm@11979
   591
wenzelm@12023
   592
subsubsection {* Set difference *}
wenzelm@11979
   593
wenzelm@11979
   594
lemma Diff_iff [simp]: "(c : A - B) = (c:A & c~:B)"
wenzelm@11979
   595
  by (unfold set_diff_def) blast
clasohm@923
   596
wenzelm@11979
   597
lemma DiffI [intro!]: "c : A ==> c ~: B ==> c : A - B"
wenzelm@11979
   598
  by simp
wenzelm@11979
   599
wenzelm@11979
   600
lemma DiffD1: "c : A - B ==> c : A"
wenzelm@11979
   601
  by simp
wenzelm@11979
   602
wenzelm@11979
   603
lemma DiffD2: "c : A - B ==> c : B ==> P"
wenzelm@11979
   604
  by simp
wenzelm@11979
   605
wenzelm@11979
   606
lemma DiffE [elim!]: "c : A - B ==> (c:A ==> c~:B ==> P) ==> P"
wenzelm@11979
   607
  by simp
wenzelm@11979
   608
wenzelm@11979
   609
wenzelm@11979
   610
subsubsection {* Augmenting a set -- insert *}
wenzelm@11979
   611
wenzelm@11979
   612
lemma insert_iff [simp]: "(a : insert b A) = (a = b | a:A)"
wenzelm@11979
   613
  by (unfold insert_def) blast
wenzelm@11979
   614
wenzelm@11979
   615
lemma insertI1: "a : insert a B"
wenzelm@11979
   616
  by simp
wenzelm@11979
   617
wenzelm@11979
   618
lemma insertI2: "a : B ==> a : insert b B"
wenzelm@11979
   619
  by simp
clasohm@923
   620
wenzelm@11979
   621
lemma insertE [elim!]: "a : insert b A ==> (a = b ==> P) ==> (a:A ==> P) ==> P"
wenzelm@11979
   622
  by (unfold insert_def) blast
wenzelm@11979
   623
wenzelm@11979
   624
lemma insertCI [intro!]: "(a~:B ==> a = b) ==> a: insert b B"
wenzelm@11979
   625
  -- {* Classical introduction rule. *}
wenzelm@11979
   626
  by auto
wenzelm@11979
   627
wenzelm@11979
   628
lemma subset_insert_iff: "(A <= insert x B) = (if x:A then A - {x} <= B else A <= B)"
wenzelm@11979
   629
  by auto
wenzelm@11979
   630
wenzelm@11979
   631
wenzelm@11979
   632
subsubsection {* Singletons, using insert *}
wenzelm@11979
   633
wenzelm@11979
   634
lemma singletonI [intro!]: "a : {a}"
wenzelm@11979
   635
    -- {* Redundant? But unlike @{text insertCI}, it proves the subgoal immediately! *}
wenzelm@11979
   636
  by (rule insertI1)
wenzelm@11979
   637
wenzelm@11979
   638
lemma singletonD: "b : {a} ==> b = a"
wenzelm@11979
   639
  by blast
wenzelm@11979
   640
wenzelm@11979
   641
lemmas singletonE [elim!] = singletonD [elim_format]
wenzelm@11979
   642
wenzelm@11979
   643
lemma singleton_iff: "(b : {a}) = (b = a)"
wenzelm@11979
   644
  by blast
wenzelm@11979
   645
wenzelm@11979
   646
lemma singleton_inject [dest!]: "{a} = {b} ==> a = b"
wenzelm@11979
   647
  by blast
wenzelm@11979
   648
wenzelm@11979
   649
lemma singleton_insert_inj_eq [iff]: "({b} = insert a A) = (a = b & A <= {b})"
wenzelm@11979
   650
  by blast
wenzelm@11979
   651
wenzelm@11979
   652
lemma singleton_insert_inj_eq' [iff]: "(insert a A = {b}) = (a = b & A <= {b})"
wenzelm@11979
   653
  by blast
wenzelm@11979
   654
wenzelm@11979
   655
lemma subset_singletonD: "A <= {x} ==> A={} | A = {x}"
wenzelm@11979
   656
  by fast
wenzelm@11979
   657
wenzelm@11979
   658
lemma singleton_conv [simp]: "{x. x = a} = {a}"
wenzelm@11979
   659
  by blast
wenzelm@11979
   660
wenzelm@11979
   661
lemma singleton_conv2 [simp]: "{x. a = x} = {a}"
wenzelm@11979
   662
  by blast
clasohm@923
   663
wenzelm@11979
   664
lemma diff_single_insert: "A - {x} <= B ==> x : A ==> A <= insert x B"
wenzelm@11979
   665
  by blast
wenzelm@11979
   666
wenzelm@11979
   667
wenzelm@11979
   668
subsubsection {* Unions of families *}
wenzelm@11979
   669
wenzelm@11979
   670
text {*
wenzelm@11979
   671
  @{term [source] "UN x:A. B x"} is @{term "Union (B`A)"}.
wenzelm@11979
   672
*}
wenzelm@11979
   673
wenzelm@11979
   674
lemma UN_iff [simp]: "(b: (UN x:A. B x)) = (EX x:A. b: B x)"
wenzelm@11979
   675
  by (unfold UNION_def) blast
wenzelm@11979
   676
wenzelm@11979
   677
lemma UN_I [intro]: "a:A ==> b: B a ==> b: (UN x:A. B x)"
wenzelm@11979
   678
  -- {* The order of the premises presupposes that @{term A} is rigid;
wenzelm@11979
   679
    @{term b} may be flexible. *}
wenzelm@11979
   680
  by auto
wenzelm@11979
   681
wenzelm@11979
   682
lemma UN_E [elim!]: "b : (UN x:A. B x) ==> (!!x. x:A ==> b: B x ==> R) ==> R"
wenzelm@11979
   683
  by (unfold UNION_def) blast
clasohm@923
   684
wenzelm@11979
   685
lemma UN_cong [cong]:
wenzelm@11979
   686
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (UN x:A. C x) = (UN x:B. D x)"
wenzelm@11979
   687
  by (simp add: UNION_def)
wenzelm@11979
   688
wenzelm@11979
   689
wenzelm@11979
   690
subsubsection {* Intersections of families *}
wenzelm@11979
   691
wenzelm@11979
   692
text {* @{term [source] "INT x:A. B x"} is @{term "Inter (B`A)"}. *}
wenzelm@11979
   693
wenzelm@11979
   694
lemma INT_iff [simp]: "(b: (INT x:A. B x)) = (ALL x:A. b: B x)"
wenzelm@11979
   695
  by (unfold INTER_def) blast
clasohm@923
   696
wenzelm@11979
   697
lemma INT_I [intro!]: "(!!x. x:A ==> b: B x) ==> b : (INT x:A. B x)"
wenzelm@11979
   698
  by (unfold INTER_def) blast
wenzelm@11979
   699
wenzelm@11979
   700
lemma INT_D [elim]: "b : (INT x:A. B x) ==> a:A ==> b: B a"
wenzelm@11979
   701
  by auto
wenzelm@11979
   702
wenzelm@11979
   703
lemma INT_E [elim]: "b : (INT x:A. B x) ==> (b: B a ==> R) ==> (a~:A ==> R) ==> R"
wenzelm@11979
   704
  -- {* "Classical" elimination -- by the Excluded Middle on @{prop "a:A"}. *}
wenzelm@11979
   705
  by (unfold INTER_def) blast
wenzelm@11979
   706
wenzelm@11979
   707
lemma INT_cong [cong]:
wenzelm@11979
   708
    "A = B ==> (!!x. x:B ==> C x = D x) ==> (INT x:A. C x) = (INT x:B. D x)"
wenzelm@11979
   709
  by (simp add: INTER_def)
wenzelm@7238
   710
clasohm@923
   711
wenzelm@11979
   712
subsubsection {* Union *}
wenzelm@11979
   713
wenzelm@11979
   714
lemma Union_iff [simp]: "(A : Union C) = (EX X:C. A:X)"
wenzelm@11979
   715
  by (unfold Union_def) blast
wenzelm@11979
   716
wenzelm@11979
   717
lemma UnionI [intro]: "X:C ==> A:X ==> A : Union C"
wenzelm@11979
   718
  -- {* The order of the premises presupposes that @{term C} is rigid;
wenzelm@11979
   719
    @{term A} may be flexible. *}
wenzelm@11979
   720
  by auto
wenzelm@11979
   721
wenzelm@11979
   722
lemma UnionE [elim!]: "A : Union C ==> (!!X. A:X ==> X:C ==> R) ==> R"
wenzelm@11979
   723
  by (unfold Union_def) blast
wenzelm@11979
   724
wenzelm@11979
   725
wenzelm@11979
   726
subsubsection {* Inter *}
wenzelm@11979
   727
wenzelm@11979
   728
lemma Inter_iff [simp]: "(A : Inter C) = (ALL X:C. A:X)"
wenzelm@11979
   729
  by (unfold Inter_def) blast
wenzelm@11979
   730
wenzelm@11979
   731
lemma InterI [intro!]: "(!!X. X:C ==> A:X) ==> A : Inter C"
wenzelm@11979
   732
  by (simp add: Inter_def)
wenzelm@11979
   733
wenzelm@11979
   734
text {*
wenzelm@11979
   735
  \medskip A ``destruct'' rule -- every @{term X} in @{term C}
wenzelm@11979
   736
  contains @{term A} as an element, but @{prop "A:X"} can hold when
wenzelm@11979
   737
  @{prop "X:C"} does not!  This rule is analogous to @{text spec}.
wenzelm@11979
   738
*}
wenzelm@11979
   739
wenzelm@11979
   740
lemma InterD [elim]: "A : Inter C ==> X:C ==> A:X"
wenzelm@11979
   741
  by auto
wenzelm@11979
   742
wenzelm@11979
   743
lemma InterE [elim]: "A : Inter C ==> (X~:C ==> R) ==> (A:X ==> R) ==> R"
wenzelm@11979
   744
  -- {* ``Classical'' elimination rule -- does not require proving
wenzelm@11979
   745
    @{prop "X:C"}. *}
wenzelm@11979
   746
  by (unfold Inter_def) blast
wenzelm@11979
   747
wenzelm@11979
   748
text {*
wenzelm@11979
   749
  \medskip Image of a set under a function.  Frequently @{term b} does
wenzelm@11979
   750
  not have the syntactic form of @{term "f x"}.
wenzelm@11979
   751
*}
wenzelm@11979
   752
wenzelm@11979
   753
lemma image_eqI [simp, intro]: "b = f x ==> x:A ==> b : f`A"
wenzelm@11979
   754
  by (unfold image_def) blast
wenzelm@11979
   755
wenzelm@11979
   756
lemma imageI: "x : A ==> f x : f ` A"
wenzelm@11979
   757
  by (rule image_eqI) (rule refl)
wenzelm@11979
   758
wenzelm@11979
   759
lemma rev_image_eqI: "x:A ==> b = f x ==> b : f`A"
wenzelm@11979
   760
  -- {* This version's more effective when we already have the
wenzelm@11979
   761
    required @{term x}. *}
wenzelm@11979
   762
  by (unfold image_def) blast
wenzelm@11979
   763
wenzelm@11979
   764
lemma imageE [elim!]:
wenzelm@11979
   765
  "b : (%x. f x)`A ==> (!!x. b = f x ==> x:A ==> P) ==> P"
wenzelm@11979
   766
  -- {* The eta-expansion gives variable-name preservation. *}
wenzelm@11979
   767
  by (unfold image_def) blast
wenzelm@11979
   768
wenzelm@11979
   769
lemma image_Un: "f`(A Un B) = f`A Un f`B"
wenzelm@11979
   770
  by blast
wenzelm@11979
   771
wenzelm@11979
   772
lemma image_iff: "(z : f`A) = (EX x:A. z = f x)"
wenzelm@11979
   773
  by blast
wenzelm@11979
   774
wenzelm@11979
   775
lemma image_subset_iff: "(f`A <= B) = (ALL x:A. f x: B)"
wenzelm@11979
   776
  -- {* This rewrite rule would confuse users if made default. *}
wenzelm@11979
   777
  by blast
wenzelm@11979
   778
wenzelm@11979
   779
lemma subset_image_iff: "(B <= f ` A) = (EX AA. AA <= A & B = f ` AA)"
wenzelm@11979
   780
  apply safe
wenzelm@11979
   781
   prefer 2 apply fast
wenzelm@11979
   782
  apply (rule_tac x = "{a. a : A & f a : B}" in exI)
wenzelm@11979
   783
  apply fast
wenzelm@11979
   784
  done
wenzelm@11979
   785
wenzelm@11979
   786
lemma image_subsetI: "(!!x. x:A ==> f x : B) ==> f`A <= B"
wenzelm@11979
   787
  -- {* Replaces the three steps @{text subsetI}, @{text imageE},
wenzelm@11979
   788
    @{text hypsubst}, but breaks too many existing proofs. *}
wenzelm@11979
   789
  by blast
wenzelm@11979
   790
wenzelm@11979
   791
text {*
wenzelm@11979
   792
  \medskip Range of a function -- just a translation for image!
wenzelm@11979
   793
*}
wenzelm@11979
   794
wenzelm@11979
   795
lemma range_eqI: "b = f x ==> b : range f"
wenzelm@11979
   796
  by simp
wenzelm@11979
   797
wenzelm@11979
   798
lemma rangeI: "f x : range f"
wenzelm@11979
   799
  by simp
wenzelm@11979
   800
wenzelm@11979
   801
lemma rangeE [elim?]: "b : range (%x. f x) ==> (!!x. b = f x ==> P) ==> P"
wenzelm@11979
   802
  by blast
wenzelm@11979
   803
wenzelm@11979
   804
wenzelm@11979
   805
subsubsection {* Set reasoning tools *}
wenzelm@11979
   806
wenzelm@11979
   807
text {*
wenzelm@11979
   808
  Rewrite rules for boolean case-splitting: faster than @{text
wenzelm@11979
   809
  "split_if [split]"}.
wenzelm@11979
   810
*}
wenzelm@11979
   811
wenzelm@11979
   812
lemma split_if_eq1: "((if Q then x else y) = b) = ((Q --> x = b) & (~ Q --> y = b))"
wenzelm@11979
   813
  by (rule split_if)
wenzelm@11979
   814
wenzelm@11979
   815
lemma split_if_eq2: "(a = (if Q then x else y)) = ((Q --> a = x) & (~ Q --> a = y))"
wenzelm@11979
   816
  by (rule split_if)
wenzelm@11979
   817
wenzelm@11979
   818
text {*
wenzelm@11979
   819
  Split ifs on either side of the membership relation.  Not for @{text
wenzelm@11979
   820
  "[simp]"} -- can cause goals to blow up!
wenzelm@11979
   821
*}
wenzelm@11979
   822
wenzelm@11979
   823
lemma split_if_mem1: "((if Q then x else y) : b) = ((Q --> x : b) & (~ Q --> y : b))"
wenzelm@11979
   824
  by (rule split_if)
wenzelm@11979
   825
wenzelm@11979
   826
lemma split_if_mem2: "(a : (if Q then x else y)) = ((Q --> a : x) & (~ Q --> a : y))"
wenzelm@11979
   827
  by (rule split_if)
wenzelm@11979
   828
wenzelm@11979
   829
lemmas split_ifs = if_bool_eq_conj split_if_eq1 split_if_eq2 split_if_mem1 split_if_mem2
wenzelm@11979
   830
wenzelm@11979
   831
lemmas mem_simps =
wenzelm@11979
   832
  insert_iff empty_iff Un_iff Int_iff Compl_iff Diff_iff
wenzelm@11979
   833
  mem_Collect_eq UN_iff Union_iff INT_iff Inter_iff
wenzelm@11979
   834
  -- {* Each of these has ALREADY been added @{text "[simp]"} above. *}
wenzelm@11979
   835
wenzelm@11979
   836
(*Would like to add these, but the existing code only searches for the
wenzelm@11979
   837
  outer-level constant, which in this case is just "op :"; we instead need
wenzelm@11979
   838
  to use term-nets to associate patterns with rules.  Also, if a rule fails to
wenzelm@11979
   839
  apply, then the formula should be kept.
wenzelm@11979
   840
  [("uminus", Compl_iff RS iffD1), ("op -", [Diff_iff RS iffD1]),
wenzelm@11979
   841
   ("op Int", [IntD1,IntD2]),
wenzelm@11979
   842
   ("Collect", [CollectD]), ("Inter", [InterD]), ("INTER", [INT_D])]
wenzelm@11979
   843
 *)
wenzelm@11979
   844
wenzelm@11979
   845
ML_setup {*
wenzelm@11979
   846
  val mksimps_pairs = [("Ball", [thm "bspec"])] @ mksimps_pairs;
wenzelm@11979
   847
  simpset_ref() := simpset() setmksimps (mksimps mksimps_pairs);
wenzelm@11979
   848
*}
wenzelm@11979
   849
wenzelm@11979
   850
declare subset_UNIV [simp] subset_refl [simp]
wenzelm@11979
   851
wenzelm@11979
   852
wenzelm@11979
   853
subsubsection {* The ``proper subset'' relation *}
wenzelm@11979
   854
wenzelm@11979
   855
lemma psubsetI [intro!]: "(A::'a set) <= B ==> A ~= B ==> A < B"
wenzelm@11979
   856
  by (unfold psubset_def) blast
wenzelm@11979
   857
wenzelm@11979
   858
lemma psubset_insert_iff:
wenzelm@11979
   859
  "(A < insert x B) = (if x:B then A < B else if x:A then A - {x} < B else A <= B)"
wenzelm@11979
   860
  apply (simp add: psubset_def subset_insert_iff)
wenzelm@11979
   861
  apply blast
wenzelm@11979
   862
  done
wenzelm@11979
   863
wenzelm@11979
   864
lemma psubset_eq: "((A::'a set) < B) = (A <= B & A ~= B)"
wenzelm@11979
   865
  by (simp only: psubset_def)
wenzelm@11979
   866
wenzelm@11979
   867
lemma psubset_imp_subset: "(A::'a set) < B ==> A <= B"
wenzelm@11979
   868
  by (simp add: psubset_eq)
wenzelm@11979
   869
wenzelm@11979
   870
lemma psubset_subset_trans: "(A::'a set) < B ==> B <= C ==> A < C"
wenzelm@11979
   871
  by (auto simp add: psubset_eq)
wenzelm@11979
   872
wenzelm@11979
   873
lemma subset_psubset_trans: "(A::'a set) <= B ==> B < C ==> A < C"
wenzelm@11979
   874
  by (auto simp add: psubset_eq)
wenzelm@11979
   875
wenzelm@11979
   876
lemma psubset_imp_ex_mem: "A < B ==> EX b. b : (B - A)"
wenzelm@11979
   877
  by (unfold psubset_def) blast
wenzelm@11979
   878
wenzelm@11979
   879
lemma atomize_ball:
wenzelm@11979
   880
    "(!!x. x:A ==> P x) == Trueprop (ALL x:A. P x)"
wenzelm@11979
   881
  by (simp only: Ball_def atomize_all atomize_imp)
wenzelm@11979
   882
wenzelm@11979
   883
declare atomize_ball [symmetric, rulify]
wenzelm@11979
   884
wenzelm@11979
   885
wenzelm@11979
   886
subsection {* Further set-theory lemmas *}
wenzelm@11979
   887
wenzelm@11979
   888
use "subset.ML"
wenzelm@11979
   889
use "equalities.ML"
wenzelm@11979
   890
use "mono.ML"
wenzelm@11979
   891
wenzelm@11982
   892
lemma Least_mono:
wenzelm@11982
   893
  "mono (f::'a::order => 'b::order) ==> EX x:S. ALL y:S. x <= y
wenzelm@11982
   894
    ==> (LEAST y. y : f ` S) = f (LEAST x. x : S)"
wenzelm@11982
   895
    -- {* Courtesy of Stephan Merz *}
wenzelm@11982
   896
  apply clarify
wenzelm@11982
   897
  apply (erule_tac P = "%x. x : S" in LeastI2)
wenzelm@11982
   898
   apply fast
wenzelm@11982
   899
  apply (rule LeastI2)
wenzelm@11982
   900
  apply (auto elim: monoD intro!: order_antisym)
wenzelm@11982
   901
  done
wenzelm@11982
   902
wenzelm@12020
   903
wenzelm@12257
   904
subsection {* Inverse image of a function *}
wenzelm@12257
   905
wenzelm@12257
   906
constdefs
wenzelm@12257
   907
  vimage :: "('a => 'b) => 'b set => 'a set"    (infixr "-`" 90)
wenzelm@12257
   908
  "f -` B == {x. f x : B}"
wenzelm@12257
   909
wenzelm@12257
   910
wenzelm@12257
   911
subsubsection {* Basic rules *}
wenzelm@12257
   912
wenzelm@12257
   913
lemma vimage_eq [simp]: "(a : f -` B) = (f a : B)"
wenzelm@12257
   914
  by (unfold vimage_def) blast
wenzelm@12257
   915
wenzelm@12257
   916
lemma vimage_singleton_eq: "(a : f -` {b}) = (f a = b)"
wenzelm@12257
   917
  by simp
wenzelm@12257
   918
wenzelm@12257
   919
lemma vimageI [intro]: "f a = b ==> b:B ==> a : f -` B"
wenzelm@12257
   920
  by (unfold vimage_def) blast
wenzelm@12257
   921
wenzelm@12257
   922
lemma vimageI2: "f a : A ==> a : f -` A"
wenzelm@12257
   923
  by (unfold vimage_def) fast
wenzelm@12257
   924
wenzelm@12257
   925
lemma vimageE [elim!]: "a: f -` B ==> (!!x. f a = x ==> x:B ==> P) ==> P"
wenzelm@12257
   926
  by (unfold vimage_def) blast
wenzelm@12257
   927
wenzelm@12257
   928
lemma vimageD: "a : f -` A ==> f a : A"
wenzelm@12257
   929
  by (unfold vimage_def) fast
wenzelm@12257
   930
wenzelm@12257
   931
wenzelm@12257
   932
subsubsection {* Equations *}
wenzelm@12257
   933
wenzelm@12257
   934
lemma vimage_empty [simp]: "f -` {} = {}"
wenzelm@12257
   935
  by blast
wenzelm@12257
   936
wenzelm@12257
   937
lemma vimage_Compl: "f -` (-A) = -(f -` A)"
wenzelm@12257
   938
  by blast
wenzelm@12257
   939
wenzelm@12257
   940
lemma vimage_Un [simp]: "f -` (A Un B) = (f -` A) Un (f -` B)"
wenzelm@12257
   941
  by blast
wenzelm@12257
   942
wenzelm@12257
   943
lemma vimage_Int [simp]: "f -` (A Int B) = (f -` A) Int (f -` B)"
wenzelm@12257
   944
  by fast
wenzelm@12257
   945
wenzelm@12257
   946
lemma vimage_Union: "f -` (Union A) = (UN X:A. f -` X)"
wenzelm@12257
   947
  by blast
wenzelm@12257
   948
wenzelm@12257
   949
lemma vimage_UN: "f-`(UN x:A. B x) = (UN x:A. f -` B x)"
wenzelm@12257
   950
  by blast
wenzelm@12257
   951
wenzelm@12257
   952
lemma vimage_INT: "f-`(INT x:A. B x) = (INT x:A. f -` B x)"
wenzelm@12257
   953
  by blast
wenzelm@12257
   954
wenzelm@12257
   955
lemma vimage_Collect_eq [simp]: "f -` Collect P = {y. P (f y)}"
wenzelm@12257
   956
  by blast
wenzelm@12257
   957
wenzelm@12257
   958
lemma vimage_Collect: "(!!x. P (f x) = Q x) ==> f -` (Collect P) = Collect Q"
wenzelm@12257
   959
  by blast
wenzelm@12257
   960
wenzelm@12257
   961
lemma vimage_insert: "f-`(insert a B) = (f-`{a}) Un (f-`B)"
wenzelm@12257
   962
  -- {* NOT suitable for rewriting because of the recurrence of @{term "{a}"}. *}
wenzelm@12257
   963
  by blast
wenzelm@12257
   964
wenzelm@12257
   965
lemma vimage_Diff: "f -` (A - B) = (f -` A) - (f -` B)"
wenzelm@12257
   966
  by blast
wenzelm@12257
   967
wenzelm@12257
   968
lemma vimage_UNIV [simp]: "f -` UNIV = UNIV"
wenzelm@12257
   969
  by blast
wenzelm@12257
   970
wenzelm@12257
   971
lemma vimage_eq_UN: "f-`B = (UN y: B. f-`{y})"
wenzelm@12257
   972
  -- {* NOT suitable for rewriting *}
wenzelm@12257
   973
  by blast
wenzelm@12257
   974
wenzelm@12257
   975
lemma vimage_mono: "A <= B ==> f -` A <= f -` B"
wenzelm@12257
   976
  -- {* monotonicity *}
wenzelm@12257
   977
  by blast
wenzelm@12257
   978
wenzelm@12257
   979
wenzelm@12023
   980
subsection {* Transitivity rules for calculational reasoning *}
wenzelm@12020
   981
wenzelm@12020
   982
lemma forw_subst: "a = b ==> P b ==> P a"
wenzelm@12020
   983
  by (rule ssubst)
wenzelm@12020
   984
wenzelm@12020
   985
lemma back_subst: "P a ==> a = b ==> P b"
wenzelm@12020
   986
  by (rule subst)
wenzelm@12020
   987
wenzelm@12020
   988
lemma set_rev_mp: "x:A ==> A <= B ==> x:B"
wenzelm@12020
   989
  by (rule subsetD)
wenzelm@12020
   990
wenzelm@12020
   991
lemma set_mp: "A <= B ==> x:A ==> x:B"
wenzelm@12020
   992
  by (rule subsetD)
wenzelm@12020
   993
wenzelm@12020
   994
lemma order_neq_le_trans: "a ~= b ==> (a::'a::order) <= b ==> a < b"
wenzelm@12020
   995
  by (simp add: order_less_le)
wenzelm@12020
   996
wenzelm@12020
   997
lemma order_le_neq_trans: "(a::'a::order) <= b ==> a ~= b ==> a < b"
wenzelm@12020
   998
  by (simp add: order_less_le)
wenzelm@12020
   999
wenzelm@12020
  1000
lemma order_less_asym': "(a::'a::order) < b ==> b < a ==> P"
wenzelm@12020
  1001
  by (rule order_less_asym)
wenzelm@12020
  1002
wenzelm@12020
  1003
lemma ord_le_eq_trans: "a <= b ==> b = c ==> a <= c"
wenzelm@12020
  1004
  by (rule subst)
wenzelm@12020
  1005
wenzelm@12020
  1006
lemma ord_eq_le_trans: "a = b ==> b <= c ==> a <= c"
wenzelm@12020
  1007
  by (rule ssubst)
wenzelm@12020
  1008
wenzelm@12020
  1009
lemma ord_less_eq_trans: "a < b ==> b = c ==> a < c"
wenzelm@12020
  1010
  by (rule subst)
wenzelm@12020
  1011
wenzelm@12020
  1012
lemma ord_eq_less_trans: "a = b ==> b < c ==> a < c"
wenzelm@12020
  1013
  by (rule ssubst)
wenzelm@12020
  1014
wenzelm@12020
  1015
lemma order_less_subst2: "(a::'a::order) < b ==> f b < (c::'c::order) ==>
wenzelm@12020
  1016
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  1017
proof -
wenzelm@12020
  1018
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1019
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  1020
  also assume "f b < c"
wenzelm@12020
  1021
  finally (order_less_trans) show ?thesis .
wenzelm@12020
  1022
qed
wenzelm@12020
  1023
wenzelm@12020
  1024
lemma order_less_subst1: "(a::'a::order) < f b ==> (b::'b::order) < c ==>
wenzelm@12020
  1025
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  1026
proof -
wenzelm@12020
  1027
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1028
  assume "a < f b"
wenzelm@12020
  1029
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  1030
  finally (order_less_trans) show ?thesis .
wenzelm@12020
  1031
qed
wenzelm@12020
  1032
wenzelm@12020
  1033
lemma order_le_less_subst2: "(a::'a::order) <= b ==> f b < (c::'c::order) ==>
wenzelm@12020
  1034
  (!!x y. x <= y ==> f x <= f y) ==> f a < c"
wenzelm@12020
  1035
proof -
wenzelm@12020
  1036
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1037
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  1038
  also assume "f b < c"
wenzelm@12020
  1039
  finally (order_le_less_trans) show ?thesis .
wenzelm@12020
  1040
qed
wenzelm@12020
  1041
wenzelm@12020
  1042
lemma order_le_less_subst1: "(a::'a::order) <= f b ==> (b::'b::order) < c ==>
wenzelm@12020
  1043
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  1044
proof -
wenzelm@12020
  1045
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1046
  assume "a <= f b"
wenzelm@12020
  1047
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  1048
  finally (order_le_less_trans) show ?thesis .
wenzelm@12020
  1049
qed
wenzelm@12020
  1050
wenzelm@12020
  1051
lemma order_less_le_subst2: "(a::'a::order) < b ==> f b <= (c::'c::order) ==>
wenzelm@12020
  1052
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  1053
proof -
wenzelm@12020
  1054
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1055
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  1056
  also assume "f b <= c"
wenzelm@12020
  1057
  finally (order_less_le_trans) show ?thesis .
wenzelm@12020
  1058
qed
wenzelm@12020
  1059
wenzelm@12020
  1060
lemma order_less_le_subst1: "(a::'a::order) < f b ==> (b::'b::order) <= c ==>
wenzelm@12020
  1061
  (!!x y. x <= y ==> f x <= f y) ==> a < f c"
wenzelm@12020
  1062
proof -
wenzelm@12020
  1063
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1064
  assume "a < f b"
wenzelm@12020
  1065
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  1066
  finally (order_less_le_trans) show ?thesis .
wenzelm@12020
  1067
qed
wenzelm@12020
  1068
wenzelm@12020
  1069
lemma order_subst1: "(a::'a::order) <= f b ==> (b::'b::order) <= c ==>
wenzelm@12020
  1070
  (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
wenzelm@12020
  1071
proof -
wenzelm@12020
  1072
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1073
  assume "a <= f b"
wenzelm@12020
  1074
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  1075
  finally (order_trans) show ?thesis .
wenzelm@12020
  1076
qed
wenzelm@12020
  1077
wenzelm@12020
  1078
lemma order_subst2: "(a::'a::order) <= b ==> f b <= (c::'c::order) ==>
wenzelm@12020
  1079
  (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
wenzelm@12020
  1080
proof -
wenzelm@12020
  1081
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1082
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  1083
  also assume "f b <= c"
wenzelm@12020
  1084
  finally (order_trans) show ?thesis .
wenzelm@12020
  1085
qed
wenzelm@12020
  1086
wenzelm@12020
  1087
lemma ord_le_eq_subst: "a <= b ==> f b = c ==>
wenzelm@12020
  1088
  (!!x y. x <= y ==> f x <= f y) ==> f a <= c"
wenzelm@12020
  1089
proof -
wenzelm@12020
  1090
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1091
  assume "a <= b" hence "f a <= f b" by (rule r)
wenzelm@12020
  1092
  also assume "f b = c"
wenzelm@12020
  1093
  finally (ord_le_eq_trans) show ?thesis .
wenzelm@12020
  1094
qed
wenzelm@12020
  1095
wenzelm@12020
  1096
lemma ord_eq_le_subst: "a = f b ==> b <= c ==>
wenzelm@12020
  1097
  (!!x y. x <= y ==> f x <= f y) ==> a <= f c"
wenzelm@12020
  1098
proof -
wenzelm@12020
  1099
  assume r: "!!x y. x <= y ==> f x <= f y"
wenzelm@12020
  1100
  assume "a = f b"
wenzelm@12020
  1101
  also assume "b <= c" hence "f b <= f c" by (rule r)
wenzelm@12020
  1102
  finally (ord_eq_le_trans) show ?thesis .
wenzelm@12020
  1103
qed
wenzelm@12020
  1104
wenzelm@12020
  1105
lemma ord_less_eq_subst: "a < b ==> f b = c ==>
wenzelm@12020
  1106
  (!!x y. x < y ==> f x < f y) ==> f a < c"
wenzelm@12020
  1107
proof -
wenzelm@12020
  1108
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1109
  assume "a < b" hence "f a < f b" by (rule r)
wenzelm@12020
  1110
  also assume "f b = c"
wenzelm@12020
  1111
  finally (ord_less_eq_trans) show ?thesis .
wenzelm@12020
  1112
qed
wenzelm@12020
  1113
wenzelm@12020
  1114
lemma ord_eq_less_subst: "a = f b ==> b < c ==>
wenzelm@12020
  1115
  (!!x y. x < y ==> f x < f y) ==> a < f c"
wenzelm@12020
  1116
proof -
wenzelm@12020
  1117
  assume r: "!!x y. x < y ==> f x < f y"
wenzelm@12020
  1118
  assume "a = f b"
wenzelm@12020
  1119
  also assume "b < c" hence "f b < f c" by (rule r)
wenzelm@12020
  1120
  finally (ord_eq_less_trans) show ?thesis .
wenzelm@12020
  1121
qed
wenzelm@12020
  1122
wenzelm@12020
  1123
text {*
wenzelm@12020
  1124
  Note that this list of rules is in reverse order of priorities.
wenzelm@12020
  1125
*}
wenzelm@12020
  1126
wenzelm@12020
  1127
lemmas basic_trans_rules [trans] =
wenzelm@12020
  1128
  order_less_subst2
wenzelm@12020
  1129
  order_less_subst1
wenzelm@12020
  1130
  order_le_less_subst2
wenzelm@12020
  1131
  order_le_less_subst1
wenzelm@12020
  1132
  order_less_le_subst2
wenzelm@12020
  1133
  order_less_le_subst1
wenzelm@12020
  1134
  order_subst2
wenzelm@12020
  1135
  order_subst1
wenzelm@12020
  1136
  ord_le_eq_subst
wenzelm@12020
  1137
  ord_eq_le_subst
wenzelm@12020
  1138
  ord_less_eq_subst
wenzelm@12020
  1139
  ord_eq_less_subst
wenzelm@12020
  1140
  forw_subst
wenzelm@12020
  1141
  back_subst
wenzelm@12020
  1142
  rev_mp
wenzelm@12020
  1143
  mp
wenzelm@12020
  1144
  set_rev_mp
wenzelm@12020
  1145
  set_mp
wenzelm@12020
  1146
  order_neq_le_trans
wenzelm@12020
  1147
  order_le_neq_trans
wenzelm@12020
  1148
  order_less_trans
wenzelm@12020
  1149
  order_less_asym'
wenzelm@12020
  1150
  order_le_less_trans
wenzelm@12020
  1151
  order_less_le_trans
wenzelm@12020
  1152
  order_trans
wenzelm@12020
  1153
  order_antisym
wenzelm@12020
  1154
  ord_le_eq_trans
wenzelm@12020
  1155
  ord_eq_le_trans
wenzelm@12020
  1156
  ord_less_eq_trans
wenzelm@12020
  1157
  ord_eq_less_trans
wenzelm@12020
  1158
  trans
wenzelm@12020
  1159
wenzelm@11979
  1160
end