author | chaieb |
Mon, 01 Jun 2009 09:26:28 +0200 | |
changeset 31369 | 8b460fd12100 |
parent 31199 | 10d413b08fa7 |
child 31370 | a551bbe49659 |
permissions | -rw-r--r-- |
29687 | 1 |
(* Title: Formal_Power_Series.thy |
2 |
Author: Amine Chaieb, University of Cambridge |
|
3 |
*) |
|
4 |
||
5 |
header{* A formalization of formal power series *} |
|
6 |
||
7 |
theory Formal_Power_Series |
|
30661 | 8 |
imports Main Fact Parity |
29687 | 9 |
begin |
10 |
||
29906 | 11 |
subsection {* The type of formal power series*} |
29687 | 12 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
13 |
typedef (open) 'a fps = "{f :: nat \<Rightarrow> 'a. True}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
14 |
morphisms fps_nth Abs_fps |
29687 | 15 |
by simp |
16 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
17 |
notation fps_nth (infixl "$" 75) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
18 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
19 |
lemma expand_fps_eq: "p = q \<longleftrightarrow> (\<forall>n. p $ n = q $ n)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
20 |
by (simp add: fps_nth_inject [symmetric] expand_fun_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
21 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
22 |
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
|
23 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
24 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
25 |
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
|
26 |
by (simp add: Abs_fps_inverse) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
27 |
|
29687 | 28 |
text{* Definition of the basic elements 0 and 1 and the basic operations of addition, negation and multiplication *} |
29 |
||
30 |
instantiation fps :: (zero) zero |
|
31 |
begin |
|
32 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
33 |
definition fps_zero_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
34 |
"0 = Abs_fps (\<lambda>n. 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
35 |
|
29687 | 36 |
instance .. |
37 |
end |
|
38 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
39 |
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
|
40 |
unfolding fps_zero_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
41 |
|
29687 | 42 |
instantiation fps :: ("{one,zero}") one |
43 |
begin |
|
44 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
45 |
definition fps_one_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
46 |
"1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
47 |
|
29687 | 48 |
instance .. |
49 |
end |
|
50 |
||
30488 | 51 |
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
|
52 |
unfolding fps_one_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
53 |
|
29687 | 54 |
instantiation fps :: (plus) plus |
55 |
begin |
|
56 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
57 |
definition fps_plus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
58 |
"op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
59 |
|
29687 | 60 |
instance .. |
61 |
end |
|
62 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
63 |
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
|
64 |
unfolding fps_plus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
65 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
66 |
instantiation fps :: (minus) minus |
29687 | 67 |
begin |
68 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
69 |
definition fps_minus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
70 |
"op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
71 |
|
29687 | 72 |
instance .. |
73 |
end |
|
74 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
75 |
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
|
76 |
unfolding fps_minus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
77 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
78 |
instantiation fps :: (uminus) uminus |
29687 | 79 |
begin |
80 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
81 |
definition fps_uminus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
82 |
"uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
83 |
|
29687 | 84 |
instance .. |
85 |
end |
|
86 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
87 |
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
|
88 |
unfolding fps_uminus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
89 |
|
29687 | 90 |
instantiation fps :: ("{comm_monoid_add, times}") times |
91 |
begin |
|
92 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
93 |
definition fps_times_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
94 |
"op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
95 |
|
29687 | 96 |
instance .. |
97 |
end |
|
98 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
99 |
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
|
100 |
unfolding fps_times_def by simp |
29687 | 101 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
102 |
declare atLeastAtMost_iff[presburger] |
29687 | 103 |
declare Bex_def[presburger] |
104 |
declare Ball_def[presburger] |
|
105 |
||
29913 | 106 |
lemma mult_delta_left: |
107 |
fixes x y :: "'a::mult_zero" |
|
108 |
shows "(if b then x else 0) * y = (if b then x * y else 0)" |
|
109 |
by simp |
|
110 |
||
111 |
lemma mult_delta_right: |
|
112 |
fixes x y :: "'a::mult_zero" |
|
113 |
shows "x * (if b then y else 0) = (if b then x * y else 0)" |
|
114 |
by simp |
|
115 |
||
29687 | 116 |
lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)" |
117 |
by auto |
|
118 |
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" |
|
119 |
by auto |
|
120 |
||
30488 | 121 |
subsection{* Formal power series form a commutative ring with unity, if the range of sequences |
29687 | 122 |
they represent is a commutative ring with unity*} |
123 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
124 |
instance fps :: (semigroup_add) semigroup_add |
29687 | 125 |
proof |
126 |
fix a b c :: "'a fps" show "a + b + c = a + (b + c)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
127 |
by (simp add: fps_ext add_assoc) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
128 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
129 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
130 |
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
|
131 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
132 |
fix a b :: "'a fps" show "a + b = b + a" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
133 |
by (simp add: fps_ext add_commute) |
29687 | 134 |
qed |
135 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
136 |
lemma fps_mult_assoc_lemma: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
137 |
fixes k :: nat and f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
138 |
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
|
139 |
(\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
140 |
proof (induct k) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
141 |
case 0 show ?case by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
142 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
143 |
case (Suc k) thus ?case |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
144 |
by (simp add: Suc_diff_le setsum_addf add_assoc |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
145 |
cong: strong_setsum_cong) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
146 |
qed |
29687 | 147 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
148 |
instance fps :: (semiring_0) semigroup_mult |
29687 | 149 |
proof |
150 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
151 |
show "(a * b) * c = a * (b * c)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
152 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
153 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
154 |
have "(\<Sum>j=0..n. \<Sum>i=0..j. a$i * b$(j - i) * c$(n - j)) = |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
155 |
(\<Sum>j=0..n. \<Sum>i=0..n - j. a$j * b$i * c$(n - j - i))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
156 |
by (rule fps_mult_assoc_lemma) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
157 |
thus "((a * b) * c) $ n = (a * (b * c)) $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
158 |
by (simp add: fps_mult_nth setsum_right_distrib |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
159 |
setsum_left_distrib mult_assoc) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
160 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
161 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
162 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
163 |
lemma fps_mult_commute_lemma: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
164 |
fixes n :: nat and f :: "nat \<Rightarrow> nat \<Rightarrow> 'a::comm_monoid_add" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
165 |
shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
166 |
proof (rule setsum_reindex_cong) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
167 |
show "inj_on (\<lambda>i. n - i) {0..n}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
168 |
by (rule inj_onI) simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
169 |
show "{0..n} = (\<lambda>i. n - i) ` {0..n}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
170 |
by (auto, rule_tac x="n - x" in image_eqI, simp_all) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
171 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
172 |
fix i assume "i \<in> {0..n}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
173 |
hence "n - (n - i) = i" by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
174 |
thus "f (n - i) i = f (n - i) (n - (n - i))" by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
175 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
176 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
177 |
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
|
178 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
179 |
fix a b :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
180 |
show "a * b = b * a" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
181 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
182 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
183 |
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
|
184 |
by (rule fps_mult_commute_lemma) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
185 |
thus "(a * b) $ n = (b * a) $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
186 |
by (simp add: fps_mult_nth mult_commute) |
29687 | 187 |
qed |
188 |
qed |
|
189 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
190 |
instance fps :: (monoid_add) monoid_add |
29687 | 191 |
proof |
192 |
fix a :: "'a fps" show "0 + a = a " |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
193 |
by (simp add: fps_ext) |
29687 | 194 |
next |
195 |
fix a :: "'a fps" show "a + 0 = a " |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
196 |
by (simp add: fps_ext) |
29687 | 197 |
qed |
198 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
199 |
instance fps :: (comm_monoid_add) comm_monoid_add |
29687 | 200 |
proof |
201 |
fix a :: "'a fps" show "0 + a = a " |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
202 |
by (simp add: fps_ext) |
29687 | 203 |
qed |
204 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
205 |
instance fps :: (semiring_1) monoid_mult |
29687 | 206 |
proof |
207 |
fix a :: "'a fps" show "1 * a = a" |
|
29913 | 208 |
by (simp add: fps_ext fps_mult_nth mult_delta_left setsum_delta) |
29687 | 209 |
next |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
210 |
fix a :: "'a fps" show "a * 1 = a" |
29913 | 211 |
by (simp add: fps_ext fps_mult_nth mult_delta_right setsum_delta') |
29687 | 212 |
qed |
213 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
214 |
instance fps :: (cancel_semigroup_add) cancel_semigroup_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
215 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
216 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
217 |
assume "a + b = a + c" then show "b = c" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
218 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
219 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
220 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
221 |
assume "b + a = c + a" then show "b = c" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
222 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
223 |
qed |
29687 | 224 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
225 |
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
|
226 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
227 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
228 |
assume "a + b = a + c" then show "b = c" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
229 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
230 |
qed |
29687 | 231 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
232 |
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
|
233 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
234 |
instance fps :: (group_add) group_add |
29687 | 235 |
proof |
236 |
fix a :: "'a fps" show "- a + a = 0" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
237 |
by (simp add: fps_ext) |
29687 | 238 |
next |
239 |
fix a b :: "'a fps" show "a - b = a + - b" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
240 |
by (simp add: fps_ext diff_minus) |
29687 | 241 |
qed |
242 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
243 |
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
|
244 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
245 |
fix a :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
246 |
show "- a + a = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
247 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
248 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
249 |
fix a b :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
250 |
show "a - b = a + - b" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
251 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
252 |
qed |
29687 | 253 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
254 |
instance fps :: (zero_neq_one) zero_neq_one |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
255 |
by default (simp add: expand_fps_eq) |
29687 | 256 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
257 |
instance fps :: (semiring_0) semiring |
29687 | 258 |
proof |
259 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
260 |
show "(a + b) * c = a * c + b * c" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
261 |
by (simp add: expand_fps_eq fps_mult_nth left_distrib setsum_addf) |
29687 | 262 |
next |
263 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
264 |
show "a * (b + c) = a * b + a * c" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
265 |
by (simp add: expand_fps_eq fps_mult_nth right_distrib setsum_addf) |
29687 | 266 |
qed |
267 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
268 |
instance fps :: (semiring_0) semiring_0 |
29687 | 269 |
proof |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
270 |
fix a:: "'a fps" show "0 * a = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
271 |
by (simp add: fps_ext fps_mult_nth) |
29687 | 272 |
next |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
273 |
fix a:: "'a fps" show "a * 0 = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
274 |
by (simp add: fps_ext fps_mult_nth) |
29687 | 275 |
qed |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
276 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
277 |
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
|
278 |
|
29906 | 279 |
subsection {* Selection of the nth power of the implicit variable in the infinite sum*} |
29687 | 280 |
|
281 |
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
|
282 |
by (simp add: expand_fps_eq) |
29687 | 283 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
284 |
lemma fps_nonzero_nth_minimal: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
285 |
"f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
286 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
287 |
let ?n = "LEAST n. f $ n \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
288 |
assume "f \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
289 |
then have "\<exists>n. f $ n \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
290 |
by (simp add: fps_nonzero_nth) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
291 |
then have "f $ ?n \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
292 |
by (rule LeastI_ex) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
293 |
moreover have "\<forall>m<?n. f $ m = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
294 |
by (auto dest: not_less_Least) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
295 |
ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" .. |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
296 |
then show "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)" .. |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
297 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
298 |
assume "\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m<n. f $ m = 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
299 |
then show "f \<noteq> 0" by (auto simp add: expand_fps_eq) |
29687 | 300 |
qed |
301 |
||
302 |
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
|
303 |
by (rule expand_fps_eq) |
29687 | 304 |
|
30488 | 305 |
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
|
306 |
proof (cases "finite S") |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
307 |
assume "\<not> finite S" then show ?thesis by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
308 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
309 |
assume "finite S" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
310 |
then show ?thesis by (induct set: finite) auto |
29687 | 311 |
qed |
312 |
||
29906 | 313 |
subsection{* Injection of the basic ring elements and multiplication by scalars *} |
29687 | 314 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
315 |
definition |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
316 |
"fps_const c = Abs_fps (\<lambda>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
|
317 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
318 |
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
|
319 |
unfolding fps_const_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
320 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
321 |
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
|
322 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
323 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
324 |
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
|
325 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
326 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
327 |
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
|
328 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
329 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
330 |
lemma fps_const_add [simp]: "fps_const (c::'a\<Colon>monoid_add) + fps_const d = fps_const (c + d)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
331 |
by (simp add: fps_ext) |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
332 |
lemma fps_const_sub [simp]: "fps_const (c::'a\<Colon>group_add) - fps_const d = fps_const (c - d)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
333 |
by (simp add: fps_ext) |
29687 | 334 |
lemma fps_const_mult[simp]: "fps_const (c::'a\<Colon>ring) * fps_const d = fps_const (c * d)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
335 |
by (simp add: fps_eq_iff fps_mult_nth setsum_0') |
29687 | 336 |
|
337 |
lemma fps_const_add_left: "fps_const (c::'a\<Colon>monoid_add) + f = 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
|
338 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
339 |
|
29687 | 340 |
lemma fps_const_add_right: "f + fps_const (c::'a\<Colon>monoid_add) = 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
|
341 |
by (simp add: fps_ext) |
29687 | 342 |
|
343 |
lemma fps_const_mult_left: "fps_const (c::'a\<Colon>semiring_0) * f = Abs_fps (\<lambda>n. c * f$n)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
344 |
unfolding fps_eq_iff fps_mult_nth |
29913 | 345 |
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
|
346 |
|
29687 | 347 |
lemma fps_const_mult_right: "f * fps_const (c::'a\<Colon>semiring_0) = Abs_fps (\<lambda>n. f$n * c)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
348 |
unfolding fps_eq_iff fps_mult_nth |
29913 | 349 |
by (simp add: fps_const_def mult_delta_right setsum_delta') |
29687 | 350 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
351 |
lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n" |
29913 | 352 |
by (simp add: fps_mult_nth mult_delta_left setsum_delta) |
29687 | 353 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
354 |
lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c" |
29913 | 355 |
by (simp add: fps_mult_nth mult_delta_right setsum_delta') |
29687 | 356 |
|
29906 | 357 |
subsection {* Formal power series form an integral domain*} |
29687 | 358 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
359 |
instance fps :: (ring) ring .. |
29687 | 360 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
361 |
instance fps :: (ring_1) ring_1 |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
362 |
by (intro_classes, auto simp add: diff_minus left_distrib) |
29687 | 363 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
364 |
instance fps :: (comm_ring_1) comm_ring_1 |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
365 |
by (intro_classes, auto simp add: diff_minus left_distrib) |
29687 | 366 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
367 |
instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors |
29687 | 368 |
proof |
369 |
fix a b :: "'a fps" |
|
370 |
assume a0: "a \<noteq> 0" and b0: "b \<noteq> 0" |
|
371 |
then obtain i j where i: "a$i\<noteq>0" "\<forall>k<i. a$k=0" |
|
372 |
and j: "b$j \<noteq>0" "\<forall>k<j. b$k =0" unfolding fps_nonzero_nth_minimal |
|
373 |
by blast+ |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
374 |
have "(a * b) $ (i+j) = (\<Sum>k=0..i+j. a$k * b$(i+j-k))" |
29687 | 375 |
by (rule fps_mult_nth) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
376 |
also have "\<dots> = (a$i * b$(i+j-i)) + (\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
377 |
by (rule setsum_diff1') simp_all |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
378 |
also have "(\<Sum>k\<in>{0..i+j}-{i}. a$k * b$(i+j-k)) = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
379 |
proof (rule setsum_0' [rule_format]) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
380 |
fix k assume "k \<in> {0..i+j} - {i}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
381 |
then have "k < i \<or> i+j-k < j" by auto |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
382 |
then show "a$k * b$(i+j-k) = 0" using i j by auto |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
383 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
384 |
also have "a$i * b$(i+j-i) + 0 = a$i * b$j" by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
385 |
also have "a$i * b$j \<noteq> 0" using i j by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
386 |
finally have "(a*b) $ (i+j) \<noteq> 0" . |
29687 | 387 |
then show "a*b \<noteq> 0" unfolding fps_nonzero_nth by blast |
388 |
qed |
|
389 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
390 |
instance fps :: (idom) idom .. |
29687 | 391 |
|
30746 | 392 |
instantiation fps :: (comm_ring_1) number_ring |
393 |
begin |
|
394 |
definition number_of_fps_def: "(number_of k::'a fps) = of_int k" |
|
395 |
||
396 |
instance |
|
397 |
by (intro_classes, rule number_of_fps_def) |
|
398 |
end |
|
399 |
||
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
400 |
lemma number_of_fps_const: "(number_of k::('a::comm_ring_1) fps) = fps_const (of_int k)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
401 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
402 |
proof(induct k rule: int_induct[where k=0]) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
403 |
case base thus ?case unfolding number_of_fps_def of_int_0 by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
404 |
next |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
405 |
case (step1 i) thus ?case unfolding number_of_fps_def |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
406 |
by (simp add: fps_const_add[symmetric] del: fps_const_add) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
407 |
next |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
408 |
case (step2 i) thus ?case unfolding number_of_fps_def |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
409 |
by (simp add: fps_const_sub[symmetric] del: fps_const_sub) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
410 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
411 |
|
29906 | 412 |
subsection{* Inverses of formal power series *} |
29687 | 413 |
|
414 |
declare setsum_cong[fundef_cong] |
|
415 |
||
416 |
||
417 |
instantiation fps :: ("{comm_monoid_add,inverse, times, uminus}") inverse |
|
418 |
begin |
|
419 |
||
30488 | 420 |
fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a" where |
29687 | 421 |
"natfun_inverse f 0 = inverse (f$0)" |
30488 | 422 |
| "natfun_inverse f n = - inverse (f$0) * setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}" |
29687 | 423 |
|
30488 | 424 |
definition fps_inverse_def: |
29687 | 425 |
"inverse f = (if f$0 = 0 then 0 else Abs_fps (natfun_inverse f))" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
426 |
definition fps_divide_def: "divide = (\<lambda>(f::'a fps) g. f * inverse g)" |
29687 | 427 |
instance .. |
428 |
end |
|
429 |
||
30488 | 430 |
lemma fps_inverse_zero[simp]: |
29687 | 431 |
"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
|
432 |
by (simp add: fps_ext fps_inverse_def) |
29687 | 433 |
|
434 |
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
|
435 |
apply (auto simp add: expand_fps_eq fps_inverse_def) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
436 |
by (case_tac n, auto) |
29687 | 437 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
438 |
instance fps :: ("{comm_monoid_add,inverse, times, uminus}") division_by_zero |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
439 |
by default (rule fps_inverse_zero) |
29687 | 440 |
|
441 |
lemma inverse_mult_eq_1[intro]: assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
442 |
shows "inverse f * f = 1" |
|
443 |
proof- |
|
444 |
have c: "inverse f * f = f * inverse f" by (simp add: mult_commute) |
|
30488 | 445 |
from f0 have ifn: "\<And>n. inverse f $ n = natfun_inverse f n" |
29687 | 446 |
by (simp add: fps_inverse_def) |
447 |
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
|
448 |
by (simp add: fps_mult_nth fps_inverse_def) |
29687 | 449 |
{fix n::nat assume np: "n >0 " |
450 |
from np have eq: "{0..n} = {0} \<union> {1 .. n}" by auto |
|
451 |
have d: "{0} \<inter> {1 .. n} = {}" by auto |
|
452 |
have f: "finite {0::nat}" "finite {1..n}" by auto |
|
30488 | 453 |
from f0 np have th0: "- (inverse f$n) = |
29687 | 454 |
(setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}) / (f$0)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
455 |
by (cases n, simp, simp add: divide_inverse fps_inverse_def) |
29687 | 456 |
from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]] |
30488 | 457 |
have th1: "setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n} = |
458 |
- (f$0) * (inverse f)$n" |
|
29687 | 459 |
by (simp add: ring_simps) |
30488 | 460 |
have "(f * inverse f) $ n = (\<Sum>i = 0..n. f $i * natfun_inverse f (n - i))" |
29687 | 461 |
unfolding fps_mult_nth ifn .. |
30488 | 462 |
also have "\<dots> = f$0 * natfun_inverse f n |
29687 | 463 |
+ (\<Sum>i = 1..n. f$i * natfun_inverse f (n-i))" |
464 |
unfolding setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] |
|
465 |
by simp |
|
466 |
also have "\<dots> = 0" unfolding th1 ifn by simp |
|
467 |
finally have "(inverse f * f)$n = 0" unfolding c . } |
|
468 |
with th0 show ?thesis by (simp add: fps_eq_iff) |
|
469 |
qed |
|
470 |
||
471 |
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
|
472 |
by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero) |
29687 | 473 |
|
474 |
lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::field) fps) \<longleftrightarrow> f $0 = 0" |
|
475 |
proof- |
|
476 |
{assume "f$0 = 0" hence "inverse f = 0" by (simp add: fps_inverse_def)} |
|
477 |
moreover |
|
478 |
{assume h: "inverse f = 0" and c: "f $0 \<noteq> 0" |
|
479 |
from inverse_mult_eq_1[OF c] h have False by simp} |
|
480 |
ultimately show ?thesis by blast |
|
481 |
qed |
|
482 |
||
483 |
lemma fps_inverse_idempotent[intro]: assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
484 |
shows "inverse (inverse f) = f" |
|
485 |
proof- |
|
486 |
from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp |
|
30488 | 487 |
from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0] |
29687 | 488 |
have th0: "inverse f * f = inverse f * inverse (inverse f)" by (simp add: mult_ac) |
489 |
then show ?thesis using f0 unfolding mult_cancel_left by simp |
|
490 |
qed |
|
491 |
||
30488 | 492 |
lemma fps_inverse_unique: assumes f0: "f$0 \<noteq> (0::'a::field)" and fg: "f*g = 1" |
29687 | 493 |
shows "inverse f = g" |
494 |
proof- |
|
495 |
from inverse_mult_eq_1[OF f0] fg |
|
496 |
have th0: "inverse f * f = g * f" by (simp add: mult_ac) |
|
497 |
then show ?thesis using f0 unfolding mult_cancel_right |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
498 |
by (auto simp add: expand_fps_eq) |
29687 | 499 |
qed |
500 |
||
30488 | 501 |
lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) |
29687 | 502 |
= Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)" |
503 |
apply (rule fps_inverse_unique) |
|
504 |
apply simp |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
505 |
apply (simp add: fps_eq_iff fps_mult_nth) |
29687 | 506 |
proof(clarsimp) |
507 |
fix n::nat assume n: "n > 0" |
|
508 |
let ?f = "\<lambda>i. if n = i then (1\<Colon>'a) else if n - i = 1 then - 1 else 0" |
|
509 |
let ?g = "\<lambda>i. if i = n then 1 else if i=n - 1 then - 1 else 0" |
|
510 |
let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0" |
|
30488 | 511 |
have th1: "setsum ?f {0..n} = setsum ?g {0..n}" |
29687 | 512 |
by (rule setsum_cong2) auto |
30488 | 513 |
have th2: "setsum ?g {0..n - 1} = setsum ?h {0..n - 1}" |
29687 | 514 |
using n apply - by (rule setsum_cong2) auto |
515 |
have eq: "{0 .. n} = {0.. n - 1} \<union> {n}" by auto |
|
30488 | 516 |
from n have d: "{0.. n - 1} \<inter> {n} = {}" by auto |
29687 | 517 |
have f: "finite {0.. n - 1}" "finite {n}" by auto |
518 |
show "setsum ?f {0..n} = 0" |
|
30488 | 519 |
unfolding th1 |
29687 | 520 |
apply (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def) |
521 |
unfolding th2 |
|
522 |
by(simp add: setsum_delta) |
|
523 |
qed |
|
524 |
||
29912 | 525 |
subsection{* Formal Derivatives, and the MacLaurin theorem around 0*} |
29687 | 526 |
|
527 |
definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" |
|
528 |
||
529 |
lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n+1)" by (simp add: fps_deriv_def) |
|
530 |
||
531 |
lemma fps_deriv_linear[simp]: "fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = fps_const a * fps_deriv f + fps_const b * fps_deriv g" |
|
532 |
unfolding fps_eq_iff fps_add_nth fps_const_mult_left fps_deriv_nth by (simp add: ring_simps) |
|
533 |
||
30488 | 534 |
lemma fps_deriv_mult[simp]: |
29687 | 535 |
fixes f :: "('a :: comm_ring_1) fps" |
536 |
shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g" |
|
537 |
proof- |
|
538 |
let ?D = "fps_deriv" |
|
539 |
{fix n::nat |
|
540 |
let ?Zn = "{0 ..n}" |
|
541 |
let ?Zn1 = "{0 .. n + 1}" |
|
542 |
let ?f = "\<lambda>i. i + 1" |
|
543 |
have fi: "inj_on ?f {0..n}" by (simp add: inj_on_def) |
|
544 |
have eq: "{1.. n+1} = ?f ` {0..n}" by auto |
|
545 |
let ?g = "\<lambda>i. of_nat (i+1) * g $ (i+1) * f $ (n - i) + |
|
546 |
of_nat (i+1)* f $ (i+1) * g $ (n - i)" |
|
547 |
let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) + |
|
548 |
of_nat i* f $ i * g $ ((n + 1) - i)" |
|
549 |
{fix k assume k: "k \<in> {0..n}" |
|
550 |
have "?h (k + 1) = ?g k" using k by auto} |
|
551 |
note th0 = this |
|
552 |
have eq': "{0..n +1}- {1 .. n+1} = {0}" by auto |
|
553 |
have s0: "setsum (\<lambda>i. of_nat i * f $ i * g $ (n + 1 - i)) ?Zn1 = setsum (\<lambda>i. of_nat (n + 1 - i) * f $ (n + 1 - i) * g $ i) ?Zn1" |
|
554 |
apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) |
|
555 |
apply (simp add: inj_on_def Ball_def) |
|
556 |
apply presburger |
|
557 |
apply (rule set_ext) |
|
558 |
apply (presburger add: image_iff) |
|
559 |
by simp |
|
560 |
have s1: "setsum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 = setsum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1" |
|
561 |
apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) |
|
562 |
apply (simp add: inj_on_def Ball_def) |
|
563 |
apply presburger |
|
564 |
apply (rule set_ext) |
|
565 |
apply (presburger add: image_iff) |
|
566 |
by simp |
|
567 |
have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n" by (simp only: mult_commute) |
|
568 |
also have "\<dots> = (\<Sum>i = 0..n. ?g i)" |
|
569 |
by (simp add: fps_mult_nth setsum_addf[symmetric]) |
|
570 |
also have "\<dots> = setsum ?h {1..n+1}" |
|
571 |
using th0 setsum_reindex_cong[OF fi eq, of "?g" "?h"] by auto |
|
572 |
also have "\<dots> = setsum ?h {0..n+1}" |
|
573 |
apply (rule setsum_mono_zero_left) |
|
574 |
apply simp |
|
575 |
apply (simp add: subset_eq) |
|
576 |
unfolding eq' |
|
577 |
by simp |
|
578 |
also have "\<dots> = (fps_deriv (f * g)) $ n" |
|
579 |
apply (simp only: fps_deriv_nth fps_mult_nth setsum_addf) |
|
580 |
unfolding s0 s1 |
|
581 |
unfolding setsum_addf[symmetric] setsum_right_distrib |
|
582 |
apply (rule setsum_cong2) |
|
583 |
by (auto simp add: of_nat_diff ring_simps) |
|
584 |
finally have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" .} |
|
30488 | 585 |
then show ?thesis unfolding fps_eq_iff by auto |
29687 | 586 |
qed |
587 |
||
588 |
lemma fps_deriv_neg[simp]: "fps_deriv (- (f:: ('a:: comm_ring_1) fps)) = - (fps_deriv f)" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
589 |
by (simp add: fps_eq_iff fps_deriv_def) |
29687 | 590 |
lemma fps_deriv_add[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) + g) = fps_deriv f + fps_deriv g" |
591 |
using fps_deriv_linear[of 1 f 1 g] by simp |
|
592 |
||
593 |
lemma fps_deriv_sub[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) - g) = fps_deriv f - fps_deriv g" |
|
30488 | 594 |
unfolding diff_minus by simp |
29687 | 595 |
|
596 |
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
|
597 |
by (simp add: fps_ext fps_deriv_def fps_const_def) |
29687 | 598 |
|
599 |
lemma fps_deriv_mult_const_left[simp]: "fps_deriv (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_deriv f" |
|
600 |
by simp |
|
601 |
||
602 |
lemma fps_deriv_0[simp]: "fps_deriv 0 = 0" |
|
603 |
by (simp add: fps_deriv_def fps_eq_iff) |
|
604 |
||
605 |
lemma fps_deriv_1[simp]: "fps_deriv 1 = 0" |
|
606 |
by (simp add: fps_deriv_def fps_eq_iff ) |
|
607 |
||
608 |
lemma fps_deriv_mult_const_right[simp]: "fps_deriv (f * fps_const (c::'a::comm_ring_1)) = fps_deriv f * fps_const c" |
|
609 |
by simp |
|
610 |
||
611 |
lemma fps_deriv_setsum: "fps_deriv (setsum f S) = setsum (\<lambda>i. fps_deriv (f i :: ('a::comm_ring_1) fps)) S" |
|
612 |
proof- |
|
613 |
{assume "\<not> finite S" hence ?thesis by simp} |
|
614 |
moreover |
|
615 |
{assume fS: "finite S" |
|
616 |
have ?thesis by (induct rule: finite_induct[OF fS], simp_all)} |
|
617 |
ultimately show ?thesis by blast |
|
618 |
qed |
|
619 |
||
620 |
lemma fps_deriv_eq_0_iff[simp]: "fps_deriv f = 0 \<longleftrightarrow> (f = fps_const (f$0 :: 'a::{idom,semiring_char_0}))" |
|
621 |
proof- |
|
622 |
{assume "f= fps_const (f$0)" hence "fps_deriv f = fps_deriv (fps_const (f$0))" by simp |
|
623 |
hence "fps_deriv f = 0" by simp } |
|
624 |
moreover |
|
625 |
{assume z: "fps_deriv f = 0" |
|
626 |
hence "\<forall>n. (fps_deriv f)$n = 0" by simp |
|
627 |
hence "\<forall>n. f$(n+1) = 0" by (simp del: of_nat_Suc of_nat_add One_nat_def) |
|
628 |
hence "f = fps_const (f$0)" |
|
629 |
apply (clarsimp simp add: fps_eq_iff fps_const_def) |
|
630 |
apply (erule_tac x="n - 1" in allE) |
|
631 |
by simp} |
|
632 |
ultimately show ?thesis by blast |
|
633 |
qed |
|
634 |
||
30488 | 635 |
lemma fps_deriv_eq_iff: |
29687 | 636 |
fixes f:: "('a::{idom,semiring_char_0}) fps" |
637 |
shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)" |
|
638 |
proof- |
|
639 |
have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0" by simp |
|
640 |
also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f-g)$0)" unfolding fps_deriv_eq_0_iff .. |
|
641 |
finally show ?thesis by (simp add: ring_simps) |
|
642 |
qed |
|
643 |
||
644 |
lemma fps_deriv_eq_iff_ex: "(fps_deriv f = fps_deriv g) \<longleftrightarrow> (\<exists>(c::'a::{idom,semiring_char_0}). f = fps_const c + g)" |
|
645 |
apply auto unfolding fps_deriv_eq_iff by blast |
|
30488 | 646 |
|
29687 | 647 |
|
648 |
fun fps_nth_deriv :: "nat \<Rightarrow> ('a::semiring_1) fps \<Rightarrow> 'a fps" where |
|
649 |
"fps_nth_deriv 0 f = f" |
|
650 |
| "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)" |
|
651 |
||
652 |
lemma fps_nth_deriv_commute: "fps_nth_deriv (Suc n) f = fps_deriv (fps_nth_deriv n f)" |
|
653 |
by (induct n arbitrary: f, auto) |
|
654 |
||
655 |
lemma fps_nth_deriv_linear[simp]: "fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g" |
|
656 |
by (induct n arbitrary: f g, auto simp add: fps_nth_deriv_commute) |
|
657 |
||
658 |
lemma fps_nth_deriv_neg[simp]: "fps_nth_deriv n (- (f:: ('a:: comm_ring_1) fps)) = - (fps_nth_deriv n f)" |
|
659 |
by (induct n arbitrary: f, simp_all) |
|
660 |
||
661 |
lemma fps_nth_deriv_add[simp]: "fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) + g) = fps_nth_deriv n f + fps_nth_deriv n g" |
|
662 |
using fps_nth_deriv_linear[of n 1 f 1 g] by simp |
|
663 |
||
664 |
lemma fps_nth_deriv_sub[simp]: "fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) - g) = fps_nth_deriv n f - fps_nth_deriv n g" |
|
30488 | 665 |
unfolding diff_minus fps_nth_deriv_add by simp |
29687 | 666 |
|
667 |
lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0" |
|
668 |
by (induct n, simp_all ) |
|
669 |
||
670 |
lemma fps_nth_deriv_1[simp]: "fps_nth_deriv n 1 = (if n = 0 then 1 else 0)" |
|
671 |
by (induct n, simp_all ) |
|
672 |
||
673 |
lemma fps_nth_deriv_const[simp]: "fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)" |
|
674 |
by (cases n, simp_all) |
|
675 |
||
676 |
lemma fps_nth_deriv_mult_const_left[simp]: "fps_nth_deriv n (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_nth_deriv n f" |
|
677 |
using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp |
|
678 |
||
679 |
lemma fps_nth_deriv_mult_const_right[simp]: "fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c" |
|
680 |
using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult_commute) |
|
681 |
||
682 |
lemma fps_nth_deriv_setsum: "fps_nth_deriv n (setsum f S) = setsum (\<lambda>i. fps_nth_deriv n (f i :: ('a::comm_ring_1) fps)) S" |
|
683 |
proof- |
|
684 |
{assume "\<not> finite S" hence ?thesis by simp} |
|
685 |
moreover |
|
686 |
{assume fS: "finite S" |
|
687 |
have ?thesis by (induct rule: finite_induct[OF fS], simp_all)} |
|
688 |
ultimately show ?thesis by blast |
|
689 |
qed |
|
690 |
||
691 |
lemma fps_deriv_maclauren_0: "(fps_nth_deriv k (f:: ('a::comm_semiring_1) fps)) $ 0 = of_nat (fact k) * f$(k)" |
|
692 |
by (induct k arbitrary: f) (auto simp add: ring_simps of_nat_mult) |
|
693 |
||
29906 | 694 |
subsection {* Powers*} |
29687 | 695 |
|
696 |
lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)" |
|
30960 | 697 |
by (induct n, auto simp add: expand_fps_eq fps_mult_nth) |
29687 | 698 |
|
699 |
lemma fps_power_first_eq: "(a:: 'a::comm_ring_1 fps)$0 =1 \<Longrightarrow> a^n $ 1 = of_nat n * a$1" |
|
700 |
proof(induct n) |
|
30960 | 701 |
case 0 thus ?case by simp |
29687 | 702 |
next |
703 |
case (Suc n) |
|
704 |
note h = Suc.hyps[OF `a$0 = 1`] |
|
30488 | 705 |
show ?case unfolding power_Suc fps_mult_nth |
29687 | 706 |
using h `a$0 = 1` fps_power_zeroth_eq_one[OF `a$0=1`] by (simp add: ring_simps) |
707 |
qed |
|
708 |
||
709 |
lemma startsby_one_power:"a $ 0 = (1::'a::comm_ring_1) \<Longrightarrow> a^n $ 0 = 1" |
|
30960 | 710 |
by (induct n, auto simp add: fps_mult_nth) |
29687 | 711 |
|
712 |
lemma startsby_zero_power:"a $0 = (0::'a::comm_ring_1) \<Longrightarrow> n > 0 \<Longrightarrow> a^n $0 = 0" |
|
30960 | 713 |
by (induct n, auto simp add: fps_mult_nth) |
29687 | 714 |
|
31021 | 715 |
lemma startsby_power:"a $0 = (v::'a::{comm_ring_1}) \<Longrightarrow> a^n $0 = v^n" |
30960 | 716 |
by (induct n, auto simp add: fps_mult_nth power_Suc) |
29687 | 717 |
|
718 |
lemma startsby_zero_power_iff[simp]: |
|
31021 | 719 |
"a^n $0 = (0::'a::{idom}) \<longleftrightarrow> (n \<noteq> 0 \<and> a$0 = 0)" |
29687 | 720 |
apply (rule iffI) |
721 |
apply (induct n, auto simp add: power_Suc fps_mult_nth) |
|
722 |
by (rule startsby_zero_power, simp_all) |
|
723 |
||
30488 | 724 |
lemma startsby_zero_power_prefix: |
29687 | 725 |
assumes a0: "a $0 = (0::'a::idom)" |
726 |
shows "\<forall>n < k. a ^ k $ n = 0" |
|
30488 | 727 |
using a0 |
29687 | 728 |
proof(induct k rule: nat_less_induct) |
729 |
fix k assume H: "\<forall>m<k. a $0 = 0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $0 = (0\<Colon>'a)" |
|
730 |
let ?ths = "\<forall>m<k. a ^ k $ m = 0" |
|
731 |
{assume "k = 0" then have ?ths by simp} |
|
732 |
moreover |
|
733 |
{fix l assume k: "k = Suc l" |
|
734 |
{fix m assume mk: "m < k" |
|
30488 | 735 |
{assume "m=0" hence "a^k $ m = 0" using startsby_zero_power[of a k] k a0 |
29687 | 736 |
by simp} |
737 |
moreover |
|
738 |
{assume m0: "m \<noteq> 0" |
|
739 |
have "a ^k $ m = (a^l * a) $m" by (simp add: k power_Suc mult_commute) |
|
740 |
also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))" by (simp add: fps_mult_nth) |
|
741 |
also have "\<dots> = 0" apply (rule setsum_0') |
|
742 |
apply auto |
|
743 |
apply (case_tac "aa = m") |
|
744 |
using a0 |
|
745 |
apply simp |
|
746 |
apply (rule H[rule_format]) |
|
30488 | 747 |
using a0 k mk by auto |
29687 | 748 |
finally have "a^k $ m = 0" .} |
749 |
ultimately have "a^k $ m = 0" by blast} |
|
750 |
hence ?ths by blast} |
|
751 |
ultimately show ?ths by (cases k, auto) |
|
752 |
qed |
|
753 |
||
30488 | 754 |
lemma startsby_zero_setsum_depends: |
29687 | 755 |
assumes a0: "a $0 = (0::'a::idom)" and kn: "n \<ge> k" |
756 |
shows "setsum (\<lambda>i. (a ^ i)$k) {0 .. n} = setsum (\<lambda>i. (a ^ i)$k) {0 .. k}" |
|
757 |
apply (rule setsum_mono_zero_right) |
|
758 |
using kn apply auto |
|
759 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
|
760 |
by arith |
|
761 |
||
31021 | 762 |
lemma startsby_zero_power_nth_same: assumes a0: "a$0 = (0::'a::{idom})" |
29687 | 763 |
shows "a^n $ n = (a$1) ^ n" |
764 |
proof(induct n) |
|
765 |
case 0 thus ?case by (simp add: power_0) |
|
766 |
next |
|
767 |
case (Suc n) |
|
768 |
have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)" by (simp add: ring_simps power_Suc) |
|
769 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}" by (simp add: fps_mult_nth) |
|
770 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}" |
|
771 |
apply (rule setsum_mono_zero_right) |
|
772 |
apply simp |
|
773 |
apply clarsimp |
|
774 |
apply clarsimp |
|
775 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
|
776 |
apply arith |
|
777 |
done |
|
778 |
also have "\<dots> = a^n $ n * a$1" using a0 by simp |
|
779 |
finally show ?case using Suc.hyps by (simp add: power_Suc) |
|
780 |
qed |
|
781 |
||
782 |
lemma fps_inverse_power: |
|
31021 | 783 |
fixes a :: "('a::{field}) fps" |
29687 | 784 |
shows "inverse (a^n) = inverse a ^ n" |
785 |
proof- |
|
786 |
{assume a0: "a$0 = 0" |
|
787 |
hence eq: "inverse a = 0" by (simp add: fps_inverse_def) |
|
788 |
{assume "n = 0" hence ?thesis by simp} |
|
789 |
moreover |
|
790 |
{assume n: "n > 0" |
|
30488 | 791 |
from startsby_zero_power[OF a0 n] eq a0 n have ?thesis |
29687 | 792 |
by (simp add: fps_inverse_def)} |
793 |
ultimately have ?thesis by blast} |
|
794 |
moreover |
|
795 |
{assume a0: "a$0 \<noteq> 0" |
|
796 |
have ?thesis |
|
797 |
apply (rule fps_inverse_unique) |
|
798 |
apply (simp add: a0) |
|
799 |
unfolding power_mult_distrib[symmetric] |
|
800 |
apply (rule ssubst[where t = "a * inverse a" and s= 1]) |
|
801 |
apply simp_all |
|
802 |
apply (subst mult_commute) |
|
803 |
by (rule inverse_mult_eq_1[OF a0])} |
|
804 |
ultimately show ?thesis by blast |
|
805 |
qed |
|
806 |
||
807 |
lemma fps_deriv_power: "fps_deriv (a ^ n) = fps_const (of_nat n :: 'a:: comm_ring_1) * fps_deriv a * a ^ (n - 1)" |
|
808 |
apply (induct n, auto simp add: power_Suc ring_simps fps_const_add[symmetric] simp del: fps_const_add) |
|
809 |
by (case_tac n, auto simp add: power_Suc ring_simps) |
|
810 |
||
30488 | 811 |
lemma fps_inverse_deriv: |
29687 | 812 |
fixes a:: "('a :: field) fps" |
813 |
assumes a0: "a$0 \<noteq> 0" |
|
814 |
shows "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" |
|
815 |
proof- |
|
816 |
from inverse_mult_eq_1[OF a0] |
|
817 |
have "fps_deriv (inverse a * a) = 0" by simp |
|
818 |
hence "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0" by simp |
|
819 |
hence "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0" by simp |
|
820 |
with inverse_mult_eq_1[OF a0] |
|
821 |
have "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) = 0" |
|
822 |
unfolding power2_eq_square |
|
823 |
apply (simp add: ring_simps) |
|
824 |
by (simp add: mult_assoc[symmetric]) |
|
825 |
hence "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) - fps_deriv a * inverse a ^ 2 = 0 - fps_deriv a * inverse a ^ 2" |
|
826 |
by simp |
|
827 |
then show "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" by (simp add: ring_simps) |
|
828 |
qed |
|
829 |
||
30488 | 830 |
lemma fps_inverse_mult: |
29687 | 831 |
fixes a::"('a :: field) fps" |
832 |
shows "inverse (a * b) = inverse a * inverse b" |
|
833 |
proof- |
|
834 |
{assume a0: "a$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth) |
|
835 |
from a0 ab0 have th: "inverse a = 0" "inverse (a*b) = 0" by simp_all |
|
836 |
have ?thesis unfolding th by simp} |
|
837 |
moreover |
|
838 |
{assume b0: "b$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth) |
|
839 |
from b0 ab0 have th: "inverse b = 0" "inverse (a*b) = 0" by simp_all |
|
840 |
have ?thesis unfolding th by simp} |
|
841 |
moreover |
|
842 |
{assume a0: "a$0 \<noteq> 0" and b0: "b$0 \<noteq> 0" |
|
843 |
from a0 b0 have ab0:"(a*b) $ 0 \<noteq> 0" by (simp add: fps_mult_nth) |
|
30488 | 844 |
from inverse_mult_eq_1[OF ab0] |
29687 | 845 |
have "inverse (a*b) * (a*b) * inverse a * inverse b = 1 * inverse a * inverse b" by simp |
846 |
then have "inverse (a*b) * (inverse a * a) * (inverse b * b) = inverse a * inverse b" |
|
847 |
by (simp add: ring_simps) |
|
848 |
then have ?thesis using inverse_mult_eq_1[OF a0] inverse_mult_eq_1[OF b0] by simp} |
|
849 |
ultimately show ?thesis by blast |
|
850 |
qed |
|
851 |
||
30488 | 852 |
lemma fps_inverse_deriv': |
29687 | 853 |
fixes a:: "('a :: field) fps" |
854 |
assumes a0: "a$0 \<noteq> 0" |
|
855 |
shows "fps_deriv (inverse a) = - fps_deriv a / a ^ 2" |
|
856 |
using fps_inverse_deriv[OF a0] |
|
857 |
unfolding power2_eq_square fps_divide_def |
|
858 |
fps_inverse_mult by simp |
|
859 |
||
860 |
lemma inverse_mult_eq_1': assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
861 |
shows "f * inverse f= 1" |
|
862 |
by (metis mult_commute inverse_mult_eq_1 f0) |
|
863 |
||
864 |
lemma fps_divide_deriv: fixes a:: "('a :: field) fps" |
|
865 |
assumes a0: "b$0 \<noteq> 0" |
|
866 |
shows "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b ^ 2" |
|
867 |
using fps_inverse_deriv[OF a0] |
|
868 |
by (simp add: fps_divide_def ring_simps power2_eq_square fps_inverse_mult inverse_mult_eq_1'[OF a0]) |
|
30488 | 869 |
|
29906 | 870 |
subsection{* The eXtractor series X*} |
29687 | 871 |
|
31021 | 872 |
lemma minus_one_power_iff: "(- (1::'a :: {comm_ring_1})) ^ n = (if even n then 1 else - 1)" |
29687 | 873 |
by (induct n, auto) |
874 |
||
875 |
definition "X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)" |
|
876 |
||
30488 | 877 |
lemma fps_inverse_gp': "inverse (Abs_fps(\<lambda>n. (1::'a::field))) |
29687 | 878 |
= 1 - X" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
879 |
by (simp add: fps_inverse_gp fps_eq_iff X_def) |
29687 | 880 |
|
881 |
lemma X_mult_nth[simp]: "(X * (f :: ('a::semiring_1) fps)) $n = (if n = 0 then 0 else f $ (n - 1))" |
|
882 |
proof- |
|
883 |
{assume n: "n \<noteq> 0" |
|
884 |
have fN: "finite {0 .. n}" by simp |
|
885 |
have "(X * f) $n = (\<Sum>i = 0..n. X $ i * f $ (n - i))" by (simp add: fps_mult_nth) |
|
29913 | 886 |
also have "\<dots> = f $ (n - 1)" |
887 |
using n by (simp add: X_def mult_delta_left setsum_delta [OF fN]) |
|
29687 | 888 |
finally have ?thesis using n by simp } |
889 |
moreover |
|
890 |
{assume n: "n=0" hence ?thesis by (simp add: fps_mult_nth X_def)} |
|
891 |
ultimately show ?thesis by blast |
|
892 |
qed |
|
893 |
||
894 |
lemma X_mult_right_nth[simp]: "((f :: ('a::comm_semiring_1) fps) * X) $n = (if n = 0 then 0 else f $ (n - 1))" |
|
895 |
by (metis X_mult_nth mult_commute) |
|
896 |
||
897 |
lemma X_power_iff: "X^k = Abs_fps (\<lambda>n. if n = k then (1::'a::comm_ring_1) else 0)" |
|
898 |
proof(induct k) |
|
30960 | 899 |
case 0 thus ?case by (simp add: X_def fps_eq_iff) |
29687 | 900 |
next |
901 |
case (Suc k) |
|
30488 | 902 |
{fix m |
29687 | 903 |
have "(X^Suc k) $ m = (if m = 0 then (0::'a) else (X^k) $ (m - 1))" |
904 |
by (simp add: power_Suc del: One_nat_def) |
|
905 |
then have "(X^Suc k) $ m = (if m = Suc k then (1::'a) else 0)" |
|
906 |
using Suc.hyps by (auto cong del: if_weak_cong)} |
|
907 |
then show ?case by (simp add: fps_eq_iff) |
|
908 |
qed |
|
909 |
||
910 |
lemma X_power_mult_nth: "(X^k * (f :: ('a::comm_ring_1) fps)) $n = (if n < k then 0 else f $ (n - k))" |
|
911 |
apply (induct k arbitrary: n) |
|
912 |
apply (simp) |
|
30488 | 913 |
unfolding power_Suc mult_assoc |
29687 | 914 |
by (case_tac n, auto) |
915 |
||
916 |
lemma X_power_mult_right_nth: "((f :: ('a::comm_ring_1) fps) * X^k) $n = (if n < k then 0 else f $ (n - k))" |
|
917 |
by (metis X_power_mult_nth mult_commute) |
|
918 |
lemma fps_deriv_X[simp]: "fps_deriv X = 1" |
|
919 |
by (simp add: fps_deriv_def X_def fps_eq_iff) |
|
920 |
||
921 |
lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)" |
|
922 |
by (cases "n", simp_all) |
|
923 |
||
924 |
lemma X_nth[simp]: "X$n = (if n = 1 then 1 else 0)" by (simp add: X_def) |
|
925 |
lemma X_power_nth[simp]: "(X^k) $n = (if n = k then 1 else (0::'a::comm_ring_1))" |
|
926 |
by (simp add: X_power_iff) |
|
927 |
||
928 |
lemma fps_inverse_X_plus1: |
|
31021 | 929 |
"inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::{field})) ^ n)" (is "_ = ?r") |
29687 | 930 |
proof- |
931 |
have eq: "(1 + X) * ?r = 1" |
|
932 |
unfolding minus_one_power_iff |
|
31148 | 933 |
by (auto simp add: ring_simps fps_eq_iff) |
29687 | 934 |
show ?thesis by (auto simp add: eq intro: fps_inverse_unique) |
935 |
qed |
|
936 |
||
30488 | 937 |
|
29906 | 938 |
subsection{* Integration *} |
29687 | 939 |
definition "fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))" |
940 |
||
941 |
lemma fps_deriv_fps_integral: "fps_deriv (fps_integral a (a0 :: 'a :: {field, ring_char_0})) = a" |
|
942 |
by (simp add: fps_integral_def fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc) |
|
943 |
||
944 |
lemma fps_integral_linear: "fps_integral (fps_const (a::'a::{field, ring_char_0}) * f + fps_const b * g) (a*a0 + b*b0) = fps_const a * fps_integral f a0 + fps_const b * fps_integral g b0" (is "?l = ?r") |
|
945 |
proof- |
|
946 |
have "fps_deriv ?l = fps_deriv ?r" by (simp add: fps_deriv_fps_integral) |
|
947 |
moreover have "?l$0 = ?r$0" by (simp add: fps_integral_def) |
|
948 |
ultimately show ?thesis |
|
949 |
unfolding fps_deriv_eq_iff by auto |
|
950 |
qed |
|
30488 | 951 |
|
29906 | 952 |
subsection {* Composition of FPSs *} |
29687 | 953 |
definition fps_compose :: "('a::semiring_1) fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55) where |
954 |
fps_compose_def: "a oo b = Abs_fps (\<lambda>n. setsum (\<lambda>i. a$i * (b^i$n)) {0..n})" |
|
955 |
||
956 |
lemma fps_compose_nth: "(a oo b)$n = setsum (\<lambda>i. a$i * (b^i$n)) {0..n}" by (simp add: fps_compose_def) |
|
957 |
||
958 |
lemma fps_compose_X[simp]: "a oo X = (a :: ('a :: comm_ring_1) fps)" |
|
29913 | 959 |
by (simp add: fps_ext fps_compose_def mult_delta_right setsum_delta') |
30488 | 960 |
|
961 |
lemma fps_const_compose[simp]: |
|
29687 | 962 |
"fps_const (a::'a::{comm_ring_1}) oo b = fps_const (a)" |
29913 | 963 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta) |
29687 | 964 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
965 |
lemma number_of_compose[simp]: "(number_of k::('a::{comm_ring_1}) fps) oo b = number_of k" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
966 |
unfolding number_of_fps_const by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
967 |
|
29687 | 968 |
lemma X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> X oo a = (a :: ('a :: comm_ring_1) fps)" |
29913 | 969 |
by (simp add: fps_eq_iff fps_compose_def mult_delta_left setsum_delta |
970 |
power_Suc not_le) |
|
29687 | 971 |
|
972 |
||
29906 | 973 |
subsection {* Rules from Herbert Wilf's Generatingfunctionology*} |
29687 | 974 |
|
29906 | 975 |
subsubsection {* Rule 1 *} |
29687 | 976 |
(* {a_{n+k}}_0^infty Corresponds to (f - setsum (\<lambda>i. a_i * x^i))/x^h, for h>0*) |
977 |
||
30488 | 978 |
lemma fps_power_mult_eq_shift: |
30992 | 979 |
"X^Suc k * Abs_fps (\<lambda>n. a (n + Suc k)) = Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a:: comm_ring_1) * X^i) {0 .. k}" (is "?lhs = ?rhs") |
29687 | 980 |
proof- |
981 |
{fix n:: nat |
|
30488 | 982 |
have "?lhs $ n = (if n < Suc k then 0 else a n)" |
29687 | 983 |
unfolding X_power_mult_nth by auto |
984 |
also have "\<dots> = ?rhs $ n" |
|
985 |
proof(induct k) |
|
986 |
case 0 thus ?case by (simp add: fps_setsum_nth power_Suc) |
|
987 |
next |
|
988 |
case (Suc k) |
|
989 |
note th = Suc.hyps[symmetric] |
|
30992 | 990 |
have "(Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. Suc k})$n = (Abs_fps a - setsum (\<lambda>i. fps_const (a i :: 'a) * X^i) {0 .. k} - fps_const (a (Suc k)) * X^ Suc k) $ n" by (simp add: ring_simps) |
29687 | 991 |
also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n" |
30488 | 992 |
using th |
29687 | 993 |
unfolding fps_sub_nth by simp |
994 |
also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)" |
|
995 |
unfolding X_power_mult_right_nth |
|
996 |
apply (auto simp add: not_less fps_const_def) |
|
997 |
apply (rule cong[of a a, OF refl]) |
|
998 |
by arith |
|
999 |
finally show ?case by simp |
|
1000 |
qed |
|
1001 |
finally have "?lhs $ n = ?rhs $ n" .} |
|
1002 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1003 |
qed |
|
1004 |
||
29906 | 1005 |
subsubsection{* Rule 2*} |
29687 | 1006 |
|
1007 |
(* We can not reach the form of Wilf, but still near to it using rewrite rules*) |
|
30488 | 1008 |
(* If f reprents {a_n} and P is a polynomial, then |
29687 | 1009 |
P(xD) f represents {P(n) a_n}*) |
1010 |
||
1011 |
definition "XD = op * X o fps_deriv" |
|
1012 |
||
1013 |
lemma XD_add[simp]:"XD (a + b) = XD a + XD (b :: ('a::comm_ring_1) fps)" |
|
1014 |
by (simp add: XD_def ring_simps) |
|
1015 |
||
1016 |
lemma XD_mult_const[simp]:"XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * XD a" |
|
1017 |
by (simp add: XD_def ring_simps) |
|
1018 |
||
1019 |
lemma XD_linear[simp]: "XD (fps_const c * a + fps_const d * b) = fps_const c * XD a + fps_const d * XD (b :: ('a::comm_ring_1) fps)" |
|
1020 |
by simp |
|
1021 |
||
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
30837
diff
changeset
|
1022 |
lemma XDN_linear: |
30971 | 1023 |
"(XD ^^ n) (fps_const c * a + fps_const d * b) = fps_const c * (XD ^^ n) a + fps_const d * (XD ^^ n) (b :: ('a::comm_ring_1) fps)" |
29687 | 1024 |
by (induct n, simp_all) |
1025 |
||
1026 |
lemma fps_mult_X_deriv_shift: "X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)" by (simp add: fps_eq_iff) |
|
1027 |
||
30994 | 1028 |
|
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
30837
diff
changeset
|
1029 |
lemma fps_mult_XD_shift: |
31021 | 1030 |
"(XD ^^ k) (a:: ('a::{comm_ring_1}) fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)" |
30952
7ab2716dd93b
power operation on functions with syntax o^; power operation on relations with syntax ^^
haftmann
parents:
30837
diff
changeset
|
1031 |
by (induct k arbitrary: a) (simp_all add: power_Suc XD_def fps_eq_iff ring_simps del: One_nat_def) |
29687 | 1032 |
|
29906 | 1033 |
subsubsection{* Rule 3 is trivial and is given by @{text fps_times_def}*} |
1034 |
subsubsection{* Rule 5 --- summation and "division" by (1 - X)*} |
|
29687 | 1035 |
|
1036 |
lemma fps_divide_X_minus1_setsum_lemma: |
|
1037 |
"a = ((1::('a::comm_ring_1) fps) - X) * Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
|
1038 |
proof- |
|
1039 |
let ?X = "X::('a::comm_ring_1) fps" |
|
1040 |
let ?sa = "Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
|
1041 |
have th0: "\<And>i. (1 - (X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)" by simp |
|
1042 |
{fix n:: nat |
|
30488 | 1043 |
{assume "n=0" hence "a$n = ((1 - ?X) * ?sa) $ n" |
29687 | 1044 |
by (simp add: fps_mult_nth)} |
1045 |
moreover |
|
1046 |
{assume n0: "n \<noteq> 0" |
|
1047 |
then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1}\<union>{2..n} = {1..n}" |
|
1048 |
"{0..n - 1}\<union>{n} = {0..n}" |
|
1049 |
apply (simp_all add: expand_set_eq) by presburger+ |
|
30488 | 1050 |
have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" |
29687 | 1051 |
"{0..n - 1}\<inter>{n} ={}" using n0 |
1052 |
by (simp_all add: expand_set_eq, presburger+) |
|
30488 | 1053 |
have f: "finite {0}" "finite {1}" "finite {2 .. n}" |
1054 |
"finite {0 .. n - 1}" "finite {n}" by simp_all |
|
29687 | 1055 |
have "((1 - ?X) * ?sa) $ n = setsum (\<lambda>i. (1 - ?X)$ i * ?sa $ (n - i)) {0 .. n}" |
1056 |
by (simp add: fps_mult_nth) |
|
1057 |
also have "\<dots> = a$n" unfolding th0 |
|
1058 |
unfolding setsum_Un_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)] |
|
1059 |
unfolding setsum_Un_disjoint[OF f(2) f(3) d(2)] |
|
1060 |
apply (simp) |
|
1061 |
unfolding setsum_Un_disjoint[OF f(4,5) d(3), unfolded u(3)] |
|
1062 |
by simp |
|
1063 |
finally have "a$n = ((1 - ?X) * ?sa) $ n" by simp} |
|
1064 |
ultimately have "a$n = ((1 - ?X) * ?sa) $ n" by blast} |
|
30488 | 1065 |
then show ?thesis |
29687 | 1066 |
unfolding fps_eq_iff by blast |
1067 |
qed |
|
1068 |
||
1069 |
lemma fps_divide_X_minus1_setsum: |
|
1070 |
"a /((1::('a::field) fps) - X) = Abs_fps (\<lambda>n. setsum (\<lambda>i. a $ i) {0..n})" |
|
1071 |
proof- |
|
1072 |
let ?X = "1 - (X::('a::field) fps)" |
|
1073 |
have th0: "?X $ 0 \<noteq> 0" by simp |
|
1074 |
have "a /?X = ?X * Abs_fps (\<lambda>n\<Colon>nat. setsum (op $ a) {0..n}) * inverse ?X" |
|
1075 |
using fps_divide_X_minus1_setsum_lemma[of a, symmetric] th0 |
|
1076 |
by (simp add: fps_divide_def mult_assoc) |
|
1077 |
also have "\<dots> = (inverse ?X * ?X) * Abs_fps (\<lambda>n\<Colon>nat. setsum (op $ a) {0..n}) " |
|
1078 |
by (simp add: mult_ac) |
|
1079 |
finally show ?thesis by (simp add: inverse_mult_eq_1[OF th0]) |
|
1080 |
qed |
|
1081 |
||
30488 | 1082 |
subsubsection{* Rule 4 in its more general form: generalizes Rule 3 for an arbitrary |
29687 | 1083 |
finite product of FPS, also the relvant instance of powers of a FPS*} |
1084 |
||
1085 |
definition "natpermute n k = {l:: nat list. length l = k \<and> foldl op + 0 l = n}" |
|
1086 |
||
1087 |
lemma natlist_trivial_1: "natpermute n 1 = {[n]}" |
|
1088 |
apply (auto simp add: natpermute_def) |
|
1089 |
apply (case_tac x, auto) |
|
1090 |
done |
|
1091 |
||
30488 | 1092 |
lemma foldl_add_start0: |
29687 | 1093 |
"foldl op + x xs = x + foldl op + (0::nat) xs" |
1094 |
apply (induct xs arbitrary: x) |
|
1095 |
apply simp |
|
1096 |
unfolding foldl.simps |
|
1097 |
apply atomize |
|
1098 |
apply (subgoal_tac "\<forall>x\<Colon>nat. foldl op + x xs = x + foldl op + (0\<Colon>nat) xs") |
|
1099 |
apply (erule_tac x="x + a" in allE) |
|
1100 |
apply (erule_tac x="a" in allE) |
|
1101 |
apply simp |
|
1102 |
apply assumption |
|
1103 |
done |
|
1104 |
||
1105 |
lemma foldl_add_append: "foldl op + (x::nat) (xs@ys) = foldl op + x xs + foldl op + 0 ys" |
|
1106 |
apply (induct ys arbitrary: x xs) |
|
1107 |
apply auto |
|
1108 |
apply (subst (2) foldl_add_start0) |
|
1109 |
apply simp |
|
1110 |
apply (subst (2) foldl_add_start0) |
|
1111 |
by simp |
|
1112 |
||
1113 |
lemma foldl_add_setsum: "foldl op + (x::nat) xs = x + setsum (nth xs) {0..<length xs}" |
|
1114 |
proof(induct xs arbitrary: x) |
|
1115 |
case Nil thus ?case by simp |
|
1116 |
next |
|
1117 |
case (Cons a as x) |
|
1118 |
have eq: "setsum (op ! (a#as)) {1..<length (a#as)} = setsum (op ! as) {0..<length as}" |
|
1119 |
apply (rule setsum_reindex_cong [where f=Suc]) |
|
1120 |
by (simp_all add: inj_on_def) |
|
1121 |
have f: "finite {0}" "finite {1 ..< length (a#as)}" by simp_all |
|
1122 |
have d: "{0} \<inter> {1..<length (a#as)} = {}" by simp |
|
1123 |
have seq: "{0} \<union> {1..<length(a#as)} = {0 ..<length (a#as)}" by auto |
|
1124 |
have "foldl op + x (a#as) = x + foldl op + a as " |
|
1125 |
apply (subst foldl_add_start0) by simp |
|
1126 |
also have "\<dots> = x + a + setsum (op ! as) {0..<length as}" unfolding Cons.hyps by simp |
|
1127 |
also have "\<dots> = x + setsum (op ! (a#as)) {0..<length (a#as)}" |
|
30488 | 1128 |
unfolding eq[symmetric] |
29687 | 1129 |
unfolding setsum_Un_disjoint[OF f d, unfolded seq] |
1130 |
by simp |
|
1131 |
finally show ?case . |
|
1132 |
qed |
|
1133 |
||
1134 |
||
1135 |
lemma append_natpermute_less_eq: |
|
1136 |
assumes h: "xs@ys \<in> natpermute n k" shows "foldl op + 0 xs \<le> n" and "foldl op + 0 ys \<le> n" |
|
1137 |
proof- |
|
1138 |
{from h have "foldl op + 0 (xs@ ys) = n" by (simp add: natpermute_def) |
|
1139 |
hence "foldl op + 0 xs + foldl op + 0 ys = n" unfolding foldl_add_append .} |
|
1140 |
note th = this |
|
1141 |
{from th show "foldl op + 0 xs \<le> n" by simp} |
|
1142 |
{from th show "foldl op + 0 ys \<le> n" by simp} |
|
1143 |
qed |
|
1144 |
||
1145 |
lemma natpermute_split: |
|
1146 |
assumes mn: "h \<le> k" |
|
1147 |
shows "natpermute n k = (\<Union>m \<in>{0..n}. {l1 @ l2 |l1 l2. l1 \<in> natpermute m h \<and> l2 \<in> natpermute (n - m) (k - h)})" (is "?L = ?R" is "?L = (\<Union>m \<in>{0..n}. ?S m)") |
|
1148 |
proof- |
|
30488 | 1149 |
{fix l assume l: "l \<in> ?R" |
29687 | 1150 |
from l obtain m xs ys where h: "m \<in> {0..n}" and xs: "xs \<in> natpermute m h" and ys: "ys \<in> natpermute (n - m) (k - h)" and leq: "l = xs@ys" by blast |
1151 |
from xs have xs': "foldl op + 0 xs = m" by (simp add: natpermute_def) |
|
1152 |
from ys have ys': "foldl op + 0 ys = n - m" by (simp add: natpermute_def) |
|
30488 | 1153 |
have "l \<in> ?L" using leq xs ys h |
29687 | 1154 |
apply simp |
1155 |
apply (clarsimp simp add: natpermute_def simp del: foldl_append) |
|
1156 |
apply (simp add: foldl_add_append[unfolded foldl_append]) |
|
1157 |
unfolding xs' ys' |
|
30488 | 1158 |
using mn xs ys |
29687 | 1159 |
unfolding natpermute_def by simp} |
1160 |
moreover |
|
1161 |
{fix l assume l: "l \<in> natpermute n k" |
|
1162 |
let ?xs = "take h l" |
|
1163 |
let ?ys = "drop h l" |
|
1164 |
let ?m = "foldl op + 0 ?xs" |
|
1165 |
from l have ls: "foldl op + 0 (?xs @ ?ys) = n" by (simp add: natpermute_def) |
|
30488 | 1166 |
have xs: "?xs \<in> natpermute ?m h" using l mn by (simp add: natpermute_def) |
29687 | 1167 |
have ys: "?ys \<in> natpermute (n - ?m) (k - h)" using l mn ls[unfolded foldl_add_append] |
1168 |
by (simp add: natpermute_def) |
|
1169 |
from ls have m: "?m \<in> {0..n}" unfolding foldl_add_append by simp |
|
30488 | 1170 |
from xs ys ls have "l \<in> ?R" |
29687 | 1171 |
apply auto |
1172 |
apply (rule bexI[where x = "?m"]) |
|
1173 |
apply (rule exI[where x = "?xs"]) |
|
1174 |
apply (rule exI[where x = "?ys"]) |
|
30488 | 1175 |
using ls l unfolding foldl_add_append |
29687 | 1176 |
by (auto simp add: natpermute_def)} |
1177 |
ultimately show ?thesis by blast |
|
1178 |
qed |
|
1179 |
||
1180 |
lemma natpermute_0: "natpermute n 0 = (if n = 0 then {[]} else {})" |
|
1181 |
by (auto simp add: natpermute_def) |
|
1182 |
lemma natpermute_0'[simp]: "natpermute 0 k = (if k = 0 then {[]} else {replicate k 0})" |
|
1183 |
apply (auto simp add: set_replicate_conv_if natpermute_def) |
|
1184 |
apply (rule nth_equalityI) |
|
1185 |
by simp_all |
|
1186 |
||
1187 |
lemma natpermute_finite: "finite (natpermute n k)" |
|
1188 |
proof(induct k arbitrary: n) |
|
30488 | 1189 |
case 0 thus ?case |
29687 | 1190 |
apply (subst natpermute_split[of 0 0, simplified]) |
1191 |
by (simp add: natpermute_0) |
|
1192 |
next |
|
1193 |
case (Suc k) |
|
1194 |
then show ?case unfolding natpermute_split[of k "Suc k", simplified] |
|
1195 |
apply - |
|
1196 |
apply (rule finite_UN_I) |
|
1197 |
apply simp |
|
1198 |
unfolding One_nat_def[symmetric] natlist_trivial_1 |
|
1199 |
apply simp |
|
1200 |
unfolding image_Collect[symmetric] |
|
1201 |
unfolding Collect_def mem_def |
|
1202 |
apply (rule finite_imageI) |
|
1203 |
apply blast |
|
1204 |
done |
|
1205 |
qed |
|
1206 |
||
1207 |
lemma natpermute_contain_maximal: |
|
1208 |
"{xs \<in> natpermute n (k+1). n \<in> set xs} = UNION {0 .. k} (\<lambda>i. {(replicate (k+1) 0) [i:=n]})" |
|
1209 |
(is "?A = ?B") |
|
1210 |
proof- |
|
1211 |
{fix xs assume H: "xs \<in> natpermute n (k+1)" and n: "n \<in> set xs" |
|
1212 |
from n obtain i where i: "i \<in> {0.. k}" "xs!i = n" using H |
|
30488 | 1213 |
unfolding in_set_conv_nth by (auto simp add: less_Suc_eq_le natpermute_def) |
29687 | 1214 |
have eqs: "({0..k} - {i}) \<union> {i} = {0..k}" using i by auto |
1215 |
have f: "finite({0..k} - {i})" "finite {i}" by auto |
|
1216 |
have d: "({0..k} - {i}) \<inter> {i} = {}" using i by auto |
|
1217 |
from H have "n = setsum (nth xs) {0..k}" apply (simp add: natpermute_def) |
|
1218 |
unfolding foldl_add_setsum by (auto simp add: atLeastLessThanSuc_atLeastAtMost) |
|
1219 |
also have "\<dots> = n + setsum (nth xs) ({0..k} - {i})" |
|
1220 |
unfolding setsum_Un_disjoint[OF f d, unfolded eqs] using i by simp |
|
1221 |
finally have zxs: "\<forall> j\<in> {0..k} - {i}. xs!j = 0" by auto |
|
1222 |
from H have xsl: "length xs = k+1" by (simp add: natpermute_def) |
|
1223 |
from i have i': "i < length (replicate (k+1) 0)" "i < k+1" |
|
1224 |
unfolding length_replicate by arith+ |
|
1225 |
have "xs = replicate (k+1) 0 [i := n]" |
|
1226 |
apply (rule nth_equalityI) |
|
1227 |
unfolding xsl length_list_update length_replicate |
|
1228 |
apply simp |
|
1229 |
apply clarify |
|
1230 |
unfolding nth_list_update[OF i'(1)] |
|
1231 |
using i zxs |
|
1232 |
by (case_tac "ia=i", auto simp del: replicate.simps) |
|
1233 |
then have "xs \<in> ?B" using i by blast} |
|
1234 |
moreover |
|
1235 |
{fix i assume i: "i \<in> {0..k}" |
|
1236 |
let ?xs = "replicate (k+1) 0 [i:=n]" |
|
1237 |
have nxs: "n \<in> set ?xs" |
|
1238 |
apply (rule set_update_memI) using i by simp |
|
1239 |
have xsl: "length ?xs = k+1" by (simp only: length_replicate length_list_update) |
|
1240 |
have "foldl op + 0 ?xs = setsum (nth ?xs) {0..<k+1}" |
|
1241 |
unfolding foldl_add_setsum add_0 length_replicate length_list_update .. |
|
1242 |
also have "\<dots> = setsum (\<lambda>j. if j = i then n else 0) {0..< k+1}" |
|
1243 |
apply (rule setsum_cong2) by (simp del: replicate.simps) |
|
1244 |
also have "\<dots> = n" using i by (simp add: setsum_delta) |
|
30488 | 1245 |
finally |
29687 | 1246 |
have "?xs \<in> natpermute n (k+1)" using xsl unfolding natpermute_def Collect_def mem_def |
1247 |
by blast |
|
1248 |
then have "?xs \<in> ?A" using nxs by blast} |
|
1249 |
ultimately show ?thesis by auto |
|
1250 |
qed |
|
1251 |
||
30488 | 1252 |
(* The general form *) |
29687 | 1253 |
lemma fps_setprod_nth: |
1254 |
fixes m :: nat and a :: "nat \<Rightarrow> ('a::comm_ring_1) fps" |
|
1255 |
shows "(setprod a {0 .. m})$n = setsum (\<lambda>v. setprod (\<lambda>j. (a j) $ (v!j)) {0..m}) (natpermute n (m+1))" |
|
1256 |
(is "?P m n") |
|
1257 |
proof(induct m arbitrary: n rule: nat_less_induct) |
|
1258 |
fix m n assume H: "\<forall>m' < m. \<forall>n. ?P m' n" |
|
1259 |
{assume m0: "m = 0" |
|
1260 |
hence "?P m n" apply simp |
|
1261 |
unfolding natlist_trivial_1[where n = n, unfolded One_nat_def] by simp} |
|
1262 |
moreover |
|
1263 |
{fix k assume k: "m = Suc k" |
|
1264 |
have km: "k < m" using k by arith |
|
1265 |
have u0: "{0 .. k} \<union> {m} = {0..m}" using k apply (simp add: expand_set_eq) by presburger |
|
1266 |
have f0: "finite {0 .. k}" "finite {m}" by auto |
|
1267 |
have d0: "{0 .. k} \<inter> {m} = {}" using k by auto |
|
1268 |
have "(setprod a {0 .. m}) $ n = (setprod a {0 .. k} * a m) $ n" |
|
1269 |
unfolding setprod_Un_disjoint[OF f0 d0, unfolded u0] by simp |
|
1270 |
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))" |
|
1271 |
unfolding fps_mult_nth H[rule_format, OF km] .. |
|
1272 |
also have "\<dots> = (\<Sum>v\<in>natpermute n (m + 1). \<Prod>j\<in>{0..m}. a j $ v ! j)" |
|
1273 |
apply (simp add: k) |
|
1274 |
unfolding natpermute_split[of m "m + 1", simplified, of n, unfolded natlist_trivial_1[unfolded One_nat_def] k] |
|
1275 |
apply (subst setsum_UN_disjoint) |
|
30488 | 1276 |
apply simp |
29687 | 1277 |
apply simp |
1278 |
unfolding image_Collect[symmetric] |
|
1279 |
apply clarsimp |
|
1280 |
apply (rule finite_imageI) |
|
1281 |
apply (rule natpermute_finite) |
|
1282 |
apply (clarsimp simp add: expand_set_eq) |
|
1283 |
apply auto |
|
1284 |
apply (rule setsum_cong2) |
|
1285 |
unfolding setsum_left_distrib |
|
1286 |
apply (rule sym) |
|
1287 |
apply (rule_tac f="\<lambda>xs. xs @[n - x]" in setsum_reindex_cong) |
|
1288 |
apply (simp add: inj_on_def) |
|
1289 |
apply auto |
|
1290 |
unfolding setprod_Un_disjoint[OF f0 d0, unfolded u0, unfolded k] |
|
1291 |
apply (clarsimp simp add: natpermute_def nth_append) |
|
1292 |
done |
|
1293 |
finally have "?P m n" .} |
|
1294 |
ultimately show "?P m n " by (cases m, auto) |
|
1295 |
qed |
|
1296 |
||
1297 |
text{* The special form for powers *} |
|
1298 |
lemma fps_power_nth_Suc: |
|
1299 |
fixes m :: nat and a :: "('a::comm_ring_1) fps" |
|
1300 |
shows "(a ^ Suc m)$n = setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m}) (natpermute n (m+1))" |
|
1301 |
proof- |
|
1302 |
have f: "finite {0 ..m}" by simp |
|
1303 |
have th0: "a^Suc m = setprod (\<lambda>i. a) {0..m}" unfolding setprod_constant[OF f, of a] by simp |
|
1304 |
show ?thesis unfolding th0 fps_setprod_nth .. |
|
1305 |
qed |
|
1306 |
lemma fps_power_nth: |
|
1307 |
fixes m :: nat and a :: "('a::comm_ring_1) fps" |
|
1308 |
shows "(a ^m)$n = (if m=0 then 1$n else setsum (\<lambda>v. setprod (\<lambda>j. a $ (v!j)) {0..m - 1}) (natpermute n m))" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1309 |
by (cases m, simp_all add: fps_power_nth_Suc del: power_Suc) |
29687 | 1310 |
|
30488 | 1311 |
lemma fps_nth_power_0: |
31021 | 1312 |
fixes m :: nat and a :: "('a::{comm_ring_1}) fps" |
29687 | 1313 |
shows "(a ^m)$0 = (a$0) ^ m" |
1314 |
proof- |
|
1315 |
{assume "m=0" hence ?thesis by simp} |
|
1316 |
moreover |
|
1317 |
{fix n assume m: "m = Suc n" |
|
1318 |
have c: "m = card {0..n}" using m by simp |
|
1319 |
have "(a ^m)$0 = setprod (\<lambda>i. a$0) {0..n}" |
|
30837
3d4832d9f7e4
added strong_setprod_cong[cong] (in analogy with setsum)
nipkow
parents:
30747
diff
changeset
|
1320 |
by (simp add: m fps_power_nth del: replicate.simps power_Suc) |
29687 | 1321 |
also have "\<dots> = (a$0) ^ m" |
1322 |
unfolding c by (rule setprod_constant, simp) |
|
1323 |
finally have ?thesis .} |
|
1324 |
ultimately show ?thesis by (cases m, auto) |
|
1325 |
qed |
|
1326 |
||
30488 | 1327 |
lemma fps_compose_inj_right: |
31021 | 1328 |
assumes a0: "a$0 = (0::'a::{idom})" |
29687 | 1329 |
and a1: "a$1 \<noteq> 0" |
1330 |
shows "(b oo a = c oo a) \<longleftrightarrow> b = c" (is "?lhs \<longleftrightarrow>?rhs") |
|
1331 |
proof- |
|
1332 |
{assume ?rhs then have "?lhs" by simp} |
|
1333 |
moreover |
|
1334 |
{assume h: ?lhs |
|
30488 | 1335 |
{fix n have "b$n = c$n" |
29687 | 1336 |
proof(induct n rule: nat_less_induct) |
1337 |
fix n assume H: "\<forall>m<n. b$m = c$m" |
|
1338 |
{assume n0: "n=0" |
|
1339 |
from h have "(b oo a)$n = (c oo a)$n" by simp |
|
1340 |
hence "b$n = c$n" using n0 by (simp add: fps_compose_nth)} |
|
1341 |
moreover |
|
1342 |
{fix n1 assume n1: "n = Suc n1" |
|
1343 |
have f: "finite {0 .. n1}" "finite {n}" by simp_all |
|
1344 |
have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using n1 by auto |
|
1345 |
have d: "{0 .. n1} \<inter> {n} = {}" using n1 by auto |
|
1346 |
have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)" |
|
1347 |
apply (rule setsum_cong2) |
|
1348 |
using H n1 by auto |
|
1349 |
have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n" |
|
1350 |
unfolding fps_compose_nth setsum_Un_disjoint[OF f d, unfolded eq] seq |
|
1351 |
using startsby_zero_power_nth_same[OF a0] |
|
1352 |
by simp |
|
1353 |
have th1: "(c oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + c$n * (a$1)^n" |
|
1354 |
unfolding fps_compose_nth setsum_Un_disjoint[OF f d, unfolded eq] |
|
1355 |
using startsby_zero_power_nth_same[OF a0] |
|
1356 |
by simp |
|
1357 |
from h[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1 |
|
1358 |
have "b$n = c$n" by auto} |
|
1359 |
ultimately show "b$n = c$n" by (cases n, auto) |
|
1360 |
qed} |
|
1361 |
then have ?rhs by (simp add: fps_eq_iff)} |
|
1362 |
ultimately show ?thesis by blast |
|
1363 |
qed |
|
1364 |
||
1365 |
||
29906 | 1366 |
subsection {* Radicals *} |
29687 | 1367 |
|
1368 |
declare setprod_cong[fundef_cong] |
|
31021 | 1369 |
function radical :: "(nat \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> ('a::{field}) fps \<Rightarrow> nat \<Rightarrow> 'a" where |
29687 | 1370 |
"radical r 0 a 0 = 1" |
1371 |
| "radical r 0 a (Suc n) = 0" |
|
1372 |
| "radical r (Suc k) a 0 = r (Suc k) (a$0)" |
|
1373 |
| "radical r (Suc k) a (Suc n) = (a$ Suc n - setsum (\<lambda>xs. setprod (\<lambda>j. radical r (Suc k) a (xs ! j)) {0..k}) {xs. xs \<in> natpermute (Suc n) (Suc k) \<and> Suc n \<notin> set xs}) / (of_nat (Suc k) * (radical r (Suc k) a 0)^k)" |
|
1374 |
by pat_completeness auto |
|
1375 |
||
1376 |
termination radical |
|
1377 |
proof |
|
1378 |
let ?R = "measure (\<lambda>(r, k, a, n). n)" |
|
1379 |
{ |
|
1380 |
show "wf ?R" by auto} |
|
1381 |
{fix r k a n xs i |
|
1382 |
assume xs: "xs \<in> {xs \<in> natpermute (Suc n) (Suc k). Suc n \<notin> set xs}" and i: "i \<in> {0..k}" |
|
1383 |
{assume c: "Suc n \<le> xs ! i" |
|
1384 |
from xs i have "xs !i \<noteq> Suc n" by (auto simp add: in_set_conv_nth natpermute_def) |
|
1385 |
with c have c': "Suc n < xs!i" by arith |
|
1386 |
have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" by simp_all |
|
1387 |
have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" by auto |
|
1388 |
have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" using i by auto |
|
1389 |
from xs have "Suc n = foldl op + 0 xs" by (simp add: natpermute_def) |
|
1390 |
also have "\<dots> = setsum (nth xs) {0..<Suc k}" unfolding foldl_add_setsum using xs |
|
1391 |
by (simp add: natpermute_def) |
|
1392 |
also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}" |
|
1393 |
unfolding eqs setsum_Un_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] |
|
1394 |
unfolding setsum_Un_disjoint[OF fths(2) fths(3) d(2)] |
|
1395 |
by simp |
|
1396 |
finally have False using c' by simp} |
|
30488 | 1397 |
then show "((r,Suc k,a,xs!i), r, Suc k, a, Suc n) \<in> ?R" |
29687 | 1398 |
apply auto by (metis not_less)} |
30488 | 1399 |
{fix r k a n |
29687 | 1400 |
show "((r,Suc k, a, 0),r, Suc k, a, Suc n) \<in> ?R" by simp} |
1401 |
qed |
|
1402 |
||
1403 |
definition "fps_radical r n a = Abs_fps (radical r n a)" |
|
1404 |
||
1405 |
lemma fps_radical0[simp]: "fps_radical r 0 a = 1" |
|
1406 |
apply (auto simp add: fps_eq_iff fps_radical_def) by (case_tac n, auto) |
|
1407 |
||
1408 |
lemma fps_radical_nth_0[simp]: "fps_radical r n a $ 0 = (if n=0 then 1 else r n (a$0))" |
|
1409 |
by (cases n, simp_all add: fps_radical_def) |
|
1410 |
||
30488 | 1411 |
lemma fps_radical_power_nth[simp]: |
29687 | 1412 |
assumes r: "(r k (a$0)) ^ k = a$0" |
1413 |
shows "fps_radical r k a ^ k $ 0 = (if k = 0 then 1 else a$0)" |
|
1414 |
proof- |
|
1415 |
{assume "k=0" hence ?thesis by simp } |
|
1416 |
moreover |
|
30488 | 1417 |
{fix h assume h: "k = Suc h" |
29687 | 1418 |
have fh: "finite {0..h}" by simp |
1419 |
have eq1: "fps_radical r k a ^ k $ 0 = (\<Prod>j\<in>{0..h}. fps_radical r k a $ (replicate k 0) ! j)" |
|
1420 |
unfolding fps_power_nth h by simp |
|
1421 |
also have "\<dots> = (\<Prod>j\<in>{0..h}. r k (a$0))" |
|
1422 |
apply (rule setprod_cong) |
|
1423 |
apply simp |
|
1424 |
using h |
|
1425 |
apply (subgoal_tac "replicate k (0::nat) ! x = 0") |
|
1426 |
by (auto intro: nth_replicate simp del: replicate.simps) |
|
1427 |
also have "\<dots> = a$0" |
|
1428 |
unfolding setprod_constant[OF fh] using r by (simp add: h) |
|
1429 |
finally have ?thesis using h by simp} |
|
1430 |
ultimately show ?thesis by (cases k, auto) |
|
30488 | 1431 |
qed |
29687 | 1432 |
|
30488 | 1433 |
lemma natpermute_max_card: assumes n0: "n\<noteq>0" |
29687 | 1434 |
shows "card {xs \<in> natpermute n (k+1). n \<in> set xs} = k+1" |
1435 |
unfolding natpermute_contain_maximal |
|
1436 |
proof- |
|
1437 |
let ?A= "\<lambda>i. {replicate (k + 1) 0[i := n]}" |
|
1438 |
let ?K = "{0 ..k}" |
|
1439 |
have fK: "finite ?K" by simp |
|
1440 |
have fAK: "\<forall>i\<in>?K. finite (?A i)" by auto |
|
1441 |
have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow> {replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}" |
|
1442 |
proof(clarify) |
|
1443 |
fix i j assume i: "i \<in> ?K" and j: "j\<in> ?K" and ij: "i\<noteq>j" |
|
1444 |
{assume eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]" |
|
1445 |
have "(replicate (k+1) 0 [i:=n] ! i) = n" using i by (simp del: replicate.simps) |
|
1446 |
moreover |
|
1447 |
have "(replicate (k+1) 0 [j:=n] ! i) = 0" using i ij by (simp del: replicate.simps) |
|
1448 |
ultimately have False using eq n0 by (simp del: replicate.simps)} |
|
1449 |
then show "{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}" |
|
1450 |
by auto |
|
1451 |
qed |
|
30488 | 1452 |
from card_UN_disjoint[OF fK fAK d] |
29687 | 1453 |
show "card (\<Union>i\<in>{0..k}. {replicate (k + 1) 0[i := n]}) = k+1" by simp |
1454 |
qed |
|
30488 | 1455 |
|
1456 |
lemma power_radical: |
|
31021 | 1457 |
fixes a:: "'a ::{field, ring_char_0} fps" |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1458 |
assumes a0: "a$0 \<noteq> 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1459 |
shows "(r (Suc k) (a$0)) ^ Suc k = a$0 \<longleftrightarrow> (fps_radical r (Suc k) a) ^ (Suc k) = a" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1460 |
proof- |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1461 |
let ?r = "fps_radical r (Suc k) a" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1462 |
{assume r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1463 |
from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1464 |
{fix z have "?r ^ Suc k $ z = a$z" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1465 |
proof(induct z rule: nat_less_induct) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1466 |
fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1467 |
{assume "n = 0" hence "?r ^ Suc k $ n = a $n" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1468 |
using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1469 |
moreover |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1470 |
{fix n1 assume n1: "n = Suc n1" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1471 |
have fK: "finite {0..k}" by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1472 |
have nz: "n \<noteq> 0" using n1 by arith |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1473 |
let ?Pnk = "natpermute n (k + 1)" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1474 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1475 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1476 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1477 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1478 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1479 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1480 |
by (metis natpermute_finite)+ |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1481 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1482 |
have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1483 |
proof(rule setsum_cong2) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1484 |
fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1485 |
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" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1486 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1487 |
unfolding natpermute_contain_maximal by auto |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1488 |
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))" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1489 |
apply (rule setprod_cong, simp) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1490 |
using i r0 by (simp del: replicate.simps) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1491 |
also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1492 |
unfolding setprod_gen_delta[OF fK] using i r0 by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1493 |
finally show ?ths . |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1494 |
qed |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1495 |
then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1496 |
by (simp add: natpermute_max_card[OF nz, simplified]) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1497 |
also have "\<dots> = a$n - setsum ?f ?Pnknn" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1498 |
unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc ) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1499 |
finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1500 |
have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1501 |
unfolding fps_power_nth_Suc setsum_Un_disjoint[OF f d, unfolded eq] .. |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1502 |
also have "\<dots> = a$n" unfolding fn by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1503 |
finally have "?r ^ Suc k $ n = a $n" .} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1504 |
ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1505 |
qed } |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1506 |
then have ?thesis using r0 by (simp add: fps_eq_iff)} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1507 |
moreover |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1508 |
{ assume h: "(fps_radical r (Suc k) a) ^ (Suc k) = a" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1509 |
hence "((fps_radical r (Suc k) a) ^ (Suc k))$0 = a$0" by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1510 |
then have "(r (Suc k) (a$0)) ^ Suc k = a$0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1511 |
unfolding fps_power_nth_Suc |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1512 |
by (simp add: setprod_constant del: replicate.simps)} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1513 |
ultimately show ?thesis by blast |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1514 |
qed |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1515 |
|
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1516 |
(* |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1517 |
lemma power_radical: |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1518 |
fixes a:: "'a ::{field, ring_char_0} fps" |
29687 | 1519 |
assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" |
30488 | 1520 |
shows "(fps_radical r (Suc k) a) ^ (Suc k) = a" |
29687 | 1521 |
proof- |
1522 |
let ?r = "fps_radical r (Suc k) a" |
|
1523 |
from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto |
|
1524 |
{fix z have "?r ^ Suc k $ z = a$z" |
|
1525 |
proof(induct z rule: nat_less_induct) |
|
1526 |
fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m" |
|
1527 |
{assume "n = 0" hence "?r ^ Suc k $ n = a $n" |
|
1528 |
using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp} |
|
1529 |
moreover |
|
1530 |
{fix n1 assume n1: "n = Suc n1" |
|
1531 |
have fK: "finite {0..k}" by simp |
|
1532 |
have nz: "n \<noteq> 0" using n1 by arith |
|
1533 |
let ?Pnk = "natpermute n (k + 1)" |
|
1534 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
|
1535 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
|
1536 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
|
1537 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
|
30488 | 1538 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
29687 | 1539 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
1540 |
by (metis natpermute_finite)+ |
|
1541 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
|
30488 | 1542 |
have "setsum ?f ?Pnkn = setsum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn" |
29687 | 1543 |
proof(rule setsum_cong2) |
1544 |
fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}" |
|
1545 |
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" |
|
1546 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
|
1547 |
unfolding natpermute_contain_maximal by auto |
|
1548 |
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))" |
|
1549 |
apply (rule setprod_cong, simp) |
|
1550 |
using i r0 by (simp del: replicate.simps) |
|
1551 |
also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k" |
|
1552 |
unfolding setprod_gen_delta[OF fK] using i r0 by simp |
|
1553 |
finally show ?ths . |
|
1554 |
qed |
|
30488 | 1555 |
then have "setsum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k" |
1556 |
by (simp add: natpermute_max_card[OF nz, simplified]) |
|
29687 | 1557 |
also have "\<dots> = a$n - setsum ?f ?Pnknn" |
1558 |
unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc ) |
|
1559 |
finally have fn: "setsum ?f ?Pnkn = a$n - setsum ?f ?Pnknn" . |
|
30488 | 1560 |
have "(?r ^ Suc k)$n = setsum ?f ?Pnkn + setsum ?f ?Pnknn" |
29687 | 1561 |
unfolding fps_power_nth_Suc setsum_Un_disjoint[OF f d, unfolded eq] .. |
1562 |
also have "\<dots> = a$n" unfolding fn by simp |
|
1563 |
finally have "?r ^ Suc k $ n = a $n" .} |
|
1564 |
ultimately show "?r ^ Suc k $ n = a $n" by (cases n, auto) |
|
1565 |
qed } |
|
1566 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1567 |
qed |
|
1568 |
||
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1569 |
*) |
29687 | 1570 |
lemma eq_divide_imp': assumes c0: "(c::'a::field) ~= 0" and eq: "a * c = b" |
30488 | 1571 |
shows "a = b / c" |
29687 | 1572 |
proof- |
1573 |
from eq have "a * c * inverse c = b * inverse c" by simp |
|
1574 |
hence "a * (inverse c * c) = b/c" by (simp only: field_simps divide_inverse) |
|
1575 |
then show "a = b/c" unfolding field_inverse[OF c0] by simp |
|
1576 |
qed |
|
1577 |
||
30488 | 1578 |
lemma radical_unique: |
1579 |
assumes r0: "(r (Suc k) (b$0)) ^ Suc k = b$0" |
|
31021 | 1580 |
and a0: "r (Suc k) (b$0 ::'a::{field, ring_char_0}) = a$0" and b0: "b$0 \<noteq> 0" |
29687 | 1581 |
shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b" |
1582 |
proof- |
|
1583 |
let ?r = "fps_radical r (Suc k) b" |
|
1584 |
have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto |
|
1585 |
{assume H: "a = ?r" |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1586 |
from H have "a^Suc k = b" using power_radical[OF b0, of r k, unfolded r0] by simp} |
29687 | 1587 |
moreover |
1588 |
{assume H: "a^Suc k = b" |
|
1589 |
have ceq: "card {0..k} = Suc k" by simp |
|
1590 |
have fk: "finite {0..k}" by simp |
|
1591 |
from a0 have a0r0: "a$0 = ?r$0" by simp |
|
1592 |
{fix n have "a $ n = ?r $ n" |
|
1593 |
proof(induct n rule: nat_less_induct) |
|
1594 |
fix n assume h: "\<forall>m<n. a$m = ?r $m" |
|
1595 |
{assume "n = 0" hence "a$n = ?r $n" using a0 by simp } |
|
1596 |
moreover |
|
1597 |
{fix n1 assume n1: "n = Suc n1" |
|
1598 |
have fK: "finite {0..k}" by simp |
|
1599 |
have nz: "n \<noteq> 0" using n1 by arith |
|
1600 |
let ?Pnk = "natpermute n (Suc k)" |
|
1601 |
let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}" |
|
1602 |
let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}" |
|
1603 |
have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast |
|
1604 |
have d: "?Pnkn \<inter> ?Pnknn = {}" by blast |
|
30488 | 1605 |
have f: "finite ?Pnkn" "finite ?Pnknn" |
29687 | 1606 |
using finite_Un[of ?Pnkn ?Pnknn, unfolded eq] |
1607 |
by (metis natpermute_finite)+ |
|
1608 |
let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j" |
|
1609 |
let ?g = "\<lambda>v. \<Prod>j\<in>{0..k}. a $ v ! j" |
|
30488 | 1610 |
have "setsum ?g ?Pnkn = setsum (\<lambda>v. a $ n * (?r$0)^k) ?Pnkn" |
29687 | 1611 |
proof(rule setsum_cong2) |
1612 |
fix v assume v: "v \<in> {xs \<in> natpermute n (Suc k). n \<in> set xs}" |
|
1613 |
let ?ths = "(\<Prod>j\<in>{0..k}. a $ v ! j) = a $ n * (?r$0)^k" |
|
1614 |
from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]" |
|
1615 |
unfolding Suc_plus1 natpermute_contain_maximal by (auto simp del: replicate.simps) |
|
1616 |
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))" |
|
1617 |
apply (rule setprod_cong, simp) |
|
1618 |
using i a0 by (simp del: replicate.simps) |
|
1619 |
also have "\<dots> = a $ n * (?r $ 0)^k" |
|
1620 |
unfolding setprod_gen_delta[OF fK] using i by simp |
|
1621 |
finally show ?ths . |
|
1622 |
qed |
|
30488 | 1623 |
then have th0: "setsum ?g ?Pnkn = of_nat (k+1) * a $ n * (?r $ 0)^k" |
29687 | 1624 |
by (simp add: natpermute_max_card[OF nz, simplified]) |
1625 |
have th1: "setsum ?g ?Pnknn = setsum ?f ?Pnknn" |
|
1626 |
proof (rule setsum_cong2, rule setprod_cong, simp) |
|
1627 |
fix xs i assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}" |
|
1628 |
{assume c: "n \<le> xs ! i" |
|
1629 |
from xs i have "xs !i \<noteq> n" by (auto simp add: in_set_conv_nth natpermute_def) |
|
1630 |
with c have c': "n < xs!i" by arith |
|
1631 |
have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}" by simp_all |
|
1632 |
have d: "{0 ..< i} \<inter> ({i} \<union> {i+1 ..< Suc k}) = {}" "{i} \<inter> {i+1..< Suc k} = {}" by auto |
|
1633 |
have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})" using i by auto |
|
1634 |
from xs have "n = foldl op + 0 xs" by (simp add: natpermute_def) |
|
1635 |
also have "\<dots> = setsum (nth xs) {0..<Suc k}" unfolding foldl_add_setsum using xs |
|
1636 |
by (simp add: natpermute_def) |
|
1637 |
also have "\<dots> = xs!i + setsum (nth xs) {0..<i} + setsum (nth xs) {i+1..<Suc k}" |
|
1638 |
unfolding eqs setsum_Un_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)] |
|
1639 |
unfolding setsum_Un_disjoint[OF fths(2) fths(3) d(2)] |
|
1640 |
by simp |
|
1641 |
finally have False using c' by simp} |
|
1642 |
then have thn: "xs!i < n" by arith |
|
30488 | 1643 |
from h[rule_format, OF thn] |
29687 | 1644 |
show "a$(xs !i) = ?r$(xs!i)" . |
1645 |
qed |
|
1646 |
have th00: "\<And>(x::'a). of_nat (Suc k) * (x * inverse (of_nat (Suc k))) = x" |
|
1647 |
by (simp add: field_simps del: of_nat_Suc) |
|
1648 |
from H have "b$n = a^Suc k $ n" by (simp add: fps_eq_iff) |
|
1649 |
also have "a ^ Suc k$n = setsum ?g ?Pnkn + setsum ?g ?Pnknn" |
|
30488 | 1650 |
unfolding fps_power_nth_Suc |
1651 |
using setsum_Un_disjoint[OF f d, unfolded Suc_plus1[symmetric], |
|
29687 | 1652 |
unfolded eq, of ?g] by simp |
1653 |
also have "\<dots> = of_nat (k+1) * a $ n * (?r $ 0)^k + setsum ?f ?Pnknn" unfolding th0 th1 .. |
|
1654 |
finally have "of_nat (k+1) * a $ n * (?r $ 0)^k = b$n - setsum ?f ?Pnknn" by simp |
|
1655 |
then have "a$n = (b$n - setsum ?f ?Pnknn) / (of_nat (k+1) * (?r $ 0)^k)" |
|
30488 | 1656 |
apply - |
29687 | 1657 |
apply (rule eq_divide_imp') |
1658 |
using r00 |
|
1659 |
apply (simp del: of_nat_Suc) |
|
1660 |
by (simp add: mult_ac) |
|
1661 |
then have "a$n = ?r $n" |
|
1662 |
apply (simp del: of_nat_Suc) |
|
1663 |
unfolding fps_radical_def n1 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1664 |
by (simp add: field_simps n1 th00 del: of_nat_Suc)} |
29687 | 1665 |
ultimately show "a$n = ?r $ n" by (cases n, auto) |
1666 |
qed} |
|
1667 |
then have "a = ?r" by (simp add: fps_eq_iff)} |
|
1668 |
ultimately show ?thesis by blast |
|
1669 |
qed |
|
1670 |
||
1671 |
||
30488 | 1672 |
lemma radical_power: |
1673 |
assumes r0: "r (Suc k) ((a$0) ^ Suc k) = a$0" |
|
31021 | 1674 |
and a0: "(a$0 ::'a::{field, ring_char_0}) \<noteq> 0" |
29687 | 1675 |
shows "(fps_radical r (Suc k) (a ^ Suc k)) = a" |
1676 |
proof- |
|
1677 |
let ?ak = "a^ Suc k" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1678 |
have ak0: "?ak $ 0 = (a$0) ^ Suc k" by (simp add: fps_nth_power_0 del: power_Suc) |
29687 | 1679 |
from r0 have th0: "r (Suc k) (a ^ Suc k $ 0) ^ Suc k = a ^ Suc k $ 0" using ak0 by auto |
1680 |
from r0 ak0 have th1: "r (Suc k) (a ^ Suc k $ 0) = a $ 0" by auto |
|
1681 |
from ak0 a0 have ak00: "?ak $ 0 \<noteq>0 " by auto |
|
1682 |
from radical_unique[of r k ?ak a, OF th0 th1 ak00] show ?thesis by metis |
|
1683 |
qed |
|
1684 |
||
30488 | 1685 |
lemma fps_deriv_radical: |
31021 | 1686 |
fixes a:: "'a ::{field, ring_char_0} fps" |
29687 | 1687 |
assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0" and a0: "a$0 \<noteq> 0" |
1688 |
shows "fps_deriv (fps_radical r (Suc k) a) = fps_deriv a / (fps_const (of_nat (Suc k)) * (fps_radical r (Suc k) a) ^ k)" |
|
1689 |
proof- |
|
1690 |
let ?r= "fps_radical r (Suc k) a" |
|
1691 |
let ?w = "(fps_const (of_nat (Suc k)) * ?r ^ k)" |
|
1692 |
from a0 r0 have r0': "r (Suc k) (a$0) \<noteq> 0" by auto |
|
1693 |
from r0' have w0: "?w $ 0 \<noteq> 0" by (simp del: of_nat_Suc) |
|
1694 |
note th0 = inverse_mult_eq_1[OF w0] |
|
1695 |
let ?iw = "inverse ?w" |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1696 |
from iffD1[OF power_radical[of a r], OF a0 r0] |
29687 | 1697 |
have "fps_deriv (?r ^ Suc k) = fps_deriv a" by simp |
1698 |
hence "fps_deriv ?r * ?w = fps_deriv a" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1699 |
by (simp add: fps_deriv_power mult_ac del: power_Suc) |
29687 | 1700 |
hence "?iw * fps_deriv ?r * ?w = ?iw * fps_deriv a" by simp |
1701 |
hence "fps_deriv ?r * (?iw * ?w) = fps_deriv a / ?w" |
|
1702 |
by (simp add: fps_divide_def) |
|
30488 | 1703 |
then show ?thesis unfolding th0 by simp |
29687 | 1704 |
qed |
1705 |
||
30488 | 1706 |
lemma radical_mult_distrib: |
31021 | 1707 |
fixes a:: "'a ::{field, ring_char_0} fps" |
30488 | 1708 |
assumes |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1709 |
k: "k > 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1710 |
and ra0: "r k (a $ 0) ^ k = a $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1711 |
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
|
1712 |
and a0: "a$0 \<noteq> 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1713 |
and b0: "b$0 \<noteq> 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1714 |
shows "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0) \<longleftrightarrow> fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1715 |
proof- |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1716 |
{assume r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1717 |
from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1718 |
by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1719 |
{assume "k=0" hence ?thesis using r0' by simp} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1720 |
moreover |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1721 |
{fix h assume k: "k = Suc h" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1722 |
let ?ra = "fps_radical r (Suc h) a" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1723 |
let ?rb = "fps_radical r (Suc h) b" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1724 |
have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1725 |
using r0' k by (simp add: fps_mult_nth) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1726 |
have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1727 |
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] |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1728 |
iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded k]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded k]] k r0' |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1729 |
have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1730 |
ultimately have ?thesis by (cases k, auto)} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1731 |
moreover |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1732 |
{assume h: "fps_radical r k (a*b) = fps_radical r k a * fps_radical r k b" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1733 |
hence "(fps_radical r k (a*b))$0 = (fps_radical r k a * fps_radical r k b)$0" by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1734 |
then have "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1735 |
using k by (simp add: fps_mult_nth)} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1736 |
ultimately show ?thesis by blast |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1737 |
qed |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1738 |
|
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1739 |
(* |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1740 |
lemma radical_mult_distrib: |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1741 |
fixes a:: "'a ::{field, ring_char_0} fps" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1742 |
assumes |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1743 |
ra0: "r k (a $ 0) ^ k = a $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1744 |
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
|
1745 |
and r0': "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0)" |
29687 | 1746 |
and a0: "a$0 \<noteq> 0" |
1747 |
and b0: "b$0 \<noteq> 0" |
|
1748 |
shows "fps_radical r (k) (a*b) = fps_radical r (k) a * fps_radical r (k) (b)" |
|
1749 |
proof- |
|
1750 |
from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0" |
|
1751 |
by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib) |
|
1752 |
{assume "k=0" hence ?thesis by simp} |
|
1753 |
moreover |
|
1754 |
{fix h assume k: "k = Suc h" |
|
1755 |
let ?ra = "fps_radical r (Suc h) a" |
|
1756 |
let ?rb = "fps_radical r (Suc h) b" |
|
30488 | 1757 |
have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0" |
29687 | 1758 |
using r0' k by (simp add: fps_mult_nth) |
1759 |
have ab0: "(a*b) $ 0 \<noteq> 0" using a0 b0 by (simp add: fps_mult_nth) |
|
30488 | 1760 |
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 | 1761 |
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
|
1762 |
have ?thesis by (auto simp add: power_mult_distrib simp del: power_Suc)} |
29687 | 1763 |
ultimately show ?thesis by (cases k, auto) |
1764 |
qed |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1765 |
*) |
29687 | 1766 |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1767 |
lemma fps_divide_1[simp]: "(a:: ('a::field) fps) / 1 = a" |
29687 | 1768 |
by (simp add: fps_divide_def) |
1769 |
||
1770 |
lemma radical_divide: |
|
31021 | 1771 |
fixes a:: "'a ::{field, ring_char_0} fps" |
30488 | 1772 |
assumes |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1773 |
kp: "k>0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1774 |
and ra0: "(r k (a $ 0)) ^ k = a $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1775 |
and rb0: "(r k (b $ 0)) ^ k = b $ 0" |
30488 | 1776 |
and a0: "a$0 \<noteq> 0" |
29687 | 1777 |
and b0: "b$0 \<noteq> 0" |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1778 |
shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow> fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b" (is "?lhs = ?rhs") |
29687 | 1779 |
proof- |
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1780 |
let ?r = "fps_radical r k" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1781 |
from kp obtain h where k: "k = Suc h" by (cases k, auto) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1782 |
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
|
1783 |
have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto |
30488 | 1784 |
|
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1785 |
{assume ?rhs |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1786 |
then have "?r (a/b) $ 0 = (?r a / ?r b)$0" by simp |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1787 |
then have ?lhs using k a0 b0 rb0' |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1788 |
by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse) } |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1789 |
moreover |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1790 |
{assume h: ?lhs |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1791 |
from a0 b0 have ab0[simp]: "(a/b)$0 = a$0 / b$0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1792 |
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
|
1793 |
have th0: "r k ((a/b)$0) ^ k = (a/b)$0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1794 |
by (simp add: h nonzero_power_divide[OF rb0'] ra0 rb0 del: k) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1795 |
from a0 b0 ra0' rb0' kp h |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1796 |
have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1797 |
by (simp add: fps_divide_def fps_mult_nth fps_inverse_def divide_inverse del: k) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1798 |
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
|
1799 |
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
|
1800 |
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
|
1801 |
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
|
1802 |
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
|
1803 |
by (simp add: fps_divide_def power_mult_distrib fps_inverse_power[symmetric]) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1804 |
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] have ?rhs .} |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1805 |
ultimately show ?thesis by blast |
29687 | 1806 |
qed |
1807 |
||
31073
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1808 |
lemma radical_inverse: |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1809 |
fixes a:: "'a ::{field, ring_char_0} fps" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1810 |
assumes |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1811 |
k: "k>0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1812 |
and ra0: "r k (a $ 0) ^ k = a $ 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1813 |
and r1: "(r k 1)^k = 1" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1814 |
and a0: "a$0 \<noteq> 0" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1815 |
shows "r k (inverse (a $ 0)) = r k 1 / (r k (a $ 0)) \<longleftrightarrow> fps_radical r k (inverse a) = fps_radical r k 1 / fps_radical r k a" |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1816 |
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
|
1817 |
by (simp add: divide_inverse fps_divide_def) |
4b44c4d08aa6
Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents:
31021
diff
changeset
|
1818 |
|
29906 | 1819 |
subsection{* Derivative of composition *} |
29687 | 1820 |
|
30488 | 1821 |
lemma fps_compose_deriv: |
29687 | 1822 |
fixes a:: "('a::idom) fps" |
1823 |
assumes b0: "b$0 = 0" |
|
1824 |
shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * (fps_deriv b)" |
|
1825 |
proof- |
|
1826 |
{fix n |
|
1827 |
have "(fps_deriv (a oo b))$n = setsum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}" |
|
1828 |
by (simp add: fps_compose_def ring_simps setsum_right_distrib del: of_nat_Suc) |
|
1829 |
also have "\<dots> = setsum (\<lambda>i. a$i * ((fps_const (of_nat i)) * (fps_deriv b * (b^(i - 1))))$n) {0.. Suc n}" |
|
1830 |
by (simp add: ring_simps fps_deriv_power del: fps_mult_left_const_nth of_nat_Suc) |
|
1831 |
also have "\<dots> = setsum (\<lambda>i. of_nat i * a$i * (((b^(i - 1)) * fps_deriv b))$n) {0.. Suc n}" |
|
1832 |
unfolding fps_mult_left_const_nth by (simp add: ring_simps) |
|
1833 |
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}" |
|
1834 |
unfolding fps_mult_nth .. |
|
1835 |
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}" |
|
1836 |
apply (rule setsum_mono_zero_right) |
|
29913 | 1837 |
apply (auto simp add: mult_delta_left setsum_delta not_le) |
1838 |
done |
|
29687 | 1839 |
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}" |
1840 |
unfolding fps_deriv_nth |
|
1841 |
apply (rule setsum_reindex_cong[where f="Suc"]) |
|
1842 |
by (auto simp add: mult_assoc) |
|
1843 |
finally have th0: "(fps_deriv (a oo b))$n = 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}" . |
|
30488 | 1844 |
|
29687 | 1845 |
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}" |
1846 |
unfolding fps_mult_nth by (simp add: mult_ac) |
|
1847 |
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}" |
|
1848 |
unfolding fps_deriv_nth fps_compose_nth setsum_right_distrib mult_assoc |
|
1849 |
apply (rule setsum_cong2) |
|
1850 |
apply (rule setsum_mono_zero_left) |
|
1851 |
apply (simp_all add: subset_eq) |
|
1852 |
apply clarify |
|
1853 |
apply (subgoal_tac "b^i$x = 0") |
|
1854 |
apply simp |
|
1855 |
apply (rule startsby_zero_power_prefix[OF b0, rule_format]) |
|
1856 |
by simp |
|
1857 |
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}" |
|
1858 |
unfolding setsum_right_distrib |
|
1859 |
apply (subst setsum_commute) |
|
1860 |
by ((rule setsum_cong2)+) simp |
|
1861 |
finally have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" |
|
1862 |
unfolding th0 by simp} |
|
1863 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1864 |
qed |
|
1865 |
||
1866 |
lemma fps_mult_X_plus_1_nth: |
|
1867 |
"((1+X)*a) $n = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" |
|
1868 |
proof- |
|
1869 |
{assume "n = 0" hence ?thesis by (simp add: fps_mult_nth )} |
|
1870 |
moreover |
|
1871 |
{fix m assume m: "n = Suc m" |
|
1872 |
have "((1+X)*a) $n = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0..n}" |
|
1873 |
by (simp add: fps_mult_nth) |
|
1874 |
also have "\<dots> = setsum (\<lambda>i. (1+X)$i * a$(n-i)) {0.. 1}" |
|
1875 |
unfolding m |
|
1876 |
apply (rule setsum_mono_zero_right) |
|
1877 |
by (auto simp add: ) |
|
1878 |
also have "\<dots> = (if n = 0 then (a$n :: 'a::comm_ring_1) else a$n + a$(n - 1))" |
|
1879 |
unfolding m |
|
1880 |
by (simp add: ) |
|
1881 |
finally have ?thesis .} |
|
1882 |
ultimately show ?thesis by (cases n, auto) |
|
1883 |
qed |
|
1884 |
||
29906 | 1885 |
subsection{* Finite FPS (i.e. polynomials) and X *} |
29687 | 1886 |
lemma fps_poly_sum_X: |
30488 | 1887 |
assumes z: "\<forall>i > n. a$i = (0::'a::comm_ring_1)" |
29687 | 1888 |
shows "a = setsum (\<lambda>i. fps_const (a$i) * X^i) {0..n}" (is "a = ?r") |
1889 |
proof- |
|
1890 |
{fix i |
|
30488 | 1891 |
have "a$i = ?r$i" |
29687 | 1892 |
unfolding fps_setsum_nth fps_mult_left_const_nth X_power_nth |
29913 | 1893 |
by (simp add: mult_delta_right setsum_delta' z) |
1894 |
} |
|
29687 | 1895 |
then show ?thesis unfolding fps_eq_iff by blast |
1896 |
qed |
|
1897 |
||
29906 | 1898 |
subsection{* Compositional inverses *} |
29687 | 1899 |
|
1900 |
||
31021 | 1901 |
fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::{field}" where |
29687 | 1902 |
"compinv a 0 = X$0" |
1903 |
| "compinv a (Suc n) = (X$ Suc n - setsum (\<lambda>i. (compinv a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n" |
|
1904 |
||
1905 |
definition "fps_inv a = Abs_fps (compinv a)" |
|
1906 |
||
1907 |
lemma fps_inv: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" |
|
1908 |
shows "fps_inv a oo a = X" |
|
1909 |
proof- |
|
1910 |
let ?i = "fps_inv a oo a" |
|
1911 |
{fix n |
|
30488 | 1912 |
have "?i $n = X$n" |
29687 | 1913 |
proof(induct n rule: nat_less_induct) |
1914 |
fix n assume h: "\<forall>m<n. ?i$m = X$m" |
|
30488 | 1915 |
{assume "n=0" hence "?i $n = X$n" using a0 |
29687 | 1916 |
by (simp add: fps_compose_nth fps_inv_def)} |
1917 |
moreover |
|
1918 |
{fix n1 assume n1: "n = Suc n1" |
|
1919 |
have "?i $ n = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1920 |
by (simp add: fps_compose_nth n1 startsby_zero_power_nth_same[OF a0] |
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1921 |
del: power_Suc) |
29687 | 1922 |
also have "\<dots> = setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + (X$ Suc n1 - setsum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1923 |
using a0 a1 n1 by (simp add: fps_inv_def) |
30488 | 1924 |
also have "\<dots> = X$n" using n1 by simp |
29687 | 1925 |
finally have "?i $ n = X$n" .} |
1926 |
ultimately show "?i $ n = X$n" by (cases n, auto) |
|
1927 |
qed} |
|
1928 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1929 |
qed |
|
1930 |
||
1931 |
||
31021 | 1932 |
fun gcompinv :: "'a fps \<Rightarrow> 'a fps \<Rightarrow> nat \<Rightarrow> 'a::{field}" where |
29687 | 1933 |
"gcompinv b a 0 = b$0" |
1934 |
| "gcompinv b a (Suc n) = (b$ Suc n - setsum (\<lambda>i. (gcompinv b a i) * (a^i)$Suc n) {0 .. n}) / (a$1) ^ Suc n" |
|
1935 |
||
1936 |
definition "fps_ginv b a = Abs_fps (gcompinv b a)" |
|
1937 |
||
1938 |
lemma fps_ginv: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" |
|
1939 |
shows "fps_ginv b a oo a = b" |
|
1940 |
proof- |
|
1941 |
let ?i = "fps_ginv b a oo a" |
|
1942 |
{fix n |
|
30488 | 1943 |
have "?i $n = b$n" |
29687 | 1944 |
proof(induct n rule: nat_less_induct) |
1945 |
fix n assume h: "\<forall>m<n. ?i$m = b$m" |
|
30488 | 1946 |
{assume "n=0" hence "?i $n = b$n" using a0 |
29687 | 1947 |
by (simp add: fps_compose_nth fps_ginv_def)} |
1948 |
moreover |
|
1949 |
{fix n1 assume n1: "n = Suc n1" |
|
1950 |
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" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1951 |
by (simp add: fps_compose_nth n1 startsby_zero_power_nth_same[OF a0] |
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
1952 |
del: power_Suc) |
29687 | 1953 |
also have "\<dots> = setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + (b$ Suc n1 - setsum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1954 |
using a0 a1 n1 by (simp add: fps_ginv_def) |
30488 | 1955 |
also have "\<dots> = b$n" using n1 by simp |
29687 | 1956 |
finally have "?i $ n = b$n" .} |
1957 |
ultimately show "?i $ n = b$n" by (cases n, auto) |
|
1958 |
qed} |
|
1959 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1960 |
qed |
|
1961 |
||
1962 |
lemma fps_inv_ginv: "fps_inv = fps_ginv X" |
|
1963 |
apply (auto simp add: expand_fun_eq fps_eq_iff fps_inv_def fps_ginv_def) |
|
1964 |
apply (induct_tac n rule: nat_less_induct, auto) |
|
1965 |
apply (case_tac na) |
|
1966 |
apply simp |
|
1967 |
apply simp |
|
1968 |
done |
|
1969 |
||
1970 |
lemma fps_compose_1[simp]: "1 oo a = 1" |
|
30960 | 1971 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta) |
29687 | 1972 |
|
1973 |
lemma fps_compose_0[simp]: "0 oo a = 0" |
|
29913 | 1974 |
by (simp add: fps_eq_iff fps_compose_nth) |
29687 | 1975 |
|
1976 |
lemma fps_compose_0_right[simp]: "a oo 0 = fps_const (a$0)" |
|
30960 | 1977 |
by (auto simp add: fps_eq_iff fps_compose_nth power_0_left setsum_0') |
29687 | 1978 |
|
1979 |
lemma fps_compose_add_distrib: "(a + b) oo c = (a oo c) + (b oo c)" |
|
30960 | 1980 |
by (simp add: fps_eq_iff fps_compose_nth ring_simps setsum_addf) |
29687 | 1981 |
|
1982 |
lemma fps_compose_setsum_distrib: "(setsum f S) oo a = setsum (\<lambda>i. f i oo a) S" |
|
1983 |
proof- |
|
1984 |
{assume "\<not> finite S" hence ?thesis by simp} |
|
1985 |
moreover |
|
1986 |
{assume fS: "finite S" |
|
1987 |
have ?thesis |
|
1988 |
proof(rule finite_induct[OF fS]) |
|
1989 |
show "setsum f {} oo a = (\<Sum>i\<in>{}. f i oo a)" by simp |
|
1990 |
next |
|
1991 |
fix x F assume fF: "finite F" and xF: "x \<notin> F" and h: "setsum f F oo a = setsum (\<lambda>i. f i oo a) F" |
|
1992 |
show "setsum f (insert x F) oo a = setsum (\<lambda>i. f i oo a) (insert x F)" |
|
1993 |
using fF xF h by (simp add: fps_compose_add_distrib) |
|
1994 |
qed} |
|
30488 | 1995 |
ultimately show ?thesis by blast |
29687 | 1996 |
qed |
1997 |
||
30488 | 1998 |
lemma convolution_eq: |
29687 | 1999 |
"setsum (%i. a (i :: nat) * b (n - i)) {0 .. n} = setsum (%(i,j). a i * b j) {(i,j). i <= n \<and> j \<le> n \<and> i + j = n}" |
2000 |
apply (rule setsum_reindex_cong[where f=fst]) |
|
2001 |
apply (clarsimp simp add: inj_on_def) |
|
2002 |
apply (auto simp add: expand_set_eq image_iff) |
|
2003 |
apply (rule_tac x= "x" in exI) |
|
2004 |
apply clarsimp |
|
2005 |
apply (rule_tac x="n - x" in exI) |
|
2006 |
apply arith |
|
2007 |
done |
|
2008 |
||
2009 |
lemma product_composition_lemma: |
|
2010 |
assumes c0: "c$0 = (0::'a::idom)" and d0: "d$0 = 0" |
|
2011 |
shows "((a oo c) * (b oo d))$n = setsum (%(k,m). a$k * b$m * (c^k * d^m) $ n) {(k,m). k + m \<le> n}" (is "?l = ?r") |
|
2012 |
proof- |
|
2013 |
let ?S = "{(k\<Colon>nat, m\<Colon>nat). k + m \<le> n}" |
|
30488 | 2014 |
have s: "?S \<subseteq> {0..n} <*> {0..n}" by (auto simp add: subset_eq) |
2015 |
have f: "finite {(k\<Colon>nat, m\<Colon>nat). k + m \<le> n}" |
|
29687 | 2016 |
apply (rule finite_subset[OF s]) |
2017 |
by auto |
|
2018 |
have "?r = setsum (%i. setsum (%(k,m). a$k * (c^k)$i * b$m * (d^m) $ (n - i)) {(k,m). k + m \<le> n}) {0..n}" |
|
2019 |
apply (simp add: fps_mult_nth setsum_right_distrib) |
|
2020 |
apply (subst setsum_commute) |
|
2021 |
apply (rule setsum_cong2) |
|
2022 |
by (auto simp add: ring_simps) |
|
30488 | 2023 |
also have "\<dots> = ?l" |
29687 | 2024 |
apply (simp add: fps_mult_nth fps_compose_nth setsum_product) |
2025 |
apply (rule setsum_cong2) |
|
2026 |
apply (simp add: setsum_cartesian_product mult_assoc) |
|
2027 |
apply (rule setsum_mono_zero_right[OF f]) |
|
2028 |
apply (simp add: subset_eq) apply presburger |
|
2029 |
apply clarsimp |
|
2030 |
apply (rule ccontr) |
|
2031 |
apply (clarsimp simp add: not_le) |
|
2032 |
apply (case_tac "x < aa") |
|
2033 |
apply simp |
|
2034 |
apply (frule_tac startsby_zero_power_prefix[rule_format, OF c0]) |
|
2035 |
apply blast |
|
2036 |
apply simp |
|
2037 |
apply (frule_tac startsby_zero_power_prefix[rule_format, OF d0]) |
|
2038 |
apply blast |
|
2039 |
done |
|
2040 |
finally show ?thesis by simp |
|
2041 |
qed |
|
2042 |
||
2043 |
lemma product_composition_lemma': |
|
2044 |
assumes c0: "c$0 = (0::'a::idom)" and d0: "d$0 = 0" |
|
2045 |
shows "((a oo c) * (b oo d))$n = setsum (%k. setsum (%m. a$k * b$m * (c^k * d^m) $ n) {0..n}) {0..n}" (is "?l = ?r") |
|
2046 |
unfolding product_composition_lemma[OF c0 d0] |
|
2047 |
unfolding setsum_cartesian_product |
|
2048 |
apply (rule setsum_mono_zero_left) |
|
2049 |
apply simp |
|
2050 |
apply (clarsimp simp add: subset_eq) |
|
2051 |
apply clarsimp |
|
2052 |
apply (rule ccontr) |
|
2053 |
apply (subgoal_tac "(c^aa * d^ba) $ n = 0") |
|
2054 |
apply simp |
|
2055 |
unfolding fps_mult_nth |
|
2056 |
apply (rule setsum_0') |
|
2057 |
apply (clarsimp simp add: not_le) |
|
2058 |
apply (case_tac "aaa < aa") |
|
2059 |
apply (rule startsby_zero_power_prefix[OF c0, rule_format]) |
|
2060 |
apply simp |
|
2061 |
apply (subgoal_tac "n - aaa < ba") |
|
2062 |
apply (frule_tac k = "ba" in startsby_zero_power_prefix[OF d0, rule_format]) |
|
2063 |
apply simp |
|
2064 |
apply arith |
|
2065 |
done |
|
30488 | 2066 |
|
29687 | 2067 |
|
30488 | 2068 |
lemma setsum_pair_less_iff: |
29687 | 2069 |
"setsum (%((k::nat),m). a k * b m * c (k + m)) {(k,m). k + m \<le> n} = setsum (%s. setsum (%i. a i * b (s - i) * c s) {0..s}) {0..n}" (is "?l = ?r") |
2070 |
proof- |
|
2071 |
let ?KM= "{(k,m). k + m \<le> n}" |
|
2072 |
let ?f = "%s. UNION {(0::nat)..s} (%i. {(i,s - i)})" |
|
2073 |
have th0: "?KM = UNION {0..n} ?f" |
|
2074 |
apply (simp add: expand_set_eq) |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2075 |
apply arith (* FIXME: VERY slow! *) |
29687 | 2076 |
done |
2077 |
show "?l = ?r " |
|
2078 |
unfolding th0 |
|
2079 |
apply (subst setsum_UN_disjoint) |
|
2080 |
apply auto |
|
2081 |
apply (subst setsum_UN_disjoint) |
|
2082 |
apply auto |
|
2083 |
done |
|
2084 |
qed |
|
2085 |
||
2086 |
lemma fps_compose_mult_distrib_lemma: |
|
2087 |
assumes c0: "c$0 = (0::'a::idom)" |
|
2088 |
shows "((a oo c) * (b oo c))$n = setsum (%s. setsum (%i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}" (is "?l = ?r") |
|
2089 |
unfolding product_composition_lemma[OF c0 c0] power_add[symmetric] |
|
2090 |
unfolding setsum_pair_less_iff[where a = "%k. a$k" and b="%m. b$m" and c="%s. (c ^ s)$n" and n = n] .. |
|
2091 |
||
2092 |
||
30488 | 2093 |
lemma fps_compose_mult_distrib: |
29687 | 2094 |
assumes c0: "c$0 = (0::'a::idom)" |
2095 |
shows "(a * b) oo c = (a oo c) * (b oo c)" (is "?l = ?r") |
|
2096 |
apply (simp add: fps_eq_iff fps_compose_mult_distrib_lemma[OF c0]) |
|
2097 |
by (simp add: fps_compose_nth fps_mult_nth setsum_left_distrib) |
|
30488 | 2098 |
lemma fps_compose_setprod_distrib: |
29687 | 2099 |
assumes c0: "c$0 = (0::'a::idom)" |
2100 |
shows "(setprod a S) oo c = setprod (%k. a k oo c) S" (is "?l = ?r") |
|
2101 |
apply (cases "finite S") |
|
2102 |
apply simp_all |
|
2103 |
apply (induct S rule: finite_induct) |
|
2104 |
apply simp |
|
2105 |
apply (simp add: fps_compose_mult_distrib[OF c0]) |
|
2106 |
done |
|
2107 |
||
2108 |
lemma fps_compose_power: assumes c0: "c$0 = (0::'a::idom)" |
|
2109 |
shows "(a oo c)^n = a^n oo c" (is "?l = ?r") |
|
2110 |
proof- |
|
2111 |
{assume "n=0" then have ?thesis by simp} |
|
2112 |
moreover |
|
2113 |
{fix m assume m: "n = Suc m" |
|
2114 |
have th0: "a^n = setprod (%k. a) {0..m}" "(a oo c) ^ n = setprod (%k. a oo c) {0..m}" |
|
2115 |
by (simp_all add: setprod_constant m) |
|
2116 |
then have ?thesis |
|
2117 |
by (simp add: fps_compose_setprod_distrib[OF c0])} |
|
2118 |
ultimately show ?thesis by (cases n, auto) |
|
2119 |
qed |
|
2120 |
||
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2121 |
lemma fps_compose_uminus: "- (a::'a::ring_1 fps) oo c = - (a oo c)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2122 |
by (simp add: fps_eq_iff fps_compose_nth ring_simps setsum_negf[symmetric]) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2123 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2124 |
lemma fps_compose_sub_distrib: |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2125 |
shows "(a - b) oo (c::'a::ring_1 fps) = (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
|
2126 |
unfolding diff_minus fps_compose_uminus fps_compose_add_distrib .. |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2127 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2128 |
lemma X_fps_compose:"X oo a = Abs_fps (\<lambda>n. if n = 0 then (0::'a::comm_ring_1) else a$n)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2129 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta power_Suc) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2130 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2131 |
lemma fps_inverse_compose: |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2132 |
assumes b0: "(b$0 :: 'a::field) = 0" and a0: "a$0 \<noteq> 0" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2133 |
shows "inverse a oo b = inverse (a oo b)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2134 |
proof- |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2135 |
let ?ia = "inverse a" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2136 |
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
|
2137 |
let ?iab = "inverse ?ab" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2138 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2139 |
from a0 have ia0: "?ia $ 0 \<noteq> 0" by (simp ) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2140 |
from a0 have ab0: "?ab $ 0 \<noteq> 0" by (simp add: fps_compose_def) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2141 |
thm inverse_mult_eq_1[OF ab0] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2142 |
have "(?ia oo b) * (a oo b) = 1" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2143 |
unfolding fps_compose_mult_distrib[OF b0, symmetric] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2144 |
unfolding inverse_mult_eq_1[OF a0] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2145 |
fps_compose_1 .. |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2146 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2147 |
then have "(?ia oo b) * (a oo b) * ?iab = 1 * ?iab" by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2148 |
then have "(?ia oo b) * (?iab * (a oo b)) = ?iab" by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2149 |
then show ?thesis |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2150 |
unfolding inverse_mult_eq_1[OF ab0] by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2151 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2152 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2153 |
lemma fps_divide_compose: |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2154 |
assumes c0: "(c$0 :: 'a::field) = 0" and b0: "b$0 \<noteq> 0" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2155 |
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
|
2156 |
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
|
2157 |
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
|
2158 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2159 |
lemma gp: assumes a0: "a$0 = (0::'a::field)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2160 |
shows "(Abs_fps (\<lambda>n. 1)) oo a = 1/(1 - a)" (is "?one oo a = _") |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2161 |
proof- |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2162 |
have o0: "?one $ 0 \<noteq> 0" by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2163 |
have th0: "(1 - X) $ 0 \<noteq> (0::'a)" by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2164 |
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
|
2165 |
have "inverse ?one = 1 - X" by (simp add: fps_eq_iff) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2166 |
hence "inverse (inverse ?one) = inverse (1 - X)" by simp |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2167 |
hence th: "?one = 1/(1 - X)" unfolding fps_inverse_idempotent[OF o0] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2168 |
by (simp add: fps_divide_def) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2169 |
show ?thesis unfolding th |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2170 |
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
|
2171 |
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
|
2172 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2173 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2174 |
lemma fps_const_power[simp]: "fps_const (c::'a::ring_1) ^ n = fps_const (c^n)" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2175 |
by (induct n, auto) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2176 |
|
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2177 |
lemma fps_compose_radical: |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2178 |
assumes b0: "b$0 = (0::'a::{field, ring_char_0})" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2179 |
and ra0: "r (Suc k) (a$0) ^ Suc k = a$0" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2180 |
and a0: "a$0 \<noteq> 0" |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2181 |
shows "fps_radical r (Suc k) a oo b = fps_radical r (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
|
2182 |
proof- |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2183 |
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
|
2184 |
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
|
2185 |
have ab0: "?ab $ 0 = a$0" by (simp add: fps_compose_def) |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2186 |
from ab0 a0 ra0 have rab0: "?ab $ 0 \<noteq> 0" "r (Suc k) (?ab $ 0) ^ Suc k = ?ab $ 0" by simp_all |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2187 |
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
|
2188 |
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
|
2189 |
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
|
2190 |
unfolding fps_compose_power[OF b0] |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2191 |
unfolding iffD1[OF power_radical[of a r k], OF a0 ra0] .. |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2192 |
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] show ?thesis . |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2193 |
qed |
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2194 |
|
29687 | 2195 |
lemma fps_const_mult_apply_left: |
2196 |
"fps_const c * (a oo b) = (fps_const c * a) oo b" |
|
2197 |
by (simp add: fps_eq_iff fps_compose_nth setsum_right_distrib mult_assoc) |
|
2198 |
||
2199 |
lemma fps_const_mult_apply_right: |
|
2200 |
"(a oo b) * fps_const (c::'a::comm_semiring_1) = (fps_const c * a) oo b" |
|
2201 |
by (auto simp add: fps_const_mult_apply_left mult_commute) |
|
2202 |
||
30488 | 2203 |
lemma fps_compose_assoc: |
29687 | 2204 |
assumes c0: "c$0 = (0::'a::idom)" and b0: "b$0 = 0" |
2205 |
shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r") |
|
2206 |
proof- |
|
2207 |
{fix n |
|
2208 |
have "?l$n = (setsum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n" |
|
2209 |
by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left setsum_right_distrib mult_assoc fps_setsum_nth) |
|
2210 |
also have "\<dots> = ((setsum (\<lambda>i. fps_const (a$i) * b^i) {0..n}) oo c)$n" |
|
2211 |
by (simp add: fps_compose_setsum_distrib) |
|
2212 |
also have "\<dots> = ?r$n" |
|
2213 |
apply (simp add: fps_compose_nth fps_setsum_nth setsum_left_distrib mult_assoc) |
|
2214 |
apply (rule setsum_cong2) |
|
2215 |
apply (rule setsum_mono_zero_right) |
|
2216 |
apply (auto simp add: not_le) |
|
2217 |
by (erule startsby_zero_power_prefix[OF b0, rule_format]) |
|
2218 |
finally have "?l$n = ?r$n" .} |
|
2219 |
then show ?thesis by (simp add: fps_eq_iff) |
|
2220 |
qed |
|
2221 |
||
2222 |
||
2223 |
lemma fps_X_power_compose: |
|
2224 |
assumes a0: "a$0=0" shows "X^k oo a = (a::('a::idom fps))^k" (is "?l = ?r") |
|
2225 |
proof- |
|
2226 |
{assume "k=0" hence ?thesis by simp} |
|
2227 |
moreover |
|
2228 |
{fix h assume h: "k = Suc h" |
|
2229 |
{fix n |
|
30488 | 2230 |
{assume kn: "k>n" hence "?l $ n = ?r $n" using a0 startsby_zero_power_prefix[OF a0] h |
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
2231 |
by (simp add: fps_compose_nth del: power_Suc)} |
29687 | 2232 |
moreover |
2233 |
{assume kn: "k \<le> n" |
|
29913 | 2234 |
hence "?l$n = ?r$n" |
2235 |
by (simp add: fps_compose_nth mult_delta_left setsum_delta)} |
|
29687 | 2236 |
moreover have "k >n \<or> k\<le> n" by arith |
2237 |
ultimately have "?l$n = ?r$n" by blast} |
|
2238 |
then have ?thesis unfolding fps_eq_iff by blast} |
|
2239 |
ultimately show ?thesis by (cases k, auto) |
|
2240 |
qed |
|
2241 |
||
2242 |
lemma fps_inv_right: assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" |
|
2243 |
shows "a oo fps_inv a = X" |
|
2244 |
proof- |
|
2245 |
let ?ia = "fps_inv a" |
|
2246 |
let ?iaa = "a oo fps_inv a" |
|
2247 |
have th0: "?ia $ 0 = 0" by (simp add: fps_inv_def) |
|
30488 | 2248 |
have th1: "?iaa $ 0 = 0" using a0 a1 |
29687 | 2249 |
by (simp add: fps_inv_def fps_compose_nth) |
2250 |
have th2: "X$0 = 0" by simp |
|
2251 |
from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo X" by simp |
|
2252 |
then have "(a oo fps_inv a) oo a = X oo a" |
|
2253 |
by (simp add: fps_compose_assoc[OF a0 th0] X_fps_compose_startby0[OF a0]) |
|
2254 |
with fps_compose_inj_right[OF a0 a1] |
|
30488 | 2255 |
show ?thesis by simp |
29687 | 2256 |
qed |
2257 |
||
2258 |
lemma fps_inv_deriv: |
|
31021 | 2259 |
assumes a0:"a$0 = (0::'a::{field})" and a1: "a$1 \<noteq> 0" |
29687 | 2260 |
shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)" |
2261 |
proof- |
|
2262 |
let ?ia = "fps_inv a" |
|
2263 |
let ?d = "fps_deriv a oo ?ia" |
|
2264 |
let ?dia = "fps_deriv ?ia" |
|
2265 |
have ia0: "?ia$0 = 0" by (simp add: fps_inv_def) |
|
2266 |
have th0: "?d$0 \<noteq> 0" using a1 by (simp add: fps_compose_nth fps_deriv_nth) |
|
2267 |
from fps_inv_right[OF a0 a1] have "?d * ?dia = 1" |
|
2268 |
by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] ) |
|
2269 |
hence "inverse ?d * ?d * ?dia = inverse ?d * 1" by simp |
|
2270 |
with inverse_mult_eq_1[OF th0] |
|
2271 |
show "?dia = inverse ?d" by simp |
|
2272 |
qed |
|
2273 |
||
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2274 |
lemma fps_inv_idempotent: |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2275 |
assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2276 |
shows "fps_inv (fps_inv a) = a" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2277 |
proof- |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2278 |
let ?r = "fps_inv" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2279 |
have ra0: "?r a $ 0 = 0" by (simp add: fps_inv_def) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2280 |
from a1 have ra1: "?r a $ 1 \<noteq> 0" by (simp add: fps_inv_def field_simps) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2281 |
have X0: "X$0 = 0" by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2282 |
from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = X" . |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2283 |
then have "?r (?r a) oo ?r a oo a = X oo a" by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2284 |
then have "?r (?r a) oo (?r a oo a) = a" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2285 |
unfolding X_fps_compose_startby0[OF a0] |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2286 |
unfolding fps_compose_assoc[OF a0 ra0, symmetric] . |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2287 |
then show ?thesis unfolding fps_inv[OF a0 a1] by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2288 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2289 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2290 |
lemma fps_ginv_ginv: |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2291 |
assumes a0: "a$0 = 0" and a1: "a$1 \<noteq> 0" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2292 |
and c0: "c$0 = 0" and c1: "c$1 \<noteq> 0" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2293 |
shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2294 |
proof- |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2295 |
let ?r = "fps_ginv" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2296 |
from c0 have rca0: "?r c a $0 = 0" by (simp add: fps_ginv_def) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2297 |
from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0" by (simp add: fps_ginv_def field_simps) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2298 |
from fps_ginv[OF rca0 rca1] |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2299 |
have "?r b (?r c a) oo ?r c a = b" . |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2300 |
then have "?r b (?r c a) oo ?r c a oo a = b oo a" by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2301 |
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
|
2302 |
apply (subst fps_compose_assoc) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2303 |
using a0 c0 by (auto simp add: fps_ginv_def) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2304 |
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
|
2305 |
unfolding fps_ginv[OF a0 a1] . |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2306 |
then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c" by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2307 |
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
|
2308 |
apply (subst fps_compose_assoc) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2309 |
using a0 c0 by (auto simp add: fps_inv_def) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2310 |
then show ?thesis unfolding fps_inv_right[OF c0 c1] by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2311 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2312 |
|
29906 | 2313 |
subsection{* Elementary series *} |
29687 | 2314 |
|
29906 | 2315 |
subsubsection{* Exponential series *} |
30488 | 2316 |
definition "E x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))" |
29687 | 2317 |
|
31021 | 2318 |
lemma E_deriv[simp]: "fps_deriv (E a) = fps_const (a::'a::{field, ring_char_0}) * E a" (is "?l = ?r") |
29687 | 2319 |
proof- |
2320 |
{fix n |
|
2321 |
have "?l$n = ?r $ n" |
|
30273
ecd6f0ca62ea
declare power_Suc [simp]; remove redundant type-specific versions of power_Suc
huffman
parents:
29915
diff
changeset
|
2322 |
apply (auto simp add: E_def field_simps power_Suc[symmetric]simp del: fact_Suc of_nat_Suc power_Suc) |
29687 | 2323 |
by (simp add: of_nat_mult ring_simps)} |
2324 |
then show ?thesis by (simp add: fps_eq_iff) |
|
2325 |
qed |
|
2326 |
||
30488 | 2327 |
lemma E_unique_ODE: |
31021 | 2328 |
"fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * E (c :: 'a::{field, ring_char_0})" |
29687 | 2329 |
(is "?lhs \<longleftrightarrow> ?rhs") |
2330 |
proof- |
|
2331 |
{assume d: ?lhs |
|
30488 | 2332 |
from d have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)" |
29687 | 2333 |
by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc) |
2334 |
{fix n have "a$n = a$0 * c ^ n/ (of_nat (fact n))" |
|
2335 |
apply (induct n) |
|
2336 |
apply simp |
|
30488 | 2337 |
unfolding th |
29687 | 2338 |
using fact_gt_zero |
2339 |
apply (simp add: field_simps del: of_nat_Suc fact.simps) |
|
2340 |
apply (drule sym) |
|
2341 |
by (simp add: ring_simps of_nat_mult power_Suc)} |
|
2342 |
note th' = this |
|
30488 | 2343 |
have ?rhs |
29687 | 2344 |
by (auto simp add: fps_eq_iff fps_const_mult_left E_def intro : th')} |
2345 |
moreover |
|
2346 |
{assume h: ?rhs |
|
30488 | 2347 |
have ?lhs |
29687 | 2348 |
apply (subst h) |
2349 |
apply simp |
|
2350 |
apply (simp only: h[symmetric]) |
|
2351 |
by simp} |
|
2352 |
ultimately show ?thesis by blast |
|
2353 |
qed |
|
2354 |
||
31021 | 2355 |
lemma E_add_mult: "E (a + b) = E (a::'a::{ring_char_0, field}) * E b" (is "?l = ?r") |
29687 | 2356 |
proof- |
2357 |
have "fps_deriv (?r) = fps_const (a+b) * ?r" |
|
2358 |
by (simp add: fps_const_add[symmetric] ring_simps del: fps_const_add) |
|
2359 |
then have "?r = ?l" apply (simp only: E_unique_ODE) |
|
2360 |
by (simp add: fps_mult_nth E_def) |
|
2361 |
then show ?thesis .. |
|
2362 |
qed |
|
2363 |
||
2364 |
lemma E_nth[simp]: "E a $ n = a^n / of_nat (fact n)" |
|
2365 |
by (simp add: E_def) |
|
2366 |
||
31021 | 2367 |
lemma E0[simp]: "E (0::'a::{field}) = 1" |
29687 | 2368 |
by (simp add: fps_eq_iff power_0_left) |
2369 |
||
31021 | 2370 |
lemma E_neg: "E (- a) = inverse (E (a::'a::{ring_char_0, field}))" |
29687 | 2371 |
proof- |
2372 |
from E_add_mult[of a "- a"] have th0: "E a * E (- a) = 1" |
|
2373 |
by (simp ) |
|
2374 |
have th1: "E a $ 0 \<noteq> 0" by simp |
|
2375 |
from fps_inverse_unique[OF th1 th0] show ?thesis by simp |
|
2376 |
qed |
|
2377 |
||
31021 | 2378 |
lemma E_nth_deriv[simp]: "fps_nth_deriv n (E (a::'a::{field, ring_char_0})) = (fps_const a)^n * (E a)" |
29687 | 2379 |
by (induct n, auto simp add: power_Suc) |
2380 |
||
31021 | 2381 |
lemma X_compose_E[simp]: "X oo E (a::'a::{field}) = E a - 1" |
29687 | 2382 |
by (simp add: fps_eq_iff X_fps_compose) |
2383 |
||
30488 | 2384 |
lemma LE_compose: |
2385 |
assumes a: "a\<noteq>0" |
|
29687 | 2386 |
shows "fps_inv (E a - 1) oo (E a - 1) = X" |
2387 |
and "(E a - 1) oo fps_inv (E a - 1) = X" |
|
2388 |
proof- |
|
2389 |
let ?b = "E a - 1" |
|
2390 |
have b0: "?b $ 0 = 0" by simp |
|
2391 |
have b1: "?b $ 1 \<noteq> 0" by (simp add: a) |
|
2392 |
from fps_inv[OF b0 b1] show "fps_inv (E a - 1) oo (E a - 1) = X" . |
|
2393 |
from fps_inv_right[OF b0 b1] show "(E a - 1) oo fps_inv (E a - 1) = X" . |
|
2394 |
qed |
|
2395 |
||
2396 |
||
30488 | 2397 |
lemma fps_const_inverse: |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2398 |
"a \<noteq> 0 \<Longrightarrow> inverse (fps_const (a::'a::field)) = fps_const (inverse a)" |
29687 | 2399 |
apply (auto simp add: fps_eq_iff fps_inverse_def) by (case_tac "n", auto) |
2400 |
||
30488 | 2401 |
lemma inverse_one_plus_X: |
31021 | 2402 |
"inverse (1 + X) = Abs_fps (\<lambda>n. (- 1 ::'a::{field})^n)" |
29687 | 2403 |
(is "inverse ?l = ?r") |
2404 |
proof- |
|
2405 |
have th: "?l * ?r = 1" |
|
31148 | 2406 |
by (auto simp add: ring_simps fps_eq_iff minus_one_power_iff) |
29687 | 2407 |
have th': "?l $ 0 \<noteq> 0" by (simp add: ) |
2408 |
from fps_inverse_unique[OF th' th] show ?thesis . |
|
2409 |
qed |
|
2410 |
||
31021 | 2411 |
lemma E_power_mult: "(E (c::'a::{field,ring_char_0}))^n = E (of_nat n * c)" |
29687 | 2412 |
by (induct n, auto simp add: ring_simps E_add_mult power_Suc) |
2413 |
||
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2414 |
lemma assumes r: "r (Suc k) 1 = 1" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2415 |
shows "fps_radical r (Suc k) (E (c::'a::{field, ring_char_0})) = E (c / of_nat (Suc k))" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2416 |
proof- |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2417 |
let ?ck = "(c / of_nat (Suc k))" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2418 |
let ?r = "fps_radical r (Suc k)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2419 |
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
|
2420 |
by (simp_all del: of_nat_Suc) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2421 |
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
|
2422 |
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
|
2423 |
"r (Suc k) (E c $ 0) = E ?ck $ 0" "E c $ 0 \<noteq> 0" using r by simp_all |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2424 |
from th0 radical_unique[where r=r and k=k, OF th] |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2425 |
show ?thesis by auto |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2426 |
qed |
29687 | 2427 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2428 |
lemma Ec_E1_eq: |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2429 |
"E (1::'a::{field, ring_char_0}) oo (fps_const c * X) = E c" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2430 |
apply (auto simp add: fps_eq_iff E_def fps_compose_def power_mult_distrib) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2431 |
by (simp add: cond_value_iff cond_application_beta setsum_delta' cong del: if_weak_cong) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2432 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2433 |
subsubsection{* Logarithmic series *} |
29687 | 2434 |
|
31199
10d413b08fa7
FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents:
31148
diff
changeset
|
2435 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2436 |
lemma Abs_fps_if_0: |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2437 |
"Abs_fps(%n. if n=0 then (v::'a::ring_1) else f n) = fps_const v + X * Abs_fps (%n. f (Suc n))" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2438 |
by (auto simp add: fps_eq_iff) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2439 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2440 |
definition L:: "'a::{field, ring_char_0} \<Rightarrow> 'a fps" where |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2441 |
"L c \<equiv> fps_const (1/c) * Abs_fps (\<lambda>n. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)" |
29687 | 2442 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2443 |
lemma fps_deriv_L: "fps_deriv (L c) = fps_const (1/c) * inverse (1 + X)" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2444 |
unfolding inverse_one_plus_X |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2445 |
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
|
2446 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2447 |
lemma L_nth: "L c $ n = (if n=0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2448 |
by (simp add: L_def field_simps) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2449 |
|
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2450 |
lemma L_0[simp]: "L c $ 0 = 0" by (simp add: L_def) |
29687 | 2451 |
lemma L_E_inv: |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2452 |
assumes a: "a\<noteq> (0::'a::{field,ring_char_0})" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2453 |
shows "L a = fps_inv (E a - 1)" (is "?l = ?r") |
29687 | 2454 |
proof- |
2455 |
let ?b = "E a - 1" |
|
2456 |
have b0: "?b $ 0 = 0" by simp |
|
2457 |
have b1: "?b $ 1 \<noteq> 0" by (simp add: a) |
|
2458 |
have "fps_deriv (E a - 1) oo fps_inv (E a - 1) = (fps_const a * (E a - 1) + fps_const a) oo fps_inv (E a - 1)" |
|
2459 |
by (simp add: ring_simps) |
|
2460 |
also have "\<dots> = fps_const a * (X + 1)" apply (simp add: fps_compose_add_distrib fps_const_mult_apply_left[symmetric] fps_inv_right[OF b0 b1]) |
|
2461 |
by (simp add: ring_simps) |
|
2462 |
finally have eq: "fps_deriv (E a - 1) oo fps_inv (E a - 1) = fps_const a * (X + 1)" . |
|
2463 |
from fps_inv_deriv[OF b0 b1, unfolded eq] |
|
2464 |
have "fps_deriv (fps_inv ?b) = fps_const (inverse a) / (X + 1)" |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2465 |
using a |
29687 | 2466 |
by (simp add: fps_const_inverse eq fps_divide_def fps_inverse_mult) |
30488 | 2467 |
hence "fps_deriv ?l = fps_deriv ?r" |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2468 |
by (simp add: fps_deriv_L add_commute fps_divide_def divide_inverse) |
29687 | 2469 |
then show ?thesis unfolding fps_deriv_eq_iff |
2470 |
by (simp add: L_nth fps_inv_def) |
|
2471 |
qed |
|
2472 |
||
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2473 |
lemma L_mult_add: |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2474 |
assumes c0: "c\<noteq>0" and d0: "d\<noteq>0" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2475 |
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
|
2476 |
(is "?r = ?l") |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2477 |
proof- |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2478 |
from c0 d0 have eq: "1/c + 1/d = (c+d)/(c*d)" by (simp add: field_simps) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2479 |
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
|
2480 |
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
|
2481 |
also have "\<dots> = fps_deriv ?l" |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2482 |
apply (simp add: fps_deriv_L) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2483 |
by (simp add: fps_eq_iff eq) |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2484 |
finally show ?thesis |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2485 |
unfolding fps_deriv_eq_iff by simp |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2486 |
qed |
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
2487 |
|
29906 | 2488 |
subsubsection{* Formal trigonometric functions *} |
29687 | 2489 |
|
31021 | 2490 |
definition "fps_sin (c::'a::{field, ring_char_0}) = |
29687 | 2491 |
Abs_fps (\<lambda>n. if even n then 0 else (- 1) ^((n - 1) div 2) * c^n /(of_nat (fact n)))" |
2492 |
||
31021 | 2493 |
definition "fps_cos (c::'a::{field, ring_char_0}) = Abs_fps (\<lambda>n. if even n then (- 1) ^ (n div 2) * c^n / (of_nat (fact n)) else 0)" |
29687 | 2494 |
|
30488 | 2495 |
lemma fps_sin_deriv: |
29687 | 2496 |
"fps_deriv (fps_sin c) = fps_const c * fps_cos c" |
2497 |
(is "?lhs = ?rhs") |
|
2498 |
proof- |
|
2499 |
{fix n::nat |
|
2500 |
{assume en: "even n" |
|
2501 |
have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp |
|
30488 | 2502 |
also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))" |
29687 | 2503 |
using en by (simp add: fps_sin_def) |
2504 |
also have "\<dots> = (- 1)^(n div 2) * c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" |
|
2505 |
unfolding fact_Suc of_nat_mult |
|
2506 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
2507 |
also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)" |
|
2508 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
30488 | 2509 |
finally have "?lhs $n = ?rhs$n" using en |
29687 | 2510 |
by (simp add: fps_cos_def ring_simps power_Suc )} |
30488 | 2511 |
then have "?lhs $ n = ?rhs $ n" |
29687 | 2512 |
by (cases "even n", simp_all add: fps_deriv_def fps_sin_def fps_cos_def) } |
2513 |
then show ?thesis by (auto simp add: fps_eq_iff) |
|
2514 |
qed |
|
2515 |
||
30488 | 2516 |
lemma fps_cos_deriv: |
29687 | 2517 |
"fps_deriv (fps_cos c) = fps_const (- c)* (fps_sin c)" |
2518 |
(is "?lhs = ?rhs") |
|
2519 |
proof- |
|
2520 |
have th0: "\<And>n. - ((- 1::'a) ^ n) = (- 1)^Suc n" by (simp add: power_Suc) |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2521 |
have th1: "\<And>n. odd n\<Longrightarrow> Suc ((n - 1) div 2) = Suc n div 2" by presburger (* FIXME: VERY slow! *) |
29687 | 2522 |
{fix n::nat |
2523 |
{assume en: "odd n" |
|
2524 |
from en have n0: "n \<noteq>0 " by presburger |
|
2525 |
have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp |
|
30488 | 2526 |
also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))" |
29687 | 2527 |
using en by (simp add: fps_cos_def) |
2528 |
also have "\<dots> = (- 1)^((n + 1) div 2)*c^Suc n * (of_nat (n+1) / (of_nat (Suc n) * of_nat (fact n)))" |
|
2529 |
unfolding fact_Suc of_nat_mult |
|
2530 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
2531 |
also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)" |
|
2532 |
by (simp add: field_simps del: of_nat_add of_nat_Suc) |
|
2533 |
also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)" |
|
2534 |
unfolding th0 unfolding th1[OF en] by simp |
|
30488 | 2535 |
finally have "?lhs $n = ?rhs$n" using en |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2536 |
by (simp add: fps_sin_def ring_simps power_Suc)} |
30488 | 2537 |
then have "?lhs $ n = ?rhs $ n" |
2538 |
by (cases "even n", simp_all add: fps_deriv_def fps_sin_def |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2539 |
fps_cos_def) } |
29687 | 2540 |
then show ?thesis by (auto simp add: fps_eq_iff) |
2541 |
qed |
|
2542 |
||
2543 |
lemma fps_sin_cos_sum_of_squares: |
|
2544 |
"fps_cos c ^ 2 + fps_sin c ^ 2 = 1" (is "?lhs = 1") |
|
2545 |
proof- |
|
2546 |
have "fps_deriv ?lhs = 0" |
|
2547 |
apply (simp add: fps_deriv_power fps_sin_deriv fps_cos_deriv power_Suc) |
|
30960 | 2548 |
by (simp add: ring_simps fps_const_neg[symmetric] del: fps_const_neg) |
29687 | 2549 |
then have "?lhs = fps_const (?lhs $ 0)" |
2550 |
unfolding fps_deriv_eq_0_iff . |
|
2551 |
also have "\<dots> = 1" |
|
30960 | 2552 |
by (auto simp add: fps_eq_iff numeral_2_eq_2 fps_mult_nth fps_cos_def fps_sin_def) |
29687 | 2553 |
finally show ?thesis . |
2554 |
qed |
|
2555 |
||
2556 |
definition "fps_tan c = fps_sin c / fps_cos c" |
|
2557 |
||
2558 |
lemma fps_tan_deriv: "fps_deriv(fps_tan c) = fps_const c/ (fps_cos c ^ 2)" |
|
2559 |
proof- |
|
2560 |
have th0: "fps_cos c $ 0 \<noteq> 0" by (simp add: fps_cos_def) |
|
30488 | 2561 |
show ?thesis |
29687 | 2562 |
using fps_sin_cos_sum_of_squares[of c] |
2563 |
apply (simp add: fps_tan_def fps_divide_deriv[OF th0] fps_sin_deriv fps_cos_deriv add: fps_const_neg[symmetric] ring_simps power2_eq_square del: fps_const_neg) |
|
2564 |
unfolding right_distrib[symmetric] |
|
2565 |
by simp |
|
2566 |
qed |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2567 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
2568 |
end |