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