src/HOL/HOL.thy
author nipkow
Sat, 22 Apr 1995 13:25:31 +0200
changeset 1068 e0f2dffab506
parent 973 f57fb576520f
child 1114 c8dfb56a7e95
permissions -rw-r--r--
HOL.thy: "@" is no longer introduced as a "binder" but has its own explicit translation rule "@x.b" == "Eps(%x.b)". If x is a proper pattern, further translation rules for abstractions with patterns take care of the rest. This is very modular and avoids problems with "binders" such as "!" mentioned below. let now allows pttrn (let (x,y) = t in u) instead of just idt (let x = t in u) Set.thy: UN, INT, ALL, EX, etc all use "pttrn" instead of idt. Same change as for "@" above, except that "@" was a "binder" originally. Prod.thy: Added new syntax for pttrn which allows arbitrarily nested tuples. Two translation rules take care of %pttrn. Unfortunately they cannot be reversed. Hence a little ML-code is used as well. Note that now "! (x,y). ..." is syntactically valid but leads to a translation error. This is because "!" is introduced as a "binder" which means that its translation into lambda-terms is not done by a rewrite rule (aka macro) but by some fixed ML-code which comes after the rewriting stage and does not know how to handle patterns. This looks like a minor blemish since patterns in unbounded quantifiers are not that useful (well, except maybe in unique existence ...). Ideally, there should be two syntactic categories: idts, as we know and love it, which does not admit patterns. patterns, which is what idts has become now. There is one more point where patterns are now allowed but don't make sense: {e | idts . P} where idts is the list of local variables. Univ.thy: converted the defs for <++> and <**> into pattern form. It worked perfectly.
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/HOL.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
Higher-Order Logic
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     7
*)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     8
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
     9
