author  berghofe 
Thu, 10 Oct 2002 14:21:49 +0200  
changeset 13638  2b234b079245 
parent 13598  8bc77b17f59f 
child 13723  c7d104550205 
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)" 
11432
8a203ae6efe3
added "The" (definite description operator) (by Larry);
wenzelm
parents:
10489
diff
changeset

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 

12633  78 
syntax (output) 
11687  79 
"=" :: "['a, 'a] => bool" (infix 50) 
12650  80 
"_not_equal" :: "['a, 'a] => bool" (infix "~=" 50) 
2260  81 

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

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

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

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

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

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

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

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

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

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

94 
syntax (xsymbols output) 
12650  95 
"_not_equal" :: "['a, 'a] => bool" (infix "\<noteq>" 50) 
3820  96 

6340  97 
syntax (HTML output) 
11687  98 
Not :: "bool => bool" ("\<not> _" [40] 40) 
6340  99 

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

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

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

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

104 

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

105 

11750  106 
subsubsection {* Axioms and basic definitions *} 
2260  107 

7357  108 
axioms 
109 
eq_reflection: "(x=y) ==> (x==y)" 

923  110 

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

6289  113 

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

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

6289  118 

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

119 
the_eq_trivial: "(THE x. x = a) = (a::'a)" 
923  120 

7357  121 
impI: "(P ==> Q) ==> P>Q" 
122 
mp: "[ P>Q; P ] ==> Q" 

923  123 

124 
defs 

7357  125 
True_def: "True == ((%x::bool. x) = (%x. x))" 
126 
All_def: "All(P) == (P = (%x. True))" 

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

127 
Ex_def: "Ex(P) == !Q. (!x. P x > Q) > Q" 
7357  128 
False_def: "False == (!P. P)" 
129 
not_def: "~ P == P>False" 

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

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

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

923  133 

7357  134 
axioms 
135 
iff: "(P>Q) > (Q>P) > (P=Q)" 

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

923  137 

138 
defs 

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

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

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

142 
arbitrary_def: "False ==> arbitrary == (THE x. False)" 
11750  143 
 {* @{term arbitrary} is completely unspecified, but is made to appear as a 
144 
definition syntactically *} 

923  145 

3320  146 

11750  147 
subsubsection {* Generic algebraic operations *} 
4868  148 

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

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

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

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

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

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

154 
axclass inverse < type 
11750  155 

156 
global 

157 

158 
consts 

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

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

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

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

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

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

165 

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

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

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

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

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

170 

11750  171 
local 
172 

