src/HOL/HOL.thy
author clasohm
Fri Mar 03 12:02:25 1995 +0100 (1995-03-03)
changeset 923 ff1574a81019
child 965 24eef3860714
permissions -rw-r--r--
new version of HOL with curried function application
clasohm@923
     1
(*  Title:      HOL/HOL.thy
clasohm@923
     2
    ID:         $Id$
clasohm@923
     3
    Author:     Tobias Nipkow
clasohm@923
     4
    Copyright   1993  University of Cambridge
clasohm@923
     5
clasohm@923
     6
Higher-Order Logic
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
HOL = CPure +
clasohm@923
    10
clasohm@923
    11
classes
clasohm@923
    12
  term < logic
clasohm@923
    13
clasohm@923
    14
axclass
clasohm@923
    15
  plus < term
clasohm@923
    16
clasohm@923
    17
axclass
clasohm@923
    18
  minus < term
clasohm@923
    19
clasohm@923
    20
axclass
clasohm@923
    21
  times < term
clasohm@923
    22
clasohm@923
    23
default
clasohm@923
    24
  term
clasohm@923
    25
clasohm@923
    26
types
clasohm@923
    27
  bool
clasohm@923
    28
clasohm@923
    29
arities
clasohm@923
    30
  fun :: (term, term) term
clasohm@923
    31
  bool :: term
clasohm@923
    32
clasohm@923
    33
clasohm@923
    34
consts
clasohm@923
    35
clasohm@923
    36
  (* Constants *)
clasohm@923
    37
clasohm@923
    38
  Trueprop      :: "bool => prop"                     ("(_)" 5)
clasohm@923
    39
  not           :: "bool => bool"                     ("~ _" [40] 40)
clasohm@923
    40
  True, False   :: "bool"
clasohm@923
    41
  if            :: "[bool, 'a, 'a] => 'a"
clasohm@923
    42
  Inv           :: "('a => 'b) => ('b => 'a)"
clasohm@923
    43
clasohm@923
    44
  (* Binders *)
clasohm@923
    45
clasohm@923
    46
  Eps           :: "('a => bool) => 'a"               (binder "@" 10)
clasohm@923
    47
  All           :: "('a => bool) => bool"             (binder "! " 10)
clasohm@923
    48
  Ex            :: "('a => bool) => bool"             (binder "? " 10)
clasohm@923
    49
  Ex1           :: "('a => bool) => bool"             (binder "?! " 10)
clasohm@923
    50
  Let           :: "['a, 'a => 'b] => 'b"
clasohm@923
    51
clasohm@923
    52
  (* Infixes *)
clasohm@923
    53
clasohm@923
    54
  o             :: "['b => 'c, 'a => 'b, 'a] => 'c"   (infixr 50)
clasohm@923
    55
  "="           :: "['a, 'a] => bool"                 (infixl 50)
clasohm@923
    56
(*"~="          :: "['a, 'a] => bool"                 (infixl 50)*)
clasohm@923
    57
  "&"           :: "[bool, bool] => bool"             (infixr 35)
clasohm@923
    58
  "|"           :: "[bool, bool] => bool"             (infixr 30)
clasohm@923
    59
  "-->"         :: "[bool, bool] => bool"             (infixr 25)
clasohm@923
    60
clasohm@923
    61
  (* Overloaded Constants *)
clasohm@923
    62
clasohm@923
    63
  "+"           :: "['a::plus, 'a] => 'a"             (infixl 65)
clasohm@923
    64
  "-"           :: "['a::minus, 'a] => 'a"            (infixl 65)
clasohm@923
    65
  "*"           :: "['a::times, 'a] => 'a"            (infixl 70)
clasohm@923
    66
clasohm@923
    67
clasohm@923
    68
types
clasohm@923
    69
  letbinds  letbind
clasohm@923
    70
  case_syn  cases_syn
clasohm@923
    71
clasohm@923
    72
syntax
clasohm@923
    73
clasohm@923
    74
  "~="          :: "['a, 'a] => bool"                 (infixl 50)
clasohm@923
    75
clasohm@923
    76
  (* Alternative Quantifiers *)
clasohm@923
    77
clasohm@923
    78
  "*All"        :: "[idts, bool] => bool"             ("(3ALL _./ _)" 10)
clasohm@923
    79
  "*Ex"         :: "[idts, bool] => bool"             ("(3EX _./ _)" 10)
clasohm@923
    80
  "*Ex1"        :: "[idts, bool] => bool"             ("(3EX! _./ _)" 10)
clasohm@923
    81
clasohm@923
    82
  (* Let expressions *)
clasohm@923
    83
clasohm@923
    84
  "_bind"       :: "[idt, 'a] => letbind"             ("(2_ =/ _)" 10)
clasohm@923
    85
  ""            :: "letbind => letbinds"              ("_")
clasohm@923
    86
  "_binds"      :: "[letbind, letbinds] => letbinds"  ("_;/ _")
clasohm@923
    87
  "_Let"        :: "[letbinds, 'a] => 'a"             ("(let (_)/ in (_))" 10)
clasohm@923
    88
clasohm@923
    89
  (* Case expressions *)
clasohm@923
    90
clasohm@923
    91
  "@case"       :: "['a, cases_syn] => 'b"            ("(case _ of/ _)" 10)
clasohm@923
    92
  "@case1"      :: "['a, 'b] => case_syn"             ("(2_ =>/ _)" 10)
clasohm@923
    93
  ""            :: "case_syn => cases_syn"            ("_")
clasohm@923
    94
  "@case2"      :: "[case_syn, cases_syn] => cases_syn"   ("_/ | _")
clasohm@923
    95
clasohm@923
    96
translations
clasohm@923
    97
  "x ~= y"      == "~ (x = y)"
clasohm@923
    98
  "ALL xs. P"   => "! xs. P"
clasohm@923
    99
  "EX xs. P"    => "? xs. P"
clasohm@923
   100
  "EX! xs. P"   => "?! xs. P"
clasohm@923
   101
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
clasohm@923
   102
  "let x = a in e"          == "Let a (%x. e)"
clasohm@923
   103
clasohm@923
   104
clasohm@923
   105
rules
clasohm@923
   106
clasohm@923
   107
  eq_reflection "(x=y) ==> (x==y)"
clasohm@923
   108
clasohm@923
   109
  (* Basic Rules *)
clasohm@923
   110
clasohm@923
   111
  refl          "t = (t::'a)"
clasohm@923
   112
  subst         "[| s = t; P(s) |] ==> P(t::'a)"
clasohm@923
   113
  ext           "(!!x::'a. (f(x)::'b) = g(x)) ==> (%x.f(x)) = (%x.g(x))"
clasohm@923
   114
  selectI       "P(x::'a) ==> P(@x.P(x))"
clasohm@923
   115
clasohm@923
   116
  impI          "(P ==> Q) ==> P-->Q"
clasohm@923
   117
  mp            "[| P-->Q;  P |] ==> Q"
clasohm@923
   118
clasohm@923
   119
defs
clasohm@923
   120
clasohm@923
   121
  True_def      "True      == ((%x::bool.x)=(%x.x))"
clasohm@923
   122
  All_def       "All(P)    == (P = (%x.True))"
clasohm@923
   123
  Ex_def        "Ex(P)     == P(@x.P(x))"
clasohm@923
   124
  False_def     "False     == (!P.P)"
clasohm@923
   125
  not_def       "~ P       == P-->False"
clasohm@923
   126
  and_def       "P & Q     == !R. (P-->Q-->R) --> R"
clasohm@923
   127
  or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
clasohm@923
   128
  Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   129
clasohm@923
   130
rules
clasohm@923
   131
  (* Axioms *)
clasohm@923
   132
clasohm@923
   133
  iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
clasohm@923
   134
  True_or_False "(P=True) | (P=False)"
clasohm@923
   135
clasohm@923
   136
defs
clasohm@923
   137
  (* Misc Definitions *)
clasohm@923
   138
clasohm@923
   139
  Let_def       "Let s f == f(s)"
clasohm@923
   140
  Inv_def       "Inv(f::'a=>'b)  == (% y. @x. f(x)=y)"
clasohm@923
   141
  o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
clasohm@923
   142
  if_def        "if P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
clasohm@923
   143
clasohm@923
   144
end
clasohm@923
   145
clasohm@923
   146
clasohm@923
   147
ML
clasohm@923
   148
clasohm@923
   149
(** Choice between the HOL and Isabelle style of quantifiers **)
clasohm@923
   150
clasohm@923
   151
val HOL_quantifiers = ref true;
clasohm@923
   152
clasohm@923
   153
fun alt_ast_tr' (name, alt_name) =
clasohm@923
   154
  let
clasohm@923
   155
    fun ast_tr' (*name*) args =
clasohm@923
   156
      if ! HOL_quantifiers then raise Match
clasohm@923
   157
      else Syntax.mk_appl (Syntax.Constant alt_name) args;
clasohm@923
   158
  in
clasohm@923
   159
    (name, ast_tr')
clasohm@923
   160
  end;
clasohm@923
   161
clasohm@923
   162
clasohm@923
   163
val print_ast_translation =
clasohm@923
   164
  map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];
clasohm@923
   165