src/HOL/HOL.thy
author oheimb
Fri Dec 11 18:56:30 1998 +0100 (1998-12-11)
changeset 6027 9dd06eeda95c
parent 5786 9a2c90bdadfe
child 6289 062aa156a300
permissions -rw-r--r--
added new print_mode "xsymbols" for extended symbol support
(e.g. genuiely long arrows)
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
wenzelm@3947
    14
global
wenzelm@3947
    15
clasohm@923
    16
classes
clasohm@923
    17
  term < logic
clasohm@923
    18
clasohm@923
    19
default
clasohm@923
    20
  term
clasohm@923
    21
clasohm@923
    22
types
clasohm@923
    23
  bool
clasohm@923
    24
clasohm@923
    25
arities
clasohm@923
    26
  fun :: (term, term) term
clasohm@923
    27
  bool :: term
clasohm@923
    28
clasohm@923
    29
clasohm@923
    30
consts
clasohm@923
    31
clasohm@923
    32
  (* Constants *)
clasohm@923
    33
clasohm@1370
    34
  Trueprop      :: bool => prop                     ("(_)" 5)
paulson@2720
    35
  Not           :: bool => bool                     ("~ _" [40] 40)
clasohm@1370
    36
  True, False   :: bool
clasohm@1370
    37
  If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
wenzelm@3947
    38
  arbitrary     :: 'a
clasohm@923
    39
clasohm@923
    40
  (* Binders *)
clasohm@923
    41
