8 header {* Univariate Polynomials *} |
8 header {* Univariate Polynomials *} |
9 |
9 |
10 theory UnivPoly = Module: |
10 theory UnivPoly = Module: |
11 |
11 |
12 text {* |
12 text {* |
13 Polynomials are formalised as modules with additional operations for |
13 Polynomials are formalised as modules with additional operations for |
14 extracting coefficients from polynomials and for obtaining monomials |
14 extracting coefficients from polynomials and for obtaining monomials |
15 from coefficients and exponents (record @{text "up_ring"}). |
15 from coefficients and exponents (record @{text "up_ring"}). The |
16 The carrier set is |
16 carrier set is a set of bounded functions from Nat to the |
17 a set of bounded functions from Nat to the coefficient domain. |
17 coefficient domain. Bounded means that these functions return zero |
18 Bounded means that these functions return zero above a certain bound |
18 above a certain bound (the degree). There is a chapter on the |
19 (the degree). There is a chapter on the formalisation of polynomials |
19 formalisation of polynomials in my PhD thesis |
20 in my PhD thesis (http://www4.in.tum.de/\~{}ballarin/publications/), |
20 (\url{http://www4.in.tum.de/~ballarin/publications/}), which was |
21 which was implemented with axiomatic type classes. This was later |
21 implemented with axiomatic type classes. This was later ported to |
22 ported to Locales. |
22 Locales. |
23 *} |
23 *} |
24 |
24 |
|
25 |
25 subsection {* The Constructor for Univariate Polynomials *} |
26 subsection {* The Constructor for Univariate Polynomials *} |
26 |
27 |
27 (* Could alternatively use locale ... |
28 locale bound = |
28 locale bound = cring + var bound + |
29 fixes z :: 'a |
29 defines ... |
30 and n :: nat |
30 *) |
31 and f :: "nat => 'a" |
31 |
32 assumes bound: "!!m. n < m \<Longrightarrow> f m = z" |
32 constdefs |
33 |
33 bound :: "['a, nat, nat => 'a] => bool" |
34 declare bound.intro [intro!] |
34 "bound z n f == (ALL i. n < i --> f i = z)" |
35 and bound.bound [dest] |
35 |
|
36 lemma boundI [intro!]: |
|
37 "[| !! m. n < m ==> f m = z |] ==> bound z n f" |
|
38 by (unfold bound_def) fast |
|
39 |
|
40 lemma boundE [elim?]: |
|
41 "[| bound z n f; (!! m. n < m ==> f m = z) ==> P |] ==> P" |
|
42 by (unfold bound_def) fast |
|
43 |
|
44 lemma boundD [dest]: |
|
45 "[| bound z n f; n < m |] ==> f m = z" |
|
46 by (unfold bound_def) fast |
|
47 |
36 |
48 lemma bound_below: |
37 lemma bound_below: |
49 assumes bound: "bound z m f" and nonzero: "f n ~= z" shows "n <= m" |
38 assumes bound: "bound z m f" and nonzero: "f n \<noteq> z" shows "n \<le> m" |
50 proof (rule classical) |
39 proof (rule classical) |
51 assume "~ ?thesis" |
40 assume "~ ?thesis" |
52 then have "m < n" by arith |
41 then have "m < n" by arith |
53 with bound have "f n = z" .. |
42 with bound have "f n = z" .. |
54 with nonzero show ?thesis by contradiction |
43 with nonzero show ?thesis by contradiction |
128 then show "EX n. bound \<zero> n (%i. \<ominus> p i)" by auto |
117 then show "EX n. bound \<zero> n (%i. \<ominus> p i)" by auto |
129 qed auto |
118 qed auto |
130 |
119 |
131 lemma (in cring) up_mult_closed: |
120 lemma (in cring) up_mult_closed: |
132 "[| p \<in> up R; q \<in> up R |] ==> |
121 "[| p \<in> up R; q \<in> up R |] ==> |
133 (%n. finsum R (%i. p i \<otimes> q (n-i)) {..n}) \<in> up R" |
122 (%n. \<Oplus>i \<in> {..n}. p i \<otimes> q (n-i)) \<in> up R" |
134 proof |
123 proof |
135 fix n |
124 fix n |
136 assume "p \<in> up R" "q \<in> up R" |
125 assume "p \<in> up R" "q \<in> up R" |
137 then show "finsum R (%i. p i \<otimes> q (n-i)) {..n} \<in> carrier R" |
126 then show "(\<Oplus>i \<in> {..n}. p i \<otimes> q (n-i)) \<in> carrier R" |
138 by (simp add: mem_upD funcsetI) |
127 by (simp add: mem_upD funcsetI) |
139 next |
128 next |
140 assume UP: "p \<in> up R" "q \<in> up R" |
129 assume UP: "p \<in> up R" "q \<in> up R" |
141 show "EX n. bound \<zero> n (%n. finsum R (%i. p i \<otimes> q (n - i)) {..n})" |
130 show "EX n. bound \<zero> n (%n. \<Oplus>i \<in> {..n}. p i \<otimes> q (n-i))" |
142 proof - |
131 proof - |
143 from UP obtain n where boundn: "bound \<zero> n p" by fast |
132 from UP obtain n where boundn: "bound \<zero> n p" by fast |
144 from UP obtain m where boundm: "bound \<zero> m q" by fast |
133 from UP obtain m where boundm: "bound \<zero> m q" by fast |
145 have "bound \<zero> (n + m) (%n. finsum R (%i. p i \<otimes> q (n - i)) {..n})" |
134 have "bound \<zero> (n + m) (%n. \<Oplus>i \<in> {..n}. p i \<otimes> q (n - i))" |
146 proof |
135 proof |
147 fix k |
136 fix k assume bound: "n + m < k" |
148 assume bound: "n + m < k" |
|
149 { |
137 { |
150 fix i |
138 fix i |
151 have "p i \<otimes> q (k-i) = \<zero>" |
139 have "p i \<otimes> q (k-i) = \<zero>" |
152 proof (cases "n < i") |
140 proof (cases "n < i") |
153 case True |
141 case True |
154 with boundn have "p i = \<zero>" by auto |
142 with boundn have "p i = \<zero>" by auto |
155 moreover from UP have "q (k-i) \<in> carrier R" by auto |
143 moreover from UP have "q (k-i) \<in> carrier R" by auto |
156 ultimately show ?thesis by simp |
144 ultimately show ?thesis by simp |
157 next |
145 next |
158 case False |
146 case False |
159 with bound have "m < k-i" by arith |
147 with bound have "m < k-i" by arith |
160 with boundm have "q (k-i) = \<zero>" by auto |
148 with boundm have "q (k-i) = \<zero>" by auto |
161 moreover from UP have "p i \<in> carrier R" by auto |
149 moreover from UP have "p i \<in> carrier R" by auto |
162 ultimately show ?thesis by simp |
150 ultimately show ?thesis by simp |
163 qed |
151 qed |
164 } |
152 } |
165 then show "finsum R (%i. p i \<otimes> q (k-i)) {..k} = \<zero>" |
153 then show "(\<Oplus>i \<in> {..k}. p i \<otimes> q (k-i)) = \<zero>" |
166 by (simp add: Pi_def) |
154 by (simp add: Pi_def) |
167 qed |
155 qed |
168 then show ?thesis by fast |
156 then show ?thesis by fast |
169 qed |
157 qed |
170 qed |
158 qed |
|
159 |
171 |
160 |
172 subsection {* Effect of operations on coefficients *} |
161 subsection {* Effect of operations on coefficients *} |
173 |
162 |
174 locale UP = struct R + struct P + |
163 locale UP = struct R + struct P + |
175 defines P_def: "P == UP R" |
164 defines P_def: "P == UP R" |
212 coeff P (p \<oplus>\<^sub>2 q) n = coeff P p n \<oplus> coeff P q n" |
201 coeff P (p \<oplus>\<^sub>2 q) n = coeff P p n \<oplus> coeff P q n" |
213 by (simp add: UP_def up_add_closed) |
202 by (simp add: UP_def up_add_closed) |
214 |
203 |
215 lemma (in UP_cring) coeff_mult [simp]: |
204 lemma (in UP_cring) coeff_mult [simp]: |
216 "[| p \<in> carrier P; q \<in> carrier P |] ==> |
205 "[| p \<in> carrier P; q \<in> carrier P |] ==> |
217 coeff P (p \<otimes>\<^sub>2 q) n = finsum R (%i. coeff P p i \<otimes> coeff P q (n-i)) {..n}" |
206 coeff P (p \<otimes>\<^sub>2 q) n = (\<Oplus>i \<in> {..n}. coeff P p i \<otimes> coeff P q (n-i))" |
218 by (simp add: UP_def up_mult_closed) |
207 by (simp add: UP_def up_mult_closed) |
219 |
208 |
220 lemma (in UP) up_eqI: |
209 lemma (in UP) up_eqI: |
221 assumes prem: "!!n. coeff P p n = coeff P q n" |
210 assumes prem: "!!n. coeff P p n = coeff P q n" |
222 and R: "p \<in> carrier P" "q \<in> carrier P" |
211 and R: "p \<in> carrier P" "q \<in> carrier P" |
223 shows "p = q" |
212 shows "p = q" |
224 proof |
213 proof |
225 fix x |
214 fix x |
226 from prem and R show "p x = q x" by (simp add: UP_def) |
215 from prem and R show "p x = q x" by (simp add: UP_def) |
227 qed |
216 qed |
228 |
217 |
229 subsection {* Polynomials form a commutative ring. *} |
218 subsection {* Polynomials form a commutative ring. *} |
230 |
219 |
231 text {* Operations are closed over @{term "P"}. *} |
220 text {* Operations are closed over @{term P}. *} |
232 |
221 |
233 lemma (in UP_cring) UP_mult_closed [simp]: |
222 lemma (in UP_cring) UP_mult_closed [simp]: |
234 "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<otimes>\<^sub>2 q \<in> carrier P" |
223 "[| p \<in> carrier P; q \<in> carrier P |] ==> p \<otimes>\<^sub>2 q \<in> carrier P" |
235 by (simp add: UP_def up_mult_closed) |
224 by (simp add: UP_def up_mult_closed) |
236 |
225 |
305 { |
294 { |
306 fix k and a b c :: "nat=>'a" |
295 fix k and a b c :: "nat=>'a" |
307 assume R: "a \<in> UNIV -> carrier R" "b \<in> UNIV -> carrier R" |
296 assume R: "a \<in> UNIV -> carrier R" "b \<in> UNIV -> carrier R" |
308 "c \<in> UNIV -> carrier R" |
297 "c \<in> UNIV -> carrier R" |
309 then have "k <= n ==> |
298 then have "k <= n ==> |
310 finsum R (%j. finsum R (%i. a i \<otimes> b (j-i)) {..j} \<otimes> c (n-j)) {..k} = |
299 (\<Oplus>j \<in> {..k}. (\<Oplus>i \<in> {..j}. a i \<otimes> b (j-i)) \<otimes> c (n-j)) = |
311 finsum R (%j. a j \<otimes> finsum R (%i. b i \<otimes> c (n-j-i)) {..k-j}) {..k}" |
300 (\<Oplus>j \<in> {..k}. a j \<otimes> (\<Oplus>i \<in> {..k-j}. b i \<otimes> c (n-j-i)))" |
312 (is "_ ==> ?eq k") |
301 (concl is "?eq k") |
313 proof (induct k) |
302 proof (induct k) |
314 case 0 then show ?case by (simp add: Pi_def m_assoc) |
303 case 0 then show ?case by (simp add: Pi_def m_assoc) |
315 next |
304 next |
316 case (Suc k) |
305 case (Suc k) |
317 then have "k <= n" by arith |
306 then have "k <= n" by arith |
318 then have "?eq k" by (rule Suc) |
307 then have "?eq k" by (rule Suc) |
319 with R show ?case |
308 with R show ?case |
320 by (simp cong: finsum_cong |
309 by (simp cong: finsum_cong |
321 add: Suc_diff_le Pi_def l_distr r_distr m_assoc) |
310 add: Suc_diff_le Pi_def l_distr r_distr m_assoc) |
322 (simp cong: finsum_cong add: Pi_def a_ac finsum_ldistr m_assoc) |
311 (simp cong: finsum_cong add: Pi_def a_ac finsum_ldistr m_assoc) |
323 qed |
312 qed |
324 } |
313 } |
325 with R show "coeff P ((p \<otimes>\<^sub>2 q) \<otimes>\<^sub>2 r) n = coeff P (p \<otimes>\<^sub>2 (q \<otimes>\<^sub>2 r)) n" |
314 with R show "coeff P ((p \<otimes>\<^sub>2 q) \<otimes>\<^sub>2 r) n = coeff P (p \<otimes>\<^sub>2 (q \<otimes>\<^sub>2 r)) n" |
351 |
340 |
352 lemma (in UP_cring) UP_m_comm: |
341 lemma (in UP_cring) UP_m_comm: |
353 assumes R: "p \<in> carrier P" "q \<in> carrier P" |
342 assumes R: "p \<in> carrier P" "q \<in> carrier P" |
354 shows "p \<otimes>\<^sub>2 q = q \<otimes>\<^sub>2 p" |
343 shows "p \<otimes>\<^sub>2 q = q \<otimes>\<^sub>2 p" |
355 proof (rule up_eqI) |
344 proof (rule up_eqI) |
356 fix n |
345 fix n |
357 { |
346 { |
358 fix k and a b :: "nat=>'a" |
347 fix k and a b :: "nat=>'a" |
359 assume R: "a \<in> UNIV -> carrier R" "b \<in> UNIV -> carrier R" |
348 assume R: "a \<in> UNIV -> carrier R" "b \<in> UNIV -> carrier R" |
360 then have "k <= n ==> |
349 then have "k <= n ==> |
361 finsum R (%i. a i \<otimes> b (n-i)) {..k} = |
350 (\<Oplus>i \<in> {..k}. a i \<otimes> b (n-i)) = |
362 finsum R (%i. a (k-i) \<otimes> b (i+n-k)) {..k}" |
351 (\<Oplus>i \<in> {..k}. a (k-i) \<otimes> b (i+n-k))" |
363 (is "_ ==> ?eq k") |
352 (concl is "?eq k") |
364 proof (induct k) |
353 proof (induct k) |
365 case 0 then show ?case by (simp add: Pi_def) |
354 case 0 then show ?case by (simp add: Pi_def) |
366 next |
355 next |
367 case (Suc k) then show ?case |
356 case (Suc k) then show ?case |
368 by (subst finsum_Suc2) (simp add: Pi_def a_comm)+ |
357 by (subst finsum_Suc2) (simp add: Pi_def a_comm)+ |
369 qed |
358 qed |
370 } |
359 } |
371 note l = this |
360 note l = this |
372 from R show "coeff P (p \<otimes>\<^sub>2 q) n = coeff P (q \<otimes>\<^sub>2 p) n" |
361 from R show "coeff P (p \<otimes>\<^sub>2 q) n = coeff P (q \<otimes>\<^sub>2 p) n" |
373 apply (simp add: Pi_def) |
362 apply (simp add: Pi_def) |
656 fix k |
646 fix k |
657 show "coeff P (monom P \<one> (Suc n)) k = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" |
647 show "coeff P (monom P \<one> (Suc n)) k = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" |
658 proof (cases "k = Suc n") |
648 proof (cases "k = Suc n") |
659 case True show ?thesis |
649 case True show ?thesis |
660 proof - |
650 proof - |
661 from True have less_add_diff: |
651 from True have less_add_diff: |
662 "!!i. [| n < i; i <= n + m |] ==> n + m - i < m" by arith |
652 "!!i. [| n < i; i <= n + m |] ==> n + m - i < m" by arith |
663 from True have "coeff P (monom P \<one> (Suc n)) k = \<one>" by simp |
653 from True have "coeff P (monom P \<one> (Suc n)) k = \<one>" by simp |
664 also from True |
654 also from True |
665 have "... = finsum R (%i. coeff P (monom P \<one> n) i \<otimes> |
655 have "... = (\<Oplus>i \<in> {..n(} \<union> {n}. coeff P (monom P \<one> n) i \<otimes> |
666 coeff P (monom P \<one> 1) (k - i)) ({..n(} Un {n})" |
656 coeff P (monom P \<one> 1) (k - i))" |
667 by (simp cong: finsum_cong add: finsum_Un_disjoint Pi_def) |
657 by (simp cong: finsum_cong add: finsum_Un_disjoint Pi_def) |
668 also have "... = finsum R (%i. coeff P (monom P \<one> n) i \<otimes> |
658 also have "... = (\<Oplus>i \<in> {..n}. coeff P (monom P \<one> n) i \<otimes> |
669 coeff P (monom P \<one> 1) (k - i)) {..n}" |
659 coeff P (monom P \<one> 1) (k - i))" |
670 by (simp only: ivl_disj_un_singleton) |
660 by (simp only: ivl_disj_un_singleton) |
671 also from True have "... = finsum R (%i. coeff P (monom P \<one> n) i \<otimes> |
661 also from True have "... = (\<Oplus>i \<in> {..n} \<union> {)n..k}. coeff P (monom P \<one> n) i \<otimes> |
672 coeff P (monom P \<one> 1) (k - i)) ({..n} Un {)n..k})" |
662 coeff P (monom P \<one> 1) (k - i))" |
673 by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one |
663 by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one |
674 order_less_imp_not_eq Pi_def) |
664 order_less_imp_not_eq Pi_def) |
675 also from True have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" |
665 also from True have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" |
676 by (simp add: ivl_disj_un_one) |
666 by (simp add: ivl_disj_un_one) |
677 finally show ?thesis . |
667 finally show ?thesis . |
678 qed |
668 qed |
679 next |
669 next |
680 case False |
670 case False |
681 note neq = False |
671 note neq = False |
682 let ?s = |
672 let ?s = |
683 "(\<lambda>i. (if n = i then \<one> else \<zero>) \<otimes> (if Suc 0 = k - i then \<one> else \<zero>))" |
673 "\<lambda>i. (if n = i then \<one> else \<zero>) \<otimes> (if Suc 0 = k - i then \<one> else \<zero>)" |
684 from neq have "coeff P (monom P \<one> (Suc n)) k = \<zero>" by simp |
674 from neq have "coeff P (monom P \<one> (Suc n)) k = \<zero>" by simp |
685 also have "... = finsum R ?s {..k}" |
675 also have "... = (\<Oplus>i \<in> {..k}. ?s i)" |
686 proof - |
676 proof - |
687 have f1: "finsum R ?s {..n(} = \<zero>" by (simp cong: finsum_cong add: Pi_def) |
677 have f1: "(\<Oplus>i \<in> {..n(}. ?s i) = \<zero>" by (simp cong: finsum_cong add: Pi_def) |
688 from neq have f2: "finsum R ?s {n} = \<zero>" |
678 from neq have f2: "(\<Oplus>i \<in> {n}. ?s i) = \<zero>" |
689 by (simp cong: finsum_cong add: Pi_def) arith |
679 by (simp cong: finsum_cong add: Pi_def) arith |
690 have f3: "n < k ==> finsum R ?s {)n..k} = \<zero>" |
680 have f3: "n < k ==> (\<Oplus>i \<in> {)n..k}. ?s i) = \<zero>" |
691 by (simp cong: finsum_cong add: order_less_imp_not_eq Pi_def) |
681 by (simp cong: finsum_cong add: order_less_imp_not_eq Pi_def) |
692 show ?thesis |
682 show ?thesis |
693 proof (cases "k < n") |
683 proof (cases "k < n") |
694 case True then show ?thesis by (simp cong: finsum_cong add: Pi_def) |
684 case True then show ?thesis by (simp cong: finsum_cong add: Pi_def) |
695 next |
685 next |
696 case False then have n_le_k: "n <= k" by arith |
686 case False then have n_le_k: "n <= k" by arith |
697 show ?thesis |
687 show ?thesis |
698 proof (cases "n = k") |
688 proof (cases "n = k") |
699 case True |
689 case True |
700 then have "\<zero> = finsum R ?s ({..n(} \<union> {n})" |
690 then have "\<zero> = (\<Oplus>i \<in> {..n(} \<union> {n}. ?s i)" |
701 by (simp cong: finsum_cong add: finsum_Un_disjoint |
691 by (simp cong: finsum_cong add: finsum_Un_disjoint |
702 ivl_disj_int_singleton Pi_def) |
692 ivl_disj_int_singleton Pi_def) |
703 also from True have "... = finsum R ?s {..k}" |
693 also from True have "... = (\<Oplus>i \<in> {..k}. ?s i)" |
704 by (simp only: ivl_disj_un_singleton) |
694 by (simp only: ivl_disj_un_singleton) |
705 finally show ?thesis . |
695 finally show ?thesis . |
706 next |
696 next |
707 case False with n_le_k have n_less_k: "n < k" by arith |
697 case False with n_le_k have n_less_k: "n < k" by arith |
708 with neq have "\<zero> = finsum R ?s ({..n(} \<union> {n})" |
698 with neq have "\<zero> = (\<Oplus>i \<in> {..n(} \<union> {n}. ?s i)" |
709 by (simp add: finsum_Un_disjoint f1 f2 |
699 by (simp add: finsum_Un_disjoint f1 f2 |
710 ivl_disj_int_singleton Pi_def del: Un_insert_right) |
700 ivl_disj_int_singleton Pi_def del: Un_insert_right) |
711 also have "... = finsum R ?s {..n}" |
701 also have "... = (\<Oplus>i \<in> {..n}. ?s i)" |
712 by (simp only: ivl_disj_un_singleton) |
702 by (simp only: ivl_disj_un_singleton) |
713 also from n_less_k neq have "... = finsum R ?s ({..n} \<union> {)n..k})" |
703 also from n_less_k neq have "... = (\<Oplus>i \<in> {..n} \<union> {)n..k}. ?s i)" |
714 by (simp add: finsum_Un_disjoint f3 ivl_disj_int_one Pi_def) |
704 by (simp add: finsum_Un_disjoint f3 ivl_disj_int_one Pi_def) |
715 also from n_less_k have "... = finsum R ?s {..k}" |
705 also from n_less_k have "... = (\<Oplus>i \<in> {..k}. ?s i)" |
716 by (simp only: ivl_disj_un_one) |
706 by (simp only: ivl_disj_un_one) |
717 finally show ?thesis . |
707 finally show ?thesis . |
718 qed |
708 qed |
719 qed |
709 qed |
720 qed |
710 qed |
721 also have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" by simp |
711 also have "... = coeff P (monom P \<one> n \<otimes>\<^sub>2 monom P \<one> 1) k" by simp |
722 finally show ?thesis . |
712 finally show ?thesis . |
723 qed |
713 qed |
787 constdefs (structure R) |
777 constdefs (structure R) |
788 deg :: "[_, nat => 'a] => nat" |
778 deg :: "[_, nat => 'a] => nat" |
789 "deg R p == LEAST n. bound \<zero> n (coeff (UP R) p)" |
779 "deg R p == LEAST n. bound \<zero> n (coeff (UP R) p)" |
790 |
780 |
791 lemma (in UP_cring) deg_aboveI: |
781 lemma (in UP_cring) deg_aboveI: |
792 "[| (!!m. n < m ==> coeff P p m = \<zero>); p \<in> carrier P |] ==> deg R p <= n" |
782 "[| (!!m. n < m ==> coeff P p m = \<zero>); p \<in> carrier P |] ==> deg R p <= n" |
793 by (unfold deg_def P_def) (fast intro: Least_le) |
783 by (unfold deg_def P_def) (fast intro: Least_le) |
794 (* |
784 (* |
795 lemma coeff_bound_ex: "EX n. bound n (coeff p)" |
785 lemma coeff_bound_ex: "EX n. bound n (coeff p)" |
796 proof - |
786 proof - |
797 have "(%n. coeff p n) : UP" by (simp add: coeff_def Rep_UP) |
787 have "(%n. coeff p n) : UP" by (simp add: coeff_def Rep_UP) |
798 then obtain n where "bound n (coeff p)" by (unfold UP_def) fast |
788 then obtain n where "bound n (coeff p)" by (unfold UP_def) fast |
799 then show ?thesis .. |
789 then show ?thesis .. |
800 qed |
790 qed |
801 |
791 |
802 lemma bound_coeff_obtain: |
792 lemma bound_coeff_obtain: |
803 assumes prem: "(!!n. bound n (coeff p) ==> P)" shows "P" |
793 assumes prem: "(!!n. bound n (coeff p) ==> P)" shows "P" |
804 proof - |
794 proof - |
805 have "(%n. coeff p n) : UP" by (simp add: coeff_def Rep_UP) |
795 have "(%n. coeff p n) : UP" by (simp add: coeff_def Rep_UP) |
806 then obtain n where "bound n (coeff p)" by (unfold UP_def) fast |
796 then obtain n where "bound n (coeff p)" by (unfold UP_def) fast |
809 *) |
799 *) |
810 lemma (in UP_cring) deg_aboveD: |
800 lemma (in UP_cring) deg_aboveD: |
811 "[| deg R p < m; p \<in> carrier P |] ==> coeff P p m = \<zero>" |
801 "[| deg R p < m; p \<in> carrier P |] ==> coeff P p m = \<zero>" |
812 proof - |
802 proof - |
813 assume R: "p \<in> carrier P" and "deg R p < m" |
803 assume R: "p \<in> carrier P" and "deg R p < m" |
814 from R obtain n where "bound \<zero> n (coeff P p)" |
804 from R obtain n where "bound \<zero> n (coeff P p)" |
815 by (auto simp add: UP_def P_def) |
805 by (auto simp add: UP_def P_def) |
816 then have "bound \<zero> (deg R p) (coeff P p)" |
806 then have "bound \<zero> (deg R p) (coeff P p)" |
817 by (auto simp: deg_def P_def dest: LeastI) |
807 by (auto simp: deg_def P_def dest: LeastI) |
818 then show ?thesis by (rule boundD) |
808 then show ?thesis .. |
819 qed |
809 qed |
820 |
810 |
821 lemma (in UP_cring) deg_belowI: |
811 lemma (in UP_cring) deg_belowI: |
822 assumes non_zero: "n ~= 0 ==> coeff P p n ~= \<zero>" |
812 assumes non_zero: "n ~= 0 ==> coeff P p n ~= \<zero>" |
823 and R: "p \<in> carrier P" |
813 and R: "p \<in> carrier P" |
824 shows "n <= deg R p" |
814 shows "n <= deg R p" |
825 -- {* Logically, this is a slightly stronger version of |
815 -- {* Logically, this is a slightly stronger version of |
826 @{thm [source] deg_aboveD} *} |
816 @{thm [source] deg_aboveD} *} |
827 proof (cases "n=0") |
817 proof (cases "n=0") |
828 case True then show ?thesis by simp |
818 case True then show ?thesis by simp |
829 next |
819 next |
830 case False then have "coeff P p n ~= \<zero>" by (rule non_zero) |
820 case False then have "coeff P p n ~= \<zero>" by (rule non_zero) |
997 also have "... = finsum R ?s {deg R p .. deg R p + deg R q}" |
987 also have "... = finsum R ?s {deg R p .. deg R p + deg R q}" |
998 by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one |
988 by (simp cong: finsum_cong add: finsum_Un_disjoint ivl_disj_int_one |
999 deg_aboveD less_add_diff R Pi_def) |
989 deg_aboveD less_add_diff R Pi_def) |
1000 also have "...= finsum R ?s ({deg R p} Un {)deg R p .. deg R p + deg R q})" |
990 also have "...= finsum R ?s ({deg R p} Un {)deg R p .. deg R p + deg R q})" |
1001 by (simp only: ivl_disj_un_singleton) |
991 by (simp only: ivl_disj_un_singleton) |
1002 also have "... = coeff P p (deg R p) \<otimes> coeff P q (deg R q)" |
992 also have "... = coeff P p (deg R p) \<otimes> coeff P q (deg R q)" |
1003 by (simp cong: finsum_cong add: finsum_Un_disjoint |
993 by (simp cong: finsum_cong add: finsum_Un_disjoint |
1004 ivl_disj_int_singleton deg_aboveD R Pi_def) |
994 ivl_disj_int_singleton deg_aboveD R Pi_def) |
1005 finally have "finsum R ?s {.. deg R p + deg R q} |
995 finally have "finsum R ?s {.. deg R p + deg R q} |
1006 = coeff P p (deg R p) \<otimes> coeff P q (deg R q)" . |
996 = coeff P p (deg R p) \<otimes> coeff P q (deg R q)" . |
1007 with nz show "finsum R ?s {.. deg R p + deg R q} ~= \<zero>" |
997 with nz show "finsum R ?s {.. deg R p + deg R q} ~= \<zero>" |
1008 by (simp add: integral_iff lcoeff_nonzero R) |
998 by (simp add: integral_iff lcoeff_nonzero R) |
1009 qed (simp add: R) |
999 qed (simp add: R) |
1010 qed |
1000 qed |
1019 simpset_ref() := simpset() setsubgoaler asm_full_simp_tac; |
1009 simpset_ref() := simpset() setsubgoaler asm_full_simp_tac; |
1020 *} |
1010 *} |
1021 |
1011 |
1022 lemma (in UP_cring) up_repr: |
1012 lemma (in UP_cring) up_repr: |
1023 assumes R: "p \<in> carrier P" |
1013 assumes R: "p \<in> carrier P" |
1024 shows "finsum P (%i. monom P (coeff P p i) i) {..deg R p} = p" |
1014 shows "(\<Oplus>\<^sub>2 i \<in> {..deg R p}. monom P (coeff P p i) i) = p" |
1025 proof (rule up_eqI) |
1015 proof (rule up_eqI) |
1026 let ?s = "(%i. monom P (coeff P p i) i)" |
1016 let ?s = "(%i. monom P (coeff P p i) i)" |
1027 fix k |
1017 fix k |
1028 from R have RR: "!!i. (if i = k then coeff P p i else \<zero>) \<in> carrier R" |
1018 from R have RR: "!!i. (if i = k then coeff P p i else \<zero>) \<in> carrier R" |
1029 by simp |
1019 by simp |
1030 show "coeff P (finsum P ?s {..deg R p}) k = coeff P p k" |
1020 show "coeff P (finsum P ?s {..deg R p}) k = coeff P p k" |
1031 proof (cases "k <= deg R p") |
1021 proof (cases "k <= deg R p") |
1032 case True |
1022 case True |
1033 hence "coeff P (finsum P ?s {..deg R p}) k = |
1023 hence "coeff P (finsum P ?s {..deg R p}) k = |
1034 coeff P (finsum P ?s ({..k} Un {)k..deg R p})) k" |
1024 coeff P (finsum P ?s ({..k} Un {)k..deg R p})) k" |
1035 by (simp only: ivl_disj_un_one) |
1025 by (simp only: ivl_disj_un_one) |
1036 also from True |
1026 also from True |
1037 have "... = coeff P (finsum P ?s {..k}) k" |
1027 have "... = coeff P (finsum P ?s {..k}) k" |
1038 by (simp cong: finsum_cong add: finsum_Un_disjoint |
1028 by (simp cong: finsum_cong add: finsum_Un_disjoint |
1039 ivl_disj_int_one order_less_imp_not_eq2 coeff_finsum R RR Pi_def) |
1029 ivl_disj_int_one order_less_imp_not_eq2 coeff_finsum R RR Pi_def) |
1040 also |
1030 also |
1041 have "... = coeff P (finsum P ?s ({..k(} Un {k})) k" |
1031 have "... = coeff P (finsum P ?s ({..k(} Un {k})) k" |
1042 by (simp only: ivl_disj_un_singleton) |
1032 by (simp only: ivl_disj_un_singleton) |
1043 also have "... = coeff P p k" |
1033 also have "... = coeff P p k" |
1044 by (simp cong: finsum_cong add: setsum_Un_disjoint |
1034 by (simp cong: finsum_cong add: setsum_Un_disjoint |
1045 ivl_disj_int_singleton coeff_finsum deg_aboveD R RR Pi_def) |
1035 ivl_disj_int_singleton coeff_finsum deg_aboveD R RR Pi_def) |
1046 finally show ?thesis . |
1036 finally show ?thesis . |
1047 next |
1037 next |
1048 case False |
1038 case False |
1049 hence "coeff P (finsum P ?s {..deg R p}) k = |
1039 hence "coeff P (finsum P ?s {..deg R p}) k = |
1050 coeff P (finsum P ?s ({..deg R p(} Un {deg R p})) k" |
1040 coeff P (finsum P ?s ({..deg R p(} Un {deg R p})) k" |
1051 by (simp only: ivl_disj_un_singleton) |
1041 by (simp only: ivl_disj_un_singleton) |
1052 also from False have "... = coeff P p k" |
1042 also from False have "... = coeff P p k" |
1053 by (simp cong: finsum_cong add: setsum_Un_disjoint ivl_disj_int_singleton |
1043 by (simp cong: finsum_cong add: setsum_Un_disjoint ivl_disj_int_singleton |
1054 coeff_finsum deg_aboveD R Pi_def) |
1044 coeff_finsum deg_aboveD R Pi_def) |
1105 assume c: "~ (p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2)" |
1095 assume c: "~ (p = \<zero>\<^sub>2 | q = \<zero>\<^sub>2)" |
1106 with R have "deg R p + deg R q = deg R (p \<otimes>\<^sub>2 q)" by simp |
1096 with R have "deg R p + deg R q = deg R (p \<otimes>\<^sub>2 q)" by simp |
1107 also from pq have "... = 0" by simp |
1097 also from pq have "... = 0" by simp |
1108 finally have "deg R p + deg R q = 0" . |
1098 finally have "deg R p + deg R q = 0" . |
1109 then have f1: "deg R p = 0 & deg R q = 0" by simp |
1099 then have f1: "deg R p = 0 & deg R q = 0" by simp |
1110 from f1 R have "p = finsum P (%i. (monom P (coeff P p i) i)) {..0}" |
1100 from f1 R have "p = (\<Oplus>\<^sub>2 i \<in> {..0}. monom P (coeff P p i) i)" |
1111 by (simp only: up_repr_le) |
1101 by (simp only: up_repr_le) |
1112 also from R have "... = monom P (coeff P p 0) 0" by simp |
1102 also from R have "... = monom P (coeff P p 0) 0" by simp |
1113 finally have p: "p = monom P (coeff P p 0) 0" . |
1103 finally have p: "p = monom P (coeff P p 0) 0" . |
1114 from f1 R have "q = finsum P (%i. (monom P (coeff P q i) i)) {..0}" |
1104 from f1 R have "q = (\<Oplus>\<^sub>2 i \<in> {..0}. monom P (coeff P q i) i)" |
1115 by (simp only: up_repr_le) |
1105 by (simp only: up_repr_le) |
1116 also from R have "... = monom P (coeff P q 0) 0" by simp |
1106 also from R have "... = monom P (coeff P q 0) 0" by simp |
1117 finally have q: "q = monom P (coeff P q 0) 0" . |
1107 finally have q: "q = monom P (coeff P q 0) 0" . |
1118 from R have "coeff P p 0 \<otimes> coeff P q 0 = coeff P (p \<otimes>\<^sub>2 q) 0" by simp |
1108 from R have "coeff P p 0 \<otimes> coeff P q 0 = coeff P (p \<otimes>\<^sub>2 q) 0" by simp |
1119 also from pq have "... = \<zero>" by simp |
1109 also from pq have "... = \<zero>" by simp |
1147 lemma (in UP_domain) smult_integral: |
1137 lemma (in UP_domain) smult_integral: |
1148 "[| a \<odot>\<^sub>2 p = \<zero>\<^sub>2; a \<in> carrier R; p \<in> carrier P |] ==> a = \<zero> | p = \<zero>\<^sub>2" |
1138 "[| a \<odot>\<^sub>2 p = \<zero>\<^sub>2; a \<in> carrier R; p \<in> carrier P |] ==> a = \<zero> | p = \<zero>\<^sub>2" |
1149 by (simp add: monom_mult_is_smult [THEN sym] UP_integral_iff |
1139 by (simp add: monom_mult_is_smult [THEN sym] UP_integral_iff |
1150 inj_on_iff [OF monom_inj, of _ "\<zero>", simplified]) |
1140 inj_on_iff [OF monom_inj, of _ "\<zero>", simplified]) |
1151 |
1141 |
|
1142 |
1152 subsection {* Evaluation Homomorphism and Universal Property*} |
1143 subsection {* Evaluation Homomorphism and Universal Property*} |
1153 |
|
1154 ML_setup {* |
|
1155 simpset_ref() := simpset() setsubgoaler asm_full_simp_tac; |
|
1156 *} |
|
1157 |
1144 |
1158 (* alternative congruence rule (possibly more efficient) |
1145 (* alternative congruence rule (possibly more efficient) |
1159 lemma (in abelian_monoid) finsum_cong2: |
1146 lemma (in abelian_monoid) finsum_cong2: |
1160 "[| !!i. i \<in> A ==> f i \<in> carrier G = True; A = B; |
1147 "[| !!i. i \<in> A ==> f i \<in> carrier G = True; A = B; |
1161 !!i. i \<in> B ==> f i = g i |] ==> finsum G f A = finsum G g B" |
1148 !!i. i \<in> B ==> f i = g i |] ==> finsum G f A = finsum G g B" |
1162 sorry |
1149 sorry*) |
1163 *) |
1150 |
|
1151 ML_setup {* |
|
1152 simpset_ref() := simpset() setsubgoaler asm_full_simp_tac; |
|
1153 *} |
1164 |
1154 |
1165 theorem (in cring) diagonal_sum: |
1155 theorem (in cring) diagonal_sum: |
1166 "[| f \<in> {..n + m::nat} -> carrier R; g \<in> {..n + m} -> carrier R |] ==> |
1156 "[| f \<in> {..n + m::nat} -> carrier R; g \<in> {..n + m} -> carrier R |] ==> |
1167 finsum R (%k. finsum R (%i. f i \<otimes> g (k - i)) {..k}) {..n + m} = |
1157 (\<Oplus>k \<in> {..n + m}. \<Oplus>i \<in> {..k}. f i \<otimes> g (k - i)) = |
1168 finsum R (%k. finsum R (%i. f k \<otimes> g i) {..n + m - k}) {..n + m}" |
1158 (\<Oplus>k \<in> {..n + m}. \<Oplus>i \<in> {..n + m - k}. f k \<otimes> g i)" |
1169 proof - |
1159 proof - |
1170 assume Rf: "f \<in> {..n + m} -> carrier R" and Rg: "g \<in> {..n + m} -> carrier R" |
1160 assume Rf: "f \<in> {..n + m} -> carrier R" and Rg: "g \<in> {..n + m} -> carrier R" |
1171 { |
1161 { |
1172 fix j |
1162 fix j |
1173 have "j <= n + m ==> |
1163 have "j <= n + m ==> |
1174 finsum R (%k. finsum R (%i. f i \<otimes> g (k - i)) {..k}) {..j} = |
1164 (\<Oplus>k \<in> {..j}. \<Oplus>i \<in> {..k}. f i \<otimes> g (k - i)) = |
1175 finsum R (%k. finsum R (%i. f k \<otimes> g i) {..j - k}) {..j}" |
1165 (\<Oplus>k \<in> {..j}. \<Oplus>i \<in> {..j - k}. f k \<otimes> g i)" |
1176 proof (induct j) |
1166 proof (induct j) |
1177 case 0 from Rf Rg show ?case by (simp add: Pi_def) |
1167 case 0 from Rf Rg show ?case by (simp add: Pi_def) |
1178 next |
1168 next |
1179 case (Suc j) |
1169 case (Suc j) |
1180 (* The following could be simplified if there was a reasoner for |
1170 (* The following could be simplified if there was a reasoner for |
1181 total orders integrated with simip. *) |
1171 total orders integrated with simip. *) |
1182 have R6: "!!i k. [| k <= j; i <= Suc j - k |] ==> g i \<in> carrier R" |
1172 have R6: "!!i k. [| k <= j; i <= Suc j - k |] ==> g i \<in> carrier R" |
1183 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1173 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1184 have R8: "!!i k. [| k <= Suc j; i <= k |] ==> g (k - i) \<in> carrier R" |
1174 have R8: "!!i k. [| k <= Suc j; i <= k |] ==> g (k - i) \<in> carrier R" |
1185 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1175 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1186 have R9: "!!i k. [| k <= Suc j |] ==> f k \<in> carrier R" |
1176 have R9: "!!i k. [| k <= Suc j |] ==> f k \<in> carrier R" |
1187 using Suc by (auto intro!: funcset_mem [OF Rf]) |
1177 using Suc by (auto intro!: funcset_mem [OF Rf]) |
1188 have R10: "!!i k. [| k <= Suc j; i <= Suc j - k |] ==> g i \<in> carrier R" |
1178 have R10: "!!i k. [| k <= Suc j; i <= Suc j - k |] ==> g i \<in> carrier R" |
1189 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1179 using Suc by (auto intro!: funcset_mem [OF Rg]) arith |
1190 have R11: "g 0 \<in> carrier R" |
1180 have R11: "g 0 \<in> carrier R" |
1191 using Suc by (auto intro!: funcset_mem [OF Rg]) |
1181 using Suc by (auto intro!: funcset_mem [OF Rg]) |
1192 from Suc show ?case |
1182 from Suc show ?case |
1193 by (simp cong: finsum_cong add: Suc_diff_le a_ac |
1183 by (simp cong: finsum_cong add: Suc_diff_le a_ac |
1194 Pi_def R6 R8 R9 R10 R11) |
1184 Pi_def R6 R8 R9 R10 R11) |
1195 qed |
1185 qed |
1196 } |
1186 } |
1197 then show ?thesis by fast |
1187 then show ?thesis by fast |
1198 qed |
1188 qed |
1199 |
1189 |
1218 proof - |
1207 proof - |
1219 fix x |
1208 fix x |
1220 show "g x \<in> carrier R" |
1209 show "g x \<in> carrier R" |
1221 using Rg bg boundD_carrier by (cases "x <= m") (auto simp: Pi_def) |
1210 using Rg bg boundD_carrier by (cases "x <= m") (auto simp: Pi_def) |
1222 qed |
1211 qed |
1223 from f g have "finsum R (%k. finsum R (%i. f i \<otimes> g (k-i)) {..k}) {..n + m} = |
1212 from f g have "(\<Oplus>k \<in> {..n + m}. \<Oplus>i \<in> {..k}. f i \<otimes> g (k - i)) = |
1224 finsum R (%k. finsum R (%i. f k \<otimes> g i) {..n + m - k}) {..n + m}" |
1213 (\<Oplus>k \<in> {..n + m}. \<Oplus>i \<in> {..n + m - k}. f k \<otimes> g i)" |
1225 by (simp add: diagonal_sum Pi_def) |
1214 by (simp add: diagonal_sum Pi_def) |
1226 also have "... = finsum R |
1215 also have "... = (\<Oplus>k \<in> {..n} \<union> {)n..n + m}. \<Oplus>i \<in> {..n + m - k}. f k \<otimes> g i)" |
1227 (%k. finsum R (%i. f k \<otimes> g i) {..n + m - k}) ({..n} Un {)n..n + m})" |
|
1228 by (simp only: ivl_disj_un_one) |
1216 by (simp only: ivl_disj_un_one) |
1229 also from f g have "... = finsum R |
1217 also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..n + m - k}. f k \<otimes> g i)" |
1230 (%k. finsum R (%i. f k \<otimes> g i) {..n + m - k}) {..n}" |
|
1231 by (simp cong: finsum_cong |
1218 by (simp cong: finsum_cong |
1232 add: boundD [OF bf] finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1219 add: bound.bound [OF bf] finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1233 also from f g have "... = finsum R |
1220 also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..m} \<union> {)m..n + m - k}. f k \<otimes> g i)" |
1234 (%k. finsum R (%i. f k \<otimes> g i) ({..m} Un {)m..n + m - k})) {..n}" |
|
1235 by (simp cong: finsum_cong add: ivl_disj_un_one le_add_diff Pi_def) |
1221 by (simp cong: finsum_cong add: ivl_disj_un_one le_add_diff Pi_def) |
1236 also from f g have "... = finsum R |
1222 also from f g have "... = (\<Oplus>k \<in> {..n}. \<Oplus>i \<in> {..m}. f k \<otimes> g i)" |
1237 (%k. finsum R (%i. f k \<otimes> g i) {..m}) {..n}" |
|
1238 by (simp cong: finsum_cong |
1223 by (simp cong: finsum_cong |
1239 add: boundD [OF bg] finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1224 add: bound.bound [OF bg] finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1240 also from f g have "... = finsum R f {..n} \<otimes> finsum R g {..m}" |
1225 also from f g have "... = (\<Oplus>i \<in> {..n}. f i) \<otimes> (\<Oplus>i \<in> {..m}. g i)" |
1241 by (simp add: finsum_ldistr diagonal_sum Pi_def, |
1226 by (simp add: finsum_ldistr diagonal_sum Pi_def, |
1242 simp cong: finsum_cong add: finsum_rdistr Pi_def) |
1227 simp cong: finsum_cong add: finsum_rdistr Pi_def) |
1243 finally show ?thesis . |
1228 finally show ?thesis . |
1244 qed |
1229 qed |
1245 |
1230 |
1280 fix p q |
1265 fix p q |
1281 assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S" |
1266 assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S" |
1282 then show "eval R S h s (p \<otimes>\<^sub>3 q) = eval R S h s p \<otimes>\<^sub>2 eval R S h s q" |
1267 then show "eval R S h s (p \<otimes>\<^sub>3 q) = eval R S h s p \<otimes>\<^sub>2 eval R S h s q" |
1283 proof (simp only: eval_on_carrier UP_mult_closed) |
1268 proof (simp only: eval_on_carrier UP_mult_closed) |
1284 from RS have |
1269 from RS have |
1285 "finsum S (%i. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R (p \<otimes>\<^sub>3 q)} = |
1270 "(\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = |
1286 finsum S (%i. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1271 (\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)} \<union> {)deg R (p \<otimes>\<^sub>3 q)..deg R p + deg R q}. |
1287 ({..deg R (p \<otimes>\<^sub>3 q)} Un {)deg R (p \<otimes>\<^sub>3 q)..deg R p + deg R q})" |
1272 h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1288 by (simp cong: finsum_cong |
1273 by (simp cong: finsum_cong |
1289 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def |
1274 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def |
1290 del: coeff_mult) |
1275 del: coeff_mult) |
1291 also from RS have "... = |
1276 also from RS have "... = |
1292 finsum S (%i. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R p + deg R q}" |
1277 (\<Oplus>\<^sub>2 i \<in> {..deg R p + deg R q}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1293 by (simp only: ivl_disj_un_one deg_mult_cring) |
1278 by (simp only: ivl_disj_un_one deg_mult_cring) |
1294 also from RS have "... = |
1279 also from RS have "... = |
1295 finsum S (%i. |
1280 (\<Oplus>\<^sub>2 i \<in> {..deg R p + deg R q}. |
1296 finsum S (%k. |
1281 \<Oplus>\<^sub>2 k \<in> {..i}. h (coeff P p k) \<otimes>\<^sub>2 h (coeff P q (i - k)) \<otimes>\<^sub>2 (s (^)\<^sub>2 k \<otimes>\<^sub>2 s (^)\<^sub>2 (i - k)))" |
1297 (h (coeff P p k) \<otimes>\<^sub>2 h (coeff P q (i-k))) \<otimes>\<^sub>2 (s (^)\<^sub>2 k \<otimes>\<^sub>2 s (^)\<^sub>2 (i-k))) |
|
1298 {..i}) {..deg R p + deg R q}" |
|
1299 by (simp cong: finsum_cong add: nat_pow_mult Pi_def |
1282 by (simp cong: finsum_cong add: nat_pow_mult Pi_def |
1300 S.m_ac S.finsum_rdistr) |
1283 S.m_ac S.finsum_rdistr) |
1301 also from RS have "... = |
1284 also from RS have "... = |
1302 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R p} \<otimes>\<^sub>2 |
1285 (\<Oplus>\<^sub>2i\<in>{..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<otimes>\<^sub>2 |
1303 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R q}" |
1286 (\<Oplus>\<^sub>2i\<in>{..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1304 by (simp add: S.cauchy_product [THEN sym] boundI deg_aboveD S.m_ac |
1287 by (simp add: S.cauchy_product [THEN sym] bound.intro deg_aboveD S.m_ac |
1305 Pi_def) |
1288 Pi_def) |
1306 finally show |
1289 finally show |
1307 "finsum S (%i. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R (p \<otimes>\<^sub>3 q)} = |
1290 "(\<Oplus>\<^sub>2 i \<in> {..deg R (p \<otimes>\<^sub>3 q)}. h (coeff P (p \<otimes>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = |
1308 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R p} \<otimes>\<^sub>2 |
1291 (\<Oplus>\<^sub>2 i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<otimes>\<^sub>2 |
1309 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R q}" . |
1292 (\<Oplus>\<^sub>2 i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" . |
1310 qed |
1293 qed |
1311 next |
1294 next |
1312 fix p q |
1295 fix p q |
1313 assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S" |
1296 assume RS: "p \<in> carrier P" "q \<in> carrier P" "s \<in> carrier S" |
1314 then show "eval R S h s (p \<oplus>\<^sub>3 q) = eval R S h s p \<oplus>\<^sub>2 eval R S h s q" |
1297 then show "eval R S h s (p \<oplus>\<^sub>3 q) = eval R S h s p \<oplus>\<^sub>2 eval R S h s q" |
1315 proof (simp only: eval_on_carrier UP_a_closed) |
1298 proof (simp only: eval_on_carrier UP_a_closed) |
1316 from RS have |
1299 from RS have |
1317 "finsum S (%i. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R (p \<oplus>\<^sub>3 q)} = |
1300 "(\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = |
1318 finsum S (%i. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1301 (\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)} \<union> {)deg R (p \<oplus>\<^sub>3 q)..max (deg R p) (deg R q)}. |
1319 ({..deg R (p \<oplus>\<^sub>3 q)} Un {)deg R (p \<oplus>\<^sub>3 q)..max (deg R p) (deg R q)})" |
1302 h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1320 by (simp cong: finsum_cong |
1303 by (simp cong: finsum_cong |
1321 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def |
1304 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def |
1322 del: coeff_add) |
1305 del: coeff_add) |
1323 also from RS have "... = |
1306 also from RS have "... = |
1324 finsum S (%i. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1307 (\<Oplus>\<^sub>2 i \<in> {..max (deg R p) (deg R q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1325 {..max (deg R p) (deg R q)}" |
|
1326 by (simp add: ivl_disj_un_one) |
1308 by (simp add: ivl_disj_un_one) |
1327 also from RS have "... = |
1309 also from RS have "... = |
1328 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..max (deg R p) (deg R q)} \<oplus>\<^sub>2 |
1310 (\<Oplus>\<^sub>2i\<in>{..max (deg R p) (deg R q)}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2 |
1329 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..max (deg R p) (deg R q)}" |
1311 (\<Oplus>\<^sub>2i\<in>{..max (deg R p) (deg R q)}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1330 by (simp cong: finsum_cong |
1312 by (simp cong: finsum_cong |
1331 add: l_distr deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1313 add: l_distr deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1332 also have "... = |
1314 also have "... = |
1333 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1315 (\<Oplus>\<^sub>2 i \<in> {..deg R p} \<union> {)deg R p..max (deg R p) (deg R q)}. |
1334 ({..deg R p} Un {)deg R p..max (deg R p) (deg R q)}) \<oplus>\<^sub>2 |
1316 h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2 |
1335 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1317 (\<Oplus>\<^sub>2 i \<in> {..deg R q} \<union> {)deg R q..max (deg R p) (deg R q)}. |
1336 ({..deg R q} Un {)deg R q..max (deg R p) (deg R q)})" |
1318 h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1337 by (simp only: ivl_disj_un_one le_maxI1 le_maxI2) |
1319 by (simp only: ivl_disj_un_one le_maxI1 le_maxI2) |
1338 also from RS have "... = |
1320 also from RS have "... = |
1339 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R p} \<oplus>\<^sub>2 |
1321 (\<Oplus>\<^sub>2 i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2 |
1340 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R q}" |
1322 (\<Oplus>\<^sub>2 i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1341 by (simp cong: finsum_cong |
1323 by (simp cong: finsum_cong |
1342 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1324 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1343 finally show |
1325 finally show |
1344 "finsum S (%i. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R (p \<oplus>\<^sub>3 q)} = |
1326 "(\<Oplus>\<^sub>2i \<in> {..deg R (p \<oplus>\<^sub>3 q)}. h (coeff P (p \<oplus>\<^sub>3 q) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = |
1345 finsum S (%i. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R p} \<oplus>\<^sub>2 |
1327 (\<Oplus>\<^sub>2i \<in> {..deg R p}. h (coeff P p i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) \<oplus>\<^sub>2 |
1346 finsum S (%i. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..deg R q}" |
1328 (\<Oplus>\<^sub>2i \<in> {..deg R q}. h (coeff P q i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1347 . |
1329 . |
1348 qed |
1330 qed |
1349 next |
1331 next |
1350 assume S: "s \<in> carrier S" |
1332 assume S: "s \<in> carrier S" |
1351 then show "eval R S h s \<one>\<^sub>3 = \<one>\<^sub>2" |
1333 then show "eval R S h s \<one>\<^sub>3 = \<one>\<^sub>2" |
1412 |
1394 |
1413 lemma (in ring_hom_UP_cring) eval_monom1: |
1395 lemma (in ring_hom_UP_cring) eval_monom1: |
1414 "s \<in> carrier S ==> eval R S h s (monom P \<one> 1) = s" |
1396 "s \<in> carrier S ==> eval R S h s (monom P \<one> 1) = s" |
1415 proof (simp only: eval_on_carrier monom_closed R.one_closed) |
1397 proof (simp only: eval_on_carrier monom_closed R.one_closed) |
1416 assume S: "s \<in> carrier S" |
1398 assume S: "s \<in> carrier S" |
1417 then have "finsum S (\<lambda>i. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1399 then have |
1418 {..deg R (monom P \<one> 1)} = |
1400 "(\<Oplus>\<^sub>2 i \<in> {..deg R (monom P \<one> 1)}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = |
1419 finsum S (\<lambda>i. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1401 (\<Oplus>\<^sub>2i\<in>{..deg R (monom P \<one> 1)} \<union> {)deg R (monom P \<one> 1)..1}. |
1420 ({..deg R (monom P \<one> 1)} Un {)deg R (monom P \<one> 1)..1})" |
1402 h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1421 by (simp cong: finsum_cong del: coeff_monom |
1403 by (simp cong: finsum_cong del: coeff_monom |
1422 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1404 add: deg_aboveD finsum_Un_disjoint ivl_disj_int_one Pi_def) |
1423 also have "... = |
1405 also have "... = |
1424 finsum S (\<lambda>i. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) {..1}" |
1406 (\<Oplus>\<^sub>2 i \<in> {..1}. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i)" |
1425 by (simp only: ivl_disj_un_one deg_monom_le R.one_closed) |
1407 by (simp only: ivl_disj_un_one deg_monom_le R.one_closed) |
1426 also have "... = s" |
1408 also have "... = s" |
1427 proof (cases "s = \<zero>\<^sub>2") |
1409 proof (cases "s = \<zero>\<^sub>2") |
1428 case True then show ?thesis by (simp add: Pi_def) |
1410 case True then show ?thesis by (simp add: Pi_def) |
1429 next |
1411 next |
1430 case False with S show ?thesis by (simp add: Pi_def) |
1412 case False with S show ?thesis by (simp add: Pi_def) |
1431 qed |
1413 qed |
1432 finally show "finsum S (\<lambda>i. h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) |
1414 finally show "(\<Oplus>\<^sub>2 i \<in> {..deg R (monom P \<one> 1)}. |
1433 {..deg R (monom P \<one> 1)} = s" . |
1415 h (coeff P (monom P \<one> 1) i) \<otimes>\<^sub>2 s (^)\<^sub>2 i) = s" . |
1434 qed |
1416 qed |
1435 |
1417 |
1436 lemma (in UP_cring) monom_pow: |
1418 lemma (in UP_cring) monom_pow: |
1437 assumes R: "a \<in> carrier R" |
1419 assumes R: "a \<in> carrier R" |
1438 shows "(monom P a n) (^)\<^sub>2 m = monom P (a (^) m) (n * m)" |
1420 shows "(monom P a n) (^)\<^sub>2 m = monom P (a (^) m) (n * m)" |
1489 proof - |
1471 proof - |
1490 have Phi_hom: "ring_hom_cring P S Phi" |
1472 have Phi_hom: "ring_hom_cring P S Phi" |
1491 by (auto intro: ring_hom_cringI UP_cring S.cring Phi) |
1473 by (auto intro: ring_hom_cringI UP_cring S.cring Phi) |
1492 have Psi_hom: "ring_hom_cring P S Psi" |
1474 have Psi_hom: "ring_hom_cring P S Psi" |
1493 by (auto intro: ring_hom_cringI UP_cring S.cring Psi) |
1475 by (auto intro: ring_hom_cringI UP_cring S.cring Psi) |
1494 have "Phi p = Phi (finsum P |
1476 have "Phi p = Phi (\<Oplus>\<^sub>3i \<in> {..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^sub>3 monom P \<one> 1 (^)\<^sub>3 i)" |
1495 (%i. monom P (coeff P p i) 0 \<otimes>\<^sub>3 (monom P \<one> 1) (^)\<^sub>3 i) {..deg R p})" |
|
1496 by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult) |
1477 by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult) |
1497 also have "... = Psi (finsum P |
1478 also have "... = Psi (\<Oplus>\<^sub>3i\<in>{..deg R p}. monom P (coeff P p i) 0 \<otimes>\<^sub>3 monom P \<one> 1 (^)\<^sub>3 i)" |
1498 (%i. monom P (coeff P p i) 0 \<otimes>\<^sub>3 (monom P \<one> 1) (^)\<^sub>3 i) {..deg R p})" |
1479 by (simp add: ring_hom_cring.hom_finsum [OF Phi_hom] |
1499 by (simp add: ring_hom_cring.hom_finsum [OF Phi_hom] |
|
1500 ring_hom_cring.hom_mult [OF Phi_hom] |
1480 ring_hom_cring.hom_mult [OF Phi_hom] |
1501 ring_hom_cring.hom_pow [OF Phi_hom] Phi |
1481 ring_hom_cring.hom_pow [OF Phi_hom] Phi |
1502 ring_hom_cring.hom_finsum [OF Psi_hom] |
1482 ring_hom_cring.hom_finsum [OF Psi_hom] |
1503 ring_hom_cring.hom_mult [OF Psi_hom] |
1483 ring_hom_cring.hom_mult [OF Psi_hom] |
1504 ring_hom_cring.hom_pow [OF Psi_hom] Psi RS Pi_def comp_def) |
1484 ring_hom_cring.hom_pow [OF Psi_hom] Psi RS Pi_def comp_def) |
1505 also have "... = Psi p" |
1485 also have "... = Psi p" |
1506 by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult) |
1486 by (simp add: up_repr RS monom_mult [THEN sym] monom_pow del: monom_mult) |
1507 finally show ?thesis . |
1487 finally show ?thesis . |