src/HOL/HOL.thy
author wenzelm
Thu Oct 04 15:42:48 2001 +0200 (2001-10-04)
changeset 11687 b0fe6e522559
parent 11451 8abfb4f7bd02
child 11698 3b3feb92207a
permissions -rw-r--r--
non-oriented infix = and ~= (output only);
added case_split (with case names);
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
paulson@11451
    10
files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"):
clasohm@923
    11
wenzelm@2260
    12
wenzelm@2260
    13
(** Core syntax **)
wenzelm@2260
    14
wenzelm@3947
    15
global
wenzelm@3947
    16
wenzelm@7357
    17
classes "term" < logic
wenzelm@7357
    18
defaultsort "term"
clasohm@923
    19
wenzelm@7357
    20
typedecl bool
clasohm@923
    21
clasohm@923
    22
arities
wenzelm@7357
    23
  bool :: "term"
wenzelm@7357
    24
  fun :: ("term", "term") "term"
clasohm@923
    25
clasohm@923
    26
consts
clasohm@923
    27
clasohm@923
    28
  (* Constants *)
clasohm@923
    29
wenzelm@7357
    30
  Trueprop      :: "bool => prop"                   ("(_)" 5)
wenzelm@7357
    31
  Not           :: "bool => bool"                   ("~ _" [40] 40)
wenzelm@7357
    32
  True          :: bool
wenzelm@7357
    33
  False         :: bool
wenzelm@7357
    34
  If            :: "[bool, 'a, 'a] => 'a"           ("(if (_)/ then (_)/ else (_))" 10)
wenzelm@3947
    35
  arbitrary     :: 'a
clasohm@923
    36
clasohm@923
    37
  (* Binders *)
clasohm@923
    38
wenzelm@11432
    39
  The           :: "('a => bool) => 'a"
wenzelm@7357
    40
  All           :: "('a => bool) => bool"           (binder "ALL " 10)
wenzelm@7357
    41
  Ex            :: "('a => bool) => bool"           (binder "EX " 10)
wenzelm@7357
    42
  Ex1           :: "('a => bool) => bool"           (binder "EX! " 10)
wenzelm@7357
    43
  Let           :: "['a, 'a => 'b] => 'b"
clasohm@923
    44
clasohm@923
    45
  (* Infixes *)
clasohm@923
    46
wenzelm@7357
    47
  "="           :: "['a, 'a] => bool"               (infixl 50)
wenzelm@7357
    48
  &             :: "[bool, bool] => bool"           (infixr 35)
wenzelm@7357
    49
  "|"           :: "[bool, bool] => bool"           (infixr 30)
wenzelm@7357
    50
  -->           :: "[bool, bool] => bool"           (infixr 25)
clasohm@923
    51
wenzelm@10432
    52
local
wenzelm@10432
    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@10432
    61
axclass inverse < "term"
wenzelm@10432
    62
wenzelm@10432
    63
global
paulson@3370
    64
wenzelm@2260
    65
consts
wenzelm@10432
    66
  "0"           :: "'a::zero"                       ("0")
wenzelm@7357
    67
  "+"           :: "['a::plus, 'a]  => 'a"          (infixl 65)
wenzelm@7357
    68
  -             :: "['a::minus, 'a] => 'a"          (infixl 65)
wenzelm@7357
    69
  uminus        :: "['a::minus] => 'a"              ("- _" [81] 80)
wenzelm@7426
    70
  *             :: "['a::times, 'a] => 'a"          (infixl 70)
wenzelm@10432
    71
wenzelm@10432
    72
local
wenzelm@10432
    73
wenzelm@10432
    74
consts
wenzelm@10432
    75
  abs           :: "'a::minus => 'a"
wenzelm@10432
    76
  inverse       :: "'a::inverse => 'a"
wenzelm@10432
    77
  divide        :: "['a::inverse, 'a] => 'a"        (infixl "'/" 70)
wenzelm@2260
    78
wenzelm@10489
    79
