src/HOL/HOL.thy
author wenzelm
Wed Nov 27 16:51:15 1996 +0100 (1996-11-27)
changeset 2260 b59781f2b809
parent 1674 33aff4d854e4
child 2368 d394336997cf
permissions -rw-r--r--
added symbols syntax;
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
wenzelm@2260
     6
Higher-Order Logic.
clasohm@923
     7
*)
clasohm@923
     8
clasohm@923
     9
HOL = CPure +
clasohm@923
    10
wenzelm@2260
    11
wenzelm@2260
    12
(** Core syntax **)
wenzelm@2260
    13
clasohm@923
    14
classes
clasohm@923
    15
  term < logic
clasohm@923
    16
clasohm@923
    17
default
clasohm@923
    18
  term
clasohm@923
    19
clasohm@923
    20
types
clasohm@923
    21
  bool
clasohm@923
    22
clasohm@923
    23
arities
clasohm@923
    24
  fun :: (term, term) term
clasohm@923
    25
  bool :: term
clasohm@923
    26
clasohm@923
    27
clasohm@923
    28
consts
clasohm@923
    29
clasohm@923
    30
  (* Constants *)
clasohm@923
    31
clasohm@1370
    32
  Trueprop      :: bool => prop                     ("(_)" 5)
clasohm@1370
    33
  not           :: bool => bool                     ("~ _" [40] 40)
clasohm@1370
    34
  True, False   :: bool
clasohm@1370
    35
  If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
clasohm@1370
    36
  Inv           :: ('a => 'b) => ('b => 'a)
clasohm@923
    37
clasohm@923
    38
  (* Binders *)
clasohm@923
    39
