src/HOL/HOL.thy
author paulson
Mon Aug 16 18:43:13 1999 +0200 (1999-08-16)
changeset 7220 da6f387ca482
parent 7203 36990a7c7c72
child 7238 36e58620ffc8
permissions -rw-r--r--
restored a high precedence to unary minus
     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 HOL = CPure +
    10 
    11 
    12 (** Core syntax **)
    13 
    14 global
    15 
    16 classes
    17   term < logic
    18 
    19 default
    20   term
    21 
    22 types
    23   bool
    24 
    25 arities
    26   fun :: (term, term) term
    27   bool :: term
    28 
    29 
    30 consts
    31 
    32   (* Constants *)
    33 
    34   Trueprop      :: bool => prop                     ("(_)" 5)
    35   Not           :: bool => bool                     ("~ _" [40] 40)
    36   True, False   :: bool
    37   If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
    38   arbitrary     :: 'a
    39 
    40   (* Binders *)
    41 
    42   Eps           :: ('a => bool) => 'a
    43   All           :: ('a => bool) => bool             (binder "! " 10)
    44   Ex            :: ('a => bool) => bool             (binder "? " 10)
    45   Ex1           :: ('a => bool) => bool             (binder "?! " 10)
    46   Let           :: ['a, 'a => 'b] => 'b
    47 
    48   (* Infixes *)
    49 
    50   "="           :: ['a, 'a] => bool                 (infixl 50)
    51   "&"           :: [bool, bool] => bool             (infixr 35)
    52   "|"           :: [bool, bool] => bool             (infixr 30)
    53   "-->"         :: [bool, bool] => bool             (infixr 25)
    54 
    55 
    56 (* Overloaded Constants *)
    57 
    58 axclass
    59   plus < term
    60 
    61 axclass
    62   minus < term
    63 
    64 axclass
    65   times < term
    66 
    67 axclass
    68   power < term
    69 
    70 consts
    71   "+"           :: ['a::plus, 'a]  => 'a            (infixl 65)
    72   "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
    73   uminus        :: ['a::minus] => 'a                ("- _" [81] 80)
    74   "*"           :: ['a::times, 'a] => 'a            (infixl 70)
    75   (*See Nat.thy for "^"*)
    76 
    77 
    78 (** Additional concrete syntax **)
    79 
    80 nonterminals
    81   letbinds  letbind
    82   case_syn  cases_syn
    83 
    84 syntax
    85 
    86   "~="          :: ['a, 'a] => bool                 (infixl 50)
    87 
    88   "@Eps"        :: [pttrn, bool] => 'a              ("(3@ _./ _)" [0, 10] 10)
    89 
    90   (* Alternative Quantifiers *)
    91 
    92   "*All"        :: [idts, bool] => bool             ("(3ALL _./ _)" [0, 10] 10)
    93   "*Ex"         :: [idts, bool] => bool             ("(3EX _./ _)" [0, 10] 10)
    94   "*Ex1"        :: [idts, bool] => bool             ("(3EX! _./ _)" [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"       :: ['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   "@ x. b"      == "Eps (%x. b)"
   113   "ALL xs. P"   => "! xs. P"
   114   "EX xs. P"    => "? xs. P"
   115   "EX! xs. P"   => "?! xs. P"
   116   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
   117   "let x = a in e"        == "Let a (%x. e)"
   118 
   119 syntax ("" output)
   120   "op ="        :: ['a, 'a] => bool                 ("(_ =/ _)" [51, 51] 50)
   121   "op ~="       :: ['a, 'a] => bool                 ("(_ ~=/ _)" [51, 51] 50)
   122 
   123 syntax (symbols)
   124   Not           :: bool => bool                     ("\\<not> _" [40] 40)
   125   "op &"        :: [bool, bool] => bool             (infixr "\\<and>" 35)
   126   "op |"        :: [bool, bool] => bool             (infixr "\\<or>" 30)
   127   "op -->"      :: [bool, bool] => bool             (infixr "\\<midarrow>\\<rightarrow>" 25)
   128   "op o"        :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl "\\<circ>" 55)
   129   "op ~="       :: ['a, 'a] => bool                 (infixl "\\<noteq>" 50)
   130   "@Eps"        :: [pttrn, bool] => 'a              ("(3\\<epsilon>_./ _)" [0, 10] 10)
   131   "! "          :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
   132   "? "          :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
   133   "?! "         :: [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 (symbols output)
   138   "op ~="       :: ['a, 'a] => bool                 ("(_ \\<noteq>/ _)" [51, 51] 50)
   139   "*All"        :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
   140   "*Ex"         :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
   141   "*Ex1"        :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" [0, 10] 10)
   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 
   150 (** Rules and definitions **)
   151 
   152 local
   153 
   154 rules
   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   selectI       "P (x::'a) ==> P (@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(@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 rules
   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 == @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 == (@x. False)"
   198 
   199 
   200 
   201 (** initial HOL theory setup **)
   202 
   203 setup Simplifier.setup
   204 setup ClasetThyData.setup
   205 
   206 
   207 end
   208 
   209 
   210 ML
   211 
   212 
   213 (** Choice between the HOL and Isabelle style of quantifiers **)
   214 
   215 val HOL_quantifiers = ref true;
   216 
   217 fun alt_ast_tr' (name, alt_name) =
   218   let
   219     fun ast_tr' (*name*) args =
   220       if ! HOL_quantifiers then raise Match
   221       else Syntax.mk_appl (Syntax.Constant alt_name) args;
   222   in
   223     (name, ast_tr')
   224   end;
   225 
   226 
   227 val print_ast_translation =
   228   map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];