author  kleing 
Wed, 14 Jan 2004 07:53:27 +0100  
changeset 14357  e49d5d5ae66a 
parent 14295  7f115e5c5de4 
child 14361  ad2f5da643b4 
permissions  rwrr 
923  1 
(* Title: HOL/HOL.thy 
2 
ID: $Id$ 

11750  3 
Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson 
12386  4 
License: GPL (GNU GENERAL PUBLIC LICENSE) 
11750  5 
*) 
923  6 

11750  7 
header {* The basis of HigherOrder Logic *} 
923  8 

7357  9 
theory HOL = CPure 
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset

10 
files ("HOL_lemmas.ML") ("cladata.ML") ("blastdata.ML") ("simpdata.ML"): 
923  11 

2260  12 

11750  13 
subsection {* Primitive logic *} 
14 

15 
subsubsection {* Core syntax *} 

2260  16 

12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

17 
classes type < logic 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

18 
defaultsort type 
3947  19 

12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

20 
global 
923  21 

7357  22 
typedecl bool 
923  23 

24 
arities 

12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

25 
bool :: type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

26 
fun :: (type, type) type 
923  27 

11750  28 
judgment 
29 
Trueprop :: "bool => prop" ("(_)" 5) 

923  30 

11750  31 
consts 
7357  32 
Not :: "bool => bool" ("~ _" [40] 40) 
33 
True :: bool 

34 
False :: bool 

35 
If :: "[bool, 'a, 'a] => 'a" ("(if (_)/ then (_)/ else (_))" 10) 

3947  36 
arbitrary :: 'a 
923  37 

11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset

38 
The :: "('a => bool) => 'a" 
7357  39 
All :: "('a => bool) => bool" (binder "ALL " 10) 
40 
Ex :: "('a => bool) => bool" (binder "EX " 10) 

41 
Ex1 :: "('a => bool) => bool" (binder "EX! " 10) 

42 
Let :: "['a, 'a => 'b] => 'b" 

923  43 

7357  44 
"=" :: "['a, 'a] => bool" (infixl 50) 
45 
& :: "[bool, bool] => bool" (infixr 35) 

46 
"" :: "[bool, bool] => bool" (infixr 30) 

47 
> :: "[bool, bool] => bool" (infixr 25) 

923  48 

10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

49 
local 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

50 

2260  51 

11750  52 
subsubsection {* Additional concrete syntax *} 
2260  53 

4868  54 
nonterminals 
923  55 
letbinds letbind 
56 
case_syn cases_syn 

57 

58 
syntax 

12650  59 
"_not_equal" :: "['a, 'a] => bool" (infixl "~=" 50) 
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset

60 
"_The" :: "[pttrn, bool] => 'a" ("(3THE _./ _)" [0, 10] 10) 
923  61 

7357  62 
"_bind" :: "[pttrn, 'a] => letbind" ("(2_ =/ _)" 10) 
63 
"" :: "letbind => letbinds" ("_") 

64 
"_binds" :: "[letbind, letbinds] => letbinds" ("_;/ _") 

65 
"_Let" :: "[letbinds, 'a] => 'a" ("(let (_)/ in (_))" 10) 

923  66 

9060
b0dd884b1848
rename @case to _case_syntax (improves on lowlevel errors);
wenzelm
parents:
8959
diff
changeset

67 
"_case_syntax":: "['a, cases_syn] => 'b" ("(case _ of/ _)" 10) 
b0dd884b1848
rename @case to _case_syntax (improves on lowlevel errors);
wenzelm
parents:
8959
diff
changeset

68 
"_case1" :: "['a, 'b] => case_syn" ("(2_ =>/ _)" 10) 
7357  69 
"" :: "case_syn => cases_syn" ("_") 
9060
b0dd884b1848
rename @case to _case_syntax (improves on lowlevel errors);
wenzelm
parents:
8959
diff
changeset

70 
"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/  _") 
923  71 

72 
translations 

7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset

73 
"x ~= y" == "~ (x = y)" 
13764  74 
"THE x. P" == "The (%x. P)" 
923  75 
"_Let (_binds b bs) e" == "_Let b (_Let bs e)" 
1114  76 
"let x = a in e" == "Let a (%x. e)" 
923  77 

13763
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

78 
print_translation {* 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

79 
(* To avoid etacontraction of body: *) 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

80 
[("The", fn [Abs abs] => 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

81 
let val (x,t) = atomic_abs_tr' abs 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

82 
in Syntax.const "_The" $ x $ t end)] 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

83 
*} 
f94b569cd610
added print translations tha avoid eta contraction for important binders.
nipkow
parents:
13723
diff
changeset

84 

12633  85 
syntax (output) 
11687  86 
"=" :: "['a, 'a] => bool" (infix 50) 
12650  87 
"_not_equal" :: "['a, 'a] => bool" (infix "~=" 50) 
2260  88 

12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset

89 
syntax (xsymbols) 
11687  90 
Not :: "bool => bool" ("\<not> _" [40] 40) 
91 
"op &" :: "[bool, bool] => bool" (infixr "\<and>" 35) 

92 
"op " :: "[bool, bool] => bool" (infixr "\<or>" 30) 

12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset

93 
"op >" :: "[bool, bool] => bool" (infixr "\<longrightarrow>" 25) 
12650  94 
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) 
11687  95 
"ALL " :: "[idts, bool] => bool" ("(3\<forall>_./ _)" [0, 10] 10) 
96 
"EX " :: "[idts, bool] => bool" ("(3\<exists>_./ _)" [0, 10] 10) 

97 
"EX! " :: "[idts, bool] => bool" ("(3\<exists>!_./ _)" [0, 10] 10) 

98 
"_case1" :: "['a, 'b] => case_syn" ("(2_ \<Rightarrow>/ _)" 10) 

9060
b0dd884b1848
rename @case to _case_syntax (improves on lowlevel errors);
wenzelm
parents:
8959
diff
changeset

99 
(*"_case2" :: "[case_syn, cases_syn] => cases_syn" ("_/ \\<orelse> _")*) 
2372  100 

12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset

101 
syntax (xsymbols output) 
12650  102 
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) 
3820  103 

6340  104 
syntax (HTML output) 
11687  105 
Not :: "bool => bool" ("\<not> _" [40] 40) 
6340  106 

