src/HOL/HOL.thy
author wenzelm
Wed Sep 13 22:29:17 2000 +0200 (2000-09-13)
changeset 9950 879e88b1e552
parent 9890 144ecc001b8f
child 9970 dfe4747c8318
permissions -rw-r--r--
\<epsilon>: syntax (input);
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
wenzelm@7357
     9
theory HOL = CPure
wenzelm@9869
    10
files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML")
wenzelm@9869
    11
  ("meson_lemmas.ML") ("Tools/meson.ML"):
clasohm@923
    12
wenzelm@2260
    13
wenzelm@2260
    14
(** Core syntax **)
wenzelm@2260
    15
wenzelm@3947
    16
global
wenzelm@3947
    17
wenzelm@7357
    18
classes "term" < logic
wenzelm@7357
    19
defaultsort "term"
clasohm@923
    20
wenzelm@7357
    21
typedecl bool
clasohm@923
    22
clasohm@923
    23
arities
wenzelm@7357
    24
  bool :: "term"
wenzelm@7357
    25
  fun :: ("term", "term") "term"
clasohm@923
    26
clasohm@923
    27
clasohm@923
    28
consts
clasohm@923
    29
clasohm@923
    30
  (* Constants *)
clasohm@923
    31
wenzelm@7357
    32
  Trueprop      :: "bool => prop"                   ("(_)" 5)
wenzelm@7357
    33
  Not           :: "bool => bool"                   ("~ _" [40] 40)
wenzelm@7357
    34
  True          :: bool
wenzelm@7357
    35
  False         :: bool
wenzelm@7357
    36
  If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
wenzelm@3947
    37
  arbitrary     :: 'a
clasohm@923
    38
clasohm@923
    39
  (* Binders *)
clasohm@923
    40
wenzelm@7357
    41
  Eps           :: "('a => bool) => 'a"
wenzelm@7357
    42
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
wenzelm@7357
    43
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
wenzelm@7357
    44
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
wenzelm@7357
    45
  Let           :: "['a, 'a => 'b] => 'b"
clasohm@923
    46
clasohm@923
    47
  (* Infixes *)
clasohm@923
    48
wenzelm@7357
    49
  "="           :: "['a, 'a] => bool"               (infixl 50)
wenzelm@7357
    50
  &             :: "[bool, bool] => bool"           (infixr 35)
wenzelm@7357
    51
  "|"           :: "[bool, bool] => bool"           (infixr 30)
wenzelm@7357
    52
  -->           :: "[bool, bool] => bool"           (infixr 25)
clasohm@923
    53
wenzelm@2260
    54
wenzelm@2260
    55
(* Overloaded Constants *)
wenzelm@2260
    56
wenzelm@9869
    57
axclass zero  < "term"
paulson@8940
    58
axclass plus  < "term"
wenzelm@7357
    59
axclass minus < "term"
wenzelm@7357
    60
axclass times < "term"
wenzelm@7357
    61
axclass power < "term"
paulson@3370
    62
wenzelm@2260
    63
consts
paulson@8940
    64
  "0"           :: "('a::zero)"                     ("0")
wenzelm@7357
    65
  "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
wenzelm@7357
    66
  -             :: "['a::minus, 'a] => 'a"          (infixl 65)
wenzelm@7357
    67
  uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
wenzelm@9869
    68
  abs           :: "('a::minus) => 'a"
wenzelm@7426
    69
  *             :: "['a::times, 'a] => 'a"          (infixl 70)
paulson@3370
    70
  (*See Nat.thy for "^"*)
wenzelm@2260
    71
paulson@8959
    72
axclass plus_ac0 < plus, zero
paulson@8959
    73
    commute: "x + y = y + x"
paulson@8959
    74
    assoc:   "(x + y) + z = x + (y + z)"
paulson@8959
    75
    zero:    "0 + x = x"
wenzelm@3820
    76
wenzelm@7238
    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
wenzelm@7357
    85
  ~=            :: "['a, 'a] => bool"                    (infixl 50)
wenzelm@7357
    86
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3SOME _./ _)" [0, 10] 10)
clasohm@923
    87
clasohm@923
    88
  (* Let expressions *)
clasohm@923
    89
wenzelm@7357
    90
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
wenzelm@7357
    91
  ""            :: "letbind => letbinds"                 ("_")
wenzelm@7357
    92
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
wenzelm@7357
    93
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
clasohm@923
    94
clasohm@923
    95
  (* Case expressions *)
