| author | wenzelm | 
| Mon, 08 Feb 1999 17:30:22 +0100 | |
| changeset 6260 | a8010d459ef7 | 
| parent 6027 | 9dd06eeda95c | 
| child 6289 | 062aa156a300 | 
| permissions | -rw-r--r-- | 
| 923 | 1 | (* Title: HOL/HOL.thy | 
| 2 | ID: $Id$ | |
| 3 | Author: Tobias Nipkow | |
| 4 | Copyright 1993 University of Cambridge | |
| 5 | ||
| 2260 | 6 | Higher-Order Logic. | 
| 923 | 7 | *) | 
| 8 | ||
| 9 | HOL = CPure + | |
| 10 | ||
| 2260 | 11 | |
| 12 | (** Core syntax **) | |
| 13 | ||
| 3947 | 14 | global | 
| 15 | ||
| 923 | 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 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 34 |   Trueprop      :: bool => prop                     ("(_)" 5)
 | 
| 2720 | 35 |   Not           :: bool => bool                     ("~ _" [40] 40)
 | 
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 36 | True, False :: bool | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 37 |   If            :: [bool, 'a, 'a] => 'a   ("(if (_)/ then (_)/ else (_))" 10)
 | 
| 3947 | 38 | arbitrary :: 'a | 
| 923 | 39 | |
| 40 | (* Binders *) | |
| 41 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 42 |   Eps           :: ('a => bool) => 'a
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 43 |   All           :: ('a => bool) => bool             (binder "! " 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 44 |   Ex            :: ('a => bool) => bool             (binder "? " 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 45 |   Ex1           :: ('a => bool) => bool             (binder "?! " 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 46 | Let :: ['a, 'a => 'b] => 'b | 
| 923 | 47 | |
| 48 | (* Infixes *) | |
| 49 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 50 | "=" :: ['a, 'a] => bool (infixl 50) | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 51 | "&" :: [bool, bool] => bool (infixr 35) | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 52 | "|" :: [bool, bool] => bool (infixr 30) | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 53 | "-->" :: [bool, bool] => bool (infixr 25) | 
| 923 | 54 | |
| 2260 | 55 | |
| 56 | (* Overloaded Constants *) | |
| 57 | ||
| 58 | axclass | |
| 59 | plus < term | |
| 923 | 60 | |
| 2260 | 61 | axclass | 
| 62 | minus < term | |
| 63 | ||
| 64 | axclass | |
| 65 | times < term | |
| 66 | ||
| 3370 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
 paulson parents: 
3320diff
changeset | 67 | axclass | 
| 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
 paulson parents: 
3320diff
changeset | 68 | power < term | 
| 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
 paulson parents: 
3320diff
changeset | 69 | |
| 2260 | 70 | consts | 
| 3370 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
 paulson parents: 
3320diff
changeset | 71 | "+" :: ['a::plus, 'a] => 'a (infixl 65) | 
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 72 | "-" :: ['a::minus, 'a] => 'a (infixl 65) | 
| 5786 
9a2c90bdadfe
increased precedence of unary minus from 80 to 100
 paulson parents: 
5492diff
changeset | 73 |   uminus        :: ['a::minus] => 'a                ("- _" [100] 100)
 | 
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 74 | "*" :: ['a::times, 'a] => 'a (infixl 70) | 
| 3370 
5c5fdce3a4e4
Overloading of "^" requires new type class "power", with types "nat" and
 paulson parents: 
3320diff
changeset | 75 | (*See Nat.thy for "^"*) | 
| 2260 | 76 | |
| 3820 | 77 | |
| 2260 | 78 | (** Additional concrete syntax **) | 
| 79 | ||
| 4868 | 80 | nonterminals | 
| 923 | 81 | letbinds letbind | 
| 82 | case_syn cases_syn | |
| 83 | ||
| 84 | syntax | |
| 85 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 86 | "~=" :: ['a, 'a] => bool (infixl 50) | 
| 923 | 87 | |
| 2368 | 88 |   "@Eps"        :: [pttrn, bool] => 'a              ("(3@ _./ _)" [0, 10] 10)
 | 
| 1068 | 89 | |
| 923 | 90 | (* Alternative Quantifiers *) | 
| 91 | ||
| 2368 | 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)
 | |
| 923 | 95 | |
| 96 | (* Let expressions *) | |
| 97 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 98 |   "_bind"       :: [pttrn, 'a] => letbind           ("(2_ =/ _)" 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 99 |   ""            :: letbind => letbinds              ("_")
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 100 |   "_binds"      :: [letbind, letbinds] => letbinds  ("_;/ _")
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 101 |   "_Let"        :: [letbinds, 'a] => 'a             ("(let (_)/ in (_))" 10)
 | 
| 923 | 102 | |
| 103 | (* Case expressions *) | |
| 104 | ||
| 1370 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 105 |   "@case"       :: ['a, cases_syn] => 'b            ("(case _ of/ _)" 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 106 |   "@case1"      :: ['a, 'b] => case_syn             ("(2_ =>/ _)" 10)
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 107 |   ""            :: case_syn => cases_syn            ("_")
 | 
| 
7361ac9b024d
removed quotes from types in consts and syntax sections
 clasohm parents: 
1273diff
changeset | 108 |   "@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ | _")
 | 
| 923 | 109 | |
| 110 | translations | |
| 111 | "x ~= y" == "~ (x = y)" | |
| 3842 | 112 | "@ x. b" == "Eps (%x. b)" | 
| 923 | 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)" | |
| 1114 | 117 | "let x = a in e" == "Let a (%x. e)" | 
| 923 | 118 | |
| 3820 | 119 | syntax ("" output)
 | 
| 120 |   "op ="        :: ['a, 'a] => bool                 ("(_ =/ _)" [51, 51] 50)
 | |
| 121 |   "op ~="       :: ['a, 'a] => bool                 ("(_ ~=/ _)" [51, 51] 50)
 | |
| 2260 | 122 | |
| 123 | syntax (symbols) | |
| 2762 | 124 |   Not           :: bool => bool                     ("\\<not> _" [40] 40)
 | 
| 2260 | 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) | |
| 2368 | 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)
 | |
| 2552 | 134 |   "@case1"      :: ['a, 'b] => case_syn             ("(2_ \\<Rightarrow>/ _)" 10)
 | 
| 3068 
b7562e452816
deactivated new symbols (not yet printable on xterm, emacs);
 wenzelm parents: 
3066diff
changeset | 135 | (*"@case2"      :: [case_syn, cases_syn] => cases_syn   ("_/ \\<orelse> _")*)
 | 
| 2372 | 136 | |
| 3820 | 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 | ||
| 2260 | 143 | |
| 6027 
9dd06eeda95c
added new print_mode "xsymbols" for extended symbol support
 oheimb parents: 
5786diff
changeset | 144 | syntax (xsymbols) | 
| 
9dd06eeda95c
added new print_mode "xsymbols" for extended symbol support
 oheimb parents: 
5786diff
changeset | 145 | "op -->" :: [bool, bool] => bool (infixr "\\<longrightarrow>" 25) | 
| 2260 | 146 | |
| 147 | (** Rules and definitions **) | |
| 148 | ||
| 3947 | 149 | local | 
| 150 | ||
| 923 | 151 | rules | 
| 152 | ||
| 153 | eq_reflection "(x=y) ==> (x==y)" | |
| 154 | ||
| 155 | (* Basic Rules *) | |
| 156 | ||
| 157 | refl "t = (t::'a)" | |
| 158 | subst "[| s = t; P(s) |] ==> P(t::'a)" | |
| 3842 | 159 | ext "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" | 
| 160 | selectI "P (x::'a) ==> P (@x. P x)" | |
| 923 | 161 | |
| 162 | impI "(P ==> Q) ==> P-->Q" | |
| 163 | mp "[| P-->Q; P |] ==> Q" | |
| 164 | ||
| 165 | defs | |
| 166 | ||
| 3842 | 167 | True_def "True == ((%x::bool. x) = (%x. x))" | 
| 168 | All_def "All(P) == (P = (%x. True))" | |
| 169 | Ex_def "Ex(P) == P(@x. P(x))" | |
| 170 | False_def "False == (!P. P)" | |
| 923 | 171 | not_def "~ P == P-->False" | 
| 172 | and_def "P & Q == !R. (P-->Q-->R) --> R" | |
| 173 | or_def "P | Q == !R. (P-->R) --> (Q-->R) --> R" | |
| 174 | Ex1_def "Ex1(P) == ? x. P(x) & (! y. P(y) --> y=x)" | |
| 175 | ||
| 176 | rules | |
| 177 | (* Axioms *) | |
| 178 | ||
| 179 | iff "(P-->Q) --> (Q-->P) --> (P=Q)" | |
| 180 | True_or_False "(P=True) | (P=False)" | |
| 181 | ||
| 182 | defs | |
| 5069 | 183 | (*misc definitions*) | 
| 923 | 184 | Let_def "Let s f == f(s)" | 
| 973 | 185 | if_def "If P x y == @z::'a. (P=True --> z=x) & (P=False --> z=y)" | 
| 5069 | 186 | |
| 187 | (*arbitrary is completely unspecified, but is made to appear as a | |
| 188 | definition syntactically*) | |
| 4371 
8755cdbbf6b3
improved arbitrary_def: we now really don't know nothing about it!
 wenzelm parents: 
4083diff
changeset | 189 | arbitrary_def "False ==> arbitrary == (@x. False)" | 
| 923 | 190 | |
| 3320 | 191 | |
| 4868 | 192 | |
| 193 | (** initial HOL theory setup **) | |
| 194 | ||
| 195 | setup Simplifier.setup | |
| 196 | setup ClasetThyData.setup | |
| 197 | ||
| 198 | ||
| 923 | 199 | end | 
| 200 | ||
| 2260 | 201 | |
| 923 | 202 | ML | 
| 203 | ||
| 4793 | 204 | |
| 923 | 205 | (** Choice between the HOL and Isabelle style of quantifiers **) | 
| 206 | ||
| 207 | val HOL_quantifiers = ref true; | |
| 208 | ||
| 209 | fun alt_ast_tr' (name, alt_name) = | |
| 210 | let | |
| 211 | fun ast_tr' (*name*) args = | |
| 212 | if ! HOL_quantifiers then raise Match | |
| 213 | else Syntax.mk_appl (Syntax.Constant alt_name) args; | |
| 214 | in | |
| 215 | (name, ast_tr') | |
| 216 | end; | |
| 217 | ||
| 218 | ||
| 219 | val print_ast_translation = | |
| 220 |   map alt_ast_tr' [("! ", "*All"), ("? ", "*Ex"), ("?! ", "*Ex1")];
 |