src/HOL/HOL.thy
author oheimb
Tue Apr 23 16:58:21 1996 +0200 (1996-04-23)
changeset 1672 2c109cd2fdd0
parent 1370 7361ac9b024d
child 1674 33aff4d854e4
permissions -rw-r--r--
repaired critical proofs depending on the order inside non-confluent SimpSets,
(temporarily) removed problematic rule less_Suc_eq form simpset_of "Nat"
     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 classes
    12   term < logic
    13 
    14 axclass
    15   plus < term
    16 
    17 axclass
    18   minus < term
    19 
    20 axclass
    21   times < term
    22 
    23 default
    24   term
    25 
    26 types
    27   bool
    28 
    29 arities
    30   fun :: (term, term) term
    31   bool :: term
    32 
    33 
    34 consts
    35 
    36   (* Constants *)
    37 
    38   Trueprop      :: bool => prop                     ("(_)" 5)
    39   not           :: bool => bool                     ("~ _" [40] 40)
    40   True, False   :: bool
    41   If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
    42   Inv           :: ('a => 'b) => ('b => 'a)
    43 
    44   (* Binders *)
    45 
    46   Eps           :: ('a => bool) => 'a
    47   All           :: ('a => bool) => bool             (binder "! " 10)
    48   Ex            :: ('a => bool) => bool             (binder "? " 10)
    49   Ex1           :: ('a => bool) => bool             (binder "?! " 10)
    50   Let           :: ['a, 'a => 'b] => 'b
    51 
    52   (* Infixes *)
    53 
    54   o             :: ['b => 'c, 'a => 'b, 'a] => 'c   (infixl 55)
    55   "="           :: ['a, 'a] => bool                 (infixl 50)
    56   "&"           :: [bool, bool] => bool             (infixr 35)
    57   "|"           :: [bool, bool] => bool             (infixr 30)
    58   "-->"         :: [bool, bool] => bool             (infixr 25)
    59 
    60   (* Overloaded Constants *)
    61 
    62   "+"           :: ['a::plus, 'a] => 'a             (infixl 65)
    63   "-"           :: ['a::minus, 'a] => 'a            (infixl 65)
    64   "*"           :: ['a::times, 'a] => 'a            (infixl 70)
    65 
    66 
    67 types
    68   letbinds  letbind
    69   case_syn  cases_syn
    70 
    71 syntax
    72 
    73   "~="          :: ['a, 'a] => bool                 (infixl 50)
    74 
    75   "@Eps"        :: [pttrn,bool] => 'a               ("(3@ _./ _)" 10)
    76 
    77   (* Alternative Quantifiers *)
    78 
    79   "*All"        :: [idts, bool] => bool             ("(3ALL _./ _)" 10)
    80   "*Ex"         :: [idts, bool] => bool             ("(3EX _./ _)" 10)
    81   "*Ex1"        :: [idts, bool] => bool             ("(3EX! _./ _)" 10)
    82 
    83   (* Let expressions *)
    84 
    85   "_bind"       :: [pttrn, 'a] => letbind           ("(2_ =/ _)" 10)
    86   ""            :: letbind => letbinds              ("_")
    87   "_binds"      :: [letbind, letbinds] => letbinds  ("_;/ _")
    88   "_Let"        :: [letbinds, 'a] => 'a             ("(let (_)/ in (_))" 10)
    89 
    90   (* Case expressions *)
    91 
    92   "@case"       :: ['a, cases_syn] => 'b            ("(case _ of/ _)" 10)
    93   "@case1"      :: ['a, 'b] => case_syn             ("(2_ =>/ _)" 10)
    94   ""            :: case_syn => cases_syn            ("_")
    95   "@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ | _")
    96 
    97 translations
    98   "x ~= y"      == "~ (x = y)"
    99   "@ x.b"       == "Eps(%x.b)"
   100   "ALL xs. P"   => "! xs. P"
   101   "EX xs. P"    => "? xs. P"
   102   "EX! xs. P"   => "?! xs. P"
   103   "_Let (_binds b bs) e"  == "_Let b (_Let bs e)"
   104   "let x = a in e"        == "Let a (%x. e)"
   105 
   106 rules
   107 
   108   eq_reflection "(x=y) ==> (x==y)"
   109 
   110   (* Basic Rules *)
   111 
   112   refl          "t = (t::'a)"
   113   subst         "[| s = t; P(s) |] ==> P(t::'a)"
   114   ext           "(!!x::'a. (f(x)::'b) = g(x)) ==> (%x.f(x)) = (%x.g(x))"
   115   selectI       "P(x::'a) ==> P(@x.P(x))"
   116 
   117   impI          "(P ==> Q) ==> P-->Q"
   118   mp            "[| P-->Q;  P |] ==> Q"
   119 
   120 defs
   121 
   122   True_def      "True      == ((%x::bool.x)=(%x.x))"
   123   All_def       "All(P)    == (P = (%x.True))"
   124   Ex_def        "Ex(P)     == P(@x.P(x))"
   125   False_def     "False     == (!P.P)"
   126   not_def       "~ P       == P-->False"
   127   and_def       "P & Q     == !R. (P-->Q-->R) --> R"
   128   or_def        "P | Q     == !R. (P-->R) --> (Q-->R) --> R"
   129   Ex1_def       "Ex1(P)    == ? x. P(x) & (! y. P(y) --> y=x)"
   130 
   131 rules
   132   (* Axioms *)
   133 
   134   iff           "(P-->Q) --> (Q-->P) --> (P=Q)"
   135   True_or_False "(P=True) | (P=False)"
   136 
   137 defs
   138   (* Misc Definitions *)
   139 
   140   Let_def       "Let s f == f(s)"
   141   Inv_def       "Inv(f::'a=>'b)  == (% y. @x. f(x)=y)"
   142   o_def         "(f::'b=>'c) o g == (%(x::'a). f(g(x)))"
   143   if_def        "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)"
   144 
   145 (* start 8bit 1 *)
   146 types
   147 ('a, 'b) ""          (infixr 5)
   148 
   149 syntax
   150   ""		:: "['a::{}, 'a] => prop"       ("(_ / _)"         [3, 2] 2)
   151   ""		:: "[prop, prop] => prop"	("(_ / _)"        [2, 1] 1)
   152   "Gbigimpl"	:: "[asms, prop] => prop"	("((3 _ ) / _)" [0, 1] 1)
   153   "Gall"	:: "('a => prop) => prop"	(binder ""                0)
   154 
   155   "Glam"         :: "[idts, 'a::logic] => 'b::logic"  ("(3_./ _)" 10)
   156   ""           :: "['a, 'a] => bool"                 (infixl 50)
   157   "Gnot"        :: "bool => bool"                     (" _" [40] 40)
   158   "GEps"        :: "[pttrn, bool] => 'a"               ("(3_./ _)" 10)
   159   "GAll"        :: "[idts, bool] => bool"             ("(3_./ _)" 10)
   160   "GEx"         :: "[idts, bool] => bool"             ("(3_./ _)" 10)
   161   "GEx1"        :: "[idts, bool] => bool"             ("(3!_./ _)" 10)
   162   ""           :: "[bool, bool] => bool"             (infixr 35)
   163   ""           :: "[bool, bool] => bool"             (infixr 30)
   164   ""          :: "[bool, bool] => bool"             (infixr 25)
   165 
   166 translations
   167 (type)  "x  y"	== (type) "x => y" 
   168 
   169 (*  "x.t"	=> "%x.t" *)
   170 
   171   "x  y"	== "x ~= y"
   172   " y"		== "~y"
   173   "x.P"	== "@x.P"
   174   "x.P"	== "! x. P"
   175   "x.P"	== "? x. P"
   176   "!x.P"	== "?! x. P"
   177   "x  y"	== "x & y"
   178   "x  y"	== "x | y"
   179   "x  y"	== "x --> y"
   180 (* end 8bit 1 *)
   181 
   182 end
   183 
   184 ML
   185 
   186 (** Choice between the HOL and Isabelle style of quantifiers **)
   187 
   188 val HOL_quantifiers = ref true;
   189 
   190 fun alt_ast_tr' (name, alt_name) =
   191   let
   192     fun ast_tr' (*name*) args =
   193       if ! HOL_quantifiers then raise Match
   194       else Syntax.mk_appl (Syntax.Constant alt_name) args;
   195   in
   196     (name, ast_tr')
   197   end;
   198 
   199 
   200 val print_ast_translation =
   201   map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];
   202 
   203 (* start 8bit 2 *)
   204 local open Ast;
   205 fun bigimpl_ast_tr (*"Gbigimpl"*) [asms, concl] =
   206       fold_ast_p "" (unfold_ast "_asms" asms, concl)
   207   | bigimpl_ast_tr (*"Gbigimpl"*) asts = raise_ast "bigimpl_ast_tr" asts;
   208 fun impl_ast_tr' (*""*) asts =
   209   (case unfold_ast_p "" (Appl (Constant "" :: asts)) of
   210     (asms as _ :: _ :: _, concl)
   211       => Appl [Constant "Gbigimpl", fold_ast "_asms" asms, concl]
   212   | _ => raise Match);
   213 
   214 in
   215 val parse_ast_translation = ("Gbigimpl", bigimpl_ast_tr)::
   216 				("Glam",    fn asts => Appl (Constant "_abs" :: asts))::
   217 				parse_ast_translation;
   218 
   219 val print_ast_translation = ("", impl_ast_tr')::
   220 				("_lambda", fn asts => Appl (Constant "Glam" :: asts)) ::	
   221 				print_ast_translation;
   222 
   223 end;
   224 
   225 local open Syntax in
   226 val thy = thy 
   227 |> add_trrules_i 
   228 [mk_appl (Constant "" ) [Variable "P", Variable "Q"] <-> 
   229  mk_appl (Constant "==") [Variable "P", Variable "Q"],
   230  mk_appl (Constant "" ) [Variable "P", Variable "Q"] <-> 
   231  mk_appl (Constant "==>") [Variable "P", Variable "Q"],
   232  (Constant "" ) <->  (Constant "!!")]
   233 end;
   234 (* end 8bit 2 *)
   235 
   236 
   237