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