author | wenzelm |
Fri, 10 Aug 2012 16:19:51 +0200 | |
changeset 48757 | 1232760e208e |
parent 47217 | 501b9bbd0d6e |
child 49834 | b27bbb021df1 |
permissions | -rw-r--r-- |
41959 | 1 |
(* Title: HOL/Library/Formal_Power_Series.thy |
29687 | 2 |
Author: Amine Chaieb, University of Cambridge |
3 |
*) |
|
4 |
||
5 |
header{* A formalization of formal power series *} |
|
6 |
||
7 |
theory Formal_Power_Series |
|
32157
adea7a729c7a
Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents:
31968
diff
changeset
|
8 |
imports Complex_Main Binomial |
29687 | 9 |
begin |
10 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
11 |
|
29906 | 12 |
subsection {* The type of formal power series*} |
29687 | 13 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
14 |
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
|
15 |
morphisms fps_nth Abs_fps |
29687 | 16 |
by simp |
17 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
18 |
notation fps_nth (infixl "$" 75) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
19 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
20 |
lemma expand_fps_eq: "p = q \<longleftrightarrow> (\<forall>n. p $ n = q $ n)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
21 |
by (simp add: fps_nth_inject [symmetric] fun_eq_iff) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
22 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
23 |
lemma fps_ext: "(\<And>n. p $ n = q $ n) \<Longrightarrow> p = q" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
24 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
25 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
26 |
lemma fps_nth_Abs_fps [simp]: "Abs_fps f $ n = f n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
27 |
by (simp add: Abs_fps_inverse) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
28 |
|
48757 | 29 |
text{* Definition of the basic elements 0 and 1 and the basic operations of addition, |
30 |
negation and multiplication *} |
|
29687 | 31 |
|
36409 | 32 |
instantiation fps :: (zero) zero |
29687 | 33 |
begin |
34 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
35 |
definition fps_zero_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
36 |
"0 = Abs_fps (\<lambda>n. 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
37 |
|
29687 | 38 |
instance .. |
39 |
end |
|
40 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
41 |
lemma fps_zero_nth [simp]: "0 $ n = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
42 |
unfolding fps_zero_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
43 |
|
36409 | 44 |
instantiation fps :: ("{one, zero}") one |
29687 | 45 |
begin |
46 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
47 |
definition fps_one_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
48 |
"1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
49 |
|
29687 | 50 |
instance .. |
51 |
end |
|
52 |
||
30488 | 53 |
lemma fps_one_nth [simp]: "1 $ n = (if n = 0 then 1 else 0)" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
54 |
unfolding fps_one_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
55 |
|
29687 | 56 |
instantiation fps :: (plus) plus |
57 |
begin |
|
58 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
59 |
definition fps_plus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
60 |
"op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
61 |
|
29687 | 62 |
instance .. |
63 |
end |
|
64 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
65 |
lemma fps_add_nth [simp]: "(f + g) $ n = f $ n + g $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
66 |
unfolding fps_plus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
67 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
68 |
instantiation fps :: (minus) minus |
29687 | 69 |
begin |
70 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
71 |
definition fps_minus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
72 |
"op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
73 |
|
29687 | 74 |
instance .. |
75 |
end |
|
76 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
77 |
lemma fps_sub_nth [simp]: "(f - g) $ n = f $ n - g $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
78 |
unfolding fps_minus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
79 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
80 |
instantiation fps :: (uminus) uminus |
29687 | 81 |
begin |
82 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
83 |
definition fps_uminus_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
84 |
"uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
85 |
|
29687 | 86 |
instance .. |
87 |
end |
|
88 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
89 |
lemma fps_neg_nth [simp]: "(- f) $ n = - (f $ n)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
90 |
unfolding fps_uminus_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
91 |
|
29687 | 92 |
instantiation fps :: ("{comm_monoid_add, times}") times |
93 |
begin |
|
94 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
95 |
definition fps_times_def: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
96 |
"op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
97 |
|
29687 | 98 |
instance .. |
99 |
end |
|
100 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
101 |
lemma fps_mult_nth: "(f * g) $ n = (\<Sum>i=0..n. f$i * g$(n - i))" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
102 |
unfolding fps_times_def by simp |
29687 | 103 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
104 |
declare atLeastAtMost_iff[presburger] |
29687 | 105 |
declare Bex_def[presburger] |
106 |
declare Ball_def[presburger] |
|
107 |
||
29913 | 108 |
lemma mult_delta_left: |
109 |
fixes x y :: "'a::mult_zero" |
|
110 |
shows "(if b then x else 0) * y = (if b then x * y else 0)" |
|
111 |
by simp |
|
112 |
||
113 |
lemma mult_delta_right: |
|
114 |
fixes x y :: "'a::mult_zero" |
|
115 |
shows "x * (if b then y else 0) = (if b then x * y else 0)" |
|
116 |
by simp |
|
117 |
||
29687 | 118 |
lemma cond_value_iff: "f (if b then x else y) = (if b then f x else f y)" |
119 |
by auto |
|
120 |
lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" |
|
121 |
by auto |
|
122 |
||
30488 | 123 |
subsection{* Formal power series form a commutative ring with unity, if the range of sequences |
29687 | 124 |
they represent is a commutative ring with unity*} |
125 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
126 |
instance fps :: (semigroup_add) semigroup_add |
29687 | 127 |
proof |
128 |
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
|
129 |
by (simp add: fps_ext add_assoc) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
130 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
131 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
132 |
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
|
133 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
134 |
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
|
135 |
by (simp add: fps_ext add_commute) |
29687 | 136 |
qed |
137 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
138 |
lemma fps_mult_assoc_lemma: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
(\<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
|
142 |
proof (induct k) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
143 |
case 0 show ?case by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
144 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
145 |
case (Suc k) thus ?case |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
146 |
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
|
147 |
cong: strong_setsum_cong) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
148 |
qed |
29687 | 149 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
150 |
instance fps :: (semiring_0) semigroup_mult |
29687 | 151 |
proof |
152 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
153 |
show "(a * b) * c = a * (b * c)" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
154 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
155 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
156 |
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
|
157 |
(\<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
|
158 |
by (rule fps_mult_assoc_lemma) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
setsum_left_distrib mult_assoc) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
162 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
163 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
164 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
165 |
lemma fps_mult_commute_lemma: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
proof (rule setsum_reindex_cong) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
169 |
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
|
170 |
by (rule inj_onI) simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
174 |
fix i assume "i \<in> {0..n}" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
175 |
hence "n - (n - i) = i" by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
176 |
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
|
177 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
178 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
179 |
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
|
180 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
181 |
fix a b :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
182 |
show "a * b = b * a" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
183 |
proof (rule fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
184 |
fix n :: nat |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
185 |
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
|
186 |
by (rule fps_mult_commute_lemma) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
187 |
thus "(a * b) $ n = (b * a) $ n" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
188 |
by (simp add: fps_mult_nth mult_commute) |
29687 | 189 |
qed |
190 |
qed |
|
191 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
192 |
instance fps :: (monoid_add) monoid_add |
29687 | 193 |
proof |
194 |
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
|
195 |
by (simp add: fps_ext) |
29687 | 196 |
next |
197 |
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
|
198 |
by (simp add: fps_ext) |
29687 | 199 |
qed |
200 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
201 |
instance fps :: (comm_monoid_add) comm_monoid_add |
29687 | 202 |
proof |
203 |
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
|
204 |
by (simp add: fps_ext) |
29687 | 205 |
qed |
206 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
207 |
instance fps :: (semiring_1) monoid_mult |
29687 | 208 |
proof |
209 |
fix a :: "'a fps" show "1 * a = a" |
|
29913 | 210 |
by (simp add: fps_ext fps_mult_nth mult_delta_left setsum_delta) |
29687 | 211 |
next |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
212 |
fix a :: "'a fps" show "a * 1 = a" |
29913 | 213 |
by (simp add: fps_ext fps_mult_nth mult_delta_right setsum_delta') |
29687 | 214 |
qed |
215 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
216 |
instance fps :: (cancel_semigroup_add) cancel_semigroup_add |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
217 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
218 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
219 |
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
|
220 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
221 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
222 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
223 |
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
|
224 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
225 |
qed |
29687 | 226 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
227 |
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
|
228 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
229 |
fix a b c :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
230 |
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
|
231 |
by (simp add: expand_fps_eq) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
232 |
qed |
29687 | 233 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
234 |
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
|
235 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
236 |
instance fps :: (group_add) group_add |
29687 | 237 |
proof |
238 |
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
|
239 |
by (simp add: fps_ext) |
29687 | 240 |
next |
241 |
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
|
242 |
by (simp add: fps_ext diff_minus) |
29687 | 243 |
qed |
244 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
245 |
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
|
246 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
247 |
fix a :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
248 |
show "- a + a = 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
249 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
250 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
251 |
fix a b :: "'a fps" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
252 |
show "a - b = a + - b" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
253 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
254 |
qed |
29687 | 255 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
256 |
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
|
257 |
by default (simp add: expand_fps_eq) |
29687 | 258 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
259 |
instance fps :: (semiring_0) semiring |
29687 | 260 |
proof |
261 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
262 |
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
|
263 |
by (simp add: expand_fps_eq fps_mult_nth left_distrib setsum_addf) |
29687 | 264 |
next |
265 |
fix a b c :: "'a fps" |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
266 |
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
|
267 |
by (simp add: expand_fps_eq fps_mult_nth right_distrib setsum_addf) |
29687 | 268 |
qed |
269 |
||
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
270 |
instance fps :: (semiring_0) semiring_0 |
29687 | 271 |
proof |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
272 |
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
|
273 |
by (simp add: fps_ext fps_mult_nth) |
29687 | 274 |
next |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
275 |
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
|
276 |
by (simp add: fps_ext fps_mult_nth) |
29687 | 277 |
qed |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
278 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
279 |
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
|
280 |
|
29906 | 281 |
subsection {* Selection of the nth power of the implicit variable in the infinite sum*} |
29687 | 282 |
|
283 |
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
|
284 |
by (simp add: expand_fps_eq) |
29687 | 285 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
286 |
lemma fps_nonzero_nth_minimal: |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
287 |
"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
|
288 |
proof |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
289 |
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
|
290 |
assume "f \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
291 |
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
|
292 |
by (simp add: fps_nonzero_nth) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
293 |
then have "f $ ?n \<noteq> 0" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
294 |
by (rule LeastI_ex) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
295 |
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
|
296 |
by (auto dest: not_less_Least) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
297 |
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
|
298 |
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
|
299 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
300 |
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
|
301 |
then show "f \<noteq> 0" by (auto simp add: expand_fps_eq) |
29687 | 302 |
qed |
303 |
||
304 |
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
|
305 |
by (rule expand_fps_eq) |
29687 | 306 |
|
30488 | 307 |
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
|
308 |
proof (cases "finite S") |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
309 |
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
|
310 |
next |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
311 |
assume "finite S" |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
312 |
then show ?thesis by (induct set: finite) auto |
29687 | 313 |
qed |
314 |
||
29906 | 315 |
subsection{* Injection of the basic ring elements and multiplication by scalars *} |
29687 | 316 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
317 |
definition |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
318 |
"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
|
319 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
320 |
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
|
321 |
unfolding fps_const_def by simp |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
322 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
323 |
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
|
324 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
325 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
326 |
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
|
327 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
328 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
329 |
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
|
330 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
331 |
|
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
332 |
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
|
333 |
by (simp add: fps_ext) |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
334 |
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
|
335 |
by (simp add: fps_ext) |
29687 | 336 |
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
|
337 |
by (simp add: fps_eq_iff fps_mult_nth setsum_0') |
29687 | 338 |
|
48757 | 339 |
lemma fps_const_add_left: "fps_const (c::'a\<Colon>monoid_add) + f = |
340 |
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
|
341 |
by (simp add: fps_ext) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
342 |
|
48757 | 343 |
lemma fps_const_add_right: "f + fps_const (c::'a\<Colon>monoid_add) = |
344 |
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
|
345 |
by (simp add: fps_ext) |
29687 | 346 |
|
347 |
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
|
348 |
unfolding fps_eq_iff fps_mult_nth |
29913 | 349 |
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
|
350 |
|
29687 | 351 |
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
|
352 |
unfolding fps_eq_iff fps_mult_nth |
29913 | 353 |
by (simp add: fps_const_def mult_delta_right setsum_delta') |
29687 | 354 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
355 |
lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n" |
29913 | 356 |
by (simp add: fps_mult_nth mult_delta_left setsum_delta) |
29687 | 357 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
358 |
lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c" |
29913 | 359 |
by (simp add: fps_mult_nth mult_delta_right setsum_delta') |
29687 | 360 |
|
29906 | 361 |
subsection {* Formal power series form an integral domain*} |
29687 | 362 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
363 |
instance fps :: (ring) ring .. |
29687 | 364 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
365 |
instance fps :: (ring_1) ring_1 |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
366 |
by (intro_classes, auto simp add: diff_minus left_distrib) |
29687 | 367 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
368 |
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
|
369 |
by (intro_classes, auto simp add: diff_minus left_distrib) |
29687 | 370 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
371 |
instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors |
29687 | 372 |
proof |
373 |
fix a b :: "'a fps" |
|
374 |
assume a0: "a \<noteq> 0" and b0: "b \<noteq> 0" |
|
375 |
then obtain i j where i: "a$i\<noteq>0" "\<forall>k<i. a$k=0" |
|
376 |
and j: "b$j \<noteq>0" "\<forall>k<j. b$k =0" unfolding fps_nonzero_nth_minimal |
|
377 |
by blast+ |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
378 |
have "(a * b) $ (i+j) = (\<Sum>k=0..i+j. a$k * b$(i+j-k))" |
29687 | 379 |
by (rule fps_mult_nth) |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
380 |
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
|
381 |
by (rule setsum_diff1') simp_all |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
382 |
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
|
383 |
proof (rule setsum_0' [rule_format]) |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
384 |
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
|
385 |
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
|
386 |
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
|
387 |
qed |
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
388 |
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
|
389 |
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
|
390 |
finally have "(a*b) $ (i+j) \<noteq> 0" . |
29687 | 391 |
then show "a*b \<noteq> 0" unfolding fps_nonzero_nth by blast |
392 |
qed |
|
393 |
||
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
394 |
instance fps :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors .. |
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
395 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
396 |
instance fps :: (idom) idom .. |
29687 | 397 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
398 |
lemma numeral_fps_const: "numeral k = fps_const (numeral k)" |
48757 | 399 |
by (induct k) (simp_all only: numeral.simps fps_const_1_eq_1 |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
400 |
fps_const_add [symmetric]) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
401 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
402 |
lemma neg_numeral_fps_const: "neg_numeral k = fps_const (neg_numeral k)" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
403 |
by (simp only: neg_numeral_def numeral_fps_const fps_const_neg) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
404 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
405 |
subsection{* The eXtractor series X*} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
406 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
407 |
lemma minus_one_power_iff: "(- (1::'a :: {comm_ring_1})) ^ n = (if even n then 1 else - 1)" |
48757 | 408 |
by (induct n) auto |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
409 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
410 |
definition "X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
411 |
lemma X_mult_nth[simp]: "(X * (f :: ('a::semiring_1) fps)) $n = (if n = 0 then 0 else f $ (n - 1))" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
412 |
proof- |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
413 |
{assume n: "n \<noteq> 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
414 |
have "(X * f) $n = (\<Sum>i = 0..n. X $ i * f $ (n - i))" by (simp add: fps_mult_nth) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
415 |
also have "\<dots> = f $ (n - 1)" |
46757 | 416 |
using n by (simp add: X_def mult_delta_left setsum_delta) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
417 |
finally have ?thesis using n by simp } |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
418 |
moreover |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
419 |
{assume n: "n=0" hence ?thesis by (simp add: fps_mult_nth X_def)} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
420 |
ultimately show ?thesis by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
421 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
422 |
|
48757 | 423 |
lemma X_mult_right_nth[simp]: |
424 |
"((f :: ('a::comm_semiring_1) fps) * X) $n = (if n = 0 then 0 else f $ (n - 1))" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
425 |
by (metis X_mult_nth mult_commute) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
426 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
427 |
lemma X_power_iff: "X^k = Abs_fps (\<lambda>n. if n = k then (1::'a::comm_ring_1) else 0)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
428 |
proof(induct k) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
429 |
case 0 thus ?case by (simp add: X_def fps_eq_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
430 |
next |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
431 |
case (Suc k) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
432 |
{fix m |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
433 |
have "(X^Suc k) $ m = (if m = 0 then (0::'a) else (X^k) $ (m - 1))" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
434 |
by (simp add: power_Suc del: One_nat_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
435 |
then have "(X^Suc k) $ m = (if m = Suc k then (1::'a) else 0)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
436 |
using Suc.hyps by (auto cong del: if_weak_cong)} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
437 |
then show ?case by (simp add: fps_eq_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
438 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
439 |
|
48757 | 440 |
lemma X_power_mult_nth: |
441 |
"(X^k * (f :: ('a::comm_ring_1) fps)) $n = (if n < k then 0 else f $ (n - k))" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
442 |
apply (induct k arbitrary: n) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
443 |
apply (simp) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
444 |
unfolding power_Suc mult_assoc |
48757 | 445 |
apply (case_tac n) |
446 |
apply auto |
|
447 |
done |
|
448 |
||
449 |
lemma X_power_mult_right_nth: |
|
450 |
"((f :: ('a::comm_ring_1) fps) * X^k) $n = (if n < k then 0 else f $ (n - k))" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
451 |
by (metis X_power_mult_nth mult_commute) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
452 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
453 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
454 |
|
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
455 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
456 |
subsection{* Formal Power series form a metric space *} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
457 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
458 |
definition (in dist) ball_def: "ball x r = {y. dist y x < r}" |
48757 | 459 |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
460 |
instantiation fps :: (comm_ring_1) dist |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
461 |
begin |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
462 |
|
48757 | 463 |
definition dist_fps_def: |
464 |
"dist (a::'a fps) b = (if (\<exists>n. a$n \<noteq> b$n) then inverse (2 ^ The (leastP (\<lambda>n. a$n \<noteq> b$n))) else 0)" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
465 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
466 |
lemma dist_fps_ge0: "dist (a::'a fps) b \<ge> 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
467 |
by (simp add: dist_fps_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
468 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
469 |
lemma dist_fps_sym: "dist (a::'a fps) b = dist b a" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
470 |
apply (auto simp add: dist_fps_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
471 |
apply (rule cong[OF refl, where x="(\<lambda>n\<Colon>nat. a $ n \<noteq> b $ n)"]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
472 |
apply (rule ext) |
48757 | 473 |
apply auto |
474 |
done |
|
475 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
476 |
instance .. |
48757 | 477 |
|
30746 | 478 |
end |
479 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
480 |
lemma fps_nonzero_least_unique: assumes a0: "a \<noteq> 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
481 |
shows "\<exists>! n. leastP (\<lambda>n. a$n \<noteq> 0) n" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
482 |
proof- |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
483 |
from fps_nonzero_nth_minimal[of a] a0 |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
484 |
obtain n where n: "a$n \<noteq> 0" "\<forall>m < n. a$m = 0" by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
485 |
from n have ln: "leastP (\<lambda>n. a$n \<noteq> 0) n" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
486 |
by (auto simp add: leastP_def setge_def not_le[symmetric]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
487 |
moreover |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
488 |
{fix m assume "leastP (\<lambda>n. a$n \<noteq> 0) m" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
489 |
then have "m = n" using ln |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
490 |
apply (auto simp add: leastP_def setge_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
491 |
apply (erule allE[where x=n]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
492 |
apply (erule allE[where x=m]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
493 |
by simp} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
494 |
ultimately show ?thesis by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
495 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
496 |
|
48757 | 497 |
lemma fps_eq_least_unique: |
498 |
assumes ab: "(a::('a::ab_group_add) fps) \<noteq> b" |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
499 |
shows "\<exists>! n. leastP (\<lambda>n. a$n \<noteq> b$n) n" |
48757 | 500 |
using fps_nonzero_least_unique[of "a - b"] ab |
501 |
by auto |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
502 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
503 |
instantiation fps :: (comm_ring_1) metric_space |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
504 |
begin |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
505 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
506 |
definition open_fps_def: "open (S :: 'a fps set) = (\<forall>a \<in> S. \<exists>r. r >0 \<and> ball a r \<subseteq> S)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
507 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
508 |
instance |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
509 |
proof |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
510 |
fix S :: "'a fps set" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
511 |
show "open S = (\<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
512 |
by (auto simp add: open_fps_def ball_def subset_eq) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
513 |
next |
48757 | 514 |
{ |
515 |
fix a b :: "'a fps" |
|
516 |
{ |
|
517 |
assume ab: "a = b" |
|
518 |
then have "\<not> (\<exists>n. a$n \<noteq> b$n)" by simp |
|
519 |
then have "dist a b = 0" by (simp add: dist_fps_def) |
|
520 |
} |
|
521 |
moreover |
|
522 |
{ |
|
523 |
assume d: "dist a b = 0" |
|
524 |
then have "\<forall>n. a$n = b$n" |
|
525 |
by - (rule ccontr, simp add: dist_fps_def) |
|
526 |
then have "a = b" by (simp add: fps_eq_iff) |
|
527 |
} |
|
528 |
ultimately show "dist a b =0 \<longleftrightarrow> a = b" by blast |
|
529 |
} |
|
530 |
note th = this |
|
531 |
from th have th'[simp]: "\<And>a::'a fps. dist a a = 0" by simp |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
532 |
fix a b c :: "'a fps" |
48757 | 533 |
{ |
534 |
assume ab: "a = b" then have d0: "dist a b = 0" unfolding th . |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
535 |
then have "dist a b \<le> dist a c + dist b c" |
48757 | 536 |
using dist_fps_ge0[of a c] dist_fps_ge0[of b c] by simp |
537 |
} |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
538 |
moreover |
48757 | 539 |
{ |
540 |
assume c: "c = a \<or> c = b" |
|
541 |
then have "dist a b \<le> dist a c + dist b c" |
|
542 |
by (cases "c=a") (simp_all add: th dist_fps_sym) |
|
543 |
} |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
544 |
moreover |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
545 |
{assume ab: "a \<noteq> b" and ac: "a \<noteq> c" and bc: "b \<noteq> c" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
546 |
let ?P = "\<lambda>a b n. a$n \<noteq> b$n" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
547 |
from fps_eq_least_unique[OF ab] fps_eq_least_unique[OF ac] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
548 |
fps_eq_least_unique[OF bc] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
549 |
obtain nab nac nbc where nab: "leastP (?P a b) nab" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
550 |
and nac: "leastP (?P a c) nac" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
551 |
and nbc: "leastP (?P b c) nbc" by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
552 |
from nab have nab': "\<And>m. m < nab \<Longrightarrow> a$m = b$m" "a$nab \<noteq> b$nab" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
553 |
by (auto simp add: leastP_def setge_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
554 |
from nac have nac': "\<And>m. m < nac \<Longrightarrow> a$m = c$m" "a$nac \<noteq> c$nac" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
555 |
by (auto simp add: leastP_def setge_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
556 |
from nbc have nbc': "\<And>m. m < nbc \<Longrightarrow> b$m = c$m" "b$nbc \<noteq> c$nbc" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
557 |
by (auto simp add: leastP_def setge_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
558 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
559 |
have th0: "\<And>(a::'a fps) b. a \<noteq> b \<longleftrightarrow> (\<exists>n. a$n \<noteq> b$n)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
560 |
by (simp add: fps_eq_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
561 |
from ab ac bc nab nac nbc |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
562 |
have dab: "dist a b = inverse (2 ^ nab)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
563 |
and dac: "dist a c = inverse (2 ^ nac)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
564 |
and dbc: "dist b c = inverse (2 ^ nbc)" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
565 |
unfolding th0 |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
566 |
apply (simp_all add: dist_fps_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
567 |
apply (erule the1_equality[OF fps_eq_least_unique[OF ab]]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
568 |
apply (erule the1_equality[OF fps_eq_least_unique[OF ac]]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
569 |
by (erule the1_equality[OF fps_eq_least_unique[OF bc]]) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
570 |
from ab ac bc have nz: "dist a b \<noteq> 0" "dist a c \<noteq> 0" "dist b c \<noteq> 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
571 |
unfolding th by simp_all |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
572 |
from nz have pos: "dist a b > 0" "dist a c > 0" "dist b c > 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
573 |
using dist_fps_ge0[of a b] dist_fps_ge0[of a c] dist_fps_ge0[of b c] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
574 |
by auto |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
575 |
have th1: "\<And>n. (2::real)^n >0" by auto |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
576 |
{assume h: "dist a b > dist a c + dist b c" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
577 |
then have gt: "dist a b > dist a c" "dist a b > dist b c" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
578 |
using pos by auto |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
579 |
from gt have gtn: "nab < nbc" "nab < nac" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
580 |
unfolding dab dbc dac by (auto simp add: th1) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
581 |
from nac'(1)[OF gtn(2)] nbc'(1)[OF gtn(1)] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
582 |
have "a$nab = b$nab" by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
583 |
with nab'(2) have False by simp} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
584 |
then have "dist a b \<le> dist a c + dist b c" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
585 |
by (auto simp add: not_le[symmetric]) } |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
586 |
ultimately show "dist a b \<le> dist a c + dist b c" by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
587 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
588 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
589 |
end |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
590 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
591 |
text{* The infinite sums and justification of the notation in textbooks*} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
592 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
593 |
lemma reals_power_lt_ex: assumes xp: "x > 0" and y1: "(y::real) > 1" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
594 |
shows "\<exists>k>0. (1/y)^k < x" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
595 |
proof- |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
596 |
have yp: "y > 0" using y1 by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
597 |
from reals_Archimedean2[of "max 0 (- log y x) + 1"] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
598 |
obtain k::nat where k: "real k > max 0 (- log y x) + 1" by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
599 |
from k have kp: "k > 0" by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
600 |
from k have "real k > - log y x" by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
601 |
then have "ln y * real k > - ln x" unfolding log_def |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
602 |
using ln_gt_zero_iff[OF yp] y1 |
36350 | 603 |
by (simp add: minus_divide_left field_simps del:minus_divide_left[symmetric]) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
604 |
then have "ln y * real k + ln x > 0" by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
605 |
then have "exp (real k * ln y + ln x) > exp 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
606 |
by (simp add: mult_ac) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
607 |
then have "y ^ k * x > 1" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
608 |
unfolding exp_zero exp_add exp_real_of_nat_mult |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
609 |
exp_ln[OF xp] exp_ln[OF yp] by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
610 |
then have "x > (1/y)^k" using yp |
36350 | 611 |
by (simp add: field_simps nonzero_power_divide) |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
612 |
then show ?thesis using kp by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
613 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
614 |
lemma X_nth[simp]: "X$n = (if n = 1 then 1 else 0)" by (simp add: X_def) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
615 |
lemma X_power_nth[simp]: "(X^k) $n = (if n = k then 1 else (0::'a::comm_ring_1))" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
616 |
by (simp add: X_power_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
617 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
618 |
|
48757 | 619 |
lemma fps_sum_rep_nth: "(setsum (%i. fps_const(a$i)*X^i) {0..m})$n = |
620 |
(if n \<le> m then a$n else (0::'a::comm_ring_1))" |
|
621 |
apply (auto simp add: fps_eq_iff fps_setsum_nth X_power_nth cond_application_beta cond_value_iff |
|
622 |
cong del: if_weak_cong) |
|
623 |
apply (simp add: setsum_delta') |
|
624 |
done |
|
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
625 |
|
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
626 |
lemma fps_notation: |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
627 |
"(%n. setsum (%i. fps_const(a$i) * X^i) {0..n}) ----> a" (is "?s ----> a") |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
628 |
proof- |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
629 |
{fix r:: real |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
630 |
assume rp: "r > 0" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
631 |
have th0: "(2::real) > 1" by simp |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
632 |
from reals_power_lt_ex[OF rp th0] |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
633 |
obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0" by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
634 |
{fix n::nat |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
635 |
assume nn0: "n \<ge> n0" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
636 |
then have thnn0: "(1/2)^n <= (1/2 :: real)^n0" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
637 |
by (auto intro: power_decreasing) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
638 |
{assume "?s n = a" then have "dist (?s n) a < r" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
639 |
unfolding dist_eq_0_iff[of "?s n" a, symmetric] |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
640 |
using rp by (simp del: dist_eq_0_iff)} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
641 |
moreover |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
642 |
{assume neq: "?s n \<noteq> a" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
643 |
from fps_eq_least_unique[OF neq] |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
644 |
obtain k where k: "leastP (\<lambda>i. ?s n $ i \<noteq> a$i) k" by blast |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
645 |
have th0: "\<And>(a::'a fps) b. a \<noteq> b \<longleftrightarrow> (\<exists>n. a$n \<noteq> b$n)" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
646 |
by (simp add: fps_eq_iff) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
647 |
from neq have dth: "dist (?s n) a = (1/2)^k" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
648 |
unfolding th0 dist_fps_def |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
649 |
unfolding the1_equality[OF fps_eq_least_unique[OF neq], OF k] |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
650 |
by (auto simp add: inverse_eq_divide power_divide) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
651 |
|
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
652 |
from k have kn: "k > n" |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
653 |
by (simp add: leastP_def setge_def fps_sum_rep_nth split:split_if_asm) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
654 |
then have "dist (?s n) a < (1/2)^n" unfolding dth |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
655 |
by (auto intro: power_strict_decreasing) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
656 |
also have "\<dots> <= (1/2)^n0" using nn0 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
657 |
by (auto intro: power_decreasing) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
658 |
also have "\<dots> < r" using n0 by simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
659 |
finally have "dist (?s n) a < r" .} |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
660 |
ultimately have "dist (?s n) a < r" by blast} |
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
661 |
then have "\<exists>n0. \<forall> n \<ge> n0. dist (?s n) a < r " by blast} |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
662 |
then show ?thesis unfolding LIMSEQ_def by blast |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
663 |
qed |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
664 |
|
29906 | 665 |
subsection{* Inverses of formal power series *} |
29687 | 666 |
|
667 |
declare setsum_cong[fundef_cong] |
|
668 |
||
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
669 |
instantiation fps :: ("{comm_monoid_add, inverse, times, uminus}") inverse |
29687 | 670 |
begin |
671 |
||
30488 | 672 |
fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a" where |
29687 | 673 |
"natfun_inverse f 0 = inverse (f$0)" |
30488 | 674 |
| "natfun_inverse f n = - inverse (f$0) * setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}" |
29687 | 675 |
|
30488 | 676 |
definition fps_inverse_def: |
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
677 |
"inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))" |
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
678 |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
679 |
definition fps_divide_def: "divide = (\<lambda>(f::'a fps) g. f * inverse g)" |
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
680 |
|
29687 | 681 |
instance .. |
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
682 |
|
29687 | 683 |
end |
684 |
||
30488 | 685 |
lemma fps_inverse_zero[simp]: |
29687 | 686 |
"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
|
687 |
by (simp add: fps_ext fps_inverse_def) |
29687 | 688 |
|
689 |
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
|
690 |
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
|
691 |
by (case_tac n, auto) |
29687 | 692 |
|
36311
ed3a87a7f977
epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents:
36309
diff
changeset
|
693 |
lemma inverse_mult_eq_1 [intro]: assumes f0: "f$0 \<noteq> (0::'a::field)" |
29687 | 694 |
shows "inverse f * f = 1" |
695 |
proof- |
|
696 |
have c: "inverse f * f = f * inverse f" by (simp add: mult_commute) |
|
30488 | 697 |
from f0 have ifn: "\<And>n. inverse f $ n = natfun_inverse f n" |
29687 | 698 |
by (simp add: fps_inverse_def) |
699 |
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
|
700 |
by (simp add: fps_mult_nth fps_inverse_def) |
29687 | 701 |
{fix n::nat assume np: "n >0 " |
702 |
from np have eq: "{0..n} = {0} \<union> {1 .. n}" by auto |
|
703 |
have d: "{0} \<inter> {1 .. n} = {}" by auto |
|
30488 | 704 |
from f0 np have th0: "- (inverse f$n) = |
29687 | 705 |
(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
|
706 |
by (cases n, simp, simp add: divide_inverse fps_inverse_def) |
29687 | 707 |
from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]] |
30488 | 708 |
have th1: "setsum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n} = |
709 |
- (f$0) * (inverse f)$n" |
|
36350 | 710 |
by (simp add: field_simps) |
30488 | 711 |
have "(f * inverse f) $ n = (\<Sum>i = 0..n. f $i * natfun_inverse f (n - i))" |
29687 | 712 |
unfolding fps_mult_nth ifn .. |
30488 | 713 |
also have "\<dots> = f$0 * natfun_inverse f n |
29687 | 714 |
+ (\<Sum>i = 1..n. f$i * natfun_inverse f (n-i))" |
46757 | 715 |
by (simp add: eq) |
29687 | 716 |
also have "\<dots> = 0" unfolding th1 ifn by simp |
717 |
finally have "(inverse f * f)$n = 0" unfolding c . } |
|
718 |
with th0 show ?thesis by (simp add: fps_eq_iff) |
|
719 |
qed |
|
720 |
||
721 |
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
|
722 |
by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero) |
29687 | 723 |
|
724 |
lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::field) fps) \<longleftrightarrow> f $0 = 0" |
|
725 |
proof- |
|
726 |
{assume "f$0 = 0" hence "inverse f = 0" by (simp add: fps_inverse_def)} |
|
727 |
moreover |
|
728 |
{assume h: "inverse f = 0" and c: "f $0 \<noteq> 0" |
|
729 |
from inverse_mult_eq_1[OF c] h have False by simp} |
|
730 |
ultimately show ?thesis by blast |
|
731 |
qed |
|
732 |
||
48757 | 733 |
lemma fps_inverse_idempotent[intro]: |
734 |
assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
29687 | 735 |
shows "inverse (inverse f) = f" |
736 |
proof- |
|
737 |
from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp |
|
30488 | 738 |
from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0] |
29687 | 739 |
have th0: "inverse f * f = inverse f * inverse (inverse f)" by (simp add: mult_ac) |
740 |
then show ?thesis using f0 unfolding mult_cancel_left by simp |
|
741 |
qed |
|
742 |
||
48757 | 743 |
lemma fps_inverse_unique: |
744 |
assumes f0: "f$0 \<noteq> (0::'a::field)" and fg: "f*g = 1" |
|
29687 | 745 |
shows "inverse f = g" |
746 |
proof- |
|
747 |
from inverse_mult_eq_1[OF f0] fg |
|
748 |
have th0: "inverse f * f = g * f" by (simp add: mult_ac) |
|
749 |
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
|
750 |
by (auto simp add: expand_fps_eq) |
29687 | 751 |
qed |
752 |
||
30488 | 753 |
lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) |
29687 | 754 |
= Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)" |
755 |
apply (rule fps_inverse_unique) |
|
756 |
apply simp |
|
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
757 |
apply (simp add: fps_eq_iff fps_mult_nth) |
29687 | 758 |
proof(clarsimp) |
759 |
fix n::nat assume n: "n > 0" |
|
760 |
let ?f = "\<lambda>i. if n = i then (1\<Colon>'a) else if n - i = 1 then - 1 else 0" |
|
761 |
let ?g = "\<lambda>i. if i = n then 1 else if i=n - 1 then - 1 else 0" |
|
762 |
let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0" |
|
30488 | 763 |
have th1: "setsum ?f {0..n} = setsum ?g {0..n}" |
29687 | 764 |
by (rule setsum_cong2) auto |
30488 | 765 |
have th2: "setsum ?g {0..n - 1} = setsum ?h {0..n - 1}" |
29687 | 766 |
using n apply - by (rule setsum_cong2) auto |
767 |
have eq: "{0 .. n} = {0.. n - 1} \<union> {n}" by auto |
|
30488 | 768 |
from n have d: "{0.. n - 1} \<inter> {n} = {}" by auto |
29687 | 769 |
have f: "finite {0.. n - 1}" "finite {n}" by auto |
770 |
show "setsum ?f {0..n} = 0" |
|
30488 | 771 |
unfolding th1 |
29687 | 772 |
apply (simp add: setsum_Un_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def) |
773 |
unfolding th2 |
|
774 |
by(simp add: setsum_delta) |
|
775 |
qed |
|
776 |
||
29912 | 777 |
subsection{* Formal Derivatives, and the MacLaurin theorem around 0*} |
29687 | 778 |
|
779 |
definition "fps_deriv f = Abs_fps (\<lambda>n. of_nat (n + 1) * f $ (n + 1))" |
|
780 |
||
48757 | 781 |
lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n+1)" |
782 |
by (simp add: fps_deriv_def) |
|
783 |
||
784 |
lemma fps_deriv_linear[simp]: |
|
785 |
"fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = |
|
786 |
fps_const a * fps_deriv f + fps_const b * fps_deriv g" |
|
36350 | 787 |
unfolding fps_eq_iff fps_add_nth fps_const_mult_left fps_deriv_nth by (simp add: field_simps) |
29687 | 788 |
|
30488 | 789 |
lemma fps_deriv_mult[simp]: |
29687 | 790 |
fixes f :: "('a :: comm_ring_1) fps" |
791 |
shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g" |
|
792 |
proof- |
|
793 |
let ?D = "fps_deriv" |
|
794 |
{fix n::nat |
|
795 |
let ?Zn = "{0 ..n}" |
|
796 |
let ?Zn1 = "{0 .. n + 1}" |
|
797 |
let ?f = "\<lambda>i. i + 1" |
|
798 |
have fi: "inj_on ?f {0..n}" by (simp add: inj_on_def) |
|
799 |
have eq: "{1.. n+1} = ?f ` {0..n}" by auto |
|
800 |
let ?g = "\<lambda>i. of_nat (i+1) * g $ (i+1) * f $ (n - i) + |
|
801 |
of_nat (i+1)* f $ (i+1) * g $ (n - i)" |
|
802 |
let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) + |
|
803 |
of_nat i* f $ i * g $ ((n + 1) - i)" |
|
804 |
{fix k assume k: "k \<in> {0..n}" |
|
805 |
have "?h (k + 1) = ?g k" using k by auto} |
|
806 |
note th0 = this |
|
807 |
have eq': "{0..n +1}- {1 .. n+1} = {0}" by auto |
|
808 |
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" |
|
809 |
apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) |
|
810 |
apply (simp add: inj_on_def Ball_def) |
|
811 |
apply presburger |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
812 |
apply (rule set_eqI) |
29687 | 813 |
apply (presburger add: image_iff) |
814 |
by simp |
|
815 |
have s1: "setsum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 = setsum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1" |
|
816 |
apply (rule setsum_reindex_cong[where f="\<lambda>i. n + 1 - i"]) |
|
817 |
apply (simp add: inj_on_def Ball_def) |
|
818 |
apply presburger |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
819 |
apply (rule set_eqI) |
29687 | 820 |
apply (presburger add: image_iff) |
821 |
by simp |
|
822 |
have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n" by (simp only: mult_commute) |
|
823 |
also have "\<dots> = (\<Sum>i = 0..n. ?g i)" |
|
824 |
by (simp add: fps_mult_nth setsum_addf[symmetric]) |
|
825 |
also have "\<dots> = setsum ?h {1..n+1}" |
|
826 |
using th0 setsum_reindex_cong[OF fi eq, of "?g" "?h"] by auto |
|
827 |
also have "\<dots> = setsum ?h {0..n+1}" |
|
828 |
apply (rule setsum_mono_zero_left) |
|
829 |
apply simp |
|
830 |
apply (simp add: subset_eq) |
|
831 |
unfolding eq' |
|
832 |
by simp |
|
833 |
also have "\<dots> = (fps_deriv (f * g)) $ n" |
|
834 |
apply (simp only: fps_deriv_nth fps_mult_nth setsum_addf) |
|
835 |
unfolding s0 s1 |
|
836 |
unfolding setsum_addf[symmetric] setsum_right_distrib |
|
837 |
apply (rule setsum_cong2) |
|
36350 | 838 |
by (auto simp add: of_nat_diff field_simps) |
29687 | 839 |
finally have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" .} |
30488 | 840 |
then show ?thesis unfolding fps_eq_iff by auto |
29687 | 841 |
qed |
842 |
||
31968
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
843 |
lemma fps_deriv_X[simp]: "fps_deriv X = 1" |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
844 |
by (simp add: fps_deriv_def X_def fps_eq_iff) |
0314441a53a6
FPS form a metric space, which justifies the infinte sum notation
chaieb
parents:
31790
diff
changeset
|
845 |
|
29687 | 846 |
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
|
847 |
by (simp add: fps_eq_iff fps_deriv_def) |
29687 | 848 |
lemma fps_deriv_add[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) + g) = fps_deriv f + fps_deriv g" |
849 |
using fps_deriv_linear[of 1 f 1 g] by simp |
|
850 |
||
851 |
lemma fps_deriv_sub[simp]: "fps_deriv ((f:: ('a::comm_ring_1) fps) - g) = fps_deriv f - fps_deriv g" |
|
30488 | 852 |
unfolding diff_minus by simp |
29687 | 853 |
|
854 |
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
|
855 |
by (simp add: fps_ext fps_deriv_def fps_const_def) |
29687 | 856 |
|
48757 | 857 |
lemma fps_deriv_mult_const_left[simp]: |
858 |
"fps_deriv (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_deriv f" |
|
29687 | 859 |
by simp |
860 |
||
861 |
lemma fps_deriv_0[simp]: "fps_deriv 0 = 0" |
|
862 |
by (simp add: fps_deriv_def fps_eq_iff) |
|
863 |
||
864 |
lemma fps_deriv_1[simp]: "fps_deriv 1 = 0" |
|
865 |
by (simp add: fps_deriv_def fps_eq_iff ) |
|
866 |
||
48757 | 867 |
lemma fps_deriv_mult_const_right[simp]: |
868 |
"fps_deriv (f * fps_const (c::'a::comm_ring_1)) = fps_deriv f * fps_const c" |
|
29687 | 869 |
by simp |
870 |
||
48757 | 871 |
lemma fps_deriv_setsum: |
872 |
"fps_deriv (setsum f S) = setsum (\<lambda>i. fps_deriv (f i :: ('a::comm_ring_1) fps)) S" |
|
29687 | 873 |
proof- |
48757 | 874 |
{ assume "\<not> finite S" hence ?thesis by simp } |
29687 | 875 |
moreover |
48757 | 876 |
{ |
877 |
assume fS: "finite S" |
|
878 |
have ?thesis by (induct rule: finite_induct[OF fS]) simp_all |
|
879 |
} |
|
29687 | 880 |
ultimately show ?thesis by blast |
881 |
qed |
|
882 |
||
48757 | 883 |
lemma fps_deriv_eq_0_iff[simp]: |
884 |
"fps_deriv f = 0 \<longleftrightarrow> (f = fps_const (f$0 :: 'a::{idom,semiring_char_0}))" |
|
29687 | 885 |
proof- |
886 |
{assume "f= fps_const (f$0)" hence "fps_deriv f = fps_deriv (fps_const (f$0))" by simp |
|
887 |
hence "fps_deriv f = 0" by simp } |
|
888 |
moreover |
|
889 |
{assume z: "fps_deriv f = 0" |
|
890 |
hence "\<forall>n. (fps_deriv f)$n = 0" by simp |
|
891 |
hence "\<forall>n. f$(n+1) = 0" by (simp del: of_nat_Suc of_nat_add One_nat_def) |
|
892 |
hence "f = fps_const (f$0)" |
|
893 |
apply (clarsimp simp add: fps_eq_iff fps_const_def) |
|
894 |
apply (erule_tac x="n - 1" in allE) |
|
895 |
by simp} |
|
896 |
ultimately show ?thesis by blast |
|
897 |
qed |
|
898 |
||
30488 | 899 |
lemma fps_deriv_eq_iff: |
29687 | 900 |
fixes f:: "('a::{idom,semiring_char_0}) fps" |
901 |
shows "fps_deriv f = fps_deriv g \<longleftrightarrow> (f = fps_const(f$0 - g$0) + g)" |
|
902 |
proof- |
|
903 |
have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0" by simp |
|
904 |
also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f-g)$0)" unfolding fps_deriv_eq_0_iff .. |
|
36350 | 905 |
finally show ?thesis by (simp add: field_simps) |
29687 | 906 |
qed |
907 |
||
48757 | 908 |
lemma fps_deriv_eq_iff_ex: |
909 |
"(fps_deriv f = fps_deriv g) \<longleftrightarrow> (\<exists>(c::'a::{idom,semiring_char_0}). f = fps_const c + g)" |
|
910 |
apply auto unfolding fps_deriv_eq_iff |
|
911 |
apply blast |
|
912 |
done |
|
913 |
||
914 |
||
915 |
fun fps_nth_deriv :: "nat \<Rightarrow> ('a::semiring_1) fps \<Rightarrow> 'a fps" |
|
916 |
where |
|
29687 | 917 |
"fps_nth_deriv 0 f = f" |
918 |
| "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)" |
|
919 |
||
920 |
lemma fps_nth_deriv_commute: "fps_nth_deriv (Suc n) f = fps_deriv (fps_nth_deriv n f)" |
|
48757 | 921 |
by (induct n arbitrary: f) auto |
922 |
||
923 |
lemma fps_nth_deriv_linear[simp]: |
|
924 |
"fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) = |
|
925 |
fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g" |
|
926 |
by (induct n arbitrary: f g) (auto simp add: fps_nth_deriv_commute) |
|
927 |
||
928 |
lemma fps_nth_deriv_neg[simp]: |
|
929 |
"fps_nth_deriv n (- (f:: ('a:: comm_ring_1) fps)) = - (fps_nth_deriv n f)" |
|
930 |
by (induct n arbitrary: f) simp_all |
|
931 |
||
932 |
lemma fps_nth_deriv_add[simp]: |
|
933 |
"fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) + g) = fps_nth_deriv n f + fps_nth_deriv n g" |
|
29687 | 934 |
using fps_nth_deriv_linear[of n 1 f 1 g] by simp |
935 |
||
48757 | 936 |
lemma fps_nth_deriv_sub[simp]: |
937 |
"fps_nth_deriv n ((f:: ('a::comm_ring_1) fps) - g) = fps_nth_deriv n f - fps_nth_deriv n g" |
|
30488 | 938 |
unfolding diff_minus fps_nth_deriv_add by simp |
29687 | 939 |
|
940 |
lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0" |
|
48757 | 941 |
by (induct n) simp_all |
29687 | 942 |
|
943 |
lemma fps_nth_deriv_1[simp]: "fps_nth_deriv n 1 = (if n = 0 then 1 else 0)" |
|
48757 | 944 |
by (induct n) simp_all |
945 |
||
946 |
lemma fps_nth_deriv_const[simp]: |
|
947 |
"fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)" |
|
948 |
by (cases n) simp_all |
|
949 |
||
950 |
lemma fps_nth_deriv_mult_const_left[simp]: |
|
951 |
"fps_nth_deriv n (fps_const (c::'a::comm_ring_1) * f) = fps_const c * fps_nth_deriv n f" |
|
29687 | 952 |
using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp |
953 |
||
48757 | 954 |
lemma fps_nth_deriv_mult_const_right[simp]: |
955 |
"fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c" |
|
29687 | 956 |
using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult_commute) |
957 |
||
48757 | 958 |
lemma fps_nth_deriv_setsum: |
959 |
"fps_nth_deriv n (setsum f S) = setsum (\<lambda>i. fps_nth_deriv n (f i :: ('a::comm_ring_1) fps)) S" |
|
29687 | 960 |
proof- |
48757 | 961 |
{ assume "\<not> finite S" hence ?thesis by simp } |
29687 | 962 |
moreover |
48757 | 963 |
{ |
964 |
assume fS: "finite S" |
|
965 |
have ?thesis by (induct rule: finite_induct[OF fS]) simp_all |
|
966 |
} |
|
29687 | 967 |
ultimately show ?thesis by blast |
968 |
qed |
|
969 |
||
48757 | 970 |
lemma fps_deriv_maclauren_0: |
971 |
"(fps_nth_deriv k (f:: ('a::comm_semiring_1) fps)) $ 0 = of_nat (fact k) * f$(k)" |
|
36350 | 972 |
by (induct k arbitrary: f) (auto simp add: field_simps of_nat_mult) |
29687 | 973 |
|
29906 | 974 |
subsection {* Powers*} |
29687 | 975 |
|
976 |
lemma fps_power_zeroth_eq_one: "a$0 =1 \<Longrightarrow> a^n $ 0 = (1::'a::semiring_1)" |
|
48757 | 977 |
by (induct n) (auto simp add: expand_fps_eq fps_mult_nth) |
29687 | 978 |
|
979 |
lemma fps_power_first_eq: "(a:: 'a::comm_ring_1 fps)$0 =1 \<Longrightarrow> a^n $ 1 = of_nat n * a$1" |
|
980 |
proof(induct n) |
|
30960 | 981 |
case 0 thus ?case by simp |
29687 | 982 |
next |
983 |
case (Suc n) |
|
984 |
note h = Suc.hyps[OF `a$0 = 1`] |
|
30488 | 985 |
show ?case unfolding power_Suc fps_mult_nth |
36350 | 986 |
using h `a$0 = 1` fps_power_zeroth_eq_one[OF `a$0=1`] by (simp add: field_simps) |
29687 | 987 |
qed |
988 |
||
989 |
lemma startsby_one_power:"a $ 0 = (1::'a::comm_ring_1) \<Longrightarrow> a^n $ 0 = 1" |
|
48757 | 990 |
by (induct n) (auto simp add: fps_mult_nth) |
29687 | 991 |
|
992 |
lemma startsby_zero_power:"a $0 = (0::'a::comm_ring_1) \<Longrightarrow> n > 0 \<Longrightarrow> a^n $0 = 0" |
|
48757 | 993 |
by (induct n) (auto simp add: fps_mult_nth) |
29687 | 994 |
|
31021 | 995 |
lemma startsby_power:"a $0 = (v::'a::{comm_ring_1}) \<Longrightarrow> a^n $0 = v^n" |
48757 | 996 |
by (induct n) (auto simp add: fps_mult_nth power_Suc) |
29687 | 997 |
|
998 |
lemma startsby_zero_power_iff[simp]: |
|
31021 | 999 |
"a^n $0 = (0::'a::{idom}) \<longleftrightarrow> (n \<noteq> 0 \<and> a$0 = 0)" |
29687 | 1000 |
apply (rule iffI) |
48757 | 1001 |
apply (induct n) |
1002 |
apply (auto simp add: fps_mult_nth) |
|
1003 |
apply (rule startsby_zero_power, simp_all) |
|
1004 |
done |
|
29687 | 1005 |
|
30488 | 1006 |
lemma startsby_zero_power_prefix: |
29687 | 1007 |
assumes a0: "a $0 = (0::'a::idom)" |
1008 |
shows "\<forall>n < k. a ^ k $ n = 0" |
|
30488 | 1009 |
using a0 |
29687 | 1010 |
proof(induct k rule: nat_less_induct) |
1011 |
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)" |
|
1012 |
let ?ths = "\<forall>m<k. a ^ k $ m = 0" |
|
1013 |
{assume "k = 0" then have ?ths by simp} |
|
1014 |
moreover |
|
1015 |
{fix l assume k: "k = Suc l" |
|
1016 |
{fix m assume mk: "m < k" |
|
30488 | 1017 |
{assume "m=0" hence "a^k $ m = 0" using startsby_zero_power[of a k] k a0 |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1018 |
by simp} |
29687 | 1019 |
moreover |
1020 |
{assume m0: "m \<noteq> 0" |
|
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1021 |
have "a ^k $ m = (a^l * a) $m" by (simp add: k power_Suc mult_commute) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1022 |
also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))" by (simp add: fps_mult_nth) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1023 |
also have "\<dots> = 0" apply (rule setsum_0') |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1024 |
apply auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1025 |
apply (case_tac "aa = m") |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1026 |
using a0 |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1027 |
apply simp |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1028 |
apply (rule H[rule_format]) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1029 |
using a0 k mk by auto |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1030 |
finally have "a^k $ m = 0" .} |
29687 | 1031 |
ultimately have "a^k $ m = 0" by blast} |
1032 |
hence ?ths by blast} |
|
1033 |
ultimately show ?ths by (cases k, auto) |
|
1034 |
qed |
|
1035 |
||
30488 | 1036 |
lemma startsby_zero_setsum_depends: |
29687 | 1037 |
assumes a0: "a $0 = (0::'a::idom)" and kn: "n \<ge> k" |
1038 |
shows "setsum (\<lambda>i. (a ^ i)$k) {0 .. n} = setsum (\<lambda>i. (a ^ i)$k) {0 .. k}" |
|
1039 |
apply (rule setsum_mono_zero_right) |
|
1040 |
using kn apply auto |
|
1041 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
|
1042 |
by arith |
|
1043 |
||
31021 | 1044 |
lemma startsby_zero_power_nth_same: assumes a0: "a$0 = (0::'a::{idom})" |
29687 | 1045 |
shows "a^n $ n = (a$1) ^ n" |
1046 |
proof(induct n) |
|
1047 |
case 0 thus ?case by (simp add: power_0) |
|
1048 |
next |
|
1049 |
case (Suc n) |
|
36350 | 1050 |
have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)" by (simp add: field_simps power_Suc) |
29687 | 1051 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}" by (simp add: fps_mult_nth) |
1052 |
also have "\<dots> = setsum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}" |
|
1053 |
apply (rule setsum_mono_zero_right) |
|
1054 |
apply simp |
|
1055 |
apply clarsimp |
|
1056 |
apply clarsimp |
|
1057 |
apply (rule startsby_zero_power_prefix[rule_format, OF a0]) |
|
1058 |
apply arith |
|
1059 |
done |
|
1060 |
also have "\<dots> = a^n $ n * a$1" using a0 by simp |
|
1061 |
finally show ?case using Suc.hyps by (simp add: power_Suc) |
|
1062 |
qed |
|
1063 |
||
1064 |
lemma fps_inverse_power: |
|
31021 | 1065 |
fixes a :: "('a::{field}) fps" |
29687 | 1066 |
shows "inverse (a^n) = inverse a ^ n" |
1067 |
proof- |
|
1068 |
{assume a0: "a$0 = 0" |
|
1069 |
hence eq: "inverse a = 0" by (simp add: fps_inverse_def) |
|
1070 |
{assume "n = 0" hence ?thesis by simp} |
|
1071 |
moreover |
|
1072 |
{assume n: "n > 0" |
|
30488 | 1073 |
from startsby_zero_power[OF a0 n] eq a0 n have ?thesis |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1074 |
by (simp add: fps_inverse_def)} |
29687 | 1075 |
ultimately have ?thesis by blast} |
1076 |
moreover |
|
1077 |
{assume a0: "a$0 \<noteq> 0" |
|
1078 |
have ?thesis |
|
1079 |
apply (rule fps_inverse_unique) |
|
1080 |
apply (simp add: a0) |
|
1081 |
unfolding power_mult_distrib[symmetric] |
|
1082 |
apply (rule ssubst[where t = "a * inverse a" and s= 1]) |
|
1083 |
apply simp_all |
|
1084 |
apply (subst mult_commute) |
|
1085 |
by (rule inverse_mult_eq_1[OF a0])} |
|
1086 |
ultimately show ?thesis by blast |
|
1087 |
qed |
|
1088 |
||
48757 | 1089 |
lemma fps_deriv_power: |
1090 |
"fps_deriv (a ^ n) = fps_const (of_nat n :: 'a:: comm_ring_1) * fps_deriv a * a ^ (n - 1)" |
|
1091 |
apply (induct n) |
|
1092 |
apply (auto simp add: power_Suc field_simps fps_const_add[symmetric] simp del: fps_const_add) |
|
1093 |
apply (case_tac n) |
|
1094 |
apply (auto simp add: power_Suc field_simps) |
|
1095 |
done |
|
29687 | 1096 |
|
30488 | 1097 |
lemma fps_inverse_deriv: |
29687 | 1098 |
fixes a:: "('a :: field) fps" |
1099 |
assumes a0: "a$0 \<noteq> 0" |
|
1100 |
shows "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" |
|
1101 |
proof- |
|
1102 |
from inverse_mult_eq_1[OF a0] |
|
1103 |
have "fps_deriv (inverse a * a) = 0" by simp |
|
1104 |
hence "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0" by simp |
|
1105 |
hence "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0" by simp |
|
1106 |
with inverse_mult_eq_1[OF a0] |
|
1107 |
have "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) = 0" |
|
1108 |
unfolding power2_eq_square |
|
36350 | 1109 |
apply (simp add: field_simps) |
29687 | 1110 |
by (simp add: mult_assoc[symmetric]) |
1111 |
hence "inverse a ^ 2 * fps_deriv a + fps_deriv (inverse a) - fps_deriv a * inverse a ^ 2 = 0 - fps_deriv a * inverse a ^ 2" |
|
1112 |
by simp |
|
36350 | 1113 |
then show "fps_deriv (inverse a) = - fps_deriv a * inverse a ^ 2" by (simp add: field_simps) |
29687 | 1114 |
qed |
1115 |
||
30488 | 1116 |
lemma fps_inverse_mult: |
29687 | 1117 |
fixes a::"('a :: field) fps" |
1118 |
shows "inverse (a * b) = inverse a * inverse b" |
|
1119 |
proof- |
|
1120 |
{assume a0: "a$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth) |
|
1121 |
from a0 ab0 have th: "inverse a = 0" "inverse (a*b) = 0" by simp_all |
|
1122 |
have ?thesis unfolding th by simp} |
|
1123 |
moreover |
|
1124 |
{assume b0: "b$0 = 0" hence ab0: "(a*b)$0 = 0" by (simp add: fps_mult_nth) |
|
1125 |
from b0 ab0 have th: "inverse b = 0" "inverse (a*b) = 0" by simp_all |
|
1126 |
have ?thesis unfolding th by simp} |
|
1127 |
moreover |
|
1128 |
{assume a0: "a$0 \<noteq> 0" and b0: "b$0 \<noteq> 0" |
|
1129 |
from a0 b0 have ab0:"(a*b) $ 0 \<noteq> 0" by (simp add: fps_mult_nth) |
|
30488 | 1130 |
from inverse_mult_eq_1[OF ab0] |
29687 | 1131 |
have "inverse (a*b) * (a*b) * inverse a * inverse b = 1 * inverse a * inverse b" by simp |
1132 |
then have "inverse (a*b) * (inverse a * a) * (inverse b * b) = inverse a * inverse b" |
|
36350 | 1133 |
by (simp add: field_simps) |
29687 | 1134 |
then have ?thesis using inverse_mult_eq_1[OF a0] inverse_mult_eq_1[OF b0] by simp} |
1135 |
ultimately show ?thesis by blast |
|
1136 |
qed |
|
1137 |
||
30488 | 1138 |
lemma fps_inverse_deriv': |
29687 | 1139 |
fixes a:: "('a :: field) fps" |
1140 |
assumes a0: "a$0 \<noteq> 0" |
|
1141 |
shows "fps_deriv (inverse a) = - fps_deriv a / a ^ 2" |
|
1142 |
using fps_inverse_deriv[OF a0] |
|
48757 | 1143 |
unfolding power2_eq_square fps_divide_def fps_inverse_mult |
1144 |
by simp |
|
29687 | 1145 |
|
1146 |
lemma inverse_mult_eq_1': assumes f0: "f$0 \<noteq> (0::'a::field)" |
|
1147 |
shows "f * inverse f= 1" |
|
1148 |
by (metis mult_commute inverse_mult_eq_1 f0) |
|
1149 |
||
1150 |
lemma fps_divide_deriv: fixes a:: "('a :: field) fps" |
|
1151 |
assumes a0: "b$0 \<noteq> 0" |
|
1152 |
shows "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b ^ 2" |
|
1153 |
using fps_inverse_deriv[OF a0] |
|
48757 | 1154 |
by (simp add: fps_divide_def field_simps |
1155 |
power2_eq_square fps_inverse_mult inverse_mult_eq_1'[OF a0]) |
|
30488 | 1156 |
|
29687 | 1157 |
|
30488 | 1158 |
lemma fps_inverse_gp': "inverse (Abs_fps(\<lambda>n. (1::'a::field))) |
29687 | 1159 |
= 1 - X" |
29911
c790a70a3d19
declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents:
29906
diff
changeset
|
1160 |
by (simp add: fps_inverse_gp fps_eq_iff X_def) |
29687 | 1161 |
|
1162 |
lemma fps_nth_deriv_X[simp]: "fps_nth_deriv n X = (if n = 0 then X else if n=1 then 1 else 0)" |
|
1163 |
by (cases "n", simp_all) |
|
1164 |
||
1165 |
||
1166 |
lemma fps_inverse_X_plus1: |
|
31021 | 1167 |
"inverse (1 + X) = Abs_fps (\<lambda>n. (- (1::'a::{field})) ^ n)" (is "_ = ?r") |
29687 | 1168 |
proof- |
1169 |
have eq: "(1 + X) * ?r = 1" |
|
1170 |
unfolding minus_one_power_iff |
|
36350 | 1171 |
by (auto simp add: field_simps fps_eq_iff) |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1172 |
show ?thesis by (auto simp add: eq intro: fps_inverse_unique simp del: minus_one) |
29687 | 1173 |
qed |
1174 |
||
30488 | 1175 |
|
29906 | 1176 |
subsection{* Integration *} |
31273 | 1177 |
|
1178 |
definition |
|
1179 |
fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps" where |
|
1180 |
"fps_integral a a0 = Abs_fps (\<lambda>n. if n = 0 then a0 else (a$(n - 1) / of_nat n))" |
|
29687 | 1181 |
|
31273 | 1182 |
lemma fps_deriv_fps_integral: "fps_deriv (fps_integral a a0) = a" |
1183 |
unfolding fps_integral_def fps_deriv_def |
|
1184 |
by (simp add: fps_eq_iff del: of_nat_Suc) |
|
29687 | 1185 |
|
31273 | 1186 |
lemma fps_integral_linear: |
1187 |
"fps_integral (fps_const a * f + fps_const b * g) (a*a0 + b*b0) = |
|
1188 |
fps_const a * fps_integral f a0 + fps_const b * fps_integral g b0" |
|
1189 |
(is "?l = ?r") |
|
29687 | 1190 |
proof- |
1191 |
have "fps_deriv ?l = fps_deriv ?r" by (simp add: fps_deriv_fps_integral) |
|
1192 |
moreover have "?l$0 = ?r$0" by (simp add: fps_integral_def) |
|
1193 |
ultimately show ?thesis |
|
1194 |
unfolding fps_deriv_eq_iff by auto |
|
1195 |
qed |
|
30488 | 1196 |
|
29906 | 1197 |
subsection {* Composition of FPSs *} |
29687 | 1198 |
definition fps_compose :: "('a::semiring_1) fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps" (infixl "oo" 55) where |
1199 |
fps_compose_def: "a oo b = Abs_fps (\<lambda>n. setsum (\<lambda>i. a$i * (b^i$n)) {0..n})" |
|
1200 |
||
48757 | 1201 |
lemma fps_compose_nth: "(a oo b)$n = setsum (\<lambda>i. a$i * (b^i$n)) {0..n}" |
1202 |
by (simp add: fps_compose_def) |
|
29687 | 1203 |
|
1204 |
lemma fps_compose_X[simp]: "a oo X = (a :: ('a :: comm_ring_1) fps)" |
|
29913 | 1205 |
by (simp add: fps_ext fps_compose_def mult_delta_right setsum_delta') |
30488 | 1206 |
|
1207 |
lemma fps_const_compose[simp]: |
|
29687 | 1208 |
"fps_const (a::'a::{comm_ring_1}) oo b = fps_const (a)" |
29913 | 1209 |
by (simp add: fps_eq_iff fps_compose_nth mult_delta_left setsum_delta) |
29687 | 1210 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1211 |
lemma numeral_compose[simp]: "(numeral k::('a::{comm_ring_1}) fps) oo b = numeral k" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1212 |
unfolding numeral_fps_const by simp |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1213 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1214 |
lemma neg_numeral_compose[simp]: "(neg_numeral k::('a::{comm_ring_1}) fps) oo b = neg_numeral k" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46757
diff
changeset
|
1215 |
unfolding neg_numeral_fps_const by simp |
31369
8b460fd12100
Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents:
31199
diff
changeset
|
1216 |
|
29687 | 1217 |
lemma X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> X oo a = (a :: ('a :: comm_ring_1) fps)" |
29913 | 1218 |
by (simp add: fps_eq_iff fps_compose_def mult_delta_left setsum_delta |
1219 |
power_Suc not_le) |
|
29687 | 1220 |
|
1221 |
||
29906 | 1222 |
subsection {* Rules from Herbert Wilf's Generatingfunctionology*} |
29687 | 1223 |
|
29906 | 1224 |
subsubsection {* Rule 1 *} |
29687 | 1225 |
(* {a_{n+k}}_0^infty Corresponds to (f - setsum (\<lambda>i. a_i * x^i))/x^h, for h>0*) |
1226 |
||
30488 | 1227 |
lemma fps_power_mult_eq_shift: |
30992 | 1228 |
"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 | 1229 |
proof- |
1230 |
{fix n:: nat |
|
30488 | 1231 |
have "?lhs $ n = (if n < Suc k then 0 else a n)" |
29687 | 1232 |
unfolding X_power_mult_nth by auto |
1233 |
also have "\<dots> = ?rhs $ n" |
|
1234 |
proof(induct k) |
|
1235 |
case 0 thus ?case by (simp add: fps_setsum_nth power_Suc) |
|
1236 |
next |
|
1237 |
case (Suc k) |
|
1238 |
note th = Suc.hyps[symmetric] |
|
36350 | 1239 |
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: field_simps) |
29687 | 1240 |
also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * X^ Suc k)$n" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1241 |
using th |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1242 |
unfolding fps_sub_nth by simp |
29687 | 1243 |
also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1244 |
unfolding X_power_mult_right_nth |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1245 |
apply (auto simp add: not_less fps_const_def) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1246 |
apply (rule cong[of a a, OF refl]) |
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
1247 |
by arith |
29687 | 1248 |
finally show ?case by simp |
1249 |
qed |
|
1250 |
finally have "?lhs $ n = ?rhs $ n" .} |
|
1251 |
then show ?thesis by (simp add: fps_eq_iff) |
|
1252 |
qed |
|
1253 |
||
29906 | 1254 |
subsubsection{* Rule 2*} |
29687 | 1255 |
|
1256 |
(* We can not reach the form of Wilf, but still near to it using rewrite rules*) |
|
30488 | 1257 |
(* If f reprents {a_n} and P is a polynomial, then |
29687 | 1258 |
P(xD) f represents {P(n) a_n}*) |
1259 |
||
1260 |
definition "XD = op * X o fps_deriv" |
|
1261 |
||
1262 |
lemma XD_add[simp]:"XD (a + b) = XD a + XD (b :: ('a::comm_ring_1) fps)" |
|
36350 | 1263 |
by (simp add: XD_def field_simps) |
29687 | 1264 |
|
1265 |
lemma XD_mult_const[simp]:"XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * XD a" |
|
36350 | 1266 |
by (simp add: XD_def field_simps) |
29687 | 1267 |
|
1268 |
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)" |
|
1269 |
by simp |
|