clasohm@923
    96
wenzelm@9060
    97
  "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
wenzelm@9060
    98
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
wenzelm@7357
    99
  ""            :: "case_syn => cases_syn"               ("_")
wenzelm@9060
   100
  "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
clasohm@923
   101
clasohm@923
   102
translations
wenzelm@7238
   103
  "x ~= y"                == "~ (x = y)"
wenzelm@7238
   104
  "SOME x. P"             == "Eps (%x. P)"
clasohm@923
   105
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
   106
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
   107
wenzelm@3820
   108
syntax ("" output)
wenzelm@7357
   109
  "op ="        :: "['a, 'a] => bool"                    ("(_ =/ _)" [51, 51] 50)
wenzelm@7357
   110
  "op ~="       :: "['a, 'a] => bool"                    ("(_ ~=/ _)" [51, 51] 50)
wenzelm@2260
   111
wenzelm@2260
   112
syntax (symbols)
wenzelm@7357
   113
  Not           :: "bool => bool"                        ("\\<not> _" [40] 40)
wenzelm@7357
   114
  "op &"        :: "[bool, bool] => bool"                (infixr "\\<and>" 35)
wenzelm@7357
   115
  "op |"        :: "[bool, bool] => bool"                (infixr "\\<or>" 30)
wenzelm@7357
   116
  "op -->"      :: "[bool, bool] => bool"                (infixr "\\<midarrow>\\<rightarrow>" 25)
wenzelm@7357
   117
  "op ~="       :: "['a, 'a] => bool"                    (infixl "\\<noteq>" 50)
wenzelm@7357
   118
  "ALL "        :: "[idts, bool] => bool"                ("(3\\<forall>_./ _)" [0, 10] 10)
wenzelm@7357
   119
  "EX "         :: "[idts, bool] => bool"                ("(3\\<exists>_./ _)" [0, 10] 10)
wenzelm@7357
   120
  "EX! "        :: "[idts, bool] => bool"                ("(3\\<exists>!_./ _)" [0, 10] 10)
wenzelm@9060
   121
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \\<Rightarrow>/ _)" 10)
wenzelm@9060
   122
(*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \\<orelse> _")*)
wenzelm@2372
   123
wenzelm@9950
   124
syntax (input)
wenzelm@9950
   125
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3\\<epsilon>_./ _)" [0, 10] 10)
wenzelm@9950
   126
wenzelm@3820
   127
syntax (symbols output)
wenzelm@7357
   128
  "op ~="       :: "['a, 'a] => bool"                    ("(_ \\<noteq>/ _)" [51, 51] 50)
wenzelm@3820
   129
oheimb@6027
   130
syntax (xsymbols)
wenzelm@7357
   131
  "op -->"      :: "[bool, bool] => bool"                (infixr "\\<longrightarrow>" 25)
wenzelm@2260
   132
wenzelm@6340
   133
syntax (HTML output)
wenzelm@7357
   134
  Not           :: "bool => bool"                        ("\\<not> _" [40] 40)
wenzelm@6340
   135
wenzelm@7238
   136
syntax (HOL)
wenzelm@7357
   137
  "_Eps"        :: "[pttrn, bool] => 'a"                 ("(3@ _./ _)" [0, 10] 10)
wenzelm@7357
   138
  "ALL "        :: "[idts, bool] => bool"                ("(3! _./ _)" [0, 10] 10)
wenzelm@7357
   139
  "EX "         :: "[idts, bool] => bool"                ("(3? _./ _)" [0, 10] 10)
wenzelm@7357
   140
  "EX! "        :: "[idts, bool] => bool"                ("(3?! _./ _)" [0, 10] 10)
wenzelm@7238
   141
wenzelm@7238
   142
wenzelm@6340
   143
wenzelm@2260
   144
(** Rules and definitions **)
wenzelm@2260
   145
wenzelm@3947
   146
local
wenzelm@3947
   147
wenzelm@7357
   148
axioms
clasohm@923
   149
wenzelm@7357
   150
  eq_reflection: "(x=y) ==> (x==y)"
clasohm@923
   151
clasohm@923
   152
  (* Basic Rules *)
clasohm@923
   153
wenzelm@7357
   154
  refl:         "t = (t::'a)"
wenzelm@7357
   155
  subst:        "[| s = t; P(s) |] ==> P(t::'a)"
paulson@6289
   156
paulson@6289
   157
  (*Extensionality is built into the meta-logic, and this rule expresses
paulson@6289
   158
    a related property.  It is an eta-expanded version of the traditional
paulson@6289
   159
    rule, and similar to the ABS rule of HOL.*)