7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset

107 
syntax (HOL) 
7357  108 
"ALL " :: "[idts, bool] => bool" ("(3! _./ _)" [0, 10] 10) 
109 
"EX " :: "[idts, bool] => bool" ("(3? _./ _)" [0, 10] 10) 

110 
"EX! " :: "[idts, bool] => bool" ("(3?! _./ _)" [0, 10] 10) 

7238
36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset

111 

36e58620ffc8
replaced HOL_quantifiers flag by "HOL" print mode;
wenzelm
parents:
7220
diff
changeset

112 

11750  113 
subsubsection {* Axioms and basic definitions *} 
2260  114 

7357  115 
axioms 
116 
eq_reflection: "(x=y) ==> (x==y)" 

923  117 

7357  118 
refl: "t = (t::'a)" 
119 
subst: "[ s = t; P(s) ] ==> P(t::'a)" 

6289  120 

7357  121 
ext: "(!!x::'a. (f x ::'b) = g x) ==> (%x. f x) = (%x. g x)" 
11750  122 
 {* Extensionality is built into the metalogic, and this rule expresses *} 
123 
 {* a related property. It is an etaexpanded version of the traditional *} 

124 
 {* rule, and similar to the ABS rule of HOL *} 

6289  125 

11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset

126 
the_eq_trivial: "(THE x. x = a) = (a::'a)" 
923  127 

7357  128 
impI: "(P ==> Q) ==> P>Q" 
129 
mp: "[ P>Q; P ] ==> Q" 

923  130 

131 
defs 

7357  132 
True_def: "True == ((%x::bool. x) = (%x. x))" 
133 
All_def: "All(P) == (P = (%x. True))" 

11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset

134 
Ex_def: "Ex(P) == !Q. (!x. P x > Q) > Q" 
7357  135 
False_def: "False == (!P. P)" 
136 
not_def: "~ P == P>False" 

137 
and_def: "P & Q == !R. (P>Q>R) > R" 

138 
or_def: "P  Q == !R. (P>R) > (Q>R) > R" 

139 
Ex1_def: "Ex1(P) == ? x. P(x) & (! y. P(y) > y=x)" 

923  140 

7357  141 
axioms 
142 
iff: "(P>Q) > (Q>P) > (P=Q)" 

143 
True_or_False: "(P=True)  (P=False)" 

923  144 

145 
defs 

7357  146 
Let_def: "Let s f == f(s)" 
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
11438
diff
changeset

147 
if_def: "If P x y == THE z::'a. (P=True > z=x) & (P=False > z=y)" 
5069  148 

14223
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset

149 
finalconsts 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset

150 
"op =" 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset

151 
"op >" 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset

152 
The 
0ee05eef881b
Added support for making constants final, that is, ensuring that no
skalberg
parents:
14208
diff
changeset

153 
arbitrary 
3320  154 

11750  155 
subsubsection {* Generic algebraic operations *} 
4868  156 

12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

157 
axclass zero < type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

158 
axclass one < type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

159 
axclass plus < type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

160 
axclass minus < type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

161 
axclass times < type 
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

162 
axclass inverse < type 
11750  163 

164 
global 

165 

166 
consts 

167 
"0" :: "'a::zero" ("0") 

168 
"1" :: "'a::one" ("1") 

169 
"+" :: "['a::plus, 'a] => 'a" (infixl 65) 

170 
 :: "['a::minus, 'a] => 'a" (infixl 65) 

171 
uminus :: "['a::minus] => 'a" (" _" [81] 80) 

172 
* :: "['a::times, 'a] => 'a" (infixl 70) 

173 

13456
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset

174 
syntax 
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset

175 
"_index1" :: index ("\<^sub>1") 
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset

176 
translations 
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset

177 
(index) "\<^sub>1" == "_index 1" 
42601eb7553f
special syntax for index "1" (plain numeral hidden by "1" symbol in HOL);
wenzelm
parents:
13438
diff
changeset

178 

11750  179 
local 
180 

181 
typed_print_translation {* 

182 
let 

183 
fun tr' c = (c, fn show_sorts => fn T => fn ts => 

184 
if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match 

185 
else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T); 

186 
in [tr' "0", tr' "1"] end; 

187 
*}  {* show types that are presumably too general *} 

188 

189 

190 
consts 

191 
abs :: "'a::minus => 'a" 

192 
inverse :: "'a::inverse => 'a" 

193 
divide :: "['a::inverse, 'a] => 'a" (infixl "'/" 70) 

194 

195 
syntax (xsymbols) 

196 
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") 

197 
syntax (HTML output) 

198 
abs :: "'a::minus => 'a" ("\<bar>_\<bar>") 

199 

200 
axclass plus_ac0 < plus, zero 

201 
commute: "x + y = y + x" 

202 
assoc: "(x + y) + z = x + (y + z)" 

203 
zero: "0 + x = x" 

204 

205 

206 
subsection {* Theory and package setup *} 

207 

208 
subsubsection {* Basic lemmas *} 

4868  209 

9736  210 
use "HOL_lemmas.ML" 
11687  211 
theorems case_split = case_split_thm [case_names True False] 
9869  212 

12386  213 

214 
subsubsection {* Intuitionistic Reasoning *} 

215 

216 
lemma impE': 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

217 
assumes 1: "P > Q" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

218 
and 2: "Q ==> R" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

219 
and 3: "P > Q ==> P" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

220 
shows R 
12386  221 
proof  
222 
from 3 and 1 have P . 

223 
with 1 have Q by (rule impE) 

224 
with 2 show R . 

225 
qed 

226 

227 
lemma allE': 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

228 
assumes 1: "ALL x. P x" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

229 
and 2: "P x ==> ALL x. P x ==> Q" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

230 
shows Q 
12386  231 
proof  
232 
from 1 have "P x" by (rule spec) 

233 
from this and 1 show Q by (rule 2) 

234 
qed 

235 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

236 
lemma notE': 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

237 
assumes 1: "~ P" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

238 
and 2: "~ P ==> P" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

239 
shows R 
12386  240 
proof  
241 
from 2 and 1 have P . 

242 
with 1 show R by (rule notE) 

243 
qed 

244 