173 
typed_print_translation {* 

174 
let 

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

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

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

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

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

180 

181 

182 
consts 

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

184 
inverse :: "'a::inverse => 'a" 

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

186 

187 
syntax (xsymbols) 

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

189 
syntax (HTML output) 

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

191 

192 
axclass plus_ac0 < plus, zero 

193 
commute: "x + y = y + x" 

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

195 
zero: "0 + x = x" 

196 

197 

198 
subsection {* Theory and package setup *} 

199 

200 
subsubsection {* Basic lemmas *} 

4868  201 

9736  202 
use "HOL_lemmas.ML" 
11687  203 
theorems case_split = case_split_thm [case_names True False] 
9869  204 

12386  205 

206 
subsubsection {* Intuitionistic Reasoning *} 

207 

208 
lemma impE': 

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

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

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

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

212 
shows R 
12386  213 
proof  
214 
from 3 and 1 have P . 

215 
with 1 have Q by (rule impE) 

216 
with 2 show R . 

217 
qed 

218 

219 
lemma allE': 

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

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

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

222 
shows Q 
12386  223 
proof  
224 
from 1 have "P x" by (rule spec) 

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

226 
qed 

227 

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

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

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

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

231 
shows R 
12386  232 
proof  
233 
from 2 and 1 have P . 

234 
with 1 show R by (rule notE) 

235 
qed 

236 

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

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

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

240 
and [CPure.intro] = exI disjI2 disjI1 

241 

242 
lemmas [trans] = trans 

243 
and [sym] = sym not_sym 

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

11750  245 

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

246 

11750  247 
subsubsection {* Atomizing metalevel connectives *} 
248 

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

12003  250 
proof 
9488  251 
assume "!!x. P x" 
10383  252 
show "ALL x. P x" by (rule allI) 
9488  253 
next 
254 
assume "ALL x. P x" 

10383  255 
thus "!!x. P x" by (rule allE) 
9488  256 
qed 
257 

11750  258 
lemma atomize_imp [atomize]: "(A ==> B) == Trueprop (A > B)" 
12003  259 
proof 
9488  260 
assume r: "A ==> B" 
10383  261 
show "A > B" by (rule impI) (rule r) 
9488  262 
next 
263 
assume "A > B" and A 

10383  264 
thus B by (rule mp) 
9488  265 
qed 
266 

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

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

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

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

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

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

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

275 

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

12003  278 
proof 
11953  279 
assume "!!C. (A ==> B ==> PROP C) ==> PROP C" 
280 
show "A & B" by (rule conjI) 

281 
next 

282 
fix C 

283 
assume "A & B" 

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

285 
thus "PROP C" 

286 
proof this 

287 
show A by (rule conjunct1) 

288 
show B by (rule conjunct2) 

289 
qed 

290 
qed 

291 

12386  292 
lemmas [symmetric, rulify] = atomize_all atomize_imp 
293 

11750  294 

295 
subsubsection {* Classical Reasoner setup *} 

9529  296 

10383  297 
use "cladata.ML" 
298 
setup hypsubst_setup 

11977  299 

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

302 
*} 

11977  303 

10383  304 
setup Classical.setup 
305 
setup clasetup 

306 

12386  307 
lemmas [intro?] = ext 
308 
and [elim?] = ex1_implies_ex 

11977  309 

9869  310 
use "blastdata.ML" 
311 
setup Blast.setup 

4868  312 

11750  313 

314 
subsubsection {* Simplifier setup *} 

315 

12281  316 
lemma meta_eq_to_obj_eq: "x == y ==> x = y" 
317 
proof  

318 
assume r: "x == y" 

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

320 
qed 

321 

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

323 

324 
lemma simp_thms: 

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

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

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

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

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

329 
"((~P) = (~Q)) = (P=Q)" 
12281  330 
"(x = x) = True" 
331 
"(~True) = False" "(~False) = True" 

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

332 
"(~P) ~= P" "P ~= (~P)" 
12281  333 
"(True=P) = P" "(P=True) = P" "(False=P) = (~P)" "(P=False) = (~P)" 
334 
"(True > P) = P" "(False > P) = True" 

335 
"(P > True) = True" "(P > P) = True" 

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

337 
"(P & True) = P" "(True & P) = P" 

338 
"(P & False) = False" "(False & P) = False" 

339 
"(P & P) = P" "(P & (P & Q)) = (P & Q)" 

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

341 
"(P  True) = True" "(True  P) = True" 

342 
"(P  False) = P" "(False  P) = P" 

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

343 
"(P  P) = P" "(P  (P  Q)) = (P  Q)" and 
12281  344 
"(ALL x. P) = P" "(EX x. P) = P" "EX x. x=t" "EX x. t=x" 
345 
 {* needed for the onepointrule quantifier simplification procs *} 

346 
 {* essential for termination!! *} and 

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

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

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

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

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

351 
by (blast, blast, blast, blast, blast, rules+) 
13421  352 

12281  353 
lemma imp_cong: "(P = P') ==> (P' ==> (Q = Q')) ==> ((P > Q) = (P' > Q'))" 
12354  354 
by rules 
12281  355 

356 
lemma ex_simps: 

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

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

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

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

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

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

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

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

364 
by (rules  blast)+ 
12281  365 

366 
lemma all_simps: 

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

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

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

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

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

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

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

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

374 
by (rules  blast)+ 
12281  375 

