author | wenzelm |
Tue, 06 Aug 2002 11:22:05 +0200 | |
changeset 13462 | 56610e2ba220 |
parent 12372 | cd3a09c7dac9 |
child 13585 | db4005b40cc6 |
permissions | -rw-r--r-- |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
1 |
(* Title: HOL/Hilbert_Choice.thy |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
2 |
ID: $Id$ |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
3 |
Author: Lawrence C Paulson |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
4 |
Copyright 2001 University of Cambridge |
12023 | 5 |
*) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
6 |
|
12023 | 7 |
header {* Hilbert's epsilon-operator and everything to do with the Axiom of Choice *} |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
8 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
9 |
theory Hilbert_Choice = NatArith |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
10 |
files ("Hilbert_Choice_lemmas.ML") ("meson_lemmas.ML") ("Tools/meson.ML"): |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
11 |
|
12298 | 12 |
|
13 |
subsection {* Hilbert's epsilon *} |
|
14 |
||
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
15 |
consts |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
16 |
Eps :: "('a => bool) => 'a" |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
17 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
18 |
syntax (input) |
12298 | 19 |
"_Eps" :: "[pttrn, bool] => 'a" ("(3\<epsilon>_./ _)" [0, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
20 |
syntax (HOL) |
12298 | 21 |
"_Eps" :: "[pttrn, bool] => 'a" ("(3@ _./ _)" [0, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
22 |
syntax |
12298 | 23 |
"_Eps" :: "[pttrn, bool] => 'a" ("(3SOME _./ _)" [0, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
24 |
translations |
12298 | 25 |
"SOME x. P" == "Eps (%x. P)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
26 |
|
12298 | 27 |
axioms |
28 |
someI: "P (x::'a) ==> P (SOME x. P x)" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
29 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
30 |
|
12298 | 31 |
constdefs |
32 |
inv :: "('a => 'b) => ('b => 'a)" |
|
33 |
"inv(f :: 'a => 'b) == %y. SOME x. f x = y" |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
34 |
|
12298 | 35 |
Inv :: "'a set => ('a => 'b) => ('b => 'a)" |
36 |
"Inv A f == %x. SOME y. y : A & f y = x" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
37 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
38 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
39 |
use "Hilbert_Choice_lemmas.ML" |
12372 | 40 |
declare someI_ex [elim?]; |
41 |
||
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
42 |
|
12298 | 43 |
lemma tfl_some: "\<forall>P x. P x --> P (Eps P)" |
44 |
-- {* dynamically-scoped fact for TFL *} |
|
45 |
by (blast intro: someI) |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
46 |
|
12298 | 47 |
|
48 |
subsection {* Least value operator *} |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
49 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
50 |
constdefs |
12298 | 51 |
LeastM :: "['a => 'b::ord, 'a => bool] => 'a" |
52 |
"LeastM m P == SOME x. P x & (ALL y. P y --> m x <= m y)" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
53 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
54 |
syntax |
12298 | 55 |
"_LeastM" :: "[pttrn, 'a => 'b::ord, bool] => 'a" ("LEAST _ WRT _. _" [0, 4, 10] 10) |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
56 |
translations |
12298 | 57 |
"LEAST x WRT m. P" == "LeastM m (%x. P)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
58 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
59 |
lemma LeastMI2: |
12298 | 60 |
"P x ==> (!!y. P y ==> m x <= m y) |
61 |
==> (!!x. P x ==> \<forall>y. P y --> m x \<le> m y ==> Q x) |
|
62 |
==> Q (LeastM m P)" |
|
63 |
apply (unfold LeastM_def) |
|
64 |
apply (rule someI2_ex) |
|
65 |
apply blast |
|
66 |
apply blast |
|
67 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
68 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
69 |
lemma LeastM_equality: |
12298 | 70 |
"P k ==> (!!x. P x ==> m k <= m x) |
71 |
==> m (LEAST x WRT m. P x) = (m k::'a::order)" |
|
72 |
apply (rule LeastMI2) |
|
73 |
apply assumption |
|
74 |
apply blast |
|
75 |
apply (blast intro!: order_antisym) |
|
76 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
77 |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
78 |
lemma wf_linord_ex_has_least: |
12298 | 79 |
"wf r ==> ALL x y. ((x,y):r^+) = ((y,x)~:r^*) ==> P k |
80 |
==> EX x. P x & (!y. P y --> (m x,m y):r^*)" |
|
81 |
apply (drule wf_trancl [THEN wf_eq_minimal [THEN iffD1]]) |
|
82 |
apply (drule_tac x = "m`Collect P" in spec) |
|
83 |
apply force |
|
84 |
done |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
85 |
|
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
86 |
lemma ex_has_least_nat: |
12298 | 87 |
"P k ==> EX x. P x & (ALL y. P y --> m x <= (m y::nat))" |
88 |
apply (simp only: pred_nat_trancl_eq_le [symmetric]) |
|
89 |
apply (rule wf_pred_nat [THEN wf_linord_ex_has_least]) |
|
90 |
apply (simp add: less_eq not_le_iff_less pred_nat_trancl_eq_le) |
|
91 |
apply assumption |
|
92 |
done |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
93 |
|
12298 | 94 |
lemma LeastM_nat_lemma: |
95 |
"P k ==> P (LeastM m P) & (ALL y. P y --> m (LeastM m P) <= (m y::nat))" |
|
96 |
apply (unfold LeastM_def) |
|
97 |
apply (rule someI_ex) |
|
98 |
apply (erule ex_has_least_nat) |
|
99 |
done |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
100 |
|
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
101 |
lemmas LeastM_natI = LeastM_nat_lemma [THEN conjunct1, standard] |
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
102 |
|
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
103 |
lemma LeastM_nat_le: "P x ==> m (LeastM m P) <= (m x::nat)" |
12298 | 104 |
apply (rule LeastM_nat_lemma [THEN conjunct2, THEN spec, THEN mp]) |
105 |
apply assumption |
|
106 |
apply assumption |
|
107 |
done |
|
11454
7514e5e21cb8
Hilbert restructuring: Wellfounded_Relations no longer needs Hilbert_Choice
paulson
parents:
11451
diff
changeset
|
108 |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
109 |
|
12298 | 110 |
subsection {* Greatest value operator *} |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
111 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
112 |
constdefs |
12298 | 113 |
GreatestM :: "['a => 'b::ord, 'a => bool] => 'a" |
114 |
"GreatestM m P == SOME x. P x & (ALL y. P y --> m y <= m x)" |
|
115 |
||
116 |
Greatest :: "('a::ord => bool) => 'a" (binder "GREATEST " 10) |
|
117 |
"Greatest == GreatestM (%x. x)" |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
118 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
119 |
syntax |
12298 | 120 |
"_GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a" |
121 |
("GREATEST _ WRT _. _" [0, 4, 10] 10) |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
122 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
123 |
translations |
12298 | 124 |
"GREATEST x WRT m. P" == "GreatestM m (%x. P)" |
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
125 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
126 |
lemma GreatestMI2: |
12298 | 127 |
"P x ==> (!!y. P y ==> m y <= m x) |
128 |
==> (!!x. P x ==> \<forall>y. P y --> m y \<le> m x ==> Q x) |
|
129 |
==> Q (GreatestM m P)" |
|
130 |
apply (unfold GreatestM_def) |
|
131 |
apply (rule someI2_ex) |
|
132 |
apply blast |
|
133 |
apply blast |
|
134 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
135 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
136 |
lemma GreatestM_equality: |
12298 | 137 |
"P k ==> (!!x. P x ==> m x <= m k) |
138 |
==> m (GREATEST x WRT m. P x) = (m k::'a::order)" |
|
139 |
apply (rule_tac m = m in GreatestMI2) |
|
140 |
apply assumption |
|
141 |
apply blast |
|
142 |
apply (blast intro!: order_antisym) |
|
143 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
144 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
145 |
lemma Greatest_equality: |
12298 | 146 |
"P (k::'a::order) ==> (!!x. P x ==> x <= k) ==> (GREATEST x. P x) = k" |
147 |
apply (unfold Greatest_def) |
|
148 |
apply (erule GreatestM_equality) |
|
149 |
apply blast |
|
150 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
151 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
152 |
lemma ex_has_greatest_nat_lemma: |
12298 | 153 |
"P k ==> ALL x. P x --> (EX y. P y & ~ ((m y::nat) <= m x)) |
154 |
==> EX y. P y & ~ (m y < m k + n)" |
|
155 |
apply (induct_tac n) |
|
156 |
apply force |
|
157 |
apply (force simp add: le_Suc_eq) |
|
158 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
159 |
|
12298 | 160 |
lemma ex_has_greatest_nat: |
161 |
"P k ==> ALL y. P y --> m y < b |
|
162 |
==> EX x. P x & (ALL y. P y --> (m y::nat) <= m x)" |
|
163 |
apply (rule ccontr) |
|
164 |
apply (cut_tac P = P and n = "b - m k" in ex_has_greatest_nat_lemma) |
|
165 |
apply (subgoal_tac [3] "m k <= b") |
|
166 |
apply auto |
|
167 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
168 |
|
12298 | 169 |
lemma GreatestM_nat_lemma: |
170 |
"P k ==> ALL y. P y --> m y < b |
|
171 |
==> P (GreatestM m P) & (ALL y. P y --> (m y::nat) <= m (GreatestM m P))" |
|
172 |
apply (unfold GreatestM_def) |
|
173 |
apply (rule someI_ex) |
|
174 |
apply (erule ex_has_greatest_nat) |
|
175 |
apply assumption |
|
176 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
177 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
178 |
lemmas GreatestM_natI = GreatestM_nat_lemma [THEN conjunct1, standard] |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
179 |
|
12298 | 180 |
lemma GreatestM_nat_le: |
181 |
"P x ==> ALL y. P y --> m y < b |
|
182 |
==> (m x::nat) <= m (GreatestM m P)" |
|
183 |
apply (blast dest: GreatestM_nat_lemma [THEN conjunct2, THEN spec]) |
|
184 |
done |
|
185 |
||
186 |
||
187 |
text {* \medskip Specialization to @{text GREATEST}. *} |
|
188 |
||
189 |
lemma GreatestI: "P (k::nat) ==> ALL y. P y --> y < b ==> P (GREATEST x. P x)" |
|
190 |
apply (unfold Greatest_def) |
|
191 |
apply (rule GreatestM_natI) |
|
192 |
apply auto |
|
193 |
done |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
194 |
|
12298 | 195 |
lemma Greatest_le: |
196 |
"P x ==> ALL y. P y --> y < b ==> (x::nat) <= (GREATEST x. P x)" |
|
197 |
apply (unfold Greatest_def) |
|
198 |
apply (rule GreatestM_nat_le) |
|
199 |
apply auto |
|
200 |
done |
|
201 |
||
202 |
||
203 |
subsection {* The Meson proof procedure *} |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
204 |
|
12298 | 205 |
subsubsection {* Negation Normal Form *} |
206 |
||
207 |
text {* de Morgan laws *} |
|
208 |
||
209 |
lemma meson_not_conjD: "~(P&Q) ==> ~P | ~Q" |
|
210 |
and meson_not_disjD: "~(P|Q) ==> ~P & ~Q" |
|
211 |
and meson_not_notD: "~~P ==> P" |
|
212 |
and meson_not_allD: "!!P. ~(ALL x. P(x)) ==> EX x. ~P(x)" |
|
213 |
and meson_not_exD: "!!P. ~(EX x. P(x)) ==> ALL x. ~P(x)" |
|
214 |
by fast+ |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
215 |
|
12298 | 216 |
text {* Removal of @{text "-->"} and @{text "<->"} (positive and |
217 |
negative occurrences) *} |
|
218 |
||
219 |
lemma meson_imp_to_disjD: "P-->Q ==> ~P | Q" |
|
220 |
and meson_not_impD: "~(P-->Q) ==> P & ~Q" |
|
221 |
and meson_iff_to_disjD: "P=Q ==> (~P | Q) & (~Q | P)" |
|
222 |
and meson_not_iffD: "~(P=Q) ==> (P | Q) & (~P | ~Q)" |
|
223 |
-- {* Much more efficient than @{prop "(P & ~Q) | (Q & ~P)"} for computing CNF *} |
|
224 |
by fast+ |
|
225 |
||
226 |
||
227 |
subsubsection {* Pulling out the existential quantifiers *} |
|
228 |
||
229 |
text {* Conjunction *} |
|
230 |
||
231 |
lemma meson_conj_exD1: "!!P Q. (EX x. P(x)) & Q ==> EX x. P(x) & Q" |
|
232 |
and meson_conj_exD2: "!!P Q. P & (EX x. Q(x)) ==> EX x. P & Q(x)" |
|
233 |
by fast+ |
|
234 |
||
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
235 |
|
12298 | 236 |
text {* Disjunction *} |
237 |
||
238 |
lemma meson_disj_exD: "!!P Q. (EX x. P(x)) | (EX x. Q(x)) ==> EX x. P(x) | Q(x)" |
|
239 |
-- {* DO NOT USE with forall-Skolemization: makes fewer schematic variables!! *} |
|
240 |
-- {* With ex-Skolemization, makes fewer Skolem constants *} |
|
241 |
and meson_disj_exD1: "!!P Q. (EX x. P(x)) | Q ==> EX x. P(x) | Q" |
|
242 |
and meson_disj_exD2: "!!P Q. P | (EX x. Q(x)) ==> EX x. P | Q(x)" |
|
243 |
by fast+ |
|
244 |
||
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
245 |
|
12298 | 246 |
subsubsection {* Generating clauses for the Meson Proof Procedure *} |
247 |
||
248 |
text {* Disjunctions *} |
|
249 |
||
250 |
lemma meson_disj_assoc: "(P|Q)|R ==> P|(Q|R)" |
|
251 |
and meson_disj_comm: "P|Q ==> Q|P" |
|
252 |
and meson_disj_FalseD1: "False|P ==> P" |
|
253 |
and meson_disj_FalseD2: "P|False ==> P" |
|
254 |
by fast+ |
|
11451
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
255 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
256 |
use "meson_lemmas.ML" |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
257 |
use "Tools/meson.ML" |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
258 |
setup meson_setup |
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
259 |
|
8abfb4f7bd02
partial restructuring to reduce dependence on Axiom of Choice
paulson
parents:
diff
changeset
|
260 |
end |