245 
lemmas [CPure.elim!] = disjE iffE FalseE conjE exE 

246 
and [CPure.intro!] = iffI conjI impI TrueI notI allI refl 

247 
and [CPure.elim 2] = allE notE' impE' 

248 
and [CPure.intro] = exI disjI2 disjI1 

249 

250 
lemmas [trans] = trans 

251 
and [sym] = sym not_sym 

252 
and [CPure.elim?] = iffD1 iffD2 impE 

11750  253 

11438
3d9222b80989
declare trans [trans] (*overridden in theory Calculation*);
wenzelm
parents:
11432
diff
changeset

254 

11750  255 
subsubsection {* Atomizing metalevel connectives *} 
256 

257 
lemma atomize_all [atomize]: "(!!x. P x) == Trueprop (ALL x. P x)" 

12003  258 
proof 
9488  259 
assume "!!x. P x" 
10383  260 
show "ALL x. P x" by (rule allI) 
9488  261 
next 
262 
assume "ALL x. P x" 

10383  263 
thus "!!x. P x" by (rule allE) 
9488  264 
qed 
265 

11750  266 
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A > B)" 
12003  267 
proof 
9488  268 
assume r: "A ==> B" 
10383  269 
show "A > B" by (rule impI) (rule r) 
9488  270 
next 
271 
assume "A > B" and A 

10383  272 
thus B by (rule mp) 
9488  273 
qed 
274 

11750  275 
lemma atomize_eq [atomize]: "(x == y) == Trueprop (x = y)" 
12003  276 
proof 
10432
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

277 
assume "x == y" 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

278 
show "x = y" by (unfold prems) (rule refl) 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

279 
next 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

280 
assume "x = y" 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

281 
thus "x == y" by (rule eq_reflection) 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

282 
qed 
3dfbc913d184
added axclass inverse and consts inverse, divide (infix "/");
wenzelm
parents:
10383
diff
changeset

283 

12023  284 
lemma atomize_conj [atomize]: 
285 
"(!!C. (A ==> B ==> PROP C) ==> PROP C) == Trueprop (A & B)" 

12003  286 
proof 
11953  287 
assume "!!C. (A ==> B ==> PROP C) ==> PROP C" 
288 
show "A & B" by (rule conjI) 

289 
next 

290 
fix C 

291 
assume "A & B" 

292 
assume "A ==> B ==> PROP C" 

293 
thus "PROP C" 

294 
proof this 

295 
show A by (rule conjunct1) 

296 
show B by (rule conjunct2) 

297 
qed 

298 
qed 

299 

12386  300 
lemmas [symmetric, rulify] = atomize_all atomize_imp 
301 

11750  302 

303 
subsubsection {* Classical Reasoner setup *} 

9529  304 

10383  305 
use "cladata.ML" 
306 
setup hypsubst_setup 

11977  307 

12386  308 
ML_setup {* 
309 
Context.>> (ContextRules.addSWrapper (fn tac => hyp_subst_tac' ORELSE' tac)); 

310 
*} 

11977  311 

10383  312 
setup Classical.setup 
313 
setup clasetup 

314 

12386  315 
lemmas [intro?] = ext 
316 
and [elim?] = ex1_implies_ex 

11977  317 

9869  318 
use "blastdata.ML" 
319 
setup Blast.setup 

4868  320 

11750  321 

322 
subsubsection {* Simplifier setup *} 

323 

12281  324 
lemma meta_eq_to_obj_eq: "x == y ==> x = y" 
325 
proof  

326 
assume r: "x == y" 

327 
show "x = y" by (unfold r) (rule refl) 

328 
qed 

329 

330 
lemma eta_contract_eq: "(%s. f s) = f" .. 

331 

332 
lemma simp_thms: 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

333 
shows not_not: "(~ ~ P) = P" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

334 
and 
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

335 
"(P ~= Q) = (P = (~Q))" 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

336 
"(P  ~P) = True" "(~P  P) = True" 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

337 
"((~P) = (~Q)) = (P=Q)" 
12281  338 
"(x = x) = True" 
339 
"(~True) = False" "(~False) = True" 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

340 
"(~P) ~= P" "P ~= (~P)" 
12281  341 
"(True=P) = P" "(P=True) = P" "(False=P) = (~P)" "(P=False) = (~P)" 
342 
"(True > P) = P" "(False > P) = True" 

343 
"(P > True) = True" "(P > P) = True" 

344 
"(P > False) = (~P)" "(P > ~P) = (~P)" 

345 
"(P & True) = P" "(True & P) = P" 

346 
"(P & False) = False" "(False & P) = False" 

347 
"(P & P) = P" "(P & (P & Q)) = (P & Q)" 

348 
"(P & ~P) = False" "(~P & P) = False" 

349 
"(P  True) = True" "(True  P) = True" 

350 
"(P  False) = P" "(False  P) = P" 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

351 
"(P  P) = P" "(P  (P  Q)) = (P  Q)" and 
12281  352 
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x" 
353 
 {* needed for the onepointrule quantifier simplification procs *} 

354 
 {* essential for termination!! *} and 

355 
"!!P. (EX x. x=t & P(x)) = P(t)" 

356 
"!!P. (EX x. t=x & P(x)) = P(t)" 

357 
"!!P. (ALL x. x=t > P(x)) = P(t)" 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

358 
"!!P. (ALL x. t=x > P(x)) = P(t)" 
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

359 
by (blast, blast, blast, blast, blast, rules+) 
13421  360 

12281  361 
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P > Q) = (P' > Q'))" 
12354  362 
by rules 
12281  363 

364 
lemma ex_simps: 

365 
"!!P Q. (EX x. P x & Q) = ((EX x. P x) & Q)" 

366 
"!!P Q. (EX x. P & Q x) = (P & (EX x. Q x))" 

367 
"!!P Q. (EX x. P x  Q) = ((EX x. P x)  Q)" 

368 
"!!P Q. (EX x. P  Q x) = (P  (EX x. Q x))" 

369 
"!!P Q. (EX x. P x > Q) = ((ALL x. P x) > Q)" 

370 
"!!P Q. (EX x. P > Q x) = (P > (EX x. Q x))" 

371 
 {* Miniscoping: pushing in existential quantifiers. *} 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

