src/HOL/Set.thy
changeset 4159 4aff9b7e5597
parent 4151 5c19cd418c33
child 4761 1681b32dd134
equal deleted inserted replaced
4158:47c7490c74fe 4159:4aff9b7e5597
    23 syntax
    23 syntax
    24   "op :"        :: ['a, 'a set] => bool             ("op :")
    24   "op :"        :: ['a, 'a set] => bool             ("op :")
    25 
    25 
    26 consts
    26 consts
    27   "{}"          :: 'a set                           ("{}")
    27   "{}"          :: 'a set                           ("{}")
       
    28   UNIV          :: 'a set
    28   insert        :: ['a, 'a set] => 'a set
    29   insert        :: ['a, 'a set] => 'a set
    29   Collect       :: ('a => bool) => 'a set               (*comprehension*)
    30   Collect       :: ('a => bool) => 'a set               (*comprehension*)
    30   Compl         :: ('a set) => 'a set                   (*complement*)
    31   Compl         :: ('a set) => 'a set                   (*complement*)
    31   Int           :: ['a set, 'a set] => 'a set       (infixl 70)
    32   Int           :: ['a set, 'a set] => 'a set       (infixl 70)
    32   Un            :: ['a set, 'a set] => 'a set       (infixl 65)
    33   Un            :: ['a set, 'a set] => 'a set       (infixl 65)
    33   UNION, INTER  :: ['a set, 'a => 'b set] => 'b set     (*general*)
    34   UNION, INTER  :: ['a set, 'a => 'b set] => 'b set     (*general*)
    34   UNION1        :: ['a => 'b set] => 'b set         (binder "UN " 10)
       
    35   INTER1        :: ['a => 'b set] => 'b set         (binder "INT " 10)
       
    36   Union, Inter  :: (('a set) set) => 'a set             (*of a set*)
    35   Union, Inter  :: (('a set) set) => 'a set             (*of a set*)
    37   Pow           :: 'a set => 'a set set                 (*powerset*)
    36   Pow           :: 'a set => 'a set set                 (*powerset*)
    38   range         :: ('a => 'b) => 'b set                 (*of function*)
    37   range         :: ('a => 'b) => 'b set                 (*of function*)
    39   Ball, Bex     :: ['a set, 'a => bool] => bool         (*bounded quantifiers*)
    38   Ball, Bex     :: ['a set, 'a => bool] => bool         (*bounded quantifiers*)
    40   "``"          :: ['a => 'b, 'a set] => ('b set)   (infixr 90)
    39   "``"          :: ['a => 'b, 'a set] => ('b set)   (infixr 90)
    45 
    44 
    46 (** Additional concrete syntax **)
    45 (** Additional concrete syntax **)
    47 
    46 
    48 syntax
    47 syntax
    49 
    48 
    50   UNIV          :: 'a set
       
    51 
       
    52   (* Infix syntax for non-membership *)
    49   (* Infix syntax for non-membership *)
    53 
    50 
    54   "op ~:"       :: ['a, 'a set] => bool               ("op ~:")
    51   "op ~:"       :: ['a, 'a set] => bool               ("op ~:")
    55   "op ~:"       :: ['a, 'a set] => bool               ("(_/ ~: _)" [50, 51] 50)
    52   "op ~:"       :: ['a, 'a set] => bool               ("(_/ ~: _)" [50, 51] 50)
    56 
    53 
    58 
    55 
    59   "@Coll"       :: [pttrn, bool] => 'a set            ("(1{_./ _})")
    56   "@Coll"       :: [pttrn, bool] => 'a set            ("(1{_./ _})")
    60   "@SetCompr"   :: ['a, idts, bool] => 'a set         ("(1{_ |/_./ _})")
    57   "@SetCompr"   :: ['a, idts, bool] => 'a set         ("(1{_ |/_./ _})")
    61 
    58 
    62   (* Big Intersection / Union *)
    59   (* Big Intersection / Union *)
       
    60 
       
    61   INTER1        :: [pttrns, 'a => 'b set] => 'b set   ("(3INT _./ _)" 10)
       
    62   UNION1        :: [pttrns, 'a => 'b set] => 'b set   ("(3UN _./ _)" 10)
    63 
    63 
    64   "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3INT _:_./ _)" 10)
    64   "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3INT _:_./ _)" 10)
    65   "@UNION"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3UN _:_./ _)" 10)
    65   "@UNION"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3UN _:_./ _)" 10)
    66 
    66 
    67   (* Bounded Quantifiers *)
    67   (* Bounded Quantifiers *)
    70   "@Bex"        :: [pttrn, 'a set, bool] => bool      ("(3? _:_./ _)" [0, 0, 10] 10)
    70   "@Bex"        :: [pttrn, 'a set, bool] => bool      ("(3? _:_./ _)" [0, 0, 10] 10)
    71   "*Ball"       :: [pttrn, 'a set, bool] => bool      ("(3ALL _:_./ _)" [0, 0, 10] 10)
    71   "*Ball"       :: [pttrn, 'a set, bool] => bool      ("(3ALL _:_./ _)" [0, 0, 10] 10)
    72   "*Bex"        :: [pttrn, 'a set, bool] => bool      ("(3EX _:_./ _)" [0, 0, 10] 10)
    72   "*Bex"        :: [pttrn, 'a set, bool] => bool      ("(3EX _:_./ _)" [0, 0, 10] 10)
    73 
    73 
    74 translations
    74 translations
    75   "UNIV"        == "Compl {}"
       
    76   "range f"     == "f``UNIV"
    75   "range f"     == "f``UNIV"
    77   "x ~: y"      == "~ (x : y)"
    76   "x ~: y"      == "~ (x : y)"
    78   "{x, xs}"     == "insert x {xs}"
    77   "{x, xs}"     == "insert x {xs}"
    79   "{x}"         == "insert x {}"
    78   "{x}"         == "insert x {}"
    80   "{x. P}"      == "Collect (%x. P)"
    79   "{x. P}"      == "Collect (%x. P)"
       
    80   "UN x y. B"   == "UN x. UN y. B"
       
    81   "UN x. B"     == "UNION UNIV (%x. B)"
       
    82   "INT x y. B"   == "INT x. INT y. B"
       
    83   "INT x. B"    == "INTER UNIV (%x. B)"
       
    84   "UN x:A. B"   == "UNION A (%x. B)"
    81   "INT x:A. B"  == "INTER A (%x. B)"
    85   "INT x:A. B"  == "INTER A (%x. B)"
    82   "UN x:A. B"   == "UNION A (%x. B)"
       
    83   "! x:A. P"    == "Ball A (%x. P)"
    86   "! x:A. P"    == "Ball A (%x. P)"
    84   "? x:A. P"    == "Bex A (%x. P)"
    87   "? x:A. P"    == "Bex A (%x. P)"
    85   "ALL x:A. P"  => "Ball A (%x. P)"
    88   "ALL x:A. P"  => "Ball A (%x. P)"
    86   "EX x:A. P"   => "Bex A (%x. P)"
    89   "EX x:A. P"   => "Bex A (%x. P)"
    87 
    90 
   102   "op :"        :: ['a, 'a set] => bool               ("(_/ \\<in> _)" [50, 51] 50)
   105   "op :"        :: ['a, 'a set] => bool               ("(_/ \\<in> _)" [50, 51] 50)
   103   "op ~:"       :: ['a, 'a set] => bool               ("op \\<notin>")
   106   "op ~:"       :: ['a, 'a set] => bool               ("op \\<notin>")
   104   "op ~:"       :: ['a, 'a set] => bool               ("(_/ \\<notin> _)" [50, 51] 50)
   107   "op ~:"       :: ['a, 'a set] => bool               ("(_/ \\<notin> _)" [50, 51] 50)
   105   "UN "         :: [idts, bool] => bool               ("(3\\<Union> _./ _)" 10)
   108   "UN "         :: [idts, bool] => bool               ("(3\\<Union> _./ _)" 10)
   106   "INT "        :: [idts, bool] => bool               ("(3\\<Inter> _./ _)" 10)
   109   "INT "        :: [idts, bool] => bool               ("(3\\<Inter> _./ _)" 10)
       
   110   "UNION1"      :: [pttrn, 'b set] => 'b set          ("(3\\<Union> _./ _)" 10)
       
   111   "INTER1"      :: [pttrn, 'b set] => 'b set          ("(3\\<Inter> _./ _)" 10)
   107   "@UNION"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Union> _\\<in>_./ _)" 10)
   112   "@UNION"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Union> _\\<in>_./ _)" 10)
   108   "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Inter> _\\<in>_./ _)" 10)
   113   "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Inter> _\\<in>_./ _)" 10)
   109   Union         :: (('a set) set) => 'a set           ("\\<Union> _" [90] 90)
   114   Union         :: (('a set) set) => 'a set           ("\\<Union> _" [90] 90)
   110   Inter         :: (('a set) set) => 'a set           ("\\<Inter> _" [90] 90)
   115   Inter         :: (('a set) set) => 'a set           ("\\<Inter> _" [90] 90)
   111   "@Ball"       :: [pttrn, 'a set, bool] => bool      ("(3\\<forall> _\\<in>_./ _)" [0, 0, 10] 10)
   116   "@Ball"       :: [pttrn, 'a set, bool] => bool      ("(3\\<forall> _\\<in>_./ _)" [0, 0, 10] 10)
   143   Un_def        "A Un B         == {x. x:A | x:B}"
   148   Un_def        "A Un B         == {x. x:A | x:B}"
   144   Int_def       "A Int B        == {x. x:A & x:B}"
   149   Int_def       "A Int B        == {x. x:A & x:B}"
   145   set_diff_def  "A - B          == {x. x:A & ~x:B}"
   150   set_diff_def  "A - B          == {x. x:A & ~x:B}"
   146   INTER_def     "INTER A B      == {y. ! x:A. y: B(x)}"
   151   INTER_def     "INTER A B      == {y. ! x:A. y: B(x)}"
   147   UNION_def     "UNION A B      == {y. ? x:A. y: B(x)}"
   152   UNION_def     "UNION A B      == {y. ? x:A. y: B(x)}"
   148   INTER1_def    "INTER1 B       == INTER {x. True} B"
       
   149   UNION1_def    "UNION1 B       == UNION {x. True} B"
       
   150   Inter_def     "Inter S        == (INT x:S. x)"
   153   Inter_def     "Inter S        == (INT x:S. x)"
   151   Union_def     "Union S        == (UN x:S. x)"
   154   Union_def     "Union S        == (UN x:S. x)"
   152   Pow_def       "Pow A          == {B. B <= A}"
   155   Pow_def       "Pow A          == {B. B <= A}"
   153   empty_def     "{}             == {x. False}"
   156   empty_def     "{}             == {x. False}"
       
   157   UNIV_def      "UNIV           == {x. True}"
   154   insert_def    "insert a B     == {x. x=a} Un B"
   158   insert_def    "insert a B     == {x. x=a} Un B"
   155   image_def     "f``A           == {y. ? x:A. y=f(x)}"
   159   image_def     "f``A           == {y. ? x:A. y=f(x)}"
   156 
   160 
   157 end
   161 end
   158 
   162