src/HOL/HOL.thy
author wenzelm
Mon Oct 20 11:25:39 1997 +0200 (1997-10-20)
changeset 3947 eb707467f8c5
parent 3842 b55686a7b22c
child 4083 bcff38832d89
permissions -rw-r--r--
adapted to qualified names;
     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   o             :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
    51   "="           :: ['a, 'a] => bool                 (infixl 50)
    52   "&"           :: [bool, bool] => bool             (infixr 35)
    53   "|"           :: [bool, bool] => bool             (infixr 30)
    54   "-->"         :: [bool, bool] => bool             (infixr 25)
    55 
    56 
    57 (* Overloaded Constants *)
    58 
    59 axclass
    60   plus < term
    61 
    62 axclass
    63   minus < term
    64 
    65 axclass
    66   times < term
    67 
    68 axclass
    69   power < term
    70 
    71 consts
    72   "+"           :: ['a::plus, 'a]  => 'a            (infixl 65)
    73   "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
    74   "*"           :: ['a::times, 'a] => 'a            (infixl 70)
    75   (*See Nat.thy for "^"*)
    76 
    77 
    78 (** Additional concrete syntax **)
    79 
    80 types
    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 
   144 
   145 (** Rules and definitions **)
   146 
   147 local
   148 
   149 rules
   150 
   151   eq_reflection "(x=y) ==> (x==y)"
   152 
   153   (* Basic Rules *)
   154 
   155   refl          "t = (t::'a)"
   156   subst         "[| s = t; P(s) |] ==> P(t::'a)"
   157   ext           "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)"
   158   selectI       "P (x::'a) ==> P (@x. P x)"
   159 
   160   impI          "(P ==> Q) ==> P-->Q"
   161   mp            "[| P-->Q;  P |] ==> Q"
   162 
   163 defs
   164 
   165   True_def      "True      == ((%x::bool. x) = (%x. x))"
   166   All_def       "All(P)    == (P = (%x. True))"
   167   Ex_def        "Ex(P)     == P(@x. P(x))"
   168   False_def     "False     == (!P. P)"
   169   not_def       "~ P       == P-->False"
   170   and_def       "P & Q     == !R. (P-->Q-->R) --> R"
   171   or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   172   Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   173 
   174 rules
   175   (* Axioms *)
   176 
   177   iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
   178   True_or_False "(P=True) | (P=False)"
   179 
   180 defs
   181   (* Misc Definitions *)
   182 
   183   Let_def       "Let s f == f(s)"
   184   o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
   185   if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
   186 
   187 
   188 end
   189 
   190 
   191 ML
   192 
   193 (** Choice between the HOL and Isabelle style of quantifiers **)
   194 
   195 val HOL_quantifiers = ref true;
   196 
   197 fun alt_ast_tr' (name, alt_name) =
   198   let
   199     fun ast_tr' (*name*) args =
   200       if ! HOL_quantifiers then raise Match
   201       else Syntax.mk_appl (Syntax.Constant alt_name) args;
   202   in
   203     (name, ast_tr')
   204   end;
   205 
   206 
   207 val print_ast_translation =
   208   map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];