376 
lemma eq_ac: 

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

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

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

379 
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

380 
lemma neq_commute: "(a~=b) = (b~=a)" by rules 
12281  381 

382 
lemma conj_comms: 

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

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

384 
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

385 
lemma conj_assoc: "((P&Q)&R) = (P&(Q&R))" by rules 
12281  386 

387 
lemma disj_comms: 

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

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

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

390 
lemma disj_assoc: "((PQ)R) = (P(QR))" by rules 
12281  391 

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

392 
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

393 
lemma conj_disj_distribR: "((PQ)&R) = (P&R  Q&R)" by rules 
12281  394 

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

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

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

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

398 
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

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

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

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

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

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

405 

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

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

408 

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

409 
lemma de_Morgan_disj: "(~(P  Q)) = (~P & ~Q)" by rules 
12281  410 
lemma de_Morgan_conj: "(~(P & Q)) = (~P  ~Q)" by blast 
411 
lemma not_imp: "(~(P > Q)) = (P & ~Q)" by blast 

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

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

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

415 
by blast 

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

417 

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

418 
lemma iff_conv_conj_imp: "(P = Q) = ((P > Q) & (Q > P))" by rules 
12281  419 

420 

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

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

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

424 
by blast 

425 

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

427 
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

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

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

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

431 
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

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

