src/HOL/HOL.thy
author wenzelm
Fri Oct 10 19:02:28 1997 +0200 (1997-10-10)
changeset 3842 b55686a7b22c
parent 3820 46b255e140dc
child 3947 eb707467f8c5
permissions -rw-r--r--
fixed dots;
     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 classes
    15   term < logic
    16 
    17 default
    18   term
    19 
    20 types
    21   bool
    22 
    23 arities
    24   fun :: (term, term) term
    25   bool :: term
    26 
    27 
    28 consts
    29 
    30   (* Constants *)
    31 
    32   Trueprop      :: bool => prop                     ("(_)" 5)
    33   Not           :: bool => bool                     ("~ _" [40] 40)
    34   True, False   :: bool
    35   If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
    36 
    37   (* Binders *)
    38 
    39   Eps           :: ('a => bool) => 'a
    40   All           :: ('a => bool) => bool             (binder "! " 10)
    41   Ex            :: ('a => bool) => bool             (binder "? " 10)
    42   Ex1           :: ('a => bool) => bool             (binder "?! " 10)
    43   Let           :: ['a, 'a => 'b] => 'b
    44 
    45   (* Infixes *)
    46 
    47   o             :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
    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 
    54 (* Overloaded Constants *)
    55 
    56 axclass
    57   plus < term
    58 
    59 axclass
    60   minus < term
    61 
    62 axclass
    63   times < term
    64 
    65 axclass
    66   power < term
    67 
    68 consts
    69   "+"           :: ['a::plus, 'a]  => 'a            (infixl 65)
    70   "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
    71   "*"           :: ['a::times, 'a] => 'a            (infixl 70)
    72   (*See Nat.thy for "^"*)
    73 
    74 
    75 (** Additional concrete syntax **)
    76 
    77 types
    78   letbinds  letbind
    79   case_syn  cases_syn
    80 
    81 syntax
    82 
    83   "~="          :: ['a, 'a] => bool                 (infixl 50)
    84 
    85   "@Eps"        :: [pttrn, bool] => 'a              ("(3@ _./ _)" [0, 10] 10)
    86 
    87   (* Alternative Quantifiers *)
    88 
    89   "*All"        :: [idts, bool] => bool             ("(3ALL _./ _)" [0, 10] 10)
    90   "*Ex"         :: [idts, bool] => bool             ("(3EX _./ _)" [0, 10] 10)
    91   "*Ex1"        :: [idts, bool] => bool             ("(3EX! _./ _)" [0, 10] 10)
    92 
    93   (* Let expressions *)
    94 
    95   "_bind"       :: [pttrn, 'a] => letbind           ("(2_ =/ _)" 10)
    96   ""            :: letbind => letbinds              ("_")
    97   "_binds"      :: [letbind, letbinds] => letbinds  ("_;/ _")
    98   "_Let"        :: [letbinds, 'a] => 'a             ("(let (_)/ in (_))" 10)
    99 
   100   (* Case expressions *)
   101 
   102   "@case"       :: ['a, cases_syn] => 'b            ("(case _ of/ _)" 10)
   103   "@case1"      :: ['a, 'b] => case_syn             ("(2_ =>/ _)" 10)
   104   ""            :: case_syn => cases_syn            ("_")
   105   "@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ | _")
   106 
   107 translations
   108   "x ~= y"      == "~ (x = y)"
   109   "@ x. b"      == "Eps (%x. b)"
   110   "ALL xs. P"   => "! xs. P"
   111   "EX xs. P"    => "? xs. P"
   112   "EX! xs. P"   => "?! xs. 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 o"        :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl "\\<circ>" 55)
   126   "op ~="       :: ['a, 'a] => bool                 (infixl "\\<noteq>" 50)
   127   "@Eps"        :: [pttrn, bool] => 'a              ("(3\\<epsilon>_./ _)" [0, 10] 10)
   128   "! "          :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
   129   "? "          :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
   130   "?! "         :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" [0, 10] 10)
   131   "@case1"      :: ['a, 'b] => case_syn             ("(2_ \\<Rightarrow>/ _)" 10)
   132 (*"@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ \\<orelse> _")*)
   133 
   134 syntax (symbols output)
   135   "op ~="       :: ['a, 'a] => bool                 ("(_ \\<noteq>/ _)" [51, 51] 50)
   136   "*All"        :: [idts, bool] => bool             ("(3\\<forall>_./ _)" [0, 10] 10)
   137   "*Ex"         :: [idts, bool] => bool             ("(3\\<exists>_./ _)" [0, 10] 10)
   138   "*Ex1"        :: [idts, bool] => bool             ("(3\\<exists>!_./ _)" [0, 10] 10)
   139 
   140 
   141 
   142 (** Rules and definitions **)
   143 
   144 rules
   145 
   146   eq_reflection "(x=y) ==> (x==y)"
   147 
   148   (* Basic Rules *)
   149 
   150   refl          "t = (t::'a)"
   151   subst         "[| s = t; P(s) |] ==> P(t::'a)"
   152   ext           "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   153   selectI       "P (x::'a) ==> P (@x. P x)"
   154 
   155   impI          "(P ==> Q) ==> P-->Q"
   156   mp            "[| P-->Q;  P |] ==> Q"
   157 
   158 defs
   159 
   160   True_def      "True      == ((%x::bool. x) = (%x. x))"
   161   All_def       "All(P)    == (P = (%x. True))"
   162   Ex_def        "Ex(P)     == P(@x. P(x))"
   163   False_def     "False     == (!P. P)"
   164   not_def       "~ P       == P-->False"
   165   and_def       "P & Q     == !R. (P-->Q-->R) --> R"
   166   or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   167   Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   168 
   169 rules
   170   (* Axioms *)
   171 
   172   iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
   173   True_or_False "(P=True) | (P=False)"
   174 
   175 defs
   176   (* Misc Definitions *)
   177 
   178   Let_def       "Let s f == f(s)"
   179   o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
   180   if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
   181 
   182 consts
   183   arbitrary :: 'a
   184 
   185 
   186 end
   187 
   188 
   189 ML
   190 
   191 (** Choice between the HOL and Isabelle style of quantifiers **)
   192 
   193 val HOL_quantifiers = ref true;
   194 
   195 fun alt_ast_tr' (name, alt_name) =
   196   let
   197     fun ast_tr' (*name*) args =
   198       if ! HOL_quantifiers then raise Match
   199       else Syntax.mk_appl (Syntax.Constant alt_name) args;
   200   in
   201     (name, ast_tr')
   202   end;
   203 
   204 
   205 val print_ast_translation =
   206   map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];