author | wenzelm |
Mon, 24 Oct 2022 20:37:32 +0200 | |
changeset 76371 | 1ac2416e8432 |
parent 74397 | e80c4cde6064 |
child 82292 | 5d91cca0aaf3 |
permissions | -rw-r--r-- |
30439 | 1 |
(* Title: HOL/Decision_Procs/Ferrack.thy |
29789 | 2 |
Author: Amine Chaieb |
3 |
*) |
|
4 |
||
5 |
theory Ferrack |
|
41849 | 6 |
imports Complex_Main Dense_Linear_Order DP_Library |
66809 | 7 |
"HOL-Library.Code_Target_Numeral" |
29789 | 8 |
begin |
9 |
||
61586 | 10 |
section \<open>Quantifier elimination for \<open>\<real> (0, 1, +, <)\<close>\<close> |
29789 | 11 |
|
12 |
(*********************************************************************************) |
|
13 |
(**** SHADOW SYNTAX AND SEMANTICS ****) |
|
14 |
(*********************************************************************************) |
|
15 |
||
66809 | 16 |
datatype (plugins del: size) num = C int | Bound nat | CN nat int num | Neg num | Add num num| Sub num num |
60710 | 17 |
| Mul int num |
29789 | 18 |
|
66809 | 19 |
instantiation num :: size |
20 |
begin |
|
21 |
||
22 |
primrec size_num :: "num \<Rightarrow> nat" |
|
60710 | 23 |
where |
66809 | 24 |
"size_num (C c) = 1" |
25 |
| "size_num (Bound n) = 1" |
|
26 |
| "size_num (Neg a) = 1 + size_num a" |
|
27 |
| "size_num (Add a b) = 1 + size_num a + size_num b" |
|
28 |
| "size_num (Sub a b) = 3 + size_num a + size_num b" |
|
29 |
| "size_num (Mul c a) = 1 + size_num a" |
|
30 |
| "size_num (CN n c a) = 3 + size_num a " |
|
31 |
||
32 |
instance .. |
|
33 |
||
34 |
end |
|
29789 | 35 |
|
36 |
(* Semantics of numeral terms (num) *) |
|
60710 | 37 |
primrec Inum :: "real list \<Rightarrow> num \<Rightarrow> real" |
38 |
where |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
39 |
"Inum bs (C c) = (real_of_int c)" |
36853 | 40 |
| "Inum bs (Bound n) = bs!n" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
41 |
| "Inum bs (CN n c a) = (real_of_int c) * (bs!n) + (Inum bs a)" |
36853 | 42 |
| "Inum bs (Neg a) = -(Inum bs a)" |
43 |
| "Inum bs (Add a b) = Inum bs a + Inum bs b" |
|
44 |
| "Inum bs (Sub a b) = Inum bs a - Inum bs b" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
45 |
| "Inum bs (Mul c a) = (real_of_int c) * Inum bs a" |
29789 | 46 |
(* FORMULAE *) |
66809 | 47 |
datatype (plugins del: size) fm = |
29789 | 48 |
T| F| Lt num| Le num| Gt num| Ge num| Eq num| NEq num| |
74101 | 49 |
Not fm| And fm fm| Or fm fm| Imp fm fm| Iff fm fm| E fm| A fm |
29789 | 50 |
|
66809 | 51 |
instantiation fm :: size |
52 |
begin |
|
29789 | 53 |
|
66809 | 54 |
primrec size_fm :: "fm \<Rightarrow> nat" |
60710 | 55 |
where |
74101 | 56 |
"size_fm (Not p) = 1 + size_fm p" |
66809 | 57 |
| "size_fm (And p q) = 1 + size_fm p + size_fm q" |
58 |
| "size_fm (Or p q) = 1 + size_fm p + size_fm q" |
|
59 |
| "size_fm (Imp p q) = 3 + size_fm p + size_fm q" |
|
60 |
| "size_fm (Iff p q) = 3 + 2 * (size_fm p + size_fm q)" |
|
61 |
| "size_fm (E p) = 1 + size_fm p" |
|
62 |
| "size_fm (A p) = 4 + size_fm p" |
|
63 |
| "size_fm T = 1" |
|
64 |
| "size_fm F = 1" |
|
65 |
| "size_fm (Lt _) = 1" |
|
66 |
| "size_fm (Le _) = 1" |
|
67 |
| "size_fm (Gt _) = 1" |
|
68 |
| "size_fm (Ge _) = 1" |
|
69 |
| "size_fm (Eq _) = 1" |
|
70 |
| "size_fm (NEq _) = 1" |
|
60710 | 71 |
|
66809 | 72 |
instance .. |
73 |
||
74 |
end |
|
75 |
||
76 |
lemma size_fm_pos [simp]: "size p > 0" for p :: fm |
|
77 |
by (induct p) simp_all |
|
29789 | 78 |
|
79 |
(* Semantics of formulae (fm) *) |
|
60710 | 80 |
primrec Ifm ::"real list \<Rightarrow> fm \<Rightarrow> bool" |
81 |
where |
|
29789 | 82 |
"Ifm bs T = True" |
36853 | 83 |
| "Ifm bs F = False" |
84 |
| "Ifm bs (Lt a) = (Inum bs a < 0)" |
|
85 |
| "Ifm bs (Gt a) = (Inum bs a > 0)" |
|
86 |
| "Ifm bs (Le a) = (Inum bs a \<le> 0)" |
|
87 |
| "Ifm bs (Ge a) = (Inum bs a \<ge> 0)" |
|
88 |
| "Ifm bs (Eq a) = (Inum bs a = 0)" |
|
89 |
| "Ifm bs (NEq a) = (Inum bs a \<noteq> 0)" |
|
74101 | 90 |
| "Ifm bs (Not p) = (\<not> (Ifm bs p))" |
36853 | 91 |
| "Ifm bs (And p q) = (Ifm bs p \<and> Ifm bs q)" |
92 |
| "Ifm bs (Or p q) = (Ifm bs p \<or> Ifm bs q)" |
|
93 |
| "Ifm bs (Imp p q) = ((Ifm bs p) \<longrightarrow> (Ifm bs q))" |
|
94 |
| "Ifm bs (Iff p q) = (Ifm bs p = Ifm bs q)" |
|
60710 | 95 |
| "Ifm bs (E p) = (\<exists>x. Ifm (x#bs) p)" |
96 |
| "Ifm bs (A p) = (\<forall>x. Ifm (x#bs) p)" |
|
29789 | 97 |
|
98 |
lemma IfmLeSub: "\<lbrakk> Inum bs s = s' ; Inum bs t = t' \<rbrakk> \<Longrightarrow> Ifm bs (Le (Sub s t)) = (s' \<le> t')" |
|
60710 | 99 |
by simp |
29789 | 100 |
|
101 |
lemma IfmLtSub: "\<lbrakk> Inum bs s = s' ; Inum bs t = t' \<rbrakk> \<Longrightarrow> Ifm bs (Lt (Sub s t)) = (s' < t')" |
|
60710 | 102 |
by simp |
103 |
||
29789 | 104 |
lemma IfmEqSub: "\<lbrakk> Inum bs s = s' ; Inum bs t = t' \<rbrakk> \<Longrightarrow> Ifm bs (Eq (Sub s t)) = (s' = t')" |
60710 | 105 |
by simp |
106 |
||
74101 | 107 |
lemma IfmNot: " (Ifm bs p = P) \<Longrightarrow> (Ifm bs (Not p) = (\<not>P))" |
60710 | 108 |
by simp |
109 |
||
29789 | 110 |
lemma IfmAnd: " \<lbrakk> Ifm bs p = P ; Ifm bs q = Q\<rbrakk> \<Longrightarrow> (Ifm bs (And p q) = (P \<and> Q))" |
60710 | 111 |
by simp |
112 |
||
29789 | 113 |
lemma IfmOr: " \<lbrakk> Ifm bs p = P ; Ifm bs q = Q\<rbrakk> \<Longrightarrow> (Ifm bs (Or p q) = (P \<or> Q))" |
60710 | 114 |
by simp |
115 |
||
29789 | 116 |
lemma IfmImp: " \<lbrakk> Ifm bs p = P ; Ifm bs q = Q\<rbrakk> \<Longrightarrow> (Ifm bs (Imp p q) = (P \<longrightarrow> Q))" |
60710 | 117 |
by simp |
118 |
||
29789 | 119 |
lemma IfmIff: " \<lbrakk> Ifm bs p = P ; Ifm bs q = Q\<rbrakk> \<Longrightarrow> (Ifm bs (Iff p q) = (P = Q))" |
60710 | 120 |
by simp |
29789 | 121 |
|
122 |
lemma IfmE: " (!! x. Ifm (x#bs) p = P x) \<Longrightarrow> (Ifm bs (E p) = (\<exists>x. P x))" |
|
60710 | 123 |
by simp |
124 |
||
29789 | 125 |
lemma IfmA: " (!! x. Ifm (x#bs) p = P x) \<Longrightarrow> (Ifm bs (A p) = (\<forall>x. P x))" |
60710 | 126 |
by simp |
29789 | 127 |
|
60710 | 128 |
fun not:: "fm \<Rightarrow> fm" |
129 |
where |
|
74101 | 130 |
"not (Not p) = p" |
36853 | 131 |
| "not T = F" |
132 |
| "not F = T" |
|
74101 | 133 |
| "not p = Not p" |
60710 | 134 |
|
74101 | 135 |
lemma not[simp]: "Ifm bs (not p) = Ifm bs (Not p)" |
60710 | 136 |
by (cases p) auto |
29789 | 137 |
|
60710 | 138 |
definition conj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
139 |
where |
|
140 |
"conj p q = |
|
141 |
(if p = F \<or> q = F then F |
|
142 |
else if p = T then q |
|
143 |
else if q = T then p |
|
144 |
else if p = q then p else And p q)" |
|
145 |
||
29789 | 146 |
lemma conj[simp]: "Ifm bs (conj p q) = Ifm bs (And p q)" |
60710 | 147 |
by (cases "p = F \<or> q = F", simp_all add: conj_def) (cases p, simp_all) |
29789 | 148 |
|
60710 | 149 |
definition disj :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
150 |
where |
|
151 |
"disj p q = |
|
152 |
(if p = T \<or> q = T then T |
|
153 |
else if p = F then q |
|
154 |
else if q = F then p |
|
155 |
else if p = q then p else Or p q)" |
|
29789 | 156 |
|
157 |
lemma disj[simp]: "Ifm bs (disj p q) = Ifm bs (Or p q)" |
|
60710 | 158 |
by (cases "p = T \<or> q = T", simp_all add: disj_def) (cases p, simp_all) |
29789 | 159 |
|
60710 | 160 |
definition imp :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
161 |
where |
|
162 |
"imp p q = |
|
163 |
(if p = F \<or> q = T \<or> p = q then T |
|
164 |
else if p = T then q |
|
165 |
else if q = F then not p |
|
29789 | 166 |
else Imp p q)" |
60710 | 167 |
|
29789 | 168 |
lemma imp[simp]: "Ifm bs (imp p q) = Ifm bs (Imp p q)" |
60710 | 169 |
by (cases "p = F \<or> q = T") (simp_all add: imp_def) |
29789 | 170 |
|
60710 | 171 |
definition iff :: "fm \<Rightarrow> fm \<Rightarrow> fm" |
172 |
where |
|
173 |
"iff p q = |
|
174 |
(if p = q then T |
|
74101 | 175 |
else if p = Not q \<or> Not p = q then F |
60710 | 176 |
else if p = F then not q |
177 |
else if q = F then not p |
|
178 |
else if p = T then q |
|
179 |
else if q = T then p |
|
180 |
else Iff p q)" |
|
181 |
||
29789 | 182 |
lemma iff[simp]: "Ifm bs (iff p q) = Ifm bs (Iff p q)" |
74101 | 183 |
by (unfold iff_def, cases "p = q", simp, cases "p = Not q", simp) (cases "Not p = q", auto) |
29789 | 184 |
|
185 |
lemma conj_simps: |
|
186 |
"conj F Q = F" |
|
187 |
"conj P F = F" |
|
188 |
"conj T Q = Q" |
|
189 |
"conj P T = P" |
|
190 |
"conj P P = P" |
|
191 |
"P \<noteq> T \<Longrightarrow> P \<noteq> F \<Longrightarrow> Q \<noteq> T \<Longrightarrow> Q \<noteq> F \<Longrightarrow> P \<noteq> Q \<Longrightarrow> conj P Q = And P Q" |
|
192 |
by (simp_all add: conj_def) |
|
193 |
||
194 |
lemma disj_simps: |
|
195 |
"disj T Q = T" |
|
196 |
"disj P T = T" |
|
197 |
"disj F Q = Q" |
|
198 |
"disj P F = P" |
|
199 |
"disj P P = P" |
|
200 |
"P \<noteq> T \<Longrightarrow> P \<noteq> F \<Longrightarrow> Q \<noteq> T \<Longrightarrow> Q \<noteq> F \<Longrightarrow> P \<noteq> Q \<Longrightarrow> disj P Q = Or P Q" |
|
201 |
by (simp_all add: disj_def) |
|
60710 | 202 |
|
29789 | 203 |
lemma imp_simps: |
204 |
"imp F Q = T" |
|
205 |
"imp P T = T" |
|
206 |
"imp T Q = Q" |
|
207 |
"imp P F = not P" |
|
208 |
"imp P P = T" |
|
209 |
"P \<noteq> T \<Longrightarrow> P \<noteq> F \<Longrightarrow> P \<noteq> Q \<Longrightarrow> Q \<noteq> T \<Longrightarrow> Q \<noteq> F \<Longrightarrow> imp P Q = Imp P Q" |
|
210 |
by (simp_all add: imp_def) |
|
60710 | 211 |
|
74101 | 212 |
lemma trivNot: "p \<noteq> Not p" "Not p \<noteq> p" |
60710 | 213 |
by (induct p) auto |
29789 | 214 |
|
215 |
lemma iff_simps: |
|
216 |
"iff p p = T" |
|
74101 | 217 |
"iff p (Not p) = F" |
218 |
"iff (Not p) p = F" |
|
29789 | 219 |
"iff p F = not p" |
220 |
"iff F p = not p" |
|
74101 | 221 |
"p \<noteq> Not T \<Longrightarrow> iff T p = p" |
222 |
"p\<noteq> Not T \<Longrightarrow> iff p T = p" |
|
223 |
"p\<noteq>q \<Longrightarrow> p\<noteq> Not q \<Longrightarrow> q\<noteq> Not p \<Longrightarrow> p\<noteq> F \<Longrightarrow> q\<noteq> F \<Longrightarrow> p \<noteq> T \<Longrightarrow> q \<noteq> T \<Longrightarrow> iff p q = Iff p q" |
|
224 |
using trivNot |
|
29789 | 225 |
by (simp_all add: iff_def, cases p, auto) |
60710 | 226 |
|
29789 | 227 |
(* Quantifier freeness *) |
60710 | 228 |
fun qfree:: "fm \<Rightarrow> bool" |
229 |
where |
|
29789 | 230 |
"qfree (E p) = False" |
36853 | 231 |
| "qfree (A p) = False" |
74101 | 232 |
| "qfree (Not p) = qfree p" |
60710 | 233 |
| "qfree (And p q) = (qfree p \<and> qfree q)" |
234 |
| "qfree (Or p q) = (qfree p \<and> qfree q)" |
|
235 |
| "qfree (Imp p q) = (qfree p \<and> qfree q)" |
|
36853 | 236 |
| "qfree (Iff p q) = (qfree p \<and> qfree q)" |
237 |
| "qfree p = True" |
|
29789 | 238 |
|
239 |
(* Boundedness and substitution *) |
|
60710 | 240 |
primrec numbound0:: "num \<Rightarrow> bool" (* a num is INDEPENDENT of Bound 0 *) |
241 |
where |
|
29789 | 242 |
"numbound0 (C c) = True" |
60710 | 243 |
| "numbound0 (Bound n) = (n > 0)" |
244 |
| "numbound0 (CN n c a) = (n \<noteq> 0 \<and> numbound0 a)" |
|
36853 | 245 |
| "numbound0 (Neg a) = numbound0 a" |
246 |
| "numbound0 (Add a b) = (numbound0 a \<and> numbound0 b)" |
|
60710 | 247 |
| "numbound0 (Sub a b) = (numbound0 a \<and> numbound0 b)" |
36853 | 248 |
| "numbound0 (Mul i a) = numbound0 a" |
249 |
||
29789 | 250 |
lemma numbound0_I: |
251 |
assumes nb: "numbound0 a" |
|
252 |
shows "Inum (b#bs) a = Inum (b'#bs) a" |
|
60710 | 253 |
using nb by (induct a) simp_all |
29789 | 254 |
|
60710 | 255 |
primrec bound0:: "fm \<Rightarrow> bool" (* A Formula is independent of Bound 0 *) |
256 |
where |
|
29789 | 257 |
"bound0 T = True" |
36853 | 258 |
| "bound0 F = True" |
259 |
| "bound0 (Lt a) = numbound0 a" |
|
260 |
| "bound0 (Le a) = numbound0 a" |
|
261 |
| "bound0 (Gt a) = numbound0 a" |
|
262 |
| "bound0 (Ge a) = numbound0 a" |
|
263 |
| "bound0 (Eq a) = numbound0 a" |
|
264 |
| "bound0 (NEq a) = numbound0 a" |
|
74101 | 265 |
| "bound0 (Not p) = bound0 p" |
36853 | 266 |
| "bound0 (And p q) = (bound0 p \<and> bound0 q)" |
267 |
| "bound0 (Or p q) = (bound0 p \<and> bound0 q)" |
|
268 |
| "bound0 (Imp p q) = ((bound0 p) \<and> (bound0 q))" |
|
269 |
| "bound0 (Iff p q) = (bound0 p \<and> bound0 q)" |
|
270 |
| "bound0 (E p) = False" |
|
271 |
| "bound0 (A p) = False" |
|
29789 | 272 |
|
273 |
lemma bound0_I: |
|
274 |
assumes bp: "bound0 p" |
|
275 |
shows "Ifm (b#bs) p = Ifm (b'#bs) p" |
|
60710 | 276 |
using bp numbound0_I[where b="b" and bs="bs" and b'="b'"] |
277 |
by (induct p) auto |
|
29789 | 278 |
|
279 |
lemma not_qf[simp]: "qfree p \<Longrightarrow> qfree (not p)" |
|
60710 | 280 |
by (cases p) auto |
281 |
||
29789 | 282 |
lemma not_bn[simp]: "bound0 p \<Longrightarrow> bound0 (not p)" |
60710 | 283 |
by (cases p) auto |
29789 | 284 |
|
285 |
||
286 |
lemma conj_qf[simp]: "\<lbrakk>qfree p ; qfree q\<rbrakk> \<Longrightarrow> qfree (conj p q)" |
|
60710 | 287 |
using conj_def by auto |
29789 | 288 |
lemma conj_nb[simp]: "\<lbrakk>bound0 p ; bound0 q\<rbrakk> \<Longrightarrow> bound0 (conj p q)" |
60710 | 289 |
using conj_def by auto |
29789 | 290 |
|
291 |
lemma disj_qf[simp]: "\<lbrakk>qfree p ; qfree q\<rbrakk> \<Longrightarrow> qfree (disj p q)" |
|
60710 | 292 |
using disj_def by auto |
29789 | 293 |
lemma disj_nb[simp]: "\<lbrakk>bound0 p ; bound0 q\<rbrakk> \<Longrightarrow> bound0 (disj p q)" |
60710 | 294 |
using disj_def by auto |
29789 | 295 |
|
296 |
lemma imp_qf[simp]: "\<lbrakk>qfree p ; qfree q\<rbrakk> \<Longrightarrow> qfree (imp p q)" |
|
60710 | 297 |
using imp_def by (cases "p=F \<or> q=T",simp_all add: imp_def) |
29789 | 298 |
lemma imp_nb[simp]: "\<lbrakk>bound0 p ; bound0 q\<rbrakk> \<Longrightarrow> bound0 (imp p q)" |
60710 | 299 |
using imp_def by (cases "p=F \<or> q=T \<or> p=q",simp_all add: imp_def) |
29789 | 300 |
|
301 |
lemma iff_qf[simp]: "\<lbrakk>qfree p ; qfree q\<rbrakk> \<Longrightarrow> qfree (iff p q)" |
|
60710 | 302 |
unfolding iff_def by (cases "p = q") auto |
29789 | 303 |
lemma iff_nb[simp]: "\<lbrakk>bound0 p ; bound0 q\<rbrakk> \<Longrightarrow> bound0 (iff p q)" |
60710 | 304 |
using iff_def unfolding iff_def by (cases "p = q") auto |
29789 | 305 |
|
60710 | 306 |
fun decrnum:: "num \<Rightarrow> num" |
307 |
where |
|
29789 | 308 |
"decrnum (Bound n) = Bound (n - 1)" |
36853 | 309 |
| "decrnum (Neg a) = Neg (decrnum a)" |
310 |
| "decrnum (Add a b) = Add (decrnum a) (decrnum b)" |
|
311 |
| "decrnum (Sub a b) = Sub (decrnum a) (decrnum b)" |
|
312 |
| "decrnum (Mul c a) = Mul c (decrnum a)" |
|
313 |
| "decrnum (CN n c a) = CN (n - 1) c (decrnum a)" |
|
314 |
| "decrnum a = a" |
|
29789 | 315 |
|
60710 | 316 |
fun decr :: "fm \<Rightarrow> fm" |
317 |
where |
|
29789 | 318 |
"decr (Lt a) = Lt (decrnum a)" |
36853 | 319 |
| "decr (Le a) = Le (decrnum a)" |
320 |
| "decr (Gt a) = Gt (decrnum a)" |
|
321 |
| "decr (Ge a) = Ge (decrnum a)" |
|
322 |
| "decr (Eq a) = Eq (decrnum a)" |
|
323 |
| "decr (NEq a) = NEq (decrnum a)" |
|
74101 | 324 |
| "decr (Not p) = Not (decr p)" |
36853 | 325 |
| "decr (And p q) = conj (decr p) (decr q)" |
326 |
| "decr (Or p q) = disj (decr p) (decr q)" |
|
327 |
| "decr (Imp p q) = imp (decr p) (decr q)" |
|
328 |
| "decr (Iff p q) = iff (decr p) (decr q)" |
|
329 |
| "decr p = p" |
|
29789 | 330 |
|
60710 | 331 |
lemma decrnum: |
332 |
assumes nb: "numbound0 t" |
|
333 |
shows "Inum (x # bs) t = Inum bs (decrnum t)" |
|
334 |
using nb by (induct t rule: decrnum.induct) simp_all |
|
29789 | 335 |
|
60710 | 336 |
lemma decr: |
337 |
assumes nb: "bound0 p" |
|
338 |
shows "Ifm (x # bs) p = Ifm bs (decr p)" |
|
339 |
using nb by (induct p rule: decr.induct) (simp_all add: decrnum) |
|
29789 | 340 |
|
341 |
lemma decr_qf: "bound0 p \<Longrightarrow> qfree (decr p)" |
|
60710 | 342 |
by (induct p) simp_all |
29789 | 343 |
|
60710 | 344 |
fun isatom :: "fm \<Rightarrow> bool" (* test for atomicity *) |
345 |
where |
|
29789 | 346 |
"isatom T = True" |
36853 | 347 |
| "isatom F = True" |
348 |
| "isatom (Lt a) = True" |
|
349 |
| "isatom (Le a) = True" |
|
350 |
| "isatom (Gt a) = True" |
|
351 |
| "isatom (Ge a) = True" |
|
352 |
| "isatom (Eq a) = True" |
|
353 |
| "isatom (NEq a) = True" |
|
354 |
| "isatom p = False" |
|
29789 | 355 |
|
356 |
lemma bound0_qf: "bound0 p \<Longrightarrow> qfree p" |
|
60710 | 357 |
by (induct p) simp_all |
29789 | 358 |
|
60710 | 359 |
definition djf :: "('a \<Rightarrow> fm) \<Rightarrow> 'a \<Rightarrow> fm \<Rightarrow> fm" |
360 |
where |
|
361 |
"djf f p q = |
|
362 |
(if q = T then T |
|
363 |
else if q = F then f p |
|
364 |
else (let fp = f p in case fp of T \<Rightarrow> T | F \<Rightarrow> q | _ \<Rightarrow> Or (f p) q))" |
|
365 |
||
366 |
definition evaldjf :: "('a \<Rightarrow> fm) \<Rightarrow> 'a list \<Rightarrow> fm" |
|
367 |
where "evaldjf f ps = foldr (djf f) ps F" |
|
29789 | 368 |
|
369 |
lemma djf_Or: "Ifm bs (djf f p q) = Ifm bs (Or (f p) q)" |
|
60710 | 370 |
by (cases "q = T", simp add: djf_def, cases "q = F", simp add: djf_def) |
371 |
(cases "f p", simp_all add: Let_def djf_def) |
|
29789 | 372 |
|
373 |
||
374 |
lemma djf_simps: |
|
375 |
"djf f p T = T" |
|
376 |
"djf f p F = f p" |
|
60710 | 377 |
"q \<noteq> T \<Longrightarrow> q \<noteq> F \<Longrightarrow> djf f p q = (let fp = f p in case fp of T \<Rightarrow> T | F \<Rightarrow> q | _ \<Rightarrow> Or (f p) q)" |
29789 | 378 |
by (simp_all add: djf_def) |
379 |
||
60710 | 380 |
lemma evaldjf_ex: "Ifm bs (evaldjf f ps) \<longleftrightarrow> (\<exists>p \<in> set ps. Ifm bs (f p))" |
381 |
by (induct ps) (simp_all add: evaldjf_def djf_Or) |
|
29789 | 382 |
|
60710 | 383 |
lemma evaldjf_bound0: |
384 |
assumes nb: "\<forall>x\<in> set xs. bound0 (f x)" |
|
29789 | 385 |
shows "bound0 (evaldjf f xs)" |
60710 | 386 |
using nb by (induct xs, auto simp add: evaldjf_def djf_def Let_def) (case_tac "f a", auto) |
29789 | 387 |
|
60710 | 388 |
lemma evaldjf_qf: |
389 |
assumes nb: "\<forall>x\<in> set xs. qfree (f x)" |
|
29789 | 390 |
shows "qfree (evaldjf f xs)" |
60710 | 391 |
using nb by (induct xs, auto simp add: evaldjf_def djf_def Let_def) (case_tac "f a", auto) |
29789 | 392 |
|
60710 | 393 |
fun disjuncts :: "fm \<Rightarrow> fm list" |
394 |
where |
|
36853 | 395 |
"disjuncts (Or p q) = disjuncts p @ disjuncts q" |
396 |
| "disjuncts F = []" |
|
397 |
| "disjuncts p = [p]" |
|
29789 | 398 |
|
60710 | 399 |
lemma disjuncts: "(\<exists>q\<in> set (disjuncts p). Ifm bs q) = Ifm bs p" |
400 |
by (induct p rule: disjuncts.induct) auto |
|
29789 | 401 |
|
60710 | 402 |
lemma disjuncts_nb: "bound0 p \<Longrightarrow> \<forall>q\<in> set (disjuncts p). bound0 q" |
403 |
proof - |
|
29789 | 404 |
assume nb: "bound0 p" |
60710 | 405 |
then have "list_all bound0 (disjuncts p)" |
406 |
by (induct p rule: disjuncts.induct) auto |
|
407 |
then show ?thesis |
|
408 |
by (simp only: list_all_iff) |
|
29789 | 409 |
qed |
410 |
||
60710 | 411 |
lemma disjuncts_qf: "qfree p \<Longrightarrow> \<forall>q\<in> set (disjuncts p). qfree q" |
412 |
proof - |
|
29789 | 413 |
assume qf: "qfree p" |
60710 | 414 |
then have "list_all qfree (disjuncts p)" |
415 |
by (induct p rule: disjuncts.induct) auto |
|
416 |
then show ?thesis |
|
417 |
by (simp only: list_all_iff) |
|
29789 | 418 |
qed |
419 |
||
60710 | 420 |
definition DJ :: "(fm \<Rightarrow> fm) \<Rightarrow> fm \<Rightarrow> fm" |
421 |
where "DJ f p = evaldjf f (disjuncts p)" |
|
29789 | 422 |
|
60710 | 423 |
lemma DJ: |
424 |
assumes fdj: "\<forall>p q. Ifm bs (f (Or p q)) = Ifm bs (Or (f p) (f q))" |
|
425 |
and fF: "f F = F" |
|
29789 | 426 |
shows "Ifm bs (DJ f p) = Ifm bs (f p)" |
60710 | 427 |
proof - |
428 |
have "Ifm bs (DJ f p) = (\<exists>q \<in> set (disjuncts p). Ifm bs (f q))" |
|
429 |
by (simp add: DJ_def evaldjf_ex) |
|
430 |
also have "\<dots> = Ifm bs (f p)" |
|
431 |
using fdj fF by (induct p rule: disjuncts.induct) auto |
|
29789 | 432 |
finally show ?thesis . |
433 |
qed |
|
434 |
||
60710 | 435 |
lemma DJ_qf: |
436 |
assumes fqf: "\<forall>p. qfree p \<longrightarrow> qfree (f p)" |
|
29789 | 437 |
shows "\<forall>p. qfree p \<longrightarrow> qfree (DJ f p) " |
60710 | 438 |
proof clarify |
439 |
fix p |
|
440 |
assume qf: "qfree p" |
|
441 |
have th: "DJ f p = evaldjf f (disjuncts p)" |
|
442 |
by (simp add: DJ_def) |
|
443 |
from disjuncts_qf[OF qf] have "\<forall>q\<in> set (disjuncts p). qfree q" . |
|
444 |
with fqf have th':"\<forall>q\<in> set (disjuncts p). qfree (f q)" |
|
445 |
by blast |
|
446 |
from evaldjf_qf[OF th'] th show "qfree (DJ f p)" |
|
447 |
by simp |
|
29789 | 448 |
qed |
449 |
||
60710 | 450 |
lemma DJ_qe: |
451 |
assumes qe: "\<forall>bs p. qfree p \<longrightarrow> qfree (qe p) \<and> (Ifm bs (qe p) = Ifm bs (E p))" |
|
452 |
shows "\<forall>bs p. qfree p \<longrightarrow> qfree (DJ qe p) \<and> (Ifm bs ((DJ qe p)) = Ifm bs (E p))" |
|
453 |
proof clarify |
|
454 |
fix p :: fm |
|
455 |
fix bs |
|
29789 | 456 |
assume qf: "qfree p" |
60710 | 457 |
from qe have qth: "\<forall>p. qfree p \<longrightarrow> qfree (qe p)" |
458 |
by blast |
|
459 |
from DJ_qf[OF qth] qf have qfth: "qfree (DJ qe p)" |
|
460 |
by auto |
|
461 |
have "Ifm bs (DJ qe p) \<longleftrightarrow> (\<exists>q\<in> set (disjuncts p). Ifm bs (qe q))" |
|
29789 | 462 |
by (simp add: DJ_def evaldjf_ex) |
60710 | 463 |
also have "\<dots> \<longleftrightarrow> (\<exists>q \<in> set(disjuncts p). Ifm bs (E q))" |
464 |
using qe disjuncts_qf[OF qf] by auto |
|
465 |
also have "\<dots> = Ifm bs (E p)" |
|
466 |
by (induct p rule: disjuncts.induct) auto |
|
467 |
finally show "qfree (DJ qe p) \<and> Ifm bs (DJ qe p) = Ifm bs (E p)" |
|
468 |
using qfth by blast |
|
29789 | 469 |
qed |
60710 | 470 |
|
29789 | 471 |
(* Simplification *) |
36853 | 472 |
|
60710 | 473 |
fun maxcoeff:: "num \<Rightarrow> int" |
474 |
where |
|
61945 | 475 |
"maxcoeff (C i) = \<bar>i\<bar>" |
476 |
| "maxcoeff (CN n c t) = max \<bar>c\<bar> (maxcoeff t)" |
|
36853 | 477 |
| "maxcoeff t = 1" |
29789 | 478 |
|
479 |
lemma maxcoeff_pos: "maxcoeff t \<ge> 0" |
|
480 |
by (induct t rule: maxcoeff.induct, auto) |
|
481 |
||
60710 | 482 |
fun numgcdh:: "num \<Rightarrow> int \<Rightarrow> int" |
483 |
where |
|
31706 | 484 |
"numgcdh (C i) = (\<lambda>g. gcd i g)" |
36853 | 485 |
| "numgcdh (CN n c t) = (\<lambda>g. gcd c (numgcdh t g))" |
486 |
| "numgcdh t = (\<lambda>g. 1)" |
|
487 |
||
60710 | 488 |
definition numgcd :: "num \<Rightarrow> int" |
489 |
where "numgcd t = numgcdh t (maxcoeff t)" |
|
29789 | 490 |
|
60710 | 491 |
fun reducecoeffh:: "num \<Rightarrow> int \<Rightarrow> num" |
492 |
where |
|
493 |
"reducecoeffh (C i) = (\<lambda>g. C (i div g))" |
|
494 |
| "reducecoeffh (CN n c t) = (\<lambda>g. CN n (c div g) (reducecoeffh t g))" |
|
36853 | 495 |
| "reducecoeffh t = (\<lambda>g. t)" |
29789 | 496 |
|
60710 | 497 |
definition reducecoeff :: "num \<Rightarrow> num" |
498 |
where |
|
36853 | 499 |
"reducecoeff t = |
60710 | 500 |
(let g = numgcd t |
501 |
in if g = 0 then C 0 else if g = 1 then t else reducecoeffh t g)" |
|
29789 | 502 |
|
60710 | 503 |
fun dvdnumcoeff:: "num \<Rightarrow> int \<Rightarrow> bool" |
504 |
where |
|
505 |
"dvdnumcoeff (C i) = (\<lambda>g. g dvd i)" |
|
506 |
| "dvdnumcoeff (CN n c t) = (\<lambda>g. g dvd c \<and> dvdnumcoeff t g)" |
|
36853 | 507 |
| "dvdnumcoeff t = (\<lambda>g. False)" |
29789 | 508 |
|
60710 | 509 |
lemma dvdnumcoeff_trans: |
510 |
assumes gdg: "g dvd g'" |
|
511 |
and dgt':"dvdnumcoeff t g'" |
|
29789 | 512 |
shows "dvdnumcoeff t g" |
60710 | 513 |
using dgt' gdg |
514 |
by (induct t rule: dvdnumcoeff.induct) (simp_all add: gdg dvd_trans[OF gdg]) |
|
29789 | 515 |
|
30042 | 516 |
declare dvd_trans [trans add] |
29789 | 517 |
|
61945 | 518 |
lemma natabs0: "nat \<bar>x\<bar> = 0 \<longleftrightarrow> x = 0" |
60710 | 519 |
by arith |
29789 | 520 |
|
521 |
lemma numgcd0: |
|
522 |
assumes g0: "numgcd t = 0" |
|
523 |
shows "Inum bs t = 0" |
|
60710 | 524 |
using g0[simplified numgcd_def] |
525 |
by (induct t rule: numgcdh.induct) (auto simp add: natabs0 maxcoeff_pos max.absorb2) |
|
29789 | 526 |
|
60710 | 527 |
lemma numgcdh_pos: |
528 |
assumes gp: "g \<ge> 0" |
|
529 |
shows "numgcdh t g \<ge> 0" |
|
530 |
using gp by (induct t rule: numgcdh.induct) auto |
|
29789 | 531 |
|
532 |
lemma numgcd_pos: "numgcd t \<ge>0" |
|
533 |
by (simp add: numgcd_def numgcdh_pos maxcoeff_pos) |
|
534 |
||
535 |
lemma reducecoeffh: |
|
60710 | 536 |
assumes gt: "dvdnumcoeff t g" |
537 |
and gp: "g > 0" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
538 |
shows "real_of_int g *(Inum bs (reducecoeffh t g)) = Inum bs t" |
29789 | 539 |
using gt |
60710 | 540 |
proof (induct t rule: reducecoeffh.induct) |
41807 | 541 |
case (1 i) |
60710 | 542 |
then have gd: "g dvd i" |
543 |
by simp |
|
544 |
with assms show ?case |
|
545 |
by (simp add: real_of_int_div[OF gd]) |
|
29789 | 546 |
next |
41807 | 547 |
case (2 n c t) |
60710 | 548 |
then have gd: "g dvd c" |
549 |
by simp |
|
550 |
from assms 2 show ?case |
|
551 |
by (simp add: real_of_int_div[OF gd] algebra_simps) |
|
29789 | 552 |
qed (auto simp add: numgcd_def gp) |
36853 | 553 |
|
60710 | 554 |
fun ismaxcoeff:: "num \<Rightarrow> int \<Rightarrow> bool" |
555 |
where |
|
61945 | 556 |
"ismaxcoeff (C i) = (\<lambda>x. \<bar>i\<bar> \<le> x)" |
557 |
| "ismaxcoeff (CN n c t) = (\<lambda>x. \<bar>c\<bar> \<le> x \<and> ismaxcoeff t x)" |
|
36853 | 558 |
| "ismaxcoeff t = (\<lambda>x. True)" |
29789 | 559 |
|
560 |
lemma ismaxcoeff_mono: "ismaxcoeff t c \<Longrightarrow> c \<le> c' \<Longrightarrow> ismaxcoeff t c'" |
|
41807 | 561 |
by (induct t rule: ismaxcoeff.induct) auto |
29789 | 562 |
|
563 |
lemma maxcoeff_ismaxcoeff: "ismaxcoeff t (maxcoeff t)" |
|
564 |
proof (induct t rule: maxcoeff.induct) |
|
565 |
case (2 n c t) |
|
60710 | 566 |
then have H:"ismaxcoeff t (maxcoeff t)" . |
61945 | 567 |
have thh: "maxcoeff t \<le> max \<bar>c\<bar> (maxcoeff t)" |
60710 | 568 |
by simp |
569 |
from ismaxcoeff_mono[OF H thh] show ?case |
|
570 |
by simp |
|
29789 | 571 |
qed simp_all |
572 |
||
67118 | 573 |
lemma zgcd_gt1: |
574 |
"\<bar>i\<bar> > 1 \<and> \<bar>j\<bar> > 1 \<or> \<bar>i\<bar> = 0 \<and> \<bar>j\<bar> > 1 \<or> \<bar>i\<bar> > 1 \<and> \<bar>j\<bar> = 0" |
|
575 |
if "gcd i j > 1" for i j :: int |
|
576 |
proof - |
|
577 |
have "\<bar>k\<bar> \<le> 1 \<longleftrightarrow> k = - 1 \<or> k = 0 \<or> k = 1" for k :: int |
|
578 |
by auto |
|
579 |
with that show ?thesis |
|
580 |
by (auto simp add: not_less) |
|
581 |
qed |
|
60710 | 582 |
|
29789 | 583 |
lemma numgcdh0:"numgcdh t m = 0 \<Longrightarrow> m =0" |
60710 | 584 |
by (induct t rule: numgcdh.induct) auto |
29789 | 585 |
|
586 |
lemma dvdnumcoeff_aux: |
|
60710 | 587 |
assumes "ismaxcoeff t m" |
588 |
and mp: "m \<ge> 0" |
|
589 |
and "numgcdh t m > 1" |
|
29789 | 590 |
shows "dvdnumcoeff t (numgcdh t m)" |
60710 | 591 |
using assms |
592 |
proof (induct t rule: numgcdh.induct) |
|
593 |
case (2 n c t) |
|
29789 | 594 |
let ?g = "numgcdh t m" |
60710 | 595 |
from 2 have th: "gcd c ?g > 1" |
596 |
by simp |
|
29789 | 597 |
from zgcd_gt1[OF th] numgcdh_pos[OF mp, where t="t"] |
61945 | 598 |
consider "\<bar>c\<bar> > 1" "?g > 1" | "\<bar>c\<bar> = 0" "?g > 1" | "?g = 0" |
60710 | 599 |
by auto |
600 |
then show ?case |
|
601 |
proof cases |
|
602 |
case 1 |
|
603 |
with 2 have th: "dvdnumcoeff t ?g" |
|
604 |
by simp |
|
605 |
have th': "gcd c ?g dvd ?g" |
|
606 |
by simp |
|
607 |
from dvdnumcoeff_trans[OF th' th] show ?thesis |
|
608 |
by simp |
|
609 |
next |
|
610 |
case "2'": 2 |
|
611 |
with 2 have th: "dvdnumcoeff t ?g" |
|
612 |
by simp |
|
613 |
have th': "gcd c ?g dvd ?g" |
|
614 |
by simp |
|
615 |
from dvdnumcoeff_trans[OF th' th] show ?thesis |
|
616 |
by simp |
|
617 |
next |
|
618 |
case 3 |
|
619 |
then have "m = 0" by (rule numgcdh0) |
|
620 |
with 2 3 show ?thesis by simp |
|
621 |
qed |
|
31706 | 622 |
qed auto |
29789 | 623 |
|
624 |
lemma dvdnumcoeff_aux2: |
|
41807 | 625 |
assumes "numgcd t > 1" |
626 |
shows "dvdnumcoeff t (numgcd t) \<and> numgcd t > 0" |
|
627 |
using assms |
|
29789 | 628 |
proof (simp add: numgcd_def) |
629 |
let ?mc = "maxcoeff t" |
|
630 |
let ?g = "numgcdh t ?mc" |
|
60710 | 631 |
have th1: "ismaxcoeff t ?mc" |
632 |
by (rule maxcoeff_ismaxcoeff) |
|
633 |
have th2: "?mc \<ge> 0" |
|
634 |
by (rule maxcoeff_pos) |
|
29789 | 635 |
assume H: "numgcdh t ?mc > 1" |
60710 | 636 |
from dvdnumcoeff_aux[OF th1 th2 H] show "dvdnumcoeff t ?g" . |
29789 | 637 |
qed |
638 |
||
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
639 |
lemma reducecoeff: "real_of_int (numgcd t) * (Inum bs (reducecoeff t)) = Inum bs t" |
60710 | 640 |
proof - |
29789 | 641 |
let ?g = "numgcd t" |
60710 | 642 |
have "?g \<ge> 0" |
643 |
by (simp add: numgcd_pos) |
|
644 |
then consider "?g = 0" | "?g = 1" | "?g > 1" by atomize_elim auto |
|
645 |
then show ?thesis |
|
646 |
proof cases |
|
647 |
case 1 |
|
648 |
then show ?thesis by (simp add: numgcd0) |
|
649 |
next |
|
650 |
case 2 |
|
651 |
then show ?thesis by (simp add: reducecoeff_def) |
|
652 |
next |
|
653 |
case g1: 3 |
|
654 |
from dvdnumcoeff_aux2[OF g1] have th1: "dvdnumcoeff t ?g" and g0: "?g > 0" |
|
655 |
by blast+ |
|
656 |
from reducecoeffh[OF th1 g0, where bs="bs"] g1 show ?thesis |
|
657 |
by (simp add: reducecoeff_def Let_def) |
|
658 |
qed |
|
29789 | 659 |
qed |
660 |
||
661 |
lemma reducecoeffh_numbound0: "numbound0 t \<Longrightarrow> numbound0 (reducecoeffh t g)" |
|
60710 | 662 |
by (induct t rule: reducecoeffh.induct) auto |
29789 | 663 |
|
664 |
lemma reducecoeff_numbound0: "numbound0 t \<Longrightarrow> numbound0 (reducecoeff t)" |
|
60710 | 665 |
using reducecoeffh_numbound0 by (simp add: reducecoeff_def Let_def) |
29789 | 666 |
|
66809 | 667 |
fun numadd:: "num \<Rightarrow> num \<Rightarrow> num" |
668 |
where |
|
669 |
"numadd (CN n1 c1 r1) (CN n2 c2 r2) = |
|
60710 | 670 |
(if n1 = n2 then |
671 |
(let c = c1 + c2 |
|
66809 | 672 |
in (if c = 0 then numadd r1 r2 else CN n1 c (numadd r1 r2))) |
673 |
else if n1 \<le> n2 then (CN n1 c1 (numadd r1 (CN n2 c2 r2))) |
|
674 |
else (CN n2 c2 (numadd (CN n1 c1 r1) r2)))" |
|
675 |
| "numadd (CN n1 c1 r1) t = CN n1 c1 (numadd r1 t)" |
|
676 |
| "numadd t (CN n2 c2 r2) = CN n2 c2 (numadd t r2)" |
|
677 |
| "numadd (C b1) (C b2) = C (b1 + b2)" |
|
678 |
| "numadd a b = Add a b" |
|
29789 | 679 |
|
66809 | 680 |
lemma numadd [simp]: "Inum bs (numadd t s) = Inum bs (Add t s)" |
681 |
by (induct t s rule: numadd.induct) (simp_all add: Let_def algebra_simps add_eq_0_iff) |
|
29789 | 682 |
|
66809 | 683 |
lemma numadd_nb [simp]: "numbound0 t \<Longrightarrow> numbound0 s \<Longrightarrow> numbound0 (numadd t s)" |
684 |
by (induct t s rule: numadd.induct) (simp_all add: Let_def) |
|
29789 | 685 |
|
60710 | 686 |
fun nummul:: "num \<Rightarrow> int \<Rightarrow> num" |
687 |
where |
|
688 |
"nummul (C j) = (\<lambda>i. C (i * j))" |
|
689 |
| "nummul (CN n c a) = (\<lambda>i. CN n (i * c) (nummul a i))" |
|
690 |
| "nummul t = (\<lambda>i. Mul i t)" |
|
29789 | 691 |
|
60710 | 692 |
lemma nummul[simp]: "\<And>i. Inum bs (nummul t i) = Inum bs (Mul i t)" |
693 |
by (induct t rule: nummul.induct) (auto simp add: algebra_simps) |
|
29789 | 694 |
|
60710 | 695 |
lemma nummul_nb[simp]: "\<And>i. numbound0 t \<Longrightarrow> numbound0 (nummul t i)" |
696 |
by (induct t rule: nummul.induct) auto |
|
29789 | 697 |
|
60710 | 698 |
definition numneg :: "num \<Rightarrow> num" |
699 |
where "numneg t = nummul t (- 1)" |
|
29789 | 700 |
|
60710 | 701 |
definition numsub :: "num \<Rightarrow> num \<Rightarrow> num" |
66809 | 702 |
where "numsub s t = (if s = t then C 0 else numadd s (numneg t))" |
29789 | 703 |
|
704 |
lemma numneg[simp]: "Inum bs (numneg t) = Inum bs (Neg t)" |
|
60710 | 705 |
using numneg_def by simp |
29789 | 706 |
|
707 |
lemma numneg_nb[simp]: "numbound0 t \<Longrightarrow> numbound0 (numneg t)" |
|
60710 | 708 |
using numneg_def by simp |
29789 | 709 |
|
710 |
lemma numsub[simp]: "Inum bs (numsub a b) = Inum bs (Sub a b)" |
|
60710 | 711 |
using numsub_def by simp |
29789 | 712 |
|
713 |
lemma numsub_nb[simp]: "\<lbrakk> numbound0 t ; numbound0 s\<rbrakk> \<Longrightarrow> numbound0 (numsub t s)" |
|
60710 | 714 |
using numsub_def by simp |
29789 | 715 |
|
60710 | 716 |
primrec simpnum:: "num \<Rightarrow> num" |
717 |
where |
|
29789 | 718 |
"simpnum (C j) = C j" |
36853 | 719 |
| "simpnum (Bound n) = CN n 1 (C 0)" |
720 |
| "simpnum (Neg t) = numneg (simpnum t)" |
|
66809 | 721 |
| "simpnum (Add t s) = numadd (simpnum t) (simpnum s)" |
36853 | 722 |
| "simpnum (Sub t s) = numsub (simpnum t) (simpnum s)" |
60710 | 723 |
| "simpnum (Mul i t) = (if i = 0 then C 0 else nummul (simpnum t) i)" |
66809 | 724 |
| "simpnum (CN n c t) = (if c = 0 then simpnum t else numadd (CN n c (C 0)) (simpnum t))" |
29789 | 725 |
|
726 |
lemma simpnum_ci[simp]: "Inum bs (simpnum t) = Inum bs t" |
|
60710 | 727 |
by (induct t) simp_all |
728 |
||
729 |
lemma simpnum_numbound0[simp]: "numbound0 t \<Longrightarrow> numbound0 (simpnum t)" |
|
730 |
by (induct t) simp_all |
|
29789 | 731 |
|
60710 | 732 |
fun nozerocoeff:: "num \<Rightarrow> bool" |
733 |
where |
|
29789 | 734 |
"nozerocoeff (C c) = True" |
60710 | 735 |
| "nozerocoeff (CN n c t) = (c \<noteq> 0 \<and> nozerocoeff t)" |
36853 | 736 |
| "nozerocoeff t = True" |
29789 | 737 |
|
66809 | 738 |
lemma numadd_nz : "nozerocoeff a \<Longrightarrow> nozerocoeff b \<Longrightarrow> nozerocoeff (numadd a b)" |
739 |
by (induct a b rule: numadd.induct) (simp_all add: Let_def) |
|
29789 | 740 |
|
60710 | 741 |
lemma nummul_nz : "\<And>i. i\<noteq>0 \<Longrightarrow> nozerocoeff a \<Longrightarrow> nozerocoeff (nummul a i)" |
742 |
by (induct a rule: nummul.induct) (auto simp add: Let_def numadd_nz) |
|
29789 | 743 |
|
744 |
lemma numneg_nz : "nozerocoeff a \<Longrightarrow> nozerocoeff (numneg a)" |
|
60710 | 745 |
by (simp add: numneg_def nummul_nz) |
29789 | 746 |
|
747 |
lemma numsub_nz: "nozerocoeff a \<Longrightarrow> nozerocoeff b \<Longrightarrow> nozerocoeff (numsub a b)" |
|
60710 | 748 |
by (simp add: numsub_def numneg_nz numadd_nz) |
29789 | 749 |
|
750 |
lemma simpnum_nz: "nozerocoeff (simpnum t)" |
|
60710 | 751 |
by (induct t) (simp_all add: numadd_nz numneg_nz numsub_nz nummul_nz) |
29789 | 752 |
|
753 |
lemma maxcoeff_nz: "nozerocoeff t \<Longrightarrow> maxcoeff t = 0 \<Longrightarrow> t = C 0" |
|
73869 | 754 |
by (induction t rule: maxcoeff.induct) auto |
29789 | 755 |
|
60710 | 756 |
lemma numgcd_nz: |
757 |
assumes nz: "nozerocoeff t" |
|
758 |
and g0: "numgcd t = 0" |
|
759 |
shows "t = C 0" |
|
760 |
proof - |
|
761 |
from g0 have th:"numgcdh t (maxcoeff t) = 0" |
|
762 |
by (simp add: numgcd_def) |
|
763 |
from numgcdh0[OF th] have th:"maxcoeff t = 0" . |
|
29789 | 764 |
from maxcoeff_nz[OF nz th] show ?thesis . |
765 |
qed |
|
766 |
||
60710 | 767 |
definition simp_num_pair :: "(num \<times> int) \<Rightarrow> num \<times> int" |
768 |
where |
|
769 |
"simp_num_pair = |
|
770 |
(\<lambda>(t,n). |
|
771 |
(if n = 0 then (C 0, 0) |
|
772 |
else |
|
773 |
(let t' = simpnum t ; g = numgcd t' in |
|
774 |
if g > 1 then |
|
775 |
(let g' = gcd n g |
|
776 |
in if g' = 1 then (t', n) else (reducecoeffh t' g', n div g')) |
|
777 |
else (t', n))))" |
|
29789 | 778 |
|
779 |
lemma simp_num_pair_ci: |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
780 |
shows "((\<lambda>(t,n). Inum bs t / real_of_int n) (simp_num_pair (t,n))) = |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
781 |
((\<lambda>(t,n). Inum bs t / real_of_int n) (t, n))" |
29789 | 782 |
(is "?lhs = ?rhs") |
60710 | 783 |
proof - |
29789 | 784 |
let ?t' = "simpnum t" |
785 |
let ?g = "numgcd ?t'" |
|
31706 | 786 |
let ?g' = "gcd n ?g" |
60710 | 787 |
show ?thesis |
788 |
proof (cases "n = 0") |
|
789 |
case True |
|
790 |
then show ?thesis |
|
791 |
by (simp add: Let_def simp_num_pair_def) |
|
792 |
next |
|
793 |
case nnz: False |
|
794 |
show ?thesis |
|
795 |
proof (cases "?g > 1") |
|
796 |
case False |
|
797 |
then show ?thesis by (simp add: Let_def simp_num_pair_def) |
|
798 |
next |
|
799 |
case g1: True |
|
800 |
then have g0: "?g > 0" |
|
801 |
by simp |
|
802 |
from g1 nnz have gp0: "?g' \<noteq> 0" |
|
803 |
by simp |
|
804 |
then have g'p: "?g' > 0" |
|
805 |
using gcd_ge_0_int[where x="n" and y="numgcd ?t'"] by arith |
|
806 |
then consider "?g' = 1" | "?g' > 1" by arith |
|
807 |
then show ?thesis |
|
808 |
proof cases |
|
809 |
case 1 |
|
810 |
then show ?thesis |
|
811 |
by (simp add: Let_def simp_num_pair_def) |
|
812 |
next |
|
813 |
case g'1: 2 |
|
814 |
from dvdnumcoeff_aux2[OF g1] have th1: "dvdnumcoeff ?t' ?g" .. |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
815 |
let ?tt = "reducecoeffh ?t' ?g'" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
816 |
let ?t = "Inum bs ?tt" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
817 |
have gpdg: "?g' dvd ?g" by simp |
60710 | 818 |
have gpdd: "?g' dvd n" by simp |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
819 |
have gpdgp: "?g' dvd ?g'" by simp |
60710 | 820 |
from reducecoeffh[OF dvdnumcoeff_trans[OF gpdg th1] g'p] |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
821 |
have th2:"real_of_int ?g' * ?t = Inum bs ?t'" |
60710 | 822 |
by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
823 |
from g1 g'1 have "?lhs = ?t / real_of_int (n div ?g')" |
60710 | 824 |
by (simp add: simp_num_pair_def Let_def) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
825 |
also have "\<dots> = (real_of_int ?g' * ?t) / (real_of_int ?g' * (real_of_int (n div ?g')))" |
60710 | 826 |
by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
827 |
also have "\<dots> = (Inum bs ?t' / real_of_int n)" |
46670 | 828 |
using real_of_int_div[OF gpdd] th2 gp0 by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
829 |
finally have "?lhs = Inum bs t / real_of_int n" |
60710 | 830 |
by simp |
831 |
then show ?thesis |
|
832 |
by (simp add: simp_num_pair_def) |
|
833 |
qed |
|
834 |
qed |
|
835 |
qed |
|
29789 | 836 |
qed |
837 |
||
60710 | 838 |
lemma simp_num_pair_l: |
839 |
assumes tnb: "numbound0 t" |
|
840 |
and np: "n > 0" |
|
841 |
and tn: "simp_num_pair (t, n) = (t', n')" |
|
842 |
shows "numbound0 t' \<and> n' > 0" |
|
843 |
proof - |
|
41807 | 844 |
let ?t' = "simpnum t" |
29789 | 845 |
let ?g = "numgcd ?t'" |
31706 | 846 |
let ?g' = "gcd n ?g" |
60710 | 847 |
show ?thesis |
848 |
proof (cases "n = 0") |
|
849 |
case True |
|
850 |
then show ?thesis |
|
851 |
using assms by (simp add: Let_def simp_num_pair_def) |
|
852 |
next |
|
853 |
case nnz: False |
|
854 |
show ?thesis |
|
855 |
proof (cases "?g > 1") |
|
856 |
case False |
|
857 |
then show ?thesis |
|
66809 | 858 |
using assms by (auto simp add: Let_def simp_num_pair_def) |
60710 | 859 |
next |
860 |
case g1: True |
|
861 |
then have g0: "?g > 0" by simp |
|
31706 | 862 |
from g1 nnz have gp0: "?g' \<noteq> 0" by simp |
60710 | 863 |
then have g'p: "?g' > 0" using gcd_ge_0_int[where x="n" and y="numgcd ?t'"] |
864 |
by arith |
|
865 |
then consider "?g'= 1" | "?g' > 1" by arith |
|
866 |
then show ?thesis |
|
867 |
proof cases |
|
868 |
case 1 |
|
869 |
then show ?thesis |
|
66809 | 870 |
using assms g1 by (auto simp add: Let_def simp_num_pair_def) |
60710 | 871 |
next |
872 |
case g'1: 2 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
873 |
have gpdg: "?g' dvd ?g" by simp |
41807 | 874 |
have gpdd: "?g' dvd n" by simp |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
875 |
have gpdgp: "?g' dvd ?g'" by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
876 |
from zdvd_imp_le[OF gpdd np] have g'n: "?g' \<le> n" . |
60710 | 877 |
from zdiv_mono1[OF g'n g'p, simplified div_self[OF gp0]] have "n div ?g' > 0" |
878 |
by simp |
|
879 |
then show ?thesis |
|
880 |
using assms g1 g'1 |
|
66809 | 881 |
by (auto simp add: simp_num_pair_def Let_def reducecoeffh_numbound0) |
60710 | 882 |
qed |
883 |
qed |
|
884 |
qed |
|
29789 | 885 |
qed |
886 |
||
60710 | 887 |
fun simpfm :: "fm \<Rightarrow> fm" |
888 |
where |
|
29789 | 889 |
"simpfm (And p q) = conj (simpfm p) (simpfm q)" |
36853 | 890 |
| "simpfm (Or p q) = disj (simpfm p) (simpfm q)" |
891 |
| "simpfm (Imp p q) = imp (simpfm p) (simpfm q)" |
|
892 |
| "simpfm (Iff p q) = iff (simpfm p) (simpfm q)" |
|
74101 | 893 |
| "simpfm (Not p) = not (simpfm p)" |
60710 | 894 |
| "simpfm (Lt a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v < 0) then T else F | _ \<Rightarrow> Lt a')" |
36853 | 895 |
| "simpfm (Le a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v \<le> 0) then T else F | _ \<Rightarrow> Le a')" |
896 |
| "simpfm (Gt a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v > 0) then T else F | _ \<Rightarrow> Gt a')" |
|
897 |
| "simpfm (Ge a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v \<ge> 0) then T else F | _ \<Rightarrow> Ge a')" |
|
898 |
| "simpfm (Eq a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v = 0) then T else F | _ \<Rightarrow> Eq a')" |
|
899 |
| "simpfm (NEq a) = (let a' = simpnum a in case a' of C v \<Rightarrow> if (v \<noteq> 0) then T else F | _ \<Rightarrow> NEq a')" |
|
900 |
| "simpfm p = p" |
|
60710 | 901 |
|
29789 | 902 |
lemma simpfm: "Ifm bs (simpfm p) = Ifm bs p" |
60710 | 903 |
proof (induct p rule: simpfm.induct) |
904 |
case (6 a) |
|
905 |
let ?sa = "simpnum a" |
|
906 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
907 |
by simp |
|
908 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
909 |
then show ?case |
|
910 |
proof cases |
|
911 |
case 1 |
|
912 |
then show ?thesis using sa by simp |
|
913 |
next |
|
914 |
case 2 |
|
915 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
916 |
qed |
|
29789 | 917 |
next |
60710 | 918 |
case (7 a) |
919 |
let ?sa = "simpnum a" |
|
920 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
921 |
by simp |
|
922 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
923 |
then show ?case |
|
924 |
proof cases |
|
925 |
case 1 |
|
926 |
then show ?thesis using sa by simp |
|
927 |
next |
|
928 |
case 2 |
|
929 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
930 |
qed |
|
29789 | 931 |
next |
60710 | 932 |
case (8 a) |
933 |
let ?sa = "simpnum a" |
|
934 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
935 |
by simp |
|
936 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
937 |
then show ?case |
|
938 |
proof cases |
|
939 |
case 1 |
|
940 |
then show ?thesis using sa by simp |
|
941 |
next |
|
942 |
case 2 |
|
943 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
944 |
qed |
|
29789 | 945 |
next |
60710 | 946 |
case (9 a) |
947 |
let ?sa = "simpnum a" |
|
948 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
949 |
by simp |
|
950 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
951 |
then show ?case |
|
952 |
proof cases |
|
953 |
case 1 |
|
954 |
then show ?thesis using sa by simp |
|
955 |
next |
|
956 |
case 2 |
|
957 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
958 |
qed |
|
29789 | 959 |
next |
60710 | 960 |
case (10 a) |
961 |
let ?sa = "simpnum a" |
|
962 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
963 |
by simp |
|
964 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
965 |
then show ?case |
|
966 |
proof cases |
|
967 |
case 1 |
|
968 |
then show ?thesis using sa by simp |
|
969 |
next |
|
970 |
case 2 |
|
971 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
972 |
qed |
|
29789 | 973 |
next |
60710 | 974 |
case (11 a) |
975 |
let ?sa = "simpnum a" |
|
976 |
from simpnum_ci have sa: "Inum bs ?sa = Inum bs a" |
|
977 |
by simp |
|
978 |
consider v where "?sa = C v" | "\<not> (\<exists>v. ?sa = C v)" by blast |
|
979 |
then show ?case |
|
980 |
proof cases |
|
981 |
case 1 |
|
982 |
then show ?thesis using sa by simp |
|
983 |
next |
|
984 |
case 2 |
|
985 |
then show ?thesis using sa by (cases ?sa) (simp_all add: Let_def) |
|
986 |
qed |
|
66809 | 987 |
qed (induct p rule: simpfm.induct, simp_all) |
29789 | 988 |
|
989 |
||
990 |
lemma simpfm_bound0: "bound0 p \<Longrightarrow> bound0 (simpfm p)" |
|
60710 | 991 |
proof (induct p rule: simpfm.induct) |
992 |
case (6 a) |
|
993 |
then have nb: "numbound0 a" by simp |
|
994 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
995 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
29789 | 996 |
next |
60710 | 997 |
case (7 a) |
998 |
then have nb: "numbound0 a" by simp |
|
999 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
1000 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
29789 | 1001 |
next |
60710 | 1002 |
case (8 a) |
1003 |
then have nb: "numbound0 a" by simp |
|
1004 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
1005 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
29789 | 1006 |
next |
60710 | 1007 |
case (9 a) |
1008 |
then have nb: "numbound0 a" by simp |
|
1009 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
1010 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
29789 | 1011 |
next |
60710 | 1012 |
case (10 a) |
1013 |
then have nb: "numbound0 a" by simp |
|
1014 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
1015 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
29789 | 1016 |
next |
60710 | 1017 |
case (11 a) |
1018 |
then have nb: "numbound0 a" by simp |
|
1019 |
then have "numbound0 (simpnum a)" by (simp only: simpnum_numbound0[OF nb]) |
|
1020 |
then show ?case by (cases "simpnum a") (auto simp add: Let_def) |
|
66809 | 1021 |
qed (auto simp add: disj_def imp_def iff_def conj_def) |
29789 | 1022 |
|
1023 |
lemma simpfm_qf: "qfree p \<Longrightarrow> qfree (simpfm p)" |
|
44779 | 1024 |
apply (induct p rule: simpfm.induct) |
1025 |
apply (auto simp add: Let_def) |
|
1026 |
apply (case_tac "simpnum a", auto)+ |
|
1027 |
done |
|
29789 | 1028 |
|
66809 | 1029 |
fun prep :: "fm \<Rightarrow> fm" |
1030 |
where |
|
29789 | 1031 |
"prep (E T) = T" |
66809 | 1032 |
| "prep (E F) = F" |
1033 |
| "prep (E (Or p q)) = disj (prep (E p)) (prep (E q))" |
|
74101 | 1034 |
| "prep (E (Imp p q)) = disj (prep (E (Not p))) (prep (E q))" |
1035 |
| "prep (E (Iff p q)) = disj (prep (E (And p q))) (prep (E (And (Not p) (Not q))))" |
|
1036 |
| "prep (E (Not (And p q))) = disj (prep (E (Not p))) (prep (E(Not q)))" |
|
1037 |
| "prep (E (Not (Imp p q))) = prep (E (And p (Not q)))" |
|
1038 |
| "prep (E (Not (Iff p q))) = disj (prep (E (And p (Not q)))) (prep (E(And (Not p) q)))" |
|
66809 | 1039 |
| "prep (E p) = E (prep p)" |
1040 |
| "prep (A (And p q)) = conj (prep (A p)) (prep (A q))" |
|
74101 | 1041 |
| "prep (A p) = prep (Not (E (Not p)))" |
1042 |
| "prep (Not (Not p)) = prep p" |
|
1043 |
| "prep (Not (And p q)) = disj (prep (Not p)) (prep (Not q))" |
|
1044 |
| "prep (Not (A p)) = prep (E (Not p))" |
|
1045 |
| "prep (Not (Or p q)) = conj (prep (Not p)) (prep (Not q))" |
|
1046 |
| "prep (Not (Imp p q)) = conj (prep p) (prep (Not q))" |
|
1047 |
| "prep (Not (Iff p q)) = disj (prep (And p (Not q))) (prep (And (Not p) q))" |
|
1048 |
| "prep (Not p) = not (prep p)" |
|
66809 | 1049 |
| "prep (Or p q) = disj (prep p) (prep q)" |
1050 |
| "prep (And p q) = conj (prep p) (prep q)" |
|
74101 | 1051 |
| "prep (Imp p q) = prep (Or (Not p) q)" |
1052 |
| "prep (Iff p q) = disj (prep (And p q)) (prep (And (Not p) (Not q)))" |
|
66809 | 1053 |
| "prep p = p" |
60710 | 1054 |
|
1055 |
lemma prep: "\<And>bs. Ifm bs (prep p) = Ifm bs p" |
|
44779 | 1056 |
by (induct p rule: prep.induct) auto |
29789 | 1057 |
|
1058 |
(* Generic quantifier elimination *) |
|
66809 | 1059 |
fun qelim :: "fm \<Rightarrow> (fm \<Rightarrow> fm) \<Rightarrow> fm" |
60710 | 1060 |
where |
1061 |
"qelim (E p) = (\<lambda>qe. DJ qe (qelim p qe))" |
|
74101 | 1062 |
| "qelim (A p) = (\<lambda>qe. not (qe ((qelim (Not p) qe))))" |
1063 |
| "qelim (Not p) = (\<lambda>qe. not (qelim p qe))" |
|
60710 | 1064 |
| "qelim (And p q) = (\<lambda>qe. conj (qelim p qe) (qelim q qe))" |
1065 |
| "qelim (Or p q) = (\<lambda>qe. disj (qelim p qe) (qelim q qe))" |
|
1066 |
| "qelim (Imp p q) = (\<lambda>qe. imp (qelim p qe) (qelim q qe))" |
|
1067 |
| "qelim (Iff p q) = (\<lambda>qe. iff (qelim p qe) (qelim q qe))" |
|
1068 |
| "qelim p = (\<lambda>y. simpfm p)" |
|
29789 | 1069 |
|
1070 |
lemma qelim_ci: |
|
60710 | 1071 |
assumes qe_inv: "\<forall>bs p. qfree p \<longrightarrow> qfree (qe p) \<and> (Ifm bs (qe p) = Ifm bs (E p))" |
1072 |
shows "\<And>bs. qfree (qelim p qe) \<and> (Ifm bs (qelim p qe) = Ifm bs p)" |
|
1073 |
using qe_inv DJ_qe[OF qe_inv] |
|
1074 |
by (induct p rule: qelim.induct) |
|
66809 | 1075 |
(auto simp add: simpfm simpfm_qf simp del: simpfm.simps) |
29789 | 1076 |
|
60710 | 1077 |
fun minusinf:: "fm \<Rightarrow> fm" (* Virtual substitution of -\<infinity>*) |
1078 |
where |
|
1079 |
"minusinf (And p q) = conj (minusinf p) (minusinf q)" |
|
1080 |
| "minusinf (Or p q) = disj (minusinf p) (minusinf q)" |
|
36853 | 1081 |
| "minusinf (Eq (CN 0 c e)) = F" |
1082 |
| "minusinf (NEq (CN 0 c e)) = T" |
|
1083 |
| "minusinf (Lt (CN 0 c e)) = T" |
|
1084 |
| "minusinf (Le (CN 0 c e)) = T" |
|
1085 |
| "minusinf (Gt (CN 0 c e)) = F" |
|
1086 |
| "minusinf (Ge (CN 0 c e)) = F" |
|
1087 |
| "minusinf p = p" |
|
29789 | 1088 |
|
60710 | 1089 |
fun plusinf:: "fm \<Rightarrow> fm" (* Virtual substitution of +\<infinity>*) |
1090 |
where |
|
1091 |
"plusinf (And p q) = conj (plusinf p) (plusinf q)" |
|
1092 |
| "plusinf (Or p q) = disj (plusinf p) (plusinf q)" |
|
36853 | 1093 |
| "plusinf (Eq (CN 0 c e)) = F" |
1094 |
| "plusinf (NEq (CN 0 c e)) = T" |
|
1095 |
| "plusinf (Lt (CN 0 c e)) = F" |
|
1096 |
| "plusinf (Le (CN 0 c e)) = F" |
|
1097 |
| "plusinf (Gt (CN 0 c e)) = T" |
|
1098 |
| "plusinf (Ge (CN 0 c e)) = T" |
|
1099 |
| "plusinf p = p" |
|
29789 | 1100 |
|
60710 | 1101 |
fun isrlfm :: "fm \<Rightarrow> bool" (* Linearity test for fm *) |
1102 |
where |
|
1103 |
"isrlfm (And p q) = (isrlfm p \<and> isrlfm q)" |
|
1104 |
| "isrlfm (Or p q) = (isrlfm p \<and> isrlfm q)" |
|
36853 | 1105 |
| "isrlfm (Eq (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
1106 |
| "isrlfm (NEq (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
|
1107 |
| "isrlfm (Lt (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
|
1108 |
| "isrlfm (Le (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
|
1109 |
| "isrlfm (Gt (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
|
1110 |
| "isrlfm (Ge (CN 0 c e)) = (c>0 \<and> numbound0 e)" |
|
1111 |
| "isrlfm p = (isatom p \<and> (bound0 p))" |
|
29789 | 1112 |
|
1113 |
(* splits the bounded from the unbounded part*) |
|
66809 | 1114 |
fun rsplit0 :: "num \<Rightarrow> int \<times> num" |
60710 | 1115 |
where |
29789 | 1116 |
"rsplit0 (Bound 0) = (1,C 0)" |
60710 | 1117 |
| "rsplit0 (Add a b) = (let (ca,ta) = rsplit0 a; (cb,tb) = rsplit0 b in (ca + cb, Add ta tb))" |
36853 | 1118 |
| "rsplit0 (Sub a b) = rsplit0 (Add a (Neg b))" |
60710 | 1119 |
| "rsplit0 (Neg a) = (let (c,t) = rsplit0 a in (- c, Neg t))" |
1120 |
| "rsplit0 (Mul c a) = (let (ca,ta) = rsplit0 a in (c * ca, Mul c ta))" |
|
1121 |
| "rsplit0 (CN 0 c a) = (let (ca,ta) = rsplit0 a in (c + ca, ta))" |
|
1122 |
| "rsplit0 (CN n c a) = (let (ca,ta) = rsplit0 a in (ca, CN n c ta))" |
|
36853 | 1123 |
| "rsplit0 t = (0,t)" |
1124 |
||
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1125 |
lemma rsplit0: "Inum bs ((case_prod (CN 0)) (rsplit0 t)) = Inum bs t \<and> numbound0 (snd (rsplit0 t))" |
29789 | 1126 |
proof (induct t rule: rsplit0.induct) |
60710 | 1127 |
case (2 a b) |
1128 |
let ?sa = "rsplit0 a" |
|
1129 |
let ?sb = "rsplit0 b" |
|
1130 |
let ?ca = "fst ?sa" |
|
1131 |
let ?cb = "fst ?sb" |
|
1132 |
let ?ta = "snd ?sa" |
|
1133 |
let ?tb = "snd ?sb" |
|
1134 |
from 2 have nb: "numbound0 (snd(rsplit0 (Add a b)))" |
|
36853 | 1135 |
by (cases "rsplit0 a") (auto simp add: Let_def split_def) |
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1136 |
have "Inum bs ((case_prod (CN 0)) (rsplit0 (Add a b))) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1137 |
Inum bs ((case_prod (CN 0)) ?sa)+Inum bs ((case_prod (CN 0)) ?sb)" |
29789 | 1138 |
by (simp add: Let_def split_def algebra_simps) |
60710 | 1139 |
also have "\<dots> = Inum bs a + Inum bs b" |
1140 |
using 2 by (cases "rsplit0 a") auto |
|
1141 |
finally show ?case |
|
1142 |
using nb by simp |
|
49962
a8cc904a6820
Renamed {left,right}_distrib to distrib_{right,left}.
webertj
parents:
49070
diff
changeset
|
1143 |
qed (auto simp add: Let_def split_def algebra_simps, simp add: distrib_left[symmetric]) |
29789 | 1144 |
|
1145 |
(* Linearize a formula*) |
|
60710 | 1146 |
definition lt :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1147 |
where |
60710 | 1148 |
"lt c t = (if c = 0 then (Lt t) else if c > 0 then (Lt (CN 0 c t)) |
29789 | 1149 |
else (Gt (CN 0 (-c) (Neg t))))" |
1150 |
||
60710 | 1151 |
definition le :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1152 |
where |
60710 | 1153 |
"le c t = (if c = 0 then (Le t) else if c > 0 then (Le (CN 0 c t)) |
29789 | 1154 |
else (Ge (CN 0 (-c) (Neg t))))" |
1155 |
||
60710 | 1156 |
definition gt :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1157 |
where |
60710 | 1158 |
"gt c t = (if c = 0 then (Gt t) else if c > 0 then (Gt (CN 0 c t)) |
29789 | 1159 |
else (Lt (CN 0 (-c) (Neg t))))" |
1160 |
||
60710 | 1161 |
definition ge :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1162 |
where |
60710 | 1163 |
"ge c t = (if c = 0 then (Ge t) else if c > 0 then (Ge (CN 0 c t)) |
29789 | 1164 |
else (Le (CN 0 (-c) (Neg t))))" |
1165 |
||
60710 | 1166 |
definition eq :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1167 |
where |
60710 | 1168 |
"eq c t = (if c = 0 then (Eq t) else if c > 0 then (Eq (CN 0 c t)) |
29789 | 1169 |
else (Eq (CN 0 (-c) (Neg t))))" |
1170 |
||
60710 | 1171 |
definition neq :: "int \<Rightarrow> num \<Rightarrow> fm" |
29789 | 1172 |
where |
60710 | 1173 |
"neq c t = (if c = 0 then (NEq t) else if c > 0 then (NEq (CN 0 c t)) |
29789 | 1174 |
else (NEq (CN 0 (-c) (Neg t))))" |
1175 |
||
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1176 |
lemma lt: "numnoabs t \<Longrightarrow> Ifm bs (case_prod lt (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1177 |
Ifm bs (Lt t) \<and> isrlfm (case_prod lt (rsplit0 t))" |
60710 | 1178 |
using rsplit0[where bs = "bs" and t="t"] |
1179 |
by (auto simp add: lt_def split_def, cases "snd(rsplit0 t)", auto, |
|
1180 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1181 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1182 |
lemma le: "numnoabs t \<Longrightarrow> Ifm bs (case_prod le (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1183 |
Ifm bs (Le t) \<and> isrlfm (case_prod le (rsplit0 t))" |
60710 | 1184 |
using rsplit0[where bs = "bs" and t="t"] |
1185 |
by (auto simp add: le_def split_def, cases "snd(rsplit0 t)", auto, |
|
1186 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1187 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1188 |
lemma gt: "numnoabs t \<Longrightarrow> Ifm bs (case_prod gt (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1189 |
Ifm bs (Gt t) \<and> isrlfm (case_prod gt (rsplit0 t))" |
60710 | 1190 |
using rsplit0[where bs = "bs" and t="t"] |
1191 |
by (auto simp add: gt_def split_def, cases "snd(rsplit0 t)", auto, |
|
1192 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1193 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1194 |
lemma ge: "numnoabs t \<Longrightarrow> Ifm bs (case_prod ge (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1195 |
Ifm bs (Ge t) \<and> isrlfm (case_prod ge (rsplit0 t))" |
60710 | 1196 |
using rsplit0[where bs = "bs" and t="t"] |
1197 |
by (auto simp add: ge_def split_def, cases "snd(rsplit0 t)", auto, |
|
1198 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1199 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1200 |
lemma eq: "numnoabs t \<Longrightarrow> Ifm bs (case_prod eq (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1201 |
Ifm bs (Eq t) \<and> isrlfm (case_prod eq (rsplit0 t))" |
60710 | 1202 |
using rsplit0[where bs = "bs" and t="t"] |
1203 |
by (auto simp add: eq_def split_def, cases "snd(rsplit0 t)", auto, |
|
1204 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1205 |
|
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1206 |
lemma neq: "numnoabs t \<Longrightarrow> Ifm bs (case_prod neq (rsplit0 t)) = |
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
1207 |
Ifm bs (NEq t) \<and> isrlfm (case_prod neq (rsplit0 t))" |
60710 | 1208 |
using rsplit0[where bs = "bs" and t="t"] |
1209 |
by (auto simp add: neq_def split_def, cases "snd(rsplit0 t)", auto, |
|
1210 |
rename_tac nat a b, case_tac "nat", auto) |
|
29789 | 1211 |
|
1212 |
lemma conj_lin: "isrlfm p \<Longrightarrow> isrlfm q \<Longrightarrow> isrlfm (conj p q)" |
|
60710 | 1213 |
by (auto simp add: conj_def) |
1214 |
||
29789 | 1215 |
lemma disj_lin: "isrlfm p \<Longrightarrow> isrlfm q \<Longrightarrow> isrlfm (disj p q)" |
60710 | 1216 |
by (auto simp add: disj_def) |
29789 | 1217 |
|
66809 | 1218 |
fun rlfm :: "fm \<Rightarrow> fm" |
1219 |
where |
|
29789 | 1220 |
"rlfm (And p q) = conj (rlfm p) (rlfm q)" |
66809 | 1221 |
| "rlfm (Or p q) = disj (rlfm p) (rlfm q)" |
74101 | 1222 |
| "rlfm (Imp p q) = disj (rlfm (Not p)) (rlfm q)" |
1223 |
| "rlfm (Iff p q) = disj (conj (rlfm p) (rlfm q)) (conj (rlfm (Not p)) (rlfm (Not q)))" |
|
66809 | 1224 |
| "rlfm (Lt a) = case_prod lt (rsplit0 a)" |
1225 |
| "rlfm (Le a) = case_prod le (rsplit0 a)" |
|
1226 |
| "rlfm (Gt a) = case_prod gt (rsplit0 a)" |
|
1227 |
| "rlfm (Ge a) = case_prod ge (rsplit0 a)" |
|
1228 |
| "rlfm (Eq a) = case_prod eq (rsplit0 a)" |
|
1229 |
| "rlfm (NEq a) = case_prod neq (rsplit0 a)" |
|
74101 | 1230 |
| "rlfm (Not (And p q)) = disj (rlfm (Not p)) (rlfm (Not q))" |
1231 |
| "rlfm (Not (Or p q)) = conj (rlfm (Not p)) (rlfm (Not q))" |
|
1232 |
| "rlfm (Not (Imp p q)) = conj (rlfm p) (rlfm (Not q))" |
|
1233 |
| "rlfm (Not (Iff p q)) = disj (conj(rlfm p) (rlfm(Not q))) (conj(rlfm(Not p)) (rlfm q))" |
|
1234 |
| "rlfm (Not (Not p)) = rlfm p" |
|
1235 |
| "rlfm (Not T) = F" |
|
1236 |
| "rlfm (Not F) = T" |
|
1237 |
| "rlfm (Not (Lt a)) = rlfm (Ge a)" |
|
1238 |
| "rlfm (Not (Le a)) = rlfm (Gt a)" |
|
1239 |
| "rlfm (Not (Gt a)) = rlfm (Le a)" |
|
1240 |
| "rlfm (Not (Ge a)) = rlfm (Lt a)" |
|
1241 |
| "rlfm (Not (Eq a)) = rlfm (NEq a)" |
|
1242 |
| "rlfm (Not (NEq a)) = rlfm (Eq a)" |
|
66809 | 1243 |
| "rlfm p = p" |
29789 | 1244 |
|
1245 |
lemma rlfm_I: |
|
1246 |
assumes qfp: "qfree p" |
|
1247 |
shows "(Ifm bs (rlfm p) = Ifm bs p) \<and> isrlfm (rlfm p)" |
|
60710 | 1248 |
using qfp |
66809 | 1249 |
by (induct p rule: rlfm.induct) (auto simp add: lt le gt ge eq neq conj_lin disj_lin) |
29789 | 1250 |
|
1251 |
(* Operations needed for Ferrante and Rackoff *) |
|
1252 |
lemma rminusinf_inf: |
|
1253 |
assumes lp: "isrlfm p" |
|
60710 | 1254 |
shows "\<exists>z. \<forall>x < z. Ifm (x#bs) (minusinf p) = Ifm (x#bs) p" (is "\<exists>z. \<forall>x. ?P z x p") |
1255 |
using lp |
|
29789 | 1256 |
proof (induct p rule: minusinf.induct) |
44779 | 1257 |
case (1 p q) |
60710 | 1258 |
then show ?case |
1259 |
apply auto |
|
1260 |
apply (rule_tac x= "min z za" in exI) |
|
1261 |
apply auto |
|
1262 |
done |
|
29789 | 1263 |
next |
44779 | 1264 |
case (2 p q) |
60710 | 1265 |
then show ?case |
1266 |
apply auto |
|
1267 |
apply (rule_tac x= "min z za" in exI) |
|
1268 |
apply auto |
|
1269 |
done |
|
29789 | 1270 |
next |
60710 | 1271 |
case (3 c e) |
41807 | 1272 |
from 3 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1273 |
from 3 have cp: "real_of_int c > 0" by simp |
29789 | 1274 |
fix a |
60710 | 1275 |
let ?e = "Inum (a#bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1276 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1277 |
{ |
1278 |
fix x |
|
29789 | 1279 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1280 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1281 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1282 |
then have "real_of_int c * x + ?e < 0" by arith |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1283 |
then have "real_of_int c * x + ?e \<noteq> 0" by simp |
29789 | 1284 |
with xz have "?P ?z x (Eq (CN 0 c e))" |
60710 | 1285 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1286 |
} |
|
1287 |
then have "\<forall>x < ?z. ?P ?z x (Eq (CN 0 c e))" by simp |
|
1288 |
then show ?case by blast |
|
29789 | 1289 |
next |
60710 | 1290 |
case (4 c e) |
41807 | 1291 |
from 4 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1292 |
from 4 have cp: "real_of_int c > 0" by simp |
29789 | 1293 |
fix a |
60710 | 1294 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1295 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1296 |
{ |
1297 |
fix x |
|
29789 | 1298 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1299 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1300 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1301 |
then have "real_of_int c * x + ?e < 0" by arith |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1302 |
then have "real_of_int c * x + ?e \<noteq> 0" by simp |
29789 | 1303 |
with xz have "?P ?z x (NEq (CN 0 c e))" |
60710 | 1304 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1305 |
} |
|
1306 |
then have "\<forall>x < ?z. ?P ?z x (NEq (CN 0 c e))" by simp |
|
1307 |
then show ?case by blast |
|
29789 | 1308 |
next |
60710 | 1309 |
case (5 c e) |
41807 | 1310 |
from 5 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1311 |
from 5 have cp: "real_of_int c > 0" by simp |
29789 | 1312 |
fix a |
1313 |
let ?e="Inum (a#bs) e" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1314 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1315 |
{ |
1316 |
fix x |
|
29789 | 1317 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1318 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1319 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1320 |
then have "real_of_int c * x + ?e < 0" by arith |
29789 | 1321 |
with xz have "?P ?z x (Lt (CN 0 c e))" |
60710 | 1322 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1323 |
} |
|
1324 |
then have "\<forall>x < ?z. ?P ?z x (Lt (CN 0 c e))" by simp |
|
1325 |
then show ?case by blast |
|
29789 | 1326 |
next |
60710 | 1327 |
case (6 c e) |
41807 | 1328 |
from 6 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1329 |
from lp 6 have cp: "real_of_int c > 0" by simp |
29789 | 1330 |
fix a |
60710 | 1331 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1332 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1333 |
{ |
1334 |
fix x |
|
29789 | 1335 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1336 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1337 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1338 |
then have "real_of_int c * x + ?e < 0" by arith |
29789 | 1339 |
with xz have "?P ?z x (Le (CN 0 c e))" |
60710 | 1340 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1341 |
} |
|
1342 |
then have "\<forall>x < ?z. ?P ?z x (Le (CN 0 c e))" by simp |
|
1343 |
then show ?case by blast |
|
29789 | 1344 |
next |
60710 | 1345 |
case (7 c e) |
41807 | 1346 |
from 7 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1347 |
from 7 have cp: "real_of_int c > 0" by simp |
29789 | 1348 |
fix a |
60710 | 1349 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1350 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1351 |
{ |
1352 |
fix x |
|
29789 | 1353 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1354 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1355 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1356 |
then have "real_of_int c * x + ?e < 0" by arith |
29789 | 1357 |
with xz have "?P ?z x (Gt (CN 0 c e))" |
60710 | 1358 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1359 |
} |
|
1360 |
then have "\<forall>x < ?z. ?P ?z x (Gt (CN 0 c e))" by simp |
|
1361 |
then show ?case by blast |
|
29789 | 1362 |
next |
60710 | 1363 |
case (8 c e) |
41807 | 1364 |
from 8 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1365 |
from 8 have cp: "real_of_int c > 0" by simp |
29789 | 1366 |
fix a |
1367 |
let ?e="Inum (a#bs) e" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1368 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1369 |
{ |
1370 |
fix x |
|
29789 | 1371 |
assume xz: "x < ?z" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1372 |
then have "(real_of_int c * x < - ?e)" |
60710 | 1373 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="- ?e"] ac_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1374 |
then have "real_of_int c * x + ?e < 0" by arith |
29789 | 1375 |
with xz have "?P ?z x (Ge (CN 0 c e))" |
60710 | 1376 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1377 |
} |
|
1378 |
then have "\<forall>x < ?z. ?P ?z x (Ge (CN 0 c e))" by simp |
|
1379 |
then show ?case by blast |
|
29789 | 1380 |
qed simp_all |
1381 |
||
1382 |
lemma rplusinf_inf: |
|
1383 |
assumes lp: "isrlfm p" |
|
60710 | 1384 |
shows "\<exists>z. \<forall>x > z. Ifm (x#bs) (plusinf p) = Ifm (x#bs) p" (is "\<exists>z. \<forall>x. ?P z x p") |
29789 | 1385 |
using lp |
1386 |
proof (induct p rule: isrlfm.induct) |
|
60710 | 1387 |
case (1 p q) |
1388 |
then show ?case |
|
1389 |
apply auto |
|
1390 |
apply (rule_tac x= "max z za" in exI) |
|
1391 |
apply auto |
|
1392 |
done |
|
29789 | 1393 |
next |
60710 | 1394 |
case (2 p q) |
1395 |
then show ?case |
|
1396 |
apply auto |
|
1397 |
apply (rule_tac x= "max z za" in exI) |
|
1398 |
apply auto |
|
1399 |
done |
|
29789 | 1400 |
next |
60710 | 1401 |
case (3 c e) |
41807 | 1402 |
from 3 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1403 |
from 3 have cp: "real_of_int c > 0" by simp |
29789 | 1404 |
fix a |
60710 | 1405 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1406 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1407 |
{ |
1408 |
fix x |
|
29789 | 1409 |
assume xz: "x > ?z" |
1410 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1411 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1412 |
then have "real_of_int c * x + ?e > 0" by arith |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1413 |
then have "real_of_int c * x + ?e \<noteq> 0" by simp |
29789 | 1414 |
with xz have "?P ?z x (Eq (CN 0 c e))" |
60710 | 1415 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1416 |
} |
|
1417 |
then have "\<forall>x > ?z. ?P ?z x (Eq (CN 0 c e))" by simp |
|
1418 |
then show ?case by blast |
|
29789 | 1419 |
next |
60710 | 1420 |
case (4 c e) |
41807 | 1421 |
from 4 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1422 |
from 4 have cp: "real_of_int c > 0" by simp |
29789 | 1423 |
fix a |
60710 | 1424 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1425 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1426 |
{ |
1427 |
fix x |
|
29789 | 1428 |
assume xz: "x > ?z" |
1429 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1430 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1431 |
then have "real_of_int c * x + ?e > 0" by arith |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1432 |
then have "real_of_int c * x + ?e \<noteq> 0" by simp |
29789 | 1433 |
with xz have "?P ?z x (NEq (CN 0 c e))" |
60710 | 1434 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1435 |
} |
|
1436 |
then have "\<forall>x > ?z. ?P ?z x (NEq (CN 0 c e))" by simp |
|
1437 |
then show ?case by blast |
|
29789 | 1438 |
next |
60710 | 1439 |
case (5 c e) |
41807 | 1440 |
from 5 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1441 |
from 5 have cp: "real_of_int c > 0" by simp |
29789 | 1442 |
fix a |
60710 | 1443 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1444 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1445 |
{ |
1446 |
fix x |
|
29789 | 1447 |
assume xz: "x > ?z" |
1448 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1449 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1450 |
then have "real_of_int c * x + ?e > 0" by arith |
29789 | 1451 |
with xz have "?P ?z x (Lt (CN 0 c e))" |
60710 | 1452 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1453 |
} |
|
1454 |
then have "\<forall>x > ?z. ?P ?z x (Lt (CN 0 c e))" by simp |
|
1455 |
then show ?case by blast |
|
29789 | 1456 |
next |
60710 | 1457 |
case (6 c e) |
41807 | 1458 |
from 6 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1459 |
from 6 have cp: "real_of_int c > 0" by simp |
29789 | 1460 |
fix a |
60710 | 1461 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1462 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1463 |
{ |
1464 |
fix x |
|
29789 | 1465 |
assume xz: "x > ?z" |
1466 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1467 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1468 |
then have "real_of_int c * x + ?e > 0" by arith |
29789 | 1469 |
with xz have "?P ?z x (Le (CN 0 c e))" |
60710 | 1470 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1471 |
} |
|
1472 |
then have "\<forall>x > ?z. ?P ?z x (Le (CN 0 c e))" by simp |
|
1473 |
then show ?case by blast |
|
29789 | 1474 |
next |
60710 | 1475 |
case (7 c e) |
41807 | 1476 |
from 7 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1477 |
from 7 have cp: "real_of_int c > 0" by simp |
29789 | 1478 |
fix a |
60710 | 1479 |
let ?e = "Inum (a # bs) e" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1480 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1481 |
{ |
1482 |
fix x |
|
29789 | 1483 |
assume xz: "x > ?z" |
1484 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1485 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1486 |
then have "real_of_int c * x + ?e > 0" by arith |
29789 | 1487 |
with xz have "?P ?z x (Gt (CN 0 c e))" |
60710 | 1488 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1489 |
} |
|
1490 |
then have "\<forall>x > ?z. ?P ?z x (Gt (CN 0 c e))" by simp |
|
1491 |
then show ?case by blast |
|
29789 | 1492 |
next |
60710 | 1493 |
case (8 c e) |
41807 | 1494 |
from 8 have nb: "numbound0 e" by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1495 |
from 8 have cp: "real_of_int c > 0" by simp |
29789 | 1496 |
fix a |
1497 |
let ?e="Inum (a#bs) e" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1498 |
let ?z = "(- ?e) / real_of_int c" |
60710 | 1499 |
{ |
1500 |
fix x |
|
29789 | 1501 |
assume xz: "x > ?z" |
1502 |
with mult_strict_right_mono [OF xz cp] cp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1503 |
have "(real_of_int c * x > - ?e)" by (simp add: ac_simps) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1504 |
then have "real_of_int c * x + ?e > 0" by arith |
29789 | 1505 |
with xz have "?P ?z x (Ge (CN 0 c e))" |
60710 | 1506 |
using numbound0_I[OF nb, where b="x" and bs="bs" and b'="a"] by simp |
1507 |
} |
|
1508 |
then have "\<forall>x > ?z. ?P ?z x (Ge (CN 0 c e))" by simp |
|
1509 |
then show ?case by blast |
|
29789 | 1510 |
qed simp_all |
1511 |
||
1512 |
lemma rminusinf_bound0: |
|
1513 |
assumes lp: "isrlfm p" |
|
1514 |
shows "bound0 (minusinf p)" |
|
60710 | 1515 |
using lp by (induct p rule: minusinf.induct) simp_all |
29789 | 1516 |
|
1517 |
lemma rplusinf_bound0: |
|
1518 |
assumes lp: "isrlfm p" |
|
1519 |
shows "bound0 (plusinf p)" |
|
60710 | 1520 |
using lp by (induct p rule: plusinf.induct) simp_all |
29789 | 1521 |
|
1522 |
lemma rminusinf_ex: |
|
1523 |
assumes lp: "isrlfm p" |
|
60710 | 1524 |
and ex: "Ifm (a#bs) (minusinf p)" |
1525 |
shows "\<exists>x. Ifm (x#bs) p" |
|
1526 |
proof - |
|
29789 | 1527 |
from bound0_I [OF rminusinf_bound0[OF lp], where b="a" and bs ="bs"] ex |
60710 | 1528 |
have th: "\<forall>x. Ifm (x#bs) (minusinf p)" by auto |
1529 |
from rminusinf_inf[OF lp, where bs="bs"] |
|
29789 | 1530 |
obtain z where z_def: "\<forall>x<z. Ifm (x # bs) (minusinf p) = Ifm (x # bs) p" by blast |
60710 | 1531 |
from th have "Ifm ((z - 1) # bs) (minusinf p)" by simp |
29789 | 1532 |
moreover have "z - 1 < z" by simp |
1533 |
ultimately show ?thesis using z_def by auto |
|
1534 |
qed |
|
1535 |
||
1536 |
lemma rplusinf_ex: |
|
1537 |
assumes lp: "isrlfm p" |
|
60710 | 1538 |
and ex: "Ifm (a # bs) (plusinf p)" |
1539 |
shows "\<exists>x. Ifm (x # bs) p" |
|
1540 |
proof - |
|
29789 | 1541 |
from bound0_I [OF rplusinf_bound0[OF lp], where b="a" and bs ="bs"] ex |
60710 | 1542 |
have th: "\<forall>x. Ifm (x # bs) (plusinf p)" by auto |
1543 |
from rplusinf_inf[OF lp, where bs="bs"] |
|
29789 | 1544 |
obtain z where z_def: "\<forall>x>z. Ifm (x # bs) (plusinf p) = Ifm (x # bs) p" by blast |
60710 | 1545 |
from th have "Ifm ((z + 1) # bs) (plusinf p)" by simp |
29789 | 1546 |
moreover have "z + 1 > z" by simp |
1547 |
ultimately show ?thesis using z_def by auto |
|
1548 |
qed |
|
1549 |
||
66809 | 1550 |
fun uset :: "fm \<Rightarrow> (num \<times> int) list" |
1551 |
where |
|
60710 | 1552 |
"uset (And p q) = (uset p @ uset q)" |
66809 | 1553 |
| "uset (Or p q) = (uset p @ uset q)" |
1554 |
| "uset (Eq (CN 0 c e)) = [(Neg e,c)]" |
|
1555 |
| "uset (NEq (CN 0 c e)) = [(Neg e,c)]" |
|
1556 |
| "uset (Lt (CN 0 c e)) = [(Neg e,c)]" |
|
1557 |
| "uset (Le (CN 0 c e)) = [(Neg e,c)]" |
|
1558 |
| "uset (Gt (CN 0 c e)) = [(Neg e,c)]" |
|
1559 |
| "uset (Ge (CN 0 c e)) = [(Neg e,c)]" |
|
1560 |
| "uset p = []" |
|
1561 |
||
1562 |
fun usubst :: "fm \<Rightarrow> num \<times> int \<Rightarrow> fm" |
|
1563 |
where |
|
60710 | 1564 |
"usubst (And p q) = (\<lambda>(t,n). And (usubst p (t,n)) (usubst q (t,n)))" |
66809 | 1565 |
| "usubst (Or p q) = (\<lambda>(t,n). Or (usubst p (t,n)) (usubst q (t,n)))" |
1566 |
| "usubst (Eq (CN 0 c e)) = (\<lambda>(t,n). Eq (Add (Mul c t) (Mul n e)))" |
|
1567 |
| "usubst (NEq (CN 0 c e)) = (\<lambda>(t,n). NEq (Add (Mul c t) (Mul n e)))" |
|
1568 |
| "usubst (Lt (CN 0 c e)) = (\<lambda>(t,n). Lt (Add (Mul c t) (Mul n e)))" |
|
1569 |
| "usubst (Le (CN 0 c e)) = (\<lambda>(t,n). Le (Add (Mul c t) (Mul n e)))" |
|
1570 |
| "usubst (Gt (CN 0 c e)) = (\<lambda>(t,n). Gt (Add (Mul c t) (Mul n e)))" |
|
1571 |
| "usubst (Ge (CN 0 c e)) = (\<lambda>(t,n). Ge (Add (Mul c t) (Mul n e)))" |
|
1572 |
| "usubst p = (\<lambda>(t, n). p)" |
|
29789 | 1573 |
|
60710 | 1574 |
lemma usubst_I: |
1575 |
assumes lp: "isrlfm p" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1576 |
and np: "real_of_int n > 0" |
60710 | 1577 |
and nbt: "numbound0 t" |
1578 |
shows "(Ifm (x # bs) (usubst p (t,n)) = |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1579 |
Ifm (((Inum (x # bs) t) / (real_of_int n)) # bs) p) \<and> bound0 (usubst p (t, n))" |
60710 | 1580 |
(is "(?I x (usubst p (t, n)) = ?I ?u p) \<and> ?B p" |
1581 |
is "(_ = ?I (?t/?n) p) \<and> _" |
|
1582 |
is "(_ = ?I (?N x t /_) p) \<and> _") |
|
29789 | 1583 |
using lp |
60710 | 1584 |
proof (induct p rule: usubst.induct) |
1585 |
case (5 c e) |
|
1586 |
with assms have cp: "c > 0" and nb: "numbound0 e" by simp_all |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1587 |
have "?I ?u (Lt (CN 0 c e)) \<longleftrightarrow> real_of_int c * (?t / ?n) + ?N x e < 0" |
29789 | 1588 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1589 |
also have "\<dots> \<longleftrightarrow> ?n * (real_of_int c * (?t / ?n)) + ?n*(?N x e) < 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1590 |
by (simp only: pos_less_divide_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1591 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1592 |
also have "\<dots> \<longleftrightarrow> real_of_int c * ?t + ?n * (?N x e) < 0" using np by simp |
29789 | 1593 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
1594 |
next |
|
60710 | 1595 |
case (6 c e) |
1596 |
with assms have cp: "c > 0" and nb: "numbound0 e" by simp_all |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1597 |
have "?I ?u (Le (CN 0 c e)) \<longleftrightarrow> real_of_int c * (?t / ?n) + ?N x e \<le> 0" |
29789 | 1598 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1599 |
also have "\<dots> = (?n*(real_of_int c *(?t/?n)) + ?n*(?N x e) \<le> 0)" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1600 |
by (simp only: pos_le_divide_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1601 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1602 |
also have "\<dots> = (real_of_int c *?t + ?n* (?N x e) \<le> 0)" using np by simp |
29789 | 1603 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
1604 |
next |
|
60710 | 1605 |
case (7 c e) |
1606 |
with assms have cp: "c >0" and nb: "numbound0 e" by simp_all |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1607 |
have "?I ?u (Gt (CN 0 c e)) \<longleftrightarrow> real_of_int c *(?t / ?n) + ?N x e > 0" |
29789 | 1608 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1609 |
also have "\<dots> \<longleftrightarrow> ?n * (real_of_int c * (?t / ?n)) + ?n * ?N x e > 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1610 |
by (simp only: pos_divide_less_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1611 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1612 |
also have "\<dots> \<longleftrightarrow> real_of_int c * ?t + ?n * ?N x e > 0" using np by simp |
29789 | 1613 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
1614 |
next |
|
60710 | 1615 |
case (8 c e) |
1616 |
with assms have cp: "c > 0" and nb: "numbound0 e" by simp_all |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1617 |
have "?I ?u (Ge (CN 0 c e)) \<longleftrightarrow> real_of_int c * (?t / ?n) + ?N x e \<ge> 0" |
29789 | 1618 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1619 |
also have "\<dots> \<longleftrightarrow> ?n * (real_of_int c * (?t / ?n)) + ?n * ?N x e \<ge> 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1620 |
by (simp only: pos_divide_le_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1621 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1622 |
also have "\<dots> \<longleftrightarrow> real_of_int c * ?t + ?n * ?N x e \<ge> 0" using np by simp |
29789 | 1623 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
1624 |
next |
|
60710 | 1625 |
case (3 c e) |
1626 |
with assms have cp: "c > 0" and nb: "numbound0 e" by simp_all |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1627 |
from np have np: "real_of_int n \<noteq> 0" by simp |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1628 |
have "?I ?u (Eq (CN 0 c e)) \<longleftrightarrow> real_of_int c * (?t / ?n) + ?N x e = 0" |
29789 | 1629 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1630 |
also have "\<dots> \<longleftrightarrow> ?n * (real_of_int c * (?t / ?n)) + ?n * ?N x e = 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1631 |
by (simp only: nonzero_eq_divide_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1632 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1633 |
also have "\<dots> \<longleftrightarrow> real_of_int c * ?t + ?n * ?N x e = 0" using np by simp |
29789 | 1634 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
1635 |
next |
|
41807 | 1636 |
case (4 c e) with assms have cp: "c >0" and nb: "numbound0 e" by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1637 |
from np have np: "real_of_int n \<noteq> 0" by simp |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1638 |
have "?I ?u (NEq (CN 0 c e)) \<longleftrightarrow> real_of_int c * (?t / ?n) + ?N x e \<noteq> 0" |
29789 | 1639 |
using numbound0_I[OF nb, where bs="bs" and b="?u" and b'="x"] by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1640 |
also have "\<dots> \<longleftrightarrow> ?n * (real_of_int c * (?t / ?n)) + ?n * ?N x e \<noteq> 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1641 |
by (simp only: nonzero_eq_divide_eq[OF np, where a="real_of_int c *(?t/?n) + (?N x e)" |
64240 | 1642 |
and b="0", simplified div_0]) (simp only: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1643 |
also have "\<dots> \<longleftrightarrow> real_of_int c * ?t + ?n * ?N x e \<noteq> 0" using np by simp |
29789 | 1644 |
finally show ?case using nbt nb by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1645 |
qed(simp_all add: nbt numbound0_I[where bs ="bs" and b="(Inum (x#bs) t)/ real_of_int n" and b'="x"]) |
29789 | 1646 |
|
1647 |
lemma uset_l: |
|
1648 |
assumes lp: "isrlfm p" |
|
60710 | 1649 |
shows "\<forall>(t,k) \<in> set (uset p). numbound0 t \<and> k > 0" |
1650 |
using lp by (induct p rule: uset.induct) auto |
|
29789 | 1651 |
|
1652 |
lemma rminusinf_uset: |
|
1653 |
assumes lp: "isrlfm p" |
|
60710 | 1654 |
and nmi: "\<not> (Ifm (a # bs) (minusinf p))" (is "\<not> (Ifm (a # bs) (?M p))") |
1655 |
and ex: "Ifm (x#bs) p" (is "?I x p") |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1656 |
shows "\<exists>(s,m) \<in> set (uset p). x \<ge> Inum (a#bs) s / real_of_int m" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1657 |
(is "\<exists>(s,m) \<in> ?U p. x \<ge> ?N a s / real_of_int m") |
60710 | 1658 |
proof - |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1659 |
have "\<exists>(s,m) \<in> set (uset p). real_of_int m * x \<ge> Inum (a#bs) s" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1660 |
(is "\<exists>(s,m) \<in> ?U p. real_of_int m *x \<ge> ?N a s") |
29789 | 1661 |
using lp nmi ex |
60710 | 1662 |
by (induct p rule: minusinf.induct) (auto simp add:numbound0_I[where bs="bs" and b="a" and b'="x"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1663 |
then obtain s m where smU: "(s,m) \<in> set (uset p)" and mx: "real_of_int m * x \<ge> ?N a s" |
60710 | 1664 |
by blast |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1665 |
from uset_l[OF lp] smU have mp: "real_of_int m > 0" |
60710 | 1666 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1667 |
from pos_divide_le_eq[OF mp, where a="x" and b="?N a s", symmetric] mx have "x \<ge> ?N a s / real_of_int m" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56544
diff
changeset
|
1668 |
by (auto simp add: mult.commute) |
60710 | 1669 |
then show ?thesis |
1670 |
using smU by auto |
|
29789 | 1671 |
qed |
1672 |
||
1673 |
lemma rplusinf_uset: |
|
1674 |
assumes lp: "isrlfm p" |
|
60710 | 1675 |
and nmi: "\<not> (Ifm (a # bs) (plusinf p))" (is "\<not> (Ifm (a # bs) (?M p))") |
1676 |
and ex: "Ifm (x # bs) p" (is "?I x p") |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1677 |
shows "\<exists>(s,m) \<in> set (uset p). x \<le> Inum (a#bs) s / real_of_int m" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1678 |
(is "\<exists>(s,m) \<in> ?U p. x \<le> ?N a s / real_of_int m") |
60710 | 1679 |
proof - |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1680 |
have "\<exists>(s,m) \<in> set (uset p). real_of_int m * x \<le> Inum (a#bs) s" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1681 |
(is "\<exists>(s,m) \<in> ?U p. real_of_int m *x \<le> ?N a s") |
29789 | 1682 |
using lp nmi ex |
60710 | 1683 |
by (induct p rule: minusinf.induct) |
1684 |
(auto simp add:numbound0_I[where bs="bs" and b="a" and b'="x"]) |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1685 |
then obtain s m where smU: "(s,m) \<in> set (uset p)" and mx: "real_of_int m * x \<le> ?N a s" |
60710 | 1686 |
by blast |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1687 |
from uset_l[OF lp] smU have mp: "real_of_int m > 0" |
60710 | 1688 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1689 |
from pos_le_divide_eq[OF mp, where a="x" and b="?N a s", symmetric] mx have "x \<le> ?N a s / real_of_int m" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56544
diff
changeset
|
1690 |
by (auto simp add: mult.commute) |
60710 | 1691 |
then show ?thesis |
1692 |
using smU by auto |
|
29789 | 1693 |
qed |
1694 |
||
60710 | 1695 |
lemma lin_dense: |
29789 | 1696 |
assumes lp: "isrlfm p" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1697 |
and noS: "\<forall>t. l < t \<and> t< u \<longrightarrow> t \<notin> (\<lambda>(t,n). Inum (x#bs) t / real_of_int n) ` set (uset p)" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1698 |
(is "\<forall>t. _ \<and> _ \<longrightarrow> t \<notin> (\<lambda>(t,n). ?N x t / real_of_int n ) ` (?U p)") |
60711 | 1699 |
and lx: "l < x" |
1700 |
and xu:"x < u" |
|
1701 |
and px:" Ifm (x#bs) p" |
|
1702 |
and ly: "l < y" and yu: "y < u" |
|
29789 | 1703 |
shows "Ifm (y#bs) p" |
60711 | 1704 |
using lp px noS |
29789 | 1705 |
proof (induct p rule: isrlfm.induct) |
60711 | 1706 |
case (5 c e) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1707 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1708 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1709 |
from 5 have "x * real_of_int c + ?N x e < 0" |
60711 | 1710 |
by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1711 |
then have pxc: "x < (- ?N x e) / real_of_int c" |
41807 | 1712 |
by (simp only: pos_less_divide_eq[OF cp, where a="x" and b="-?N x e"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1713 |
from 5 have noSc:"\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1714 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1715 |
with ly yu have yne: "y \<noteq> - ?N x e / real_of_int c" |
60711 | 1716 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1717 |
then consider "y < (-?N x e)/ real_of_int c" | "y > (- ?N x e) / real_of_int c" |
60711 | 1718 |
by atomize_elim auto |
1719 |
then show ?case |
|
1720 |
proof cases |
|
60767 | 1721 |
case 1 |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1722 |
then have "y * real_of_int c < - ?N x e" |
60711 | 1723 |
by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1724 |
then have "real_of_int c * y + ?N x e < 0" |
60711 | 1725 |
by (simp add: algebra_simps) |
1726 |
then show ?thesis |
|
1727 |
using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp |
|
1728 |
next |
|
60767 | 1729 |
case 2 |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1730 |
with yu have eu: "u > (- ?N x e) / real_of_int c" |
60711 | 1731 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1732 |
with noSc ly yu have "(- ?N x e) / real_of_int c \<le> l" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1733 |
by (cases "(- ?N x e) / real_of_int c > l") auto |
60711 | 1734 |
with lx pxc have False |
1735 |
by auto |
|
1736 |
then show ?thesis .. |
|
1737 |
qed |
|
1738 |
next |
|
1739 |
case (6 c e) |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1740 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1741 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1742 |
from 6 have "x * real_of_int c + ?N x e \<le> 0" |
60711 | 1743 |
by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1744 |
then have pxc: "x \<le> (- ?N x e) / real_of_int c" |
60711 | 1745 |
by (simp only: pos_le_divide_eq[OF cp, where a="x" and b="-?N x e"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1746 |
from 6 have noSc:"\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1747 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1748 |
with ly yu have yne: "y \<noteq> - ?N x e / real_of_int c" |
60711 | 1749 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1750 |
then consider "y < (- ?N x e) / real_of_int c" | "y > (-?N x e) / real_of_int c" |
60711 | 1751 |
by atomize_elim auto |
1752 |
then show ?case |
|
1753 |
proof cases |
|
60767 | 1754 |
case 1 |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1755 |
then have "y * real_of_int c < - ?N x e" |
41807 | 1756 |
by (simp add: pos_less_divide_eq[OF cp, where a="y" and b="-?N x e", symmetric]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1757 |
then have "real_of_int c * y + ?N x e < 0" |
60711 | 1758 |
by (simp add: algebra_simps) |
1759 |
then show ?thesis |
|
1760 |
using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp |
|
1761 |
next |
|
60767 | 1762 |
case 2 |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1763 |
with yu have eu: "u > (- ?N x e) / real_of_int c" |
60711 | 1764 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1765 |
with noSc ly yu have "(- ?N x e) / real_of_int c \<le> l" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1766 |
by (cases "(- ?N x e) / real_of_int c > l") auto |
60711 | 1767 |
with lx pxc have False |
1768 |
by auto |
|
1769 |
then show ?thesis .. |
|
1770 |
qed |
|
29789 | 1771 |
next |
60711 | 1772 |
case (7 c e) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1773 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1774 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1775 |
from 7 have "x * real_of_int c + ?N x e > 0" |
60711 | 1776 |
by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1777 |
then have pxc: "x > (- ?N x e) / real_of_int c" |
41807 | 1778 |
by (simp only: pos_divide_less_eq[OF cp, where a="x" and b="-?N x e"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1779 |
from 7 have noSc: "\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1780 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1781 |
with ly yu have yne: "y \<noteq> - ?N x e / real_of_int c" |
60711 | 1782 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1783 |
then consider "y > (- ?N x e) / real_of_int c" | "y < (-?N x e) / real_of_int c" |
60711 | 1784 |
by atomize_elim auto |
1785 |
then show ?case |
|
1786 |
proof cases |
|
1787 |
case 1 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1788 |
then have "y * real_of_int c > - ?N x e" |
60711 | 1789 |
by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1790 |
then have "real_of_int c * y + ?N x e > 0" |
60711 | 1791 |
by (simp add: algebra_simps) |
1792 |
then show ?thesis |
|
1793 |
using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp |
|
1794 |
next |
|
1795 |
case 2 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1796 |
with ly have eu: "l < (- ?N x e) / real_of_int c" |
60711 | 1797 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1798 |
with noSc ly yu have "(- ?N x e) / real_of_int c \<ge> u" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1799 |
by (cases "(- ?N x e) / real_of_int c > l") auto |
60711 | 1800 |
with xu pxc have False by auto |
1801 |
then show ?thesis .. |
|
1802 |
qed |
|
1803 |
next |
|
1804 |
case (8 c e) |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1805 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1806 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1807 |
from 8 have "x * real_of_int c + ?N x e \<ge> 0" |
60711 | 1808 |
by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1809 |
then have pxc: "x \<ge> (- ?N x e) / real_of_int c" |
60711 | 1810 |
by (simp only: pos_divide_le_eq[OF cp, where a="x" and b="-?N x e"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1811 |
from 8 have noSc:"\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1812 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1813 |
with ly yu have yne: "y \<noteq> - ?N x e / real_of_int c" |
60711 | 1814 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1815 |
then consider "y > (- ?N x e) / real_of_int c" | "y < (-?N x e) / real_of_int c" |
60711 | 1816 |
by atomize_elim auto |
1817 |
then show ?case |
|
1818 |
proof cases |
|
1819 |
case 1 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1820 |
then have "y * real_of_int c > - ?N x e" |
41807 | 1821 |
by (simp add: pos_divide_less_eq[OF cp, where a="y" and b="-?N x e", symmetric]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1822 |
then have "real_of_int c * y + ?N x e > 0" by (simp add: algebra_simps) |
60711 | 1823 |
then show ?thesis |
1824 |
using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] by simp |
|
1825 |
next |
|
1826 |
case 2 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1827 |
with ly have eu: "l < (- ?N x e) / real_of_int c" |
60711 | 1828 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1829 |
with noSc ly yu have "(- ?N x e) / real_of_int c \<ge> u" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1830 |
by (cases "(- ?N x e) / real_of_int c > l") auto |
60711 | 1831 |
with xu pxc have False |
1832 |
by auto |
|
1833 |
then show ?thesis .. |
|
1834 |
qed |
|
29789 | 1835 |
next |
60711 | 1836 |
case (3 c e) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1837 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1838 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1839 |
from cp have cnz: "real_of_int c \<noteq> 0" |
60711 | 1840 |
by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1841 |
from 3 have "x * real_of_int c + ?N x e = 0" |
60711 | 1842 |
by (simp add: algebra_simps) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1843 |
then have pxc: "x = (- ?N x e) / real_of_int c" |
41807 | 1844 |
by (simp only: nonzero_eq_divide_eq[OF cnz, where a="x" and b="-?N x e"]) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1845 |
from 3 have noSc:"\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1846 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1847 |
with lx xu have yne: "x \<noteq> - ?N x e / real_of_int c" |
60711 | 1848 |
by auto |
1849 |
with pxc show ?case |
|
1850 |
by simp |
|
29789 | 1851 |
next |
60711 | 1852 |
case (4 c e) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1853 |
then have cp: "real_of_int c > 0" and nb: "numbound0 e" |
60711 | 1854 |
by simp_all |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1855 |
from cp have cnz: "real_of_int c \<noteq> 0" |
60711 | 1856 |
by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1857 |
from 4 have noSc:"\<forall>t. l < t \<and> t < u \<longrightarrow> t \<noteq> (- ?N x e) / real_of_int c" |
60711 | 1858 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1859 |
with ly yu have yne: "y \<noteq> - ?N x e / real_of_int c" |
60711 | 1860 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1861 |
then have "y* real_of_int c \<noteq> -?N x e" |
41807 | 1862 |
by (simp only: nonzero_eq_divide_eq[OF cnz, where a="y" and b="-?N x e"]) simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1863 |
then have "y* real_of_int c + ?N x e \<noteq> 0" |
60711 | 1864 |
by (simp add: algebra_simps) |
60710 | 1865 |
then show ?case using numbound0_I[OF nb, where bs="bs" and b="x" and b'="y"] |
41807 | 1866 |
by (simp add: algebra_simps) |
41842 | 1867 |
qed (auto simp add: numbound0_I[where bs="bs" and b="y" and b'="x"]) |
29789 | 1868 |
|
1869 |
lemma finite_set_intervals: |
|
60711 | 1870 |
fixes x :: real |
1871 |
assumes px: "P x" |
|
1872 |
and lx: "l \<le> x" |
|
1873 |
and xu: "x \<le> u" |
|
1874 |
and linS: "l\<in> S" |
|
1875 |
and uinS: "u \<in> S" |
|
1876 |
and fS: "finite S" |
|
1877 |
and lS: "\<forall>x\<in> S. l \<le> x" |
|
1878 |
and Su: "\<forall>x\<in> S. x \<le> u" |
|
60710 | 1879 |
shows "\<exists>a \<in> S. \<exists>b \<in> S. (\<forall>y. a < y \<and> y < b \<longrightarrow> y \<notin> S) \<and> a \<le> x \<and> x \<le> b \<and> P x" |
1880 |
proof - |
|
29789 | 1881 |
let ?Mx = "{y. y\<in> S \<and> y \<le> x}" |
1882 |
let ?xM = "{y. y\<in> S \<and> x \<le> y}" |
|
1883 |
let ?a = "Max ?Mx" |
|
1884 |
let ?b = "Min ?xM" |
|
60711 | 1885 |
have MxS: "?Mx \<subseteq> S" |
1886 |
by blast |
|
1887 |
then have fMx: "finite ?Mx" |
|
1888 |
using fS finite_subset by auto |
|
1889 |
from lx linS have linMx: "l \<in> ?Mx" |
|
1890 |
by blast |
|
1891 |
then have Mxne: "?Mx \<noteq> {}" |
|
1892 |
by blast |
|
1893 |
have xMS: "?xM \<subseteq> S" |
|
1894 |
by blast |
|
1895 |
then have fxM: "finite ?xM" |
|
1896 |
using fS finite_subset by auto |
|
1897 |
from xu uinS have linxM: "u \<in> ?xM" |
|
1898 |
by blast |
|
1899 |
then have xMne: "?xM \<noteq> {}" |
|
1900 |
by blast |
|
1901 |
have ax:"?a \<le> x" |
|
1902 |
using Mxne fMx by auto |
|
1903 |
have xb:"x \<le> ?b" |
|
1904 |
using xMne fxM by auto |
|
1905 |
have "?a \<in> ?Mx" |
|
1906 |
using Max_in[OF fMx Mxne] by simp |
|
1907 |
then have ainS: "?a \<in> S" |
|
1908 |
using MxS by blast |
|
1909 |
have "?b \<in> ?xM" |
|
1910 |
using Min_in[OF fxM xMne] by simp |
|
1911 |
then have binS: "?b \<in> S" |
|
1912 |
using xMS by blast |
|
1913 |
have noy: "\<forall>y. ?a < y \<and> y < ?b \<longrightarrow> y \<notin> S" |
|
1914 |
proof clarsimp |
|
29789 | 1915 |
fix y |
1916 |
assume ay: "?a < y" and yb: "y < ?b" and yS: "y \<in> S" |
|
60711 | 1917 |
from yS consider "y \<in> ?Mx" | "y \<in> ?xM" |
1918 |
by atomize_elim auto |
|
1919 |
then show False |
|
1920 |
proof cases |
|
1921 |
case 1 |
|
1922 |
then have "y \<le> ?a" |
|
1923 |
using Mxne fMx by auto |
|
1924 |
with ay show ?thesis by simp |
|
1925 |
next |
|
1926 |
case 2 |
|
1927 |
then have "y \<ge> ?b" |
|
1928 |
using xMne fxM by auto |
|
1929 |
with yb show ?thesis by simp |
|
1930 |
qed |
|
29789 | 1931 |
qed |
60711 | 1932 |
from ainS binS noy ax xb px show ?thesis |
1933 |
by blast |
|
29789 | 1934 |
qed |
1935 |
||
1936 |
lemma rinf_uset: |
|
1937 |
assumes lp: "isrlfm p" |
|
60711 | 1938 |
and nmi: "\<not> (Ifm (x # bs) (minusinf p))" (is "\<not> (Ifm (x # bs) (?M p))") |
1939 |
and npi: "\<not> (Ifm (x # bs) (plusinf p))" (is "\<not> (Ifm (x # bs) (?P p))") |
|
1940 |
and ex: "\<exists>x. Ifm (x # bs) p" (is "\<exists>x. ?I x p") |
|
1941 |
shows "\<exists>(l,n) \<in> set (uset p). \<exists>(s,m) \<in> set (uset p). |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1942 |
?I ((Inum (x#bs) l / real_of_int n + Inum (x#bs) s / real_of_int m) / 2) p" |
60710 | 1943 |
proof - |
60711 | 1944 |
let ?N = "\<lambda>x t. Inum (x # bs) t" |
29789 | 1945 |
let ?U = "set (uset p)" |
60711 | 1946 |
from ex obtain a where pa: "?I a p" |
1947 |
by blast |
|
29789 | 1948 |
from bound0_I[OF rminusinf_bound0[OF lp], where bs="bs" and b="x" and b'="a"] nmi |
60711 | 1949 |
have nmi': "\<not> (?I a (?M p))" |
1950 |
by simp |
|
29789 | 1951 |
from bound0_I[OF rplusinf_bound0[OF lp], where bs="bs" and b="x" and b'="a"] npi |
60711 | 1952 |
have npi': "\<not> (?I a (?P p))" |
1953 |
by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1954 |
have "\<exists>(l,n) \<in> set (uset p). \<exists>(s,m) \<in> set (uset p). ?I ((?N a l/real_of_int n + ?N a s /real_of_int m) / 2) p" |
60710 | 1955 |
proof - |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1956 |
let ?M = "(\<lambda>(t,c). ?N a t / real_of_int c) ` ?U" |
60711 | 1957 |
have fM: "finite ?M" |
1958 |
by auto |
|
60710 | 1959 |
from rminusinf_uset[OF lp nmi pa] rplusinf_uset[OF lp npi pa] |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1960 |
have "\<exists>(l,n) \<in> set (uset p). \<exists>(s,m) \<in> set (uset p). a \<le> ?N x l / real_of_int n \<and> a \<ge> ?N x s / real_of_int m" |
60711 | 1961 |
by blast |
1962 |
then obtain "t" "n" "s" "m" |
|
1963 |
where tnU: "(t,n) \<in> ?U" |
|
1964 |
and smU: "(s,m) \<in> ?U" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1965 |
and xs1: "a \<le> ?N x s / real_of_int m" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1966 |
and tx1: "a \<ge> ?N x t / real_of_int n" |
60711 | 1967 |
by blast |
1968 |
from uset_l[OF lp] tnU smU numbound0_I[where bs="bs" and b="x" and b'="a"] xs1 tx1 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1969 |
have xs: "a \<le> ?N a s / real_of_int m" and tx: "a \<ge> ?N a t / real_of_int n" |
60711 | 1970 |
by auto |
1971 |
from tnU have Mne: "?M \<noteq> {}" |
|
1972 |
by auto |
|
1973 |
then have Une: "?U \<noteq> {}" |
|
1974 |
by simp |
|
29789 | 1975 |
let ?l = "Min ?M" |
1976 |
let ?u = "Max ?M" |
|
60711 | 1977 |
have linM: "?l \<in> ?M" |
1978 |
using fM Mne by simp |
|
1979 |
have uinM: "?u \<in> ?M" |
|
1980 |
using fM Mne by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1981 |
have tnM: "?N a t / real_of_int n \<in> ?M" |
60711 | 1982 |
using tnU by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1983 |
have smM: "?N a s / real_of_int m \<in> ?M" |
60711 | 1984 |
using smU by auto |
1985 |
have lM: "\<forall>t\<in> ?M. ?l \<le> t" |
|
1986 |
using Mne fM by auto |
|
1987 |
have Mu: "\<forall>t\<in> ?M. t \<le> ?u" |
|
1988 |
using Mne fM by auto |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1989 |
have "?l \<le> ?N a t / real_of_int n" |
60711 | 1990 |
using tnM Mne by simp |
1991 |
then have lx: "?l \<le> a" |
|
1992 |
using tx by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
1993 |
have "?N a s / real_of_int m \<le> ?u" |
60711 | 1994 |
using smM Mne by simp |
1995 |
then have xu: "a \<le> ?u" |
|
1996 |
using xs by simp |
|
60710 | 1997 |
from finite_set_intervals2[where P="\<lambda>x. ?I x p",OF pa lx xu linM uinM fM lM Mu] |
60711 | 1998 |
consider u where "u \<in> ?M" "?I u p" |
1999 |
| t1 t2 where "t1 \<in> ?M" "t2 \<in> ?M" "\<forall>y. t1 < y \<and> y < t2 \<longrightarrow> y \<notin> ?M" "t1 < a" "a < t2" "?I a p" |
|
2000 |
by blast |
|
2001 |
then show ?thesis |
|
2002 |
proof cases |
|
2003 |
case 1 |
|
2004 |
note um = \<open>u \<in> ?M\<close> and pu = \<open>?I u p\<close> |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2005 |
then have "\<exists>(tu,nu) \<in> ?U. u = ?N a tu / real_of_int nu" |
60711 | 2006 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2007 |
then obtain tu nu where tuU: "(tu, nu) \<in> ?U" and tuu: "u= ?N a tu / real_of_int nu" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
2008 |
by blast |
60711 | 2009 |
have "(u + u) / 2 = u" |
2010 |
by auto |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2011 |
with pu tuu have "?I (((?N a tu / real_of_int nu) + (?N a tu / real_of_int nu)) / 2) p" |
60711 | 2012 |
by simp |
2013 |
with tuU show ?thesis by blast |
|
2014 |
next |
|
2015 |
case 2 |
|
2016 |
note t1M = \<open>t1 \<in> ?M\<close> and t2M = \<open>t2\<in> ?M\<close> |
|
2017 |
and noM = \<open>\<forall>y. t1 < y \<and> y < t2 \<longrightarrow> y \<notin> ?M\<close> |
|
2018 |
and t1x = \<open>t1 < a\<close> and xt2 = \<open>a < t2\<close> and px = \<open>?I a p\<close> |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2019 |
from t1M have "\<exists>(t1u,t1n) \<in> ?U. t1 = ?N a t1u / real_of_int t1n" |
60711 | 2020 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2021 |
then obtain t1u t1n where t1uU: "(t1u, t1n) \<in> ?U" and t1u: "t1 = ?N a t1u / real_of_int t1n" |
60711 | 2022 |
by blast |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2023 |
from t2M have "\<exists>(t2u,t2n) \<in> ?U. t2 = ?N a t2u / real_of_int t2n" |
60711 | 2024 |
by auto |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2025 |
then obtain t2u t2n where t2uU: "(t2u, t2n) \<in> ?U" and t2u: "t2 = ?N a t2u / real_of_int t2n" |
60711 | 2026 |
by blast |
2027 |
from t1x xt2 have t1t2: "t1 < t2" |
|
2028 |
by simp |
|
29789 | 2029 |
let ?u = "(t1 + t2) / 2" |
60711 | 2030 |
from less_half_sum[OF t1t2] gt_half_sum[OF t1t2] have t1lu: "t1 < ?u" and ut2: "?u < t2" |
2031 |
by auto |
|
29789 | 2032 |
from lin_dense[OF lp noM t1x xt2 px t1lu ut2] have "?I ?u p" . |
60711 | 2033 |
with t1uU t2uU t1u t2u show ?thesis |
2034 |
by blast |
|
2035 |
qed |
|
29789 | 2036 |
qed |
60711 | 2037 |
then obtain l n s m where lnU: "(l, n) \<in> ?U" and smU:"(s, m) \<in> ?U" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2038 |
and pu: "?I ((?N a l / real_of_int n + ?N a s / real_of_int m) / 2) p" |
60711 | 2039 |
by blast |
2040 |
from lnU smU uset_l[OF lp] have nbl: "numbound0 l" and nbs: "numbound0 s" |
|
2041 |
by auto |
|
60710 | 2042 |
from numbound0_I[OF nbl, where bs="bs" and b="a" and b'="x"] |
29789 | 2043 |
numbound0_I[OF nbs, where bs="bs" and b="a" and b'="x"] pu |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2044 |
have "?I ((?N x l / real_of_int n + ?N x s / real_of_int m) / 2) p" |
60711 | 2045 |
by simp |
2046 |
with lnU smU show ?thesis |
|
2047 |
by auto |
|
29789 | 2048 |
qed |
60711 | 2049 |
|
2050 |
||
29789 | 2051 |
(* The Ferrante - Rackoff Theorem *) |
2052 |
||
60710 | 2053 |
theorem fr_eq: |
29789 | 2054 |
assumes lp: "isrlfm p" |
60711 | 2055 |
shows "(\<exists>x. Ifm (x#bs) p) \<longleftrightarrow> |
2056 |
Ifm (x # bs) (minusinf p) \<or> Ifm (x # bs) (plusinf p) \<or> |
|
2057 |
(\<exists>(t,n) \<in> set (uset p). \<exists>(s,m) \<in> set (uset p). |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2058 |
Ifm ((((Inum (x # bs) t) / real_of_int n + (Inum (x # bs) s) / real_of_int m) / 2) # bs) p)" |
60711 | 2059 |
(is "(\<exists>x. ?I x p) \<longleftrightarrow> (?M \<or> ?P \<or> ?F)" is "?E = ?D") |
29789 | 2060 |
proof |
60710 | 2061 |
assume px: "\<exists>x. ?I x p" |
60711 | 2062 |
consider "?M \<or> ?P" | "\<not> ?M" "\<not> ?P" by blast |
2063 |
then show ?D |
|
2064 |
proof cases |
|
2065 |
case 1 |
|
2066 |
then show ?thesis by blast |
|
2067 |
next |
|
2068 |
case 2 |
|
2069 |
from rinf_uset[OF lp this] have ?F |
|
2070 |
using px by blast |
|
2071 |
then show ?thesis by blast |
|
2072 |
qed |
|
29789 | 2073 |
next |
60711 | 2074 |
assume ?D |
2075 |
then consider ?M | ?P | ?F by blast |
|
2076 |
then show ?E |
|
2077 |
proof cases |
|
2078 |
case 1 |
|
2079 |
from rminusinf_ex[OF lp this] show ?thesis . |
|
2080 |
next |
|
2081 |
case 2 |
|
2082 |
from rplusinf_ex[OF lp this] show ?thesis . |
|
2083 |
next |
|
2084 |
case 3 |
|
2085 |
then show ?thesis by blast |
|
2086 |
qed |
|
29789 | 2087 |
qed |
2088 |
||
2089 |
||
60710 | 2090 |
lemma fr_equsubst: |
29789 | 2091 |
assumes lp: "isrlfm p" |
60711 | 2092 |
shows "(\<exists>x. Ifm (x # bs) p) \<longleftrightarrow> |
2093 |
(Ifm (x # bs) (minusinf p) \<or> Ifm (x # bs) (plusinf p) \<or> |
|
2094 |
(\<exists>(t,k) \<in> set (uset p). \<exists>(s,l) \<in> set (uset p). |
|
2095 |
Ifm (x#bs) (usubst p (Add (Mul l t) (Mul k s), 2 * k * l))))" |
|
2096 |
(is "(\<exists>x. ?I x p) \<longleftrightarrow> ?M \<or> ?P \<or> ?F" is "?E = ?D") |
|
29789 | 2097 |
proof |
60710 | 2098 |
assume px: "\<exists>x. ?I x p" |
60711 | 2099 |
consider "?M \<or> ?P" | "\<not> ?M" "\<not> ?P" by blast |
2100 |
then show ?D |
|
2101 |
proof cases |
|
2102 |
case 1 |
|
2103 |
then show ?thesis by blast |
|
2104 |
next |
|
2105 |
case 2 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2106 |
let ?f = "\<lambda>(t,n). Inum (x # bs) t / real_of_int n" |
60711 | 2107 |
let ?N = "\<lambda>t. Inum (x # bs) t" |
2108 |
{ |
|
2109 |
fix t n s m |
|
2110 |
assume "(t, n) \<in> set (uset p)" and "(s, m) \<in> set (uset p)" |
|
2111 |
with uset_l[OF lp] have tnb: "numbound0 t" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2112 |
and np: "real_of_int n > 0" and snb: "numbound0 s" and mp: "real_of_int m > 0" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
2113 |
by auto |
29789 | 2114 |
let ?st = "Add (Mul m t) (Mul n s)" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2115 |
from np mp have mnp: "real_of_int (2 * n * m) > 0" |
60711 | 2116 |
by (simp add: mult.commute) |
2117 |
from tnb snb have st_nb: "numbound0 ?st" |
|
2118 |
by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2119 |
have st: "(?N t / real_of_int n + ?N s / real_of_int m) / 2 = ?N ?st / real_of_int (2 * n * m)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32642
diff
changeset
|
2120 |
using mnp mp np by (simp add: algebra_simps add_divide_distrib) |
60710 | 2121 |
from usubst_I[OF lp mnp st_nb, where x="x" and bs="bs"] |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2122 |
have "?I x (usubst p (?st, 2 * n * m)) = ?I ((?N t / real_of_int n + ?N s / real_of_int m) / 2) p" |
60711 | 2123 |
by (simp only: st[symmetric]) |
2124 |
} |
|
2125 |
with rinf_uset[OF lp 2 px] have ?F |
|
2126 |
by blast |
|
2127 |
then show ?thesis |
|
2128 |
by blast |
|
2129 |
qed |
|
29789 | 2130 |
next |
60711 | 2131 |
assume ?D |
2132 |
then consider ?M | ?P | t k s l where "(t, k) \<in> set (uset p)" "(s, l) \<in> set (uset p)" |
|
2133 |
"?I x (usubst p (Add (Mul l t) (Mul k s), 2 * k * l))" |
|
2134 |
by blast |
|
2135 |
then show ?E |
|
2136 |
proof cases |
|
2137 |
case 1 |
|
2138 |
from rminusinf_ex[OF lp this] show ?thesis . |
|
2139 |
next |
|
2140 |
case 2 |
|
2141 |
from rplusinf_ex[OF lp this] show ?thesis . |
|
2142 |
next |
|
2143 |
case 3 |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2144 |
with uset_l[OF lp] have tnb: "numbound0 t" and np: "real_of_int k > 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2145 |
and snb: "numbound0 s" and mp: "real_of_int l > 0" |
60711 | 2146 |
by auto |
29789 | 2147 |
let ?st = "Add (Mul l t) (Mul k s)" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2148 |
from np mp have mnp: "real_of_int (2 * k * l) > 0" |
60711 | 2149 |
by (simp add: mult.commute) |
2150 |
from tnb snb have st_nb: "numbound0 ?st" |
|
2151 |
by simp |
|
2152 |
from usubst_I[OF lp mnp st_nb, where bs="bs"] |
|
2153 |
\<open>?I x (usubst p (Add (Mul l t) (Mul k s), 2 * k * l))\<close> show ?thesis |
|
2154 |
by auto |
|
2155 |
qed |
|
29789 | 2156 |
qed |
2157 |
||
2158 |
||
2159 |
(* Implement the right hand side of Ferrante and Rackoff's Theorem. *) |
|
60711 | 2160 |
definition ferrack :: "fm \<Rightarrow> fm" |
2161 |
where |
|
2162 |
"ferrack p = |
|
2163 |
(let |
|
2164 |
p' = rlfm (simpfm p); |
|
2165 |
mp = minusinf p'; |
|
2166 |
pp = plusinf p' |
|
2167 |
in |
|
2168 |
if mp = T \<or> pp = T then T |
|
2169 |
else |
|
2170 |
(let U = remdups (map simp_num_pair |
|
2171 |
(map (\<lambda>((t,n),(s,m)). (Add (Mul m t) (Mul n s) , 2 * n * m)) |
|
2172 |
(alluopairs (uset p')))) |
|
2173 |
in decr (disj mp (disj pp (evaldjf (simpfm \<circ> usubst p') U)))))" |
|
29789 | 2174 |
|
2175 |
lemma uset_cong_aux: |
|
60711 | 2176 |
assumes Ul: "\<forall>(t,n) \<in> set U. numbound0 t \<and> n > 0" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2177 |
shows "((\<lambda>(t,n). Inum (x # bs) t / real_of_int n) ` |
60711 | 2178 |
(set (map (\<lambda>((t,n),(s,m)). (Add (Mul m t) (Mul n s), 2 * n * m)) (alluopairs U)))) = |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2179 |
((\<lambda>((t,n),(s,m)). (Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m) / 2) ` (set U \<times> set U))" |
29789 | 2180 |
(is "?lhs = ?rhs") |
60711 | 2181 |
proof auto |
29789 | 2182 |
fix t n s m |
60711 | 2183 |
assume "((t, n), (s, m)) \<in> set (alluopairs U)" |
2184 |
then have th: "((t, n), (s, m)) \<in> set U \<times> set U" |
|
29789 | 2185 |
using alluopairs_set1[where xs="U"] by blast |
60711 | 2186 |
let ?N = "\<lambda>t. Inum (x # bs) t" |
2187 |
let ?st = "Add (Mul m t) (Mul n s)" |
|
2188 |
from Ul th have mnz: "m \<noteq> 0" |
|
2189 |
by auto |
|
2190 |
from Ul th have nnz: "n \<noteq> 0" |
|
2191 |
by auto |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2192 |
have st: "(?N t / real_of_int n + ?N s / real_of_int m) / 2 = ?N ?st / real_of_int (2 * n * m)" |
60711 | 2193 |
using mnz nnz by (simp add: algebra_simps add_divide_distrib) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2194 |
then show "(real_of_int m * Inum (x # bs) t + real_of_int n * Inum (x # bs) s) / (2 * real_of_int n * real_of_int m) |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2195 |
\<in> (\<lambda>((t, n), s, m). (Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m) / 2) ` |
60711 | 2196 |
(set U \<times> set U)" |
2197 |
using mnz nnz th |
|
29789 | 2198 |
apply (auto simp add: th add_divide_distrib algebra_simps split_def image_def) |
60711 | 2199 |
apply (rule_tac x="(s,m)" in bexI) |
2200 |
apply simp_all |
|
2201 |
apply (rule_tac x="(t,n)" in bexI) |
|
2202 |
apply (simp_all add: mult.commute) |
|
2203 |
done |
|
29789 | 2204 |
next |
2205 |
fix t n s m |
|
60711 | 2206 |
assume tnU: "(t, n) \<in> set U" and smU: "(s, m) \<in> set U" |
2207 |
let ?N = "\<lambda>t. Inum (x # bs) t" |
|
2208 |
let ?st = "Add (Mul m t) (Mul n s)" |
|
2209 |
from Ul smU have mnz: "m \<noteq> 0" |
|
2210 |
by auto |
|
2211 |
from Ul tnU have nnz: "n \<noteq> 0" |
|
2212 |
by auto |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2213 |
have st: "(?N t / real_of_int n + ?N s / real_of_int m) / 2 = ?N ?st / real_of_int (2 * n * m)" |
60711 | 2214 |
using mnz nnz by (simp add: algebra_simps add_divide_distrib) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2215 |
let ?P = "\<lambda>(t',n') (s',m'). (Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m)/2 = |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2216 |
(Inum (x # bs) t' / real_of_int n' + Inum (x # bs) s' / real_of_int m') / 2" |
60711 | 2217 |
have Pc:"\<forall>a b. ?P a b = ?P b a" |
2218 |
by auto |
|
2219 |
from Ul alluopairs_set1 have Up:"\<forall>((t,n),(s,m)) \<in> set (alluopairs U). n \<noteq> 0 \<and> m \<noteq> 0" |
|
2220 |
by blast |
|
2221 |
from alluopairs_ex[OF Pc, where xs="U"] tnU smU |
|
2222 |
have th':"\<exists>((t',n'),(s',m')) \<in> set (alluopairs U). ?P (t',n') (s',m')" |
|
2223 |
by blast |
|
2224 |
then obtain t' n' s' m' where ts'_U: "((t',n'),(s',m')) \<in> set (alluopairs U)" |
|
2225 |
and Pts': "?P (t', n') (s', m')" |
|
2226 |
by blast |
|
2227 |
from ts'_U Up have mnz': "m' \<noteq> 0" and nnz': "n'\<noteq> 0" |
|
2228 |
by auto |
|
2229 |
let ?st' = "Add (Mul m' t') (Mul n' s')" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2230 |
have st': "(?N t' / real_of_int n' + ?N s' / real_of_int m') / 2 = ?N ?st' / real_of_int (2 * n' * m')" |
60711 | 2231 |
using mnz' nnz' by (simp add: algebra_simps add_divide_distrib) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2232 |
from Pts' have "(Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m) / 2 = |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2233 |
(Inum (x # bs) t' / real_of_int n' + Inum (x # bs) s' / real_of_int m') / 2" |
60711 | 2234 |
by simp |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2235 |
also have "\<dots> = (\<lambda>(t, n). Inum (x # bs) t / real_of_int n) |
60711 | 2236 |
((\<lambda>((t, n), s, m). (Add (Mul m t) (Mul n s), 2 * n * m)) ((t', n'), (s', m')))" |
2237 |
by (simp add: st') |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2238 |
finally show "(Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m) / 2 |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2239 |
\<in> (\<lambda>(t, n). Inum (x # bs) t / real_of_int n) ` |
60711 | 2240 |
(\<lambda>((t, n), s, m). (Add (Mul m t) (Mul n s), 2 * n * m)) ` set (alluopairs U)" |
2241 |
using ts'_U by blast |
|
29789 | 2242 |
qed |
2243 |
||
2244 |
lemma uset_cong: |
|
2245 |
assumes lp: "isrlfm p" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2246 |
and UU': "((\<lambda>(t,n). Inum (x # bs) t / real_of_int n) ` U') = |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2247 |
((\<lambda>((t,n),(s,m)). (Inum (x # bs) t / real_of_int n + Inum (x # bs) s / real_of_int m) / 2) ` (U \<times> U))" |
60711 | 2248 |
(is "?f ` U' = ?g ` (U \<times> U)") |
2249 |
and U: "\<forall>(t,n) \<in> U. numbound0 t \<and> n > 0" |
|
2250 |
and U': "\<forall>(t,n) \<in> U'. numbound0 t \<and> n > 0" |
|
2251 |
shows "(\<exists>(t,n) \<in> U. \<exists>(s,m) \<in> U. Ifm (x # bs) (usubst p (Add (Mul m t) (Mul n s), 2 * n * m))) = |
|
2252 |
(\<exists>(t,n) \<in> U'. Ifm (x # bs) (usubst p (t, n)))" |
|
2253 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
29789 | 2254 |
proof |
60711 | 2255 |
show ?rhs if ?lhs |
2256 |
proof - |
|
2257 |
from that obtain t n s m where tnU: "(t, n) \<in> U" and smU: "(s, m) \<in> U" |
|
2258 |
and Pst: "Ifm (x # bs) (usubst p (Add (Mul m t) (Mul n s), 2 * n * m))" |
|
2259 |
by blast |
|
2260 |
let ?N = "\<lambda>t. Inum (x#bs) t" |
|
2261 |
from tnU smU U have tnb: "numbound0 t" and np: "n > 0" |
|
2262 |
and snb: "numbound0 s" and mp: "m > 0" |
|
2263 |
by auto |
|
2264 |
let ?st = "Add (Mul m t) (Mul n s)" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2265 |
from np mp have mnp: "real_of_int (2 * n * m) > 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2266 |
by (simp add: mult.commute of_int_mult[symmetric] del: of_int_mult) |
60711 | 2267 |
from tnb snb have stnb: "numbound0 ?st" |
2268 |
by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2269 |
have st: "(?N t / real_of_int n + ?N s / real_of_int m) / 2 = ?N ?st / real_of_int (2 * n * m)" |
60711 | 2270 |
using mp np by (simp add: algebra_simps add_divide_distrib) |
2271 |
from tnU smU UU' have "?g ((t, n), (s, m)) \<in> ?f ` U'" |
|
2272 |
by blast |
|
2273 |
then have "\<exists>(t',n') \<in> U'. ?g ((t, n), (s, m)) = ?f (t', n')" |
|
2274 |
apply auto |
|
2275 |
apply (rule_tac x="(a, b)" in bexI) |
|
2276 |
apply auto |
|
2277 |
done |
|
2278 |
then obtain t' n' where tnU': "(t',n') \<in> U'" and th: "?g ((t, n), (s, m)) = ?f (t', n')" |
|
2279 |
by blast |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2280 |
from U' tnU' have tnb': "numbound0 t'" and np': "real_of_int n' > 0" |
60711 | 2281 |
by auto |
2282 |
from usubst_I[OF lp mnp stnb, where bs="bs" and x="x"] Pst |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2283 |
have Pst2: "Ifm (Inum (x # bs) (Add (Mul m t) (Mul n s)) / real_of_int (2 * n * m) # bs) p" |
60711 | 2284 |
by simp |
2285 |
from conjunct1[OF usubst_I[OF lp np' tnb', where bs="bs" and x="x"], symmetric] |
|
2286 |
th[simplified split_def fst_conv snd_conv,symmetric] Pst2[simplified st[symmetric]] |
|
2287 |
have "Ifm (x # bs) (usubst p (t', n'))" |
|
2288 |
by (simp only: st) |
|
2289 |
then show ?thesis |
|
2290 |
using tnU' by auto |
|
2291 |
qed |
|
2292 |
show ?lhs if ?rhs |
|
2293 |
proof - |
|
2294 |
from that obtain t' n' where tnU': "(t', n') \<in> U'" and Pt': "Ifm (x # bs) (usubst p (t', n'))" |
|
2295 |
by blast |
|
2296 |
from tnU' UU' have "?f (t', n') \<in> ?g ` (U \<times> U)" |
|
2297 |
by blast |
|
2298 |
then have "\<exists>((t,n),(s,m)) \<in> U \<times> U. ?f (t', n') = ?g ((t, n), (s, m))" |
|
2299 |
apply auto |
|
2300 |
apply (rule_tac x="(a,b)" in bexI) |
|
2301 |
apply auto |
|
2302 |
done |
|
2303 |
then obtain t n s m where tnU: "(t, n) \<in> U" and smU: "(s, m) \<in> U" and |
|
2304 |
th: "?f (t', n') = ?g ((t, n), (s, m))" |
|
2305 |
by blast |
|
2306 |
let ?N = "\<lambda>t. Inum (x # bs) t" |
|
2307 |
from tnU smU U have tnb: "numbound0 t" and np: "n > 0" |
|
2308 |
and snb: "numbound0 s" and mp: "m > 0" |
|
2309 |
by auto |
|
2310 |
let ?st = "Add (Mul m t) (Mul n s)" |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2311 |
from np mp have mnp: "real_of_int (2 * n * m) > 0" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2312 |
by (simp add: mult.commute of_int_mult[symmetric] del: of_int_mult) |
60711 | 2313 |
from tnb snb have stnb: "numbound0 ?st" |
2314 |
by simp |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2315 |
have st: "(?N t / real_of_int n + ?N s / real_of_int m) / 2 = ?N ?st / real_of_int (2 * n * m)" |
60711 | 2316 |
using mp np by (simp add: algebra_simps add_divide_distrib) |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2317 |
from U' tnU' have tnb': "numbound0 t'" and np': "real_of_int n' > 0" |
60711 | 2318 |
by auto |
2319 |
from usubst_I[OF lp np' tnb', where bs="bs" and x="x",simplified |
|
2320 |
th[simplified split_def fst_conv snd_conv] st] Pt' |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2321 |
have Pst2: "Ifm (Inum (x # bs) (Add (Mul m t) (Mul n s)) / real_of_int (2 * n * m) # bs) p" |
60711 | 2322 |
by simp |
2323 |
with usubst_I[OF lp mnp stnb, where x="x" and bs="bs"] tnU smU |
|
2324 |
show ?thesis by blast |
|
2325 |
qed |
|
29789 | 2326 |
qed |
2327 |
||
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2328 |
lemma ferrack: |
29789 | 2329 |
assumes qf: "qfree p" |
60711 | 2330 |
shows "qfree (ferrack p) \<and> (Ifm bs (ferrack p) \<longleftrightarrow> (\<exists>x. Ifm (x # bs) p))" |
2331 |
(is "_ \<and> (?rhs \<longleftrightarrow> ?lhs)") |
|
60710 | 2332 |
proof - |
60711 | 2333 |
let ?I = "\<lambda>x p. Ifm (x # bs) p" |
29789 | 2334 |
fix x |
60711 | 2335 |
let ?N = "\<lambda>t. Inum (x # bs) t" |
60710 | 2336 |
let ?q = "rlfm (simpfm p)" |
29789 | 2337 |
let ?U = "uset ?q" |
2338 |
let ?Up = "alluopairs ?U" |
|
60711 | 2339 |
let ?g = "\<lambda>((t,n),(s,m)). (Add (Mul m t) (Mul n s), 2 * n * m)" |
29789 | 2340 |
let ?S = "map ?g ?Up" |
2341 |
let ?SS = "map simp_num_pair ?S" |
|
36853 | 2342 |
let ?Y = "remdups ?SS" |
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2343 |
let ?f = "\<lambda>(t,n). ?N t / real_of_int n" |
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2344 |
let ?h = "\<lambda>((t,n),(s,m)). (?N t / real_of_int n + ?N s / real_of_int m) / 2" |
60711 | 2345 |
let ?F = "\<lambda>p. \<exists>a \<in> set (uset p). \<exists>b \<in> set (uset p). ?I x (usubst p (?g (a, b)))" |
60710 | 2346 |
let ?ep = "evaldjf (simpfm \<circ> (usubst ?q)) ?Y" |
60711 | 2347 |
from rlfm_I[OF simpfm_qf[OF qf]] have lq: "isrlfm ?q" |
2348 |
by blast |
|
2349 |
from alluopairs_set1[where xs="?U"] have UpU: "set ?Up \<subseteq> set ?U \<times> set ?U" |
|
2350 |
by simp |
|
60710 | 2351 |
from uset_l[OF lq] have U_l: "\<forall>(t,n) \<in> set ?U. numbound0 t \<and> n > 0" . |
2352 |
from U_l UpU |
|
60711 | 2353 |
have "\<forall>((t,n),(s,m)) \<in> set ?Up. numbound0 t \<and> n> 0 \<and> numbound0 s \<and> m > 0" |
2354 |
by auto |
|
2355 |
then have Snb: "\<forall>(t,n) \<in> set ?S. numbound0 t \<and> n > 0 " |
|
2356 |
by auto |
|
60710 | 2357 |
have Y_l: "\<forall>(t,n) \<in> set ?Y. numbound0 t \<and> n > 0" |
2358 |
proof - |
|
60711 | 2359 |
have "numbound0 t \<and> n > 0" if tnY: "(t, n) \<in> set ?Y" for t n |
2360 |
proof - |
|
2361 |
from that have "(t,n) \<in> set ?SS" |
|
2362 |
by simp |
|
2363 |
then have "\<exists>(t',n') \<in> set ?S. simp_num_pair (t', n') = (t, n)" |
|
2364 |
apply (auto simp add: split_def simp del: map_map) |
|
2365 |
apply (rule_tac x="((aa,ba),(ab,bb))" in bexI) |
|
2366 |
apply simp_all |
|
2367 |
done |
|
2368 |
then obtain t' n' where tn'S: "(t', n') \<in> set ?S" and tns: "simp_num_pair (t', n') = (t, n)" |
|
2369 |
by blast |
|
2370 |
from tn'S Snb have tnb: "numbound0 t'" and np: "n' > 0" |
|
2371 |
by auto |
|
2372 |
from simp_num_pair_l[OF tnb np tns] show ?thesis . |
|
2373 |
qed |
|
60710 | 2374 |
then show ?thesis by blast |
29789 | 2375 |
qed |
2376 |
||
2377 |
have YU: "(?f ` set ?Y) = (?h ` (set ?U \<times> set ?U))" |
|
60710 | 2378 |
proof - |
60711 | 2379 |
from simp_num_pair_ci[where bs="x#bs"] have "\<forall>x. (?f \<circ> simp_num_pair) x = ?f x" |
2380 |
by auto |
|
2381 |
then have th: "?f \<circ> simp_num_pair = ?f" |
|
2382 |
by auto |
|
2383 |
have "(?f ` set ?Y) = ((?f \<circ> simp_num_pair) ` set ?S)" |
|
2384 |
by (simp add: comp_assoc image_comp) |
|
2385 |
also have "\<dots> = ?f ` set ?S" |
|
2386 |
by (simp add: th) |
|
2387 |
also have "\<dots> = (?f \<circ> ?g) ` set ?Up" |
|
56154
f0a927235162
more complete set of lemmas wrt. image and composition
haftmann
parents:
55422
diff
changeset
|
2388 |
by (simp only: set_map o_def image_comp) |
60711 | 2389 |
also have "\<dots> = ?h ` (set ?U \<times> set ?U)" |
2390 |
using uset_cong_aux[OF U_l, where x="x" and bs="bs", simplified set_map image_comp] |
|
2391 |
by blast |
|
29789 | 2392 |
finally show ?thesis . |
2393 |
qed |
|
60711 | 2394 |
have "\<forall>(t,n) \<in> set ?Y. bound0 (simpfm (usubst ?q (t, n)))" |
60710 | 2395 |
proof - |
60711 | 2396 |
have "bound0 (simpfm (usubst ?q (t, n)))" if tnY: "(t,n) \<in> set ?Y" for t n |
2397 |
proof - |
|
61609
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents:
61424
diff
changeset
|
2398 |
from Y_l that have tnb: "numbound0 t" and np: "real_of_int n > 0" |
60711 | 2399 |
by auto |
2400 |
from usubst_I[OF lq np tnb] have "bound0 (usubst ?q (t, n))" |
|
2401 |
by simp |
|
2402 |
then show ?thesis |
|
2403 |
using simpfm_bound0 by simp |
|
2404 |
qed |
|
60710 | 2405 |
then show ?thesis by blast |
29789 | 2406 |
qed |
60711 | 2407 |
then have ep_nb: "bound0 ?ep" |
2408 |
using evaldjf_bound0[where xs="?Y" and f="simpfm \<circ> (usubst ?q)"] by auto |
|
29789 | 2409 |
let ?mp = "minusinf ?q" |
2410 |
let ?pp = "plusinf ?q" |
|
2411 |
let ?M = "?I x ?mp" |
|
2412 |
let ?P = "?I x ?pp" |
|
2413 |
let ?res = "disj ?mp (disj ?pp ?ep)" |
|
60711 | 2414 |
from rminusinf_bound0[OF lq] rplusinf_bound0[OF lq] ep_nb have nbth: "bound0 ?res" |
2415 |
by auto |
|
29789 | 2416 |
|
60711 | 2417 |
from conjunct1[OF rlfm_I[OF simpfm_qf[OF qf]]] simpfm have th: "?lhs = (\<exists>x. ?I x ?q)" |
2418 |
by auto |
|
29789 | 2419 |
from th fr_equsubst[OF lq, where bs="bs" and x="x"] have lhfr: "?lhs = (?M \<or> ?P \<or> ?F ?q)" |
2420 |
by (simp only: split_def fst_conv snd_conv) |
|
60710 | 2421 |
also have "\<dots> = (?M \<or> ?P \<or> (\<exists>(t,n) \<in> set ?Y. ?I x (simpfm (usubst ?q (t,n)))))" |
60711 | 2422 |
using uset_cong[OF lq YU U_l Y_l] by (simp only: split_def fst_conv snd_conv simpfm) |
29789 | 2423 |
also have "\<dots> = (Ifm (x#bs) ?res)" |
60710 | 2424 |
using evaldjf_ex[where ps="?Y" and bs = "x#bs" and f="simpfm \<circ> (usubst ?q)",symmetric] |
61424
c3658c18b7bc
prod_case as canonical name for product type eliminator
haftmann
parents:
60767
diff
changeset
|
2425 |
by (simp add: split_def prod.collapse) |
60711 | 2426 |
finally have lheq: "?lhs = Ifm bs (decr ?res)" |
2427 |
using decr[OF nbth] by blast |
|
2428 |
then have lr: "?lhs = ?rhs" |
|
2429 |
unfolding ferrack_def Let_def |
|
29789 | 2430 |
by (cases "?mp = T \<or> ?pp = T", auto) (simp add: disj_def)+ |
60711 | 2431 |
from decr_qf[OF nbth] have "qfree (ferrack p)" |
2432 |
by (auto simp add: Let_def ferrack_def) |
|
2433 |
with lr show ?thesis |
|
2434 |
by blast |
|
29789 | 2435 |
qed |
2436 |
||
60711 | 2437 |
definition linrqe:: "fm \<Rightarrow> fm" |
2438 |
where "linrqe p = qelim (prep p) ferrack" |
|
29789 | 2439 |
|
2440 |
theorem linrqe: "Ifm bs (linrqe p) = Ifm bs p \<and> qfree (linrqe p)" |
|
60711 | 2441 |
using ferrack qelim_ci prep |
2442 |
unfolding linrqe_def by auto |
|
29789 | 2443 |
|
60711 | 2444 |
definition ferrack_test :: "unit \<Rightarrow> fm" |
2445 |
where |
|
2446 |
"ferrack_test u = |
|
2447 |
linrqe (A (A (Imp (Lt (Sub (Bound 1) (Bound 0))) |
|
2448 |
(E (Eq (Sub (Add (Bound 0) (Bound 2)) (Bound 1)))))))" |
|
29789 | 2449 |
|
60533 | 2450 |
ML_val \<open>@{code ferrack_test} ()\<close> |
29789 | 2451 |
|
60533 | 2452 |
oracle linr_oracle = \<open> |
29789 | 2453 |
let |
2454 |
||
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2455 |
val mk_C = @{code C} o @{code int_of_integer}; |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2456 |
val mk_Bound = @{code Bound} o @{code nat_of_integer}; |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2457 |
|
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2458 |
fun num_of_term vs (Free vT) = mk_Bound (find_index (fn vT' => vT = vT') vs) |
69597 | 2459 |
| num_of_term vs \<^term>\<open>real_of_int (0::int)\<close> = mk_C 0 |
2460 |
| num_of_term vs \<^term>\<open>real_of_int (1::int)\<close> = mk_C 1 |
|
74397 | 2461 |
| num_of_term vs \<^Const_>\<open>zero_class.zero \<^Type>\<open>real\<close>\<close> = mk_C 0 |
2462 |
| num_of_term vs \<^Const_>\<open>one_class.one \<^Type>\<open>real\<close>\<close> = mk_C 1 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2463 |
| num_of_term vs (Bound i) = mk_Bound i |
74397 | 2464 |
| num_of_term vs \<^Const_>\<open>uminus \<^Type>\<open>real\<close> for t'\<close> = @{code Neg} (num_of_term vs t') |
2465 |
| num_of_term vs \<^Const_>\<open>plus \<^Type>\<open>real\<close> for t1 t2\<close> = |
|
36853 | 2466 |
@{code Add} (num_of_term vs t1, num_of_term vs t2) |
74397 | 2467 |
| num_of_term vs \<^Const_>\<open>minus \<^Type>\<open>real\<close> for t1 t2\<close> = |
36853 | 2468 |
@{code Sub} (num_of_term vs t1, num_of_term vs t2) |
74397 | 2469 |
| num_of_term vs \<^Const_>\<open>times \<^Type>\<open>real\<close> for t1 t2\<close> = (case num_of_term vs t1 |
29789 | 2470 |
of @{code C} i => @{code Mul} (i, num_of_term vs t2) |
36853 | 2471 |
| _ => error "num_of_term: unsupported multiplication") |
69597 | 2472 |
| num_of_term vs (\<^term>\<open>real_of_int :: int \<Rightarrow> real\<close> $ t') = |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2473 |
(mk_C (snd (HOLogic.dest_number t')) |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46670
diff
changeset
|
2474 |
handle TERM _ => error ("num_of_term: unknown term")) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46670
diff
changeset
|
2475 |
| num_of_term vs t' = |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2476 |
(mk_C (snd (HOLogic.dest_number t')) |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46670
diff
changeset
|
2477 |
handle TERM _ => error ("num_of_term: unknown term")); |
29789 | 2478 |
|
74397 | 2479 |
fun fm_of_term vs \<^Const_>\<open>True\<close> = @{code T} |
2480 |
| fm_of_term vs \<^Const_>\<open>False\<close> = @{code F} |
|
2481 |
| fm_of_term vs \<^Const_>\<open>less \<^Type>\<open>real\<close> for t1 t2\<close> = |
|
36853 | 2482 |
@{code Lt} (@{code Sub} (num_of_term vs t1, num_of_term vs t2)) |
74397 | 2483 |
| fm_of_term vs \<^Const_>\<open>less_eq \<^Type>\<open>real\<close> for t1 t2\<close> = |
36853 | 2484 |
@{code Le} (@{code Sub} (num_of_term vs t1, num_of_term vs t2)) |
74397 | 2485 |
| fm_of_term vs \<^Const_>\<open>HOL.eq \<^Type>\<open>real\<close> for t1 t2\<close> = |
60710 | 2486 |
@{code Eq} (@{code Sub} (num_of_term vs t1, num_of_term vs t2)) |
74397 | 2487 |
| fm_of_term vs \<^Const_>\<open>HOL.eq \<^Type>\<open>bool\<close> for t1 t2\<close> = |
36853 | 2488 |
@{code Iff} (fm_of_term vs t1, fm_of_term vs t2) |
74397 | 2489 |
| fm_of_term vs \<^Const_>\<open>HOL.conj for t1 t2\<close> = @{code And} (fm_of_term vs t1, fm_of_term vs t2) |
2490 |
| fm_of_term vs \<^Const_>\<open>HOL.disj for t1 t2\<close> = @{code Or} (fm_of_term vs t1, fm_of_term vs t2) |
|
2491 |
| fm_of_term vs \<^Const_>\<open>HOL.implies for t1 t2\<close> = @{code Imp} (fm_of_term vs t1, fm_of_term vs t2) |
|
2492 |
| fm_of_term vs \<^Const_>\<open>HOL.Not for t'\<close> = @{code Not} (fm_of_term vs t') |
|
2493 |
| fm_of_term vs \<^Const_>\<open>Ex _ for \<open>Abs (xn, xT, p)\<close>\<close> = @{code E} (fm_of_term (("", dummyT) :: vs) p) |
|
2494 |
| fm_of_term vs \<^Const_>\<open>All _ for \<open>Abs (xn, xT, p)\<close>\<close> = @{code A} (fm_of_term (("", dummyT) :: vs) p) |
|
69597 | 2495 |
| fm_of_term vs t = error ("fm_of_term : unknown term " ^ Syntax.string_of_term \<^context> t); |
29789 | 2496 |
|
69597 | 2497 |
fun term_of_num vs (@{code C} i) = \<^term>\<open>real_of_int :: int \<Rightarrow> real\<close> $ |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2498 |
HOLogic.mk_number HOLogic.intT (@{code integer_of_int} i) |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
49962
diff
changeset
|
2499 |
| term_of_num vs (@{code Bound} n) = Free (nth vs (@{code integer_of_nat} n)) |
74397 | 2500 |
| term_of_num vs (@{code Neg} t') = \<^Const>\<open>uminus \<^Type>\<open>real\<close> for \<open>term_of_num vs t'\<close>\<close> |
2501 |
| term_of_num vs (@{code Add} (t1, t2)) = |
|
2502 |
\<^Const>\<open>plus \<^Type>\<open>real\<close> for \<open>term_of_num vs t1\<close> \<open>term_of_num vs t2\<close>\<close> |
|
2503 |
| term_of_num vs (@{code Sub} (t1, t2)) = |
|
2504 |
\<^Const>\<open>minus \<^Type>\<open>real\<close> for \<open>term_of_num vs t1\<close> \<open>term_of_num vs t2\<close>\<close> |
|
2505 |
| term_of_num vs (@{code Mul} (i, t2)) = |
|
2506 |
\<^Const>\<open>times \<^Type>\<open>real\<close> for \<open>term_of_num vs (@{code C} i)\<close> \<open>term_of_num vs t2\<close>\<close> |
|
29789 | 2507 |
| term_of_num vs (@{code CN} (n, i, t)) = term_of_num vs (@{code Add} (@{code Mul} (i, @{code Bound} n), t)); |
2508 |
||
74397 | 2509 |
fun term_of_fm vs @{code T} = \<^Const>\<open>True\<close> |
2510 |
| term_of_fm vs @{code F} = \<^Const>\<open>False\<close> |
|
2511 |
| term_of_fm vs (@{code Lt} t) = \<^Const>\<open>less \<^Type>\<open>real\<close> for \<open>term_of_num vs t\<close> \<^term>\<open>0::real\<close>\<close> |
|
2512 |
| term_of_fm vs (@{code Le} t) = \<^Const>\<open>less_eq \<^Type>\<open>real\<close> for \<open>term_of_num vs t\<close> \<^term>\<open>0::real\<close>\<close> |
|
2513 |
| term_of_fm vs (@{code Gt} t) = \<^Const>\<open>less \<^Type>\<open>real\<close> for \<^term>\<open>0::real\<close> \<open>term_of_num vs t\<close>\<close> |
|
2514 |
| term_of_fm vs (@{code Ge} t) = \<^Const>\<open>less_eq \<^Type>\<open>real\<close> for \<^term>\<open>0::real\<close> \<open>term_of_num vs t\<close>\<close> |
|
2515 |
| term_of_fm vs (@{code Eq} t) = \<^Const>\<open>HOL.eq \<^Type>\<open>real\<close> for \<open>term_of_num vs t\<close> \<^term>\<open>0::real\<close>\<close> |
|
74101 | 2516 |
| term_of_fm vs (@{code NEq} t) = term_of_fm vs (@{code Not} (@{code Eq} t)) |
74397 | 2517 |
| term_of_fm vs (@{code Not} t') = \<^Const>\<open>HOL.Not for \<open>term_of_fm vs t'\<close>\<close> |
2518 |
| term_of_fm vs (@{code And} (t1, t2)) = \<^Const>\<open>HOL.conj for \<open>term_of_fm vs t1\<close> \<open>term_of_fm vs t2\<close>\<close> |
|
2519 |
| term_of_fm vs (@{code Or} (t1, t2)) = \<^Const>\<open>HOL.disj for \<open>term_of_fm vs t1\<close> \<open>term_of_fm vs t2\<close>\<close> |
|
2520 |
| term_of_fm vs (@{code Imp} (t1, t2)) = \<^Const>\<open>HOL.implies for \<open>term_of_fm vs t1\<close> \<open>term_of_fm vs t2\<close>\<close> |
|
2521 |
| term_of_fm vs (@{code Iff} (t1, t2)) = \<^Const>\<open>HOL.eq \<^Type>\<open>bool\<close> for \<open>term_of_fm vs t1\<close> \<open>term_of_fm vs t2\<close>\<close> |
|
29789 | 2522 |
|
36853 | 2523 |
in fn (ctxt, t) => |
60710 | 2524 |
let |
36853 | 2525 |
val vs = Term.add_frees t []; |
2526 |
val t' = (term_of_fm vs o @{code linrqe} o fm_of_term vs) t; |
|
59621
291934bac95e
Thm.cterm_of and Thm.ctyp_of operate on local context;
wenzelm
parents:
59580
diff
changeset
|
2527 |
in (Thm.cterm_of ctxt o HOLogic.mk_Trueprop o HOLogic.mk_eq) (t, t') end |
69266
7cc2d66a92a6
proper ML expressions, without trailing semicolons;
wenzelm
parents:
69064
diff
changeset
|
2528 |
end |
60533 | 2529 |
\<close> |
29789 | 2530 |
|
69605 | 2531 |
ML_file \<open>ferrack_tac.ML\<close> |
47432 | 2532 |
|
60533 | 2533 |
method_setup rferrack = \<open> |
53168 | 2534 |
Scan.lift (Args.mode "no_quantify") >> |
47432 | 2535 |
(fn q => fn ctxt => SIMPLE_METHOD' (Ferrack_Tac.linr_tac ctxt (not q))) |
60533 | 2536 |
\<close> "decision procedure for linear real arithmetic" |
47432 | 2537 |
|
29789 | 2538 |
|
2539 |
lemma |
|
2540 |
fixes x :: real |
|
2541 |
shows "2 * x \<le> 2 * x \<and> 2 * x \<le> 2 * x + 1" |
|
49070 | 2542 |
by rferrack |
29789 | 2543 |
|
2544 |
lemma |
|
2545 |
fixes x :: real |
|
2546 |
shows "\<exists>y \<le> x. x = y + 1" |
|
49070 | 2547 |
by rferrack |
29789 | 2548 |
|
2549 |
lemma |
|
2550 |
fixes x :: real |
|
2551 |
shows "\<not> (\<exists>z. x + z = x + z + 1)" |
|
49070 | 2552 |
by rferrack |
29789 | 2553 |
|
2554 |
end |