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