372 
by (rules  blast)+ 
12281  373 

374 
lemma all_simps: 

375 
"!!P Q. (ALL x. P x & Q) = ((ALL x. P x) & Q)" 

376 
"!!P Q. (ALL x. P & Q x) = (P & (ALL x. Q x))" 

377 
"!!P Q. (ALL x. P x  Q) = ((ALL x. P x)  Q)" 

378 
"!!P Q. (ALL x. P  Q x) = (P  (ALL x. Q x))" 

379 
"!!P Q. (ALL x. P x > Q) = ((EX x. P x) > Q)" 

380 
"!!P Q. (ALL x. P > Q x) = (P > (ALL x. Q x))" 

381 
 {* Miniscoping: pushing in universal quantifiers. *} 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

382 
by (rules  blast)+ 
12281  383 

14201  384 
lemma disj_absorb: "(A  A) = A" 
385 
by blast 

386 

387 
lemma disj_left_absorb: "(A  (A  B)) = (A  B)" 

388 
by blast 

389 

390 
lemma conj_absorb: "(A & A) = A" 

391 
by blast 

392 

393 
lemma conj_left_absorb: "(A & (A & B)) = (A & B)" 

394 
by blast 

395 

12281  396 
lemma eq_ac: 
12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

397 
shows eq_commute: "(a=b) = (b=a)" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

398 
and eq_left_commute: "(P=(Q=R)) = (Q=(P=R))" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

399 
and eq_assoc: "((P=Q)=R) = (P=(Q=R))" by (rules, blast+) 
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

400 
lemma neq_commute: "(a~=b) = (b~=a)" by rules 
12281  401 

402 
lemma conj_comms: 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

403 
shows conj_commute: "(P&Q) = (Q&P)" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

404 
and conj_left_commute: "(P&(Q&R)) = (Q&(P&R))" by rules+ 
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

405 
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules 
12281  406 

407 
lemma disj_comms: 

12937
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

408 
shows disj_commute: "(PQ) = (QP)" 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
wenzelm
parents:
12892
diff
changeset

409 
and disj_left_commute: "(P(QR)) = (Q(PR))" by rules+ 
12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

410 
lemma disj_assoc: "((PQ)R) = (P(QR))" by rules 
12281  411 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

412 
lemma conj_disj_distribL: "(P&(QR)) = (P&Q  P&R)" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

413 
lemma conj_disj_distribR: "((PQ)&R) = (P&R  Q&R)" by rules 
12281  414 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

415 
lemma disj_conj_distribL: "(P(Q&R)) = ((PQ) & (PR))" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

416 
lemma disj_conj_distribR: "((P&Q)R) = ((PR) & (QR))" by rules 
12281  417 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

418 
lemma imp_conjR: "(P > (Q&R)) = ((P>Q) & (P>R))" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

419 
lemma imp_conjL: "((P&Q) >R) = (P > (Q > R))" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

420 
lemma imp_disjL: "((PQ) > R) = ((P>R)&(Q>R))" by rules 
12281  421 

422 
text {* These two are specialized, but @{text imp_disj_not1} is useful in @{text "Auth/Yahalom"}. *} 

423 
lemma imp_disj_not1: "(P > Q  R) = (~Q > P > R)" by blast 

424 
lemma imp_disj_not2: "(P > Q  R) = (~R > P > Q)" by blast 

425 

426 
lemma imp_disj1: "((P>Q)R) = (P> QR)" by blast 

427 
lemma imp_disj2: "(Q(P>R)) = (P> QR)" by blast 

428 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

429 
lemma de_Morgan_disj: "(~(P  Q)) = (~P & ~Q)" by rules 
12281  430 
lemma de_Morgan_conj: "(~(P & Q)) = (~P  ~Q)" by blast 
431 
lemma not_imp: "(~(P > Q)) = (P & ~Q)" by blast 

432 
lemma not_iff: "(P~=Q) = (P = (~Q))" by blast 

433 
lemma disj_not1: "(~P  Q) = (P > Q)" by blast 

