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