clasohm@1370
    42
  Eps           :: ('a => bool) => 'a
clasohm@1370
    43
  All           :: ('a => bool) => bool             (binder "! " 10)
clasohm@1370
    44
  Ex            :: ('a => bool) => bool             (binder "? " 10)
clasohm@1370
    45
  Ex1           :: ('a => bool) => bool             (binder "?! " 10)
clasohm@1370
    46
  Let           :: ['a, 'a => 'b] => 'b
clasohm@923
    47
clasohm@923
    48
  (* Infixes *)
clasohm@923
    49
clasohm@1370
    50
  "="           :: ['a, 'a] => bool                 (infixl 50)
clasohm@1370
    51
  "&"           :: [bool, bool] => bool             (infixr 35)
clasohm@1370
    52
  "|"           :: [bool, bool] => bool             (infixr 30)
clasohm@1370
    53
  "-->"         :: [bool, bool] => bool             (infixr 25)
clasohm@923
    54
wenzelm@2260
    55
wenzelm@2260
    56
(* Overloaded Constants *)
wenzelm@2260
    57
wenzelm@2260
    58
axclass
wenzelm@2260
    59
  plus < term
clasohm@923
    60
wenzelm@2260
    61
axclass
wenzelm@2260
    62
  minus < term
wenzelm@2260
    63
wenzelm@2260
    64
axclass
wenzelm@2260
    65
  times < term
wenzelm@2260
    66
paulson@3370
    67
axclass
paulson@3370
    68
  power < term
paulson@3370
    69
wenzelm@2260
    70
consts
paulson@3370
    71
  "+"           :: ['a::plus, 'a]  => 'a            (infixl 65)
clasohm@1370
    72
  "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
paulson@5786
    73
  uminus        :: ['a::minus] => 'a                ("- _" [100] 100)
clasohm@1370
    74
  "*"           :: ['a::times, 'a] => 'a            (infixl 70)
paulson@3370
    75
  (*See Nat.thy for "^"*)
wenzelm@2260
    76
wenzelm@3820
    77
wenzelm@2260
    78
(** Additional concrete syntax **)
wenzelm@2260
    79
wenzelm@4868
    80
nonterminals
clasohm@923
    81
  letbinds  letbind
clasohm@923
    82
  case_syn  cases_syn
clasohm@923
    83
clasohm@923
    84
syntax
clasohm@923
    85
clasohm@1370
    86
  "~="          :: ['a, 'a] => bool                 (infixl 50)
clasohm@923
    87
wenzelm@2368
    88
  "@Eps"        :: [pttrn, bool] => 'a              ("(3@ _./ _)" [0, 10] 10)
nipkow@1068
    89
clasohm@923
    90
  (* Alternative Quantifiers *)
clasohm@923
    91
wenzelm@2368
    92
  "*All"        :: [idts, bool] => bool             ("(3ALL _./ _)" [0, 10] 10)
wenzelm@2368
    93
  "*Ex"         :: [idts, bool] => bool             ("(3EX _./ _)" [0, 10] 10)
wenzelm@2368
    94
  "*Ex1"        :: [idts, bool] => bool             ("(3EX! _./ _)" [0, 10] 10)
clasohm@923
    95
clasohm@923
    96
  (* Let expressions *)
clasohm@923
    97
clasohm@1370
    98
  "_bind"       :: [pttrn, 'a] => letbind           ("(2_ =/ _)" 10)
clasohm@1370
    99
  ""            :: letbind => letbinds              ("_")
clasohm@1370
   100
  "_binds"      :: [letbind, letbinds] => letbinds  ("_;/ _")
clasohm@1370
   101
  "_Let"        :: [letbinds, 'a] => 'a             ("(let (_)/ in (_))" 10)
clasohm@923
   102
clasohm@923
   103
  (* Case expressions *)
clasohm@923
   104
clasohm@1370
   105
  "@case"       :: ['a, cases_syn] => 'b            ("(case _ of/ _)" 10)
clasohm@1370
   106
  "@case1"      :: ['a, 'b] => case_syn             ("(2_ =>/ _)" 10)
clasohm@1370
   107
  ""            :: case_syn => cases_syn            ("_")
clasohm@1370
   108
  "@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ | _")
clasohm@923
   109
clasohm@923
   110
translations
clasohm@923
   111
  "x ~= y"      == "~ (x = y)"
wenzelm@3842
   112
  "@ x. b"      == "Eps (%x. b)"
clasohm@923
   113
  "ALL xs. P"   => "! xs. P"
clasohm@923
   114
  "EX xs. P"    => "? xs. P"
clasohm@923
   115
  "EX! xs. P"   => "?! xs. P"
clasohm@923
   116
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
   117
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
   118
wenzelm@3820
   119
syntax ("" output)
wenzelm@3820
   120
  "op ="        :: ['a, 'a] => bool                 ("(_ =/ _)" [51, 51] 50)
wenzelm@3820
   121
  "op ~="       :: ['a, 'a] => bool                 ("(_ ~=/ _)" [51, 51] 50)
wenzelm@2260
   122
wenzelm@2260
   123
syntax (symbols)
wenzelm@2762
   124
  Not           :: bool => bool                     ("\\<not> _" [40] 40)
wenzelm@2260
   125
  "op &"        :: [bool, bool] => bool             (infixr "\\<and>" 35)
wenzelm@2260
   126
  "op |"        :: [bool, bool] => bool             (infixr "\\<or>" 30)
wenzelm@2260
   127
  "op -->"      :: [bool, bool] => bool             (infixr "\\<midarrow>\\<rightarrow>" 25)
wenzelm@2260
   128
  "op o"        :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl "\\<circ>" 55)
wenzelm@2260
   129
  "op ~="       :: ['a, 'a] => bool                 (infixl "\\<noteq>" 50)
wenzelm@2368
   130
  "@Eps"        :: [pttrn, bool] => 'a              ("(3\\<epsilon>_./ _)" [0, 10] 10)
wenzelm@2368
   131
  "! "          :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
wenzelm@2368
   132
  "? "          :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
wenzelm@2368
   133
  "?! "         :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" [0, 10] 10)
wenzelm@2552
   134
  "@case1"      :: ['a, 'b] => case_syn             ("(2_ \\<Rightarrow>/ _)" 10)
wenzelm@3068
   135
(*"@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ \\<orelse> _")*)
wenzelm@2372
   136
wenzelm@3820
   137
syntax (symbols output)
wenzelm@3820
   138
  "op ~="       :: ['a, 'a] => bool                 ("(_ \\<noteq>/ _)" [51, 51] 50)
wenzelm@3820
   139
  "*All"        :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
wenzelm@3820
   140
  "*Ex"         :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
wenzelm@3820
   141
  "*Ex1"        :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" [0, 10] 10)
wenzelm@3820
   142
wenzelm@2260
   143
oheimb@6027
   144
syntax (xsymbols)
oheimb@6027
   145
  "op -->"      :: [bool, bool] => bool             (infixr "\\<longrightarrow>" 25)
wenzelm@2260
   146
wenzelm@2260
   147
(** Rules and definitions **)
wenzelm@2260
   148
wenzelm@3947
   149
local
wenzelm@3947
   150
clasohm@923
   151
rules
clasohm@923
   152
clasohm@923
   153
  eq_reflection "(x=y) ==> (x==y)"
clasohm@923
   154
clasohm@923
   155
  (* Basic Rules *)
clasohm@923
   156
clasohm@923
   157
  refl          "t = (t::'a)"
clasohm@923
   158
  subst         "[| s = t; P(s) |] ==> P(t::'a)"
wenzelm@3842
   159
  ext           "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
wenzelm@3842
   160
  selectI       "P (x::'a) ==> P (@x. P x)"
clasohm@923
   161
clasohm@923
   162
  impI          "(P ==> Q) ==> P-->Q"
clasohm@923
   163
  mp            "[| P-->Q;  P |] ==> Q"
clasohm@923
   164
clasohm@923
   165
defs
clasohm@923
   166
wenzelm@3842
   167
  True_def      "True      == ((%x::bool. x) = (%x. x))"
wenzelm@3842
   168
  All_def       "All(P)    == (P = (%x. True))"
wenzelm@3842
   169
  Ex_def        "Ex(P)     == P(@x. P(x))"
wenzelm@3842
   170
  False_def     "False     == (!P. P)"
clasohm@923
   171
  not_def       "~ P       == P-->False"
clasohm@923
   172
  and_def       "P & Q     == !R. (P-->Q-->R) --> R"
clasohm@923
   173
  or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
clasohm@923
   174
  Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   175
clasohm@923
   176
rules
clasohm@923
   177
  (* Axioms *)
clasohm@923
   178
clasohm@923
   179
  iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
clasohm@923
   180
  True_or_False "(P=True) | (P=False)"
clasohm@923
   181
clasohm@923
   182
defs
wenzelm@5069
   183
  (*misc definitions*)
clasohm@923
   184
  Let_def       "Let s f == f(s)"
nipkow@973
   185
  if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
wenzelm@5069
   186
wenzelm@5069
   187
  (*arbitrary is completely unspecified, but is made to appear as a
wenzelm@5069
   188
    definition syntactically*)
wenzelm@4371
   189
  arbitrary_def "False ==> arbitrary == (@x. False)"
clasohm@923
   190
nipkow@3320
   191
wenzelm@4868
   192
wenzelm@4868
   193
(** initial HOL theory setup **)
wenzelm@4868
   194
wenzelm@4868
   195
setup Simplifier.setup
wenzelm@4868
   196
setup ClasetThyData.setup
wenzelm@4868
   197
wenzelm@4868
   198
clasohm@923
   199
end
clasohm@923
   200
wenzelm@2260
   201
clasohm@923
   202
ML
clasohm@923
   203
wenzelm@4793
   204
clasohm@923
   205
(** Choice between the HOL and Isabelle style of quantifiers **)
clasohm@923
   206
clasohm@923
   207
val HOL_quantifiers = ref true;
clasohm@923
   208
clasohm@923
   209
fun alt_ast_tr' (name, alt_name) =
clasohm@923
   210
  let
clasohm@923
   211
    fun ast_tr' (*name*) args =
clasohm@923
   212
      if ! HOL_quantifiers then raise Match
clasohm@923
   213
      else Syntax.mk_appl (Syntax.Constant alt_name) args;
clasohm@923
   214
  in
clasohm@923
   215
    (name, ast_tr')
clasohm@923
   216
  end;
clasohm@923
   217
clasohm@923
   218
clasohm@923
   219
val print_ast_translation =
clasohm@923
   220
  map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];