434 
lemma disj_not2: "(P  ~Q) = (Q > P)"  {* changes orientation :( *} 

435 
by blast 

436 
lemma imp_conv_disj: "(P > Q) = ((~P)  Q)" by blast 

437 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

438 
lemma iff_conv_conj_imp: "(P = Q) = ((P > Q) & (Q > P))" by rules 
12281  439 

440 

441 
lemma cases_simp: "((P > Q) & (~P > Q)) = Q" 

442 
 {* Avoids duplication of subgoals after @{text split_if}, when the true and false *} 

443 
 {* cases boil down to the same thing. *} 

444 
by blast 

445 

446 
lemma not_all: "(~ (! x. P(x))) = (? x.~P(x))" by blast 

447 
lemma imp_all: "((! x. P x) > Q) = (? x. P x > Q)" by blast 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

448 
lemma not_ex: "(~ (? x. P(x))) = (! x.~P(x))" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

449 
lemma imp_ex: "((? x. P x) > Q) = (! x. P x > Q)" by rules 
12281  450 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

451 
lemma ex_disj_distrib: "(? x. P(x)  Q(x)) = ((? x. P(x))  (? x. Q(x)))" by rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

452 
lemma all_conj_distrib: "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))" by rules 
12281  453 

454 
text {* 

455 
\medskip The @{text "&"} congruence rule: not included by default! 

456 
May slow rewrite proofs down by as much as 50\% *} 

457 

458 
lemma conj_cong: 

459 
"(P = P') ==> (P' ==> (Q = Q')) ==> ((P & Q) = (P' & Q'))" 

12354  460 
by rules 
12281  461 

462 
lemma rev_conj_cong: 

463 
"(Q = Q') ==> (Q' ==> (P = P')) ==> ((P & Q) = (P' & Q'))" 

12354  464 
by rules 
12281  465 

466 
text {* The @{text ""} congruence rule: not included by default! *} 

467 

468 
lemma disj_cong: 

469 
"(P = P') ==> (~P' ==> (Q = Q')) ==> ((P  Q) = (P'  Q'))" 

470 
by blast 

471 

472 
lemma eq_sym_conv: "(x = y) = (y = x)" 

12354  473 
by rules 
12281  474 

475 

476 
text {* \medskip ifthenelse rules *} 

477 

478 
lemma if_True: "(if True then x else y) = x" 

479 
by (unfold if_def) blast 

480 

481 
lemma if_False: "(if False then x else y) = y" 

482 
by (unfold if_def) blast 

483 

484 
lemma if_P: "P ==> (if P then x else y) = x" 

485 
by (unfold if_def) blast 

486 

487 
lemma if_not_P: "~P ==> (if P then x else y) = y" 

488 
by (unfold if_def) blast 

489 

490 
lemma split_if: "P (if Q then x else y) = ((Q > P(x)) & (~Q > P(y)))" 

491 
apply (rule case_split [of Q]) 

492 
apply (subst if_P) 

14208  493 
prefer 3 apply (subst if_not_P, blast+) 
12281  494 
done 
495 

496 
lemma split_if_asm: "P (if Q then x else y) = (~((Q & ~P x)  (~Q & ~P y)))" 

14208  497 
by (subst split_if, blast) 
12281  498 

499 
lemmas if_splits = split_if split_if_asm 

500 

501 
lemma if_def2: "(if Q then x else y) = ((Q > x) & (~ Q > y))" 

502 
by (rule split_if) 

503 

504 
lemma if_cancel: "(if c then x else x) = x" 

14208  505 
by (subst split_if, blast) 
12281  506 

507 
lemma if_eq_cancel: "(if x = y then y else x) = x" 

14208  508 
by (subst split_if, blast) 
12281  509 

510 
lemma if_bool_eq_conj: "(if P then Q else R) = ((P>Q) & (~P>R))" 

511 
 {* This form is useful for expanding @{text if}s on the RIGHT of the @{text "==>"} symbol. *} 

512 
by (rule split_if) 

513 

514 
lemma if_bool_eq_disj: "(if P then Q else R) = ((P&Q)  (~P&R))" 

515 
 {* And this form is useful for expanding @{text if}s on the LEFT. *} 

14208  516 
apply (subst split_if, blast) 
12281  517 
done 
518 

12436
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

519 
lemma Eq_TrueI: "P ==> P == True" by (unfold atomize_eq) rules 
a2df07fefed7
Replaced several occurrences of "blast" by "rules".
berghofe
parents:
12386
diff
changeset

520 
lemma Eq_FalseI: "~P ==> P == False" by (unfold atomize_eq) rules 
12281  521 

14201  522 
subsubsection {* Actual Installation of the Simplifier *} 
523 

9869  524 
use "simpdata.ML" 
525 
setup Simplifier.setup 

526 
setup "Simplifier.method_setup Splitter.split_modifiers" setup simpsetup 

527 
setup Splitter.setup setup Clasimp.setup 

528 

14201  529 
declare disj_absorb [simp] conj_absorb [simp] 
530 

13723  531 
lemma ex1_eq[iff]: "EX! x. x = t" "EX! x. t = x" 
532 
by blast+ 

533 

13638  534 
theorem choice_eq: "(ALL x. EX! y. P x y) = (EX! f. ALL x. P x (f x))" 
535 
apply (rule iffI) 

536 
apply (rule_tac a = "%x. THE y. P x y" in ex1I) 

537 
apply (fast dest!: theI') 

538 
apply (fast intro: ext the1_equality [symmetric]) 

539 
apply (erule ex1E) 

540 
apply (rule allI) 

541 
apply (rule ex1I) 

542 
apply (erule spec) 

543 
apply (erule_tac x = "%z. if z = x then y else f z" in allE) 

544 
apply (erule impE) 

545 
apply (rule allI) 

546 
apply (rule_tac P = "xa = x" in case_split_thm) 

14208  547 
apply (drule_tac [3] x = x in fun_cong, simp_all) 
13638  548 
done 
549 

13438
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

550 
text{*Needs only HOLlemmas:*} 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

551 
lemma mk_left_commute: 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

552 
assumes a: "\<And>x y z. f (f x y) z = f x (f y z)" and 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

553 
c: "\<And>x y. f x y = f y x" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

554 
shows "f x (f y z) = f y (f x z)" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

555 
by(rule trans[OF trans[OF c a] arg_cong[OF c, of "f y"]]) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

556 

11750  557 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

558 
subsubsection {* Generic cases and induction *} 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

559 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

560 
constdefs 
11989  561 
induct_forall :: "('a => bool) => bool" 
562 
"induct_forall P == \<forall>x. P x" 

563 
induct_implies :: "bool => bool => bool" 

564 
"induct_implies A B == A > B" 

565 
induct_equal :: "'a => 'a => bool" 

566 
"induct_equal x y == x = y" 

567 
induct_conj :: "bool => bool => bool" 

568 
"induct_conj A B == A & B" 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

569 

11989  570 
lemma induct_forall_eq: "(!!x. P x) == Trueprop (induct_forall (\<lambda>x. P x))" 
571 
by (simp only: atomize_all induct_forall_def) 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

572 

11989  573 
lemma induct_implies_eq: "(A ==> B) == Trueprop (induct_implies A B)" 
574 
by (simp only: atomize_imp induct_implies_def) 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

575 

11989  576 
lemma induct_equal_eq: "(x == y) == Trueprop (induct_equal x y)" 
577 
by (simp only: atomize_eq induct_equal_def) 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

578 

11989  579 
lemma induct_forall_conj: "induct_forall (\<lambda>x. induct_conj (A x) (B x)) = 
580 
induct_conj (induct_forall A) (induct_forall B)" 

12354  581 
by (unfold induct_forall_def induct_conj_def) rules 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

582 

11989  583 
lemma induct_implies_conj: "induct_implies C (induct_conj A B) = 
584 
induct_conj (induct_implies C A) (induct_implies C B)" 

12354  585 
by (unfold induct_implies_def induct_conj_def) rules 
11989  586 

13598
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

587 
lemma induct_conj_curry: "(induct_conj A B ==> PROP C) == (A ==> B ==> PROP C)" 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

588 
proof 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

589 
assume r: "induct_conj A B ==> PROP C" and A B 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

590 
show "PROP C" by (rule r) (simp! add: induct_conj_def) 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

591 
next 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

592 
assume r: "A ==> B ==> PROP C" and "induct_conj A B" 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

593 
show "PROP C" by (rule r) (simp! add: induct_conj_def)+ 
8bc77b17f59f
Fixed problem with induct_conj_curry: variable C should have type prop.
berghofe
parents:
13596
diff
changeset

594 
qed 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

595 

11989  596 
lemma induct_impliesI: "(A ==> B) ==> induct_implies A B" 
597 
by (simp add: induct_implies_def) 

11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

598 

12161  599 
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq 
600 
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq 

601 
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def 

11989  602 
lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

603 

11989  604 
hide const induct_forall induct_implies induct_equal induct_conj 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

605 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

606 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

607 
text {* Method setup. *} 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

608 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

609 
ML {* 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

610 
structure InductMethod = InductMethodFun 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

611 
(struct 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

612 
val dest_concls = HOLogic.dest_concls; 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

613 
val cases_default = thm "case_split"; 
11989  614 
val local_impI = thm "induct_impliesI"; 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

615 
val conjI = thm "conjI"; 
11989  616 
val atomize = thms "induct_atomize"; 
617 
val rulify1 = thms "induct_rulify1"; 

618 
val rulify2 = thms "induct_rulify2"; 

12240  619 
val localize = [Thm.symmetric (thm "induct_implies_def")]; 
11824
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

620 
end); 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

621 
*} 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

622 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

623 
setup InductMethod.setup 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

624 

f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

625 

11750  626 
subsection {* Order signatures and orders *} 
627 

628 
axclass 

12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
12281
diff
changeset

629 
ord < type 
11750  630 

631 
syntax 

632 
"op <" :: "['a::ord, 'a] => bool" ("op <") 

633 
"op <=" :: "['a::ord, 'a] => bool" ("op <=") 

634 

635 
global 

636 

637 
consts 

638 
"op <" :: "['a::ord, 'a] => bool" ("(_/ < _)" [50, 51] 50) 

639 
"op <=" :: "['a::ord, 'a] => bool" ("(_/ <= _)" [50, 51] 50) 

640 

641 
local 

642 

12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset

643 
syntax (xsymbols) 
11750  644 
"op <=" :: "['a::ord, 'a] => bool" ("op \<le>") 
645 
"op <=" :: "['a::ord, 'a] => bool" ("(_/ \<le> _)" [50, 51] 50) 

646 

647 

14295  648 
lemma Not_eq_iff: "((~P) = (~Q)) = (P = Q)" 
649 
by blast 

650 

11750  651 
subsubsection {* Monotonicity *} 
652 

13412  653 
locale mono = 
654 
fixes f 

655 
assumes mono: "A <= B ==> f A <= f B" 

11750  656 

13421  657 
lemmas monoI [intro?] = mono.intro 
13412  658 
and monoD [dest?] = mono.mono 
11750  659 

660 
constdefs 

661 
min :: "['a::ord, 'a] => 'a" 

662 
"min a b == (if a <= b then a else b)" 

663 
max :: "['a::ord, 'a] => 'a" 

664 
"max a b == (if a <= b then b else a)" 

665 

666 
lemma min_leastL: "(!!x. least <= x) ==> min least x = least" 

667 
by (simp add: min_def) 

668 

669 
lemma min_of_mono: 

670 
"ALL x y. (f x <= f y) = (x <= y) ==> min (f m) (f n) = f (min m n)" 

671 
by (simp add: min_def) 

672 

673 
lemma max_leastL: "(!!x. least <= x) ==> max least x = x" 

674 
by (simp add: max_def) 

675 

676 
lemma max_of_mono: 

677 
"ALL x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)" 

678 
by (simp add: max_def) 

679 

680 

681 
subsubsection "Orders" 

682 

683 
axclass order < ord 

684 
order_refl [iff]: "x <= x" 

685 
order_trans: "x <= y ==> y <= z ==> x <= z" 

686 
order_antisym: "x <= y ==> y <= x ==> x = y" 

687 
order_less_le: "(x < y) = (x <= y & x ~= y)" 

688 

689 

690 
text {* Reflexivity. *} 

691 

692 
lemma order_eq_refl: "!!x::'a::order. x = y ==> x <= y" 

693 
 {* This form is useful with the classical reasoner. *} 

694 
apply (erule ssubst) 

695 
apply (rule order_refl) 

696 
done 

697 

13553  698 
lemma order_less_irrefl [iff]: "~ x < (x::'a::order)" 
11750  699 
by (simp add: order_less_le) 
700 

701 
lemma order_le_less: "((x::'a::order) <= y) = (x < y  x = y)" 

702 
 {* NOT suitable for iff, since it can cause PROOF FAILED. *} 

14208  703 
apply (simp add: order_less_le, blast) 
11750  704 
done 
705 

706 
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard] 

707 

708 
lemma order_less_imp_le: "!!x::'a::order. x < y ==> x <= y" 

709 
by (simp add: order_less_le) 

710 

711 

712 
text {* Asymmetry. *} 

713 

714 
lemma order_less_not_sym: "(x::'a::order) < y ==> ~ (y < x)" 

715 
by (simp add: order_less_le order_antisym) 

716 

717 
lemma order_less_asym: "x < (y::'a::order) ==> (~P ==> y < x) ==> P" 

718 
apply (drule order_less_not_sym) 

14208  719 
apply (erule contrapos_np, simp) 
11750  720 
done 
721 

14295  722 
lemma order_eq_iff: "!!x::'a::order. (x = y) = (x \<le> y & y \<le> x)" 
723 
by (blast intro: order_antisym) 

724 

11750  725 

726 
text {* Transitivity. *} 

727 

728 
lemma order_less_trans: "!!x::'a::order. [ x < y; y < z ] ==> x < z" 

729 
apply (simp add: order_less_le) 

730 
apply (blast intro: order_trans order_antisym) 

731 
done 

732 

733 
lemma order_le_less_trans: "!!x::'a::order. [ x <= y; y < z ] ==> x < z" 

734 
apply (simp add: order_less_le) 

735 
apply (blast intro: order_trans order_antisym) 

736 
done 

737 

738 
lemma order_less_le_trans: "!!x::'a::order. [ x < y; y <= z ] ==> x < z" 

739 
apply (simp add: order_less_le) 

740 
apply (blast intro: order_trans order_antisym) 

741 
done 

742 

743 

744 
text {* Useful for simplification, but too risky to include by default. *} 

745 

746 
lemma order_less_imp_not_less: "(x::'a::order) < y ==> (~ y < x) = True" 

747 
by (blast elim: order_less_asym) 

748 

749 
lemma order_less_imp_triv: "(x::'a::order) < y ==> (y < x > P) = True" 

750 
by (blast elim: order_less_asym) 

751 

752 
lemma order_less_imp_not_eq: "(x::'a::order) < y ==> (x = y) = False" 

753 
by auto 

754 

755 
lemma order_less_imp_not_eq2: "(x::'a::order) < y ==> (y = x) = False" 

756 
by auto 

757 

758 

759 
text {* Other operators. *} 

760 

761 
lemma min_leastR: "(!!x::'a::order. least <= x) ==> min x least = least" 

762 
apply (simp add: min_def) 

763 
apply (blast intro: order_antisym) 

764 
done 

765 

766 
lemma max_leastR: "(!!x::'a::order. least <= x) ==> max x least = x" 

767 
apply (simp add: max_def) 

768 
apply (blast intro: order_antisym) 

769 
done 

770 

771 

772 
subsubsection {* Least value operator *} 

773 

774 
constdefs 

775 
Least :: "('a::ord => bool) => 'a" (binder "LEAST " 10) 

776 
"Least P == THE x. P x & (ALL y. P y > x <= y)" 

777 
 {* We can no longer use LeastM because the latter requires HilbertAC. *} 

778 

779 
lemma LeastI2: 

780 
"[ P (x::'a::order); 

781 
!!y. P y ==> x <= y; 

782 
!!x. [ P x; ALL y. P y > x \<le> y ] ==> Q x ] 

