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