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