12281  783 
==> Q (Least P)" 
11750  784 
apply (unfold Least_def) 
785 
apply (rule theI2) 

786 
apply (blast intro: order_antisym)+ 

787 
done 

788 

789 
lemma Least_equality: 

12281  790 
"[ P (k::'a::order); !!x. P x ==> k <= x ] ==> (LEAST x. P x) = k" 
11750  791 
apply (simp add: Least_def) 
792 
apply (rule the_equality) 

793 
apply (auto intro!: order_antisym) 

794 
done 

795 

796 

797 
subsubsection "Linear / total orders" 

798 

799 
axclass linorder < order 

800 
linorder_linear: "x <= y  y <= x" 

801 

802 
lemma linorder_less_linear: "!!x::'a::linorder. x<y  x=y  y<x" 

803 
apply (simp add: order_less_le) 

14208  804 
apply (insert linorder_linear, blast) 
11750  805 
done 
806 

807 
lemma linorder_cases [case_names less equal greater]: 

808 
"((x::'a::linorder) < y ==> P) ==> (x = y ==> P) ==> (y < x ==> P) ==> P" 

14208  809 
apply (insert linorder_less_linear, blast) 
11750  810 
done 
811 

812 
lemma linorder_not_less: "!!x::'a::linorder. (~ x < y) = (y <= x)" 