syntax (xsymbols)
wenzelm@11687
    80
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@10489
    81
syntax (HTML output)
wenzelm@11687
    82
  abs :: "'a::minus => 'a"    ("\<bar>_\<bar>")
wenzelm@10489
    83
paulson@8959
    84
axclass plus_ac0 < plus, zero
wenzelm@10432
    85
  commute: "x + y = y + x"
wenzelm@10432
    86
  assoc:   "(x + y) + z = x + (y + z)"
wenzelm@10432
    87
  zero:    "0 + x = x"
wenzelm@3820
    88
wenzelm@7238
    89
wenzelm@2260
    90
(** Additional concrete syntax **)
wenzelm@2260
    91
wenzelm@4868
    92
nonterminals
clasohm@923
    93
  letbinds  letbind
clasohm@923
    94
  case_syn  cases_syn
clasohm@923
    95
clasohm@923
    96
syntax
wenzelm@7357
    97
  ~=            :: "['a, 'a] => bool"                    (infixl 50)
wenzelm@11432
    98
  "_The"        :: "[pttrn, bool] => 'a"                 ("(3THE _./ _)" [0, 10] 10)
clasohm@923
    99
clasohm@923
   100
  (* Let expressions *)
clasohm@923
   101
wenzelm@7357
   102
  "_bind"       :: "[pttrn, 'a] => letbind"              ("(2_ =/ _)" 10)
wenzelm@7357
   103
  ""            :: "letbind => letbinds"                 ("_")
wenzelm@7357
   104
  "_binds"      :: "[letbind, letbinds] => letbinds"     ("_;/ _")
wenzelm@7357
   105
  "_Let"        :: "[letbinds, 'a] => 'a"                ("(let (_)/ in (_))" 10)
clasohm@923
   106
clasohm@923
   107
  (* Case expressions *)
clasohm@923
   108
wenzelm@9060
   109
  "_case_syntax":: "['a, cases_syn] => 'b"               ("(case _ of/ _)" 10)
wenzelm@9060
   110
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ =>/ _)" 10)
wenzelm@7357
   111
  ""            :: "case_syn => cases_syn"               ("_")
wenzelm@9060
   112
  "_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ | _")
clasohm@923
   113
clasohm@923
   114
translations
wenzelm@7238
   115
  "x ~= y"                == "~ (x = y)"
wenzelm@11432
   116
  "THE x. P"              == "The (%x. P)"
clasohm@923
   117
  "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
nipkow@1114
   118
  "let x = a in e"        == "Let a (%x. e)"
clasohm@923
   119
wenzelm@3820
   120
syntax ("" output)
wenzelm@11687
   121
  "="           :: "['a, 'a] => bool"                    (infix 50)
wenzelm@11687
   122
  "~="          :: "['a, 'a] => bool"                    (infix 50)
wenzelm@2260
   123
wenzelm@2260
   124
syntax (symbols)
wenzelm@11687
   125
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
wenzelm@11687
   126
  "op &"        :: "[bool, bool] => bool"                (infixr "\<and>" 35)
wenzelm@11687
   127
  "op |"        :: "[bool, bool] => bool"                (infixr "\<or>" 30)
wenzelm@11687
   128
  "op -->"      :: "[bool, bool] => bool"                (infixr "\<midarrow>\<rightarrow>" 25)
wenzelm@11687
   129
  "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@11687
   130
  "ALL "        :: "[idts, bool] => bool"                ("(3\<forall>_./ _)" [0, 10] 10)
wenzelm@11687
   131
  "EX "         :: "[idts, bool] => bool"                ("(3\<exists>_./ _)" [0, 10] 10)
wenzelm@11687
   132
  "EX! "        :: "[idts, bool] => bool"                ("(3\<exists>!_./ _)" [0, 10] 10)
wenzelm@11687
   133
  "_case1"      :: "['a, 'b] => case_syn"                ("(2_ \<Rightarrow>/ _)" 10)
wenzelm@9060
   134
