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