clasohm@1370
    40
  Eps           :: ('a => bool) => 'a
clasohm@1370
    41
  All           :: ('a => bool) => bool             (binder "! " 10)
clasohm@1370
    42
  Ex            :: ('a => bool) => bool             (binder "? " 10)
clasohm@1370
    43
  Ex1           :: ('a => bool) => bool             (binder "?! " 10)
clasohm@1370
    44
  Let           :: ['a, 'a => 'b] => 'b
clasohm@923
    45
clasohm@923
    46
  (* Infixes *)
clasohm@923
    47
clasohm@1370
    48
  o             :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
clasohm@1370
    49
  "="           :: ['a, 'a] => bool                 (infixl 50)
clasohm@1370
    50
  "&"           :: [bool, bool] => bool             (infixr 35)
clasohm@1370
    51
  "|"           :: [bool, bool] => bool             (infixr 30)
clasohm@1370
    52
  "-->"         :: [bool, bool] => bool             (infixr 25)
clasohm@923
    53
wenzelm@2260
    54
wenzelm@2260
    55
(* Overloaded Constants *)
wenzelm@2260
    56
wenzelm@2260
    57
axclass
wenzelm@2260
    58
  plus < term
clasohm@923
    59
wenzelm@2260
    60
axclass
wenzelm@2260
    61
  minus < term
wenzelm@2260
    62
wenzelm@2260
    63
axclass
wenzelm@2260
    64
  times < term
wenzelm@2260
    65
wenzelm@2260
    66
consts
clasohm@1370
    67
  "+"           :: ['a::plus, 'a] => 'a             (infixl 65)
clasohm@1370
    68
  "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
clasohm@1370
    69
  "*"           :: ['a::times, 'a] => 'a            (infixl 70)
clasohm@923
    70
clasohm@923
    71
wenzelm@2260
    72
wenzelm@2260
    73
(** Additional concrete syntax **)
wenzelm@2260
    74
clasohm@923
    75
types
clasohm@923
    76
  letbinds  letbind
clasohm@923
    77
  case_syn  cases_syn
clasohm@923
    78
clasohm@923
    79
syntax
clasohm@923
    80
clasohm@1370
    81
  "~="          :: ['a, 'a] => bool                 (infixl 50)
clasohm@923
    82
wenzelm@2260
    83
  "@Eps"        :: [pttrn, bool] => 'a              ("(3@ _./ _)" 10)
nipkow@1068
    84
clasohm@923
    85
  (* Alternative Quantifiers *)
clasohm@923
    86
clasohm@1370
    87
  "*All"        :: [idts, bool] => bool             ("(3ALL _./ _)" 10)
clasohm@1370
    88
  "*Ex"         :: [idts, bool] => bool             ("(3EX _./ _)" 10)
clasohm@1370
    89
  "*Ex1"        :: [idts, bool] => bool             ("(3EX! _./ _)" 10)
clasohm@923
    90
clasohm@923
    91
  (* Let expressions *)
clasohm@923
    92
clasohm@1370
    93
  "_bind"       :: [pttrn, 'a] => letbind           ("(2_ =/ _)" 10)
clasohm@1370
    94
  ""            :: letbind => letbinds              ("_")
clasohm@1370
    95
  "_binds"      :: [letbind, letbinds] => letbinds  ("_;/ _")
clasohm@1370
    96
  "_Let"        :: [letbinds, 'a] => 'a             ("(let (_)/ in (_))" 10)
clasohm@923
    97
clasohm@923
    98
  (* Case expressions *)
clasohm@923
    99
clasohm@1370
   100
  "@case"       :: ['a, cases_syn] => 'b            ("(case _ of/ _)" 10)
clasohm@1370
   101
  "@case1"      :: ['a, 'b] => case_syn             ("(2_ =>/ _)" 10)
clasohm@1370
   102
  ""            :: case_syn => cases_syn            ("_")
clasohm@1370
   103
  "@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ | _")
clasohm@923
   104
clasohm@923
   105
translations
clasohm@923
   106
  "x ~= y"      == "~ (x = y)"
wenzelm@2260
   107
  "@ x.b"       == "Eps (%x. b)"
clasohm@923
   108
  "ALL xs. P"   => "! xs. P"
clasohm@923
   109
  "EX xs. P"    => "? xs. P"
clasohm@923
   110
  "EX! xs. P"   => "?! xs. P"
clasohm@923
   111
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
   112
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
   113
wenzelm@2260
   114
wenzelm@2260
   115
syntax (symbols)
wenzelm@2260
   116
  not           :: bool => bool                     ("\\<not> _" [40] 40)
wenzelm@2260
   117
  "op &"        :: [bool, bool] => bool             (infixr "\\<and>" 35)
wenzelm@2260
   118
  "op |"        :: [bool, bool] => bool             (infixr "\\<or>" 30)
wenzelm@2260
   119
  "op -->"      :: [bool, bool] => bool             (infixr "\\<midarrow>\\<rightarrow>" 25)
wenzelm@2260
   120
  "op o"        :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl "\\<circ>" 55)
wenzelm@2260
   121
  "op ~="       :: ['a, 'a] => bool                 (infixl "\\<noteq>" 50)
wenzelm@2260
   122
  "@Eps"        :: [pttrn, bool] => 'a              ("(3\\<epsilon>_./ _)" 10)
wenzelm@2260
   123
  "! "          :: [idts, bool] => bool             ("(3\\<forall>_./ _)" 10)
wenzelm@2260
   124
  "? "          :: [idts, bool] => bool             ("(3\\<exists>_./ _)" 10)
wenzelm@2260
   125
  "?! "         :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" 10)
wenzelm@2260
   126
  "*All"        :: [idts, bool] => bool             ("(3\\<forall>_./ _)" 10)
wenzelm@2260
   127
  "*Ex"         :: [idts, bool] => bool             ("(3\\<exists>_./ _)" 10)
wenzelm@2260
   128
  "*Ex1"        :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" 10)
wenzelm@2260
   129
  "@case1"      :: ['a, 'b] => case_syn             ("(2_ \\<mapsto>/ _)" 10)
wenzelm@2260
   130
wenzelm@2260
   131
wenzelm@2260
   132
wenzelm@2260
   133
(** Rules and definitions **)
wenzelm@2260
   134
clasohm@923
   135
rules
clasohm@923
   136
clasohm@923
   137
  eq_reflection "(x=y) ==> (x==y)"
clasohm@923
   138
clasohm@923
   139
  (* Basic Rules *)
clasohm@923
   140
clasohm@923
   141
  refl          "t = (t::'a)"
clasohm@923
   142
  subst         "[| s = t; P(s) |] ==> P(t::'a)"
clasohm@923
   143
  ext           "(!!x::'a. (f(x)::'b) = g(x)) ==> (%x.f(x)) = (%x.g(x))"
clasohm@923
   144
  selectI       "P(x::'a) ==> P(@x.P(x))"
clasohm@923
   145
clasohm@923
   146
  impI          "(P ==> Q) ==> P-->Q"
clasohm@923
   147
  mp            "[| P-->Q;  P |] ==> Q"
clasohm@923
   148
clasohm@923
   149
defs
clasohm@923
   150
clasohm@923
   151
  True_def      "True      == ((%x::bool.x)=(%x.x))"
clasohm@923
   152
  All_def       "All(P)    == (P = (%x.True))"
clasohm@923
   153
  Ex_def        "Ex(P)     == P(@x.P(x))"
clasohm@923
   154
  False_def     "False     == (!P.P)"
clasohm@923
   155
  not_def       "~ P       == P-->False"
clasohm@923
   156
  and_def       "P & Q     == !R. (P-->Q-->R) --> R"
clasohm@923
   157
  or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
clasohm@923
   158
  Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   159
clasohm@923
   160
rules
clasohm@923
   161
  (* Axioms *)
clasohm@923
   162
clasohm@923
   163
  iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
clasohm@923
   164
  True_or_False "(P=True) | (P=False)"
clasohm@923
   165
clasohm@923
   166
defs
clasohm@923
   167
  (* Misc Definitions *)
clasohm@923
   168
clasohm@923
   169
  Let_def       "Let s f == f(s)"
clasohm@923
   170
  Inv_def       "Inv(f::'a=>'b)  == (% y. @x. f(x)=y)"
clasohm@923
   171
  o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
nipkow@973
   172
  if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
clasohm@923
   173
regensbu@1273
   174
(* start 8bit 1 *)
regensbu@1273
   175
(* end 8bit 1 *)
regensbu@1273
   176
clasohm@923
   177
end
clasohm@923
   178
wenzelm@2260
   179
clasohm@923
   180
ML
clasohm@923
   181
clasohm@923
   182
(** Choice between the HOL and Isabelle style of quantifiers **)
clasohm@923
   183
clasohm@923
   184
val HOL_quantifiers = ref true;
clasohm@923
   185
clasohm@923
   186
fun alt_ast_tr' (name, alt_name) =
clasohm@923
   187
  let
clasohm@923
   188
    fun ast_tr' (*name*) args =
clasohm@923
   189
      if ! HOL_quantifiers then raise Match
clasohm@923
   190
      else Syntax.mk_appl (Syntax.Constant alt_name) args;
clasohm@923
   191
  in
clasohm@923
   192
    (name, ast_tr')
clasohm@923
   193
  end;
clasohm@923
   194
clasohm@923
   195
clasohm@923
   196
val print_ast_translation =
clasohm@923
   197
  map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];
regensbu@1273
   198
regensbu@1273
   199
(* start 8bit 2 *)
regensbu@1273
   200
(* end 8bit 2 *)