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