(*"_case2"      :: "[case_syn, cases_syn] => cases_syn"  ("_/ \\<orelse> _")*)
wenzelm@2372
   135
wenzelm@3820
   136
syntax (symbols output)
wenzelm@11687
   137
  "op ~="       :: "['a, 'a] => bool"                    (infix "\<noteq>" 50)
wenzelm@3820
   138
oheimb@6027
   139
syntax (xsymbols)
wenzelm@11687
   140
  "op -->"      :: "[bool, bool] => bool"                (infixr "\<longrightarrow>" 25)
wenzelm@2260
   141
wenzelm@6340
   142
syntax (HTML output)
wenzelm@11687
   143
  Not           :: "bool => bool"                        ("\<not> _" [40] 40)
wenzelm@6340
   144
wenzelm@7238
   145
syntax (HOL)
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@11432
   168
  the_eq_trivial: "(THE x. x = a) = (a::'a)"
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))"
paulson@11451
   177
  Ex_def:       "Ex(P)     == !Q. (!x. P x --> Q) --> Q"
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)"
paulson@11451
   193
  if_def:       "If P x y == THE 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*)
paulson@11451
   197
  arbitrary_def:  "False ==> arbitrary == (THE 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@11687
   204
theorems case_split = case_split_thm [case_names True False]
wenzelm@9869
   205
wenzelm@11438
   206
declare trans [trans]  (*overridden in theory Calculation*)
wenzelm@11438
   207
wenzelm@10432
   208
lemma atomize_all: "(!!x. P x) == Trueprop (ALL x. P x)"
wenzelm@9488
   209
proof (rule equal_intr_rule)
wenzelm@9488
   210
  assume "!!x. P x"
wenzelm@10383
   211
  show "ALL x. P x" by (rule allI)
wenzelm@9488
   212
next
wenzelm@9488
   213
  assume "ALL x. P x"
wenzelm@10383
   214
  thus "!!x. P x" by (rule allE)
wenzelm@9488
   215
qed
wenzelm@9488
   216
wenzelm@10432
   217
lemma atomize_imp: "(A ==> B) == Trueprop (A --> B)"
wenzelm@9488
   218
proof (rule equal_intr_rule)
wenzelm@9488
   219
  assume r: "A ==> B"
wenzelm@10383
   220
  show "A --> B" by (rule impI) (rule r)
wenzelm@9488
   221
next
wenzelm@9488
   222
  assume "A --> B" and A
wenzelm@10383
   223
  thus B by (rule mp)
wenzelm@9488
   224
qed
wenzelm@9488
   225
wenzelm@10432
   226
lemma atomize_eq: "(x == y) == Trueprop (x = y)"
wenzelm@10432
   227
proof (rule equal_intr_rule)
wenzelm@10432
   228
  assume "x == y"
wenzelm@10432
   229
  show "x = y" by (unfold prems) (rule refl)
wenzelm@10432
   230
next
wenzelm@10432
   231
  assume "x = y"
wenzelm@10432
   232
  thus "x == y" by (rule eq_reflection)
wenzelm@10432
   233
qed
wenzelm@10432
   234
wenzelm@10432
   235
lemmas atomize = atomize_all atomize_imp
wenzelm@10432
   236
lemmas atomize' = atomize atomize_eq
wenzelm@9529
   237
wenzelm@10383
   238
use "cladata.ML"
wenzelm@10383
   239
setup hypsubst_setup
wenzelm@10383
   240
setup Classical.setup
wenzelm@10383
   241
setup clasetup
wenzelm@10383
   242
wenzelm@9869
   243
use "blastdata.ML"
wenzelm@9869
   244
setup Blast.setup
wenzelm@4868
   245
wenzelm@9869
   246
use "simpdata.ML"
wenzelm@9869
   247
setup Simplifier.setup
wenzelm@9869
   248
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup
wenzelm@9869
   249
setup Splitter.setup setup Clasimp.setup
wenzelm@9869
   250
clasohm@923
   251
end