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