813 
apply (simp add: order_less_le) 

814 
apply (insert linorder_linear) 

815 
apply (blast intro: order_antisym) 

816 
done 

817 

818 
lemma linorder_not_le: "!!x::'a::linorder. (~ x <= y) = (y < x)" 

819 
apply (simp add: order_less_le) 

820 
apply (insert linorder_linear) 

821 
apply (blast intro: order_antisym) 

822 
done 

823 

824 
lemma linorder_neq_iff: "!!x::'a::linorder. (x ~= y) = (x<y  y<x)" 

14208  825 
by (cut_tac x = x and y = y in linorder_less_linear, auto) 
11750  826 

827 
lemma linorder_neqE: "x ~= (y::'a::linorder) ==> (x < y ==> R) ==> (y < x ==> R) ==> R" 

14208  828 
by (simp add: linorder_neq_iff, blast) 
11750  829 

830 

831 
subsubsection "Min and max on (linear) orders" 

832 

833 
lemma min_same [simp]: "min (x::'a::order) x = x" 

834 
by (simp add: min_def) 

835 

836 
lemma max_same [simp]: "max (x::'a::order) x = x" 

837 
by (simp add: max_def) 

838 

839 
lemma le_max_iff_disj: "!!z::'a::linorder. (z <= max x y) = (z <= x  z <= y)" 

840 
apply (simp add: max_def) 

841 
apply (insert linorder_linear) 

842 
apply (blast intro: order_trans) 

843 
done 

844 

845 
lemma le_maxI1: "(x::'a::linorder) <= max x y" 

846 
by (simp add: le_max_iff_disj) 

847 

848 
lemma le_maxI2: "(y::'a::linorder) <= max x y" 

849 
 {* CANNOT use with @{text "[intro!]"} because blast will give PROOF FAILED. *} 

850 
by (simp add: le_max_iff_disj) 

851 

852 
lemma less_max_iff_disj: "!!z::'a::linorder. (z < max x y) = (z < x  z < y)" 

853 
apply (simp add: max_def order_le_less) 

854 
apply (insert linorder_less_linear) 

855 
apply (blast intro: order_less_trans) 

856 
done 

857 

858 
lemma max_le_iff_conj [simp]: 

859 
"!!z::'a::linorder. (max x y <= z) = (x <= z & y <= z)" 

860 
apply (simp add: max_def) 

861 
apply (insert linorder_linear) 

862 
apply (blast intro: order_trans) 

863 
done 

864 

865 
lemma max_less_iff_conj [simp]: 

866 
"!!z::'a::linorder. (max x y < z) = (x < z & y < z)" 

867 
apply (simp add: order_le_less max_def) 

868 
apply (insert linorder_less_linear) 

869 
apply (blast intro: order_less_trans) 

870 
done 

871 

872 
lemma le_min_iff_conj [simp]: 

873 
"!!z::'a::linorder. (z <= min x y) = (z <= x & z <= y)" 

12892  874 
 {* @{text "[iff]"} screws up a @{text blast} in MiniML *} 
11750  875 
apply (simp add: min_def) 
876 
apply (insert linorder_linear) 

877 
apply (blast intro: order_trans) 

