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