src/HOL/Set.thy
author paulson
Fri, 31 Jan 1997 17:13:19 +0100
changeset 2572 8a47f85e7a03
parent 2412 025e80ed698d
child 2684 9781d63ef063
permissions -rw-r--r--
ex_impE was incorrectly listed as Safe
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$
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     3
    Author:     Tobias Nipkow
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
Set = Ord +
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
     9
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    10
(** Core syntax **)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    11
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
types
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
  'a set
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
arities
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
  set :: (term) term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
instance
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
  set :: (term) {ord, minus}
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
consts
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    22
  "{}"          :: 'a set                           ("{}")
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    23
  insert        :: ['a, 'a set] => 'a set
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    24
  Collect       :: ('a => bool) => 'a set               (*comprehension*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    25
  Compl         :: ('a set) => 'a set                   (*complement*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    26
  Int           :: ['a set, 'a set] => 'a set       (infixl 70)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    27
  Un            :: ['a set, 'a set] => 'a set       (infixl 65)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    28
  UNION, INTER  :: ['a set, 'a => 'b set] => 'b set     (*general*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    29
  UNION1        :: ['a => 'b set] => 'b set         (binder "UN " 10)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    30
  INTER1        :: ['a => 'b set] => 'b set         (binder "INT " 10)
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    31
  Union, Inter  :: (('a set) set) => 'a set             (*of a set*)
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    32
  Pow           :: 'a set => 'a set set                 (*powerset*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    33
  range         :: ('a => 'b) => 'b set                 (*of function*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    34
  Ball, Bex     :: ['a set, 'a => bool] => bool         (*bounded quantifiers*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    35
  inj, surj     :: ('a => 'b) => bool                   (*inj/surjective*)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    36
  inj_onto      :: ['a => 'b, 'a set] => bool
1962
e60a230da179 Corrected associativity: must be to right, as the type dictatess
paulson
parents: 1883
diff changeset
    37
  "``"          :: ['a => 'b, 'a set] => ('b set)   (infixr 90)
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    38
  (*membership*)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    39
  "op :"        :: ['a, 'a set] => bool             ("(_/ : _)" [50, 51] 50)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    41
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    42
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    43
(** Additional concrete syntax **)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    44
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
syntax
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    46
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    47
  "op :"        :: ['a, 'a set] => bool               ("op :")
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1370
diff changeset
    48
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    49
  UNIV          :: 'a set
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    50
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    51
  (* Infix syntax for non-membership *)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    53
  "op ~:"       :: ['a, 'a set] => bool               ("(_/ ~: _)" [50, 51] 50)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    54
  "op ~:"       :: ['a, 'a set] => bool               ("op ~:")
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    56
  "@Finset"     :: args => 'a set                     ("{(_)}")
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    57
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    58
  "@Coll"       :: [pttrn, bool] => 'a set            ("(1{_./ _})")
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
  (* Big Intersection / Union *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
1370
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
diff changeset
    63
  "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3INT _:_./ _)" 10)
7361ac9b024d removed quotes from types in consts and syntax sections
clasohm
parents: 1273
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    66
  (* Bounded Quantifiers *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
2368
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
    68
  "@Ball"       :: [pttrn, 'a set, bool] => bool      ("(3! _:_./ _)" [0, 0, 10] 10)
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
    69
  "@Bex"        :: [pttrn, 'a set, bool] => bool      ("(3? _:_./ _)" [0, 0, 10] 10)
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
    70
  "*Ball"       :: [pttrn, 'a set, bool] => bool      ("(3ALL _:_./ _)" [0, 0, 10] 10)
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
    71
  "*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
    72
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    73
translations
1531
e5eb247ad13c Added a constant UNIV == {x.True}
nipkow
parents: 1370
diff changeset
    74
  "UNIV"        == "Compl {}"
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    75
  "range f"     == "f``UNIV"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    76
  "x ~: y"      == "~ (x : y)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
  "{x, xs}"     == "insert x {xs}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
  "{x}"         == "insert x {}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
  "{x. P}"      == "Collect (%x. P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
  "INT x:A. B"  == "INTER A (%x. B)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
  "UN x:A. B"   == "UNION A (%x. B)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
  "! x:A. P"    == "Ball A (%x. P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
  "? x:A. P"    == "Bex A (%x. P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
  "ALL x:A. P"  => "Ball A (%x. P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    85
  "EX x:A. P"   => "Bex A (%x. P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
2388
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
    87
syntax ("" output)
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
    88
  "_setle"      :: ['a set, 'a set] => bool           ("(_/ <= _)" [50, 51] 50)
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
    89
  "_setle"      :: ['a set, 'a set] => bool           ("op <=")
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    91
syntax (symbols)
2388
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
    92
  "_setle"      :: ['a set, 'a set] => bool           ("(_/ \\<subseteq> _)" [50, 51] 50)
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
    93
  "_setle"      :: ['a set, 'a set] => bool           ("op \\<subseteq>")
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    94
  "op Int"      :: ['a set, 'a set] => 'a set         (infixl "\\<inter>" 70)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    95
  "op Un"       :: ['a set, 'a set] => 'a set         (infixl "\\<union>" 65)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    96
  "op :"        :: ['a, 'a set] => bool               ("(_/ \\<in> _)" [50, 51] 50)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    97
  "op :"        :: ['a, 'a set] => bool               ("op \\<in>")
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    98
  "op ~:"       :: ['a, 'a set] => bool               ("(_/ \\<notin> _)" [50, 51] 50)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
    99
  "op ~:"       :: ['a, 'a set] => bool               ("op \\<notin>")
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   100
  "UN "         :: [idts, bool] => bool               ("(3\\<Union> _./ _)" 10)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   101
  "INT "        :: [idts, bool] => bool               ("(3\\<Inter> _./ _)" 10)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   102
  "@UNION"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Union> _\\<in>_./ _)" 10)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   103
  "@INTER"      :: [pttrn, 'a set, 'b set] => 'b set  ("(3\\<Inter> _\\<in>_./ _)" 10)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   104
  Union         :: (('a set) set) => 'a set           ("\\<Union> _" [90] 90)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   105
  Inter         :: (('a set) set) => 'a set           ("\\<Inter> _" [90] 90)
2368
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
   106
  "@Ball"       :: [pttrn, 'a set, bool] => bool      ("(3\\<forall> _\\<in>_./ _)" [0, 0, 10] 10)
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
   107
  "@Bex"        :: [pttrn, 'a set, bool] => bool      ("(3\\<exists> _\\<in>_./ _)" [0, 0, 10] 10)
2372
a2999e19703b fixed alternative quantifier symbol syntax;
wenzelm
parents: 2368
diff changeset
   108
a2999e19703b fixed alternative quantifier symbol syntax;
wenzelm
parents: 2368
diff changeset
   109
syntax (symbols output)
2368
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
   110
  "*Ball"       :: [pttrn, 'a set, bool] => bool      ("(3\\<forall> _\\<in>_./ _)" [0, 0, 10] 10)
d394336997cf fixed pris of binder syntax;
wenzelm
parents: 2261
diff changeset
   111
  "*Bex"        :: [pttrn, 'a set, bool] => bool      ("(3\\<exists> _\\<in>_./ _)" [0, 0, 10] 10)
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   112
2412
025e80ed698d fixed \<subseteq> input;
wenzelm
parents: 2393
diff changeset
   113
translations
025e80ed698d fixed \<subseteq> input;
wenzelm
parents: 2393
diff changeset
   114
  "op \\<subseteq>" => "op <="
025e80ed698d fixed \<subseteq> input;
wenzelm
parents: 2393
diff changeset
   115
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   116
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   117
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   118
(** Rules and definitions **)
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   119
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
rules
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
  (* Isomorphisms between Predicates and Sets *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
  mem_Collect_eq    "(a : {x.P(x)}) = P(a)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
  Collect_mem_eq    "{x.x:A} = A"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
defs
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   129
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
  Ball_def      "Ball A P       == ! x. x:A --> P(x)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
  Bex_def       "Bex A P        == ? x. x:A & P(x)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
  subset_def    "A <= B         == ! x:A. x:B"
2393
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   133
  Compl_def     "Compl A        == {x. ~x:A}"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
  Un_def        "A Un B         == {x.x:A | x:B}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
  Int_def       "A Int B        == {x.x:A & x:B}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
  set_diff_def  "A - B          == {x. x:A & ~x:B}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
  INTER_def     "INTER A B      == {y. ! x:A. y: B(x)}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
  UNION_def     "UNION A B      == {y. ? x:A. y: B(x)}"
2393
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   139
  INTER1_def    "INTER1 B       == INTER {x.True} B"
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   140
  UNION1_def    "UNION1 B       == UNION {x.True} B"
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   141
  Inter_def     "Inter S        == (INT x:S. x)"
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   142
  Union_def     "Union S        == (UN x:S. x)"
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   143
  Pow_def       "Pow A          == {B. B <= A}"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   144
  empty_def     "{}             == {x. False}"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
  insert_def    "insert a B     == {x.x=a} Un B"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
  image_def     "f``A           == {y. ? x:A. y=f(x)}"
2393
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   147
  inj_def       "inj f          == ! x y. f(x)=f(y) --> x=y"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
  inj_onto_def  "inj_onto f A   == ! x:A. ! y:A. f(x)=f(y) --> x=y"
2393
651fce76c86c adaptions for symbol font
oheimb
parents: 2388
diff changeset
   149
  surj_def      "surj f         == ! y. ? x. y=f(x)"
1273
6960ec882bca added 8bit pragmas
regensbu
parents: 1068
diff changeset
   150
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
end
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
2261
d926157c0a6a added "op :", "op ~:" syntax;
wenzelm
parents: 2006
diff changeset
   153
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
ML
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
local
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
2388
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   158
(* Set inclusion *)
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   159
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   160
fun le_tr' (*op <=*) (Type ("fun", (Type ("set", _) :: _))) ts =
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   161
      list_comb (Syntax.const "_setle", ts)
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   162
  | le_tr' (*op <=*) _ _ = raise Match;
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   163
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   164
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
(* Translates between { e | x1..xn. P} and {u. ? x1..xn. u=e & P}      *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
(* {y. ? x1..xn. y = e & P} is only translated if [0..n] subset bvs(e) *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   167
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   168
val ex_tr = snd(mk_binder_tr("? ","Ex"));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   169
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   170
fun nvars(Const("_idts",_) $ _ $ idts) = nvars(idts)+1
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   171
  | nvars(_) = 1;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   172
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   173
fun setcompr_tr[e,idts,b] =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   174
  let val eq = Syntax.const("op =") $ Bound(nvars(idts)) $ e
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   175
      val P = Syntax.const("op &") $ eq $ b
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   176
      val exP = ex_tr [idts,P]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   177
  in Syntax.const("Collect") $ Abs("",dummyT,exP) end;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   178
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   179
val ex_tr' = snd(mk_binder_tr' ("Ex","DUMMY"));
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   180
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   181
fun setcompr_tr'[Abs(_,_,P)] =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   182
  let fun ok(Const("Ex",_)$Abs(_,_,P),n) = ok(P,n+1)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   183
        | ok(Const("op &",_) $ (Const("op =",_) $ Bound(m) $ e) $ _, n) =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   184
            if n>0 andalso m=n andalso
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   185
              ((0 upto (n-1)) subset add_loose_bnos(e,0,[]))
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   186
            then () else raise Match
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   187
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   188
      fun tr'(_ $ abs) =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   189
        let val _ $ idts $ (_ $ (_ $ _ $ e) $ Q) = ex_tr'[abs]
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   190
        in Syntax.const("@SetCompr") $ e $ idts $ Q end
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   191
  in ok(P,0); tr'(P) end;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   192
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   193
in
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   194
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   195
val parse_translation = [("@SetCompr", setcompr_tr)];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   196
val print_translation = [("Collect", setcompr_tr')];
2388
d1f0505fc602 added set inclusion symbol syntax;
wenzelm
parents: 2372
diff changeset
   197
val typed_print_translation = [("op <=", le_tr')];
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   198
val print_ast_translation =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   199
  map HOL.alt_ast_tr' [("@Ball", "*Ball"), ("@Bex", "*Bex")];
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   200
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   201
end;