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