wenzelm@7357
   160
  ext:          "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
paulson@6289
   161
wenzelm@7357
   162
  selectI:      "P (x::'a) ==> P (@x. P x)"
clasohm@923
   163
wenzelm@7357
   164
  impI:         "(P ==> Q) ==> P-->Q"
wenzelm@7357
   165
  mp:           "[| P-->Q;  P |] ==> Q"
clasohm@923
   166
clasohm@923
   167
defs
clasohm@923
   168
wenzelm@7357
   169
  True_def:     "True      == ((%x::bool. x) = (%x. x))"
wenzelm@7357
   170
  All_def:      "All(P)    == (P = (%x. True))"
wenzelm@7357
   171
  Ex_def:       "Ex(P)     == P(@x. P(x))"
wenzelm@7357
   172
  False_def:    "False     == (!P. P)"
wenzelm@7357
   173
  not_def:      "~ P       == P-->False"
wenzelm@7357
   174
  and_def:      "P & Q     == !R. (P-->Q-->R) --> R"
wenzelm@7357
   175
  or_def:       "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
wenzelm@7357
   176
  Ex1_def:      "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
clasohm@923
   177
wenzelm@7357
   178
axioms
clasohm@923
   179
  (* Axioms *)
clasohm@923
   180
wenzelm@7357
   181
  iff:          "(P-->Q) --> (Q-->P) --> (P=Q)"
wenzelm@7357
   182
  True_or_False:  "(P=True) | (P=False)"
clasohm@923
   183
clasohm@923
   184
defs
wenzelm@5069
   185
  (*misc definitions*)
wenzelm@7357
   186
  Let_def:      "Let s f == f(s)"
wenzelm@7357
   187
  if_def:       "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
wenzelm@5069
   188
wenzelm@5069
   189
  (*arbitrary is completely unspecified, but is made to appear as a
wenzelm@5069
   190
    definition syntactically*)
wenzelm@7357
   191
  arbitrary_def:  "False ==> arbitrary == (@x. False)"
clasohm@923
   192
nipkow@3320
   193
wenzelm@4868
   194
wenzelm@7357
   195
(* theory and package setup *)
wenzelm@4868
   196
nipkow@9736
   197
use "HOL_lemmas.ML"
wenzelm@9869
   198
wenzelm@9869
   199
use "cladata.ML"
wenzelm@9869
   200
setup hypsubst_setup
wenzelm@9869
   201
setup Classical.setup
wenzelm@9869
   202
setup clasetup
wenzelm@9488
   203
wenzelm@9488
   204
lemma all_eq: "(!!x. P x) == Trueprop (ALL x. P x)"
wenzelm@9488
   205
proof (rule equal_intr_rule)
wenzelm@9488
   206
  assume "!!x. P x"
wenzelm@9488
   207
  show "ALL x. P x" ..
wenzelm@9488
   208
next
wenzelm@9488
   209
  assume "ALL x. P x"
wenzelm@9488
   210
  thus "!!x. P x" ..
wenzelm@9488
   211
qed
wenzelm@9488
   212
wenzelm@9488
   213
lemma imp_eq: "(A ==> B) == Trueprop (A --> B)"
wenzelm@9488
   214
proof (rule equal_intr_rule)
wenzelm@9488
   215
  assume r: "A ==> B"
wenzelm@9488
   216
  show "A --> B"
wenzelm@9488
   217
    by (rule) (rule r)
wenzelm@9488
   218
next
wenzelm@9488
   219
  assume "A --> B" and A
wenzelm@9488
   220
  thus B ..
wenzelm@9488
   221
qed
wenzelm@9488
   222
wenzelm@9529
   223
lemmas atomize = all_eq imp_eq
wenzelm@9529
   224
wenzelm@9869
   225
use "blastdata.ML"
wenzelm@9869
   226
setup Blast.setup
wenzelm@4868
   227
wenzelm@9869
   228
use "simpdata.ML"
wenzelm@9869
   229
setup Simplifier.setup
wenzelm@9869
   230
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
wenzelm@9869
   231
setup Splitter.setup setup Clasimp.setup
wenzelm@9869
   232
wenzelm@9869
   233
use "meson_lemmas.ML"
paulson@9839
   234
use "Tools/meson.ML"
wenzelm@9869
   235
setup meson_setup
paulson@9839
   236
clasohm@923
   237
end