3 This theory is about of the relative completeness of method comm-ring |
3 This theory is about of the relative completeness of method comm-ring |
4 method. As long as the reified atomic polynomials of type 'a pol are |
4 method. As long as the reified atomic polynomials of type 'a pol are |
5 in normal form, the cring method is complete. |
5 in normal form, the cring method is complete. |
6 *) |
6 *) |
7 |
7 |
8 section {* Proof of the relative completeness of method comm-ring *} |
8 section \<open>Proof of the relative completeness of method comm-ring\<close> |
9 |
9 |
10 theory Commutative_Ring_Complete |
10 theory Commutative_Ring_Complete |
11 imports Commutative_Ring |
11 imports Commutative_Ring |
12 begin |
12 begin |
13 |
13 |
14 text {* Formalization of normal form *} |
14 text \<open>Formalization of normal form\<close> |
15 fun isnorm :: "'a::comm_ring pol \<Rightarrow> bool" |
15 fun isnorm :: "'a::comm_ring pol \<Rightarrow> bool" |
16 where |
16 where |
17 "isnorm (Pc c) \<longleftrightarrow> True" |
17 "isnorm (Pc c) \<longleftrightarrow> True" |
18 | "isnorm (Pinj i (Pc c)) \<longleftrightarrow> False" |
18 | "isnorm (Pinj i (Pc c)) \<longleftrightarrow> False" |
19 | "isnorm (Pinj i (Pinj j Q)) \<longleftrightarrow> False" |
19 | "isnorm (Pinj i (Pinj j Q)) \<longleftrightarrow> False" |
123 by (auto simp add: norm_PX1[of P1 y P2] norm_PX2[of P1 y P2]) |
123 by (auto simp add: norm_PX1[of P1 y P2] norm_PX2[of P1 y P2]) |
124 from assms PX Y0 show ?thesis |
124 from assms PX Y0 show ?thesis |
125 by (cases x) (auto simp add: mkPX_def norm_PXtrans2[of P1 y _ Q _], cases P2, auto) |
125 by (cases x) (auto simp add: mkPX_def norm_PXtrans2[of P1 y _ Q _], cases P2, auto) |
126 qed |
126 qed |
127 |
127 |
128 text {* add conserves normalizedness *} |
128 text \<open>add conserves normalizedness\<close> |
129 lemma add_cn: "isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<oplus> Q)" |
129 lemma add_cn: "isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<oplus> Q)" |
130 proof (induct P Q rule: add.induct) |
130 proof (induct P Q rule: add.induct) |
131 case (2 c i P2) |
131 case (2 c i P2) |
132 then show ?case |
132 then show ?case |
133 by (cases P2) (simp_all, cases i, simp_all) |
133 by (cases P2) (simp_all, cases i, simp_all) |
162 note 6 X0 |
162 note 6 X0 |
163 moreover |
163 moreover |
164 from 6 have "isnorm P2" "isnorm Q2" |
164 from 6 have "isnorm P2" "isnorm Q2" |
165 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
165 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
166 moreover |
166 moreover |
167 from 6 `x < y` y have "isnorm (Pinj d Q2)" |
167 from 6 \<open>x < y\<close> y have "isnorm (Pinj d Q2)" |
168 by (cases d, simp, cases Q2, auto) |
168 by (cases d, simp, cases Q2, auto) |
169 ultimately have ?case by (simp add: mkPinj_cn) |
169 ultimately have ?case by (simp add: mkPinj_cn) |
170 } |
170 } |
171 moreover { |
171 moreover { |
172 assume "x = y" |
172 assume "x = y" |
186 note 6 Y0 |
186 note 6 Y0 |
187 moreover |
187 moreover |
188 from 6 have "isnorm P2" "isnorm Q2" |
188 from 6 have "isnorm P2" "isnorm Q2" |
189 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
189 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
190 moreover |
190 moreover |
191 from 6 `x > y` x have "isnorm (Pinj d P2)" |
191 from 6 \<open>x > y\<close> x have "isnorm (Pinj d P2)" |
192 by (cases d) (simp, cases P2, auto) |
192 by (cases d) (simp, cases P2, auto) |
193 ultimately have ?case by (simp add: mkPinj_cn) |
193 ultimately have ?case by (simp add: mkPinj_cn) |
194 } |
194 } |
195 ultimately show ?case by blast |
195 ultimately show ?case by blast |
196 next |
196 next |
202 } |
202 } |
203 moreover { |
203 moreover { |
204 assume "x = 1" |
204 assume "x = 1" |
205 from 7 have "isnorm R" "isnorm P2" |
205 from 7 have "isnorm R" "isnorm P2" |
206 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
206 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
207 with 7 `x = 1` have "isnorm (R \<oplus> P2)" by simp |
207 with 7 \<open>x = 1\<close> have "isnorm (R \<oplus> P2)" by simp |
208 with 7 `x = 1` have ?case |
208 with 7 \<open>x = 1\<close> have ?case |
209 by (simp add: norm_PXtrans[of Q2 y _]) |
209 by (simp add: norm_PXtrans[of Q2 y _]) |
210 } |
210 } |
211 moreover { |
211 moreover { |
212 assume "x > 1" then have "\<exists>d. x=Suc (Suc d)" by arith |
212 assume "x > 1" then have "\<exists>d. x=Suc (Suc d)" by arith |
213 then obtain d where X: "x=Suc (Suc d)" .. |
213 then obtain d where X: "x=Suc (Suc d)" .. |
214 with 7 have NR: "isnorm R" "isnorm P2" |
214 with 7 have NR: "isnorm R" "isnorm P2" |
215 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
215 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
216 with 7 X have "isnorm (Pinj (x - 1) P2)" by (cases P2) auto |
216 with 7 X have "isnorm (Pinj (x - 1) P2)" by (cases P2) auto |
217 with 7 X NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" by simp |
217 with 7 X NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" by simp |
218 with `isnorm (PX Q2 y R)` X have ?case |
218 with \<open>isnorm (PX Q2 y R)\<close> X have ?case |
219 by (simp add: norm_PXtrans[of Q2 y _]) |
219 by (simp add: norm_PXtrans[of Q2 y _]) |
220 } |
220 } |
221 ultimately show ?case by blast |
221 ultimately show ?case by blast |
222 next |
222 next |
223 case (8 Q2 y R x P2) |
223 case (8 Q2 y R x P2) |
229 } |
229 } |
230 moreover { |
230 moreover { |
231 assume "x = 1" |
231 assume "x = 1" |
232 with 8 have "isnorm R" "isnorm P2" |
232 with 8 have "isnorm R" "isnorm P2" |
233 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
233 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
234 with 8 `x = 1` have "isnorm (R \<oplus> P2)" |
234 with 8 \<open>x = 1\<close> have "isnorm (R \<oplus> P2)" |
235 by simp |
235 by simp |
236 with 8 `x = 1` have ?case |
236 with 8 \<open>x = 1\<close> have ?case |
237 by (simp add: norm_PXtrans[of Q2 y _]) |
237 by (simp add: norm_PXtrans[of Q2 y _]) |
238 } |
238 } |
239 moreover { |
239 moreover { |
240 assume "x > 1" |
240 assume "x > 1" |
241 then have "\<exists>d. x = Suc (Suc d)" by arith |
241 then have "\<exists>d. x = Suc (Suc d)" by arith |
242 then obtain d where X: "x = Suc (Suc d)" .. |
242 then obtain d where X: "x = Suc (Suc d)" .. |
243 with 8 have NR: "isnorm R" "isnorm P2" |
243 with 8 have NR: "isnorm R" "isnorm P2" |
244 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
244 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
245 with 8 X have "isnorm (Pinj (x - 1) P2)" |
245 with 8 X have "isnorm (Pinj (x - 1) P2)" |
246 by (cases P2) auto |
246 by (cases P2) auto |
247 with 8 `x > 1` NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" |
247 with 8 \<open>x > 1\<close> NR have "isnorm (R \<oplus> Pinj (x - 1) P2)" |
248 by simp |
248 by simp |
249 with `isnorm (PX Q2 y R)` X have ?case |
249 with \<open>isnorm (PX Q2 y R)\<close> X have ?case |
250 by (simp add: norm_PXtrans[of Q2 y _]) |
250 by (simp add: norm_PXtrans[of Q2 y _]) |
251 } |
251 } |
252 ultimately show ?case by blast |
252 ultimately show ?case by blast |
253 next |
253 next |
254 case (9 P1 x P2 Q1 y Q2) |
254 case (9 P1 x P2 Q1 y Q2) |
317 by (simp add: mkPX_cn) |
317 by (simp add: mkPX_cn) |
318 } |
318 } |
319 ultimately show ?case by blast |
319 ultimately show ?case by blast |
320 qed simp |
320 qed simp |
321 |
321 |
322 text {* mul concerves normalizedness *} |
322 text \<open>mul concerves normalizedness\<close> |
323 lemma mul_cn: "isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<otimes> Q)" |
323 lemma mul_cn: "isnorm P \<Longrightarrow> isnorm Q \<Longrightarrow> isnorm (P \<otimes> Q)" |
324 proof (induct P Q rule: mul.induct) |
324 proof (induct P Q rule: mul.induct) |
325 case (2 c i P2) |
325 case (2 c i P2) |
326 then show ?case |
326 then show ?case |
327 by (cases P2) (simp_all, cases i, simp_all add: mkPinj_cn) |
327 by (cases P2) (simp_all, cases i, simp_all add: mkPinj_cn) |
355 by (cases x) (auto simp add: norm_Pinj_0_False) |
355 by (cases x) (auto simp add: norm_Pinj_0_False) |
356 moreover |
356 moreover |
357 from 6 have "isnorm P2" "isnorm Q2" |
357 from 6 have "isnorm P2" "isnorm Q2" |
358 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
358 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
359 moreover |
359 moreover |
360 from 6 `x < y` y have "isnorm (Pinj d Q2)" |
360 from 6 \<open>x < y\<close> y have "isnorm (Pinj d Q2)" |
361 by (cases d) (simp, cases Q2, auto) |
361 by (cases d) (simp, cases Q2, auto) |
362 ultimately have ?case by (simp add: mkPinj_cn) |
362 ultimately have ?case by (simp add: mkPinj_cn) |
363 } |
363 } |
364 moreover { |
364 moreover { |
365 assume "x = y" |
365 assume "x = y" |
384 by (cases y) (auto simp add: norm_Pinj_0_False) |
384 by (cases y) (auto simp add: norm_Pinj_0_False) |
385 moreover |
385 moreover |
386 from 6 have "isnorm P2" "isnorm Q2" |
386 from 6 have "isnorm P2" "isnorm Q2" |
387 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
387 by (auto simp add: norm_Pinj[of _ P2] norm_Pinj[of _ Q2]) |
388 moreover |
388 moreover |
389 from 6 `x > y` x have "isnorm (Pinj d P2)" |
389 from 6 \<open>x > y\<close> x have "isnorm (Pinj d P2)" |
390 by (cases d) (simp, cases P2, auto) |
390 by (cases d) (simp, cases P2, auto) |
391 ultimately have ?case by (simp add: mkPinj_cn) |
391 ultimately have ?case by (simp add: mkPinj_cn) |
392 } |
392 } |
393 ultimately show ?case by blast |
393 ultimately show ?case by blast |
394 next |
394 next |
402 } |
402 } |
403 moreover { |
403 moreover { |
404 assume "x = 1" |
404 assume "x = 1" |
405 from 7 have "isnorm R" "isnorm P2" |
405 from 7 have "isnorm R" "isnorm P2" |
406 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
406 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
407 with 7 `x = 1` have "isnorm (R \<otimes> P2)" "isnorm Q2" |
407 with 7 \<open>x = 1\<close> have "isnorm (R \<otimes> P2)" "isnorm Q2" |
408 by (auto simp add: norm_PX1[of Q2 y R]) |
408 by (auto simp add: norm_PX1[of Q2 y R]) |
409 with 7 `x = 1` Y0 have ?case |
409 with 7 \<open>x = 1\<close> Y0 have ?case |
410 by (simp add: mkPX_cn) |
410 by (simp add: mkPX_cn) |
411 } |
411 } |
412 moreover { |
412 moreover { |
413 assume "x > 1" |
413 assume "x > 1" |
414 then have "\<exists>d. x = Suc (Suc d)" |
414 then have "\<exists>d. x = Suc (Suc d)" |
442 } |
442 } |
443 moreover { |
443 moreover { |
444 assume "x = 1" |
444 assume "x = 1" |
445 from 8 have "isnorm R" "isnorm P2" |
445 from 8 have "isnorm R" "isnorm P2" |
446 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
446 by (auto simp add: norm_Pinj[of _ P2] norm_PX2[of Q2 y R]) |
447 with 8 `x = 1` have "isnorm (R \<otimes> P2)" "isnorm Q2" |
447 with 8 \<open>x = 1\<close> have "isnorm (R \<otimes> P2)" "isnorm Q2" |
448 by (auto simp add: norm_PX1[of Q2 y R]) |
448 by (auto simp add: norm_PX1[of Q2 y R]) |
449 with 8 `x = 1` Y0 have ?case |
449 with 8 \<open>x = 1\<close> Y0 have ?case |
450 by (simp add: mkPX_cn) |
450 by (simp add: mkPX_cn) |
451 } |
451 } |
452 moreover { |
452 moreover { |
453 assume "x > 1" |
453 assume "x > 1" |
454 then have "\<exists>d. x = Suc (Suc d)" by arith |
454 then have "\<exists>d. x = Suc (Suc d)" by arith |
488 "isnorm (mkPX (Q1 \<otimes> mkPinj (Suc 0) P2) y (Pc 0))" |
488 "isnorm (mkPX (Q1 \<otimes> mkPinj (Suc 0) P2) y (Pc 0))" |
489 by (auto simp add: mkPX_cn) |
489 by (auto simp add: mkPX_cn) |
490 then show ?case by (simp add: add_cn) |
490 then show ?case by (simp add: add_cn) |
491 qed simp |
491 qed simp |
492 |
492 |
493 text {* neg conserves normalizedness *} |
493 text \<open>neg conserves normalizedness\<close> |
494 lemma neg_cn: "isnorm P \<Longrightarrow> isnorm (neg P)" |
494 lemma neg_cn: "isnorm P \<Longrightarrow> isnorm (neg P)" |
495 proof (induct P) |
495 proof (induct P) |
496 case (Pinj i P2) |
496 case (Pinj i P2) |
497 then have "isnorm P2" |
497 then have "isnorm P2" |
498 by (simp add: norm_Pinj[of i P2]) |
498 by (simp add: norm_Pinj[of i P2]) |
512 with PX1 show ?thesis |
512 with PX1 show ?thesis |
513 by (cases x) auto |
513 by (cases x) auto |
514 qed (cases x, auto) |
514 qed (cases x, auto) |
515 qed simp |
515 qed simp |
516 |
516 |
517 text {* sub conserves normalizedness *} |
517 text \<open>sub conserves normalizedness\<close> |
518 lemma sub_cn: "isnorm p \<Longrightarrow> isnorm q \<Longrightarrow> isnorm (p \<ominus> q)" |
518 lemma sub_cn: "isnorm p \<Longrightarrow> isnorm q \<Longrightarrow> isnorm (p \<ominus> q)" |
519 by (simp add: sub_def add_cn neg_cn) |
519 by (simp add: sub_def add_cn neg_cn) |
520 |
520 |
521 text {* sqr conserves normalizizedness *} |
521 text \<open>sqr conserves normalizizedness\<close> |
522 lemma sqr_cn: "isnorm P \<Longrightarrow> isnorm (sqr P)" |
522 lemma sqr_cn: "isnorm P \<Longrightarrow> isnorm (sqr P)" |
523 proof (induct P) |
523 proof (induct P) |
524 case Pc |
524 case Pc |
525 then show ?case by simp |
525 then show ?case by simp |
526 next |
526 next |
536 by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn) |
536 by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn) |
537 then show ?case |
537 then show ?case |
538 by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn) |
538 by (auto simp add: add_cn mkPX_cn mkPinj_cn mul_cn) |
539 qed |
539 qed |
540 |
540 |
541 text {* pow conserves normalizedness *} |
541 text \<open>pow conserves normalizedness\<close> |
542 lemma pow_cn: "isnorm P \<Longrightarrow> isnorm (pow n P)" |
542 lemma pow_cn: "isnorm P \<Longrightarrow> isnorm (pow n P)" |
543 proof (induct n arbitrary: P rule: less_induct) |
543 proof (induct n arbitrary: P rule: less_induct) |
544 case (less k) |
544 case (less k) |
545 show ?case |
545 show ?case |
546 proof (cases "k = 0") |
546 proof (cases "k = 0") |