author | eberlm |
Tue, 10 Nov 2015 14:46:11 +0100 | |
changeset 61608 | a0487caabb4a |
parent 61585 | a9599d3d7610 |
child 61610 | 4f54d2759a0b |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Library/Formal_Power_Series.thy |
29687 | 2 |
Author: Amine Chaieb, University of Cambridge |
3 |
*) |
|
4 |
||
60501 | 5 |
section \<open>A formalization of formal power series\<close> |
29687 | 6 |
|
7 |
theory Formal_Power_Series |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
8 |
imports Complex_Main "~~/src/HOL/Number_Theory/Euclidean_Algorithm" |
29687 | 9 |
begin |
10 |
||
60501 | 11 |
|
60500 | 12 |
subsection \<open>The type of formal power series\<close> |
29687 | 13 |
|
49834 | 14 |
typedef 'a fps = "{f :: nat \<Rightarrow> 'a. True}" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
15 |
morphisms fps_nth Abs_fps |
29687 | 16 |
by simp |
17 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
18 |
notation fps_nth (infixl "$" 75) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
19 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
20 |
lemma expand_fps_eq: "p = q \<longleftrightarrow> (\<forall>n. p $ n = q $ n)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
21 |
by (simp add: fps_nth_inject [symmetric] fun_eq_iff) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
22 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
23 |
lemma fps_ext: "(\<And>n. p $ n = q $ n) \<Longrightarrow> p = q" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
24 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
25 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
26 |
lemma fps_nth_Abs_fps [simp]: "Abs_fps f $ n = f n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
27 |
by (simp add: Abs_fps_inverse) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
28 |
|
60501 | 29 |
text \<open>Definition of the basic elements 0 and 1 and the basic operations of addition, |
30 |
negation and multiplication.\<close> |
|
29687 | 31 |
|
36409 | 32 |
instantiation fps :: (zero) zero |
29687 | 33 |
begin |
60501 | 34 |
definition fps_zero_def: "0 = Abs_fps (\<lambda>n. 0)" |
35 |
instance .. |
|
29687 | 36 |
end |
37 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
38 |
lemma fps_zero_nth [simp]: "0 $ n = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
39 |
unfolding fps_zero_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
40 |
|
36409 | 41 |
instantiation fps :: ("{one, zero}") one |
29687 | 42 |
begin |
60501 | 43 |
definition fps_one_def: "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)" |
44 |
instance .. |
|
29687 | 45 |
end |
46 |
||
30488 | 47 |
lemma fps_one_nth [simp]: "1 $ n = (if n = 0 then 1 else 0)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
48 |
unfolding fps_one_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
49 |
|
54681 | 50 |
instantiation fps :: (plus) plus |
29687 | 51 |
begin |
60501 | 52 |
definition fps_plus_def: "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))" |
53 |
instance .. |
|
29687 | 54 |
end |
55 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
56 |
lemma fps_add_nth [simp]: "(f + g) $ n = f $ n + g $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
57 |
unfolding fps_plus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
58 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
59 |
instantiation fps :: (minus) minus |
29687 | 60 |
begin |
60501 | 61 |
definition fps_minus_def: "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))" |
62 |
instance .. |
|
29687 | 63 |
end |
64 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
65 |
lemma fps_sub_nth [simp]: "(f - g) $ n = f $ n - g $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
66 |
unfolding fps_minus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
67 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
68 |
instantiation fps :: (uminus) uminus |
29687 | 69 |
begin |
60501 | 70 |
definition fps_uminus_def: "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))" |
71 |
instance .. |
|
29687 | 72 |
end |
73 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
74 |
lemma fps_neg_nth [simp]: "(- f) $ n = - (f $ n)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
75 |
unfolding fps_uminus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
76 |
|
54681 | 77 |
instantiation fps :: ("{comm_monoid_add, times}") times |
29687 | 78 |
begin |
60501 | 79 |
definition fps_times_def: "op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))" |
80 |
instance .. |
|
29687 | 81 |
end |
82 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
83 |
lemma fps_mult_nth: "(f * g) $ n = (\<Sum>i=0..n. f$i * g$(n - i))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
84 |
unfolding fps_times_def by simp |
29687 | 85 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
86 |
lemma fps_mult_nth_0 [simp]: "(f * g) $ 0 = f $ 0 * g $ 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
87 |
unfolding fps_times_def by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
88 |
|
52891 | 89 |
declare atLeastAtMost_iff [presburger] |
90 |
declare Bex_def [presburger] |
|
91 |
declare Ball_def [presburger] |
|
29687 | 92 |
|
29913 | 93 |
lemma mult_delta_left: |
94 |
fixes x y :: "'a::mult_zero" |
|
95 |
shows "(if b then x else 0) * y = (if b then x * y else 0)" |
|
96 |
by simp |
|
97 |
||
98 |
lemma mult_delta_right: |
|
99 |
fixes x y :: "'a::mult_zero" |
|
100 |
shows "x * (if b then y else 0) = (if b then x * y else 0)" |
|
101 |
by simp |
|
102 |
||
29687 | 103 |
lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)" |
104 |
by auto |
|
52891 | 105 |
|
29687 | 106 |
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" |
107 |
by auto |
|
108 |
||
60501 | 109 |
|
110 |
subsection \<open>Formal power series form a commutative ring with unity, if the range of sequences |
|
60500 | 111 |
they represent is a commutative ring with unity\<close> |
29687 | 112 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
113 |
instance fps :: (semigroup_add) semigroup_add |
29687 | 114 |
proof |
52891 | 115 |
fix a b c :: "'a fps" |
116 |
show "a + b + c = a + (b + c)" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
117 |
by (simp add: fps_ext add.assoc) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
118 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
119 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
120 |
instance fps :: (ab_semigroup_add) ab_semigroup_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
121 |
proof |
52891 | 122 |
fix a b :: "'a fps" |
123 |
show "a + b = b + a" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
124 |
by (simp add: fps_ext add.commute) |
29687 | 125 |
qed |
126 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
127 |
lemma fps_mult_assoc_lemma: |
53195 | 128 |
fixes k :: nat |
129 |
and f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
130 |
shows "(\<Sum>j=0..k. \<Sum>i=0..j. f i (j - i) (n - j)) = |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
131 |
(\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
132 |
by (induct k) (simp_all add: Suc_diff_le setsum.distrib add.assoc) |
29687 | 133 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
134 |
instance fps :: (semiring_0) semigroup_mult |
29687 | 135 |
proof |
136 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
137 |
show "(a * b) * c = a * (b * c)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
138 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
139 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
140 |
have "(\<Sum>j=0..n. \<Sum>i=0..j. a$i * b$(j - i) * c$(n - j)) = |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
141 |
(\<Sum>j=0..n. \<Sum>i=0..n - j. a$j * b$i * c$(n - j - i))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
142 |
by (rule fps_mult_assoc_lemma) |
52891 | 143 |
then show "((a * b) * c) $ n = (a * (b * c)) $ n" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
144 |
by (simp add: fps_mult_nth setsum_right_distrib setsum_left_distrib mult.assoc) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
145 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
146 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
147 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
148 |
lemma fps_mult_commute_lemma: |
52903 | 149 |
fixes n :: nat |
150 |
and f :: "nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
151 |
shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
152 |
by (rule setsum.reindex_bij_witness[where i="op - n" and j="op - n"]) auto |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
153 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
154 |
instance fps :: (comm_semiring_0) ab_semigroup_mult |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
155 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
156 |
fix a b :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
157 |
show "a * b = b * a" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
158 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
159 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
160 |
have "(\<Sum>i=0..n. a$i * b$(n - i)) = (\<Sum>i=0..n. a$(n - i) * b$i)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
161 |
by (rule fps_mult_commute_lemma) |
52891 | 162 |
then show "(a * b) $ n = (b * a) $ n" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
163 |
by (simp add: fps_mult_nth mult.commute) |
29687 | 164 |
qed |
165 |
qed |
|
166 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
167 |
instance fps :: (monoid_add) monoid_add |
29687 | 168 |
proof |
52891 | 169 |
fix a :: "'a fps" |
170 |
show "0 + a = a" by (simp add: fps_ext) |
|
171 |
show "a + 0 = a" by (simp add: fps_ext) |
|
29687 | 172 |
qed |
173 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
174 |
instance fps :: (comm_monoid_add) comm_monoid_add |
29687 | 175 |
proof |
52891 | 176 |
fix a :: "'a fps" |
177 |
show "0 + a = a" by (simp add: fps_ext) |
|
29687 | 178 |
qed |
179 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
180 |
instance fps :: (semiring_1) monoid_mult |
29687 | 181 |
proof |
52891 | 182 |
fix a :: "'a fps" |
60501 | 183 |
show "1 * a = a" |
184 |
by (simp add: fps_ext fps_mult_nth mult_delta_left setsum.delta) |
|
185 |
show "a * 1 = a" |
|
186 |
by (simp add: fps_ext fps_mult_nth mult_delta_right setsum.delta') |
|
29687 | 187 |
qed |
188 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
189 |
instance fps :: (cancel_semigroup_add) cancel_semigroup_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
190 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
191 |
fix a b c :: "'a fps" |
60501 | 192 |
show "b = c" if "a + b = a + c" |
193 |
using that by (simp add: expand_fps_eq) |
|
194 |
show "b = c" if "b + a = c + a" |
|
195 |
using that by (simp add: expand_fps_eq) |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
196 |
qed |
29687 | 197 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
198 |
instance fps :: (cancel_ab_semigroup_add) cancel_ab_semigroup_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
199 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
200 |
fix a b c :: "'a fps" |
60501 | 201 |
show "a + b - a = b" |
202 |
by (simp add: expand_fps_eq) |
|
203 |
show "a - b - c = a - (b + c)" |
|
204 |
by (simp add: expand_fps_eq diff_diff_eq) |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
205 |
qed |
29687 | 206 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
207 |
instance fps :: (cancel_comm_monoid_add) cancel_comm_monoid_add .. |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
208 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
209 |
instance fps :: (group_add) group_add |
29687 | 210 |
proof |
52891 | 211 |
fix a b :: "'a fps" |
212 |
show "- a + a = 0" by (simp add: fps_ext) |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
213 |
show "a + - b = a - b" by (simp add: fps_ext) |
29687 | 214 |
qed |
215 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
216 |
instance fps :: (ab_group_add) ab_group_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
217 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
218 |
fix a b :: "'a fps" |
52891 | 219 |
show "- a + a = 0" by (simp add: fps_ext) |
220 |
show "a - b = a + - b" by (simp add: fps_ext) |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
221 |
qed |
29687 | 222 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
223 |
instance fps :: (zero_neq_one) zero_neq_one |
60679 | 224 |
by standard (simp add: expand_fps_eq) |
29687 | 225 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
226 |
instance fps :: (semiring_0) semiring |
29687 | 227 |
proof |
228 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
229 |
show "(a + b) * c = a * c + b * c" |
57418 | 230 |
by (simp add: expand_fps_eq fps_mult_nth distrib_right setsum.distrib) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
231 |
show "a * (b + c) = a * b + a * c" |
57418 | 232 |
by (simp add: expand_fps_eq fps_mult_nth distrib_left setsum.distrib) |
29687 | 233 |
qed |
234 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
235 |
instance fps :: (semiring_0) semiring_0 |
29687 | 236 |
proof |
53195 | 237 |
fix a :: "'a fps" |
60501 | 238 |
show "0 * a = 0" |
239 |
by (simp add: fps_ext fps_mult_nth) |
|
240 |
show "a * 0 = 0" |
|
241 |
by (simp add: fps_ext fps_mult_nth) |
|
29687 | 242 |
qed |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
243 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
244 |
instance fps :: (semiring_0_cancel) semiring_0_cancel .. |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
245 |
|
60867 | 246 |
instance fps :: (semiring_1) semiring_1 .. |
247 |
||
60501 | 248 |
|
60500 | 249 |
subsection \<open>Selection of the nth power of the implicit variable in the infinite sum\<close> |
29687 | 250 |
|
251 |
lemma fps_nonzero_nth: "f \<noteq> 0 \<longleftrightarrow> (\<exists> n. f $n \<noteq> 0)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
252 |
by (simp add: expand_fps_eq) |
29687 | 253 |
|
52902 | 254 |
lemma fps_nonzero_nth_minimal: "f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m < n. f $ m = 0))" |
60501 | 255 |
(is "?lhs \<longleftrightarrow> ?rhs") |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
256 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
257 |
let ?n = "LEAST n. f $ n \<noteq> 0" |
60501 | 258 |
show ?rhs if ?lhs |
259 |
proof - |
|
260 |
from that have "\<exists>n. f $ n \<noteq> 0" |
|
261 |
by (simp add: fps_nonzero_nth) |
|
262 |
then have "f $ ?n \<noteq> 0" |
|
263 |
by (rule LeastI_ex) |
|
264 |
moreover have "\<forall>m<?n. f $ m = 0" |
|
265 |
by (auto dest: not_less_Least) |
|
266 |
ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" .. |
|
267 |
then show ?thesis .. |
|
268 |
qed |
|
269 |
show ?lhs if ?rhs |
|
270 |
using that by (auto simp add: expand_fps_eq) |
|
29687 | 271 |
qed |
272 |
||
273 |
lemma fps_eq_iff: "f = g \<longleftrightarrow> (\<forall>n. f $ n = g $n)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
274 |
by (rule expand_fps_eq) |
29687 | 275 |
|
52891 | 276 |
lemma fps_setsum_nth: "setsum f S $ n = setsum (\<lambda>k. (f k) $ n) S" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
277 |
proof (cases "finite S") |
52891 | 278 |
case True |
279 |
then show ?thesis by (induct set: finite) auto |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
280 |
next |
52891 | 281 |
case False |
282 |
then show ?thesis by simp |
|
29687 | 283 |
qed |
284 |
||
60501 | 285 |
|
286 |
subsection \<open>Injection of the basic ring elements and multiplication by scalars\<close> |
|
29687 | 287 |
|
52891 | 288 |
definition "fps_const c = Abs_fps (\<lambda>n. if n = 0 then c else 0)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
289 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
290 |
lemma fps_nth_fps_const [simp]: "fps_const c $ n = (if n = 0 then c else 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
291 |
unfolding fps_const_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
292 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
293 |
lemma fps_const_0_eq_0 [simp]: "fps_const 0 = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
294 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
295 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
296 |
lemma fps_const_1_eq_1 [simp]: "fps_const 1 = 1" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
297 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
298 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
299 |
lemma fps_const_neg [simp]: "- (fps_const (c::'a::ring)) = fps_const (- c)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
300 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
301 |
|
54681 | 302 |
lemma fps_const_add [simp]: "fps_const (c::'a::monoid_add) + fps_const d = fps_const (c + d)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
303 |
by (simp add: fps_ext) |
52891 | 304 |
|
54681 | 305 |
lemma fps_const_sub [simp]: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)" |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
306 |
by (simp add: fps_ext) |
52891 | 307 |
|
54681 | 308 |
lemma fps_const_mult[simp]: "fps_const (c::'a::ring) * fps_const d = fps_const (c * d)" |
57418 | 309 |
by (simp add: fps_eq_iff fps_mult_nth setsum.neutral) |
29687 | 310 |
|
54681 | 311 |
lemma fps_const_add_left: "fps_const (c::'a::monoid_add) + f = |
48757 | 312 |
Abs_fps (\<lambda>n. if n = 0 then c + f$0 else f$n)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
313 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
314 |
|
54681 | 315 |
lemma fps_const_add_right: "f + fps_const (c::'a::monoid_add) = |
48757 | 316 |
Abs_fps (\<lambda>n. if n = 0 then f$0 + c else f$n)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
317 |
by (simp add: fps_ext) |
29687 | 318 |
|
54681 | 319 |
lemma fps_const_mult_left: "fps_const (c::'a::semiring_0) * f = Abs_fps (\<lambda>n. c * f$n)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
320 |
unfolding fps_eq_iff fps_mult_nth |
57418 | 321 |
by (simp add: fps_const_def mult_delta_left setsum.delta) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
322 |
|
54681 | 323 |
lemma fps_const_mult_right: "f * fps_const (c::'a::semiring_0) = Abs_fps (\<lambda>n. f$n * c)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
324 |
unfolding fps_eq_iff fps_mult_nth |
57418 | 325 |
by (simp add: fps_const_def mult_delta_right setsum.delta') |
29687 | 326 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
327 |
lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n" |
57418 | 328 |
by (simp add: fps_mult_nth mult_delta_left setsum.delta) |
29687 | 329 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
330 |
lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c" |
57418 | 331 |
by (simp add: fps_mult_nth mult_delta_right setsum.delta') |
29687 | 332 |
|
60501 | 333 |
|
60500 | 334 |
subsection \<open>Formal power series form an integral domain\<close> |
29687 | 335 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
336 |
instance fps :: (ring) ring .. |
29687 | 337 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
338 |
instance fps :: (ring_1) ring_1 |
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
339 |
by (intro_classes, auto simp add: distrib_right) |
29687 | 340 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
341 |
instance fps :: (comm_ring_1) comm_ring_1 |
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
342 |
by (intro_classes, auto simp add: distrib_right) |
29687 | 343 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
344 |
instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors |
29687 | 345 |
proof |
346 |
fix a b :: "'a fps" |
|
60501 | 347 |
assume "a \<noteq> 0" and "b \<noteq> 0" |
348 |
then obtain i j where i: "a $ i \<noteq> 0" "\<forall>k<i. a $ k = 0" and j: "b $ j \<noteq> 0" "\<forall>k<j. b $ k =0" |
|
54681 | 349 |
unfolding fps_nonzero_nth_minimal |
29687 | 350 |
by blast+ |
60501 | 351 |
have "(a * b) $ (i + j) = (\<Sum>k=0..i+j. a $ k * b $ (i + j - k))" |
29687 | 352 |
by (rule fps_mult_nth) |
60501 | 353 |
also have "\<dots> = (a $ i * b $ (i + j - i)) + (\<Sum>k\<in>{0..i+j} - {i}. a $ k * b $ (i + j - k))" |
57418 | 354 |
by (rule setsum.remove) simp_all |
60501 | 355 |
also have "(\<Sum>k\<in>{0..i+j}-{i}. a $ k * b $ (i + j - k)) = 0" |
356 |
proof (rule setsum.neutral [rule_format]) |
|
357 |
fix k assume "k \<in> {0..i+j} - {i}" |
|
358 |
then have "k < i \<or> i+j-k < j" |
|
359 |
by auto |
|
360 |
then show "a $ k * b $ (i + j - k) = 0" |
|
361 |
using i j by auto |
|
362 |
qed |
|
363 |
also have "a $ i * b $ (i + j - i) + 0 = a $ i * b $ j" |
|
364 |
by simp |
|
365 |
also have "a $ i * b $ j \<noteq> 0" |
|
366 |
using i j by simp |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
367 |
finally have "(a*b) $ (i+j) \<noteq> 0" . |
60501 | 368 |
then show "a * b \<noteq> 0" |
369 |
unfolding fps_nonzero_nth by blast |
|
29687 | 370 |
qed |
371 |
||
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
372 |
instance fps :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors .. |
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
373 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
374 |
instance fps :: (idom) idom .. |
29687 | 375 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
376 |
lemma numeral_fps_const: "numeral k = fps_const (numeral k)" |
48757 | 377 |
by (induct k) (simp_all only: numeral.simps fps_const_1_eq_1 |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
378 |
fps_const_add [symmetric]) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
379 |
|
60867 | 380 |
lemma neg_numeral_fps_const: |
381 |
"(- numeral k :: 'a :: ring_1 fps) = fps_const (- numeral k)" |
|
382 |
by (simp add: numeral_fps_const) |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
383 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
384 |
lemma fps_numeral_nth: "numeral n $ i = (if i = 0 then numeral n else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
385 |
by (simp add: numeral_fps_const) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
386 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
387 |
lemma fps_numeral_nth_0 [simp]: "numeral n $ 0 = numeral n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
388 |
by (simp add: numeral_fps_const) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
389 |
|
60501 | 390 |
|
391 |
subsection \<open>The eXtractor series X\<close> |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
392 |
|
54681 | 393 |
lemma minus_one_power_iff: "(- (1::'a::comm_ring_1)) ^ n = (if even n then 1 else - 1)" |
48757 | 394 |
by (induct n) auto |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
395 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
396 |
definition "X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)" |
53195 | 397 |
|
398 |
lemma X_mult_nth [simp]: |
|
54681 | 399 |
"(X * (f :: 'a::semiring_1 fps)) $n = (if n = 0 then 0 else f $ (n - 1))" |
53195 | 400 |
proof (cases "n = 0") |
401 |
case False |
|
402 |
have "(X * f) $n = (\<Sum>i = 0..n. X $ i * f $ (n - i))" |
|
403 |
by (simp add: fps_mult_nth) |
|
404 |
also have "\<dots> = f $ (n - 1)" |
|
57418 | 405 |
using False by (simp add: X_def mult_delta_left setsum.delta) |
60501 | 406 |
finally show ?thesis |
407 |
using False by simp |
|
53195 | 408 |
next |
409 |
case True |
|
60501 | 410 |
then show ?thesis |
411 |
by (simp add: fps_mult_nth X_def) |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
412 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
413 |
|
48757 | 414 |
lemma X_mult_right_nth[simp]: |
54681 | 415 |
"((f :: 'a::comm_semiring_1 fps) * X) $n = (if n = 0 then 0 else f $ (n - 1))" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
416 |
by (metis X_mult_nth mult.commute) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
417 |
|
54681 | 418 |
lemma X_power_iff: "X^k = Abs_fps (\<lambda>n. if n = k then 1::'a::comm_ring_1 else 0)" |
52902 | 419 |
proof (induct k) |
420 |
case 0 |
|
54452 | 421 |
then show ?case by (simp add: X_def fps_eq_iff) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
422 |
next |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
423 |
case (Suc k) |
60501 | 424 |
have "(X^Suc k) $ m = (if m = Suc k then 1::'a else 0)" for m |
425 |
proof - |
|
426 |
have "(X^Suc k) $ m = (if m = 0 then 0 else (X^k) $ (m - 1))" |
|
52891 | 427 |
by (simp del: One_nat_def) |
60501 | 428 |
then show ?thesis |
52891 | 429 |
using Suc.hyps by (auto cong del: if_weak_cong) |
60501 | 430 |
qed |
431 |
then show ?case |
|
432 |
by (simp add: fps_eq_iff) |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
433 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
434 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
435 |
lemma X_nth[simp]: "X$n = (if n = 1 then 1 else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
436 |
by (simp add: X_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
437 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
438 |
lemma X_power_nth[simp]: "(X^k) $n = (if n = k then 1 else 0::'a::comm_ring_1)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
439 |
by (simp add: X_power_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
440 |
|
60501 | 441 |
lemma X_power_mult_nth: "(X^k * (f :: 'a::comm_ring_1 fps)) $n = (if n < k then 0 else f $ (n - k))" |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
442 |
apply (induct k arbitrary: n) |
52891 | 443 |
apply simp |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
444 |
unfolding power_Suc mult.assoc |
48757 | 445 |
apply (case_tac n) |
446 |
apply auto |
|
447 |
done |
|
448 |
||
449 |
lemma X_power_mult_right_nth: |
|
54681 | 450 |
"((f :: 'a::comm_ring_1 fps) * X^k) $n = (if n < k then 0 else f $ (n - k))" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
451 |
by (metis X_power_mult_nth mult.commute) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
452 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
453 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
454 |
lemma X_neq_fps_const [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> fps_const c" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
455 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
456 |
assume "(X::'a fps) = fps_const (c::'a)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
457 |
hence "X$1 = (fps_const (c::'a))$1" by (simp only:) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
458 |
thus False by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
459 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
460 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
461 |
lemma X_neq_zero [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
462 |
by (simp only: fps_const_0_eq_0[symmetric] X_neq_fps_const) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
463 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
464 |
lemma X_neq_one [simp]: "(X :: 'a :: zero_neq_one fps) \<noteq> 1" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
465 |
by (simp only: fps_const_1_eq_1[symmetric] X_neq_fps_const) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
466 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
467 |
lemma X_neq_numeral [simp]: "(X :: 'a :: {semiring_1,zero_neq_one} fps) \<noteq> numeral c" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
468 |
by (simp only: numeral_fps_const X_neq_fps_const) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
469 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
470 |
lemma X_pow_eq_X_pow_iff [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
471 |
"(X :: ('a :: {comm_ring_1}) fps) ^ m = X ^ n \<longleftrightarrow> m = n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
472 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
473 |
assume "(X :: 'a fps) ^ m = X ^ n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
474 |
hence "(X :: 'a fps) ^ m $ m = X ^ n $ m" by (simp only:) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
475 |
thus "m = n" by (simp split: split_if_asm) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
476 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
477 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
478 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
479 |
subsection {* Subdegrees *} |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
480 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
481 |
definition subdegree :: "('a::zero) fps \<Rightarrow> nat" where |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
482 |
"subdegree f = (if f = 0 then 0 else LEAST n. f$n \<noteq> 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
483 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
484 |
lemma subdegreeI: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
485 |
assumes "f $ d \<noteq> 0" and "\<And>i. i < d \<Longrightarrow> f $ i = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
486 |
shows "subdegree f = d" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
487 |
proof- |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
488 |
from assms(1) have "f \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
489 |
moreover from assms(1) have "(LEAST i. f $ i \<noteq> 0) = d" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
490 |
proof (rule Least_equality) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
491 |
fix e assume "f $ e \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
492 |
with assms(2) have "\<not>(e < d)" by blast |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
493 |
thus "e \<ge> d" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
494 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
495 |
ultimately show ?thesis unfolding subdegree_def by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
496 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
497 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
498 |
lemma nth_subdegree_nonzero [simp,intro]: "f \<noteq> 0 \<Longrightarrow> f $ subdegree f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
499 |
proof- |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
500 |
assume "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
501 |
hence "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
502 |
also from \<open>f \<noteq> 0\<close> have "\<exists>n. f$n \<noteq> 0" using fps_nonzero_nth by blast |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
503 |
from LeastI_ex[OF this] have "f $ (LEAST n. f $ n \<noteq> 0) \<noteq> 0" . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
504 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
505 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
506 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
507 |
lemma nth_less_subdegree_zero [dest]: "n < subdegree f \<Longrightarrow> f $ n = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
508 |
proof (cases "f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
509 |
assume "f \<noteq> 0" and less: "n < subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
510 |
note less |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
511 |
also from \<open>f \<noteq> 0\<close> have "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
512 |
finally show "f $ n = 0" using not_less_Least by blast |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
513 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
514 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
515 |
lemma subdegree_geI: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
516 |
assumes "f \<noteq> 0" "\<And>i. i < n \<Longrightarrow> f$i = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
517 |
shows "subdegree f \<ge> n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
518 |
proof (rule ccontr) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
519 |
assume "\<not>(subdegree f \<ge> n)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
520 |
with assms(2) have "f $ subdegree f = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
521 |
moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
522 |
ultimately show False by contradiction |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
523 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
524 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
525 |
lemma subdegree_greaterI: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
526 |
assumes "f \<noteq> 0" "\<And>i. i \<le> n \<Longrightarrow> f$i = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
527 |
shows "subdegree f > n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
528 |
proof (rule ccontr) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
529 |
assume "\<not>(subdegree f > n)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
530 |
with assms(2) have "f $ subdegree f = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
531 |
moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
532 |
ultimately show False by contradiction |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
533 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
534 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
535 |
lemma subdegree_leI: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
536 |
"f $ n \<noteq> 0 \<Longrightarrow> subdegree f \<le> n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
537 |
by (rule leI) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
538 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
539 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
540 |
lemma subdegree_0 [simp]: "subdegree 0 = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
541 |
by (simp add: subdegree_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
542 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
543 |
lemma subdegree_1 [simp]: "subdegree (1 :: ('a :: zero_neq_one) fps) = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
544 |
by (auto intro!: subdegreeI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
545 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
546 |
lemma subdegree_X [simp]: "subdegree (X :: ('a :: zero_neq_one) fps) = 1" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
547 |
by (auto intro!: subdegreeI simp: X_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
548 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
549 |
lemma subdegree_fps_const [simp]: "subdegree (fps_const c) = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
550 |
by (cases "c = 0") (auto intro!: subdegreeI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
551 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
552 |
lemma subdegree_numeral [simp]: "subdegree (numeral n) = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
553 |
by (simp add: numeral_fps_const) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
554 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
555 |
lemma subdegree_eq_0_iff: "subdegree f = 0 \<longleftrightarrow> f = 0 \<or> f $ 0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
556 |
proof (cases "f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
557 |
assume "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
558 |
thus ?thesis |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
559 |
using nth_subdegree_nonzero[OF \<open>f \<noteq> 0\<close>] by (fastforce intro!: subdegreeI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
560 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
561 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
562 |
lemma subdegree_eq_0 [simp]: "f $ 0 \<noteq> 0 \<Longrightarrow> subdegree f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
563 |
by (simp add: subdegree_eq_0_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
564 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
565 |
lemma nth_subdegree_mult [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
566 |
fixes f g :: "('a :: {mult_zero,comm_monoid_add}) fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
567 |
shows "(f * g) $ (subdegree f + subdegree g) = f $ subdegree f * g $ subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
568 |
proof- |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
569 |
let ?n = "subdegree f + subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
570 |
have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
571 |
by (simp add: fps_mult_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
572 |
also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
573 |
proof (intro setsum.cong) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
574 |
fix x assume x: "x \<in> {0..?n}" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
575 |
hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
576 |
thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
577 |
by (elim disjE conjE) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
578 |
qed auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
579 |
also have "... = f $ subdegree f * g $ subdegree g" by (simp add: setsum.delta) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
580 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
581 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
582 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
583 |
lemma subdegree_mult [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
584 |
assumes "f \<noteq> 0" "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
585 |
shows "subdegree ((f :: ('a :: {ring_no_zero_divisors}) fps) * g) = subdegree f + subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
586 |
proof (rule subdegreeI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
587 |
let ?n = "subdegree f + subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
588 |
have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))" by (simp add: fps_mult_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
589 |
also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
590 |
proof (intro setsum.cong) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
591 |
fix x assume x: "x \<in> {0..?n}" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
592 |
hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
593 |
thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
594 |
by (elim disjE conjE) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
595 |
qed auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
596 |
also have "... = f $ subdegree f * g $ subdegree g" by (simp add: setsum.delta) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
597 |
also from assms have "... \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
598 |
finally show "(f * g) $ (subdegree f + subdegree g) \<noteq> 0" . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
599 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
600 |
fix m assume m: "m < subdegree f + subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
601 |
have "(f * g) $ m = (\<Sum>i=0..m. f$i * g$(m-i))" by (simp add: fps_mult_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
602 |
also have "... = (\<Sum>i=0..m. 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
603 |
proof (rule setsum.cong) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
604 |
fix i assume "i \<in> {0..m}" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
605 |
with m have "i < subdegree f \<or> m - i < subdegree g" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
606 |
thus "f$i * g$(m-i) = 0" by (elim disjE) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
607 |
qed auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
608 |
finally show "(f * g) $ m = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
609 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
610 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
611 |
lemma subdegree_power [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
612 |
"subdegree ((f :: ('a :: ring_1_no_zero_divisors) fps) ^ n) = n * subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
613 |
by (cases "f = 0"; induction n) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
614 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
615 |
lemma subdegree_uminus [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
616 |
"subdegree (-(f::('a::group_add) fps)) = subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
617 |
by (simp add: subdegree_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
618 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
619 |
lemma subdegree_minus_commute [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
620 |
"subdegree (f-(g::('a::group_add) fps)) = subdegree (g - f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
621 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
622 |
have "f - g = -(g - f)" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
623 |
also have "subdegree ... = subdegree (g - f)" by (simp only: subdegree_uminus) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
624 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
625 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
626 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
627 |
lemma subdegree_add_ge: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
628 |
assumes "f \<noteq> -(g :: ('a :: {group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
629 |
shows "subdegree (f + g) \<ge> min (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
630 |
proof (rule subdegree_geI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
631 |
from assms show "f + g \<noteq> 0" by (subst (asm) eq_neg_iff_add_eq_0) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
632 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
633 |
fix i assume "i < min (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
634 |
hence "f $ i = 0" and "g $ i = 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
635 |
thus "(f + g) $ i = 0" by force |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
636 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
637 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
638 |
lemma subdegree_add_eq1: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
639 |
assumes "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
640 |
assumes "subdegree f < subdegree (g :: ('a :: {group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
641 |
shows "subdegree (f + g) = subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
642 |
proof (rule antisym[OF subdegree_leI]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
643 |
from assms show "subdegree (f + g) \<ge> subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
644 |
by (intro order.trans[OF min.boundedI subdegree_add_ge]) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
645 |
from assms have "f $ subdegree f \<noteq> 0" "g $ subdegree f = 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
646 |
thus "(f + g) $ subdegree f \<noteq> 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
647 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
648 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
649 |
lemma subdegree_add_eq2: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
650 |
assumes "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
651 |
assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
652 |
shows "subdegree (f + g) = subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
653 |
using subdegree_add_eq1[OF assms] by (simp add: add.commute) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
654 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
655 |
lemma subdegree_diff_eq1: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
656 |
assumes "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
657 |
assumes "subdegree f < subdegree (g :: ('a :: {ab_group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
658 |
shows "subdegree (f - g) = subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
659 |
using subdegree_add_eq1[of f "-g"] assms by (simp add: add.commute) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
660 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
661 |
lemma subdegree_diff_eq2: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
662 |
assumes "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
663 |
assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
664 |
shows "subdegree (f - g) = subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
665 |
using subdegree_add_eq2[of "-g" f] assms by (simp add: add.commute) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
666 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
667 |
lemma subdegree_diff_ge [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
668 |
assumes "f \<noteq> (g :: ('a :: {group_add}) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
669 |
shows "subdegree (f - g) \<ge> min (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
670 |
using assms subdegree_add_ge[of f "-g"] by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
671 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
672 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
673 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
674 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
675 |
subsection \<open>Shifting and slicing\<close> |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
676 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
677 |
definition fps_shift :: "nat \<Rightarrow> 'a fps \<Rightarrow> 'a fps" where |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
678 |
"fps_shift n f = Abs_fps (\<lambda>i. f $ (i + n))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
679 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
680 |
lemma fps_shift_nth [simp]: "fps_shift n f $ i = f $ (i + n)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
681 |
by (simp add: fps_shift_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
682 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
683 |
lemma fps_shift_0 [simp]: "fps_shift 0 f = f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
684 |
by (intro fps_ext) (simp add: fps_shift_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
685 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
686 |
lemma fps_shift_zero [simp]: "fps_shift n 0 = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
687 |
by (intro fps_ext) (simp add: fps_shift_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
688 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
689 |
lemma fps_shift_one: "fps_shift n 1 = (if n = 0 then 1 else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
690 |
by (intro fps_ext) (simp add: fps_shift_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
691 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
692 |
lemma fps_shift_fps_const: "fps_shift n (fps_const c) = (if n = 0 then fps_const c else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
693 |
by (intro fps_ext) (simp add: fps_shift_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
694 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
695 |
lemma fps_shift_numeral: "fps_shift n (numeral c) = (if n = 0 then numeral c else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
696 |
by (simp add: numeral_fps_const fps_shift_fps_const) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
697 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
698 |
lemma fps_shift_X_power [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
699 |
"n \<le> m \<Longrightarrow> fps_shift n (X ^ m) = (X ^ (m - n) ::'a::comm_ring_1 fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
700 |
by (intro fps_ext) (auto simp: fps_shift_def ) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
701 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
702 |
lemma fps_shift_times_X_power: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
703 |
"n \<le> subdegree f \<Longrightarrow> fps_shift n f * X ^ n = (f :: 'a :: comm_ring_1 fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
704 |
by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
705 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
706 |
lemma fps_shift_times_X_power' [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
707 |
"fps_shift n (f * X^n) = (f :: 'a :: comm_ring_1 fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
708 |
by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
709 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
710 |
lemma fps_shift_times_X_power'': |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
711 |
"m \<le> n \<Longrightarrow> fps_shift n (f * X^m) = fps_shift (n - m) (f :: 'a :: comm_ring_1 fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
712 |
by (intro fps_ext) (auto simp: X_power_mult_right_nth nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
713 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
714 |
lemma fps_shift_subdegree [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
715 |
"n \<le> subdegree f \<Longrightarrow> subdegree (fps_shift n f) = subdegree (f :: 'a :: comm_ring_1 fps) - n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
716 |
by (cases "f = 0") (force intro: nth_less_subdegree_zero subdegreeI)+ |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
717 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
718 |
lemma subdegree_decompose: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
719 |
"f = fps_shift (subdegree f) f * X ^ subdegree (f :: ('a :: comm_ring_1) fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
720 |
by (rule fps_ext) (auto simp: X_power_mult_right_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
721 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
722 |
lemma subdegree_decompose': |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
723 |
"n \<le> subdegree (f :: ('a :: comm_ring_1) fps) \<Longrightarrow> f = fps_shift n f * X^n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
724 |
by (rule fps_ext) (auto simp: X_power_mult_right_nth intro!: nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
725 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
726 |
lemma fps_shift_fps_shift: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
727 |
"fps_shift (m + n) f = fps_shift m (fps_shift n f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
728 |
by (rule fps_ext) (simp add: add_ac) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
729 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
730 |
lemma fps_shift_add: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
731 |
"fps_shift n (f + g) = fps_shift n f + fps_shift n g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
732 |
by (simp add: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
733 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
734 |
lemma fps_shift_mult: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
735 |
assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
736 |
shows "fps_shift n (h*g) = h * fps_shift n g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
737 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
738 |
from assms have "g = fps_shift n g * X^n" by (rule subdegree_decompose') |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
739 |
also have "h * ... = (h * fps_shift n g) * X^n" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
740 |
also have "fps_shift n ... = h * fps_shift n g" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
741 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
742 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
743 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
744 |
lemma fps_shift_mult_right: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
745 |
assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
746 |
shows "fps_shift n (g*h) = h * fps_shift n g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
747 |
by (subst mult.commute, subst fps_shift_mult) (simp_all add: assms) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
748 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
749 |
lemma nth_subdegree_zero_iff [simp]: "f $ subdegree f = 0 \<longleftrightarrow> f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
750 |
by (cases "f = 0") auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
751 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
752 |
lemma fps_shift_subdegree_zero_iff [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
753 |
"fps_shift (subdegree f) f = 0 \<longleftrightarrow> f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
754 |
by (subst (1) nth_subdegree_zero_iff[symmetric], cases "f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
755 |
(simp_all del: nth_subdegree_zero_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
756 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
757 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
758 |
definition "fps_cutoff n f = Abs_fps (\<lambda>i. if i < n then f$i else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
759 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
760 |
lemma fps_cutoff_nth [simp]: "fps_cutoff n f $ i = (if i < n then f$i else 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
761 |
unfolding fps_cutoff_def by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
762 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
763 |
lemma fps_cutoff_zero_iff: "fps_cutoff n f = 0 \<longleftrightarrow> (f = 0 \<or> n \<le> subdegree f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
764 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
765 |
assume A: "fps_cutoff n f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
766 |
thus "f = 0 \<or> n \<le> subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
767 |
proof (cases "f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
768 |
assume "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
769 |
with A have "n \<le> subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
770 |
by (intro subdegree_geI) (auto simp: fps_eq_iff split: split_if_asm) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
771 |
thus ?thesis .. |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
772 |
qed simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
773 |
qed (auto simp: fps_eq_iff intro: nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
774 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
775 |
lemma fps_cutoff_0 [simp]: "fps_cutoff 0 f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
776 |
by (simp add: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
777 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
778 |
lemma fps_cutoff_zero [simp]: "fps_cutoff n 0 = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
779 |
by (simp add: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
780 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
781 |
lemma fps_cutoff_one: "fps_cutoff n 1 = (if n = 0 then 0 else 1)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
782 |
by (simp add: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
783 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
784 |
lemma fps_cutoff_fps_const: "fps_cutoff n (fps_const c) = (if n = 0 then 0 else fps_const c)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
785 |
by (simp add: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
786 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
787 |
lemma fps_cutoff_numeral: "fps_cutoff n (numeral c) = (if n = 0 then 0 else numeral c)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
788 |
by (simp add: numeral_fps_const fps_cutoff_fps_const) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
789 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
790 |
lemma fps_shift_cutoff: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
791 |
"fps_shift n (f :: ('a :: comm_ring_1) fps) * X^n + fps_cutoff n f = f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
792 |
by (simp add: fps_eq_iff X_power_mult_right_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
793 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
794 |
|
60501 | 795 |
subsection \<open>Formal Power series form a metric space\<close> |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
796 |
|
52902 | 797 |
definition (in dist) "ball x r = {y. dist y x < r}" |
48757 | 798 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
799 |
instantiation fps :: (comm_ring_1) dist |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
800 |
begin |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
801 |
|
52891 | 802 |
definition |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
803 |
dist_fps_def: "dist (a :: 'a fps) b = (if a = b then 0 else inverse (2 ^ subdegree (a - b)))" |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
804 |
|
54681 | 805 |
lemma dist_fps_ge0: "dist (a :: 'a fps) b \<ge> 0" |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
806 |
by (simp add: dist_fps_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
807 |
|
54681 | 808 |
lemma dist_fps_sym: "dist (a :: 'a fps) b = dist b a" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
809 |
by (simp add: dist_fps_def) |
48757 | 810 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
811 |
instance .. |
48757 | 812 |
|
30746 | 813 |
end |
814 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
815 |
instantiation fps :: (comm_ring_1) metric_space |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
816 |
begin |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
817 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
818 |
definition open_fps_def: "open (S :: 'a fps set) = (\<forall>a \<in> S. \<exists>r. r >0 \<and> ball a r \<subseteq> S)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
819 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
820 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
821 |
instance |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
822 |
proof |
60501 | 823 |
show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)" for S :: "'a fps set" |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
824 |
by (auto simp add: open_fps_def ball_def subset_eq) |
60501 | 825 |
show th: "dist a b = 0 \<longleftrightarrow> a = b" for a b :: "'a fps" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
826 |
by (simp add: dist_fps_def split: split_if_asm) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
827 |
then have th'[simp]: "dist a a = 0" for a :: "'a fps" by simp |
60501 | 828 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
829 |
fix a b c :: "'a fps" |
60501 | 830 |
consider "a = b" | "c = a \<or> c = b" | "a \<noteq> b" "a \<noteq> c" "b \<noteq> c" by blast |
831 |
then show "dist a b \<le> dist a c + dist b c" |
|
832 |
proof cases |
|
833 |
case 1 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
834 |
then show ?thesis by (simp add: dist_fps_def) |
60501 | 835 |
next |
836 |
case 2 |
|
837 |
then show ?thesis |
|
52891 | 838 |
by (cases "c = a") (simp_all add: th dist_fps_sym) |
60501 | 839 |
next |
60567 | 840 |
case neq: 3 |
60558 | 841 |
have False if "dist a b > dist a c + dist b c" |
842 |
proof - |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
843 |
let ?n = "subdegree (a - b)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
844 |
from neq have "dist a b > 0" "dist b c > 0" and "dist a c > 0" by (simp_all add: dist_fps_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
845 |
with that have "dist a b > dist a c" and "dist a b > dist b c" by simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
846 |
with neq have "?n < subdegree (a - c)" and "?n < subdegree (b - c)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
847 |
by (simp_all add: dist_fps_def field_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
848 |
hence "(a - c) $ ?n = 0" and "(b - c) $ ?n = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
849 |
by (simp_all only: nth_less_subdegree_zero) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
850 |
hence "(a - b) $ ?n = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
851 |
moreover from neq have "(a - b) $ ?n \<noteq> 0" by (intro nth_subdegree_nonzero) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
852 |
ultimately show False by contradiction |
60558 | 853 |
qed |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
854 |
thus ?thesis by (auto simp add: not_le[symmetric]) |
60501 | 855 |
qed |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
856 |
qed |
52891 | 857 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
858 |
end |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
859 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
860 |
|
60558 | 861 |
text \<open>The infinite sums and justification of the notation in textbooks.\<close> |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
862 |
|
52891 | 863 |
lemma reals_power_lt_ex: |
54681 | 864 |
fixes x y :: real |
865 |
assumes xp: "x > 0" |
|
866 |
and y1: "y > 1" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
867 |
shows "\<exists>k>0. (1/y)^k < x" |
52891 | 868 |
proof - |
54681 | 869 |
have yp: "y > 0" |
870 |
using y1 by simp |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
871 |
from reals_Archimedean2[of "max 0 (- log y x) + 1"] |
54681 | 872 |
obtain k :: nat where k: "real k > max 0 (- log y x) + 1" |
873 |
by blast |
|
874 |
from k have kp: "k > 0" |
|
875 |
by simp |
|
876 |
from k have "real k > - log y x" |
|
877 |
by simp |
|
878 |
then have "ln y * real k > - ln x" |
|
879 |
unfolding log_def |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
880 |
using ln_gt_zero_iff[OF yp] y1 |
54681 | 881 |
by (simp add: minus_divide_left field_simps del: minus_divide_left[symmetric]) |
882 |
then have "ln y * real k + ln x > 0" |
|
883 |
by simp |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
884 |
then have "exp (real k * ln y + ln x) > exp 0" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
885 |
by (simp add: ac_simps) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
886 |
then have "y ^ k * x > 1" |
52891 | 887 |
unfolding exp_zero exp_add exp_real_of_nat_mult exp_ln [OF xp] exp_ln [OF yp] |
888 |
by simp |
|
889 |
then have "x > (1 / y)^k" using yp |
|
60867 | 890 |
by (simp add: field_simps) |
54681 | 891 |
then show ?thesis |
892 |
using kp by blast |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
893 |
qed |
52891 | 894 |
|
54452 | 895 |
lemma fps_sum_rep_nth: "(setsum (\<lambda>i. fps_const(a$i)*X^i) {0..m})$n = |
54681 | 896 |
(if n \<le> m then a$n else 0::'a::comm_ring_1)" |
52891 | 897 |
apply (auto simp add: fps_setsum_nth cond_value_iff cong del: if_weak_cong) |
57418 | 898 |
apply (simp add: setsum.delta') |
48757 | 899 |
done |
52891 | 900 |
|
54452 | 901 |
lemma fps_notation: "(\<lambda>n. setsum (\<lambda>i. fps_const(a$i) * X^i) {0..n}) ----> a" |
52902 | 902 |
(is "?s ----> a") |
52891 | 903 |
proof - |
60558 | 904 |
have "\<exists>n0. \<forall>n \<ge> n0. dist (?s n) a < r" if "r > 0" for r |
905 |
proof - |
|
60501 | 906 |
obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0" |
907 |
using reals_power_lt_ex[OF \<open>r > 0\<close>, of 2] by auto |
|
60558 | 908 |
show ?thesis |
60501 | 909 |
proof - |
60558 | 910 |
have "dist (?s n) a < r" if nn0: "n \<ge> n0" for n |
911 |
proof - |
|
912 |
from that have thnn0: "(1/2)^n \<le> (1/2 :: real)^n0" |
|
60501 | 913 |
by (simp add: divide_simps) |
60558 | 914 |
show ?thesis |
60501 | 915 |
proof (cases "?s n = a") |
916 |
case True |
|
917 |
then show ?thesis |
|
918 |
unfolding dist_eq_0_iff[of "?s n" a, symmetric] |
|
919 |
using \<open>r > 0\<close> by (simp del: dist_eq_0_iff) |
|
920 |
next |
|
921 |
case False |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
922 |
from False have dth: "dist (?s n) a = (1/2)^subdegree (?s n - a)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
923 |
by (simp add: dist_fps_def field_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
924 |
from False have kn: "subdegree (?s n - a) > n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
925 |
by (intro subdegree_greaterI) (simp_all add: fps_sum_rep_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
926 |
then have "dist (?s n) a < (1/2)^n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
927 |
by (simp add: field_simps dist_fps_def) |
60501 | 928 |
also have "\<dots> \<le> (1/2)^n0" |
929 |
using nn0 by (simp add: divide_simps) |
|
930 |
also have "\<dots> < r" |
|
931 |
using n0 by simp |
|
932 |
finally show ?thesis . |
|
933 |
qed |
|
60558 | 934 |
qed |
60501 | 935 |
then show ?thesis by blast |
936 |
qed |
|
60558 | 937 |
qed |
54681 | 938 |
then show ?thesis |
60017
b785d6d06430
Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
paulson <lp15@cam.ac.uk>
parents:
59867
diff
changeset
|
939 |
unfolding lim_sequentially by blast |
52891 | 940 |
qed |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
941 |
|
54681 | 942 |
|
60501 | 943 |
subsection \<open>Inverses of formal power series\<close> |
29687 | 944 |
|
57418 | 945 |
declare setsum.cong[fundef_cong] |
29687 | 946 |
|
60558 | 947 |
instantiation fps :: ("{comm_monoid_add,inverse,times,uminus}") inverse |
29687 | 948 |
begin |
949 |
||
52891 | 950 |
fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a" |
951 |
where |
|
29687 | 952 |
"natfun_inverse f 0 = inverse (f$0)" |
30488 | 953 |
| "natfun_inverse f n = - inverse (f$0) * setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}" |
29687 | 954 |
|
60501 | 955 |
definition fps_inverse_def: "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))" |
956 |
||
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
957 |
definition fps_divide_def: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
958 |
"f div g = (if g = 0 then 0 else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
959 |
let n = subdegree g; h = fps_shift n g |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
960 |
in fps_shift n (f * inverse h))" |
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
961 |
|
29687 | 962 |
instance .. |
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
963 |
|
29687 | 964 |
end |
965 |
||
52891 | 966 |
lemma fps_inverse_zero [simp]: |
54681 | 967 |
"inverse (0 :: 'a::{comm_monoid_add,inverse,times,uminus} fps) = 0" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
968 |
by (simp add: fps_ext fps_inverse_def) |
29687 | 969 |
|
52891 | 970 |
lemma fps_inverse_one [simp]: "inverse (1 :: 'a::{division_ring,zero_neq_one} fps) = 1" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
971 |
apply (auto simp add: expand_fps_eq fps_inverse_def) |
52891 | 972 |
apply (case_tac n) |
973 |
apply auto |
|
974 |
done |
|
975 |
||
976 |
lemma inverse_mult_eq_1 [intro]: |
|
977 |
assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
29687 | 978 |
shows "inverse f * f = 1" |
52891 | 979 |
proof - |
54681 | 980 |
have c: "inverse f * f = f * inverse f" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
981 |
by (simp add: mult.commute) |
30488 | 982 |
from f0 have ifn: "\<And>n. inverse f $ n = natfun_inverse f n" |
29687 | 983 |
by (simp add: fps_inverse_def) |
984 |
from f0 have th0: "(inverse f * f) $ 0 = 1" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
985 |
by (simp add: fps_mult_nth fps_inverse_def) |
60501 | 986 |
have "(inverse f * f)$n = 0" if np: "n > 0" for n |
987 |
proof - |
|
54681 | 988 |
from np have eq: "{0..n} = {0} \<union> {1 .. n}" |
989 |
by auto |
|
990 |
have d: "{0} \<inter> {1 .. n} = {}" |
|
991 |
by auto |
|
52891 | 992 |
from f0 np have th0: "- (inverse f $ n) = |
29687 | 993 |
(setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}) / (f$0)" |
52891 | 994 |
by (cases n) (simp_all add: divide_inverse fps_inverse_def) |
29687 | 995 |
from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]] |
52891 | 996 |
have th1: "setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n} = - (f$0) * (inverse f)$n" |
36350 | 997 |
by (simp add: field_simps) |
30488 | 998 |
have "(f * inverse f) $ n = (\<Sum>i = 0..n. f $i * natfun_inverse f (n - i))" |
29687 | 999 |
unfolding fps_mult_nth ifn .. |
52891 | 1000 |
also have "\<dots> = f$0 * natfun_inverse f n + (\<Sum>i = 1..n. f$i * natfun_inverse f (n-i))" |
46757 | 1001 |
by (simp add: eq) |
54681 | 1002 |
also have "\<dots> = 0" |
1003 |
unfolding th1 ifn by simp |
|
60501 | 1004 |
finally show ?thesis unfolding c . |
1005 |
qed |
|
54681 | 1006 |
with th0 show ?thesis |
1007 |
by (simp add: fps_eq_iff) |
|
29687 | 1008 |
qed |
1009 |
||
60501 | 1010 |
lemma fps_inverse_0_iff[simp]: "(inverse f) $ 0 = (0::'a::division_ring) \<longleftrightarrow> f $ 0 = 0" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1011 |
by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero) |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1012 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1013 |
lemma fps_inverse_nth_0 [simp]: "inverse f $ 0 = inverse (f $ 0 :: 'a :: division_ring)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1014 |
by (simp add: fps_inverse_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1015 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1016 |
lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::division_ring) fps) \<longleftrightarrow> f $ 0 = 0" |
60501 | 1017 |
proof |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1018 |
assume A: "inverse f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1019 |
have "0 = inverse f $ 0" by (subst A) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1020 |
thus "f $ 0 = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1021 |
qed (simp add: fps_inverse_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1022 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1023 |
lemma fps_inverse_idempotent[intro, simp]: |
48757 | 1024 |
assumes f0: "f$0 \<noteq> (0::'a::field)" |
29687 | 1025 |
shows "inverse (inverse f) = f" |
52891 | 1026 |
proof - |
29687 | 1027 |
from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp |
30488 | 1028 |
from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0] |
52891 | 1029 |
have "inverse f * f = inverse f * inverse (inverse f)" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
1030 |
by (simp add: ac_simps) |
54681 | 1031 |
then show ?thesis |
1032 |
using f0 unfolding mult_cancel_left by simp |
|
29687 | 1033 |
qed |
1034 |
||
48757 | 1035 |
lemma fps_inverse_unique: |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1036 |
assumes fg: "(f :: 'a :: field fps) * g = 1" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1037 |
shows "inverse f = g" |
52891 | 1038 |
proof - |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1039 |
have f0: "f $ 0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1040 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1041 |
assume "f $ 0 = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1042 |
hence "0 = (f * g) $ 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1043 |
also from fg have "(f * g) $ 0 = 1" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1044 |
finally show False by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1045 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1046 |
from inverse_mult_eq_1[OF this] fg |
54681 | 1047 |
have th0: "inverse f * f = g * f" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
1048 |
by (simp add: ac_simps) |
54681 | 1049 |
then show ?thesis |
1050 |
using f0 |
|
1051 |
unfolding mult_cancel_right |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1052 |
by (auto simp add: expand_fps_eq) |
29687 | 1053 |
qed |
1054 |
||
60162 | 1055 |
lemma setsum_zero_lemma: |
1056 |
fixes n::nat |
|
1057 |
assumes "0 < n" |
|
1058 |
shows "(\<Sum>i = 0..n. if n = i then 1 else if n - i = 1 then - 1 else 0) = (0::'a::field)" |
|
54681 | 1059 |
proof - |
60162 | 1060 |
let ?f = "\<lambda>i. if n = i then 1 else if n - i = 1 then - 1 else 0" |
1061 |
let ?g = "\<lambda>i. if i = n then 1 else if i = n - 1 then - 1 else 0" |
|
29687 | 1062 |
let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0" |
30488 | 1063 |
have th1: "setsum ?f {0..n} = setsum ?g {0..n}" |
57418 | 1064 |
by (rule setsum.cong) auto |
30488 | 1065 |
have th2: "setsum ?g {0..n - 1} = setsum ?h {0..n - 1}" |
57418 | 1066 |
apply (rule setsum.cong) |
60162 | 1067 |
using assms |
54681 | 1068 |
apply auto |
1069 |
done |
|
1070 |
have eq: "{0 .. n} = {0.. n - 1} \<union> {n}" |
|
1071 |
by auto |
|
60162 | 1072 |
from assms have d: "{0.. n - 1} \<inter> {n} = {}" |
54681 | 1073 |
by auto |
1074 |
have f: "finite {0.. n - 1}" "finite {n}" |
|
1075 |
by auto |
|
60162 | 1076 |
show ?thesis |
30488 | 1077 |
unfolding th1 |
57418 | 1078 |
apply (simp add: setsum.union_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def) |
29687 | 1079 |
unfolding th2 |
57418 | 1080 |
apply (simp add: setsum.delta) |
52891 | 1081 |
done |
29687 | 1082 |
qed |
1083 |
||
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1084 |
lemma fps_inverse_mult: "inverse (f * g :: 'a::field fps) = inverse f * inverse g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1085 |
proof (cases "f$0 = 0 \<or> g$0 = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1086 |
assume "\<not>(f$0 = 0 \<or> g$0 = 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1087 |
hence [simp]: "f$0 \<noteq> 0" "g$0 \<noteq> 0" by simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1088 |
show ?thesis |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1089 |
proof (rule fps_inverse_unique) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1090 |
have "f * g * (inverse f * inverse g) = (inverse f * f) * (inverse g * g)" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1091 |
also have "... = 1" by (subst (1 2) inverse_mult_eq_1) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1092 |
finally show "f * g * (inverse f * inverse g) = 1" . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1093 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1094 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1095 |
assume A: "f$0 = 0 \<or> g$0 = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1096 |
hence "inverse (f * g) = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1097 |
also from A have "... = inverse f * inverse g" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1098 |
finally show "inverse (f * g) = inverse f * inverse g" . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1099 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1100 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1101 |
|
60501 | 1102 |
lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) = |
1103 |
Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)" |
|
60162 | 1104 |
apply (rule fps_inverse_unique) |
1105 |
apply (simp_all add: fps_eq_iff fps_mult_nth setsum_zero_lemma) |
|
1106 |
done |
|
1107 |
||
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1108 |
lemma subdegree_inverse [simp]: "subdegree (inverse (f::'a::field fps)) = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1109 |
proof (cases "f$0 = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1110 |
assume nz: "f$0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1111 |
hence "subdegree (inverse f) + subdegree f = subdegree (inverse f * f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1112 |
by (subst subdegree_mult) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1113 |
also from nz have "subdegree f = 0" by (simp add: subdegree_eq_0_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1114 |
also from nz have "inverse f * f = 1" by (rule inverse_mult_eq_1) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1115 |
finally show "subdegree (inverse f) = 0" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1116 |
qed (simp_all add: fps_inverse_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1117 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1118 |
lemma fps_is_unit_iff [simp]: "(f :: 'a :: field fps) dvd 1 \<longleftrightarrow> f $ 0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1119 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1120 |
assume "f dvd 1" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1121 |
then obtain g where "1 = f * g" by (elim dvdE) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1122 |
from this[symmetric] have "(f*g) $ 0 = 1" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1123 |
thus "f $ 0 \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1124 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1125 |
assume A: "f $ 0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1126 |
thus "f dvd 1" by (simp add: inverse_mult_eq_1[OF A, symmetric]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1127 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1128 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1129 |
lemma subdegree_eq_0' [simp]: "(f :: 'a :: field fps) dvd 1 \<Longrightarrow> subdegree f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1130 |
by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1131 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1132 |
lemma fps_unit_dvd [simp]: "(f $ 0 :: 'a :: field) \<noteq> 0 \<Longrightarrow> f dvd g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1133 |
by (rule dvd_trans, subst fps_is_unit_iff) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1134 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1135 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1136 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1137 |
instantiation fps :: (field) ring_div |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1138 |
begin |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1139 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1140 |
definition fps_mod_def: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1141 |
"f mod g = (if g = 0 then f else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1142 |
let n = subdegree g; h = fps_shift n g |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1143 |
in fps_cutoff n (f * inverse h) * h)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1144 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1145 |
lemma fps_mod_eq_zero: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1146 |
assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1147 |
shows "f mod g = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1148 |
using assms by (cases "f = 0") (auto simp: fps_cutoff_zero_iff fps_mod_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1149 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1150 |
lemma fps_times_divide_eq: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1151 |
assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree (g :: 'a fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1152 |
shows "f div g * g = f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1153 |
proof (cases "f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1154 |
assume nz: "f \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1155 |
def n \<equiv> "subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1156 |
def h \<equiv> "fps_shift n g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1157 |
from assms have [simp]: "h $ 0 \<noteq> 0" unfolding h_def by (simp add: n_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1158 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1159 |
from assms nz have "f div g * g = fps_shift n (f * inverse h) * g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1160 |
by (simp add: fps_divide_def Let_def h_def n_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1161 |
also have "... = fps_shift n (f * inverse h) * X^n * h" unfolding h_def n_def |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1162 |
by (subst subdegree_decompose[of g]) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1163 |
also have "fps_shift n (f * inverse h) * X^n = f * inverse h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1164 |
by (rule fps_shift_times_X_power) (simp_all add: nz assms n_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1165 |
also have "... * h = f * (inverse h * h)" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1166 |
also have "inverse h * h = 1" by (rule inverse_mult_eq_1) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1167 |
finally show ?thesis by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1168 |
qed (simp_all add: fps_divide_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1169 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1170 |
lemma |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1171 |
assumes "g$0 \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1172 |
shows fps_divide_unit: "f div g = f * inverse g" and fps_mod_unit [simp]: "f mod g = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1173 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1174 |
from assms have [simp]: "subdegree g = 0" by (simp add: subdegree_eq_0_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1175 |
from assms show "f div g = f * inverse g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1176 |
by (auto simp: fps_divide_def Let_def subdegree_eq_0_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1177 |
from assms show "f mod g = 0" by (intro fps_mod_eq_zero) auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1178 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1179 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1180 |
context |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1181 |
begin |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1182 |
private lemma fps_divide_cancel_aux1: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1183 |
assumes "h$0 \<noteq> (0 :: 'a :: field)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1184 |
shows "(h * f) div (h * g) = f div g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1185 |
proof (cases "g = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1186 |
assume "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1187 |
from assms have "h \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1188 |
note nz [simp] = \<open>g \<noteq> 0\<close> \<open>h \<noteq> 0\<close> |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1189 |
from assms have [simp]: "subdegree h = 0" by (simp add: subdegree_eq_0_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1190 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1191 |
have "(h * f) div (h * g) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1192 |
fps_shift (subdegree g) (h * f * inverse (fps_shift (subdegree g) (h*g)))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1193 |
by (simp add: fps_divide_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1194 |
also have "h * f * inverse (fps_shift (subdegree g) (h*g)) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1195 |
(inverse h * h) * f * inverse (fps_shift (subdegree g) g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1196 |
by (subst fps_shift_mult) (simp_all add: algebra_simps fps_inverse_mult) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1197 |
also from assms have "inverse h * h = 1" by (rule inverse_mult_eq_1) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1198 |
finally show "(h * f) div (h * g) = f div g" by (simp_all add: fps_divide_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1199 |
qed (simp_all add: fps_divide_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1200 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1201 |
private lemma fps_divide_cancel_aux2: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1202 |
"(f * X^m) div (g * X^m) = f div (g :: 'a :: field fps)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1203 |
proof (cases "g = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1204 |
assume [simp]: "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1205 |
have "(f * X^m) div (g * X^m) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1206 |
fps_shift (subdegree g + m) (f*inverse (fps_shift (subdegree g + m) (g*X^m))*X^m)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1207 |
by (simp add: fps_divide_def Let_def algebra_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1208 |
also have "... = f div g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1209 |
by (simp add: fps_shift_times_X_power'' fps_divide_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1210 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1211 |
qed (simp_all add: fps_divide_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1212 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1213 |
instance proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1214 |
fix f g :: "'a fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1215 |
def n \<equiv> "subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1216 |
def h \<equiv> "fps_shift n g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1217 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1218 |
show "f div g * g + f mod g = f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1219 |
proof (cases "g = 0 \<or> f = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1220 |
assume "\<not>(g = 0 \<or> f = 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1221 |
hence nz [simp]: "f \<noteq> 0" "g \<noteq> 0" by simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1222 |
show ?thesis |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1223 |
proof (rule disjE[OF le_less_linear]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1224 |
assume "subdegree f \<ge> subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1225 |
with nz show ?thesis by (simp add: fps_mod_eq_zero fps_times_divide_eq) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1226 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1227 |
assume "subdegree f < subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1228 |
have g_decomp: "g = h * X^n" unfolding h_def n_def by (rule subdegree_decompose) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1229 |
have "f div g * g + f mod g = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1230 |
fps_shift n (f * inverse h) * g + fps_cutoff n (f * inverse h) * h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1231 |
by (simp add: fps_mod_def fps_divide_def Let_def n_def h_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1232 |
also have "... = h * (fps_shift n (f * inverse h) * X^n + fps_cutoff n (f * inverse h))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1233 |
by (subst g_decomp) (simp add: algebra_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1234 |
also have "... = f * (inverse h * h)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1235 |
by (subst fps_shift_cutoff) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1236 |
also have "inverse h * h = 1" by (rule inverse_mult_eq_1) (simp add: h_def n_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1237 |
finally show ?thesis by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1238 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1239 |
qed (auto simp: fps_mod_def fps_divide_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1240 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1241 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1242 |
fix f g h :: "'a fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1243 |
assume "h \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1244 |
show "(h * f) div (h * g) = f div g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1245 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1246 |
def m \<equiv> "subdegree h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1247 |
def h' \<equiv> "fps_shift m h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1248 |
have h_decomp: "h = h' * X ^ m" unfolding h'_def m_def by (rule subdegree_decompose) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1249 |
from \<open>h \<noteq> 0\<close> have [simp]: "h'$0 \<noteq> 0" by (simp add: h'_def m_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1250 |
have "(h * f) div (h * g) = (h' * f * X^m) div (h' * g * X^m)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1251 |
by (simp add: h_decomp algebra_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1252 |
also have "... = f div g" by (simp add: fps_divide_cancel_aux1 fps_divide_cancel_aux2) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1253 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1254 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1255 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1256 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1257 |
fix f g h :: "'a fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1258 |
assume [simp]: "h \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1259 |
def n \<equiv> "subdegree h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1260 |
def h' \<equiv> "fps_shift n h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1261 |
note dfs = n_def h'_def |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1262 |
have "(f + g * h) div h = fps_shift n (f * inverse h') + fps_shift n (g * (h * inverse h'))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1263 |
by (simp add: fps_divide_def Let_def dfs[symmetric] algebra_simps fps_shift_add) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1264 |
also have "h * inverse h' = (inverse h' * h') * X^n" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1265 |
by (subst subdegree_decompose) (simp_all add: dfs) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1266 |
also have "... = X^n" by (subst inverse_mult_eq_1) (simp_all add: dfs) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1267 |
also have "fps_shift n (g * X^n) = g" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1268 |
also have "fps_shift n (f * inverse h') = f div h" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1269 |
by (simp add: fps_divide_def Let_def dfs) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1270 |
finally show "(f + g * h) div h = g + f div h" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1271 |
qed (auto simp: fps_divide_def fps_mod_def Let_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1272 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1273 |
end |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1274 |
end |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1275 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1276 |
lemma subdegree_mod: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1277 |
assumes "f \<noteq> 0" "subdegree f < subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1278 |
shows "subdegree (f mod g) = subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1279 |
proof (cases "f div g * g = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1280 |
assume "f div g * g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1281 |
hence [simp]: "f div g \<noteq> 0" "g \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1282 |
from mod_div_equality[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1283 |
also from assms have "subdegree ... = subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1284 |
by (intro subdegree_diff_eq1) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1285 |
finally show ?thesis . |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1286 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1287 |
assume zero: "f div g * g = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1288 |
from mod_div_equality[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1289 |
also note zero |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1290 |
finally show ?thesis by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1291 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1292 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1293 |
lemma fps_divide_nth_0 [simp]: "g $ 0 \<noteq> 0 \<Longrightarrow> (f div g) $ 0 = f $ 0 / (g $ 0 :: _ :: field)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1294 |
by (simp add: fps_divide_unit divide_inverse) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1295 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1296 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1297 |
lemma dvd_imp_subdegree_le: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1298 |
"(f :: 'a :: idom fps) dvd g \<Longrightarrow> g \<noteq> 0 \<Longrightarrow> subdegree f \<le> subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1299 |
by (auto elim: dvdE) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1300 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1301 |
lemma fps_dvd_iff: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1302 |
assumes "(f :: 'a :: field fps) \<noteq> 0" "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1303 |
shows "f dvd g \<longleftrightarrow> subdegree f \<le> subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1304 |
proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1305 |
assume "subdegree f \<le> subdegree g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1306 |
with assms have "g mod f = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1307 |
by (simp add: fps_mod_def Let_def fps_cutoff_zero_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1308 |
thus "f dvd g" by (simp add: dvd_eq_mod_eq_0) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1309 |
qed (simp add: assms dvd_imp_subdegree_le) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1310 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1311 |
lemma fps_const_inverse: "inverse (fps_const (a::'a::field)) = fps_const (inverse a)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1312 |
by (cases "a \<noteq> 0", rule fps_inverse_unique) (auto simp: fps_eq_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1313 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1314 |
lemma fps_const_divide: "fps_const (x :: _ :: field) / fps_const y = fps_const (x / y)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1315 |
by (cases "y = 0") (simp_all add: fps_divide_unit fps_const_inverse divide_inverse) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1316 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1317 |
lemma inverse_fps_numeral: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1318 |
"inverse (numeral n :: ('a :: field_char_0) fps) = fps_const (inverse (numeral n))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1319 |
by (intro fps_inverse_unique fps_ext) (simp_all add: fps_numeral_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1320 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1321 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1322 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1323 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1324 |
instantiation fps :: (field) normalization_semidom |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1325 |
begin |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1326 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1327 |
definition fps_unit_factor_def [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1328 |
"unit_factor f = fps_shift (subdegree f) f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1329 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1330 |
definition fps_normalize_def [simp]: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1331 |
"normalize f = (if f = 0 then 0 else X ^ subdegree f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1332 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1333 |
instance proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1334 |
fix f :: "'a fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1335 |
show "unit_factor f * normalize f = f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1336 |
by (simp add: fps_shift_times_X_power) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1337 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1338 |
fix f g :: "'a fps" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1339 |
show "unit_factor (f * g) = unit_factor f * unit_factor g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1340 |
proof (cases "f = 0 \<or> g = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1341 |
assume "\<not>(f = 0 \<or> g = 0)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1342 |
thus "unit_factor (f * g) = unit_factor f * unit_factor g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1343 |
unfolding fps_unit_factor_def |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1344 |
by (auto simp: fps_shift_fps_shift fps_shift_mult fps_shift_mult_right) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1345 |
qed auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1346 |
qed auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1347 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1348 |
end |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1349 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1350 |
instance fps :: (field) algebraic_semidom .. |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1351 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1352 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1353 |
subsection \<open>Formal power series form a Euclidean ring\<close> |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1354 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1355 |
instantiation fps :: (field) euclidean_ring |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1356 |
begin |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1357 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1358 |
definition fps_euclidean_size_def: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1359 |
"euclidean_size f = (if f = 0 then 0 else Suc (subdegree f))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1360 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1361 |
instance proof |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1362 |
fix f g :: "'a fps" assume [simp]: "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1363 |
show "euclidean_size f \<le> euclidean_size (f * g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1364 |
by (cases "f = 0") (auto simp: fps_euclidean_size_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1365 |
show "euclidean_size (f mod g) < euclidean_size g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1366 |
apply (cases "f = 0", simp add: fps_euclidean_size_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1367 |
apply (rule disjE[OF le_less_linear[of "subdegree g" "subdegree f"]]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1368 |
apply (simp_all add: fps_mod_eq_zero fps_euclidean_size_def subdegree_mod) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1369 |
done |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1370 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1371 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1372 |
end |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1373 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1374 |
instantiation fps :: (field) euclidean_ring_gcd |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1375 |
begin |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1376 |
definition fps_gcd_def: "(gcd :: 'a fps \<Rightarrow> _) = gcd_eucl" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1377 |
definition fps_lcm_def: "(lcm :: 'a fps \<Rightarrow> _) = lcm_eucl" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1378 |
definition fps_Gcd_def: "(Gcd :: 'a fps set \<Rightarrow> _) = Gcd_eucl" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1379 |
definition fps_Lcm_def: "(Lcm :: 'a fps set \<Rightarrow> _) = Lcm_eucl" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1380 |
instance by intro_classes (simp_all add: fps_gcd_def fps_lcm_def fps_Gcd_def fps_Lcm_def) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1381 |
end |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1382 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1383 |
lemma fps_gcd: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1384 |
assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1385 |
shows "gcd f g = X ^ min (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1386 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1387 |
let ?m = "min (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1388 |
show "gcd f g = X ^ ?m" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1389 |
proof (rule sym, rule gcdI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1390 |
fix d assume "d dvd f" "d dvd g" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1391 |
thus "d dvd X ^ ?m" by (cases "d = 0") (auto simp: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1392 |
qed (simp_all add: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1393 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1394 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1395 |
lemma fps_gcd_altdef: "gcd (f :: 'a :: field fps) g = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1396 |
(if f = 0 \<and> g = 0 then 0 else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1397 |
if f = 0 then X ^ subdegree g else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1398 |
if g = 0 then X ^ subdegree f else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1399 |
X ^ min (subdegree f) (subdegree g))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1400 |
by (simp add: fps_gcd) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1401 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1402 |
lemma fps_lcm: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1403 |
assumes [simp]: "f \<noteq> 0" "g \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1404 |
shows "lcm f g = X ^ max (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1405 |
proof - |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1406 |
let ?m = "max (subdegree f) (subdegree g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1407 |
show "lcm f g = X ^ ?m" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1408 |
proof (rule sym, rule lcmI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1409 |
fix d assume "f dvd d" "g dvd d" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1410 |
thus "X ^ ?m dvd d" by (cases "d = 0") (auto simp: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1411 |
qed (simp_all add: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1412 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1413 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1414 |
lemma fps_lcm_altdef: "lcm (f :: 'a :: field fps) g = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1415 |
(if f = 0 \<or> g = 0 then 0 else X ^ max (subdegree f) (subdegree g))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1416 |
by (simp add: fps_lcm) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1417 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1418 |
lemma fps_Gcd: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1419 |
assumes "A - {0} \<noteq> {}" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1420 |
shows "Gcd A = X ^ (INF f:A-{0}. subdegree f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1421 |
proof (rule sym, rule GcdI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1422 |
fix f assume "f \<in> A" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1423 |
thus "X ^ (INF f:A - {0}. subdegree f) dvd f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1424 |
by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cINF_lower) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1425 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1426 |
fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> d dvd f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1427 |
from assms obtain f where "f \<in> A - {0}" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1428 |
with d[of f] have [simp]: "d \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1429 |
from d assms have "subdegree d \<le> (INF f:A-{0}. subdegree f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1430 |
by (intro cINF_greatest) (auto simp: fps_dvd_iff[symmetric]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1431 |
with d assms show "d dvd X ^ (INF f:A-{0}. subdegree f)" by (simp add: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1432 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1433 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1434 |
lemma fps_Gcd_altdef: "Gcd (A :: 'a :: field fps set) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1435 |
(if A \<subseteq> {0} then 0 else X ^ (INF f:A-{0}. subdegree f))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1436 |
using fps_Gcd by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1437 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1438 |
lemma fps_Lcm: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1439 |
assumes "A \<noteq> {}" "0 \<notin> A" "bdd_above (subdegree`A)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1440 |
shows "Lcm A = X ^ (SUP f:A. subdegree f)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1441 |
proof (rule sym, rule LcmI) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1442 |
fix f assume "f \<in> A" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1443 |
moreover from assms(3) have "bdd_above (subdegree ` A)" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1444 |
ultimately show "f dvd X ^ (SUP f:A. subdegree f)" using assms(2) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1445 |
by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cSUP_upper) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1446 |
next |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1447 |
fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> f dvd d" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1448 |
from assms obtain f where f: "f \<in> A" "f \<noteq> 0" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1449 |
show "X ^ (SUP f:A. subdegree f) dvd d" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1450 |
proof (cases "d = 0") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1451 |
assume "d \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1452 |
moreover from d have "\<And>f. f \<in> A \<Longrightarrow> f \<noteq> 0 \<Longrightarrow> f dvd d" by blast |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1453 |
ultimately have "subdegree d \<ge> (SUP f:A. subdegree f)" using assms |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1454 |
by (intro cSUP_least) (auto simp: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1455 |
with \<open>d \<noteq> 0\<close> show ?thesis by (simp add: fps_dvd_iff) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1456 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1457 |
qed simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1458 |
|
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1459 |
lemma fps_Lcm_altdef: |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1460 |
"Lcm (A :: 'a :: field fps set) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1461 |
(if 0 \<in> A \<or> \<not>bdd_above (subdegree`A) then 0 else |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1462 |
if A = {} then 1 else X ^ (SUP f:A. subdegree f))" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1463 |
proof (cases "bdd_above (subdegree`A)") |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1464 |
assume unbounded: "\<not>bdd_above (subdegree`A)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1465 |
have "Lcm A = 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1466 |
proof (rule ccontr) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1467 |
assume "Lcm A \<noteq> 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1468 |
from unbounded obtain f where f: "f \<in> A" "subdegree (Lcm A) < subdegree f" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1469 |
unfolding bdd_above_def by (auto simp: not_le) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1470 |
moreover from this and `Lcm A \<noteq> 0` have "subdegree f \<le> subdegree (Lcm A)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1471 |
by (intro dvd_imp_subdegree_le) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1472 |
ultimately show False by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1473 |
qed |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1474 |
with unbounded show ?thesis by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1475 |
qed (simp_all add: fps_Lcm) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1476 |
|
54681 | 1477 |
|
60500 | 1478 |
subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close> |
29687 | 1479 |
|
1480 |
definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" |
|
1481 |
||
54681 | 1482 |
lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n + 1)" |
48757 | 1483 |
by (simp add: fps_deriv_def) |
1484 |
||
1485 |
lemma fps_deriv_linear[simp]: |
|
1486 |
"fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = |
|
1487 |
fps_const a * fps_deriv f + fps_const b * fps_deriv g" |
|
36350 | 1488 |
unfolding fps_eq_iff fps_add_nth fps_const_mult_left fps_deriv_nth by (simp add: field_simps) |
29687 | 1489 |
|
30488 | 1490 |
lemma fps_deriv_mult[simp]: |
54681 | 1491 |
fixes f :: "'a::comm_ring_1 fps" |
29687 | 1492 |
shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g" |
52891 | 1493 |
proof - |
29687 | 1494 |
let ?D = "fps_deriv" |
60558 | 1495 |
have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" for n |
1496 |
proof - |
|
29687 | 1497 |
let ?Zn = "{0 ..n}" |
1498 |
let ?Zn1 = "{0 .. n + 1}" |
|
1499 |
let ?g = "\<lambda>i. of_nat (i+1) * g $ (i+1) * f $ (n - i) + |
|
1500 |
of_nat (i+1)* f $ (i+1) * g $ (n - i)" |
|
1501 |
let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) + |
|
1502 |
of_nat i* f $ i * g $ ((n + 1) - i)" |
|
52891 | 1503 |
have s0: "setsum (\<lambda>i. of_nat i * f $ i * g $ (n + 1 - i)) ?Zn1 = |
1504 |
setsum (\<lambda>i. of_nat (n + 1 - i) * f $ (n + 1 - i) * g $ i) ?Zn1" |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
1505 |
by (rule setsum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto |
52891 | 1506 |
have s1: "setsum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 = |
1507 |
setsum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1" |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
1508 |
by (rule setsum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto |
52891 | 1509 |
have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
1510 |
by (simp only: mult.commute) |
29687 | 1511 |
also have "\<dots> = (\<Sum>i = 0..n. ?g i)" |
57418 | 1512 |
by (simp add: fps_mult_nth setsum.distrib[symmetric]) |
29687 | 1513 |
also have "\<dots> = setsum ?h {0..n+1}" |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
1514 |
by (rule setsum.reindex_bij_witness_not_neutral |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
1515 |
[where S'="{}" and T'="{0}" and j="Suc" and i="\<lambda>i. i - 1"]) auto |
29687 | 1516 |
also have "\<dots> = (fps_deriv (f * g)) $ n" |
57418 | 1517 |
apply (simp only: fps_deriv_nth fps_mult_nth setsum.distrib) |
29687 | 1518 |
unfolding s0 s1 |
57418 | 1519 |
unfolding setsum.distrib[symmetric] setsum_right_distrib |
1520 |
apply (rule setsum.cong) |
|
52891 | 1521 |
apply (auto simp add: of_nat_diff field_simps) |
1522 |
done |
|
60558 | 1523 |
finally show ?thesis . |
1524 |
qed |
|
1525 |
then show ?thesis |
|
1526 |
unfolding fps_eq_iff by auto |
|
29687 | 1527 |
qed |
1528 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
1529 |
lemma fps_deriv_X[simp]: "fps_deriv X = 1" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
1530 |
by (simp add: fps_deriv_def X_def fps_eq_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
1531 |
|
54681 | 1532 |
lemma fps_deriv_neg[simp]: |
1533 |
"fps_deriv (- (f:: 'a::comm_ring_1 fps)) = - (fps_deriv f)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1534 |
by (simp add: fps_eq_iff fps_deriv_def) |
52891 | 1535 |
|
54681 | 1536 |
lemma fps_deriv_add[simp]: |
1537 |
"fps_deriv ((f:: 'a::comm_ring_1 fps) + g) = fps_deriv f + fps_deriv g" |
|
29687 | 1538 |
using fps_deriv_linear[of 1 f 1 g] by simp |
1539 |
||
54681 | 1540 |
lemma fps_deriv_sub[simp]: |
1541 |
"fps_deriv ((f:: 'a::comm_ring_1 fps) - g) = fps_deriv f - fps_deriv g" |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
1542 |
using fps_deriv_add [of f "- g"] by simp |
29687 | 1543 |
|
1544 |
lemma fps_deriv_const[simp]: "fps_deriv (fps_const c) = 0" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1545 |
by (simp add: fps_ext fps_deriv_def fps_const_def) |
29687 | 1546 |
|
48757 | 1547 |
lemma fps_deriv_mult_const_left[simp]: |
54681 | 1548 |
"fps_deriv (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_deriv f" |
29687 | 1549 |
by simp |
1550 |
||
1551 |
lemma fps_deriv_0[simp]: "fps_deriv 0 = 0" |
|
1552 |
by (simp add: fps_deriv_def fps_eq_iff) |
|
1553 |
||
1554 |
lemma fps_deriv_1[simp]: "fps_deriv 1 = 0" |
|
1555 |
by (simp add: fps_deriv_def fps_eq_iff ) |
|
1556 |
||
48757 | 1557 |
lemma fps_deriv_mult_const_right[simp]: |
54681 | 1558 |
"fps_deriv (f * fps_const (c::'a::comm_ring_1)) = fps_deriv f * fps_const c" |
29687 | 1559 |
by simp |
1560 |
||
48757 | 1561 |
lemma fps_deriv_setsum: |
54681 | 1562 |
"fps_deriv (setsum f S) = setsum (\<lambda>i. fps_deriv (f i :: 'a::comm_ring_1 fps)) S" |
53195 | 1563 |
proof (cases "finite S") |
1564 |
case False |
|
1565 |
then show ?thesis by simp |
|
1566 |
next |
|
1567 |
case True |
|
1568 |
show ?thesis by (induct rule: finite_induct [OF True]) simp_all |
|
29687 | 1569 |
qed |
1570 |
||
52902 | 1571 |
lemma fps_deriv_eq_0_iff [simp]: |
54681 | 1572 |
"fps_deriv f = 0 \<longleftrightarrow> f = fps_const (f$0 :: 'a::{idom,semiring_char_0})" |
60501 | 1573 |
(is "?lhs \<longleftrightarrow> ?rhs") |
1574 |
proof |
|
1575 |
show ?lhs if ?rhs |
|
1576 |
proof - |
|
1577 |
from that have "fps_deriv f = fps_deriv (fps_const (f$0))" |
|
1578 |
by simp |
|
1579 |
then show ?thesis |
|
1580 |
by simp |
|
1581 |
qed |
|
1582 |
show ?rhs if ?lhs |
|
1583 |
proof - |
|
1584 |
from that have "\<forall>n. (fps_deriv f)$n = 0" |
|
1585 |
by simp |
|
1586 |
then have "\<forall>n. f$(n+1) = 0" |
|
1587 |
by (simp del: of_nat_Suc of_nat_add One_nat_def) |
|
1588 |
then show ?thesis |
|
29687 | 1589 |
apply (clarsimp simp add: fps_eq_iff fps_const_def) |
1590 |
apply (erule_tac x="n - 1" in allE) |
|
52891 | 1591 |
apply simp |
1592 |
done |
|
60501 | 1593 |
qed |
29687 | 1594 |
qed |
1595 |
||
30488 | 1596 |
lemma fps_deriv_eq_iff: |
54681 | 1597 |
fixes f :: "'a::{idom,semiring_char_0} fps" |
29687 | 1598 |
shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)" |
52891 | 1599 |
proof - |
52903 | 1600 |
have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0" |
1601 |
by simp |
|
54681 | 1602 |
also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f - g) $ 0)" |
52903 | 1603 |
unfolding fps_deriv_eq_0_iff .. |
60501 | 1604 |
finally show ?thesis |
1605 |
by (simp add: field_simps) |
|
29687 | 1606 |
qed |
1607 |
||
48757 | 1608 |
lemma fps_deriv_eq_iff_ex: |
54681 | 1609 |
"(fps_deriv f = fps_deriv g) \<longleftrightarrow> (\<exists>c::'a::{idom,semiring_char_0}. f = fps_const c + g)" |
53195 | 1610 |
by (auto simp: fps_deriv_eq_iff) |
48757 | 1611 |
|
1612 |
||
54681 | 1613 |
fun fps_nth_deriv :: "nat \<Rightarrow> 'a::semiring_1 fps \<Rightarrow> 'a fps" |
48757 | 1614 |
where |
29687 | 1615 |
"fps_nth_deriv 0 f = f" |
1616 |
| "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)" |
|
1617 |
||
1618 |
lemma fps_nth_deriv_commute: "fps_nth_deriv (Suc n) f = fps_deriv (fps_nth_deriv n f)" |
|
48757 | 1619 |
by (induct n arbitrary: f) auto |
1620 |
||
1621 |
lemma fps_nth_deriv_linear[simp]: |
|
1622 |
"fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = |
|
1623 |
fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g" |
|
1624 |
by (induct n arbitrary: f g) (auto simp add: fps_nth_deriv_commute) |
|
1625 |
||
1626 |
lemma fps_nth_deriv_neg[simp]: |
|
54681 | 1627 |
"fps_nth_deriv n (- (f :: 'a::comm_ring_1 fps)) = - (fps_nth_deriv n f)" |
48757 | 1628 |
by (induct n arbitrary: f) simp_all |
1629 |
||
1630 |
lemma fps_nth_deriv_add[simp]: |
|
54681 | 1631 |
"fps_nth_deriv n ((f :: 'a::comm_ring_1 fps) + g) = fps_nth_deriv n f + fps_nth_deriv n g" |
29687 | 1632 |
using fps_nth_deriv_linear[of n 1 f 1 g] by simp |
1633 |
||
48757 | 1634 |
lemma fps_nth_deriv_sub[simp]: |
54681 | 1635 |
"fps_nth_deriv n ((f :: 'a::comm_ring_1 fps) - g) = fps_nth_deriv n f - fps_nth_deriv n g" |
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
1636 |
using fps_nth_deriv_add [of n f "- g"] by simp |
29687 | 1637 |
|
1638 |
lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0" |
|
48757 | 1639 |
by (induct n) simp_all |
29687 | 1640 |
|
1641 |
lemma fps_nth_deriv_1[simp]: "fps_nth_deriv n 1 = (if n = 0 then 1 else 0)" |
|
48757 | 1642 |
by (induct n) simp_all |
1643 |
||
1644 |
lemma fps_nth_deriv_const[simp]: |
|
1645 |
"fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)" |
|
1646 |
by (cases n) simp_all |
|
1647 |
||
1648 |
lemma fps_nth_deriv_mult_const_left[simp]: |
|
1649 |
"fps_nth_deriv n (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_nth_deriv n f" |
|
29687 | 1650 |
using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp |
1651 |
||
48757 | 1652 |
lemma fps_nth_deriv_mult_const_right[simp]: |
1653 |
"fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
1654 |
using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult.commute) |
29687 | 1655 |
|
48757 | 1656 |
lemma fps_nth_deriv_setsum: |
54681 | 1657 |
"fps_nth_deriv n (setsum f S) = setsum (\<lambda>i. fps_nth_deriv n (f i :: 'a::comm_ring_1 fps)) S" |
52903 | 1658 |
proof (cases "finite S") |
1659 |
case True |
|
1660 |
show ?thesis by (induct rule: finite_induct [OF True]) simp_all |
|
1661 |
next |
|
1662 |
case False |
|
1663 |
then show ?thesis by simp |
|
29687 | 1664 |
qed |
1665 |
||
48757 | 1666 |
lemma fps_deriv_maclauren_0: |
54681 | 1667 |
"(fps_nth_deriv k (f :: 'a::comm_semiring_1 fps)) $ 0 = of_nat (fact k) * f $ k" |
36350 | 1668 |
by (induct k arbitrary: f) (auto simp add: field_simps of_nat_mult) |
29687 | 1669 |
|
54681 | 1670 |
|
60500 | 1671 |
subsection \<open>Powers\<close> |
29687 | 1672 |
|
1673 |
lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)" |
|
48757 | 1674 |
by (induct n) (auto simp add: expand_fps_eq fps_mult_nth) |
29687 | 1675 |
|
54681 | 1676 |
lemma fps_power_first_eq: "(a :: 'a::comm_ring_1 fps) $ 0 =1 \<Longrightarrow> a^n $ 1 = of_nat n * a$1" |
52891 | 1677 |
proof (induct n) |
1678 |
case 0 |
|
1679 |
then show ?case by simp |
|
29687 | 1680 |
next |
1681 |
case (Suc n) |
|
30488 | 1682 |
show ?case unfolding power_Suc fps_mult_nth |
60501 | 1683 |
using Suc.hyps[OF \<open>a$0 = 1\<close>] \<open>a$0 = 1\<close> fps_power_zeroth_eq_one[OF \<open>a$0=1\<close>] |
52891 | 1684 |
by (simp add: field_simps) |
29687 | 1685 |
qed |
1686 |
||
1687 |
lemma startsby_one_power:"a $ 0 = (1::'a::comm_ring_1) \<Longrightarrow> a^n $ 0 = 1" |
|
48757 | 1688 |
by (induct n) (auto simp add: fps_mult_nth) |
29687 | 1689 |
|
1690 |
lemma startsby_zero_power:"a $0 = (0::'a::comm_ring_1) \<Longrightarrow> n > 0 \<Longrightarrow> a^n $0 = 0" |
|
48757 | 1691 |
by (induct n) (auto simp add: fps_mult_nth) |
29687 | 1692 |
|
54681 | 1693 |
lemma startsby_power:"a $0 = (v::'a::comm_ring_1) \<Longrightarrow> a^n $0 = v^n" |
52891 | 1694 |
by (induct n) (auto simp add: fps_mult_nth) |
1695 |
||
54681 | 1696 |
lemma startsby_zero_power_iff[simp]: "a^n $0 = (0::'a::idom) \<longleftrightarrow> n \<noteq> 0 \<and> a$0 = 0" |
52891 | 1697 |
apply (rule iffI) |
1698 |
apply (induct n) |
|
1699 |
apply (auto simp add: fps_mult_nth) |
|
1700 |
apply (rule startsby_zero_power, simp_all) |
|
1701 |
done |
|
29687 | 1702 |
|
30488 | 1703 |
lemma startsby_zero_power_prefix: |
60501 | 1704 |
assumes a0: "a $ 0 = (0::'a::idom)" |
29687 | 1705 |
shows "\<forall>n < k. a ^ k $ n = 0" |
30488 | 1706 |
using a0 |
54681 | 1707 |
proof (induct k rule: nat_less_induct) |
52891 | 1708 |
fix k |
54681 | 1709 |
assume H: "\<forall>m<k. a $0 = 0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $ 0 = 0" |
60501 | 1710 |
show "\<forall>m<k. a ^ k $ m = 0" |
1711 |
proof (cases k) |
|
1712 |
case 0 |
|
1713 |
then show ?thesis by simp |
|
1714 |
next |
|
1715 |
case (Suc l) |
|
1716 |
have "a^k $ m = 0" if mk: "m < k" for m |
|
1717 |
proof (cases "m = 0") |
|
1718 |
case True |
|
1719 |
then show ?thesis |
|
1720 |
using startsby_zero_power[of a k] Suc a0 by simp |
|
1721 |
next |
|
1722 |
case False |
|
1723 |
have "a ^k $ m = (a^l * a) $m" |
|
1724 |
by (simp add: Suc mult.commute) |
|
1725 |
also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))" |
|
1726 |
by (simp add: fps_mult_nth) |
|
1727 |
also have "\<dots> = 0" |
|
1728 |
apply (rule setsum.neutral) |
|
1729 |
apply auto |
|
1730 |
apply (case_tac "x = m") |
|
1731 |
using a0 apply simp |
|
1732 |
apply (rule H[rule_format]) |
|
1733 |
using a0 Suc mk apply auto |
|
1734 |
done |
|
1735 |
finally show ?thesis . |
|
1736 |
qed |
|
1737 |
then show ?thesis by blast |
|
1738 |
qed |
|
29687 | 1739 |
qed |
1740 |
||
30488 | 1741 |
lemma startsby_zero_setsum_depends: |
54681 | 1742 |
assumes a0: "a $0 = (0::'a::idom)" |
1743 |
and kn: "n \<ge> k" |
|
29687 | 1744 |
shows "setsum (\<lambda>i. (a ^ i)$k) {0 .. n} = setsum (\<lambda>i. (a ^ i)$k) {0 .. k}" |
57418 | 1745 |
apply (rule setsum.mono_neutral_right) |
54681 | 1746 |
using kn |
1747 |
apply auto |
|
29687 | 1748 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
52891 | 1749 |
apply arith |
1750 |
done |
|
1751 |
||
1752 |
lemma startsby_zero_power_nth_same: |
|
54681 | 1753 |
assumes a0: "a$0 = (0::'a::idom)" |
29687 | 1754 |
shows "a^n $ n = (a$1) ^ n" |
52891 | 1755 |
proof (induct n) |
1756 |
case 0 |
|
52902 | 1757 |
then show ?case by simp |
29687 | 1758 |
next |
1759 |
case (Suc n) |
|
54681 | 1760 |
have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)" |
1761 |
by (simp add: field_simps) |
|
52891 | 1762 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}" |
1763 |
by (simp add: fps_mult_nth) |
|
29687 | 1764 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}" |
57418 | 1765 |
apply (rule setsum.mono_neutral_right) |
29687 | 1766 |
apply simp |
1767 |
apply clarsimp |
|
1768 |
apply clarsimp |
|
1769 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
|
1770 |
apply arith |
|
1771 |
done |
|
54681 | 1772 |
also have "\<dots> = a^n $ n * a$1" |
1773 |
using a0 by simp |
|
1774 |
finally show ?case |
|
1775 |
using Suc.hyps by simp |
|
29687 | 1776 |
qed |
1777 |
||
1778 |
lemma fps_inverse_power: |
|
54681 | 1779 |
fixes a :: "'a::field fps" |
29687 | 1780 |
shows "inverse (a^n) = inverse a ^ n" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1781 |
by (induction n) (simp_all add: fps_inverse_mult) |
29687 | 1782 |
|
48757 | 1783 |
lemma fps_deriv_power: |
54681 | 1784 |
"fps_deriv (a ^ n) = fps_const (of_nat n :: 'a::comm_ring_1) * fps_deriv a * a ^ (n - 1)" |
48757 | 1785 |
apply (induct n) |
52891 | 1786 |
apply (auto simp add: field_simps fps_const_add[symmetric] simp del: fps_const_add) |
48757 | 1787 |
apply (case_tac n) |
52891 | 1788 |
apply (auto simp add: field_simps) |
48757 | 1789 |
done |
29687 | 1790 |
|
30488 | 1791 |
lemma fps_inverse_deriv: |
54681 | 1792 |
fixes a :: "'a::field fps" |
29687 | 1793 |
assumes a0: "a$0 \<noteq> 0" |
53077 | 1794 |
shows "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2" |
54681 | 1795 |
proof - |
29687 | 1796 |
from inverse_mult_eq_1[OF a0] |
1797 |
have "fps_deriv (inverse a * a) = 0" by simp |
|
54452 | 1798 |
then have "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0" |
1799 |
by simp |
|
1800 |
then have "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0" |
|
1801 |
by simp |
|
29687 | 1802 |
with inverse_mult_eq_1[OF a0] |
53077 | 1803 |
have "(inverse a)\<^sup>2 * fps_deriv a + fps_deriv (inverse a) = 0" |
29687 | 1804 |
unfolding power2_eq_square |
36350 | 1805 |
apply (simp add: field_simps) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
1806 |
apply (simp add: mult.assoc[symmetric]) |
52903 | 1807 |
done |
53077 | 1808 |
then have "(inverse a)\<^sup>2 * fps_deriv a + fps_deriv (inverse a) - fps_deriv a * (inverse a)\<^sup>2 = |
1809 |
0 - fps_deriv a * (inverse a)\<^sup>2" |
|
29687 | 1810 |
by simp |
53077 | 1811 |
then show "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2" |
52902 | 1812 |
by (simp add: field_simps) |
29687 | 1813 |
qed |
1814 |
||
30488 | 1815 |
lemma fps_inverse_deriv': |
54681 | 1816 |
fixes a :: "'a::field fps" |
60501 | 1817 |
assumes a0: "a $ 0 \<noteq> 0" |
53077 | 1818 |
shows "fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1819 |
using fps_inverse_deriv[OF a0] a0 |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1820 |
by (simp add: fps_divide_unit power2_eq_square fps_inverse_mult) |
29687 | 1821 |
|
52902 | 1822 |
lemma inverse_mult_eq_1': |
1823 |
assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
60567 | 1824 |
shows "f * inverse f = 1" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
1825 |
by (metis mult.commute inverse_mult_eq_1 f0) |
29687 | 1826 |
|
52902 | 1827 |
lemma fps_divide_deriv: |
54681 | 1828 |
fixes a :: "'a::field fps" |
29687 | 1829 |
assumes a0: "b$0 \<noteq> 0" |
53077 | 1830 |
shows "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b\<^sup>2" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1831 |
using fps_inverse_deriv[OF a0] a0 |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1832 |
by (simp add: fps_divide_unit field_simps |
48757 | 1833 |
power2_eq_square fps_inverse_mult inverse_mult_eq_1'[OF a0]) |
30488 | 1834 |
|
29687 | 1835 |
|
54681 | 1836 |
lemma fps_inverse_gp': "inverse (Abs_fps (\<lambda>n. 1::'a::field)) = 1 - X" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1837 |
by (simp add: fps_inverse_gp fps_eq_iff X_def) |
29687 | 1838 |
|
1839 |
lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)" |
|
52902 | 1840 |
by (cases n) simp_all |
29687 | 1841 |
|
60501 | 1842 |
lemma fps_inverse_X_plus1: "inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::field)) ^ n)" |
1843 |
(is "_ = ?r") |
|
54681 | 1844 |
proof - |
29687 | 1845 |
have eq: "(1 + X) * ?r = 1" |
1846 |
unfolding minus_one_power_iff |
|
36350 | 1847 |
by (auto simp add: field_simps fps_eq_iff) |
54681 | 1848 |
show ?thesis |
1849 |
by (auto simp add: eq intro: fps_inverse_unique) |
|
29687 | 1850 |
qed |
1851 |
||
30488 | 1852 |
|
60501 | 1853 |
subsection \<open>Integration\<close> |
31273 | 1854 |
|
52903 | 1855 |
definition fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps" |
1856 |
where "fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))" |
|
29687 | 1857 |
|
31273 | 1858 |
lemma fps_deriv_fps_integral: "fps_deriv (fps_integral a a0) = a" |
1859 |
unfolding fps_integral_def fps_deriv_def |
|
1860 |
by (simp add: fps_eq_iff del: of_nat_Suc) |
|
29687 | 1861 |
|
31273 | 1862 |
lemma fps_integral_linear: |
1863 |
"fps_integral (fps_const a * f + fps_const b * g) (a*a0 + b*b0) = |
|
1864 |
fps_const a * fps_integral f a0 + fps_const b * fps_integral g b0" |
|
1865 |
(is "?l = ?r") |
|
53195 | 1866 |
proof - |
54681 | 1867 |
have "fps_deriv ?l = fps_deriv ?r" |
1868 |
by (simp add: fps_deriv_fps_integral) |
|
1869 |
moreover have "?l$0 = ?r$0" |
|
1870 |
by (simp add: fps_integral_def) |
|
29687 | 1871 |
ultimately show ?thesis |
1872 |
unfolding fps_deriv_eq_iff by auto |
|
1873 |
qed |
|
30488 | 1874 |
|
53195 | 1875 |
|
60500 | 1876 |
subsection \<open>Composition of FPSs\<close> |
53195 | 1877 |
|
60501 | 1878 |
definition fps_compose :: "'a::semiring_1 fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55) |
54681 | 1879 |
where "a oo b = Abs_fps (\<lambda>n. setsum (\<lambda>i. a$i * (b^i$n)) {0..n})" |
29687 | 1880 |
|
48757 | 1881 |
lemma fps_compose_nth: "(a oo b)$n = setsum (\<lambda>i. a$i * (b^i$n)) {0..n}" |
1882 |
by (simp add: fps_compose_def) |
|
29687 | 1883 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1884 |
lemma fps_compose_nth_0 [simp]: "(f oo g) $ 0 = f $ 0" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1885 |
by (simp add: fps_compose_nth) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
1886 |
|
54681 | 1887 |
lemma fps_compose_X[simp]: "a oo X = (a :: 'a::comm_ring_1 fps)" |
57418 | 1888 |
by (simp add: fps_ext fps_compose_def mult_delta_right setsum.delta') |
30488 | 1889 |
|
60501 | 1890 |
lemma fps_const_compose[simp]: "fps_const (a::'a::comm_ring_1) oo b = fps_const a" |
57418 | 1891 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum.delta) |
29687 | 1892 |
|
54681 | 1893 |
lemma numeral_compose[simp]: "(numeral k :: 'a::comm_ring_1 fps) oo b = numeral k" |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1894 |
unfolding numeral_fps_const by simp |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1895 |
|
54681 | 1896 |
lemma neg_numeral_compose[simp]: "(- numeral k :: 'a::comm_ring_1 fps) oo b = - numeral k" |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1897 |
unfolding neg_numeral_fps_const by simp |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
1898 |
|
54681 | 1899 |
lemma X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> X oo a = (a :: 'a::comm_ring_1 fps)" |
57418 | 1900 |
by (simp add: fps_eq_iff fps_compose_def mult_delta_left setsum.delta not_le) |
29687 | 1901 |
|
1902 |
||
60500 | 1903 |
subsection \<open>Rules from Herbert Wilf's Generatingfunctionology\<close> |
1904 |
||
1905 |
subsubsection \<open>Rule 1\<close> |
|
29687 | 1906 |
(* {a_{n+k}}_0^infty Corresponds to (f - setsum (\<lambda>i. a_i * x^i))/x^h, for h>0*) |
1907 |
||
30488 | 1908 |
lemma fps_power_mult_eq_shift: |
52902 | 1909 |
"X^Suc k * Abs_fps (\<lambda>n. a (n + Suc k)) = |
54681 | 1910 |
Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a::comm_ring_1) * X^i) {0 .. k}" |
52902 | 1911 |
(is "?lhs = ?rhs") |
1912 |
proof - |
|
60501 | 1913 |
have "?lhs $ n = ?rhs $ n" for n :: nat |
1914 |
proof - |
|
30488 | 1915 |
have "?lhs $ n = (if n < Suc k then 0 else a n)" |
29687 | 1916 |
unfolding X_power_mult_nth by auto |
1917 |
also have "\<dots> = ?rhs $ n" |
|
52902 | 1918 |
proof (induct k) |
1919 |
case 0 |
|
60501 | 1920 |
then show ?case |
1921 |
by (simp add: fps_setsum_nth) |
|
29687 | 1922 |
next |
1923 |
case (Suc k) |
|
52902 | 1924 |
have "(Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. Suc k})$n = |
53196 | 1925 |
(Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. k} - |
1926 |
fps_const (a (Suc k)) * X^ Suc k) $ n" |
|
52902 | 1927 |
by (simp add: field_simps) |
1928 |
also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n" |
|
60501 | 1929 |
using Suc.hyps[symmetric] unfolding fps_sub_nth by simp |
29687 | 1930 |
also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1931 |
unfolding X_power_mult_right_nth |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1932 |
apply (auto simp add: not_less fps_const_def) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1933 |
apply (rule cong[of a a, OF refl]) |
52902 | 1934 |
apply arith |
1935 |
done |
|
60501 | 1936 |
finally show ?case |
1937 |
by simp |
|
29687 | 1938 |
qed |
60501 | 1939 |
finally show ?thesis . |
1940 |
qed |
|
1941 |
then show ?thesis |
|
1942 |
by (simp add: fps_eq_iff) |
|
29687 | 1943 |
qed |
1944 |
||
53195 | 1945 |
|
60500 | 1946 |
subsubsection \<open>Rule 2\<close> |
29687 | 1947 |
|
1948 |
(* We can not reach the form of Wilf, but still near to it using rewrite rules*) |
|
30488 | 1949 |
(* If f reprents {a_n} and P is a polynomial, then |
29687 | 1950 |
P(xD) f represents {P(n) a_n}*) |
1951 |
||
54681 | 1952 |
definition "XD = op * X \<circ> fps_deriv" |
1953 |
||
1954 |
lemma XD_add[simp]:"XD (a + b) = XD a + XD (b :: 'a::comm_ring_1 fps)" |
|
36350 | 1955 |
by (simp add: XD_def field_simps) |
29687 | 1956 |
|
1957 |
lemma XD_mult_const[simp]:"XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * XD a" |
|
36350 | 1958 |
by (simp add: XD_def field_simps) |
29687 | 1959 |
|
52902 | 1960 |
lemma XD_linear[simp]: "XD (fps_const c * a + fps_const d * b) = |
54681 | 1961 |
fps_const c * XD a + fps_const d * XD (b :: 'a::comm_ring_1 fps)" |
29687 | 1962 |
by simp |
1963 |
||
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
30837
diff
changeset
|
1964 |
lemma XDN_linear: |
52902 | 1965 |
"(XD ^^ n) (fps_const c * a + fps_const d * b) = |
54681 | 1966 |
fps_const c * (XD ^^ n) a + fps_const d * (XD ^^ n) (b :: 'a::comm_ring_1 fps)" |
48757 | 1967 |
by (induct n) simp_all |
29687 | 1968 |
|
52902 | 1969 |
lemma fps_mult_X_deriv_shift: "X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)" |
1970 |
by (simp add: fps_eq_iff) |
|
29687 | 1971 |
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
30837
diff
changeset
|
1972 |
lemma fps_mult_XD_shift: |
54681 | 1973 |
"(XD ^^ k) (a :: 'a::comm_ring_1 fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)" |
52902 | 1974 |
by (induct k arbitrary: a) (simp_all add: XD_def fps_eq_iff field_simps del: One_nat_def) |
29687 | 1975 |
|
53195 | 1976 |
|
60501 | 1977 |
subsubsection \<open>Rule 3\<close> |
1978 |
||
61585 | 1979 |
text \<open>Rule 3 is trivial and is given by \<open>fps_times_def\<close>.\<close> |
60501 | 1980 |
|
60500 | 1981 |
|
1982 |
subsubsection \<open>Rule 5 --- summation and "division" by (1 - X)\<close> |
|
29687 | 1983 |
|
1984 |
lemma fps_divide_X_minus1_setsum_lemma: |
|
54681 | 1985 |
"a = ((1::'a::comm_ring_1 fps) - X) * Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
53195 | 1986 |
proof - |
29687 | 1987 |
let ?sa = "Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
52902 | 1988 |
have th0: "\<And>i. (1 - (X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)" |
1989 |
by simp |
|
60501 | 1990 |
have "a$n = ((1 - X) * ?sa) $ n" for n |
1991 |
proof (cases "n = 0") |
|
1992 |
case True |
|
1993 |
then show ?thesis |
|
1994 |
by (simp add: fps_mult_nth) |
|
1995 |
next |
|
1996 |
case False |
|
1997 |
then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1} \<union> {2..n} = {1..n}" |
|
1998 |
"{0..n - 1} \<union> {n} = {0..n}" |
|
1999 |
by (auto simp: set_eq_iff) |
|
2000 |
have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" "{0..n - 1} \<inter> {n} = {}" |
|
2001 |
using False by simp_all |
|
2002 |
have f: "finite {0}" "finite {1}" "finite {2 .. n}" |
|
2003 |
"finite {0 .. n - 1}" "finite {n}" by simp_all |
|
2004 |
have "((1 - X) * ?sa) $ n = setsum (\<lambda>i. (1 - X)$ i * ?sa $ (n - i)) {0 .. n}" |
|
2005 |
by (simp add: fps_mult_nth) |
|
2006 |
also have "\<dots> = a$n" |
|
2007 |
unfolding th0 |
|
2008 |
unfolding setsum.union_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)] |
|
2009 |
unfolding setsum.union_disjoint[OF f(2) f(3) d(2)] |
|
2010 |
apply (simp) |
|
2011 |
unfolding setsum.union_disjoint[OF f(4,5) d(3), unfolded u(3)] |
|
2012 |
apply simp |
|
2013 |
done |
|
2014 |
finally show ?thesis |
|
2015 |
by simp |
|
2016 |
qed |
|
54681 | 2017 |
then show ?thesis |
2018 |
unfolding fps_eq_iff by blast |
|
29687 | 2019 |
qed |
2020 |
||
2021 |
lemma fps_divide_X_minus1_setsum: |
|
54681 | 2022 |
"a /((1::'a::field fps) - X) = Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
52902 | 2023 |
proof - |
54681 | 2024 |
let ?X = "1 - (X::'a fps)" |
2025 |
have th0: "?X $ 0 \<noteq> 0" |
|
2026 |
by simp |
|
2027 |
have "a /?X = ?X * Abs_fps (\<lambda>n::nat. setsum (op $ a) {0..n}) * inverse ?X" |
|
29687 | 2028 |
using fps_divide_X_minus1_setsum_lemma[of a, symmetric] th0 |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
2029 |
by (simp add: fps_divide_def mult.assoc) |
54681 | 2030 |
also have "\<dots> = (inverse ?X * ?X) * Abs_fps (\<lambda>n::nat. setsum (op $ a) {0..n}) " |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
2031 |
by (simp add: ac_simps) |
54681 | 2032 |
finally show ?thesis |
2033 |
by (simp add: inverse_mult_eq_1[OF th0]) |
|
29687 | 2034 |
qed |
2035 |
||
53195 | 2036 |
|
60501 | 2037 |
subsubsection \<open>Rule 4 in its more general form: generalizes Rule 3 for an arbitrary |
60500 | 2038 |
finite product of FPS, also the relvant instance of powers of a FPS\<close> |
29687 | 2039 |
|
46131 | 2040 |
definition "natpermute n k = {l :: nat list. length l = k \<and> listsum l = n}" |
29687 | 2041 |
|
2042 |
lemma natlist_trivial_1: "natpermute n 1 = {[n]}" |
|
2043 |
apply (auto simp add: natpermute_def) |
|
52902 | 2044 |
apply (case_tac x) |
2045 |
apply auto |
|
29687 | 2046 |
done |
2047 |
||
2048 |
lemma append_natpermute_less_eq: |
|
54452 | 2049 |
assumes "xs @ ys \<in> natpermute n k" |
54681 | 2050 |
shows "listsum xs \<le> n" |
2051 |
and "listsum ys \<le> n" |
|
52902 | 2052 |
proof - |
54452 | 2053 |
from assms have "listsum (xs @ ys) = n" |
2054 |
by (simp add: natpermute_def) |
|
2055 |
then have "listsum xs + listsum ys = n" |
|
2056 |
by simp |
|
2057 |
then show "listsum xs \<le> n" and "listsum ys \<le> n" |
|
2058 |
by simp_all |
|
29687 | 2059 |
qed |
2060 |
||
2061 |
lemma natpermute_split: |
|
54452 | 2062 |
assumes "h \<le> k" |
52902 | 2063 |
shows "natpermute n k = |
2064 |
(\<Union>m \<in>{0..n}. {l1 @ l2 |l1 l2. l1 \<in> natpermute m h \<and> l2 \<in> natpermute (n - m) (k - h)})" |
|
60558 | 2065 |
(is "?L = ?R" is "_ = (\<Union>m \<in>{0..n}. ?S m)") |
2066 |
proof |
|
2067 |
show "?R \<subseteq> ?L" |
|
2068 |
proof |
|
52902 | 2069 |
fix l |
2070 |
assume l: "l \<in> ?R" |
|
2071 |
from l obtain m xs ys where h: "m \<in> {0..n}" |
|
2072 |
and xs: "xs \<in> natpermute m h" |
|
2073 |
and ys: "ys \<in> natpermute (n - m) (k - h)" |
|
2074 |
and leq: "l = xs@ys" by blast |
|
2075 |
from xs have xs': "listsum xs = m" |
|
2076 |
by (simp add: natpermute_def) |
|
2077 |
from ys have ys': "listsum ys = n - m" |
|
2078 |
by (simp add: natpermute_def) |
|
60558 | 2079 |
show "l \<in> ?L" using leq xs ys h |
46131 | 2080 |
apply (clarsimp simp add: natpermute_def) |
29687 | 2081 |
unfolding xs' ys' |
54452 | 2082 |
using assms xs ys |
48757 | 2083 |
unfolding natpermute_def |
2084 |
apply simp |
|
2085 |
done |
|
60558 | 2086 |
qed |
2087 |
show "?L \<subseteq> ?R" |
|
2088 |
proof |
|
52902 | 2089 |
fix l |
2090 |
assume l: "l \<in> natpermute n k" |
|
29687 | 2091 |
let ?xs = "take h l" |
2092 |
let ?ys = "drop h l" |
|
46131 | 2093 |
let ?m = "listsum ?xs" |
52902 | 2094 |
from l have ls: "listsum (?xs @ ?ys) = n" |
2095 |
by (simp add: natpermute_def) |
|
54452 | 2096 |
have xs: "?xs \<in> natpermute ?m h" using l assms |
52902 | 2097 |
by (simp add: natpermute_def) |
2098 |
have l_take_drop: "listsum l = listsum (take h l @ drop h l)" |
|
2099 |
by simp |
|
2100 |
then have ys: "?ys \<in> natpermute (n - ?m) (k - h)" |
|
54452 | 2101 |
using l assms ls by (auto simp add: natpermute_def simp del: append_take_drop_id) |
52902 | 2102 |
from ls have m: "?m \<in> {0..n}" |
2103 |
by (simp add: l_take_drop del: append_take_drop_id) |
|
60558 | 2104 |
from xs ys ls show "l \<in> ?R" |
29687 | 2105 |
apply auto |
52902 | 2106 |
apply (rule bexI [where x = "?m"]) |
2107 |
apply (rule exI [where x = "?xs"]) |
|
2108 |
apply (rule exI [where x = "?ys"]) |
|
52891 | 2109 |
using ls l |
46131 | 2110 |
apply (auto simp add: natpermute_def l_take_drop simp del: append_take_drop_id) |
48757 | 2111 |
apply simp |
2112 |
done |
|
60558 | 2113 |
qed |
29687 | 2114 |
qed |
2115 |
||
2116 |
lemma natpermute_0: "natpermute n 0 = (if n = 0 then {[]} else {})" |
|
2117 |
by (auto simp add: natpermute_def) |
|
52902 | 2118 |
|
29687 | 2119 |
lemma natpermute_0'[simp]: "natpermute 0 k = (if k = 0 then {[]} else {replicate k 0})" |
2120 |
apply (auto simp add: set_replicate_conv_if natpermute_def) |
|
2121 |
apply (rule nth_equalityI) |
|
48757 | 2122 |
apply simp_all |
2123 |
done |
|
29687 | 2124 |
|
2125 |
lemma natpermute_finite: "finite (natpermute n k)" |
|
52902 | 2126 |
proof (induct k arbitrary: n) |
2127 |
case 0 |
|
2128 |
then show ?case |
|
29687 | 2129 |
apply (subst natpermute_split[of 0 0, simplified]) |
52902 | 2130 |
apply (simp add: natpermute_0) |
2131 |
done |
|
29687 | 2132 |
next |
2133 |
case (Suc k) |
|
52902 | 2134 |
then show ?case unfolding natpermute_split [of k "Suc k", simplified] |
29687 | 2135 |
apply - |
2136 |
apply (rule finite_UN_I) |
|
2137 |
apply simp |
|
2138 |
unfolding One_nat_def[symmetric] natlist_trivial_1 |
|
2139 |
apply simp |
|
2140 |
done |
|
2141 |
qed |
|
2142 |
||
2143 |
lemma natpermute_contain_maximal: |
|
60558 | 2144 |
"{xs \<in> natpermute n (k + 1). n \<in> set xs} = (\<Union>i\<in>{0 .. k}. {(replicate (k + 1) 0) [i:=n]})" |
29687 | 2145 |
(is "?A = ?B") |
60558 | 2146 |
proof |
2147 |
show "?A \<subseteq> ?B" |
|
2148 |
proof |
|
52902 | 2149 |
fix xs |
60558 | 2150 |
assume "xs \<in> ?A" |
2151 |
then have H: "xs \<in> natpermute n (k + 1)" and n: "n \<in> set xs" |
|
2152 |
by blast+ |
|
2153 |
then obtain i where i: "i \<in> {0.. k}" "xs!i = n" |
|
30488 | 2154 |
unfolding in_set_conv_nth by (auto simp add: less_Suc_eq_le natpermute_def) |
52902 | 2155 |
have eqs: "({0..k} - {i}) \<union> {i} = {0..k}" |
2156 |
using i by auto |
|
2157 |
have f: "finite({0..k} - {i})" "finite {i}" |
|
2158 |
by auto |
|
2159 |
have d: "({0..k} - {i}) \<inter> {i} = {}" |
|
2160 |
using i by auto |
|
2161 |
from H have "n = setsum (nth xs) {0..k}" |
|
2162 |
apply (simp add: natpermute_def) |
|
2163 |
apply (auto simp add: atLeastLessThanSuc_atLeastAtMost listsum_setsum_nth) |
|
2164 |
done |
|
29687 | 2165 |
also have "\<dots> = n + setsum (nth xs) ({0..k} - {i})" |
57418 | 2166 |
unfolding setsum.union_disjoint[OF f d, unfolded eqs] using i by simp |
52902 | 2167 |
finally have zxs: "\<forall> j\<in> {0..k} - {i}. xs!j = 0" |
2168 |
by auto |
|
2169 |
from H have xsl: "length xs = k+1" |
|
2170 |
by (simp add: natpermute_def) |
|
29687 | 2171 |
from i have i': "i < length (replicate (k+1) 0)" "i < k+1" |
52902 | 2172 |
unfolding length_replicate by presburger+ |
29687 | 2173 |
have "xs = replicate (k+1) 0 [i := n]" |
2174 |
apply (rule nth_equalityI) |
|
2175 |
unfolding xsl length_list_update length_replicate |
|
2176 |
apply simp |
|
2177 |
apply clarify |
|
2178 |
unfolding nth_list_update[OF i'(1)] |
|
2179 |
using i zxs |
|
52902 | 2180 |
apply (case_tac "ia = i") |
2181 |
apply (auto simp del: replicate.simps) |
|
2182 |
done |
|
60558 | 2183 |
then show "xs \<in> ?B" using i by blast |
2184 |
qed |
|
2185 |
show "?B \<subseteq> ?A" |
|
2186 |
proof |
|
2187 |
fix xs |
|
2188 |
assume "xs \<in> ?B" |
|
2189 |
then obtain i where i: "i \<in> {0..k}" and xs: "xs = replicate (k + 1) 0 [i:=n]" |
|
2190 |
by auto |
|
2191 |
have nxs: "n \<in> set xs" |
|
2192 |
unfolding xs |
|
52902 | 2193 |
apply (rule set_update_memI) |
2194 |
using i apply simp |
|
2195 |
done |
|
60558 | 2196 |
have xsl: "length xs = k + 1" |
2197 |
by (simp only: xs length_replicate length_list_update) |
|
2198 |
have "listsum xs = setsum (nth xs) {0..<k+1}" |
|
46131 | 2199 |
unfolding listsum_setsum_nth xsl .. |
29687 | 2200 |
also have "\<dots> = setsum (\<lambda>j. if j = i then n else 0) {0..< k+1}" |
60558 | 2201 |
by (rule setsum.cong) (simp_all add: xs del: replicate.simps) |
57418 | 2202 |
also have "\<dots> = n" using i by (simp add: setsum.delta) |
60558 | 2203 |
finally have "xs \<in> natpermute n (k + 1)" |
52902 | 2204 |
using xsl unfolding natpermute_def mem_Collect_eq by blast |
60558 | 2205 |
then show "xs \<in> ?A" |
2206 |
using nxs by blast |
|
2207 |
qed |
|
29687 | 2208 |
qed |
2209 |
||
60558 | 2210 |
text \<open>The general form.\<close> |
29687 | 2211 |
lemma fps_setprod_nth: |
52902 | 2212 |
fixes m :: nat |
54681 | 2213 |
and a :: "nat \<Rightarrow> 'a::comm_ring_1 fps" |
2214 |
shows "(setprod a {0 .. m}) $ n = |
|
53196 | 2215 |
setsum (\<lambda>v. setprod (\<lambda>j. (a j) $ (v!j)) {0..m}) (natpermute n (m+1))" |
29687 | 2216 |
(is "?P m n") |
52902 | 2217 |
proof (induct m arbitrary: n rule: nat_less_induct) |
29687 | 2218 |
fix m n assume H: "\<forall>m' < m. \<forall>n. ?P m' n" |
53196 | 2219 |
show "?P m n" |
2220 |
proof (cases m) |
|
2221 |
case 0 |
|
2222 |
then show ?thesis |
|
2223 |
apply simp |
|
2224 |
unfolding natlist_trivial_1[where n = n, unfolded One_nat_def] |
|
2225 |
apply simp |
|
2226 |
done |
|
2227 |
next |
|
2228 |
case (Suc k) |
|
2229 |
then have km: "k < m" by arith |
|
52902 | 2230 |
have u0: "{0 .. k} \<union> {m} = {0..m}" |
54452 | 2231 |
using Suc by (simp add: set_eq_iff) presburger |
29687 | 2232 |
have f0: "finite {0 .. k}" "finite {m}" by auto |
53196 | 2233 |
have d0: "{0 .. k} \<inter> {m} = {}" using Suc by auto |
29687 | 2234 |
have "(setprod a {0 .. m}) $ n = (setprod a {0 .. k} * a m) $ n" |
57418 | 2235 |
unfolding setprod.union_disjoint[OF f0 d0, unfolded u0] by simp |
29687 | 2236 |
also have "\<dots> = (\<Sum>i = 0..n. (\<Sum>v\<in>natpermute i (k + 1). \<Prod>j\<in>{0..k}. a j $ v ! j) * a m $ (n - i))" |
2237 |
unfolding fps_mult_nth H[rule_format, OF km] .. |
|
2238 |
also have "\<dots> = (\<Sum>v\<in>natpermute n (m + 1). \<Prod>j\<in>{0..m}. a j $ v ! j)" |
|
53196 | 2239 |
apply (simp add: Suc) |
48757 | 2240 |
unfolding natpermute_split[of m "m + 1", simplified, of n, |
53196 | 2241 |
unfolded natlist_trivial_1[unfolded One_nat_def] Suc] |
57418 | 2242 |
apply (subst setsum.UNION_disjoint) |
30488 | 2243 |
apply simp |
29687 | 2244 |
apply simp |
2245 |
unfolding image_Collect[symmetric] |
|
2246 |
apply clarsimp |
|
2247 |
apply (rule finite_imageI) |
|
2248 |
apply (rule natpermute_finite) |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
2249 |
apply (clarsimp simp add: set_eq_iff) |
29687 | 2250 |
apply auto |
57418 | 2251 |
apply (rule setsum.cong) |
2252 |
apply (rule refl) |
|
29687 | 2253 |
unfolding setsum_left_distrib |
2254 |
apply (rule sym) |
|
57418 | 2255 |
apply (rule_tac l = "\<lambda>xs. xs @ [n - x]" in setsum.reindex_cong) |
29687 | 2256 |
apply (simp add: inj_on_def) |
2257 |
apply auto |
|
57418 | 2258 |
unfolding setprod.union_disjoint[OF f0 d0, unfolded u0, unfolded Suc] |
29687 | 2259 |
apply (clarsimp simp add: natpermute_def nth_append) |
2260 |
done |
|
53196 | 2261 |
finally show ?thesis . |
2262 |
qed |
|
29687 | 2263 |
qed |
2264 |
||
60558 | 2265 |
text \<open>The special form for powers.\<close> |
29687 | 2266 |
lemma fps_power_nth_Suc: |
52903 | 2267 |
fixes m :: nat |
54681 | 2268 |
and a :: "'a::comm_ring_1 fps" |
29687 | 2269 |
shows "(a ^ Suc m)$n = setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m}) (natpermute n (m+1))" |
52902 | 2270 |
proof - |
54452 | 2271 |
have th0: "a^Suc m = setprod (\<lambda>i. a) {0..m}" |
2272 |
by (simp add: setprod_constant) |
|
29687 | 2273 |
show ?thesis unfolding th0 fps_setprod_nth .. |
2274 |
qed |
|
52902 | 2275 |
|
29687 | 2276 |
lemma fps_power_nth: |
54452 | 2277 |
fixes m :: nat |
54681 | 2278 |
and a :: "'a::comm_ring_1 fps" |
53196 | 2279 |
shows "(a ^m)$n = |
2280 |
(if m=0 then 1$n else setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m - 1}) (natpermute n m))" |
|
52902 | 2281 |
by (cases m) (simp_all add: fps_power_nth_Suc del: power_Suc) |
29687 | 2282 |
|
30488 | 2283 |
lemma fps_nth_power_0: |
54452 | 2284 |
fixes m :: nat |
54681 | 2285 |
and a :: "'a::comm_ring_1 fps" |
29687 | 2286 |
shows "(a ^m)$0 = (a$0) ^ m" |
53195 | 2287 |
proof (cases m) |
2288 |
case 0 |
|
2289 |
then show ?thesis by simp |
|
2290 |
next |
|
2291 |
case (Suc n) |
|
2292 |
then have c: "m = card {0..n}" by simp |
|
2293 |
have "(a ^m)$0 = setprod (\<lambda>i. a$0) {0..n}" |
|
2294 |
by (simp add: Suc fps_power_nth del: replicate.simps power_Suc) |
|
2295 |
also have "\<dots> = (a$0) ^ m" |
|
2296 |
unfolding c by (rule setprod_constant) simp |
|
2297 |
finally show ?thesis . |
|
29687 | 2298 |
qed |
2299 |
||
30488 | 2300 |
lemma fps_compose_inj_right: |
54681 | 2301 |
assumes a0: "a$0 = (0::'a::idom)" |
52902 | 2302 |
and a1: "a$1 \<noteq> 0" |
54681 | 2303 |
shows "(b oo a = c oo a) \<longleftrightarrow> b = c" |
2304 |
(is "?lhs \<longleftrightarrow>?rhs") |
|
53196 | 2305 |
proof |
60501 | 2306 |
show ?lhs if ?rhs using that by simp |
2307 |
show ?rhs if ?lhs |
|
2308 |
proof - |
|
2309 |
have "b$n = c$n" for n |
|
53196 | 2310 |
proof (induct n rule: nat_less_induct) |
2311 |
fix n |
|
2312 |
assume H: "\<forall>m<n. b$m = c$m" |
|
60501 | 2313 |
show "b$n = c$n" |
2314 |
proof (cases n) |
|
2315 |
case 0 |
|
2316 |
from \<open>?lhs\<close> have "(b oo a)$n = (c oo a)$n" |
|
2317 |
by simp |
|
2318 |
then show ?thesis |
|
2319 |
using 0 by (simp add: fps_compose_nth) |
|
2320 |
next |
|
2321 |
case (Suc n1) |
|
53196 | 2322 |
have f: "finite {0 .. n1}" "finite {n}" by simp_all |
60501 | 2323 |
have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using Suc by auto |
2324 |
have d: "{0 .. n1} \<inter> {n} = {}" using Suc by auto |
|
53196 | 2325 |
have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)" |
57418 | 2326 |
apply (rule setsum.cong) |
60501 | 2327 |
using H Suc |
53196 | 2328 |
apply auto |
2329 |
done |
|
2330 |
have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n" |
|
57418 | 2331 |
unfolding fps_compose_nth setsum.union_disjoint[OF f d, unfolded eq] seq |
53196 | 2332 |
using startsby_zero_power_nth_same[OF a0] |
2333 |
by simp |
|
2334 |
have th1: "(c oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + c$n * (a$1)^n" |
|
57418 | 2335 |
unfolding fps_compose_nth setsum.union_disjoint[OF f d, unfolded eq] |
53196 | 2336 |
using startsby_zero_power_nth_same[OF a0] |
2337 |
by simp |
|
60501 | 2338 |
from \<open>?lhs\<close>[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1 |
2339 |
show ?thesis by auto |
|
2340 |
qed |
|
2341 |
qed |
|
2342 |
then show ?rhs by (simp add: fps_eq_iff) |
|
2343 |
qed |
|
29687 | 2344 |
qed |
2345 |
||
2346 |
||
60500 | 2347 |
subsection \<open>Radicals\<close> |
29687 | 2348 |
|
57418 | 2349 |
declare setprod.cong [fundef_cong] |
52903 | 2350 |
|
54681 | 2351 |
function radical :: "(nat \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a::field fps \<Rightarrow> nat \<Rightarrow> 'a" |
52902 | 2352 |
where |
29687 | 2353 |
"radical r 0 a 0 = 1" |
2354 |
| "radical r 0 a (Suc n) = 0" |
|
2355 |
| "radical r (Suc k) a 0 = r (Suc k) (a$0)" |
|
48757 | 2356 |
| "radical r (Suc k) a (Suc n) = |
2357 |
(a$ Suc n - setsum (\<lambda>xs. setprod (\<lambda>j. radical r (Suc k) a (xs ! j)) {0..k}) |
|
2358 |
{xs. xs \<in> natpermute (Suc n) (Suc k) \<and> Suc n \<notin> set xs}) / |
|
2359 |
(of_nat (Suc k) * (radical r (Suc k) a 0)^k)" |
|
52902 | 2360 |
by pat_completeness auto |
29687 | 2361 |
|
2362 |
termination radical |
|
2363 |
proof |
|
2364 |
let ?R = "measure (\<lambda>(r, k, a, n). n)" |
|
2365 |
{ |
|
52902 | 2366 |
show "wf ?R" by auto |
2367 |
next |
|
2368 |
fix r k a n xs i |
|
29687 | 2369 |
assume xs: "xs \<in> {xs \<in> natpermute (Suc n) (Suc k). Suc n \<notin> set xs}" and i: "i \<in> {0..k}" |
60558 | 2370 |
have False if c: "Suc n \<le> xs ! i" |
2371 |
proof - |
|
52902 | 2372 |
from xs i have "xs !i \<noteq> Suc n" |
2373 |
by (auto simp add: in_set_conv_nth natpermute_def) |
|
29687 | 2374 |
with c have c': "Suc n < xs!i" by arith |
52902 | 2375 |
have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" |
2376 |
by simp_all |
|
2377 |
have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" |
|
2378 |
by auto |
|
2379 |
have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" |
|
2380 |
using i by auto |
|
2381 |
from xs have "Suc n = listsum xs" |
|
2382 |
by (simp add: natpermute_def) |
|
46131 | 2383 |
also have "\<dots> = setsum (nth xs) {0..<Suc k}" using xs |
2384 |
by (simp add: natpermute_def listsum_setsum_nth) |
|
29687 | 2385 |
also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}" |
57418 | 2386 |
unfolding eqs setsum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] |
2387 |
unfolding setsum.union_disjoint[OF fths(2) fths(3) d(2)] |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2388 |
by simp |
60558 | 2389 |
finally show ?thesis using c' by simp |
2390 |
qed |
|
52902 | 2391 |
then show "((r, Suc k, a, xs!i), r, Suc k, a, Suc n) \<in> ?R" |
2392 |
apply auto |
|
2393 |
apply (metis not_less) |
|
2394 |
done |
|
2395 |
next |
|
2396 |
fix r k a n |
|
2397 |
show "((r, Suc k, a, 0), r, Suc k, a, Suc n) \<in> ?R" by simp |
|
2398 |
} |
|
29687 | 2399 |
qed |
2400 |
||
2401 |
definition "fps_radical r n a = Abs_fps (radical r n a)" |
|
2402 |
||
2403 |
lemma fps_radical0[simp]: "fps_radical r 0 a = 1" |
|
52902 | 2404 |
apply (auto simp add: fps_eq_iff fps_radical_def) |
2405 |
apply (case_tac n) |
|
2406 |
apply auto |
|
2407 |
done |
|
29687 | 2408 |
|
60501 | 2409 |
lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n = 0 then 1 else r n (a$0))" |
52902 | 2410 |
by (cases n) (simp_all add: fps_radical_def) |
29687 | 2411 |
|
30488 | 2412 |
lemma fps_radical_power_nth[simp]: |
29687 | 2413 |
assumes r: "(r k (a$0)) ^ k = a$0" |
2414 |
shows "fps_radical r k a ^ k $ 0 = (if k = 0 then 1 else a$0)" |
|
53196 | 2415 |
proof (cases k) |
2416 |
case 0 |
|
2417 |
then show ?thesis by simp |
|
2418 |
next |
|
2419 |
case (Suc h) |
|
2420 |
have eq1: "fps_radical r k a ^ k $ 0 = (\<Prod>j\<in>{0..h}. fps_radical r k a $ (replicate k 0) ! j)" |
|
2421 |
unfolding fps_power_nth Suc by simp |
|
2422 |
also have "\<dots> = (\<Prod>j\<in>{0..h}. r k (a$0))" |
|
57418 | 2423 |
apply (rule setprod.cong) |
53196 | 2424 |
apply simp |
2425 |
using Suc |
|
54681 | 2426 |
apply (subgoal_tac "replicate k 0 ! x = 0") |
53196 | 2427 |
apply (auto intro: nth_replicate simp del: replicate.simps) |
2428 |
done |
|
60501 | 2429 |
also have "\<dots> = a$0" |
2430 |
using r Suc by (simp add: setprod_constant) |
|
2431 |
finally show ?thesis |
|
2432 |
using Suc by simp |
|
30488 | 2433 |
qed |
29687 | 2434 |
|
52902 | 2435 |
lemma natpermute_max_card: |
54452 | 2436 |
assumes n0: "n \<noteq> 0" |
60558 | 2437 |
shows "card {xs \<in> natpermute n (k + 1). n \<in> set xs} = k + 1" |
29687 | 2438 |
unfolding natpermute_contain_maximal |
52902 | 2439 |
proof - |
60501 | 2440 |
let ?A = "\<lambda>i. {replicate (k + 1) 0[i := n]}" |
29687 | 2441 |
let ?K = "{0 ..k}" |
60501 | 2442 |
have fK: "finite ?K" |
2443 |
by simp |
|
2444 |
have fAK: "\<forall>i\<in>?K. finite (?A i)" |
|
2445 |
by auto |
|
48757 | 2446 |
have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow> |
2447 |
{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}" |
|
52902 | 2448 |
proof clarify |
2449 |
fix i j |
|
60501 | 2450 |
assume i: "i \<in> ?K" and j: "j \<in> ?K" and ij: "i \<noteq> j" |
60558 | 2451 |
have False if eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]" |
2452 |
proof - |
|
52902 | 2453 |
have "(replicate (k+1) 0 [i:=n] ! i) = n" |
2454 |
using i by (simp del: replicate.simps) |
|
29687 | 2455 |
moreover |
52902 | 2456 |
have "(replicate (k+1) 0 [j:=n] ! i) = 0" |
2457 |
using i ij by (simp del: replicate.simps) |
|
60558 | 2458 |
ultimately show ?thesis |
52902 | 2459 |
using eq n0 by (simp del: replicate.simps) |
60558 | 2460 |
qed |
29687 | 2461 |
then show "{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}" |
2462 |
by auto |
|
2463 |
qed |
|
54452 | 2464 |
from card_UN_disjoint[OF fK fAK d] |
2465 |
show "card (\<Union>i\<in>{0..k}. {replicate (k + 1) 0[i := n]}) = k + 1" |
|
52902 | 2466 |
by simp |
29687 | 2467 |
qed |
30488 | 2468 |
|
2469 |
lemma power_radical: |
|
31273 | 2470 |
fixes a:: "'a::field_char_0 fps" |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2471 |
assumes a0: "a$0 \<noteq> 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2472 |
shows "(r (Suc k) (a$0)) ^ Suc k = a$0 \<longleftrightarrow> (fps_radical r (Suc k) a) ^ (Suc k) = a" |
60558 | 2473 |
(is "?lhs \<longleftrightarrow> ?rhs") |
2474 |
proof |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2475 |
let ?r = "fps_radical r (Suc k) a" |
60558 | 2476 |
show ?rhs if r0: ?lhs |
2477 |
proof - |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2478 |
from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto |
60501 | 2479 |
have "?r ^ Suc k $ z = a$z" for z |
2480 |
proof (induct z rule: nat_less_induct) |
|
2481 |
fix n |
|
2482 |
assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" |
|
2483 |
show "?r ^ Suc k $ n = a $n" |
|
2484 |
proof (cases n) |
|
2485 |
case 0 |
|
2486 |
then show ?thesis |
|
2487 |
using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp |
|
2488 |
next |
|
2489 |
case (Suc n1) |
|
2490 |
then have "n \<noteq> 0" by simp |
|
2491 |
let ?Pnk = "natpermute n (k + 1)" |
|
2492 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
|
2493 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
|
2494 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
|
2495 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
|
2496 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
|
2497 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
|
2498 |
by (metis natpermute_finite)+ |
|
2499 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
|
2500 |
have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" |
|
2501 |
proof (rule setsum.cong) |
|
2502 |
fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}" |
|
2503 |
let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = |
|
2504 |
fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k" |
|
2505 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
|
2506 |
unfolding natpermute_contain_maximal by auto |
|
2507 |
have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = |
|
2508 |
(\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))" |
|
2509 |
apply (rule setprod.cong, simp) |
|
2510 |
using i r0 |
|
2511 |
apply (simp del: replicate.simps) |
|
2512 |
done |
|
2513 |
also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" |
|
2514 |
using i r0 by (simp add: setprod_gen_delta) |
|
2515 |
finally show ?ths . |
|
2516 |
qed rule |
|
2517 |
then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" |
|
2518 |
by (simp add: natpermute_max_card[OF \<open>n \<noteq> 0\<close>, simplified]) |
|
2519 |
also have "\<dots> = a$n - setsum ?f ?Pnknn" |
|
2520 |
unfolding Suc using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc) |
|
2521 |
finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . |
|
2522 |
have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" |
|
2523 |
unfolding fps_power_nth_Suc setsum.union_disjoint[OF f d, unfolded eq] .. |
|
2524 |
also have "\<dots> = a$n" unfolding fn by simp |
|
2525 |
finally show ?thesis . |
|
52903 | 2526 |
qed |
60501 | 2527 |
qed |
60558 | 2528 |
then show ?thesis using r0 by (simp add: fps_eq_iff) |
2529 |
qed |
|
2530 |
show ?lhs if ?rhs |
|
2531 |
proof - |
|
2532 |
from that have "((fps_radical r (Suc k) a) ^ (Suc k))$0 = a$0" |
|
2533 |
by simp |
|
2534 |
then show ?thesis |
|
52903 | 2535 |
unfolding fps_power_nth_Suc |
2536 |
by (simp add: setprod_constant del: replicate.simps) |
|
60558 | 2537 |
qed |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2538 |
qed |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2539 |
|
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2540 |
(* |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2541 |
lemma power_radical: |
31273 | 2542 |
fixes a:: "'a::field_char_0 fps" |
29687 | 2543 |
assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" |
30488 | 2544 |
shows "(fps_radical r (Suc k) a) ^ (Suc k) = a" |
29687 | 2545 |
proof- |
2546 |
let ?r = "fps_radical r (Suc k) a" |
|
2547 |
from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto |
|
2548 |
{fix z have "?r ^ Suc k $ z = a$z" |
|
2549 |
proof(induct z rule: nat_less_induct) |
|
2550 |
fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" |
|
54452 | 2551 |
{assume "n = 0" then have "?r ^ Suc k $ n = a $n" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2552 |
using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} |
29687 | 2553 |
moreover |
2554 |
{fix n1 assume n1: "n = Suc n1" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2555 |
have fK: "finite {0..k}" by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2556 |
have nz: "n \<noteq> 0" using n1 by arith |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2557 |
let ?Pnk = "natpermute n (k + 1)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2558 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2559 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2560 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2561 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2562 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2563 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2564 |
by (metis natpermute_finite)+ |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2565 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2566 |
have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" |
57418 | 2567 |
proof(rule setsum.cong2) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2568 |
fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2569 |
let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2570 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2571 |
unfolding natpermute_contain_maximal by auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2572 |
have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) = (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))" |
57418 | 2573 |
apply (rule setprod.cong, simp) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2574 |
using i r0 by (simp del: replicate.simps) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2575 |
also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2576 |
unfolding setprod_gen_delta[OF fK] using i r0 by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2577 |
finally show ?ths . |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2578 |
qed |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2579 |
then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2580 |
by (simp add: natpermute_max_card[OF nz, simplified]) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2581 |
also have "\<dots> = a$n - setsum ?f ?Pnknn" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2582 |
unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc ) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2583 |
finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2584 |
have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" |
57418 | 2585 |
unfolding fps_power_nth_Suc setsum.union_disjoint[OF f d, unfolded eq] .. |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2586 |
also have "\<dots> = a$n" unfolding fn by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2587 |
finally have "?r ^ Suc k $ n = a $n" .} |
29687 | 2588 |
ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) |
2589 |
qed } |
|
2590 |
then show ?thesis by (simp add: fps_eq_iff) |
|
2591 |
qed |
|
2592 |
||
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2593 |
*) |
52903 | 2594 |
lemma eq_divide_imp': |
60501 | 2595 |
fixes c :: "'a::field" |
2596 |
shows "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c" |
|
56480
093ea91498e6
field_simps: better support for negation and division, and power
hoelzl
parents:
56479
diff
changeset
|
2597 |
by (simp add: field_simps) |
29687 | 2598 |
|
30488 | 2599 |
lemma radical_unique: |
2600 |
assumes r0: "(r (Suc k) (b$0)) ^ Suc k = b$0" |
|
52903 | 2601 |
and a0: "r (Suc k) (b$0 ::'a::field_char_0) = a$0" |
2602 |
and b0: "b$0 \<noteq> 0" |
|
29687 | 2603 |
shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b" |
60501 | 2604 |
(is "?lhs \<longleftrightarrow> ?rhs" is "_ \<longleftrightarrow> a = ?r") |
2605 |
proof |
|
2606 |
show ?lhs if ?rhs |
|
2607 |
using that using power_radical[OF b0, of r k, unfolded r0] by simp |
|
2608 |
show ?rhs if ?lhs |
|
2609 |
proof - |
|
2610 |
have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto |
|
29687 | 2611 |
have ceq: "card {0..k} = Suc k" by simp |
2612 |
from a0 have a0r0: "a$0 = ?r$0" by simp |
|
60501 | 2613 |
have "a $ n = ?r $ n" for n |
2614 |
proof (induct n rule: nat_less_induct) |
|
52903 | 2615 |
fix n |
60501 | 2616 |
assume h: "\<forall>m<n. a$m = ?r $m" |
2617 |
show "a$n = ?r $ n" |
|
2618 |
proof (cases n) |
|
2619 |
case 0 |
|
2620 |
then show ?thesis using a0 by simp |
|
2621 |
next |
|
2622 |
case (Suc n1) |
|
2623 |
have fK: "finite {0..k}" by simp |
|
2624 |
have nz: "n \<noteq> 0" using Suc by simp |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2625 |
let ?Pnk = "natpermute n (Suc k)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2626 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2627 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2628 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2629 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2630 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2631 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2632 |
by (metis natpermute_finite)+ |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2633 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2634 |
let ?g = "\<lambda>v. \<Prod>j\<in>{0..k}. a $ v ! j" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2635 |
have "setsum ?g ?Pnkn = setsum (\<lambda>v. a $ n * (?r$0)^k) ?Pnkn" |
57418 | 2636 |
proof (rule setsum.cong) |
52903 | 2637 |
fix v |
2638 |
assume v: "v \<in> {xs \<in> natpermute n (Suc k). n \<in> set xs}" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2639 |
let ?ths = "(\<Prod>j\<in>{0..k}. a $ v ! j) = a $ n * (?r$0)^k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2640 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
52903 | 2641 |
unfolding Suc_eq_plus1 natpermute_contain_maximal |
2642 |
by (auto simp del: replicate.simps) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2643 |
have "(\<Prod>j\<in>{0..k}. a $ v ! j) = (\<Prod>j\<in>{0..k}. if j = i then a $ n else r (Suc k) (b$0))" |
57418 | 2644 |
apply (rule setprod.cong, simp) |
54452 | 2645 |
using i a0 |
2646 |
apply (simp del: replicate.simps) |
|
52903 | 2647 |
done |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2648 |
also have "\<dots> = a $ n * (?r $ 0)^k" |
46757 | 2649 |
using i by (simp add: setprod_gen_delta) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2650 |
finally show ?ths . |
57418 | 2651 |
qed rule |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2652 |
then have th0: "setsum ?g ?Pnkn = of_nat (k+1) * a $ n * (?r $ 0)^k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2653 |
by (simp add: natpermute_max_card[OF nz, simplified]) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2654 |
have th1: "setsum ?g ?Pnknn = setsum ?f ?Pnknn" |
57418 | 2655 |
proof (rule setsum.cong, rule refl, rule setprod.cong, simp) |
52903 | 2656 |
fix xs i |
2657 |
assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}" |
|
60501 | 2658 |
have False if c: "n \<le> xs ! i" |
2659 |
proof - |
|
2660 |
from xs i have "xs ! i \<noteq> n" |
|
52903 | 2661 |
by (auto simp add: in_set_conv_nth natpermute_def) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2662 |
with c have c': "n < xs!i" by arith |
52903 | 2663 |
have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" |
2664 |
by simp_all |
|
2665 |
have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" |
|
2666 |
by auto |
|
2667 |
have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" |
|
2668 |
using i by auto |
|
2669 |
from xs have "n = listsum xs" |
|
2670 |
by (simp add: natpermute_def) |
|
2671 |
also have "\<dots> = setsum (nth xs) {0..<Suc k}" |
|
2672 |
using xs by (simp add: natpermute_def listsum_setsum_nth) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2673 |
also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}" |
57418 | 2674 |
unfolding eqs setsum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] |
2675 |
unfolding setsum.union_disjoint[OF fths(2) fths(3) d(2)] |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2676 |
by simp |
60501 | 2677 |
finally show ?thesis using c' by simp |
2678 |
qed |
|
52902 | 2679 |
then have thn: "xs!i < n" by presburger |
52903 | 2680 |
from h[rule_format, OF thn] show "a$(xs !i) = ?r$(xs!i)" . |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2681 |
qed |
54681 | 2682 |
have th00: "\<And>x::'a. of_nat (Suc k) * (x * inverse (of_nat (Suc k))) = x" |
36350 | 2683 |
by (simp add: field_simps del: of_nat_Suc) |
60501 | 2684 |
from \<open>?lhs\<close> have "b$n = a^Suc k $ n" |
52903 | 2685 |
by (simp add: fps_eq_iff) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2686 |
also have "a ^ Suc k$n = setsum ?g ?Pnkn + setsum ?g ?Pnknn" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2687 |
unfolding fps_power_nth_Suc |
57418 | 2688 |
using setsum.union_disjoint[OF f d, unfolded Suc_eq_plus1[symmetric], |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2689 |
unfolded eq, of ?g] by simp |
52903 | 2690 |
also have "\<dots> = of_nat (k+1) * a $ n * (?r $ 0)^k + setsum ?f ?Pnknn" |
2691 |
unfolding th0 th1 .. |
|
2692 |
finally have "of_nat (k+1) * a $ n * (?r $ 0)^k = b$n - setsum ?f ?Pnknn" |
|
2693 |
by simp |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2694 |
then have "a$n = (b$n - setsum ?f ?Pnknn) / (of_nat (k+1) * (?r $ 0)^k)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2695 |
apply - |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2696 |
apply (rule eq_divide_imp') |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2697 |
using r00 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2698 |
apply (simp del: of_nat_Suc) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
2699 |
apply (simp add: ac_simps) |
52903 | 2700 |
done |
60501 | 2701 |
then show ?thesis |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2702 |
apply (simp del: of_nat_Suc) |
60501 | 2703 |
unfolding fps_radical_def Suc |
2704 |
apply (simp add: field_simps Suc th00 del: of_nat_Suc) |
|
52903 | 2705 |
done |
2706 |
qed |
|
60501 | 2707 |
qed |
2708 |
then show ?rhs by (simp add: fps_eq_iff) |
|
2709 |
qed |
|
29687 | 2710 |
qed |
2711 |
||
2712 |
||
30488 | 2713 |
lemma radical_power: |
2714 |
assumes r0: "r (Suc k) ((a$0) ^ Suc k) = a$0" |
|
54681 | 2715 |
and a0: "(a$0 :: 'a::field_char_0) \<noteq> 0" |
29687 | 2716 |
shows "(fps_radical r (Suc k) (a ^ Suc k)) = a" |
52903 | 2717 |
proof - |
29687 | 2718 |
let ?ak = "a^ Suc k" |
52903 | 2719 |
have ak0: "?ak $ 0 = (a$0) ^ Suc k" |
2720 |
by (simp add: fps_nth_power_0 del: power_Suc) |
|
2721 |
from r0 have th0: "r (Suc k) (a ^ Suc k $ 0) ^ Suc k = a ^ Suc k $ 0" |
|
2722 |
using ak0 by auto |
|
2723 |
from r0 ak0 have th1: "r (Suc k) (a ^ Suc k $ 0) = a $ 0" |
|
2724 |
by auto |
|
2725 |
from ak0 a0 have ak00: "?ak $ 0 \<noteq>0 " |
|
2726 |
by auto |
|
2727 |
from radical_unique[of r k ?ak a, OF th0 th1 ak00] show ?thesis |
|
2728 |
by metis |
|
29687 | 2729 |
qed |
2730 |
||
30488 | 2731 |
lemma fps_deriv_radical: |
54681 | 2732 |
fixes a :: "'a::field_char_0 fps" |
52903 | 2733 |
assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" |
2734 |
and a0: "a$0 \<noteq> 0" |
|
53196 | 2735 |
shows "fps_deriv (fps_radical r (Suc k) a) = |
2736 |
fps_deriv a / (fps_const (of_nat (Suc k)) * (fps_radical r (Suc k) a) ^ k)" |
|
52903 | 2737 |
proof - |
2738 |
let ?r = "fps_radical r (Suc k) a" |
|
29687 | 2739 |
let ?w = "(fps_const (of_nat (Suc k)) * ?r ^ k)" |
52903 | 2740 |
from a0 r0 have r0': "r (Suc k) (a$0) \<noteq> 0" |
2741 |
by auto |
|
2742 |
from r0' have w0: "?w $ 0 \<noteq> 0" |
|
2743 |
by (simp del: of_nat_Suc) |
|
29687 | 2744 |
note th0 = inverse_mult_eq_1[OF w0] |
2745 |
let ?iw = "inverse ?w" |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2746 |
from iffD1[OF power_radical[of a r], OF a0 r0] |
52903 | 2747 |
have "fps_deriv (?r ^ Suc k) = fps_deriv a" |
2748 |
by simp |
|
54452 | 2749 |
then have "fps_deriv ?r * ?w = fps_deriv a" |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
2750 |
by (simp add: fps_deriv_power ac_simps del: power_Suc) |
54452 | 2751 |
then have "?iw * fps_deriv ?r * ?w = ?iw * fps_deriv a" |
52903 | 2752 |
by simp |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2753 |
with a0 r0 have "fps_deriv ?r * (?iw * ?w) = fps_deriv a / ?w" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2754 |
by (subst fps_divide_unit) (auto simp del: of_nat_Suc) |
30488 | 2755 |
then show ?thesis unfolding th0 by simp |
29687 | 2756 |
qed |
2757 |
||
30488 | 2758 |
lemma radical_mult_distrib: |
54681 | 2759 |
fixes a :: "'a::field_char_0 fps" |
48757 | 2760 |
assumes k: "k > 0" |
2761 |
and ra0: "r k (a $ 0) ^ k = a $ 0" |
|
2762 |
and rb0: "r k (b $ 0) ^ k = b $ 0" |
|
60558 | 2763 |
and a0: "a $ 0 \<noteq> 0" |
2764 |
and b0: "b $ 0 \<noteq> 0" |
|
48757 | 2765 |
shows "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0) \<longleftrightarrow> |
60558 | 2766 |
fps_radical r k (a * b) = fps_radical r k a * fps_radical r k b" |
2767 |
(is "?lhs \<longleftrightarrow> ?rhs") |
|
2768 |
proof |
|
2769 |
show ?rhs if r0': ?lhs |
|
2770 |
proof - |
|
2771 |
from r0' have r0: "(r k ((a * b) $ 0)) ^ k = (a * b) $ 0" |
|
52903 | 2772 |
by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) |
60558 | 2773 |
show ?thesis |
60501 | 2774 |
proof (cases k) |
2775 |
case 0 |
|
2776 |
then show ?thesis using r0' by simp |
|
2777 |
next |
|
2778 |
case (Suc h) |
|
52903 | 2779 |
let ?ra = "fps_radical r (Suc h) a" |
2780 |
let ?rb = "fps_radical r (Suc h) b" |
|
2781 |
have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" |
|
60501 | 2782 |
using r0' Suc by (simp add: fps_mult_nth) |
52903 | 2783 |
have ab0: "(a*b) $ 0 \<noteq> 0" |
2784 |
using a0 b0 by (simp add: fps_mult_nth) |
|
60501 | 2785 |
from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded Suc] th0 ab0, symmetric] |
2786 |
iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded Suc]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded Suc]] Suc r0' |
|
2787 |
show ?thesis |
|
2788 |
by (auto simp add: power_mult_distrib simp del: power_Suc) |
|
2789 |
qed |
|
60558 | 2790 |
qed |
2791 |
show ?lhs if ?rhs |
|
2792 |
proof - |
|
2793 |
from that have "(fps_radical r k (a * b)) $ 0 = (fps_radical r k a * fps_radical r k b) $ 0" |
|
52903 | 2794 |
by simp |
60558 | 2795 |
then show ?thesis |
52903 | 2796 |
using k by (simp add: fps_mult_nth) |
60558 | 2797 |
qed |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2798 |
qed |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2799 |
|
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2800 |
(* |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2801 |
lemma radical_mult_distrib: |
31273 | 2802 |
fixes a:: "'a::field_char_0 fps" |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2803 |
assumes |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2804 |
ra0: "r k (a $ 0) ^ k = a $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2805 |
and rb0: "r k (b $ 0) ^ k = b $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2806 |
and r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" |
29687 | 2807 |
and a0: "a$0 \<noteq> 0" |
2808 |
and b0: "b$0 \<noteq> 0" |
|
2809 |
shows "fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" |
|
2810 |
proof- |
|
2811 |
from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" |
|
2812 |
by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) |
|
54452 | 2813 |
{assume "k=0" then have ?thesis by simp} |
29687 | 2814 |
moreover |
2815 |
{fix h assume k: "k = Suc h" |
|
2816 |
let ?ra = "fps_radical r (Suc h) a" |
|
2817 |
let ?rb = "fps_radical r (Suc h) b" |
|
30488 | 2818 |
have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" |
29687 | 2819 |
using r0' k by (simp add: fps_mult_nth) |
2820 |
have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) |
|
30488 | 2821 |
from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded k] th0 ab0, symmetric] |
29687 | 2822 |
power_radical[of r, OF ra0[unfolded k] a0] power_radical[of r, OF rb0[unfolded k] b0] k |
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
2823 |
have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} |
29687 | 2824 |
ultimately show ?thesis by (cases k, auto) |
2825 |
qed |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2826 |
*) |
29687 | 2827 |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2828 |
lemma fps_divide_1 [simp]: "(a :: 'a::field fps) / 1 = a" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2829 |
by (fact divide_1) |
29687 | 2830 |
|
2831 |
lemma radical_divide: |
|
31273 | 2832 |
fixes a :: "'a::field_char_0 fps" |
52903 | 2833 |
assumes kp: "k > 0" |
2834 |
and ra0: "(r k (a $ 0)) ^ k = a $ 0" |
|
2835 |
and rb0: "(r k (b $ 0)) ^ k = b $ 0" |
|
2836 |
and a0: "a$0 \<noteq> 0" |
|
2837 |
and b0: "b$0 \<noteq> 0" |
|
2838 |
shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow> |
|
2839 |
fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b" |
|
2840 |
(is "?lhs = ?rhs") |
|
60501 | 2841 |
proof |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2842 |
let ?r = "fps_radical r k" |
60558 | 2843 |
from kp obtain h where k: "k = Suc h" |
2844 |
by (cases k) auto |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2845 |
have ra0': "r k (a$0) \<noteq> 0" using a0 ra0 k by auto |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2846 |
have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto |
30488 | 2847 |
|
60501 | 2848 |
show ?lhs if ?rhs |
2849 |
proof - |
|
2850 |
from that have "?r (a/b) $ 0 = (?r a / ?r b)$0" |
|
2851 |
by simp |
|
2852 |
then show ?thesis |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2853 |
using k a0 b0 rb0' by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def divide_inverse) |
60501 | 2854 |
qed |
2855 |
show ?rhs if ?lhs |
|
2856 |
proof - |
|
52891 | 2857 |
from a0 b0 have ab0[simp]: "(a/b)$0 = a$0 / b$0" |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2858 |
by (simp add: fps_divide_def fps_mult_nth divide_inverse fps_inverse_def) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2859 |
have th0: "r k ((a/b)$0) ^ k = (a/b)$0" |
60867 | 2860 |
by (simp add: \<open>?lhs\<close> power_divide ra0 rb0) |
60501 | 2861 |
from a0 b0 ra0' rb0' kp \<open>?lhs\<close> |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2862 |
have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2863 |
by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def divide_inverse) |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2864 |
from a0 b0 ra0' rb0' kp have ab0': "(a / b) $ 0 \<noteq> 0" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2865 |
by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def nonzero_imp_inverse_nonzero) |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2866 |
note tha[simp] = iffD1[OF power_radical[where r=r and k=h], OF a0 ra0[unfolded k], unfolded k[symmetric]] |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2867 |
note thb[simp] = iffD1[OF power_radical[where r=r and k=h], OF b0 rb0[unfolded k], unfolded k[symmetric]] |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2868 |
from b0 rb0' have th2: "(?r a / ?r b)^k = a/b" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2869 |
by (simp add: fps_divide_unit power_mult_distrib fps_inverse_power[symmetric]) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
2870 |
|
52902 | 2871 |
from iffD1[OF radical_unique[where r=r and a="?r a / ?r b" and b="a/b" and k=h], symmetric, unfolded k[symmetric], OF th0 th1 ab0' th2] |
60501 | 2872 |
show ?thesis . |
2873 |
qed |
|
29687 | 2874 |
qed |
2875 |
||
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2876 |
lemma radical_inverse: |
31273 | 2877 |
fixes a :: "'a::field_char_0 fps" |
52903 | 2878 |
assumes k: "k > 0" |
2879 |
and ra0: "r k (a $ 0) ^ k = a $ 0" |
|
2880 |
and r1: "(r k 1)^k = 1" |
|
2881 |
and a0: "a$0 \<noteq> 0" |
|
53196 | 2882 |
shows "r k (inverse (a $ 0)) = r k 1 / (r k (a $ 0)) \<longleftrightarrow> |
2883 |
fps_radical r k (inverse a) = fps_radical r k 1 / fps_radical r k a" |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2884 |
using radical_divide[where k=k and r=r and a=1 and b=a, OF k ] ra0 r1 a0 |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2885 |
by (simp add: divide_inverse fps_divide_def) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
2886 |
|
60501 | 2887 |
|
2888 |
subsection \<open>Derivative of composition\<close> |
|
29687 | 2889 |
|
30488 | 2890 |
lemma fps_compose_deriv: |
54681 | 2891 |
fixes a :: "'a::idom fps" |
29687 | 2892 |
assumes b0: "b$0 = 0" |
54681 | 2893 |
shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * fps_deriv b" |
52903 | 2894 |
proof - |
60501 | 2895 |
have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" for n |
2896 |
proof - |
|
29687 | 2897 |
have "(fps_deriv (a oo b))$n = setsum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}" |
36350 | 2898 |
by (simp add: fps_compose_def field_simps setsum_right_distrib del: of_nat_Suc) |
29687 | 2899 |
also have "\<dots> = setsum (\<lambda>i. a$i * ((fps_const (of_nat i)) * (fps_deriv b * (b^(i - 1))))$n) {0.. Suc n}" |
36350 | 2900 |
by (simp add: field_simps fps_deriv_power del: fps_mult_left_const_nth of_nat_Suc) |
52903 | 2901 |
also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (((b^(i - 1)) * fps_deriv b))$n) {0.. Suc n}" |
2902 |
unfolding fps_mult_left_const_nth by (simp add: field_simps) |
|
2903 |
also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (setsum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {0.. Suc n}" |
|
2904 |
unfolding fps_mult_nth .. |
|
2905 |
also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (setsum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {1.. Suc n}" |
|
57418 | 2906 |
apply (rule setsum.mono_neutral_right) |
2907 |
apply (auto simp add: mult_delta_left setsum.delta not_le) |
|
52903 | 2908 |
done |
2909 |
also have "\<dots> = setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" |
|
2910 |
unfolding fps_deriv_nth |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
2911 |
by (rule setsum.reindex_cong [of Suc]) (auto simp add: mult.assoc) |
52903 | 2912 |
finally have th0: "(fps_deriv (a oo b))$n = |
2913 |
setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" . |
|
2914 |
||
2915 |
have "(((fps_deriv a) oo b) * (fps_deriv b))$n = setsum (\<lambda>i. (fps_deriv b)$ (n - i) * ((fps_deriv a) oo b)$i) {0..n}" |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
2916 |
unfolding fps_mult_nth by (simp add: ac_simps) |
52903 | 2917 |
also have "\<dots> = setsum (\<lambda>i. setsum (\<lambda>j. of_nat (n - i +1) * b$(n - i + 1) * of_nat (j + 1) * a$(j+1) * (b^j)$i) {0..n}) {0..n}" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
2918 |
unfolding fps_deriv_nth fps_compose_nth setsum_right_distrib mult.assoc |
57418 | 2919 |
apply (rule setsum.cong) |
2920 |
apply (rule refl) |
|
2921 |
apply (rule setsum.mono_neutral_left) |
|
52903 | 2922 |
apply (simp_all add: subset_eq) |
2923 |
apply clarify |
|
2924 |
apply (subgoal_tac "b^i$x = 0") |
|
2925 |
apply simp |
|
2926 |
apply (rule startsby_zero_power_prefix[OF b0, rule_format]) |
|
2927 |
apply simp |
|
2928 |
done |
|
2929 |
also have "\<dots> = setsum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (setsum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" |
|
2930 |
unfolding setsum_right_distrib |
|
57418 | 2931 |
apply (subst setsum.commute) |
2932 |
apply (rule setsum.cong, rule refl)+ |
|
52903 | 2933 |
apply simp |
2934 |
done |
|
60501 | 2935 |
finally show ?thesis |
52903 | 2936 |
unfolding th0 by simp |
60501 | 2937 |
qed |
52903 | 2938 |
then show ?thesis by (simp add: fps_eq_iff) |
29687 | 2939 |
qed |
2940 |
||
2941 |
lemma fps_mult_X_plus_1_nth: |
|
2942 |
"((1+X)*a) $n = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" |
|
52903 | 2943 |
proof (cases n) |
2944 |
case 0 |
|
54681 | 2945 |
then show ?thesis |
60501 | 2946 |
by (simp add: fps_mult_nth) |
52903 | 2947 |
next |
2948 |
case (Suc m) |
|
60501 | 2949 |
have "((1 + X)*a) $ n = setsum (\<lambda>i. (1 + X) $ i * a $ (n - i)) {0..n}" |
52903 | 2950 |
by (simp add: fps_mult_nth) |
2951 |
also have "\<dots> = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0.. 1}" |
|
57418 | 2952 |
unfolding Suc by (rule setsum.mono_neutral_right) auto |
52903 | 2953 |
also have "\<dots> = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" |
2954 |
by (simp add: Suc) |
|
2955 |
finally show ?thesis . |
|
29687 | 2956 |
qed |
2957 |
||
54681 | 2958 |
|
60500 | 2959 |
subsection \<open>Finite FPS (i.e. polynomials) and X\<close> |
52903 | 2960 |
|
29687 | 2961 |
lemma fps_poly_sum_X: |
60501 | 2962 |
assumes "\<forall>i > n. a$i = (0::'a::comm_ring_1)" |
29687 | 2963 |
shows "a = setsum (\<lambda>i. fps_const (a$i) * X^i) {0..n}" (is "a = ?r") |
52903 | 2964 |
proof - |
60501 | 2965 |
have "a$i = ?r$i" for i |
2966 |
unfolding fps_setsum_nth fps_mult_left_const_nth X_power_nth |
|
2967 |
by (simp add: mult_delta_right setsum.delta' assms) |
|
2968 |
then show ?thesis |
|
2969 |
unfolding fps_eq_iff by blast |
|
29687 | 2970 |
qed |
2971 |
||
52903 | 2972 |
|
60501 | 2973 |
subsection \<open>Compositional inverses\<close> |
29687 | 2974 |
|
54681 | 2975 |
fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::field" |
52903 | 2976 |
where |
29687 | 2977 |
"compinv a 0 = X$0" |
52903 | 2978 |
| "compinv a (Suc n) = |
2979 |
(X$ Suc n - setsum (\<lambda>i. (compinv a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n" |
|
29687 | 2980 |
|
2981 |
definition "fps_inv a = Abs_fps (compinv a)" |
|
2982 |
||
52903 | 2983 |
lemma fps_inv: |
2984 |
assumes a0: "a$0 = 0" |
|
2985 |
and a1: "a$1 \<noteq> 0" |
|
29687 | 2986 |
shows "fps_inv a oo a = X" |
52903 | 2987 |
proof - |
29687 | 2988 |
let ?i = "fps_inv a oo a" |
60501 | 2989 |
have "?i $n = X$n" for n |
2990 |
proof (induct n rule: nat_less_induct) |
|
52903 | 2991 |
fix n |
60501 | 2992 |
assume h: "\<forall>m<n. ?i$m = X$m" |
2993 |
show "?i $ n = X$n" |
|
2994 |
proof (cases n) |
|
2995 |
case 0 |
|
2996 |
then show ?thesis using a0 |
|
2997 |
by (simp add: fps_compose_nth fps_inv_def) |
|
2998 |
next |
|
2999 |
case (Suc n1) |
|
3000 |
have "?i $ n = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1" |
|
3001 |
by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc) |
|
3002 |
also have "\<dots> = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + |
|
3003 |
(X$ Suc n1 - setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})" |
|
3004 |
using a0 a1 Suc by (simp add: fps_inv_def) |
|
3005 |
also have "\<dots> = X$n" using Suc by simp |
|
3006 |
finally show ?thesis . |
|
52903 | 3007 |
qed |
60501 | 3008 |
qed |
3009 |
then show ?thesis |
|
3010 |
by (simp add: fps_eq_iff) |
|
29687 | 3011 |
qed |
3012 |
||
3013 |
||
54681 | 3014 |
fun gcompinv :: "'a fps \<Rightarrow> 'a fps \<Rightarrow> nat \<Rightarrow> 'a::field" |
52903 | 3015 |
where |
29687 | 3016 |
"gcompinv b a 0 = b$0" |
52903 | 3017 |
| "gcompinv b a (Suc n) = |
3018 |
(b$ Suc n - setsum (\<lambda>i. (gcompinv b a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n" |
|
29687 | 3019 |
|
3020 |
definition "fps_ginv b a = Abs_fps (gcompinv b a)" |
|
3021 |
||
52903 | 3022 |
lemma fps_ginv: |
3023 |
assumes a0: "a$0 = 0" |
|
3024 |
and a1: "a$1 \<noteq> 0" |
|
29687 | 3025 |
shows "fps_ginv b a oo a = b" |
52903 | 3026 |
proof - |
29687 | 3027 |
let ?i = "fps_ginv b a oo a" |
60501 | 3028 |
have "?i $n = b$n" for n |
3029 |
proof (induct n rule: nat_less_induct) |
|
52903 | 3030 |
fix n |
60501 | 3031 |
assume h: "\<forall>m<n. ?i$m = b$m" |
3032 |
show "?i $ n = b$n" |
|
3033 |
proof (cases n) |
|
3034 |
case 0 |
|
3035 |
then show ?thesis using a0 |
|
3036 |
by (simp add: fps_compose_nth fps_ginv_def) |
|
3037 |
next |
|
3038 |
case (Suc n1) |
|
3039 |
have "?i $ n = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1" |
|
3040 |
by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc) |
|
3041 |
also have "\<dots> = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + |
|
3042 |
(b$ Suc n1 - setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})" |
|
3043 |
using a0 a1 Suc by (simp add: fps_ginv_def) |
|
3044 |
also have "\<dots> = b$n" using Suc by simp |
|
3045 |
finally show ?thesis . |
|
52903 | 3046 |
qed |
60501 | 3047 |
qed |
3048 |
then show ?thesis |
|
3049 |
by (simp add: fps_eq_iff) |
|
29687 | 3050 |
qed |
3051 |
||
3052 |
lemma fps_inv_ginv: "fps_inv = fps_ginv X" |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
3053 |
apply (auto simp add: fun_eq_iff fps_eq_iff fps_inv_def fps_ginv_def) |
48757 | 3054 |
apply (induct_tac n rule: nat_less_induct) |
3055 |
apply auto |
|
29687 | 3056 |
apply (case_tac na) |
3057 |
apply simp |
|
3058 |
apply simp |
|
3059 |
done |
|
3060 |
||
3061 |
lemma fps_compose_1[simp]: "1 oo a = 1" |
|
57418 | 3062 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum.delta) |
29687 | 3063 |
|
3064 |
lemma fps_compose_0[simp]: "0 oo a = 0" |
|
29913 | 3065 |
by (simp add: fps_eq_iff fps_compose_nth) |
29687 | 3066 |
|
60867 | 3067 |
lemma fps_compose_0_right[simp]: "a oo 0 = fps_const (a $ 0)" |
57418 | 3068 |
by (auto simp add: fps_eq_iff fps_compose_nth power_0_left setsum.neutral) |
29687 | 3069 |
|
3070 |
lemma fps_compose_add_distrib: "(a + b) oo c = (a oo c) + (b oo c)" |
|
57418 | 3071 |
by (simp add: fps_eq_iff fps_compose_nth field_simps setsum.distrib) |
29687 | 3072 |
|
3073 |
lemma fps_compose_setsum_distrib: "(setsum f S) oo a = setsum (\<lambda>i. f i oo a) S" |
|
52903 | 3074 |
proof (cases "finite S") |
3075 |
case True |
|
3076 |
show ?thesis |
|
3077 |
proof (rule finite_induct[OF True]) |
|
60501 | 3078 |
show "setsum f {} oo a = (\<Sum>i\<in>{}. f i oo a)" |
3079 |
by simp |
|
52903 | 3080 |
next |
3081 |
fix x F |
|
3082 |
assume fF: "finite F" |
|
3083 |
and xF: "x \<notin> F" |
|
3084 |
and h: "setsum f F oo a = setsum (\<lambda>i. f i oo a) F" |
|
3085 |
show "setsum f (insert x F) oo a = setsum (\<lambda>i. f i oo a) (insert x F)" |
|
3086 |
using fF xF h by (simp add: fps_compose_add_distrib) |
|
3087 |
qed |
|
3088 |
next |
|
3089 |
case False |
|
3090 |
then show ?thesis by simp |
|
29687 | 3091 |
qed |
3092 |
||
30488 | 3093 |
lemma convolution_eq: |
54452 | 3094 |
"setsum (\<lambda>i. a (i :: nat) * b (n - i)) {0 .. n} = |
3095 |
setsum (\<lambda>(i,j). a i * b j) {(i,j). i \<le> n \<and> j \<le> n \<and> i + j = n}" |
|
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3096 |
by (rule setsum.reindex_bij_witness[where i=fst and j="\<lambda>i. (i, n - i)"]) auto |
29687 | 3097 |
|
3098 |
lemma product_composition_lemma: |
|
52903 | 3099 |
assumes c0: "c$0 = (0::'a::idom)" |
3100 |
and d0: "d$0 = 0" |
|
3101 |
shows "((a oo c) * (b oo d))$n = |
|
54452 | 3102 |
setsum (\<lambda>(k,m). a$k * b$m * (c^k * d^m) $ n) {(k,m). k + m \<le> n}" (is "?l = ?r") |
52903 | 3103 |
proof - |
54681 | 3104 |
let ?S = "{(k::nat, m::nat). k + m \<le> n}" |
30488 | 3105 |
have s: "?S \<subseteq> {0..n} <*> {0..n}" by (auto simp add: subset_eq) |
54681 | 3106 |
have f: "finite {(k::nat, m::nat). k + m \<le> n}" |
29687 | 3107 |
apply (rule finite_subset[OF s]) |
52903 | 3108 |
apply auto |
3109 |
done |
|
54452 | 3110 |
have "?r = setsum (\<lambda>i. setsum (\<lambda>(k,m). a$k * (c^k)$i * b$m * (d^m) $ (n - i)) {(k,m). k + m \<le> n}) {0..n}" |
29687 | 3111 |
apply (simp add: fps_mult_nth setsum_right_distrib) |
57418 | 3112 |
apply (subst setsum.commute) |
3113 |
apply (rule setsum.cong) |
|
52903 | 3114 |
apply (auto simp add: field_simps) |
3115 |
done |
|
30488 | 3116 |
also have "\<dots> = ?l" |
29687 | 3117 |
apply (simp add: fps_mult_nth fps_compose_nth setsum_product) |
57418 | 3118 |
apply (rule setsum.cong) |
3119 |
apply (rule refl) |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3120 |
apply (simp add: setsum.cartesian_product mult.assoc) |
57418 | 3121 |
apply (rule setsum.mono_neutral_right[OF f]) |
54452 | 3122 |
apply (simp add: subset_eq) |
3123 |
apply presburger |
|
29687 | 3124 |
apply clarsimp |
3125 |
apply (rule ccontr) |
|
3126 |
apply (clarsimp simp add: not_le) |
|
3127 |
apply (case_tac "x < aa") |
|
3128 |
apply simp |
|
3129 |
apply (frule_tac startsby_zero_power_prefix[rule_format, OF c0]) |
|
3130 |
apply blast |
|
3131 |
apply simp |
|
3132 |
apply (frule_tac startsby_zero_power_prefix[rule_format, OF d0]) |
|
3133 |
apply blast |
|
3134 |
done |
|
3135 |
finally show ?thesis by simp |
|
3136 |
qed |
|
3137 |
||
3138 |
lemma product_composition_lemma': |
|
52903 | 3139 |
assumes c0: "c$0 = (0::'a::idom)" |
3140 |
and d0: "d$0 = 0" |
|
3141 |
shows "((a oo c) * (b oo d))$n = |
|
54452 | 3142 |
setsum (\<lambda>k. setsum (\<lambda>m. a$k * b$m * (c^k * d^m) $ n) {0..n}) {0..n}" (is "?l = ?r") |
29687 | 3143 |
unfolding product_composition_lemma[OF c0 d0] |
57418 | 3144 |
unfolding setsum.cartesian_product |
3145 |
apply (rule setsum.mono_neutral_left) |
|
29687 | 3146 |
apply simp |
3147 |
apply (clarsimp simp add: subset_eq) |
|
3148 |
apply clarsimp |
|
3149 |
apply (rule ccontr) |
|
3150 |
apply (subgoal_tac "(c^aa * d^ba) $ n = 0") |
|
3151 |
apply simp |
|
3152 |
unfolding fps_mult_nth |
|
57418 | 3153 |
apply (rule setsum.neutral) |
29687 | 3154 |
apply (clarsimp simp add: not_le) |
51489 | 3155 |
apply (case_tac "x < aa") |
29687 | 3156 |
apply (rule startsby_zero_power_prefix[OF c0, rule_format]) |
3157 |
apply simp |
|
51489 | 3158 |
apply (subgoal_tac "n - x < ba") |
29687 | 3159 |
apply (frule_tac k = "ba" in startsby_zero_power_prefix[OF d0, rule_format]) |
3160 |
apply simp |
|
3161 |
apply arith |
|
3162 |
done |
|
30488 | 3163 |
|
29687 | 3164 |
|
30488 | 3165 |
lemma setsum_pair_less_iff: |
54452 | 3166 |
"setsum (\<lambda>((k::nat),m). a k * b m * c (k + m)) {(k,m). k + m \<le> n} = |
3167 |
setsum (\<lambda>s. setsum (\<lambda>i. a i * b (s - i) * c s) {0..s}) {0..n}" |
|
52903 | 3168 |
(is "?l = ?r") |
3169 |
proof - |
|
3170 |
let ?KM = "{(k,m). k + m \<le> n}" |
|
54452 | 3171 |
let ?f = "\<lambda>s. UNION {(0::nat)..s} (\<lambda>i. {(i,s - i)})" |
29687 | 3172 |
have th0: "?KM = UNION {0..n} ?f" |
59862 | 3173 |
by (auto simp add: set_eq_iff Bex_def) |
29687 | 3174 |
show "?l = ?r " |
3175 |
unfolding th0 |
|
57418 | 3176 |
apply (subst setsum.UNION_disjoint) |
29687 | 3177 |
apply auto |
57418 | 3178 |
apply (subst setsum.UNION_disjoint) |
29687 | 3179 |
apply auto |
3180 |
done |
|
3181 |
qed |
|
3182 |
||
3183 |
lemma fps_compose_mult_distrib_lemma: |
|
3184 |
assumes c0: "c$0 = (0::'a::idom)" |
|
60501 | 3185 |
shows "((a oo c) * (b oo c))$n = setsum (\<lambda>s. setsum (\<lambda>i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}" |
29687 | 3186 |
unfolding product_composition_lemma[OF c0 c0] power_add[symmetric] |
54452 | 3187 |
unfolding setsum_pair_less_iff[where a = "\<lambda>k. a$k" and b="\<lambda>m. b$m" and c="\<lambda>s. (c ^ s)$n" and n = n] .. |
29687 | 3188 |
|
30488 | 3189 |
lemma fps_compose_mult_distrib: |
54489
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54452
diff
changeset
|
3190 |
assumes c0: "c $ 0 = (0::'a::idom)" |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54452
diff
changeset
|
3191 |
shows "(a * b) oo c = (a oo c) * (b oo c)" |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54452
diff
changeset
|
3192 |
apply (simp add: fps_eq_iff fps_compose_mult_distrib_lemma [OF c0]) |
52903 | 3193 |
apply (simp add: fps_compose_nth fps_mult_nth setsum_left_distrib) |
3194 |
done |
|
3195 |
||
30488 | 3196 |
lemma fps_compose_setprod_distrib: |
29687 | 3197 |
assumes c0: "c$0 = (0::'a::idom)" |
54452 | 3198 |
shows "setprod a S oo c = setprod (\<lambda>k. a k oo c) S" |
29687 | 3199 |
apply (cases "finite S") |
3200 |
apply simp_all |
|
3201 |
apply (induct S rule: finite_induct) |
|
3202 |
apply simp |
|
3203 |
apply (simp add: fps_compose_mult_distrib[OF c0]) |
|
3204 |
done |
|
3205 |
||
53195 | 3206 |
lemma fps_compose_power: |
3207 |
assumes c0: "c$0 = (0::'a::idom)" |
|
3208 |
shows "(a oo c)^n = a^n oo c" |
|
52903 | 3209 |
proof (cases n) |
3210 |
case 0 |
|
3211 |
then show ?thesis by simp |
|
3212 |
next |
|
3213 |
case (Suc m) |
|
54452 | 3214 |
have th0: "a^n = setprod (\<lambda>k. a) {0..m}" "(a oo c) ^ n = setprod (\<lambda>k. a oo c) {0..m}" |
52903 | 3215 |
by (simp_all add: setprod_constant Suc) |
3216 |
then show ?thesis |
|
3217 |
by (simp add: fps_compose_setprod_distrib[OF c0]) |
|
29687 | 3218 |
qed |
3219 |
||
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3220 |
lemma fps_compose_uminus: "- (a::'a::ring_1 fps) oo c = - (a oo c)" |
36350 | 3221 |
by (simp add: fps_eq_iff fps_compose_nth field_simps setsum_negf[symmetric]) |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3222 |
|
52903 | 3223 |
lemma fps_compose_sub_distrib: "(a - b) oo (c::'a::ring_1 fps) = (a oo c) - (b oo c)" |
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
53374
diff
changeset
|
3224 |
using fps_compose_add_distrib [of a "- b" c] by (simp add: fps_compose_uminus) |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3225 |
|
52903 | 3226 |
lemma X_fps_compose: "X oo a = Abs_fps (\<lambda>n. if n = 0 then (0::'a::comm_ring_1) else a$n)" |
57418 | 3227 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum.delta) |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3228 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3229 |
lemma fps_inverse_compose: |
52903 | 3230 |
assumes b0: "(b$0 :: 'a::field) = 0" |
3231 |
and a0: "a$0 \<noteq> 0" |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3232 |
shows "inverse a oo b = inverse (a oo b)" |
52903 | 3233 |
proof - |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3234 |
let ?ia = "inverse a" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3235 |
let ?ab = "a oo b" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3236 |
let ?iab = "inverse ?ab" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3237 |
|
52903 | 3238 |
from a0 have ia0: "?ia $ 0 \<noteq> 0" by simp |
3239 |
from a0 have ab0: "?ab $ 0 \<noteq> 0" by (simp add: fps_compose_def) |
|
3240 |
have "(?ia oo b) * (a oo b) = 1" |
|
3241 |
unfolding fps_compose_mult_distrib[OF b0, symmetric] |
|
3242 |
unfolding inverse_mult_eq_1[OF a0] |
|
3243 |
fps_compose_1 .. |
|
54452 | 3244 |
|
52903 | 3245 |
then have "(?ia oo b) * (a oo b) * ?iab = 1 * ?iab" by simp |
3246 |
then have "(?ia oo b) * (?iab * (a oo b)) = ?iab" by simp |
|
3247 |
then show ?thesis unfolding inverse_mult_eq_1[OF ab0] by simp |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3248 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3249 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3250 |
lemma fps_divide_compose: |
52903 | 3251 |
assumes c0: "(c$0 :: 'a::field) = 0" |
3252 |
and b0: "b$0 \<noteq> 0" |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3253 |
shows "(a/b) oo c = (a oo c) / (b oo c)" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3254 |
using b0 c0 by (simp add: fps_divide_unit fps_inverse_compose fps_compose_mult_distrib) |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3255 |
|
52903 | 3256 |
lemma gp: |
3257 |
assumes a0: "a$0 = (0::'a::field)" |
|
3258 |
shows "(Abs_fps (\<lambda>n. 1)) oo a = 1/(1 - a)" |
|
3259 |
(is "?one oo a = _") |
|
3260 |
proof - |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3261 |
have o0: "?one $ 0 \<noteq> 0" by simp |
52891 | 3262 |
have th0: "(1 - X) $ 0 \<noteq> (0::'a)" by simp |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3263 |
from fps_inverse_gp[where ?'a = 'a] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3264 |
have "inverse ?one = 1 - X" by (simp add: fps_eq_iff) |
54452 | 3265 |
then have "inverse (inverse ?one) = inverse (1 - X)" by simp |
3266 |
then have th: "?one = 1/(1 - X)" unfolding fps_inverse_idempotent[OF o0] |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3267 |
by (simp add: fps_divide_def) |
52903 | 3268 |
show ?thesis |
3269 |
unfolding th |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3270 |
unfolding fps_divide_compose[OF a0 th0] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3271 |
fps_compose_1 fps_compose_sub_distrib X_fps_compose_startby0[OF a0] .. |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3272 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3273 |
|
52903 | 3274 |
lemma fps_const_power [simp]: "fps_const (c::'a::ring_1) ^ n = fps_const (c^n)" |
48757 | 3275 |
by (induct n) auto |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3276 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3277 |
lemma fps_compose_radical: |
31273 | 3278 |
assumes b0: "b$0 = (0::'a::field_char_0)" |
52903 | 3279 |
and ra0: "r (Suc k) (a$0) ^ Suc k = a$0" |
3280 |
and a0: "a$0 \<noteq> 0" |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3281 |
shows "fps_radical r (Suc k) a oo b = fps_radical r (Suc k) (a oo b)" |
52903 | 3282 |
proof - |
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3283 |
let ?r = "fps_radical r (Suc k)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3284 |
let ?ab = "a oo b" |
52903 | 3285 |
have ab0: "?ab $ 0 = a$0" |
3286 |
by (simp add: fps_compose_def) |
|
3287 |
from ab0 a0 ra0 have rab0: "?ab $ 0 \<noteq> 0" "r (Suc k) (?ab $ 0) ^ Suc k = ?ab $ 0" |
|
3288 |
by simp_all |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3289 |
have th00: "r (Suc k) ((a oo b) $ 0) = (fps_radical r (Suc k) a oo b) $ 0" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3290 |
by (simp add: ab0 fps_compose_def) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3291 |
have th0: "(?r a oo b) ^ (Suc k) = a oo b" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3292 |
unfolding fps_compose_power[OF b0] |
52891 | 3293 |
unfolding iffD1[OF power_radical[of a r k], OF a0 ra0] .. |
52903 | 3294 |
from iffD1[OF radical_unique[where r=r and k=k and b= ?ab and a = "?r a oo b", OF rab0(2) th00 rab0(1)], OF th0] |
3295 |
show ?thesis . |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3296 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
3297 |
|
52903 | 3298 |
lemma fps_const_mult_apply_left: "fps_const c * (a oo b) = (fps_const c * a) oo b" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3299 |
by (simp add: fps_eq_iff fps_compose_nth setsum_right_distrib mult.assoc) |
29687 | 3300 |
|
3301 |
lemma fps_const_mult_apply_right: |
|
3302 |
"(a oo b) * fps_const (c::'a::comm_semiring_1) = (fps_const c * a) oo b" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3303 |
by (auto simp add: fps_const_mult_apply_left mult.commute) |
29687 | 3304 |
|
30488 | 3305 |
lemma fps_compose_assoc: |
52903 | 3306 |
assumes c0: "c$0 = (0::'a::idom)" |
3307 |
and b0: "b$0 = 0" |
|
29687 | 3308 |
shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r") |
52903 | 3309 |
proof - |
60501 | 3310 |
have "?l$n = ?r$n" for n |
3311 |
proof - |
|
29687 | 3312 |
have "?l$n = (setsum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n" |
52903 | 3313 |
by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3314 |
setsum_right_distrib mult.assoc fps_setsum_nth) |
29687 | 3315 |
also have "\<dots> = ((setsum (\<lambda>i. fps_const (a$i) * b^i) {0..n}) oo c)$n" |
3316 |
by (simp add: fps_compose_setsum_distrib) |
|
3317 |
also have "\<dots> = ?r$n" |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3318 |
apply (simp add: fps_compose_nth fps_setsum_nth setsum_left_distrib mult.assoc) |
57418 | 3319 |
apply (rule setsum.cong) |
3320 |
apply (rule refl) |
|
3321 |
apply (rule setsum.mono_neutral_right) |
|
29687 | 3322 |
apply (auto simp add: not_le) |
52903 | 3323 |
apply (erule startsby_zero_power_prefix[OF b0, rule_format]) |
3324 |
done |
|
60501 | 3325 |
finally show ?thesis . |
3326 |
qed |
|
3327 |
then show ?thesis |
|
3328 |
by (simp add: fps_eq_iff) |
|
29687 | 3329 |
qed |
3330 |
||
3331 |
||
3332 |
lemma fps_X_power_compose: |
|
52903 | 3333 |
assumes a0: "a$0=0" |
54681 | 3334 |
shows "X^k oo a = (a::'a::idom fps)^k" |
3335 |
(is "?l = ?r") |
|
52903 | 3336 |
proof (cases k) |
3337 |
case 0 |
|
3338 |
then show ?thesis by simp |
|
3339 |
next |
|
53196 | 3340 |
case (Suc h) |
60501 | 3341 |
have "?l $ n = ?r $n" for n |
3342 |
proof - |
|
3343 |
consider "k > n" | "k \<le> n" by arith |
|
3344 |
then show ?thesis |
|
3345 |
proof cases |
|
3346 |
case 1 |
|
3347 |
then show ?thesis |
|
3348 |
using a0 startsby_zero_power_prefix[OF a0] Suc |
|
52903 | 3349 |
by (simp add: fps_compose_nth del: power_Suc) |
60501 | 3350 |
next |
3351 |
case 2 |
|
3352 |
then show ?thesis |
|
57418 | 3353 |
by (simp add: fps_compose_nth mult_delta_left setsum.delta) |
60501 | 3354 |
qed |
3355 |
qed |
|
3356 |
then show ?thesis |
|
3357 |
unfolding fps_eq_iff by blast |
|
29687 | 3358 |
qed |
3359 |
||
52903 | 3360 |
lemma fps_inv_right: |
3361 |
assumes a0: "a$0 = 0" |
|
3362 |
and a1: "a$1 \<noteq> 0" |
|
29687 | 3363 |
shows "a oo fps_inv a = X" |
52903 | 3364 |
proof - |
29687 | 3365 |
let ?ia = "fps_inv a" |
3366 |
let ?iaa = "a oo fps_inv a" |
|
60501 | 3367 |
have th0: "?ia $ 0 = 0" |
3368 |
by (simp add: fps_inv_def) |
|
3369 |
have th1: "?iaa $ 0 = 0" |
|
3370 |
using a0 a1 by (simp add: fps_inv_def fps_compose_nth) |
|
3371 |
have th2: "X$0 = 0" |
|
3372 |
by simp |
|
3373 |
from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X" |
|
3374 |
by simp |
|
29687 | 3375 |
then have "(a oo fps_inv a) oo a = X oo a" |
3376 |
by (simp add: fps_compose_assoc[OF a0 th0] X_fps_compose_startby0[OF a0]) |
|
60501 | 3377 |
with fps_compose_inj_right[OF a0 a1] show ?thesis |
3378 |
by simp |
|
29687 | 3379 |
qed |
3380 |
||
3381 |
lemma fps_inv_deriv: |
|
60501 | 3382 |
assumes a0: "a$0 = (0::'a::field)" |
52903 | 3383 |
and a1: "a$1 \<noteq> 0" |
29687 | 3384 |
shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)" |
52903 | 3385 |
proof - |
29687 | 3386 |
let ?ia = "fps_inv a" |
3387 |
let ?d = "fps_deriv a oo ?ia" |
|
3388 |
let ?dia = "fps_deriv ?ia" |
|
60501 | 3389 |
have ia0: "?ia$0 = 0" |
3390 |
by (simp add: fps_inv_def) |
|
3391 |
have th0: "?d$0 \<noteq> 0" |
|
3392 |
using a1 by (simp add: fps_compose_nth) |
|
29687 | 3393 |
from fps_inv_right[OF a0 a1] have "?d * ?dia = 1" |
3394 |
by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] ) |
|
60501 | 3395 |
then have "inverse ?d * ?d * ?dia = inverse ?d * 1" |
3396 |
by simp |
|
3397 |
with inverse_mult_eq_1 [OF th0] show "?dia = inverse ?d" |
|
3398 |
by simp |
|
29687 | 3399 |
qed |
3400 |
||
52891 | 3401 |
lemma fps_inv_idempotent: |
52903 | 3402 |
assumes a0: "a$0 = 0" |
3403 |
and a1: "a$1 \<noteq> 0" |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3404 |
shows "fps_inv (fps_inv a) = a" |
52903 | 3405 |
proof - |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3406 |
let ?r = "fps_inv" |
60501 | 3407 |
have ra0: "?r a $ 0 = 0" |
3408 |
by (simp add: fps_inv_def) |
|
3409 |
from a1 have ra1: "?r a $ 1 \<noteq> 0" |
|
3410 |
by (simp add: fps_inv_def field_simps) |
|
3411 |
have X0: "X$0 = 0" |
|
3412 |
by simp |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3413 |
from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = X" . |
60501 | 3414 |
then have "?r (?r a) oo ?r a oo a = X oo a" |
3415 |
by simp |
|
52891 | 3416 |
then have "?r (?r a) oo (?r a oo a) = a" |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3417 |
unfolding X_fps_compose_startby0[OF a0] |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3418 |
unfolding fps_compose_assoc[OF a0 ra0, symmetric] . |
60501 | 3419 |
then show ?thesis |
3420 |
unfolding fps_inv[OF a0 a1] by simp |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3421 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3422 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3423 |
lemma fps_ginv_ginv: |
52903 | 3424 |
assumes a0: "a$0 = 0" |
3425 |
and a1: "a$1 \<noteq> 0" |
|
3426 |
and c0: "c$0 = 0" |
|
3427 |
and c1: "c$1 \<noteq> 0" |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3428 |
shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c" |
52903 | 3429 |
proof - |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3430 |
let ?r = "fps_ginv" |
60501 | 3431 |
from c0 have rca0: "?r c a $0 = 0" |
3432 |
by (simp add: fps_ginv_def) |
|
3433 |
from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0" |
|
3434 |
by (simp add: fps_ginv_def field_simps) |
|
52891 | 3435 |
from fps_ginv[OF rca0 rca1] |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3436 |
have "?r b (?r c a) oo ?r c a = b" . |
60501 | 3437 |
then have "?r b (?r c a) oo ?r c a oo a = b oo a" |
3438 |
by simp |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3439 |
then have "?r b (?r c a) oo (?r c a oo a) = b oo a" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3440 |
apply (subst fps_compose_assoc) |
53195 | 3441 |
using a0 c0 |
3442 |
apply (auto simp add: fps_ginv_def) |
|
52903 | 3443 |
done |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3444 |
then have "?r b (?r c a) oo c = b oo a" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3445 |
unfolding fps_ginv[OF a0 a1] . |
60501 | 3446 |
then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c" |
3447 |
by simp |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3448 |
then have "?r b (?r c a) oo (c oo fps_inv c) = b oo a oo fps_inv c" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3449 |
apply (subst fps_compose_assoc) |
53195 | 3450 |
using a0 c0 |
3451 |
apply (auto simp add: fps_inv_def) |
|
52903 | 3452 |
done |
60501 | 3453 |
then show ?thesis |
3454 |
unfolding fps_inv_right[OF c0 c1] by simp |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3455 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3456 |
|
32410 | 3457 |
lemma fps_ginv_deriv: |
54681 | 3458 |
assumes a0:"a$0 = (0::'a::field)" |
52903 | 3459 |
and a1: "a$1 \<noteq> 0" |
32410 | 3460 |
shows "fps_deriv (fps_ginv b a) = (fps_deriv b / fps_deriv a) oo fps_ginv X a" |
52903 | 3461 |
proof - |
32410 | 3462 |
let ?ia = "fps_ginv b a" |
3463 |
let ?iXa = "fps_ginv X a" |
|
3464 |
let ?d = "fps_deriv" |
|
3465 |
let ?dia = "?d ?ia" |
|
60501 | 3466 |
have iXa0: "?iXa $ 0 = 0" |
3467 |
by (simp add: fps_ginv_def) |
|
3468 |
have da0: "?d a $ 0 \<noteq> 0" |
|
3469 |
using a1 by simp |
|
3470 |
from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b" |
|
3471 |
by simp |
|
3472 |
then have "(?d ?ia oo a) * ?d a = ?d b" |
|
3473 |
unfolding fps_compose_deriv[OF a0] . |
|
3474 |
then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)" |
|
3475 |
by simp |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3476 |
with a1 have "(?d ?ia oo a) * (inverse (?d a) * ?d a) = ?d b / ?d a" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3477 |
by (simp add: fps_divide_unit) |
60501 | 3478 |
then have "(?d ?ia oo a) oo ?iXa = (?d b / ?d a) oo ?iXa" |
32410 | 3479 |
unfolding inverse_mult_eq_1[OF da0] by simp |
3480 |
then have "?d ?ia oo (a oo ?iXa) = (?d b / ?d a) oo ?iXa" |
|
3481 |
unfolding fps_compose_assoc[OF iXa0 a0] . |
|
3482 |
then show ?thesis unfolding fps_inv_ginv[symmetric] |
|
3483 |
unfolding fps_inv_right[OF a0 a1] by simp |
|
3484 |
qed |
|
3485 |
||
60501 | 3486 |
|
3487 |
subsection \<open>Elementary series\<close> |
|
3488 |
||
3489 |
subsubsection \<open>Exponential series\<close> |
|
53195 | 3490 |
|
30488 | 3491 |
definition "E x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))" |
29687 | 3492 |
|
31273 | 3493 |
lemma E_deriv[simp]: "fps_deriv (E a) = fps_const (a::'a::field_char_0) * E a" (is "?l = ?r") |
52903 | 3494 |
proof - |
60501 | 3495 |
have "?l$n = ?r $ n" for n |
3496 |
apply (auto simp add: E_def field_simps power_Suc[symmetric] |
|
3497 |
simp del: fact.simps of_nat_Suc power_Suc) |
|
3498 |
apply (simp add: of_nat_mult field_simps) |
|
3499 |
done |
|
3500 |
then show ?thesis |
|
3501 |
by (simp add: fps_eq_iff) |
|
29687 | 3502 |
qed |
3503 |
||
30488 | 3504 |
lemma E_unique_ODE: |
54681 | 3505 |
"fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * E (c::'a::field_char_0)" |
29687 | 3506 |
(is "?lhs \<longleftrightarrow> ?rhs") |
52903 | 3507 |
proof |
60501 | 3508 |
show ?rhs if ?lhs |
3509 |
proof - |
|
3510 |
from that have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)" |
|
3511 |
by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc) |
|
3512 |
have th': "a$n = a$0 * c ^ n/ (fact n)" for n |
|
3513 |
proof (induct n) |
|
3514 |
case 0 |
|
3515 |
then show ?case by simp |
|
3516 |
next |
|
3517 |
case Suc |
|
3518 |
then show ?case |
|
3519 |
unfolding th |
|
3520 |
using fact_gt_zero |
|
3521 |
apply (simp add: field_simps del: of_nat_Suc fact_Suc) |
|
3522 |
apply simp |
|
3523 |
done |
|
3524 |
qed |
|
3525 |
show ?thesis |
|
3526 |
by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro: th') |
|
3527 |
qed |
|
3528 |
show ?lhs if ?rhs |
|
3529 |
using that by (metis E_deriv fps_deriv_mult_const_left mult.left_commute) |
|
29687 | 3530 |
qed |
3531 |
||
31273 | 3532 |
lemma E_add_mult: "E (a + b) = E (a::'a::field_char_0) * E b" (is "?l = ?r") |
52903 | 3533 |
proof - |
60501 | 3534 |
have "fps_deriv ?r = fps_const (a + b) * ?r" |
36350 | 3535 |
by (simp add: fps_const_add[symmetric] field_simps del: fps_const_add) |
60501 | 3536 |
then have "?r = ?l" |
3537 |
by (simp only: E_unique_ODE) (simp add: fps_mult_nth E_def) |
|
29687 | 3538 |
then show ?thesis .. |
3539 |
qed |
|
3540 |
||
3541 |
lemma E_nth[simp]: "E a $ n = a^n / of_nat (fact n)" |
|
3542 |
by (simp add: E_def) |
|
3543 |
||
54681 | 3544 |
lemma E0[simp]: "E (0::'a::field) = 1" |
29687 | 3545 |
by (simp add: fps_eq_iff power_0_left) |
3546 |
||
31273 | 3547 |
lemma E_neg: "E (- a) = inverse (E (a::'a::field_char_0))" |
52903 | 3548 |
proof - |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3549 |
from E_add_mult[of a "- a"] have th0: "E a * E (- a) = 1" by simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3550 |
from fps_inverse_unique[OF th0] show ?thesis by simp |
29687 | 3551 |
qed |
3552 |
||
31273 | 3553 |
lemma E_nth_deriv[simp]: "fps_nth_deriv n (E (a::'a::field_char_0)) = (fps_const a)^n * (E a)" |
52902 | 3554 |
by (induct n) auto |
29687 | 3555 |
|
54681 | 3556 |
lemma X_compose_E[simp]: "X oo E (a::'a::field) = E a - 1" |
29687 | 3557 |
by (simp add: fps_eq_iff X_fps_compose) |
3558 |
||
30488 | 3559 |
lemma LE_compose: |
60501 | 3560 |
assumes a: "a \<noteq> 0" |
29687 | 3561 |
shows "fps_inv (E a - 1) oo (E a - 1) = X" |
52903 | 3562 |
and "(E a - 1) oo fps_inv (E a - 1) = X" |
53195 | 3563 |
proof - |
29687 | 3564 |
let ?b = "E a - 1" |
60501 | 3565 |
have b0: "?b $ 0 = 0" |
3566 |
by simp |
|
3567 |
have b1: "?b $ 1 \<noteq> 0" |
|
3568 |
by (simp add: a) |
|
29687 | 3569 |
from fps_inv[OF b0 b1] show "fps_inv (E a - 1) oo (E a - 1) = X" . |
3570 |
from fps_inv_right[OF b0 b1] show "(E a - 1) oo fps_inv (E a - 1) = X" . |
|
3571 |
qed |
|
3572 |
||
31273 | 3573 |
lemma E_power_mult: "(E (c::'a::field_char_0))^n = E (of_nat n * c)" |
52902 | 3574 |
by (induct n) (auto simp add: field_simps E_add_mult) |
29687 | 3575 |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3576 |
lemma radical_E: |
52891 | 3577 |
assumes r: "r (Suc k) 1 = 1" |
54681 | 3578 |
shows "fps_radical r (Suc k) (E (c::'a::field_char_0)) = E (c / of_nat (Suc k))" |
52903 | 3579 |
proof - |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3580 |
let ?ck = "(c / of_nat (Suc k))" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3581 |
let ?r = "fps_radical r (Suc k)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3582 |
have eq0[simp]: "?ck * of_nat (Suc k) = c" "of_nat (Suc k) * ?ck = c" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3583 |
by (simp_all del: of_nat_Suc) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3584 |
have th0: "E ?ck ^ (Suc k) = E c" unfolding E_power_mult eq0 .. |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3585 |
have th: "r (Suc k) (E c $0) ^ Suc k = E c $ 0" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3586 |
"r (Suc k) (E c $ 0) = E ?ck $ 0" "E c $ 0 \<noteq> 0" using r by simp_all |
60501 | 3587 |
from th0 radical_unique[where r=r and k=k, OF th] show ?thesis |
3588 |
by auto |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3589 |
qed |
29687 | 3590 |
|
54681 | 3591 |
lemma Ec_E1_eq: "E (1::'a::field_char_0) oo (fps_const c * X) = E c" |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3592 |
apply (auto simp add: fps_eq_iff E_def fps_compose_def power_mult_distrib) |
57418 | 3593 |
apply (simp add: cond_value_iff cond_application_beta setsum.delta' cong del: if_weak_cong) |
52902 | 3594 |
done |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3595 |
|
53195 | 3596 |
|
60501 | 3597 |
subsubsection \<open>Logarithmic series\<close> |
29687 | 3598 |
|
52891 | 3599 |
lemma Abs_fps_if_0: |
60501 | 3600 |
"Abs_fps (\<lambda>n. if n = 0 then (v::'a::ring_1) else f n) = |
3601 |
fps_const v + X * Abs_fps (\<lambda>n. f (Suc n))" |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3602 |
by (auto simp add: fps_eq_iff) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3603 |
|
52902 | 3604 |
definition L :: "'a::field_char_0 \<Rightarrow> 'a fps" |
3605 |
where "L c = fps_const (1/c) * Abs_fps (\<lambda>n. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)" |
|
29687 | 3606 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3607 |
lemma fps_deriv_L: "fps_deriv (L c) = fps_const (1/c) * inverse (1 + X)" |
60162 | 3608 |
unfolding fps_inverse_X_plus1 |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3609 |
by (simp add: L_def fps_eq_iff del: of_nat_Suc) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3610 |
|
60501 | 3611 |
lemma L_nth: "L c $ n = (if n = 0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))" |
36350 | 3612 |
by (simp add: L_def field_simps) |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3613 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3614 |
lemma L_0[simp]: "L c $ 0 = 0" by (simp add: L_def) |
52903 | 3615 |
|
29687 | 3616 |
lemma L_E_inv: |
54452 | 3617 |
fixes a :: "'a::field_char_0" |
3618 |
assumes a: "a \<noteq> 0" |
|
3619 |
shows "L a = fps_inv (E a - 1)" (is "?l = ?r") |
|
52903 | 3620 |
proof - |
29687 | 3621 |
let ?b = "E a - 1" |
3622 |
have b0: "?b $ 0 = 0" by simp |
|
3623 |
have b1: "?b $ 1 \<noteq> 0" by (simp add: a) |
|
52903 | 3624 |
have "fps_deriv (E a - 1) oo fps_inv (E a - 1) = |
3625 |
(fps_const a * (E a - 1) + fps_const a) oo fps_inv (E a - 1)" |
|
36350 | 3626 |
by (simp add: field_simps) |
52903 | 3627 |
also have "\<dots> = fps_const a * (X + 1)" |
3628 |
apply (simp add: fps_compose_add_distrib fps_const_mult_apply_left[symmetric] fps_inv_right[OF b0 b1]) |
|
3629 |
apply (simp add: field_simps) |
|
3630 |
done |
|
29687 | 3631 |
finally have eq: "fps_deriv (E a - 1) oo fps_inv (E a - 1) = fps_const a * (X + 1)" . |
3632 |
from fps_inv_deriv[OF b0 b1, unfolded eq] |
|
3633 |
have "fps_deriv (fps_inv ?b) = fps_const (inverse a) / (X + 1)" |
|
52891 | 3634 |
using a |
29687 | 3635 |
by (simp add: fps_const_inverse eq fps_divide_def fps_inverse_mult) |
54452 | 3636 |
then have "fps_deriv ?l = fps_deriv ?r" |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3637 |
by (simp add: fps_deriv_L add.commute fps_divide_def divide_inverse) |
29687 | 3638 |
then show ?thesis unfolding fps_deriv_eq_iff |
3639 |
by (simp add: L_nth fps_inv_def) |
|
3640 |
qed |
|
3641 |
||
52891 | 3642 |
lemma L_mult_add: |
52903 | 3643 |
assumes c0: "c\<noteq>0" |
3644 |
and d0: "d\<noteq>0" |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3645 |
shows "L c + L d = fps_const (c+d) * L (c*d)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3646 |
(is "?r = ?l") |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3647 |
proof- |
36350 | 3648 |
from c0 d0 have eq: "1/c + 1/d = (c+d)/(c*d)" by (simp add: field_simps) |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3649 |
have "fps_deriv ?r = fps_const (1/c + 1/d) * inverse (1 + X)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3650 |
by (simp add: fps_deriv_L fps_const_add[symmetric] algebra_simps del: fps_const_add) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3651 |
also have "\<dots> = fps_deriv ?l" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3652 |
apply (simp add: fps_deriv_L) |
52903 | 3653 |
apply (simp add: fps_eq_iff eq) |
3654 |
done |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3655 |
finally show ?thesis |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3656 |
unfolding fps_deriv_eq_iff by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3657 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
3658 |
|
53196 | 3659 |
|
60501 | 3660 |
subsubsection \<open>Binomial series\<close> |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3661 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3662 |
definition "fps_binomial a = Abs_fps (\<lambda>n. a gchoose n)" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3663 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3664 |
lemma fps_binomial_nth[simp]: "fps_binomial a $ n = a gchoose n" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3665 |
by (simp add: fps_binomial_def) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3666 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3667 |
lemma fps_binomial_ODE_unique: |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3668 |
fixes c :: "'a::field_char_0" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3669 |
shows "fps_deriv a = (fps_const c * a) / (1 + X) \<longleftrightarrow> a = fps_const (a$0) * fps_binomial c" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3670 |
(is "?lhs \<longleftrightarrow> ?rhs") |
60501 | 3671 |
proof |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3672 |
let ?da = "fps_deriv a" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3673 |
let ?x1 = "(1 + X):: 'a fps" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3674 |
let ?l = "?x1 * ?da" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3675 |
let ?r = "fps_const c * a" |
60501 | 3676 |
|
3677 |
have eq: "?l = ?r \<longleftrightarrow> ?lhs" |
|
3678 |
proof - |
|
3679 |
have x10: "?x1 $ 0 \<noteq> 0" by simp |
|
3680 |
have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp |
|
3681 |
also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1" |
|
3682 |
apply (simp only: fps_divide_def mult.assoc[symmetric] inverse_mult_eq_1[OF x10]) |
|
3683 |
apply (simp add: field_simps) |
|
3684 |
done |
|
3685 |
finally show ?thesis . |
|
3686 |
qed |
|
3687 |
||
3688 |
show ?rhs if ?lhs |
|
3689 |
proof - |
|
3690 |
from eq that have h: "?l = ?r" .. |
|
3691 |
have th0: "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n" for n |
|
3692 |
proof - |
|
3693 |
from h have "?l $ n = ?r $ n" by simp |
|
3694 |
then show ?thesis |
|
36350 | 3695 |
apply (simp add: field_simps del: of_nat_Suc) |
60501 | 3696 |
apply (cases n) |
3697 |
apply (simp_all add: field_simps del: of_nat_Suc) |
|
3698 |
done |
|
3699 |
qed |
|
3700 |
have th1: "a $ n = (c gchoose n) * a $ 0" for n |
|
3701 |
proof (induct n) |
|
3702 |
case 0 |
|
3703 |
then show ?case by simp |
|
3704 |
next |
|
3705 |
case (Suc m) |
|
3706 |
then show ?case |
|
3707 |
unfolding th0 |
|
3708 |
apply (simp add: field_simps del: of_nat_Suc) |
|
3709 |
unfolding mult.assoc[symmetric] gbinomial_mult_1 |
|
3710 |
apply (simp add: field_simps) |
|
3711 |
done |
|
3712 |
qed |
|
3713 |
show ?thesis |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3714 |
apply (simp add: fps_eq_iff) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3715 |
apply (subst th1) |
53196 | 3716 |
apply (simp add: field_simps) |
3717 |
done |
|
60501 | 3718 |
qed |
3719 |
||
3720 |
show ?lhs if ?rhs |
|
3721 |
proof - |
|
3722 |
have th00: "x * (a $ 0 * y) = a $ 0 * (x * y)" for x y |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3723 |
by (simp add: mult.commute) |
52891 | 3724 |
have "?l = ?r" |
60501 | 3725 |
apply (subst \<open>?rhs\<close>) |
3726 |
apply (subst (2) \<open>?rhs\<close>) |
|
36350 | 3727 |
apply (clarsimp simp add: fps_eq_iff field_simps) |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3728 |
unfolding mult.assoc[symmetric] th00 gbinomial_mult_1 |
53196 | 3729 |
apply (simp add: field_simps gbinomial_mult_1) |
3730 |
done |
|
60501 | 3731 |
with eq show ?thesis .. |
3732 |
qed |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3733 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3734 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3735 |
lemma fps_binomial_deriv: "fps_deriv (fps_binomial c) = fps_const c * fps_binomial c / (1 + X)" |
53196 | 3736 |
proof - |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3737 |
let ?a = "fps_binomial c" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3738 |
have th0: "?a = fps_const (?a$0) * ?a" by (simp) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3739 |
from iffD2[OF fps_binomial_ODE_unique, OF th0] show ?thesis . |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3740 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3741 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3742 |
lemma fps_binomial_add_mult: "fps_binomial (c+d) = fps_binomial c * fps_binomial d" (is "?l = ?r") |
53196 | 3743 |
proof - |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3744 |
let ?P = "?r - ?l" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3745 |
let ?b = "fps_binomial" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3746 |
let ?db = "\<lambda>x. fps_deriv (?b x)" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3747 |
have "fps_deriv ?P = ?db c * ?b d + ?b c * ?db d - ?db (c + d)" by simp |
53196 | 3748 |
also have "\<dots> = inverse (1 + X) * |
3749 |
(fps_const c * ?b c * ?b d + fps_const d * ?b c * ?b d - fps_const (c+d) * ?b (c + d))" |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3750 |
unfolding fps_binomial_deriv |
36350 | 3751 |
by (simp add: fps_divide_def field_simps) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3752 |
also have "\<dots> = (fps_const (c + d)/ (1 + X)) * ?P" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
3753 |
by (simp add: field_simps fps_divide_unit fps_const_add[symmetric] del: fps_const_add) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3754 |
finally have th0: "fps_deriv ?P = fps_const (c+d) * ?P / (1 + X)" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3755 |
by (simp add: fps_divide_def) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3756 |
have "?P = fps_const (?P$0) * ?b (c + d)" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3757 |
unfolding fps_binomial_ODE_unique[symmetric] |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3758 |
using th0 by simp |
54452 | 3759 |
then have "?P = 0" by (simp add: fps_mult_nth) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3760 |
then show ?thesis by simp |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3761 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3762 |
|
61552
980dd46a03fb
Added binomial identities to CONTRIBUTORS; small lemmas on of_int/pochhammer
eberlm
parents:
60867
diff
changeset
|
3763 |
lemma fps_binomial_minus_one: "fps_binomial (- 1) = inverse (1 + X)" |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3764 |
(is "?l = inverse ?r") |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3765 |
proof- |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3766 |
have th: "?r$0 \<noteq> 0" by simp |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3767 |
have th': "fps_deriv (inverse ?r) = fps_const (- 1) * inverse ?r / (1 + X)" |
53196 | 3768 |
by (simp add: fps_inverse_deriv[OF th] fps_divide_def |
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
57418
diff
changeset
|
3769 |
power2_eq_square mult.commute fps_const_neg[symmetric] del: fps_const_neg) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3770 |
have eq: "inverse ?r $ 0 = 1" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3771 |
by (simp add: fps_inverse_def) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3772 |
from iffD1[OF fps_binomial_ODE_unique[of "inverse (1 + X)" "- 1"] th'] eq |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3773 |
show ?thesis by (simp add: fps_inverse_def) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3774 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3775 |
|
60558 | 3776 |
text \<open>Vandermonde's Identity as a consequence.\<close> |
53196 | 3777 |
lemma gbinomial_Vandermonde: |
3778 |
"setsum (\<lambda>k. (a gchoose k) * (b gchoose (n - k))) {0..n} = (a + b) gchoose n" |
|
3779 |
proof - |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3780 |
let ?ba = "fps_binomial a" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3781 |
let ?bb = "fps_binomial b" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3782 |
let ?bab = "fps_binomial (a + b)" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3783 |
from fps_binomial_add_mult[of a b] have "?bab $ n = (?ba * ?bb)$n" by simp |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3784 |
then show ?thesis by (simp add: fps_mult_nth) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3785 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3786 |
|
53196 | 3787 |
lemma binomial_Vandermonde: |
3788 |
"setsum (\<lambda>k. (a choose k) * (b choose (n - k))) {0..n} = (a + b) choose n" |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3789 |
using gbinomial_Vandermonde[of "(of_nat a)" "of_nat b" n] |
53196 | 3790 |
apply (simp only: binomial_gbinomial[symmetric] of_nat_mult[symmetric] |
3791 |
of_nat_setsum[symmetric] of_nat_add[symmetric]) |
|
53195 | 3792 |
apply simp |
3793 |
done |
|
52891 | 3794 |
|
60501 | 3795 |
lemma binomial_Vandermonde_same: "setsum (\<lambda>k. (n choose k)\<^sup>2) {0..n} = (2 * n) choose n" |
3796 |
using binomial_Vandermonde[of n n n, symmetric] |
|
53195 | 3797 |
unfolding mult_2 |
3798 |
apply (simp add: power2_eq_square) |
|
57418 | 3799 |
apply (rule setsum.cong) |
53195 | 3800 |
apply (auto intro: binomial_symmetric) |
3801 |
done |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3802 |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3803 |
lemma Vandermonde_pochhammer_lemma: |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3804 |
fixes a :: "'a::field_char_0" |
60504 | 3805 |
assumes b: "\<forall>j\<in>{0 ..<n}. b \<noteq> of_nat j" |
54452 | 3806 |
shows "setsum (\<lambda>k. (pochhammer (- a) k * pochhammer (- (of_nat n)) k) / |
53196 | 3807 |
(of_nat (fact k) * pochhammer (b - of_nat n + 1) k)) {0..n} = |
54452 | 3808 |
pochhammer (- (a + b)) n / pochhammer (- b) n" |
53196 | 3809 |
(is "?l = ?r") |
3810 |
proof - |
|
54452 | 3811 |
let ?m1 = "\<lambda>m. (- 1 :: 'a) ^ m" |
3812 |
let ?f = "\<lambda>m. of_nat (fact m)" |
|
3813 |
let ?p = "\<lambda>(x::'a). pochhammer (- x)" |
|
60501 | 3814 |
from b have bn0: "?p b n \<noteq> 0" |
3815 |
unfolding pochhammer_eq_0_iff by simp |
|
60558 | 3816 |
have th00: |
3817 |
"b gchoose (n - k) = |
|
3818 |
(?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" |
|
3819 |
(is ?gchoose) |
|
3820 |
"pochhammer (1 + b - of_nat n) k \<noteq> 0" |
|
3821 |
(is ?pochhammer) |
|
3822 |
if kn: "k \<in> {0..n}" for k |
|
3823 |
proof - |
|
60501 | 3824 |
have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0" |
3825 |
proof |
|
3826 |
assume "pochhammer (1 + b - of_nat n) n = 0" |
|
3827 |
then have c: "pochhammer (b - of_nat n + 1) n = 0" |
|
3828 |
by (simp add: algebra_simps) |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3829 |
then obtain j where j: "j < n" "b - of_nat n + 1 = - of_nat j" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3830 |
unfolding pochhammer_eq_0_iff by blast |
52891 | 3831 |
from j have "b = of_nat n - of_nat j - of_nat 1" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3832 |
by (simp add: algebra_simps) |
52891 | 3833 |
then have "b = of_nat (n - j - 1)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3834 |
using j kn by (simp add: of_nat_diff) |
60501 | 3835 |
with b show False using j by auto |
3836 |
qed |
|
52891 | 3837 |
|
3838 |
from nz kn [simplified] have nz': "pochhammer (1 + b - of_nat n) k \<noteq> 0" |
|
35175 | 3839 |
by (rule pochhammer_neq_0_mono) |
60504 | 3840 |
|
60567 | 3841 |
consider "k = 0 \<or> n = 0" | "k \<noteq> 0" "n \<noteq> 0" |
3842 |
by blast |
|
60504 | 3843 |
then have "b gchoose (n - k) = |
3844 |
(?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)" |
|
3845 |
proof cases |
|
3846 |
case 1 |
|
3847 |
then show ?thesis |
|
3848 |
using kn by (cases "k = 0") (simp_all add: gbinomial_pochhammer) |
|
3849 |
next |
|
60567 | 3850 |
case neq: 2 |
60501 | 3851 |
then obtain m where m: "n = Suc m" |
3852 |
by (cases n) auto |
|
60567 | 3853 |
from neq(1) obtain h where h: "k = Suc h" |
60501 | 3854 |
by (cases k) auto |
60504 | 3855 |
show ?thesis |
60501 | 3856 |
proof (cases "k = n") |
3857 |
case True |
|
3858 |
then show ?thesis |
|
59862 | 3859 |
using pochhammer_minus'[where k=k and b=b] |
3860 |
apply (simp add: pochhammer_same) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3861 |
using bn0 |
53195 | 3862 |
apply (simp add: field_simps power_add[symmetric]) |
3863 |
done |
|
60501 | 3864 |
next |
3865 |
case False |
|
3866 |
with kn have kn': "k < n" |
|
3867 |
by simp |
|
54452 | 3868 |
have m1nk: "?m1 n = setprod (\<lambda>i. - 1) {0..m}" "?m1 k = setprod (\<lambda>i. - 1) {0..h}" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3869 |
by (simp_all add: setprod_constant m h) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3870 |
have bnz0: "pochhammer (b - of_nat n + 1) k \<noteq> 0" |
52891 | 3871 |
using bn0 kn |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3872 |
unfolding pochhammer_eq_0_iff |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3873 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3874 |
apply (erule_tac x= "n - ka - 1" in allE) |
53196 | 3875 |
apply (auto simp add: algebra_simps of_nat_diff) |
3876 |
done |
|
54452 | 3877 |
have eq1: "setprod (\<lambda>k. (1::'a) + of_nat m - of_nat k) {0 .. h} = |
53196 | 3878 |
setprod of_nat {Suc (m - h) .. Suc m}" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3879 |
using kn' h m |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3880 |
by (intro setprod.reindex_bij_witness[where i="\<lambda>k. Suc m - k" and j="\<lambda>k. Suc m - k"]) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3881 |
(auto simp: of_nat_diff) |
52891 | 3882 |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3883 |
have th1: "(?m1 k * ?p (of_nat n) k) / ?f n = 1 / of_nat(fact (n - k))" |
52891 | 3884 |
unfolding m1nk |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3885 |
unfolding m h pochhammer_Suc_setprod |
54489
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54452
diff
changeset
|
3886 |
apply (simp add: field_simps del: fact_Suc) |
59730
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
paulson <lp15@cam.ac.uk>
parents:
59667
diff
changeset
|
3887 |
unfolding fact_altdef id_def |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3888 |
unfolding of_nat_setprod |
57418 | 3889 |
unfolding setprod.distrib[symmetric] |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3890 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3891 |
unfolding eq1 |
57418 | 3892 |
apply (subst setprod.union_disjoint[symmetric]) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3893 |
apply (auto) |
57418 | 3894 |
apply (rule setprod.cong) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3895 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3896 |
done |
54452 | 3897 |
have th20: "?m1 n * ?p b n = setprod (\<lambda>i. b - of_nat i) {0..m}" |
52891 | 3898 |
unfolding m1nk |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3899 |
unfolding m h pochhammer_Suc_setprod |
57418 | 3900 |
unfolding setprod.distrib[symmetric] |
3901 |
apply (rule setprod.cong) |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3902 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3903 |
done |
54452 | 3904 |
have th21:"pochhammer (b - of_nat n + 1) k = setprod (\<lambda>i. b - of_nat i) {n - k .. n - 1}" |
52891 | 3905 |
unfolding h m |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3906 |
unfolding pochhammer_Suc_setprod |
57129
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3907 |
using kn m h |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3908 |
by (intro setprod.reindex_bij_witness[where i="\<lambda>k. n - 1 - k" and j="\<lambda>i. m-i"]) |
7edb7550663e
introduce more powerful reindexing rules for big operators
hoelzl
parents:
56480
diff
changeset
|
3909 |
(auto simp: of_nat_diff) |
53196 | 3910 |
|
3911 |
have "?m1 n * ?p b n = |
|
54452 | 3912 |
pochhammer (b - of_nat n + 1) k * setprod (\<lambda>i. b - of_nat i) {0.. n - k - 1}" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3913 |
unfolding th20 th21 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3914 |
unfolding h m |
57418 | 3915 |
apply (subst setprod.union_disjoint[symmetric]) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3916 |
using kn' h m |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3917 |
apply auto |
57418 | 3918 |
apply (rule setprod.cong) |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3919 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3920 |
done |
53196 | 3921 |
then have th2: "(?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k = |
54452 | 3922 |
setprod (\<lambda>i. b - of_nat i) {0.. n - k - 1}" |
36350 | 3923 |
using nz' by (simp add: field_simps) |
53196 | 3924 |
have "(?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k) = |
3925 |
((?m1 k * ?p (of_nat n) k) / ?f n) * ((?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k)" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3926 |
using bnz0 |
36350 | 3927 |
by (simp add: field_simps) |
52891 | 3928 |
also have "\<dots> = b gchoose (n - k)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3929 |
unfolding th1 th2 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
3930 |
using kn' by (simp add: gbinomial_def) |
60501 | 3931 |
finally show ?thesis by simp |
3932 |
qed |
|
60504 | 3933 |
qed |
60558 | 3934 |
then show ?gchoose and ?pochhammer |
53195 | 3935 |
apply (cases "n = 0") |
52891 | 3936 |
using nz' |
53195 | 3937 |
apply auto |
3938 |
done |
|
60558 | 3939 |
qed |
60504 | 3940 |
have "?r = ((a + b) gchoose n) * (of_nat (fact n) / (?m1 n * pochhammer (- b) n))" |
52891 | 3941 |
unfolding gbinomial_pochhammer |
36350 | 3942 |
using bn0 by (auto simp add: field_simps) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3943 |
also have "\<dots> = ?l" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3944 |
unfolding gbinomial_Vandermonde[symmetric] |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3945 |
apply (simp add: th00) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3946 |
unfolding gbinomial_pochhammer |
53196 | 3947 |
using bn0 |
3948 |
apply (simp add: setsum_left_distrib setsum_right_distrib field_simps) |
|
57418 | 3949 |
apply (rule setsum.cong) |
3950 |
apply (rule refl) |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3951 |
apply (drule th00(2)) |
53196 | 3952 |
apply (simp add: field_simps power_add[symmetric]) |
3953 |
done |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3954 |
finally show ?thesis by simp |
52891 | 3955 |
qed |
3956 |
||
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3957 |
lemma Vandermonde_pochhammer: |
53195 | 3958 |
fixes a :: "'a::field_char_0" |
54452 | 3959 |
assumes c: "\<forall>i \<in> {0..< n}. c \<noteq> - of_nat i" |
3960 |
shows "setsum (\<lambda>k. (pochhammer a k * pochhammer (- (of_nat n)) k) / |
|
53195 | 3961 |
(of_nat (fact k) * pochhammer c k)) {0..n} = pochhammer (c - a) n / pochhammer c n" |
3962 |
proof - |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3963 |
let ?a = "- a" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3964 |
let ?b = "c + of_nat n - 1" |
60558 | 3965 |
have h: "\<forall> j \<in>{0..< n}. ?b \<noteq> of_nat j" |
3966 |
using c |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3967 |
apply (auto simp add: algebra_simps of_nat_diff) |
60501 | 3968 |
apply (erule_tac x = "n - j - 1" in ballE) |
53195 | 3969 |
apply (auto simp add: of_nat_diff algebra_simps) |
3970 |
done |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3971 |
have th0: "pochhammer (- (?a + ?b)) n = (- 1)^n * pochhammer (c - a) n" |
59862 | 3972 |
unfolding pochhammer_minus |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3973 |
by (simp add: algebra_simps) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3974 |
have th1: "pochhammer (- ?b) n = (- 1)^n * pochhammer c n" |
59862 | 3975 |
unfolding pochhammer_minus |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3976 |
by simp |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3977 |
have nz: "pochhammer c n \<noteq> 0" using c |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3978 |
by (simp add: pochhammer_eq_0_iff) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3979 |
from Vandermonde_pochhammer_lemma[where a = "?a" and b="?b" and n=n, OF h, unfolded th0 th1] |
60501 | 3980 |
show ?thesis |
3981 |
using nz by (simp add: field_simps setsum_right_distrib) |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
3982 |
qed |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
3983 |
|
53195 | 3984 |
|
60501 | 3985 |
subsubsection \<open>Formal trigonometric functions\<close> |
29687 | 3986 |
|
31273 | 3987 |
definition "fps_sin (c::'a::field_char_0) = |
29687 | 3988 |
Abs_fps (\<lambda>n. if even n then 0 else (- 1) ^((n - 1) div 2) * c^n /(of_nat (fact n)))" |
3989 |
||
31273 | 3990 |
definition "fps_cos (c::'a::field_char_0) = |
3991 |
Abs_fps (\<lambda>n. if even n then (- 1) ^ (n div 2) * c^n / (of_nat (fact n)) else 0)" |
|
29687 | 3992 |
|
30488 | 3993 |
lemma fps_sin_deriv: |
29687 | 3994 |
"fps_deriv (fps_sin c) = fps_const c * fps_cos c" |
3995 |
(is "?lhs = ?rhs") |
|
31273 | 3996 |
proof (rule fps_ext) |
53195 | 3997 |
fix n :: nat |
60501 | 3998 |
show "?lhs $ n = ?rhs $ n" |
3999 |
proof (cases "even n") |
|
4000 |
case True |
|
52902 | 4001 |
have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp |
4002 |
also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))" |
|
60501 | 4003 |
using True by (simp add: fps_sin_def) |
52902 | 4004 |
also have "\<dots> = (- 1)^(n div 2) * c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" |
4005 |
unfolding fact_Suc of_nat_mult |
|
4006 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
4007 |
also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)" |
|
4008 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
60501 | 4009 |
finally show ?thesis |
4010 |
using True by (simp add: fps_cos_def field_simps) |
|
4011 |
next |
|
4012 |
case False |
|
4013 |
then show ?thesis |
|
4014 |
by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def) |
|
4015 |
qed |
|
29687 | 4016 |
qed |
4017 |
||
52902 | 4018 |
lemma fps_cos_deriv: "fps_deriv (fps_cos c) = fps_const (- c)* (fps_sin c)" |
29687 | 4019 |
(is "?lhs = ?rhs") |
31273 | 4020 |
proof (rule fps_ext) |
60501 | 4021 |
have th0: "- ((- 1::'a) ^ n) = (- 1)^Suc n" for n |
4022 |
by simp |
|
4023 |
show "?lhs $ n = ?rhs $ n" for n |
|
4024 |
proof (cases "even n") |
|
4025 |
case False |
|
4026 |
then have n0: "n \<noteq> 0" by presburger |
|
4027 |
from False have th1: "Suc ((n - 1) div 2) = Suc n div 2" |
|
4028 |
by (cases n) simp_all |
|
52902 | 4029 |
have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp |
4030 |
also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))" |
|
60501 | 4031 |
using False by (simp add: fps_cos_def) |
52902 | 4032 |
also have "\<dots> = (- 1)^((n + 1) div 2)*c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" |
4033 |
unfolding fact_Suc of_nat_mult |
|
4034 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
4035 |
also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)" |
|
4036 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
4037 |
also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)" |
|
60501 | 4038 |
unfolding th0 unfolding th1 by simp |
4039 |
finally show ?thesis |
|
4040 |
using False by (simp add: fps_sin_def field_simps) |
|
4041 |
next |
|
4042 |
case True |
|
4043 |
then show ?thesis |
|
4044 |
by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def) |
|
4045 |
qed |
|
29687 | 4046 |
qed |
4047 |
||
60501 | 4048 |
lemma fps_sin_cos_sum_of_squares: "(fps_cos c)\<^sup>2 + (fps_sin c)\<^sup>2 = 1" |
4049 |
(is "?lhs = _") |
|
53077 | 4050 |
proof - |
29687 | 4051 |
have "fps_deriv ?lhs = 0" |
52902 | 4052 |
apply (simp add: fps_deriv_power fps_sin_deriv fps_cos_deriv) |
4053 |
apply (simp add: field_simps fps_const_neg[symmetric] del: fps_const_neg) |
|
4054 |
done |
|
29687 | 4055 |
then have "?lhs = fps_const (?lhs $ 0)" |
4056 |
unfolding fps_deriv_eq_0_iff . |
|
4057 |
also have "\<dots> = 1" |
|
30960 | 4058 |
by (auto simp add: fps_eq_iff numeral_2_eq_2 fps_mult_nth fps_cos_def fps_sin_def) |
29687 | 4059 |
finally show ?thesis . |
4060 |
qed |
|
4061 |
||
31274 | 4062 |
lemma fps_sin_nth_0 [simp]: "fps_sin c $ 0 = 0" |
53195 | 4063 |
unfolding fps_sin_def by simp |
31274 | 4064 |
|
4065 |
lemma fps_sin_nth_1 [simp]: "fps_sin c $ 1 = c" |
|
53195 | 4066 |
unfolding fps_sin_def by simp |
31274 | 4067 |
|
4068 |
lemma fps_sin_nth_add_2: |
|
60501 | 4069 |
"fps_sin c $ (n + 2) = - (c * c * fps_sin c $ n / (of_nat (n + 1) * of_nat (n + 2)))" |
53195 | 4070 |
unfolding fps_sin_def |
60501 | 4071 |
apply (cases n) |
4072 |
apply simp |
|
60162 | 4073 |
apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc) |
53195 | 4074 |
apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc) |
4075 |
done |
|
31274 | 4076 |
|
4077 |
lemma fps_cos_nth_0 [simp]: "fps_cos c $ 0 = 1" |
|
53195 | 4078 |
unfolding fps_cos_def by simp |
31274 | 4079 |
|
4080 |
lemma fps_cos_nth_1 [simp]: "fps_cos c $ 1 = 0" |
|
53195 | 4081 |
unfolding fps_cos_def by simp |
31274 | 4082 |
|
4083 |
lemma fps_cos_nth_add_2: |
|
60501 | 4084 |
"fps_cos c $ (n + 2) = - (c * c * fps_cos c $ n / (of_nat (n + 1) * of_nat (n + 2)))" |
52902 | 4085 |
unfolding fps_cos_def |
60162 | 4086 |
apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc) |
52902 | 4087 |
apply (simp add: of_nat_mult del: of_nat_Suc mult_Suc) |
4088 |
done |
|
4089 |
||
4090 |
lemma nat_induct2: "P 0 \<Longrightarrow> P 1 \<Longrightarrow> (\<And>n. P n \<Longrightarrow> P (n + 2)) \<Longrightarrow> P (n::nat)" |
|
4091 |
unfolding One_nat_def numeral_2_eq_2 |
|
4092 |
apply (induct n rule: nat_less_induct) |
|
53196 | 4093 |
apply (case_tac n) |
4094 |
apply simp |
|
4095 |
apply (rename_tac m) |
|
4096 |
apply (case_tac m) |
|
4097 |
apply simp |
|
4098 |
apply (rename_tac k) |
|
4099 |
apply (case_tac k) |
|
4100 |
apply simp_all |
|
52902 | 4101 |
done |
31274 | 4102 |
|
4103 |
lemma nat_add_1_add_1: "(n::nat) + 1 + 1 = n + 2" |
|
52902 | 4104 |
by simp |
31274 | 4105 |
|
4106 |
lemma eq_fps_sin: |
|
52902 | 4107 |
assumes 0: "a $ 0 = 0" |
4108 |
and 1: "a $ 1 = c" |
|
4109 |
and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" |
|
31274 | 4110 |
shows "a = fps_sin c" |
52902 | 4111 |
apply (rule fps_ext) |
4112 |
apply (induct_tac n rule: nat_induct2) |
|
4113 |
apply (simp add: 0) |
|
4114 |
apply (simp add: 1 del: One_nat_def) |
|
4115 |
apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) |
|
4116 |
apply (simp add: nat_add_1_add_1 fps_sin_nth_add_2 |
|
4117 |
del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') |
|
4118 |
apply (subst minus_divide_left) |
|
60162 | 4119 |
apply (subst nonzero_eq_divide_eq) |
52902 | 4120 |
apply (simp del: of_nat_add of_nat_Suc) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
4121 |
apply (simp only: ac_simps) |
52902 | 4122 |
done |
31274 | 4123 |
|
4124 |
lemma eq_fps_cos: |
|
52902 | 4125 |
assumes 0: "a $ 0 = 1" |
4126 |
and 1: "a $ 1 = 0" |
|
4127 |
and 2: "fps_deriv (fps_deriv a) = - (fps_const c * fps_const c * a)" |
|
31274 | 4128 |
shows "a = fps_cos c" |
52902 | 4129 |
apply (rule fps_ext) |
4130 |
apply (induct_tac n rule: nat_induct2) |
|
4131 |
apply (simp add: 0) |
|
4132 |
apply (simp add: 1 del: One_nat_def) |
|
4133 |
apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2]) |
|
4134 |
apply (simp add: nat_add_1_add_1 fps_cos_nth_add_2 |
|
4135 |
del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc') |
|
4136 |
apply (subst minus_divide_left) |
|
60162 | 4137 |
apply (subst nonzero_eq_divide_eq) |
52902 | 4138 |
apply (simp del: of_nat_add of_nat_Suc) |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
4139 |
apply (simp only: ac_simps) |
52902 | 4140 |
done |
31274 | 4141 |
|
4142 |
lemma mult_nth_0 [simp]: "(a * b) $ 0 = a $ 0 * b $ 0" |
|
52902 | 4143 |
by (simp add: fps_mult_nth) |
31274 | 4144 |
|
4145 |
lemma mult_nth_1 [simp]: "(a * b) $ 1 = a $ 0 * b $ 1 + a $ 1 * b $ 0" |
|
52902 | 4146 |
by (simp add: fps_mult_nth) |
4147 |
||
4148 |
lemma fps_sin_add: "fps_sin (a + b) = fps_sin a * fps_cos b + fps_cos a * fps_sin b" |
|
4149 |
apply (rule eq_fps_sin [symmetric], simp, simp del: One_nat_def) |
|
4150 |
apply (simp del: fps_const_neg fps_const_add fps_const_mult |
|
4151 |
add: fps_const_add [symmetric] fps_const_neg [symmetric] |
|
4152 |
fps_sin_deriv fps_cos_deriv algebra_simps) |
|
4153 |
done |
|
4154 |
||
4155 |
lemma fps_cos_add: "fps_cos (a + b) = fps_cos a * fps_cos b - fps_sin a * fps_sin b" |
|
4156 |
apply (rule eq_fps_cos [symmetric], simp, simp del: One_nat_def) |
|
4157 |
apply (simp del: fps_const_neg fps_const_add fps_const_mult |
|
4158 |
add: fps_const_add [symmetric] fps_const_neg [symmetric] |
|
4159 |
fps_sin_deriv fps_cos_deriv algebra_simps) |
|
4160 |
done |
|
31274 | 4161 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
4162 |
lemma fps_sin_even: "fps_sin (- c) = - fps_sin c" |
56479
91958d4b30f7
revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents:
56410
diff
changeset
|
4163 |
by (auto simp add: fps_eq_iff fps_sin_def) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
4164 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
4165 |
lemma fps_cos_odd: "fps_cos (- c) = fps_cos c" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
4166 |
by (auto simp add: fps_eq_iff fps_cos_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
4167 |
|
29687 | 4168 |
definition "fps_tan c = fps_sin c / fps_cos c" |
4169 |
||
53077 | 4170 |
lemma fps_tan_deriv: "fps_deriv (fps_tan c) = fps_const c / (fps_cos c)\<^sup>2" |
52902 | 4171 |
proof - |
29687 | 4172 |
have th0: "fps_cos c $ 0 \<noteq> 0" by (simp add: fps_cos_def) |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4173 |
from this have "fps_cos c \<noteq> 0" by (intro notI) simp |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4174 |
hence "fps_deriv (fps_tan c) = |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4175 |
fps_const c * (fps_cos c^2 + fps_sin c^2) / (fps_cos c^2)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4176 |
by (simp add: fps_tan_def fps_divide_deriv power2_eq_square algebra_simps |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4177 |
fps_sin_deriv fps_cos_deriv fps_const_neg[symmetric] div_mult_swap |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4178 |
del: fps_const_neg) |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4179 |
also note fps_sin_cos_sum_of_squares |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4180 |
finally show ?thesis by simp |
29687 | 4181 |
qed |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
4182 |
|
60558 | 4183 |
text \<open>Connection to E c over the complex numbers --- Euler and de Moivre.\<close> |
60501 | 4184 |
|
4185 |
lemma Eii_sin_cos: "E (ii * c) = fps_cos c + fps_const ii * fps_sin c" |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4186 |
(is "?l = ?r") |
52902 | 4187 |
proof - |
60501 | 4188 |
have "?l $ n = ?r $ n" for n |
4189 |
proof (cases "even n") |
|
4190 |
case True |
|
4191 |
then obtain m where m: "n = 2 * m" .. |
|
4192 |
show ?thesis |
|
4193 |
by (simp add: m fps_sin_def fps_cos_def power_mult_distrib power_mult power_minus [of "c ^ 2"]) |
|
4194 |
next |
|
4195 |
case False |
|
4196 |
then obtain m where m: "n = 2 * m + 1" .. |
|
4197 |
show ?thesis |
|
4198 |
by (simp add: m fps_sin_def fps_cos_def power_mult_distrib |
|
4199 |
power_mult power_minus [of "c ^ 2"]) |
|
4200 |
qed |
|
4201 |
then show ?thesis |
|
4202 |
by (simp add: fps_eq_iff) |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4203 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4204 |
|
52902 | 4205 |
lemma E_minus_ii_sin_cos: "E (- (ii * c)) = fps_cos c - fps_const ii * fps_sin c" |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4206 |
unfolding minus_mult_right Eii_sin_cos by (simp add: fps_sin_even fps_cos_odd) |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4207 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4208 |
lemma fps_const_minus: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4209 |
by (fact fps_const_sub) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4210 |
|
54681 | 4211 |
lemma fps_numeral_fps_const: "numeral i = fps_const (numeral i :: 'a::comm_ring_1)" |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
4212 |
by (fact numeral_fps_const) (* FIXME: duplicate *) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4213 |
|
52902 | 4214 |
lemma fps_cos_Eii: "fps_cos c = (E (ii * c) + E (- ii * c)) / fps_const 2" |
4215 |
proof - |
|
52891 | 4216 |
have th: "fps_cos c + fps_cos c = fps_cos c * fps_const 2" |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
4217 |
by (simp add: numeral_fps_const) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4218 |
show ?thesis |
60501 | 4219 |
unfolding Eii_sin_cos minus_mult_commute |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4220 |
by (simp add: fps_sin_even fps_cos_odd numeral_fps_const fps_divide_unit fps_const_inverse th) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4221 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4222 |
|
52902 | 4223 |
lemma fps_sin_Eii: "fps_sin c = (E (ii * c) - E (- ii * c)) / fps_const (2*ii)" |
4224 |
proof - |
|
52891 | 4225 |
have th: "fps_const \<i> * fps_sin c + fps_const \<i> * fps_sin c = fps_sin c * fps_const (2 * ii)" |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
4226 |
by (simp add: fps_eq_iff numeral_fps_const) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4227 |
show ?thesis |
52902 | 4228 |
unfolding Eii_sin_cos minus_mult_commute |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4229 |
by (simp add: fps_sin_even fps_cos_odd fps_divide_unit fps_const_inverse th) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4230 |
qed |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4231 |
|
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4232 |
lemma fps_tan_Eii: |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4233 |
"fps_tan c = (E (ii * c) - E (- ii * c)) / (fps_const ii * (E (ii * c) + E (- ii * c)))" |
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4234 |
unfolding fps_tan_def fps_sin_Eii fps_cos_Eii mult_minus_left E_neg |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4235 |
apply (simp add: fps_divide_unit fps_inverse_mult fps_const_mult[symmetric] fps_const_inverse del: fps_const_mult) |
52902 | 4236 |
apply simp |
4237 |
done |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4238 |
|
60501 | 4239 |
lemma fps_demoivre: |
4240 |
"(fps_cos a + fps_const ii * fps_sin a)^n = |
|
4241 |
fps_cos (of_nat n * a) + fps_const ii * fps_sin (of_nat n * a)" |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4242 |
unfolding Eii_sin_cos[symmetric] E_power_mult |
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57512
diff
changeset
|
4243 |
by (simp add: ac_simps) |
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
4244 |
|
52902 | 4245 |
|
60500 | 4246 |
subsection \<open>Hypergeometric series\<close> |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4247 |
|
59867
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
haftmann
parents:
59862
diff
changeset
|
4248 |
definition "F as bs (c::'a::{field_char_0,field}) = |
54452 | 4249 |
Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / |
4250 |
(foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n)))" |
|
52902 | 4251 |
|
4252 |
lemma F_nth[simp]: "F as bs c $ n = |
|
4253 |
(foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) / |
|
4254 |
(foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n))" |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4255 |
by (simp add: F_def) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4256 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4257 |
lemma foldl_mult_start: |
54452 | 4258 |
fixes v :: "'a::comm_ring_1" |
4259 |
shows "foldl (\<lambda>r x. r * f x) v as * x = foldl (\<lambda>r x. r * f x) (v * x) as " |
|
48757 | 4260 |
by (induct as arbitrary: x v) (auto simp add: algebra_simps) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4261 |
|
53196 | 4262 |
lemma foldr_mult_foldl: |
54452 | 4263 |
fixes v :: "'a::comm_ring_1" |
4264 |
shows "foldr (\<lambda>x r. r * f x) as v = foldl (\<lambda>r x. r * f x) v as" |
|
48757 | 4265 |
by (induct as arbitrary: v) (auto simp add: foldl_mult_start) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4266 |
|
53196 | 4267 |
lemma F_nth_alt: |
4268 |
"F as bs c $ n = foldr (\<lambda>a r. r * pochhammer a n) as (c ^ n) / |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4269 |
foldr (\<lambda>b r. r * pochhammer b n) bs (of_nat (fact n))" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4270 |
by (simp add: foldl_mult_start foldr_mult_foldl) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4271 |
|
52891 | 4272 |
lemma F_E[simp]: "F [] [] c = E c" |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4273 |
by (simp add: fps_eq_iff) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4274 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4275 |
lemma F_1_0[simp]: "F [1] [] c = 1/(1 - fps_const c * X)" |
52902 | 4276 |
proof - |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4277 |
let ?a = "(Abs_fps (\<lambda>n. 1)) oo (fps_const c * X)" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4278 |
have th0: "(fps_const c * X) $ 0 = 0" by simp |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4279 |
show ?thesis unfolding gp[OF th0, symmetric] |
53196 | 4280 |
by (auto simp add: fps_eq_iff pochhammer_fact[symmetric] |
57418 | 4281 |
fps_compose_nth power_mult_distrib cond_value_iff setsum.delta' cong del: if_weak_cong) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4282 |
qed |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4283 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4284 |
lemma F_B[simp]: "F [-a] [] (- 1) = fps_binomial a" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4285 |
by (simp add: fps_eq_iff gbinomial_pochhammer algebra_simps) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4286 |
|
60501 | 4287 |
lemma F_0[simp]: "F as bs c $ 0 = 1" |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4288 |
apply simp |
54452 | 4289 |
apply (subgoal_tac "\<forall>as. foldl (\<lambda>(r::'a) (a::'a). r) 1 as = 1") |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4290 |
apply auto |
48757 | 4291 |
apply (induct_tac as) |
4292 |
apply auto |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4293 |
done |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4294 |
|
53196 | 4295 |
lemma foldl_prod_prod: |
54452 | 4296 |
"foldl (\<lambda>(r::'b::comm_ring_1) (x::'a::comm_ring_1). r * f x) v as * foldl (\<lambda>r x. r * g x) w as = |
4297 |
foldl (\<lambda>r x. r * f x * g x) (v * w) as" |
|
48757 | 4298 |
by (induct as arbitrary: v w) (auto simp add: algebra_simps) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4299 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4300 |
|
53196 | 4301 |
lemma F_rec: |
54452 | 4302 |
"F as bs c $ Suc n = ((foldl (\<lambda>r a. r* (a + of_nat n)) c as) / |
4303 |
(foldl (\<lambda>r b. r * (b + of_nat n)) (of_nat (Suc n)) bs )) * F as bs c $ n" |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4304 |
apply (simp del: of_nat_Suc of_nat_add fact_Suc) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4305 |
apply (simp add: foldl_mult_start del: fact_Suc of_nat_Suc) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4306 |
unfolding foldl_prod_prod[unfolded foldl_mult_start] pochhammer_Suc |
52902 | 4307 |
apply (simp add: algebra_simps of_nat_mult) |
4308 |
done |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4309 |
|
54452 | 4310 |
lemma XD_nth[simp]: "XD a $ n = (if n = 0 then 0 else of_nat n * a$n)" |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4311 |
by (simp add: XD_def) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4312 |
|
60501 | 4313 |
lemma XD_0th[simp]: "XD a $ 0 = 0" |
4314 |
by simp |
|
4315 |
lemma XD_Suc[simp]:" XD a $ Suc n = of_nat (Suc n) * a $ Suc n" |
|
4316 |
by simp |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4317 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4318 |
definition "XDp c a = XD a + fps_const c * a" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4319 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4320 |
lemma XDp_nth[simp]: "XDp c a $ n = (c + of_nat n) * a$n" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4321 |
by (simp add: XDp_def algebra_simps) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4322 |
|
54681 | 4323 |
lemma XDp_commute: "XDp b \<circ> XDp (c::'a::comm_ring_1) = XDp c \<circ> XDp b" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
4324 |
by (auto simp add: XDp_def fun_eq_iff fps_eq_iff algebra_simps) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4325 |
|
52902 | 4326 |
lemma XDp0 [simp]: "XDp 0 = XD" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
4327 |
by (simp add: fun_eq_iff fps_eq_iff) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4328 |
|
52902 | 4329 |
lemma XDp_fps_integral [simp]: "XDp 0 (fps_integral a c) = X * a" |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4330 |
by (simp add: fps_eq_iff fps_integral_def) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4331 |
|
52891 | 4332 |
lemma F_minus_nat: |
59867
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
haftmann
parents:
59862
diff
changeset
|
4333 |
"F [- of_nat n] [- of_nat (n + m)] (c::'a::{field_char_0,field}) $ k = |
54452 | 4334 |
(if k \<le> n then |
52902 | 4335 |
pochhammer (- of_nat n) k * c ^ k / (pochhammer (- of_nat (n + m)) k * of_nat (fact k)) |
4336 |
else 0)" |
|
59867
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
haftmann
parents:
59862
diff
changeset
|
4337 |
"F [- of_nat m] [- of_nat (m + n)] (c::'a::{field_char_0,field}) $ k = |
54452 | 4338 |
(if k \<le> m then |
52902 | 4339 |
pochhammer (- of_nat m) k * c ^ k / (pochhammer (- of_nat (m + n)) k * of_nat (fact k)) |
4340 |
else 0)" |
|
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4341 |
by (auto simp add: pochhammer_eq_0_iff) |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4342 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4343 |
lemma setsum_eq_if: "setsum f {(n::nat) .. m} = (if m < n then 0 else f n + setsum f {n+1 .. m})" |
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4344 |
apply simp |
57418 | 4345 |
apply (subst setsum.insert[symmetric]) |
52902 | 4346 |
apply (auto simp add: not_less setsum_head_Suc) |
4347 |
done |
|
4348 |
||
4349 |
lemma pochhammer_rec_if: "pochhammer a n = (if n = 0 then 1 else a * pochhammer (a + 1) (n - 1))" |
|
4350 |
by (cases n) (simp_all add: pochhammer_rec) |
|
4351 |
||
54681 | 4352 |
lemma XDp_foldr_nth [simp]: "foldr (\<lambda>c r. XDp c \<circ> r) cs (\<lambda>c. XDp c a) c0 $ n = |
54452 | 4353 |
foldr (\<lambda>c r. (c + of_nat n) * r) cs (c0 + of_nat n) * a$n" |
48757 | 4354 |
by (induct cs arbitrary: c0) (auto simp add: algebra_simps) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4355 |
|
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4356 |
lemma genric_XDp_foldr_nth: |
54452 | 4357 |
assumes f: "\<forall>n c a. f c a $ n = (of_nat n + k c) * a$n" |
54681 | 4358 |
shows "foldr (\<lambda>c r. f c \<circ> r) cs (\<lambda>c. g c a) c0 $ n = |
54452 | 4359 |
foldr (\<lambda>c r. (k c + of_nat n) * r) cs (g c0 a $ n)" |
48757 | 4360 |
by (induct cs arbitrary: c0) (auto simp add: algebra_simps f) |
32160
63686057cbe8
Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents:
32157
diff
changeset
|
4361 |
|
51107 | 4362 |
lemma dist_less_imp_nth_equal: |
4363 |
assumes "dist f g < inverse (2 ^ i)" |
|
52902 | 4364 |
and"j \<le> i" |
51107 | 4365 |
shows "f $ j = g $ j" |
54263
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents:
54230
diff
changeset
|
4366 |
proof (rule ccontr) |
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents:
54230
diff
changeset
|
4367 |
assume "f $ j \<noteq> g $ j" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4368 |
hence "f \<noteq> g" by auto |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4369 |
with assms have "i < subdegree (f - g)" |
51107 | 4370 |
by (simp add: split_if_asm dist_fps_def) |
54263
c4159fe6fa46
move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents:
54230
diff
changeset
|
4371 |
also have "\<dots> \<le> j" |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4372 |
using \<open>f $ j \<noteq> g $ j\<close> by (intro subdegree_leI) simp_all |
60500 | 4373 |
finally show False using \<open>j \<le> i\<close> by simp |
52902 | 4374 |
qed |
51107 | 4375 |
|
4376 |
lemma nth_equal_imp_dist_less: |
|
4377 |
assumes "\<And>j. j \<le> i \<Longrightarrow> f $ j = g $ j" |
|
4378 |
shows "dist f g < inverse (2 ^ i)" |
|
52902 | 4379 |
proof (cases "f = g") |
60501 | 4380 |
case True |
4381 |
then show ?thesis by simp |
|
4382 |
next |
|
52902 | 4383 |
case False |
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4384 |
with assms have "dist f g = inverse (2 ^ subdegree (f - g))" |
51107 | 4385 |
by (simp add: split_if_asm dist_fps_def) |
4386 |
moreover |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4387 |
from assms and False have "i < subdegree (f - g)" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4388 |
by (intro subdegree_greaterI) simp_all |
51107 | 4389 |
ultimately show ?thesis by simp |
60501 | 4390 |
qed |
52902 | 4391 |
|
4392 |
lemma dist_less_eq_nth_equal: "dist f g < inverse (2 ^ i) \<longleftrightarrow> (\<forall>j \<le> i. f $ j = g $ j)" |
|
51107 | 4393 |
using dist_less_imp_nth_equal nth_equal_imp_dist_less by blast |
4394 |
||
4395 |
instance fps :: (comm_ring_1) complete_space |
|
4396 |
proof |
|
54681 | 4397 |
fix X :: "nat \<Rightarrow> 'a fps" |
51107 | 4398 |
assume "Cauchy X" |
60501 | 4399 |
obtain M where M: "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. X (M i) $ j = X m $ j" |
4400 |
proof - |
|
4401 |
have "\<exists>M. \<forall>m \<ge> M. \<forall>j\<le>i. X M $ j = X m $ j" for i |
|
4402 |
proof - |
|
4403 |
have "0 < inverse ((2::real)^i)" by simp |
|
4404 |
from metric_CauchyD[OF \<open>Cauchy X\<close> this] dist_less_imp_nth_equal |
|
4405 |
show ?thesis by blast |
|
4406 |
qed |
|
4407 |
then show ?thesis using that by metis |
|
4408 |
qed |
|
4409 |
||
51107 | 4410 |
show "convergent X" |
4411 |
proof (rule convergentI) |
|
4412 |
show "X ----> Abs_fps (\<lambda>i. X (M i) $ i)" |
|
4413 |
unfolding tendsto_iff |
|
4414 |
proof safe |
|
61608
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4415 |
fix e::real assume e: "0 < e" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4416 |
have "(\<lambda>n. inverse (2 ^ n) :: real) ----> 0" by (rule LIMSEQ_inverse_realpow_zero) simp_all |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4417 |
from this and e have "eventually (\<lambda>i. inverse (2 ^ i) < e) sequentially" |
a0487caabb4a
subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents:
61585
diff
changeset
|
4418 |
by (rule order_tendstoD) |
60501 | 4419 |
then obtain i where "inverse (2 ^ i) < e" |
4420 |
by (auto simp: eventually_sequentially) |
|
4421 |
have "eventually (\<lambda>x. M i \<le> x) sequentially" |
|
4422 |
by (auto simp: eventually_sequentially) |
|
54452 | 4423 |
then show "eventually (\<lambda>x. dist (X x) (Abs_fps (\<lambda>i. X (M i) $ i)) < e) sequentially" |
51107 | 4424 |
proof eventually_elim |
52902 | 4425 |
fix x |
60501 | 4426 |
assume x: "M i \<le> x" |
4427 |
have "X (M i) $ j = X (M j) $ j" if "j \<le> i" for j |
|
4428 |
using M that by (metis nat_le_linear) |
|
4429 |
with x have "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < inverse (2 ^ i)" |
|
51107 | 4430 |
using M by (force simp: dist_less_eq_nth_equal) |
60500 | 4431 |
also note \<open>inverse (2 ^ i) < e\<close> |
51107 | 4432 |
finally show "dist (X x) (Abs_fps (\<lambda>j. X (M j) $ j)) < e" . |
4433 |
qed |
|
4434 |
qed |
|
4435 |
qed |
|
4436 |
qed |
|
4437 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
4438 |
end |