878 
done 

879 

880 
lemma min_less_iff_conj [simp]: 

881 
"!!z::'a::linorder. (z < min x y) = (z < x & z < y)" 

882 
apply (simp add: order_le_less min_def) 

883 
apply (insert linorder_less_linear) 

884 
apply (blast intro: order_less_trans) 

885 
done 

886 

887 
lemma min_le_iff_disj: "!!z::'a::linorder. (min x y <= z) = (x <= z  y <= z)" 

888 
apply (simp add: min_def) 

889 
apply (insert linorder_linear) 

890 
apply (blast intro: order_trans) 

891 
done 

892 

893 
lemma min_less_iff_disj: "!!z::'a::linorder. (min x y < z) = (x < z  y < z)" 

894 
apply (simp add: min_def order_le_less) 

895 
apply (insert linorder_less_linear) 

896 
apply (blast intro: order_less_trans) 

897 
done 

898 

13438
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

899 
lemma max_assoc: "!!x::'a::linorder. max (max x y) z = max x (max y z)" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

900 
apply(simp add:max_def) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

901 
apply(rule conjI) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

902 
apply(blast intro:order_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

903 
apply(simp add:linorder_not_le) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

904 
apply(blast dest: order_less_trans order_le_less_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

905 
done 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

906 

527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

907 
lemma max_commute: "!!x::'a::linorder. max x y = max y x" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

908 
apply(simp add:max_def) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

909 
apply(rule conjI) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

910 
apply(blast intro:order_antisym) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

911 
apply(simp add:linorder_not_le) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

912 
apply(blast dest: order_less_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

913 
done 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

914 

527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

915 
lemmas max_ac = max_assoc max_commute 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

916 
mk_left_commute[of max,OF max_assoc max_commute] 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

917 

527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

918 
lemma min_assoc: "!!x::'a::linorder. min (min x y) z = min x (min y z)" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

919 
apply(simp add:min_def) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

920 
apply(rule conjI) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

921 
apply(blast intro:order_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

922 
apply(simp add:linorder_not_le) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

923 
apply(blast dest: order_less_trans order_le_less_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

924 
done 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

925 

527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

926 
lemma min_commute: "!!x::'a::linorder. min x y = min y x" 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

927 
apply(simp add:min_def) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

928 
apply(rule conjI) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

929 
apply(blast intro:order_antisym) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

930 
apply(simp add:linorder_not_le) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

931 
apply(blast dest: order_less_trans) 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

932 
done 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

933 

527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

934 
lemmas min_ac = min_assoc min_commute 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

935 
mk_left_commute[of min,OF min_assoc min_commute] 
527811f00c56
added mk_left_commute to HOL.thy and used it "everywhere"
nipkow
parents:
13421
diff
changeset

936 

11750  937 
lemma split_min: 
938 
"P (min (i::'a::linorder) j) = ((i <= j > P(i)) & (~ i <= j > P(j)))" 

939 
by (simp add: min_def) 

940 

941 
lemma split_max: 

942 
"P (max (i::'a::linorder) j) = ((i <= j > P(j)) & (~ i <= j > P(i)))" 

943 
by (simp add: max_def) 

944 

945 

946 
subsubsection "Bounded quantifiers" 

947 

948 
syntax 

949 
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3ALL _<_./ _)" [0, 0, 10] 10) 

950 
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3EX _<_./ _)" [0, 0, 10] 10) 

951 
"_leAll" :: "[idt, 'a, bool] => bool" ("(3ALL _<=_./ _)" [0, 0, 10] 10) 

952 
"_leEx" :: "[idt, 'a, bool] => bool" ("(3EX _<=_./ _)" [0, 0, 10] 10) 

953 

12114
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
wenzelm
parents:
12023
diff
changeset

954 
syntax (xsymbols) 
11750  955 
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3\<forall>_<_./ _)" [0, 0, 10] 10) 
956 
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3\<exists>_<_./ _)" [0, 0, 10] 10) 

957 
"_leAll" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10) 

958 
"_leEx" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10) 

959 

960 
syntax (HOL) 

961 
"_lessAll" :: "[idt, 'a, bool] => bool" ("(3! _<_./ _)" [0, 0, 10] 10) 

962 
"_lessEx" :: "[idt, 'a, bool] => bool" ("(3? _<_./ _)" [0, 0, 10] 10) 

963 
"_leAll" :: "[idt, 'a, bool] => bool" ("(3! _<=_./ _)" [0, 0, 10] 10) 

964 
"_leEx" :: "[idt, 'a, bool] => bool" ("(3? _<=_./ _)" [0, 0, 10] 10) 

965 

966 
translations 

967 
"ALL x<y. P" => "ALL x. x < y > P" 

968 
"EX x<y. P" => "EX x. x < y & P" 

969 
"ALL x<=y. P" => "ALL x. x <= y > P" 

970 
"EX x<=y. P" => "EX x. x <= y & P" 

971 

14357  972 
print_translation {* 
973 
let 

974 
fun all_tr' [Const ("_bound",_) $ Free (v,_), 

975 
Const("op >",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 

976 
(if v=v' then Syntax.const "_lessAll" $ Syntax.mark_bound v' $ n $ P else raise Match) 

977 

978 
 all_tr' [Const ("_bound",_) $ Free (v,_), 

979 
Const("op >",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 

980 
(if v=v' then Syntax.const "_leAll" $ Syntax.mark_bound v' $ n $ P else raise Match); 

981 

982 
fun ex_tr' [Const ("_bound",_) $ Free (v,_), 

983 
Const("op &",_) $ (Const ("op <",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 

984 
(if v=v' then Syntax.const "_lessEx" $ Syntax.mark_bound v' $ n $ P else raise Match) 

985 

986 
 ex_tr' [Const ("_bound",_) $ Free (v,_), 

987 
Const("op &",_) $ (Const ("op <=",_) $ (Const ("_bound",_) $ Free (v',_)) $ n ) $ P] = 

988 
(if v=v' then Syntax.const "_leEx" $ Syntax.mark_bound v' $ n $ P else raise Match) 

989 
in 

990 
[("ALL ", all_tr'), ("EX ", ex_tr')] 

923  991 
end 
14357  992 
*} 
993 

994 
end 