HOL = CPure +
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    10
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    11
classes
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    12
  term < logic
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    13
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    14
axclass
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    15
  plus < term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    16
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    17
axclass
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    18
  minus < term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    19
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    20
axclass
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    21
  times < term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    22
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    23
default
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    24
  term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    25
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    26
types
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    27
  bool
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    28
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    29
arities
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    30
  fun :: (term, term) term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    31
  bool :: term
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    32
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    33
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    34
consts
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    35
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    36
  (* Constants *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    37
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    38
  Trueprop      :: "bool => prop"                     ("(_)" 5)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    39
  not           :: "bool => bool"                     ("~ _" [40] 40)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    40
  True, False   :: "bool"
965
24eef3860714 changed syntax of "if"
clasohm
parents: 923
diff changeset
    41
  If            :: "[bool, 'a, 'a] => 'a"   ("(if (_)/ then (_)/ else (_))" 10)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    42
  Inv           :: "('a => 'b) => ('b => 'a)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    43
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    44
  (* Binders *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    45
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 973
diff changeset
    46
  Eps           :: "('a => bool) => 'a"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    47
  All           :: "('a => bool) => bool"             (binder "! " 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    48
  Ex            :: "('a => bool) => bool"             (binder "? " 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    49
  Ex1           :: "('a => bool) => bool"             (binder "?! " 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    50
  Let           :: "['a, 'a => 'b] => 'b"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    51
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    52
  (* Infixes *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    53
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    54
  o             :: "['b => 'c, 'a => 'b, 'a] => 'c"   (infixr 50)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    55
  "="           :: "['a, 'a] => bool"                 (infixl 50)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    56
  "&"           :: "[bool, bool] => bool"             (infixr 35)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    57
  "|"           :: "[bool, bool] => bool"             (infixr 30)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    58
  "-->"         :: "[bool, bool] => bool"             (infixr 25)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    59
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    60
  (* Overloaded Constants *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    61
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    62
  "+"           :: "['a::plus, 'a] => 'a"             (infixl 65)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    63
  "-"           :: "['a::minus, 'a] => 'a"            (infixl 65)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    64
  "*"           :: "['a::times, 'a] => 'a"            (infixl 70)
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
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    67
types
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    68
  letbinds  letbind
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    69
  case_syn  cases_syn
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    70
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    71
syntax
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
  "~="          :: "['a, 'a] => bool"                 (infixl 50)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    74
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 973
diff changeset
    75
  "@Eps"        :: "[pttrn,bool] => 'a"               ("(3@ _./ _)" 10)
e0f2dffab506 HOL.thy:
nipkow
parents: 973
diff changeset
    76
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    77
  (* Alternative Quantifiers *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    78
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    79
  "*All"        :: "[idts, bool] => bool"             ("(3ALL _./ _)" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    80
  "*Ex"         :: "[idts, bool] => bool"             ("(3EX _./ _)" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    81
  "*Ex1"        :: "[idts, bool] => bool"             ("(3EX! _./ _)" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    82
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    83
  (* Let expressions *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    84
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 973
diff changeset
    85
  "_bind"       :: "[pttrn, 'a] => letbind"           ("(2_ =/ _)" 10)
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    86
  ""            :: "letbind => letbinds"              ("_")
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    87
  "_binds"      :: "[letbind, letbinds] => letbinds"  ("_;/ _")
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    88
  "_Let"        :: "[letbinds, 'a] => 'a"             ("(let (_)/ in (_))" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    89
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    90
  (* Case expressions *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    91
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    92
  "@case"       :: "['a, cases_syn] => 'b"            ("(case _ of/ _)" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    93
  "@case1"      :: "['a, 'b] => case_syn"             ("(2_ =>/ _)" 10)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    94
  ""            :: "case_syn => cases_syn"            ("_")
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    95
  "@case2"      :: "[case_syn, cases_syn] => cases_syn"   ("_/ | _")
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    96
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    97
translations
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
    98
  "x ~= y"      == "~ (x = y)"
1068
e0f2dffab506 HOL.thy:
nipkow
parents: 973
diff changeset
    99
  "@ x.b"       == "Eps(%x.b)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   100
  "ALL xs. P"   => "! xs. P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   101
  "EX xs. P"    => "? xs. P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   102
  "EX! xs. P"   => "?! xs. P"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   103
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   104
  "let x = a in e"          == "Let a (%x. e)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   105
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   106
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   107
rules
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   108
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   109
  eq_reflection "(x=y) ==> (x==y)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   110
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   111
  (* Basic Rules *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   112
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   113
  refl          "t = (t::'a)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   114
  subst         "[| s = t; P(s) |] ==> P(t::'a)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   115
  ext           "(!!x::'a. (f(x)::'b) = g(x)) ==> (%x.f(x)) = (%x.g(x))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   116
  selectI       "P(x::'a) ==> P(@x.P(x))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   117
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   118
  impI          "(P ==> Q) ==> P-->Q"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   119
  mp            "[| P-->Q;  P |] ==> Q"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   120
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   121
defs
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   122
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   123
  True_def      "True      == ((%x::bool.x)=(%x.x))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   124
  All_def       "All(P)    == (P = (%x.True))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   125
  Ex_def        "Ex(P)     == P(@x.P(x))"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   126
  False_def     "False     == (!P.P)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   127
  not_def       "~ P       == P-->False"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   128
  and_def       "P & Q     == !R. (P-->Q-->R) --> R"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   129
  or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   130
  Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   131
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   132
rules
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   133
  (* Axioms *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   134
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   135
  iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   136
  True_or_False "(P=True) | (P=False)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   137
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   138
defs
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   139
  (* Misc Definitions *)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   140
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   141
  Let_def       "Let s f == f(s)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   142
  Inv_def       "Inv(f::'a=>'b)  == (% y. @x. f(x)=y)"
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   143
  o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
973
f57fb576520f Modified If_def to avoid ambiguity.
nipkow
parents: 965
diff changeset
   144
  if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
923
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   145
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   146
end
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   147
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   148
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   149
ML
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   150
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   151
(** Choice between the HOL and Isabelle style of quantifiers **)
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   152
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   153
val HOL_quantifiers = ref true;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   154
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   155
fun alt_ast_tr' (name, alt_name) =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   156
  let
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   157
    fun ast_tr' (*name*) args =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   158
      if ! HOL_quantifiers then raise Match
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   159
      else Syntax.mk_appl (Syntax.Constant alt_name) args;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   160
  in
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   161
    (name, ast_tr')
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   162
  end;
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   163
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   164
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   165
val print_ast_translation =
ff1574a81019 new version of HOL with curried function application
clasohm
parents:
diff changeset
   166
  map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];