434 
text {* 

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

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

437 

438 
lemma conj_cong: 

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

12354  440 
by rules 
12281  441 

442 
lemma rev_conj_cong: 

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

12354  444 
by rules 
12281  445 

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

447 

448 
lemma disj_cong: 

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

450 
by blast 

451 

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

12354  453 
by rules 
12281  454 

455 

456 
text {* \medskip ifthenelse rules *} 

457 

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

459 
by (unfold if_def) blast 

460 

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

462 
by (unfold if_def) blast 

463 

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

465 
by (unfold if_def) blast 

466 

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

468 
by (unfold if_def) blast 

469 

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

471 
apply (rule case_split [of Q]) 

472 
apply (subst if_P) 

473 
prefer 3 apply (subst if_not_P) 

474 
apply blast+ 

475 
done 

476 

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

478 
apply (subst split_if) 

479 
apply blast 

480 
done 

481 

482 
lemmas if_splits = split_if split_if_asm 

483 

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

485 
by (rule split_if) 

486 

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

488 
apply (subst split_if) 

489 
apply blast 

490 
done 

491 

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

493 
apply (subst split_if) 

494 
apply blast 

495 
done 

496 

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

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

499 
by (rule split_if) 

500 

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

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

503 
apply (subst split_if) 

504 
apply blast 

505 
done 

506 

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

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

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

9869  510 
use "simpdata.ML" 
511 
setup Simplifier.setup 

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

513 
setup Splitter.setup setup Clasimp.setup 

514 

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

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

518 
apply (fast dest!: theI') 

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

520 
apply (erule ex1E) 

521 
apply (rule allI) 

522 
apply (rule ex1I) 

523 
apply (erule spec) 

524 
apply (rule ccontr) 

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

526 
apply (erule impE) 

527 
apply (rule allI) 

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

529 
apply (drule_tac [3] x = x in fun_cong) 

530 
apply simp_all 

531 
done 

532 

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

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

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

535 
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

536 
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

537 
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

538 
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

539 

11750  540 

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

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

542 

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

543 
constdefs 
11989  544 
induct_forall :: "('a => bool) => bool" 
545 
"induct_forall P == \<forall>x. P x" 

546 
induct_implies :: "bool => bool => bool" 

547 
"induct_implies A B == A > B" 

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

549 
"induct_equal x y == x = y" 

550 
induct_conj :: "bool => bool => bool" 

551 
"induct_conj A B == A & B" 

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

552 

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

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

555 

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

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

558 

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

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

561 

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

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

565 

11989  566 
lemma induct_implies_conj: "induct_implies C (induct_conj A B) = 
567 
induct_conj (induct_implies C A) (induct_implies C B)" 

12354  568 
by (unfold induct_implies_def induct_conj_def) rules 
11989  569 

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

570 
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

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

572 
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

573 
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

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

575 
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

576 
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

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

578 

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

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

581 

12161  582 
lemmas induct_atomize = atomize_conj induct_forall_eq induct_implies_eq induct_equal_eq 
583 
lemmas induct_rulify1 [symmetric, standard] = induct_forall_eq induct_implies_eq induct_equal_eq 

584 
lemmas induct_rulify2 = induct_forall_def induct_implies_def induct_equal_def induct_conj_def 

11989  585 
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

586 

11989  587 
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

588 

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

589 

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

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

591 

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

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

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

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

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

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

598 
val conjI = thm "conjI"; 
11989  599 
val atomize = thms "induct_atomize"; 
600 
val rulify1 = thms "induct_rulify1"; 

601 
val rulify2 = thms "induct_rulify2"; 

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

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

604 
*} 
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 
setup InductMethod.setup 
f4c1882dde2c
setup generic cases and induction (from Inductive.thy);
wenzelm
parents:
11770
diff
changeset

607 

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

608 

11750  609 
subsection {* Order signatures and orders *} 
610 

611 
axclass 

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

612 
ord < type 
11750  613 

614 
syntax 

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

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

617 

618 
global 

619 

620 
consts 

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

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

623 

624 
local 

625 

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

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

629 

630 

631 
subsubsection {* Monotonicity *} 

632 

13412  633 
locale mono = 
634 
fixes f 

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

11750  636 

13421  637 
lemmas monoI [intro?] = mono.intro 
13412  638 
and monoD [dest?] = mono.mono 
11750  639 

640 
constdefs 

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

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

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

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

645 

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

647 
by (simp add: min_def) 

648 

649 
lemma min_of_mono: 

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

651 
by (simp add: min_def) 

652 

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

654 
by (simp add: max_def) 

655 

656 
lemma max_of_mono: 

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

658 
by (simp add: max_def) 

659 

660 

661 
subsubsection "Orders" 

662 

663 
axclass order < ord 

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

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

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

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

668 

669 

670 
text {* Reflexivity. *} 

671 

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

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

674 
apply (erule ssubst) 

675 
apply (rule order_refl) 

676 
done 

677 

13553  678 
lemma order_less_irrefl [iff]: "~ x < (x::'a::order)" 
11750  679 
by (simp add: order_less_le) 
680 

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

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

683 
apply (simp add: order_less_le) 

12256  684 
apply blast 
11750  685 
done 
686 

687 
lemmas order_le_imp_less_or_eq = order_le_less [THEN iffD1, standard] 

688 

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

690 
by (simp add: order_less_le) 

691 

692 

693 
text {* Asymmetry. *} 

694 

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

696 
by (simp add: order_less_le order_antisym) 

697 

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

699 
apply (drule order_less_not_sym) 

700 
apply (erule contrapos_np) 

701 
apply simp 

702 
done 

703 

704 

705 
text {* Transitivity. *} 

706 

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

708 
apply (simp add: order_less_le) 

709 
apply (blast intro: order_trans order_antisym) 

710 
done 

711 

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

713 
apply (simp add: order_less_le) 

714 
apply (blast intro: order_trans order_antisym) 

715 
done 

716 

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

718 
apply (simp add: order_less_le) 

719 
apply (blast intro: order_trans order_antisym) 

720 
done 

721 

722 

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

724 

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

726 
by (blast elim: order_less_asym) 

727 

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

729 
by (blast elim: order_less_asym) 

730 

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

732 
by auto 

733 

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

735 
by auto 

736 

737 

738 
text {* Other operators. *} 

739 

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

741 
apply (simp add: min_def) 

742 
apply (blast intro: order_antisym) 

743 
done 

744 

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

746 
apply (simp add: max_def) 

747 
apply (blast intro: order_antisym) 

748 
done 

749 

750 

751 
subsubsection {* Least value operator *} 

752 

753 
constdefs 

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

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

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

757 

758 
lemma LeastI2: 

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

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

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

12281  762 
==> Q (Least P)" 
11750  763 
apply (unfold Least_def) 
764 
apply (rule theI2) 

765 
apply (blast intro: order_antisym)+ 

766 
done 

767 

768 
lemma Least_equality: 

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

772 
apply (auto intro!: order_antisym) 

773 
done 

774 

775 

776 
subsubsection "Linear / total orders" 

777 

778 
axclass linorder < order 

779 
linorder_linear: "x <= y  y <= x" 

780 

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

782 
apply (simp add: order_less_le) 

783 
apply (insert linorder_linear) 

784 
apply blast 

785 
done 

786 

787 
lemma linorder_cases [case_names less equal greater]: 

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

789 
apply (insert linorder_less_linear) 

790 
apply blast 

791 
done 

792 

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

794 
apply (simp add: order_less_le) 

795 
apply (insert linorder_linear) 

796 
apply (blast intro: order_antisym) 

797 
done 

798 

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

800 
apply (simp add: order_less_le) 

801 
apply (insert linorder_linear) 

802 
apply (blast intro: order_antisym) 

803 
done 

804 

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

806 
apply (cut_tac x = x and y = y in linorder_less_linear) 

807 
apply auto 

808 
done 

809 

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

811 
apply (simp add: linorder_neq_iff) 

812 
apply blast 

813 
done 

814 

815 

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

817 

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

819 
by (simp add: min_def) 

820 

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

822 
by (simp add: max_def) 

823 

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

825 
apply (simp add: max_def) 

826 
apply (insert linorder_linear) 

827 
apply (blast intro: order_trans) 

828 
done 

829 

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

831 
by (simp add: le_max_iff_disj) 

832 

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

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

835 
by (simp add: le_max_iff_disj) 

836 

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

838 
apply (simp add: max_def order_le_less) 

839 
apply (insert linorder_less_linear) 

840 
apply (blast intro: order_less_trans) 

841 
done 

842 

843 
lemma max_le_iff_conj [simp]: 

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

845 
apply (simp add: max_def) 

846 
apply (insert linorder_linear) 

847 
apply (blast intro: order_trans) 

848 
done 

849 

850 
lemma max_less_iff_conj [simp]: 

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

852 
apply (simp add: order_le_less max_def) 

853 
apply (insert linorder_less_linear) 

854 
apply (blast intro: order_less_trans) 

855 
done 

856 

857 
lemma le_min_iff_conj [simp]: 

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

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

862 
apply (blast intro: order_trans) 

863 
done 

864 

865 
lemma min_less_iff_conj [simp]: 

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

867 
apply (simp add: order_le_less min_def) 

868 
apply (insert linorder_less_linear) 

869 
apply (blast intro: order_less_trans) 

870 
done 

871 

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

873 
apply (simp add: min_def) 

874 
apply (insert linorder_linear) 

875 
apply (blast intro: order_trans) 

876 
done 

877 

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

879 
apply (simp add: min_def order_le_less) 

880 
apply (insert linorder_less_linear) 

881 
apply (blast intro: order_less_trans) 

882 
done 

883 

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

884 
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

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

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

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

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

889 
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

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

891 

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

892 
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

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

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

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

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

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

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

899 

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

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

901 
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

902 

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

903 
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

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

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

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

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

908 
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

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

910 

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

911 
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

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

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

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

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

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

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

918 

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

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

920 
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

921 

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

924 
by (simp add: min_def) 

925 

926 
lemma split_max: 

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

928 
by (simp add: max_def) 

929 

930 

931 
subsubsection "Bounded quantifiers" 

932 

933 
syntax 

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

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

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

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

938 

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

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

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

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

944 

945 
syntax (HOL) 

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

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

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

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

950 

951 
translations 

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

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

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

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

956 

923  957 
end 