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