src/HOL/Computational_Algebra/Formal_Power_Series.thy
author wenzelm
Sat, 11 Nov 2017 17:04:14 +0100
changeset 67047 19b6091c2137
parent 66817 0b12755ccbb2
child 67399 eab6ce8368fa
permissions -rw-r--r--
support alternative USER_HOME directory;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65435
378175f44328 tuned headers;
wenzelm
parents: 65417
diff changeset
     1
(*  Title:      HOL/Computational_Algebra/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
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
     5
section \<open>A formalization of formal power series\<close>
29687
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
65417
fc41a5650fb1 session containing computational algebra
haftmann
parents: 65398
diff changeset
     8
imports
fc41a5650fb1 session containing computational algebra
haftmann
parents: 65398
diff changeset
     9
  Complex_Main
fc41a5650fb1 session containing computational algebra
haftmann
parents: 65398
diff changeset
    10
  Euclidean_Algorithm
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    11
begin
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    12
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    13
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
    14
subsection \<open>The type of formal power series\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    15
49834
b27bbb021df1 discontinued obsolete typedef (open) syntax;
wenzelm
parents: 48757
diff changeset
    16
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
    17
  morphisms fps_nth Abs_fps
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    18
  by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    19
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    20
notation fps_nth (infixl "$" 75)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    21
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    22
lemma 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
    23
  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
    24
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    25
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
    26
  by (simp add: expand_fps_eq)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    27
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    28
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
    29
  by (simp add: Abs_fps_inverse)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    30
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    31
text \<open>Definition of the basic elements 0 and 1 and the basic operations of addition,
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    32
  negation and multiplication.\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    33
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36350
diff changeset
    34
instantiation fps :: (zero) zero
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    35
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    36
  definition fps_zero_def: "0 = Abs_fps (\<lambda>n. 0)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    37
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    38
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    39
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    40
lemma fps_zero_nth [simp]: "0 $ n = 0"
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    41
  unfolding fps_zero_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    42
36409
d323e7773aa8 use new classes (linordered_)field_inverse_zero
haftmann
parents: 36350
diff changeset
    43
instantiation fps :: ("{one, zero}") one
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    44
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    45
  definition fps_one_def: "1 = Abs_fps (\<lambda>n. if n = 0 then 1 else 0)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    46
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    47
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    48
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
    49
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
    50
  unfolding fps_one_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    51
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
    52
instantiation fps :: (plus) plus
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    53
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    54
  definition fps_plus_def: "op + = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n + g $ n))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    55
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    56
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    57
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    58
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
    59
  unfolding fps_plus_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    60
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    61
instantiation fps :: (minus) minus
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    62
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    63
  definition fps_minus_def: "op - = (\<lambda>f g. Abs_fps (\<lambda>n. f $ n - g $ n))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    64
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    65
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    66
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    67
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
    68
  unfolding fps_minus_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    69
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    70
instantiation fps :: (uminus) uminus
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    71
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    72
  definition fps_uminus_def: "uminus = (\<lambda>f. Abs_fps (\<lambda>n. - (f $ n)))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    73
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    74
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    75
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    76
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
    77
  unfolding fps_uminus_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    78
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
    79
instantiation fps :: ("{comm_monoid_add, times}") times
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    80
begin
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    81
  definition fps_times_def: "op * = (\<lambda>f g. Abs_fps (\<lambda>n. \<Sum>i=0..n. f $ i * g $ (n - i)))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
    82
  instance ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    83
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    84
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
    85
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
    86
  unfolding fps_times_def by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    87
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
    88
lemma fps_mult_nth_0 [simp]: "(f * g) $ 0 = f $ 0 * g $ 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
    89
  unfolding fps_times_def by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
    90
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
    91
declare atLeastAtMost_iff [presburger]
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
    92
declare Bex_def [presburger]
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
    93
declare Ball_def [presburger]
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
    94
29913
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
    95
lemma mult_delta_left:
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
    96
  fixes x y :: "'a::mult_zero"
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
    97
  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
    98
  by simp
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
    99
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
   100
lemma mult_delta_right:
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
   101
  fixes x y :: "'a::mult_zero"
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
   102
  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
   103
  by simp
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
   104
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   105
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
   106
  by auto
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   107
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   108
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
   109
  by auto
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   110
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   111
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   112
subsection \<open>Formal power series form a commutative ring with unity, if the range of sequences
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
   113
  they represent is a commutative ring with unity\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   114
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   115
instance fps :: (semigroup_add) semigroup_add
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   116
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   117
  fix a b c :: "'a fps"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   118
  show "a + b + c = a + (b + c)"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   119
    by (simp add: fps_ext add.assoc)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   120
qed
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   121
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   122
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
   123
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   124
  fix a b :: "'a fps"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   125
  show "a + b = b + a"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   126
    by (simp add: fps_ext add.commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   127
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   128
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   129
lemma fps_mult_assoc_lemma:
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   130
  fixes k :: nat
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   131
    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
   132
  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
   133
         (\<Sum>j=0..k. \<Sum>i=0..k - j. f j i (n - j - i))"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   134
  by (induct k) (simp_all add: Suc_diff_le sum.distrib add.assoc)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   135
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   136
instance fps :: (semiring_0) semigroup_mult
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   137
proof
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   138
  fix a b c :: "'a fps"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   139
  show "(a * b) * c = a * (b * c)"
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   140
  proof (rule fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   141
    fix n :: nat
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   142
    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
   143
          (\<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
   144
      by (rule fps_mult_assoc_lemma)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   145
    then show "((a * b) * c) $ n = (a * (b * c)) $ n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   146
      by (simp add: fps_mult_nth sum_distrib_left sum_distrib_right mult.assoc)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   147
  qed
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   148
qed
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   149
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   150
lemma fps_mult_commute_lemma:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
   151
  fixes n :: nat
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
   152
    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
   153
  shows "(\<Sum>i=0..n. f i (n - i)) = (\<Sum>i=0..n. f (n - i) i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   154
  by (rule sum.reindex_bij_witness[where i="op - n" and j="op - n"]) auto
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   155
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   156
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
   157
proof
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   158
  fix a b :: "'a fps"
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   159
  show "a * b = b * a"
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   160
  proof (rule fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   161
    fix n :: nat
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   162
    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
   163
      by (rule fps_mult_commute_lemma)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   164
    then show "(a * b) $ n = (b * a) $ n"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   165
      by (simp add: fps_mult_nth mult.commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   166
  qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   167
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   168
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   169
instance fps :: (monoid_add) monoid_add
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   170
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   171
  fix a :: "'a fps"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   172
  show "0 + a = a" by (simp add: fps_ext)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   173
  show "a + 0 = a" by (simp add: fps_ext)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   174
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   175
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   176
instance fps :: (comm_monoid_add) comm_monoid_add
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   177
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   178
  fix a :: "'a fps"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   179
  show "0 + a = a" by (simp add: fps_ext)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   180
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   181
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   182
instance fps :: (semiring_1) monoid_mult
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   183
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   184
  fix a :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   185
  show "1 * a = a"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   186
    by (simp add: fps_ext fps_mult_nth mult_delta_left sum.delta)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   187
  show "a * 1 = a"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   188
    by (simp add: fps_ext fps_mult_nth mult_delta_right sum.delta')
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   189
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   190
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   191
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
   192
proof
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   193
  fix a b c :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   194
  show "b = c" if "a + b = a + c"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   195
    using that by (simp add: expand_fps_eq)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   196
  show "b = c" if "b + a = c + a"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   197
    using that by (simp add: expand_fps_eq)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   198
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   199
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   200
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
   201
proof
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   202
  fix a b c :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   203
  show "a + b - a = b"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   204
    by (simp add: expand_fps_eq)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   205
  show "a - b - c = a - (b + c)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   206
    by (simp add: expand_fps_eq diff_diff_eq)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   207
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   208
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   209
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
   210
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   211
instance fps :: (group_add) group_add
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   212
proof
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   213
  fix a b :: "'a fps"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   214
  show "- a + a = 0" by (simp add: fps_ext)
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53374
diff changeset
   215
  show "a + - b = a - b" by (simp add: fps_ext)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   216
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   217
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   218
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
   219
proof
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   220
  fix a b :: "'a fps"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   221
  show "- a + a = 0" by (simp add: fps_ext)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   222
  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
   223
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   224
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   225
instance fps :: (zero_neq_one) zero_neq_one
60679
ade12ef2773c tuned proofs;
wenzelm
parents: 60567
diff changeset
   226
  by standard (simp add: expand_fps_eq)
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 :: (semiring_0) semiring
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   229
proof
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   230
  fix a b c :: "'a fps"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   231
  show "(a + b) * c = a * c + b * c"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   232
    by (simp add: expand_fps_eq fps_mult_nth distrib_right sum.distrib)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   233
  show "a * (b + c) = a * b + a * c"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   234
    by (simp add: expand_fps_eq fps_mult_nth distrib_left sum.distrib)
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 :: (semiring_0) semiring_0
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   238
proof
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   239
  fix a :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   240
  show "0 * a = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   241
    by (simp add: fps_ext fps_mult_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   242
  show "a * 0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   243
    by (simp add: fps_ext fps_mult_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   244
qed
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   245
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   246
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
   247
60867
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   248
instance fps :: (semiring_1) semiring_1 ..
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   249
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   250
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
   251
subsection \<open>Selection of the nth power of the implicit variable in the infinite sum\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   252
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   253
lemma fps_square_nth: "(f^2) $ n = (\<Sum>k\<le>n. f $ k * f $ (n - k))"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   254
  by (simp add: power2_eq_square fps_mult_nth atLeast0AtMost)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   255
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   256
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
   257
  by (simp add: expand_fps_eq)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   258
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
   259
lemma fps_nonzero_nth_minimal: "f \<noteq> 0 \<longleftrightarrow> (\<exists>n. f $ n \<noteq> 0 \<and> (\<forall>m < n. f $ m = 0))"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   260
  (is "?lhs \<longleftrightarrow> ?rhs")
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   261
proof
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   262
  let ?n = "LEAST n. f $ n \<noteq> 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   263
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   264
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   265
    from that have "\<exists>n. f $ n \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   266
      by (simp add: fps_nonzero_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   267
    then have "f $ ?n \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   268
      by (rule LeastI_ex)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   269
    moreover have "\<forall>m<?n. f $ m = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   270
      by (auto dest: not_less_Least)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   271
    ultimately have "f $ ?n \<noteq> 0 \<and> (\<forall>m<?n. f $ m = 0)" ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   272
    then show ?thesis ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   273
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   274
  show ?lhs if ?rhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   275
    using that by (auto simp add: expand_fps_eq)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   276
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   277
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   278
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
   279
  by (rule expand_fps_eq)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   280
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   281
lemma fps_sum_nth: "sum f S $ n = sum (\<lambda>k. (f k) $ n) S"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   282
proof (cases "finite S")
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   283
  case True
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   284
  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
   285
next
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   286
  case False
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   287
  then show ?thesis by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   288
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   289
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   290
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   291
subsection \<open>Injection of the basic ring elements and multiplication by scalars\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   292
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   293
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
   294
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   295
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
   296
  unfolding fps_const_def by simp
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   297
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   298
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
   299
  by (simp add: fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   300
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   301
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
   302
  by (simp add: fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   303
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   304
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
   305
  by (simp add: fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   306
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   307
lemma fps_const_add [simp]: "fps_const (c::'a::monoid_add) + fps_const d = fps_const (c + d)"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   308
  by (simp add: fps_ext)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   309
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   310
lemma fps_const_sub [simp]: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)"
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
   311
  by (simp add: fps_ext)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   312
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   313
lemma fps_const_mult[simp]: "fps_const (c::'a::ring) * fps_const d = fps_const (c * d)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   314
  by (simp add: fps_eq_iff fps_mult_nth sum.neutral)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   315
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   316
lemma fps_const_add_left: "fps_const (c::'a::monoid_add) + f =
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   317
    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
   318
  by (simp add: fps_ext)
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   319
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   320
lemma fps_const_add_right: "f + fps_const (c::'a::monoid_add) =
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   321
    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
   322
  by (simp add: fps_ext)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   323
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   324
lemma fps_const_mult_left: "fps_const (c::'a::semiring_0) * f = Abs_fps (\<lambda>n. c * f$n)"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   325
  unfolding fps_eq_iff fps_mult_nth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   326
  by (simp add: fps_const_def mult_delta_left sum.delta)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   327
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   328
lemma fps_const_mult_right: "f * fps_const (c::'a::semiring_0) = Abs_fps (\<lambda>n. f$n * c)"
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   329
  unfolding fps_eq_iff fps_mult_nth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   330
  by (simp add: fps_const_def mult_delta_right sum.delta')
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   331
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   332
lemma fps_mult_left_const_nth [simp]: "(fps_const (c::'a::semiring_1) * f)$n = c* f$n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   333
  by (simp add: fps_mult_nth mult_delta_left sum.delta)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   334
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   335
lemma fps_mult_right_const_nth [simp]: "(f * fps_const (c::'a::semiring_1))$n = f$n * c"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   336
  by (simp add: fps_mult_nth mult_delta_right sum.delta')
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   337
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   338
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
   339
subsection \<open>Formal power series form an integral domain\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   340
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   341
instance fps :: (ring) ring ..
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
instance fps :: (ring_1) ring_1
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53374
diff changeset
   344
  by (intro_classes, auto simp add: distrib_right)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   345
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   346
instance fps :: (comm_ring_1) comm_ring_1
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53374
diff changeset
   347
  by (intro_classes, auto simp add: distrib_right)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   348
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   349
instance fps :: (ring_no_zero_divisors) ring_no_zero_divisors
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   350
proof
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   351
  fix a b :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   352
  assume "a \<noteq> 0" and "b \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   353
  then obtain i j where i: "a $ i \<noteq> 0" "\<forall>k<i. a $ k = 0" and j: "b $ j \<noteq> 0" "\<forall>k<j. b $ k =0"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   354
    unfolding fps_nonzero_nth_minimal
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   355
    by blast+
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   356
  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
   357
    by (rule fps_mult_nth)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   358
  also have "\<dots> = (a $ i * b $ (i + j - i)) + (\<Sum>k\<in>{0..i+j} - {i}. a $ k * b $ (i + j - k))"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   359
    by (rule sum.remove) simp_all
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   360
  also have "(\<Sum>k\<in>{0..i+j}-{i}. a $ k * b $ (i + j - k)) = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   361
  proof (rule sum.neutral [rule_format])
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   362
    fix k assume "k \<in> {0..i+j} - {i}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   363
    then have "k < i \<or> i+j-k < j"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   364
      by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   365
    then show "a $ k * b $ (i + j - k) = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   366
      using i j by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   367
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   368
  also have "a $ i * b $ (i + j - i) + 0 = a $ i * b $ j"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   369
    by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   370
  also have "a $ i * b $ j \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   371
    using i j by simp
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   372
  finally have "(a*b) $ (i+j) \<noteq> 0" .
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   373
  then show "a * b \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   374
    unfolding fps_nonzero_nth by blast
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   375
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   376
36311
ed3a87a7f977 epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents: 36309
diff changeset
   377
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
   378
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
   379
instance fps :: (idom) idom ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   380
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
   381
lemma numeral_fps_const: "numeral k = fps_const (numeral k)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   382
  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
   383
    fps_const_add [symmetric])
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
   384
60867
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   385
lemma neg_numeral_fps_const:
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   386
  "(- numeral k :: 'a :: ring_1 fps) = fps_const (- numeral k)"
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   387
  by (simp add: numeral_fps_const)
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
   388
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   389
lemma fps_numeral_nth: "numeral n $ i = (if i = 0 then numeral n else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   390
  by (simp add: numeral_fps_const)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   391
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   392
lemma fps_numeral_nth_0 [simp]: "numeral n $ 0 = numeral n"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   393
  by (simp add: numeral_fps_const)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   394
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   395
lemma fps_of_nat: "fps_const (of_nat c) = of_nat c"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   396
  by (induction c) (simp_all add: fps_const_add [symmetric] del: fps_const_add)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   397
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
   398
lemma numeral_neq_fps_zero [simp]: "(numeral f :: 'a :: field_char_0 fps) \<noteq> 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
   399
proof
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
   400
  assume "numeral f = (0 :: 'a fps)"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
   401
  from arg_cong[of _ _ "\<lambda>F. F $ 0", OF this] show False by simp
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
   402
qed 
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   403
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   404
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   405
subsection \<open>The efps_Xtractor series fps_X\<close>
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   406
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   407
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
   408
  by (induct n) auto
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   409
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   410
definition "fps_X = Abs_fps (\<lambda>n. if n = 1 then 1 else 0)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   411
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   412
lemma fps_X_mult_nth [simp]:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   413
  "(fps_X * (f :: 'a::semiring_1 fps)) $n = (if n = 0 then 0 else f $ (n - 1))"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   414
proof (cases "n = 0")
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   415
  case False
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   416
  have "(fps_X * f) $n = (\<Sum>i = 0..n. fps_X $ i * f $ (n - i))"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   417
    by (simp add: fps_mult_nth)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   418
  also have "\<dots> = f $ (n - 1)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   419
    using False by (simp add: fps_X_def mult_delta_left sum.delta)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   420
  finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   421
    using False by simp
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   422
next
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
   423
  case True
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   424
  then show ?thesis
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   425
    by (simp add: fps_mult_nth fps_X_def)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   426
qed
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   427
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   428
lemma fps_X_mult_right_nth[simp]:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   429
  "((a::'a::semiring_1 fps) * fps_X) $ n = (if n = 0 then 0 else a $ (n - 1))"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   430
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   431
  have "(a * fps_X) $ n = (\<Sum>i = 0..n. a $ i * (if n - i = Suc 0 then 1 else 0))"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   432
    by (simp add: fps_times_def fps_X_def)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   433
  also have "\<dots> = (\<Sum>i = 0..n. if i = n - 1 then if n = 0 then 0 else a $ i else 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   434
    by (intro sum.cong) auto
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   435
  also have "\<dots> = (if n = 0 then 0 else a $ (n - 1))" by (simp add: sum.delta)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   436
  finally show ?thesis .
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   437
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   438
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   439
lemma fps_mult_fps_X_commute: "fps_X * (a :: 'a :: semiring_1 fps) = a * fps_X" 
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
   440
  by (simp add: fps_eq_iff)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   441
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   442
lemma fps_X_power_iff: "fps_X ^ n = Abs_fps (\<lambda>m. if m = n then 1 else 0)"
66466
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
   443
  by (induction n) (auto simp: fps_eq_iff)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   444
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   445
lemma fps_X_nth[simp]: "fps_X$n = (if n = 1 then 1 else 0)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   446
  by (simp add: fps_X_def)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   447
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   448
lemma fps_X_power_nth[simp]: "(fps_X^k) $n = (if n = k then 1 else 0::'a::comm_ring_1)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   449
  by (simp add: fps_X_power_iff)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   450
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   451
lemma fps_X_power_mult_nth: "(fps_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
   452
  apply (induct k arbitrary: n)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   453
  apply simp
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   454
  unfolding power_Suc mult.assoc
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   455
  apply (case_tac n)
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   456
  apply auto
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   457
  done
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   458
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   459
lemma fps_X_power_mult_right_nth:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   460
    "((f :: 'a::comm_ring_1 fps) * fps_X^k) $n = (if n < k then 0 else f $ (n - k))"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   461
  by (metis fps_X_power_mult_nth mult.commute)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   462
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   463
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   464
lemma fps_X_neq_fps_const [simp]: "(fps_X :: 'a :: zero_neq_one fps) \<noteq> fps_const c"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   465
proof
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   466
  assume "(fps_X::'a fps) = fps_const (c::'a)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   467
  hence "fps_X$1 = (fps_const (c::'a))$1" by (simp only:)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   468
  thus False by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   469
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   470
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   471
lemma fps_X_neq_zero [simp]: "(fps_X :: 'a :: zero_neq_one fps) \<noteq> 0"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   472
  by (simp only: fps_const_0_eq_0[symmetric] fps_X_neq_fps_const) simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   473
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   474
lemma fps_X_neq_one [simp]: "(fps_X :: 'a :: zero_neq_one fps) \<noteq> 1"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   475
  by (simp only: fps_const_1_eq_1[symmetric] fps_X_neq_fps_const) simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   476
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   477
lemma fps_X_neq_numeral [simp]: "(fps_X :: 'a :: {semiring_1,zero_neq_one} fps) \<noteq> numeral c"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   478
  by (simp only: numeral_fps_const fps_X_neq_fps_const) simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   479
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   480
lemma fps_X_pow_eq_fps_X_pow_iff [simp]:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   481
  "(fps_X :: ('a :: {comm_ring_1}) fps) ^ m = fps_X ^ n \<longleftrightarrow> m = n"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   482
proof
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   483
  assume "(fps_X :: 'a fps) ^ m = fps_X ^ n"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   484
  hence "(fps_X :: 'a fps) ^ m $ m = fps_X ^ n $ m" by (simp only:)
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   485
  thus "m = n" by (simp split: if_split_asm)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   486
qed simp_all
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   487
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   488
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   489
subsection \<open>Subdegrees\<close>
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   490
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   491
definition subdegree :: "('a::zero) fps \<Rightarrow> nat" where
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   492
  "subdegree f = (if f = 0 then 0 else LEAST n. f$n \<noteq> 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   493
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   494
lemma subdegreeI:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   495
  assumes "f $ d \<noteq> 0" and "\<And>i. i < d \<Longrightarrow> f $ i = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   496
  shows   "subdegree f = d"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   497
proof-
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   498
  from assms(1) have "f \<noteq> 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   499
  moreover from assms(1) have "(LEAST i. f $ i \<noteq> 0) = d"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   500
  proof (rule Least_equality)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   501
    fix e assume "f $ e \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   502
    with assms(2) have "\<not>(e < d)" by blast
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   503
    thus "e \<ge> d" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   504
  qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   505
  ultimately show ?thesis unfolding subdegree_def by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   506
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   507
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   508
lemma nth_subdegree_nonzero [simp,intro]: "f \<noteq> 0 \<Longrightarrow> f $ subdegree f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   509
proof-
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   510
  assume "f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   511
  hence "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   512
  also from \<open>f \<noteq> 0\<close> have "\<exists>n. f$n \<noteq> 0" using fps_nonzero_nth by blast
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   513
  from LeastI_ex[OF this] have "f $ (LEAST n. f $ n \<noteq> 0) \<noteq> 0" .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   514
  finally show ?thesis .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   515
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   516
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   517
lemma nth_less_subdegree_zero [dest]: "n < subdegree f \<Longrightarrow> f $ n = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   518
proof (cases "f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   519
  assume "f \<noteq> 0" and less: "n < subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   520
  note less
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   521
  also from \<open>f \<noteq> 0\<close> have "subdegree f = (LEAST n. f $ n \<noteq> 0)" by (simp add: subdegree_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   522
  finally show "f $ n = 0" using not_less_Least by blast
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   523
qed simp_all
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   524
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   525
lemma subdegree_geI:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   526
  assumes "f \<noteq> 0" "\<And>i. i < n \<Longrightarrow> f$i = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   527
  shows   "subdegree f \<ge> n"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   528
proof (rule ccontr)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   529
  assume "\<not>(subdegree f \<ge> n)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   530
  with assms(2) have "f $ subdegree f = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   531
  moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   532
  ultimately show False by contradiction
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   533
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   534
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   535
lemma subdegree_greaterI:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   536
  assumes "f \<noteq> 0" "\<And>i. i \<le> n \<Longrightarrow> f$i = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   537
  shows   "subdegree f > n"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   538
proof (rule ccontr)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   539
  assume "\<not>(subdegree f > n)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   540
  with assms(2) have "f $ subdegree f = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   541
  moreover from assms(1) have "f $ subdegree f \<noteq> 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   542
  ultimately show False by contradiction
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   543
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   544
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   545
lemma subdegree_leI:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   546
  "f $ n \<noteq> 0 \<Longrightarrow> subdegree f \<le> n"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   547
  by (rule leI) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   548
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   549
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   550
lemma subdegree_0 [simp]: "subdegree 0 = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   551
  by (simp add: subdegree_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   552
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   553
lemma subdegree_1 [simp]: "subdegree (1 :: ('a :: zero_neq_one) fps) = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   554
  by (auto intro!: subdegreeI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   555
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   556
lemma subdegree_fps_X [simp]: "subdegree (fps_X :: ('a :: zero_neq_one) fps) = 1"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   557
  by (auto intro!: subdegreeI simp: fps_X_def)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   558
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   559
lemma subdegree_fps_const [simp]: "subdegree (fps_const c) = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   560
  by (cases "c = 0") (auto intro!: subdegreeI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   561
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   562
lemma subdegree_numeral [simp]: "subdegree (numeral n) = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   563
  by (simp add: numeral_fps_const)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   564
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   565
lemma subdegree_eq_0_iff: "subdegree f = 0 \<longleftrightarrow> f = 0 \<or> f $ 0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   566
proof (cases "f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   567
  assume "f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   568
  thus ?thesis
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   569
    using nth_subdegree_nonzero[OF \<open>f \<noteq> 0\<close>] by (fastforce intro!: subdegreeI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   570
qed simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   571
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   572
lemma subdegree_eq_0 [simp]: "f $ 0 \<noteq> 0 \<Longrightarrow> subdegree f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   573
  by (simp add: subdegree_eq_0_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   574
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   575
lemma nth_subdegree_mult [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   576
  fixes f g :: "('a :: {mult_zero,comm_monoid_add}) fps"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   577
  shows "(f * g) $ (subdegree f + subdegree g) = f $ subdegree f * g $ subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   578
proof-
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   579
  let ?n = "subdegree f + subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   580
  have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   581
    by (simp add: fps_mult_nth)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   582
  also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   583
  proof (intro sum.cong)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   584
    fix x assume x: "x \<in> {0..?n}"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   585
    hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   586
    thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   587
      by (elim disjE conjE) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   588
  qed auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   589
  also have "... = f $ subdegree f * g $ subdegree g" by (simp add: sum.delta)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   590
  finally show ?thesis .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   591
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   592
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   593
lemma subdegree_mult [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   594
  assumes "f \<noteq> 0" "g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   595
  shows "subdegree ((f :: ('a :: {ring_no_zero_divisors}) fps) * g) = subdegree f + subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   596
proof (rule subdegreeI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   597
  let ?n = "subdegree f + subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   598
  have "(f * g) $ ?n = (\<Sum>i=0..?n. f$i * g$(?n-i))" by (simp add: fps_mult_nth)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   599
  also have "... = (\<Sum>i=0..?n. if i = subdegree f then f$i * g$(?n-i) else 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   600
  proof (intro sum.cong)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   601
    fix x assume x: "x \<in> {0..?n}"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   602
    hence "x = subdegree f \<or> x < subdegree f \<or> ?n - x < subdegree g" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   603
    thus "f $ x * g $ (?n - x) = (if x = subdegree f then f $ x * g $ (?n - x) else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   604
      by (elim disjE conjE) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   605
  qed auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   606
  also have "... = f $ subdegree f * g $ subdegree g" by (simp add: sum.delta)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   607
  also from assms have "... \<noteq> 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   608
  finally show "(f * g) $ (subdegree f + subdegree g) \<noteq> 0" .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   609
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   610
  fix m assume m: "m < subdegree f + subdegree g"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   611
  have "(f * g) $ m = (\<Sum>i=0..m. f$i * g$(m-i))" by (simp add: fps_mult_nth)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   612
  also have "... = (\<Sum>i=0..m. 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   613
  proof (rule sum.cong)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   614
    fix i assume "i \<in> {0..m}"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   615
    with m have "i < subdegree f \<or> m - i < subdegree g" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   616
    thus "f$i * g$(m-i) = 0" by (elim disjE) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   617
  qed auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   618
  finally show "(f * g) $ m = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   619
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   620
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   621
lemma subdegree_power [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   622
  "subdegree ((f :: ('a :: ring_1_no_zero_divisors) fps) ^ n) = n * subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   623
  by (cases "f = 0"; induction n) simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   624
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   625
lemma subdegree_uminus [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   626
  "subdegree (-(f::('a::group_add) fps)) = subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   627
  by (simp add: subdegree_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   628
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   629
lemma subdegree_minus_commute [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   630
  "subdegree (f-(g::('a::group_add) fps)) = subdegree (g - f)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   631
proof -
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   632
  have "f - g = -(g - f)" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   633
  also have "subdegree ... = subdegree (g - f)" by (simp only: subdegree_uminus)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   634
  finally show ?thesis .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   635
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   636
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   637
lemma subdegree_add_ge:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   638
  assumes "f \<noteq> -(g :: ('a :: {group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   639
  shows   "subdegree (f + g) \<ge> min (subdegree f) (subdegree g)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   640
proof (rule subdegree_geI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   641
  from assms show "f + g \<noteq> 0" by (subst (asm) eq_neg_iff_add_eq_0)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   642
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   643
  fix i assume "i < min (subdegree f) (subdegree g)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   644
  hence "f $ i = 0" and "g $ i = 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   645
  thus "(f + g) $ i = 0" by force
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   646
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   647
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   648
lemma subdegree_add_eq1:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   649
  assumes "f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   650
  assumes "subdegree f < subdegree (g :: ('a :: {group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   651
  shows   "subdegree (f + g) = subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   652
proof (rule antisym[OF subdegree_leI])
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   653
  from assms show "subdegree (f + g) \<ge> subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   654
    by (intro order.trans[OF min.boundedI subdegree_add_ge]) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   655
  from assms have "f $ subdegree f \<noteq> 0" "g $ subdegree f = 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   656
  thus "(f + g) $ subdegree f \<noteq> 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   657
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   658
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   659
lemma subdegree_add_eq2:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   660
  assumes "g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   661
  assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   662
  shows   "subdegree (f + g) = subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   663
  using subdegree_add_eq1[OF assms] by (simp add: add.commute)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   664
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   665
lemma subdegree_diff_eq1:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   666
  assumes "f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   667
  assumes "subdegree f < subdegree (g :: ('a :: {ab_group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   668
  shows   "subdegree (f - g) = subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   669
  using subdegree_add_eq1[of f "-g"] assms by (simp add: add.commute)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   670
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   671
lemma subdegree_diff_eq2:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   672
  assumes "g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   673
  assumes "subdegree g < subdegree (f :: ('a :: {ab_group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   674
  shows   "subdegree (f - g) = subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   675
  using subdegree_add_eq2[of "-g" f] assms by (simp add: add.commute)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   676
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   677
lemma subdegree_diff_ge [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   678
  assumes "f \<noteq> (g :: ('a :: {group_add}) fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   679
  shows   "subdegree (f - g) \<ge> min (subdegree f) (subdegree g)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   680
  using assms subdegree_add_ge[of f "-g"] by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   681
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   682
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   683
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   684
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   685
subsection \<open>Shifting and slicing\<close>
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   686
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   687
definition fps_shift :: "nat \<Rightarrow> 'a fps \<Rightarrow> 'a fps" where
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   688
  "fps_shift n f = Abs_fps (\<lambda>i. f $ (i + n))"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   689
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   690
lemma fps_shift_nth [simp]: "fps_shift n f $ i = f $ (i + n)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   691
  by (simp add: fps_shift_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   692
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   693
lemma fps_shift_0 [simp]: "fps_shift 0 f = f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   694
  by (intro fps_ext) (simp add: fps_shift_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   695
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   696
lemma fps_shift_zero [simp]: "fps_shift n 0 = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   697
  by (intro fps_ext) (simp add: fps_shift_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   698
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   699
lemma fps_shift_one: "fps_shift n 1 = (if n = 0 then 1 else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   700
  by (intro fps_ext) (simp add: fps_shift_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   701
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   702
lemma fps_shift_fps_const: "fps_shift n (fps_const c) = (if n = 0 then fps_const c else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   703
  by (intro fps_ext) (simp add: fps_shift_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   704
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   705
lemma fps_shift_numeral: "fps_shift n (numeral c) = (if n = 0 then numeral c else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   706
  by (simp add: numeral_fps_const fps_shift_fps_const)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   707
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   708
lemma fps_shift_fps_X_power [simp]:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   709
  "n \<le> m \<Longrightarrow> fps_shift n (fps_X ^ m) = (fps_X ^ (m - n) ::'a::comm_ring_1 fps)"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   710
  by (intro fps_ext) (auto simp: fps_shift_def )
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   711
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   712
lemma fps_shift_times_fps_X_power:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   713
  "n \<le> subdegree f \<Longrightarrow> fps_shift n f * fps_X ^ n = (f :: 'a :: comm_ring_1 fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   714
  by (intro fps_ext) (auto simp: fps_X_power_mult_right_nth nth_less_subdegree_zero)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   715
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   716
lemma fps_shift_times_fps_X_power' [simp]:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   717
  "fps_shift n (f * fps_X^n) = (f :: 'a :: comm_ring_1 fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   718
  by (intro fps_ext) (auto simp: fps_X_power_mult_right_nth nth_less_subdegree_zero)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   719
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   720
lemma fps_shift_times_fps_X_power'':
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   721
  "m \<le> n \<Longrightarrow> fps_shift n (f * fps_X^m) = fps_shift (n - m) (f :: 'a :: comm_ring_1 fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   722
  by (intro fps_ext) (auto simp: fps_X_power_mult_right_nth nth_less_subdegree_zero)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   723
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   724
lemma fps_shift_subdegree [simp]:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   725
  "n \<le> subdegree f \<Longrightarrow> subdegree (fps_shift n f) = subdegree (f :: 'a :: comm_ring_1 fps) - n"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   726
  by (cases "f = 0") (force intro: nth_less_subdegree_zero subdegreeI)+
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   727
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   728
lemma subdegree_decompose:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   729
  "f = fps_shift (subdegree f) f * fps_X ^ subdegree (f :: ('a :: comm_ring_1) fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   730
  by (rule fps_ext) (auto simp: fps_X_power_mult_right_nth)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   731
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   732
lemma subdegree_decompose':
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   733
  "n \<le> subdegree (f :: ('a :: comm_ring_1) fps) \<Longrightarrow> f = fps_shift n f * fps_X^n"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   734
  by (rule fps_ext) (auto simp: fps_X_power_mult_right_nth intro!: nth_less_subdegree_zero)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   735
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   736
lemma fps_shift_fps_shift:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   737
  "fps_shift (m + n) f = fps_shift m (fps_shift n f)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   738
  by (rule fps_ext) (simp add: add_ac)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   739
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   740
lemma fps_shift_add:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   741
  "fps_shift n (f + g) = fps_shift n f + fps_shift n g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   742
  by (simp add: fps_eq_iff)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   743
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   744
lemma fps_shift_mult:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   745
  assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   746
  shows   "fps_shift n (h*g) = h * fps_shift n g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   747
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   748
  from assms have "g = fps_shift n g * fps_X^n" by (rule subdegree_decompose')
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   749
  also have "h * ... = (h * fps_shift n g) * fps_X^n" by simp
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   750
  also have "fps_shift n ... = h * fps_shift n g" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   751
  finally show ?thesis .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   752
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   753
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   754
lemma fps_shift_mult_right:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   755
  assumes "n \<le> subdegree (g :: 'b :: {comm_ring_1} fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   756
  shows   "fps_shift n (g*h) = h * fps_shift n g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   757
  by (subst mult.commute, subst fps_shift_mult) (simp_all add: assms)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   758
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   759
lemma nth_subdegree_zero_iff [simp]: "f $ subdegree f = 0 \<longleftrightarrow> f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   760
  by (cases "f = 0") auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   761
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   762
lemma fps_shift_subdegree_zero_iff [simp]:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   763
  "fps_shift (subdegree f) f = 0 \<longleftrightarrow> f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   764
  by (subst (1) nth_subdegree_zero_iff[symmetric], cases "f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   765
     (simp_all del: nth_subdegree_zero_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   766
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   767
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   768
definition "fps_cutoff n f = Abs_fps (\<lambda>i. if i < n then f$i else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   769
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   770
lemma fps_cutoff_nth [simp]: "fps_cutoff n f $ i = (if i < n then f$i else 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   771
  unfolding fps_cutoff_def by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   772
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   773
lemma fps_cutoff_zero_iff: "fps_cutoff n f = 0 \<longleftrightarrow> (f = 0 \<or> n \<le> subdegree f)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   774
proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   775
  assume A: "fps_cutoff n f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   776
  thus "f = 0 \<or> n \<le> subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   777
  proof (cases "f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   778
    assume "f \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   779
    with A have "n \<le> subdegree f"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   780
      by (intro subdegree_geI) (auto simp: fps_eq_iff split: if_split_asm)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   781
    thus ?thesis ..
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   782
  qed simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   783
qed (auto simp: fps_eq_iff intro: nth_less_subdegree_zero)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   784
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   785
lemma fps_cutoff_0 [simp]: "fps_cutoff 0 f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   786
  by (simp add: fps_eq_iff)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   787
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   788
lemma fps_cutoff_zero [simp]: "fps_cutoff n 0 = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   789
  by (simp add: fps_eq_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   790
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   791
lemma fps_cutoff_one: "fps_cutoff n 1 = (if n = 0 then 0 else 1)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   792
  by (simp add: fps_eq_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   793
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   794
lemma fps_cutoff_fps_const: "fps_cutoff n (fps_const c) = (if n = 0 then 0 else fps_const c)"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   795
  by (simp add: fps_eq_iff)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   796
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   797
lemma fps_cutoff_numeral: "fps_cutoff n (numeral c) = (if n = 0 then 0 else numeral c)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   798
  by (simp add: numeral_fps_const fps_cutoff_fps_const)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   799
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   800
lemma fps_shift_cutoff:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   801
  "fps_shift n (f :: ('a :: comm_ring_1) fps) * fps_X^n + fps_cutoff n f = f"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   802
  by (simp add: fps_eq_iff fps_X_power_mult_right_nth)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   803
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   804
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   805
subsection \<open>Formal Power series form a metric space\<close>
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   806
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   807
instantiation fps :: (comm_ring_1) dist
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   808
begin
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   809
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   810
definition
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   811
  dist_fps_def: "dist (a :: 'a fps) b = (if a = b then 0 else inverse (2 ^ subdegree (a - b)))"
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   812
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   813
lemma dist_fps_ge0: "dist (a :: 'a fps) b \<ge> 0"
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   814
  by (simp add: dist_fps_def)
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   815
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   816
lemma dist_fps_sym: "dist (a :: 'a fps) b = dist b a"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   817
  by (simp add: dist_fps_def)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   818
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   819
instance ..
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
   820
30746
d6915b738bd9 fps made instance of number_ring
chaieb
parents: 30488
diff changeset
   821
end
d6915b738bd9 fps made instance of number_ring
chaieb
parents: 30488
diff changeset
   822
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   823
instantiation fps :: (comm_ring_1) metric_space
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   824
begin
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   825
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   826
definition uniformity_fps_def [code del]:
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   827
  "(uniformity :: ('a fps \<times> 'a fps) filter) = (INF e:{0 <..}. principal {(x, y). dist x y < e})"
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   828
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   829
definition open_fps_def' [code del]:
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   830
  "open (U :: 'a fps set) \<longleftrightarrow> (\<forall>x\<in>U. eventually (\<lambda>(x', y). x' = x \<longrightarrow> y \<in> U) uniformity)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   831
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   832
instance
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   833
proof
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   834
  show th: "dist a b = 0 \<longleftrightarrow> a = b" for a b :: "'a fps"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
   835
    by (simp add: dist_fps_def split: if_split_asm)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   836
  then have th'[simp]: "dist a a = 0" for a :: "'a fps" by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   837
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   838
  fix a b c :: "'a fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   839
  consider "a = b" | "c = a \<or> c = b" | "a \<noteq> b" "a \<noteq> c" "b \<noteq> c" by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   840
  then show "dist a b \<le> dist a c + dist b c"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   841
  proof cases
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   842
    case 1
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   843
    then show ?thesis by (simp add: dist_fps_def)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   844
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   845
    case 2
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   846
    then show ?thesis
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   847
      by (cases "c = a") (simp_all add: th dist_fps_sym)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   848
  next
60567
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
   849
    case neq: 3
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   850
    have False if "dist a b > dist a c + dist b c"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   851
    proof -
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   852
      let ?n = "subdegree (a - b)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   853
      from neq have "dist a b > 0" "dist b c > 0" and "dist a c > 0" by (simp_all add: dist_fps_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   854
      with that have "dist a b > dist a c" and "dist a b > dist b c" by simp_all
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   855
      with neq have "?n < subdegree (a - c)" and "?n < subdegree (b - c)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   856
        by (simp_all add: dist_fps_def field_simps)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   857
      hence "(a - c) $ ?n = 0" and "(b - c) $ ?n = 0"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   858
        by (simp_all only: nth_less_subdegree_zero)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   859
      hence "(a - b) $ ?n = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   860
      moreover from neq have "(a - b) $ ?n \<noteq> 0" by (intro nth_subdegree_nonzero) simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   861
      ultimately show False by contradiction
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   862
    qed
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   863
    thus ?thesis by (auto simp add: not_le[symmetric])
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   864
  qed
62101
26c0a70f78a3 add uniform spaces
hoelzl
parents: 61969
diff changeset
   865
qed (rule open_fps_def' uniformity_fps_def)+
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   866
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   867
end
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   868
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   869
declare uniformity_Abort[where 'a="'a :: comm_ring_1 fps", code]
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   870
66373
56f8bfe1211c Removed unnecessary constant 'ball' from Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 66311
diff changeset
   871
lemma open_fps_def: "open (S :: 'a::comm_ring_1 fps set) = (\<forall>a \<in> S. \<exists>r. r >0 \<and> {y. dist y a < r} \<subseteq> S)"
56f8bfe1211c Removed unnecessary constant 'ball' from Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 66311
diff changeset
   872
  unfolding open_dist subset_eq by simp
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   873
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   874
text \<open>The infinite sums and justification of the notation in textbooks.\<close>
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   875
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   876
lemma reals_power_lt_ex:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   877
  fixes x y :: real
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   878
  assumes xp: "x > 0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   879
    and y1: "y > 1"
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   880
  shows "\<exists>k>0. (1/y)^k < x"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   881
proof -
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   882
  have yp: "y > 0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   883
    using y1 by simp
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   884
  from reals_Archimedean2[of "max 0 (- log y x) + 1"]
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   885
  obtain k :: nat where k: "real k > max 0 (- log y x) + 1"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   886
    by blast
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   887
  from k have kp: "k > 0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   888
    by simp
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   889
  from k have "real k > - log y x"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   890
    by simp
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   891
  then have "ln y * real k > - ln x"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   892
    unfolding log_def
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   893
    using ln_gt_zero_iff[OF yp] y1
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   894
    by (simp add: minus_divide_left field_simps del: minus_divide_left[symmetric])
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   895
  then have "ln y * real k + ln x > 0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   896
    by simp
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   897
  then have "exp (real k * ln y + ln x) > exp 0"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
   898
    by (simp add: ac_simps)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   899
  then have "y ^ k * x > 1"
65578
e4997c181cce New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
paulson <lp15@cam.ac.uk>
parents: 65435
diff changeset
   900
    unfolding exp_zero exp_add exp_of_nat_mult exp_ln [OF xp] exp_ln [OF yp]
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   901
    by simp
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   902
  then have "x > (1 / y)^k" using yp
60867
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
   903
    by (simp add: field_simps)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   904
  then show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   905
    using kp by blast
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   906
qed
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   907
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   908
lemma fps_sum_rep_nth: "(sum (\<lambda>i. fps_const(a$i)*fps_X^i) {0..m})$n =
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   909
    (if n \<le> m then a$n else 0::'a::comm_ring_1)"
66089
def95e0bc529 Some new material. SIMPRULE STATUS for sum/prod.delta rules!
paulson <lp15@cam.ac.uk>
parents: 65578
diff changeset
   910
  by (auto simp add: fps_sum_nth cond_value_iff cong del: if_weak_cong)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   911
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
   912
lemma fps_notation: "(\<lambda>n. sum (\<lambda>i. fps_const(a$i) * fps_X^i) {0..n}) \<longlonglongrightarrow> a"
61969
e01015e49041 more symbols;
wenzelm
parents: 61943
diff changeset
   913
  (is "?s \<longlonglongrightarrow> a")
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   914
proof -
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   915
  have "\<exists>n0. \<forall>n \<ge> n0. dist (?s n) a < r" if "r > 0" for r
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   916
  proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   917
    obtain n0 where n0: "(1/2)^n0 < r" "n0 > 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   918
      using reals_power_lt_ex[OF \<open>r > 0\<close>, of 2] by auto
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   919
    show ?thesis
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   920
    proof -
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   921
      have "dist (?s n) a < r" if nn0: "n \<ge> n0" for n
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   922
      proof -
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   923
        from that have thnn0: "(1/2)^n \<le> (1/2 :: real)^n0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   924
          by (simp add: divide_simps)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   925
        show ?thesis
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   926
        proof (cases "?s n = a")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   927
          case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   928
          then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   929
            unfolding dist_eq_0_iff[of "?s n" a, symmetric]
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   930
            using \<open>r > 0\<close> by (simp del: dist_eq_0_iff)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   931
        next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   932
          case False
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   933
          from False have dth: "dist (?s n) a = (1/2)^subdegree (?s n - a)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   934
            by (simp add: dist_fps_def field_simps)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   935
          from False have kn: "subdegree (?s n - a) > n"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   936
            by (intro subdegree_greaterI) (simp_all add: fps_sum_rep_nth)
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   937
          then have "dist (?s n) a < (1/2)^n"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   938
            by (simp add: field_simps dist_fps_def)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   939
          also have "\<dots> \<le> (1/2)^n0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   940
            using nn0 by (simp add: divide_simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   941
          also have "\<dots> < r"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   942
            using n0 by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   943
          finally show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   944
        qed
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   945
      qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   946
      then show ?thesis by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   947
    qed
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   948
  qed
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   949
  then show ?thesis
60017
b785d6d06430 Overloading of ln and powr, but "approximation" no longer works for powr. Code generation also fails due to type ambiguity in scala.
paulson <lp15@cam.ac.uk>
parents: 59867
diff changeset
   950
    unfolding lim_sequentially by blast
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   951
qed
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
   952
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   953
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   954
subsection \<open>Inverses of formal power series\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   955
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   956
declare sum.cong[fundef_cong]
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   957
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
   958
instantiation fps :: ("{comm_monoid_add,inverse,times,uminus}") inverse
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   959
begin
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   960
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   961
fun natfun_inverse:: "'a fps \<Rightarrow> nat \<Rightarrow> 'a"
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   962
where
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   963
  "natfun_inverse f 0 = inverse (f$0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
   964
| "natfun_inverse f n = - inverse (f$0) * sum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   965
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   966
definition fps_inverse_def: "inverse f = (if f $ 0 = 0 then 0 else Abs_fps (natfun_inverse f))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   967
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   968
definition fps_divide_def:
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
   969
  "f div g = (if g = 0 then 0 else
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   970
     let n = subdegree g; h = fps_shift n g
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
   971
     in  fps_shift n (f * inverse h))"
36311
ed3a87a7f977 epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents: 36309
diff changeset
   972
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   973
instance ..
36311
ed3a87a7f977 epheremal replacement of field_simps by field_eq_simps; dropped old division_by_zero instance
haftmann
parents: 36309
diff changeset
   974
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   975
end
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   976
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   977
lemma fps_inverse_zero [simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   978
  "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
   979
  by (simp add: fps_ext fps_inverse_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   980
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   981
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
   982
  apply (auto simp add: expand_fps_eq fps_inverse_def)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   983
  apply (case_tac n)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   984
  apply auto
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   985
  done
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   986
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   987
lemma inverse_mult_eq_1 [intro]:
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   988
  assumes f0: "f$0 \<noteq> (0::'a::field)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   989
  shows "inverse f * f = 1"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
   990
proof -
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   991
  have c: "inverse f * f = f * inverse f"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
   992
    by (simp add: mult.commute)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
   993
  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
   994
    by (simp add: fps_inverse_def)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
   995
  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
   996
    by (simp add: fps_mult_nth fps_inverse_def)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   997
  have "(inverse f * f)$n = 0" if np: "n > 0" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
   998
  proof -
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
   999
    from np have eq: "{0..n} = {0} \<union> {1 .. n}"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1000
      by auto
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1001
    have d: "{0} \<inter> {1 .. n} = {}"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1002
      by auto
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1003
    from f0 np have th0: "- (inverse f $ n) =
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1004
      (sum (\<lambda>i. f$i * natfun_inverse f (n - i)) {1..n}) / (f$0)"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1005
      by (cases n) (simp_all add: divide_inverse fps_inverse_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1006
    from th0[symmetric, unfolded nonzero_divide_eq_eq[OF f0]]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1007
    have th1: "sum (\<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
  1008
      by (simp add: field_simps)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1009
    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
  1010
      unfolding fps_mult_nth ifn ..
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1011
    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
  1012
      by (simp add: eq)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1013
    also have "\<dots> = 0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1014
      unfolding th1 ifn by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1015
    finally show ?thesis unfolding c .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1016
  qed
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1017
  with th0 show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1018
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1019
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1020
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1021
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
  1022
  by (simp add: fps_inverse_def nonzero_imp_inverse_nonzero)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1023
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1024
lemma fps_inverse_nth_0 [simp]: "inverse f $ 0 = inverse (f $ 0 :: 'a :: division_ring)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1025
  by (simp add: fps_inverse_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1026
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1027
lemma fps_inverse_eq_0_iff[simp]: "inverse f = (0:: ('a::division_ring) fps) \<longleftrightarrow> f $ 0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1028
proof
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1029
  assume A: "inverse f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1030
  have "0 = inverse f $ 0" by (subst A) simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1031
  thus "f $ 0 = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1032
qed (simp add: fps_inverse_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1033
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1034
lemma fps_inverse_idempotent[intro, simp]:
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1035
  assumes f0: "f$0 \<noteq> (0::'a::field)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1036
  shows "inverse (inverse f) = f"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1037
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1038
  from f0 have if0: "inverse f $ 0 \<noteq> 0" by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1039
  from inverse_mult_eq_1[OF f0] inverse_mult_eq_1[OF if0]
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1040
  have "inverse f * f = inverse f * inverse (inverse f)"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  1041
    by (simp add: ac_simps)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1042
  then show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1043
    using f0 unfolding mult_cancel_left by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1044
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1045
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1046
lemma fps_inverse_unique:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1047
  assumes fg: "(f :: 'a :: field fps) * g = 1"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1048
  shows   "inverse f = g"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1049
proof -
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1050
  have f0: "f $ 0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1051
  proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1052
    assume "f $ 0 = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1053
    hence "0 = (f * g) $ 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1054
    also from fg have "(f * g) $ 0 = 1" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1055
    finally show False by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1056
  qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1057
  from inverse_mult_eq_1[OF this] fg
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1058
  have th0: "inverse f * f = g * f"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  1059
    by (simp add: ac_simps)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1060
  then show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1061
    using f0
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1062
    unfolding mult_cancel_right
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
  1063
    by (auto simp add: expand_fps_eq)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1064
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1065
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1066
lemma fps_inverse_eq_0: "f$0 = 0 \<Longrightarrow> inverse (f :: 'a :: division_ring fps) = 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1067
  by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1068
  
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1069
lemma sum_zero_lemma:
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1070
  fixes n::nat
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1071
  assumes "0 < n"
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1072
  shows "(\<Sum>i = 0..n. if n = i then 1 else if n - i = 1 then - 1 else 0) = (0::'a::field)"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1073
proof -
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1074
  let ?f = "\<lambda>i. if n = i then 1 else if n - i = 1 then - 1 else 0"
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1075
  let ?g = "\<lambda>i. if i = n then 1 else if i = n - 1 then - 1 else 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1076
  let ?h = "\<lambda>i. if i=n - 1 then - 1 else 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1077
  have th1: "sum ?f {0..n} = sum ?g {0..n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1078
    by (rule sum.cong) auto
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1079
  have th2: "sum ?g {0..n - 1} = sum ?h {0..n - 1}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1080
    apply (rule sum.cong)
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1081
    using assms
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1082
    apply auto
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1083
    done
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1084
  have eq: "{0 .. n} = {0.. n - 1} \<union> {n}"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1085
    by auto
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1086
  from assms have d: "{0.. n - 1} \<inter> {n} = {}"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1087
    by auto
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1088
  have f: "finite {0.. n - 1}" "finite {n}"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1089
    by auto
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1090
  show ?thesis
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1091
    unfolding th1
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1092
    apply (simp add: sum.union_disjoint[OF f d, unfolded eq[symmetric]] del: One_nat_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1093
    unfolding th2
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1094
    apply (simp add: sum.delta)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1095
    done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1096
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1097
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1098
lemma fps_inverse_mult: "inverse (f * g :: 'a::field fps) = inverse f * inverse g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1099
proof (cases "f$0 = 0 \<or> g$0 = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1100
  assume "\<not>(f$0 = 0 \<or> g$0 = 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1101
  hence [simp]: "f$0 \<noteq> 0" "g$0 \<noteq> 0" by simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1102
  show ?thesis
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1103
  proof (rule fps_inverse_unique)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1104
    have "f * g * (inverse f * inverse g) = (inverse f * f) * (inverse g * g)" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1105
    also have "... = 1" by (subst (1 2) inverse_mult_eq_1) simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1106
    finally show "f * g * (inverse f * inverse g) = 1" .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1107
  qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1108
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1109
  assume A: "f$0 = 0 \<or> g$0 = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1110
  hence "inverse (f * g) = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1111
  also from A have "... = inverse f * inverse g" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1112
  finally show "inverse (f * g) = inverse f * inverse g" .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1113
qed
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1114
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1115
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1116
lemma fps_inverse_gp: "inverse (Abs_fps(\<lambda>n. (1::'a::field))) =
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1117
    Abs_fps (\<lambda>n. if n= 0 then 1 else if n=1 then - 1 else 0)"
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1118
  apply (rule fps_inverse_unique)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1119
  apply (simp_all add: fps_eq_iff fps_mult_nth sum_zero_lemma)
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1120
  done
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  1121
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1122
lemma subdegree_inverse [simp]: "subdegree (inverse (f::'a::field fps)) = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1123
proof (cases "f$0 = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1124
  assume nz: "f$0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1125
  hence "subdegree (inverse f) + subdegree f = subdegree (inverse f * f)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1126
    by (subst subdegree_mult) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1127
  also from nz have "subdegree f = 0" by (simp add: subdegree_eq_0_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1128
  also from nz have "inverse f * f = 1" by (rule inverse_mult_eq_1)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1129
  finally show "subdegree (inverse f) = 0" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1130
qed (simp_all add: fps_inverse_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1131
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1132
lemma fps_is_unit_iff [simp]: "(f :: 'a :: field fps) dvd 1 \<longleftrightarrow> f $ 0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1133
proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1134
  assume "f dvd 1"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1135
  then obtain g where "1 = f * g" by (elim dvdE)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1136
  from this[symmetric] have "(f*g) $ 0 = 1" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1137
  thus "f $ 0 \<noteq> 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1138
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1139
  assume A: "f $ 0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1140
  thus "f dvd 1" by (simp add: inverse_mult_eq_1[OF A, symmetric])
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1141
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1142
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1143
lemma subdegree_eq_0' [simp]: "(f :: 'a :: field fps) dvd 1 \<Longrightarrow> subdegree f = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1144
  by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1145
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1146
lemma fps_unit_dvd [simp]: "(f $ 0 :: 'a :: field) \<noteq> 0 \<Longrightarrow> f dvd g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1147
  by (rule dvd_trans, subst fps_is_unit_iff) simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1148
64592
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1149
instantiation fps :: (field) normalization_semidom
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1150
begin
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1151
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1152
definition fps_unit_factor_def [simp]:
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1153
  "unit_factor f = fps_shift (subdegree f) f"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1154
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1155
definition fps_normalize_def [simp]:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1156
  "normalize f = (if f = 0 then 0 else fps_X ^ subdegree f)"
64592
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1157
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1158
instance proof
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1159
  fix f :: "'a fps"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1160
  show "unit_factor f * normalize f = f"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1161
    by (simp add: fps_shift_times_fps_X_power)
64592
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1162
next
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1163
  fix f g :: "'a fps"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1164
  show "unit_factor (f * g) = unit_factor f * unit_factor g"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1165
  proof (cases "f = 0 \<or> g = 0")
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1166
    assume "\<not>(f = 0 \<or> g = 0)"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1167
    thus "unit_factor (f * g) = unit_factor f * unit_factor g"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1168
    unfolding fps_unit_factor_def
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1169
      by (auto simp: fps_shift_fps_shift fps_shift_mult fps_shift_mult_right)
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1170
  qed auto
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1171
next
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1172
  fix f g :: "'a fps"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1173
  assume "g \<noteq> 0"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1174
  then have "f * (fps_shift (subdegree g) g * inverse (fps_shift (subdegree g) g)) = f"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1175
    by (metis add_cancel_right_left fps_shift_nth inverse_mult_eq_1 mult.commute mult_cancel_left2 nth_subdegree_nonzero)
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1176
  then have "fps_shift (subdegree g) (g * (f * inverse (fps_shift (subdegree g) g))) = f"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1177
    by (simp add: fps_shift_mult_right mult.commute)
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1178
  with \<open>g \<noteq> 0\<close> show "f * g / g = f"
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1179
    by (simp add: fps_divide_def Let_def ac_simps)
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1180
qed (auto simp add: fps_divide_def Let_def)
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1181
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1182
end
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1183
66806
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1184
instantiation fps :: (field) idom_modulo
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1185
begin
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1186
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1187
definition fps_mod_def:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1188
  "f mod g = (if g = 0 then f else
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1189
     let n = subdegree g; h = fps_shift n g
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1190
     in  fps_cutoff n (f * inverse h) * h)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1191
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1192
lemma fps_mod_eq_zero:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1193
  assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1194
  shows   "f mod g = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1195
  using assms by (cases "f = 0") (auto simp: fps_cutoff_zero_iff fps_mod_def Let_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1196
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1197
lemma fps_times_divide_eq:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1198
  assumes "g \<noteq> 0" and "subdegree f \<ge> subdegree (g :: 'a fps)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1199
  shows   "f div g * g = f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1200
proof (cases "f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1201
  assume nz: "f \<noteq> 0"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62481
diff changeset
  1202
  define n where "n = subdegree g"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62481
diff changeset
  1203
  define h where "h = fps_shift n g"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1204
  from assms have [simp]: "h $ 0 \<noteq> 0" unfolding h_def by (simp add: n_def)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1205
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1206
  from assms nz have "f div g * g = fps_shift n (f * inverse h) * g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1207
    by (simp add: fps_divide_def Let_def h_def n_def)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1208
  also have "... = fps_shift n (f * inverse h) * fps_X^n * h" unfolding h_def n_def
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1209
    by (subst subdegree_decompose[of g]) simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1210
  also have "fps_shift n (f * inverse h) * fps_X^n = f * inverse h"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1211
    by (rule fps_shift_times_fps_X_power) (simp_all add: nz assms n_def)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1212
  also have "... * h = f * (inverse h * h)" by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1213
  also have "inverse h * h = 1" by (rule inverse_mult_eq_1) simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1214
  finally show ?thesis by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1215
qed (simp_all add: fps_divide_def Let_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1216
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1217
lemma
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1218
  assumes "g$0 \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1219
  shows   fps_divide_unit: "f div g = f * inverse g" and fps_mod_unit [simp]: "f mod g = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1220
proof -
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1221
  from assms have [simp]: "subdegree g = 0" by (simp add: subdegree_eq_0_iff)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1222
  from assms show "f div g = f * inverse g"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1223
    by (auto simp: fps_divide_def Let_def subdegree_eq_0_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1224
  from assms show "f mod g = 0" by (intro fps_mod_eq_zero) auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1225
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1226
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1227
instance proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1228
  fix f g :: "'a fps"
63040
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62481
diff changeset
  1229
  define n where "n = subdegree g"
eb4ddd18d635 eliminated old 'def';
wenzelm
parents: 62481
diff changeset
  1230
  define h where "h = fps_shift n g"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1231
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1232
  show "f div g * g + f mod g = f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1233
  proof (cases "g = 0 \<or> f = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1234
    assume "\<not>(g = 0 \<or> f = 0)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1235
    hence nz [simp]: "f \<noteq> 0" "g \<noteq> 0" by simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1236
    show ?thesis
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1237
    proof (rule disjE[OF le_less_linear])
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1238
      assume "subdegree f \<ge> subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1239
      with nz show ?thesis by (simp add: fps_mod_eq_zero fps_times_divide_eq)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1240
    next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1241
      assume "subdegree f < subdegree g"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1242
      have g_decomp: "g = h * fps_X^n" unfolding h_def n_def by (rule subdegree_decompose)
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1243
      have "f div g * g + f mod g =
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1244
              fps_shift n (f * inverse h) * g + fps_cutoff n (f * inverse h) * h"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1245
        by (simp add: fps_mod_def fps_divide_def Let_def n_def h_def)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1246
      also have "... = h * (fps_shift n (f * inverse h) * fps_X^n + fps_cutoff n (f * inverse h))"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1247
        by (subst g_decomp) (simp add: algebra_simps)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1248
      also have "... = f * (inverse h * h)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1249
        by (subst fps_shift_cutoff) simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1250
      also have "inverse h * h = 1" by (rule inverse_mult_eq_1) (simp add: h_def n_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1251
      finally show ?thesis by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1252
    qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1253
  qed (auto simp: fps_mod_def fps_divide_def Let_def)
64592
7759f1766189 more fine-grained type class hierarchy for div and mod
haftmann
parents: 64272
diff changeset
  1254
qed
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1255
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1256
end
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1257
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1258
lemma subdegree_mod:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1259
  assumes "f \<noteq> 0" "subdegree f < subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1260
  shows   "subdegree (f mod g) = subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1261
proof (cases "f div g * g = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1262
  assume "f div g * g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1263
  hence [simp]: "f div g \<noteq> 0" "g \<noteq> 0" by auto
64242
93c6f0da5c70 more standardized theorem names for facts involving the div and mod identity
haftmann
parents: 64240
diff changeset
  1264
  from div_mult_mod_eq[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1265
  also from assms have "subdegree ... = subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1266
    by (intro subdegree_diff_eq1) simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1267
  finally show ?thesis .
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1268
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1269
  assume zero: "f div g * g = 0"
64242
93c6f0da5c70 more standardized theorem names for facts involving the div and mod identity
haftmann
parents: 64240
diff changeset
  1270
  from div_mult_mod_eq[of f g] have "f mod g = f - f div g * g" by (simp add: algebra_simps)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1271
  also note zero
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1272
  finally show ?thesis by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1273
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1274
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1275
lemma fps_divide_nth_0 [simp]: "g $ 0 \<noteq> 0 \<Longrightarrow> (f div g) $ 0 = f $ 0 / (g $ 0 :: _ :: field)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1276
  by (simp add: fps_divide_unit divide_inverse)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1277
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1278
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1279
lemma dvd_imp_subdegree_le:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1280
  "(f :: 'a :: idom fps) dvd g \<Longrightarrow> g \<noteq> 0 \<Longrightarrow> subdegree f \<le> subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1281
  by (auto elim: dvdE)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1282
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1283
lemma fps_dvd_iff:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1284
  assumes "(f :: 'a :: field fps) \<noteq> 0" "g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1285
  shows   "f dvd g \<longleftrightarrow> subdegree f \<le> subdegree g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1286
proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1287
  assume "subdegree f \<le> subdegree g"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1288
  with assms have "g mod f = 0"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1289
    by (simp add: fps_mod_def Let_def fps_cutoff_zero_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1290
  thus "f dvd g" by (simp add: dvd_eq_mod_eq_0)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1291
qed (simp add: assms dvd_imp_subdegree_le)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1292
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1293
lemma fps_shift_altdef:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1294
  "fps_shift n f = (f :: 'a :: field fps) div fps_X^n"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1295
  by (simp add: fps_divide_def)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1296
  
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1297
lemma fps_div_fps_X_power_nth: "((f :: 'a :: field fps) div fps_X^n) $ k = f $ (k + n)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1298
  by (simp add: fps_shift_altdef [symmetric])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1299
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1300
lemma fps_div_fps_X_nth: "((f :: 'a :: field fps) div fps_X) $ k = f $ Suc k"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1301
  using fps_div_fps_X_power_nth[of f 1] by simp
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1302
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1303
lemma fps_const_inverse: "inverse (fps_const (a::'a::field)) = fps_const (inverse a)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1304
  by (cases "a \<noteq> 0", rule fps_inverse_unique) (auto simp: fps_eq_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1305
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1306
lemma fps_const_divide: "fps_const (x :: _ :: field) / fps_const y = fps_const (x / y)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1307
  by (cases "y = 0") (simp_all add: fps_divide_unit fps_const_inverse divide_inverse)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1308
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1309
lemma inverse_fps_numeral:
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1310
  "inverse (numeral n :: ('a :: field_char_0) fps) = fps_const (inverse (numeral n))"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1311
  by (intro fps_inverse_unique fps_ext) (simp_all add: fps_numeral_nth)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1312
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1313
lemma fps_numeral_divide_divide:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1314
  "x / numeral b / numeral c = (x / numeral (b * c) :: 'a :: field fps)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1315
  by (cases "numeral b = (0::'a)"; cases "numeral c = (0::'a)")
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1316
      (simp_all add: fps_divide_unit fps_inverse_mult [symmetric] numeral_fps_const numeral_mult 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1317
                del: numeral_mult [symmetric])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1318
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1319
lemma fps_numeral_mult_divide:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1320
  "numeral b * x / numeral c = (numeral b / numeral c * x :: 'a :: field fps)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1321
  by (cases "numeral c = (0::'a)") (simp_all add: fps_divide_unit numeral_fps_const)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1322
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1323
lemmas fps_numeral_simps = 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1324
  fps_numeral_divide_divide fps_numeral_mult_divide inverse_fps_numeral neg_numeral_fps_const
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1325
66550
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1326
lemma subdegree_div:
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1327
  assumes "q dvd p"
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1328
  shows   "subdegree ((p :: 'a :: field fps) div q) = subdegree p - subdegree q"
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1329
proof (cases "p = 0")
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1330
  case False
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1331
  from assms have "p = p div q * q" by simp
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1332
  also from assms False have "subdegree \<dots> = subdegree (p div q) + subdegree q"
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1333
    by (intro subdegree_mult) (auto simp: dvd_div_eq_0_iff)
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1334
  finally show ?thesis by simp
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1335
qed simp_all
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1336
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1337
lemma subdegree_div_unit:
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1338
  assumes "q $ 0 \<noteq> 0"
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1339
  shows   "subdegree ((p :: 'a :: field fps) div q) = subdegree p"
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1340
  using assms by (subst subdegree_div) simp_all
e5d82cf3c387 Some small lemmas about polynomials and FPSs
eberlm <eberlm@in.tum.de>
parents: 66480
diff changeset
  1341
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1342
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1343
subsection \<open>Formal power series form a Euclidean ring\<close>
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1344
64784
5cb5e7ecb284 reshaped euclidean semiring into hierarchy of euclidean semirings culminating in uniquely determined euclidean divion
haftmann
parents: 64592
diff changeset
  1345
instantiation fps :: (field) euclidean_ring_cancel
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1346
begin
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1347
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1348
definition fps_euclidean_size_def:
62422
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1349
  "euclidean_size f = (if f = 0 then 0 else 2 ^ subdegree f)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1350
66806
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1351
context
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1352
begin
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1353
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1354
private lemma fps_divide_cancel_aux1:
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1355
  assumes "h$0 \<noteq> (0 :: 'a :: field)"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1356
  shows   "(h * f) div (h * g) = f div g"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1357
proof (cases "g = 0")
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1358
  assume "g \<noteq> 0"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1359
  from assms have "h \<noteq> 0" by auto
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1360
  note nz [simp] = \<open>g \<noteq> 0\<close> \<open>h \<noteq> 0\<close>
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1361
  from assms have [simp]: "subdegree h = 0" by (simp add: subdegree_eq_0_iff)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1362
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1363
  have "(h * f) div (h * g) =
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1364
          fps_shift (subdegree g) (h * f * inverse (fps_shift (subdegree g) (h*g)))"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1365
    by (simp add: fps_divide_def Let_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1366
  also have "h * f * inverse (fps_shift (subdegree g) (h*g)) =
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1367
               (inverse h * h) * f * inverse (fps_shift (subdegree g) g)"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1368
    by (subst fps_shift_mult) (simp_all add: algebra_simps fps_inverse_mult)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1369
  also from assms have "inverse h * h = 1" by (rule inverse_mult_eq_1)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1370
  finally show "(h * f) div (h * g) = f div g" by (simp_all add: fps_divide_def Let_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1371
qed (simp_all add: fps_divide_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1372
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1373
private lemma fps_divide_cancel_aux2:
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1374
  "(f * fps_X^m) div (g * fps_X^m) = f div (g :: 'a :: field fps)"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1375
proof (cases "g = 0")
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1376
  assume [simp]: "g \<noteq> 0"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1377
  have "(f * fps_X^m) div (g * fps_X^m) =
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1378
          fps_shift (subdegree g + m) (f*inverse (fps_shift (subdegree g + m) (g*fps_X^m))*fps_X^m)"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1379
    by (simp add: fps_divide_def Let_def algebra_simps)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1380
  also have "... = f div g"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1381
    by (simp add: fps_shift_times_fps_X_power'' fps_divide_def Let_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1382
  finally show ?thesis .
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1383
qed (simp_all add: fps_divide_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1384
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1385
instance proof
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1386
  fix f g :: "'a fps" assume [simp]: "g \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1387
  show "euclidean_size f \<le> euclidean_size (f * g)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1388
    by (cases "f = 0") (auto simp: fps_euclidean_size_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1389
  show "euclidean_size (f mod g) < euclidean_size g"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1390
    apply (cases "f = 0", simp add: fps_euclidean_size_def)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1391
    apply (rule disjE[OF le_less_linear[of "subdegree g" "subdegree f"]])
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1392
    apply (simp_all add: fps_mod_eq_zero fps_euclidean_size_def subdegree_mod)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1393
    done
66806
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1394
  show "(h * f) div (h * g) = f div g" if "h \<noteq> 0"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1395
    for f g h :: "'a fps"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1396
  proof -
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1397
    define m where "m = subdegree h"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1398
    define h' where "h' = fps_shift m h"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1399
    have h_decomp: "h = h' * fps_X ^ m" unfolding h'_def m_def by (rule subdegree_decompose)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1400
    from \<open>h \<noteq> 0\<close> have [simp]: "h'$0 \<noteq> 0" by (simp add: h'_def m_def)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1401
    have "(h * f) div (h * g) = (h' * f * fps_X^m) div (h' * g * fps_X^m)"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1402
      by (simp add: h_decomp algebra_simps)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1403
    also have "... = f div g"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1404
      by (simp add: fps_divide_cancel_aux1 fps_divide_cancel_aux2)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1405
    finally show ?thesis .
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1406
  qed
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1407
  show "(f + g * h) div h = g + f div h"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1408
    if "h \<noteq> 0" for f g h :: "'a fps"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1409
  proof -
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1410
    define n h' where dfs: "n = subdegree h" "h' = fps_shift n h"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1411
    have "(f + g * h) div h = fps_shift n (f * inverse h') + fps_shift n (g * (h * inverse h'))"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1412
      by (simp add: fps_divide_def Let_def dfs [symmetric] algebra_simps fps_shift_add that)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1413
    also have "h * inverse h' = (inverse h' * h') * fps_X^n"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1414
      by (subst subdegree_decompose) (simp_all add: dfs)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1415
    also have "... = fps_X^n"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1416
      by (subst inverse_mult_eq_1) (simp_all add: dfs that)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1417
    also have "fps_shift n (g * fps_X^n) = g" by simp
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1418
    also have "fps_shift n (f * inverse h') = f div h"
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1419
      by (simp add: fps_divide_def Let_def dfs)
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1420
    finally show ?thesis by simp
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1421
  qed
62422
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1422
qed (simp_all add: fps_euclidean_size_def)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1423
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1424
end
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1425
66806
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1426
end
a4e82b58d833 abolished (semi)ring_div in favour of euclidean_(semi)ring_cancel
haftmann
parents: 66804
diff changeset
  1427
66817
0b12755ccbb2 euclidean rings need no normalization
haftmann
parents: 66806
diff changeset
  1428
instance fps :: (field) normalization_euclidean_semiring ..
0b12755ccbb2 euclidean rings need no normalization
haftmann
parents: 66806
diff changeset
  1429
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1430
instantiation fps :: (field) euclidean_ring_gcd
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1431
begin
64786
340db65fd2c1 reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
haftmann
parents: 64784
diff changeset
  1432
definition fps_gcd_def: "(gcd :: 'a fps \<Rightarrow> _) = Euclidean_Algorithm.gcd"
340db65fd2c1 reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
haftmann
parents: 64784
diff changeset
  1433
definition fps_lcm_def: "(lcm :: 'a fps \<Rightarrow> _) = Euclidean_Algorithm.lcm"
340db65fd2c1 reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
haftmann
parents: 64784
diff changeset
  1434
definition fps_Gcd_def: "(Gcd :: 'a fps set \<Rightarrow> _) = Euclidean_Algorithm.Gcd"
340db65fd2c1 reworked to provide auxiliary operations Euclidean_Algorithm.* to instantiate gcd etc. for euclidean rings
haftmann
parents: 64784
diff changeset
  1435
definition fps_Lcm_def: "(Lcm :: 'a fps set \<Rightarrow> _) = Euclidean_Algorithm.Lcm"
62422
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1436
instance by standard (simp_all add: fps_gcd_def fps_lcm_def fps_Gcd_def fps_Lcm_def)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1437
end
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1438
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1439
lemma fps_gcd:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1440
  assumes [simp]: "f \<noteq> 0" "g \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1441
  shows   "gcd f g = fps_X ^ min (subdegree f) (subdegree g)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1442
proof -
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1443
  let ?m = "min (subdegree f) (subdegree g)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1444
  show "gcd f g = fps_X ^ ?m"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1445
  proof (rule sym, rule gcdI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1446
    fix d assume "d dvd f" "d dvd g"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1447
    thus "d dvd fps_X ^ ?m" by (cases "d = 0") (auto simp: fps_dvd_iff)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1448
  qed (simp_all add: fps_dvd_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1449
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1450
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1451
lemma fps_gcd_altdef: "gcd (f :: 'a :: field fps) g =
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1452
  (if f = 0 \<and> g = 0 then 0 else
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1453
   if f = 0 then fps_X ^ subdegree g else
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1454
   if g = 0 then fps_X ^ subdegree f else
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1455
     fps_X ^ min (subdegree f) (subdegree g))"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1456
  by (simp add: fps_gcd)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1457
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1458
lemma fps_lcm:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1459
  assumes [simp]: "f \<noteq> 0" "g \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1460
  shows   "lcm f g = fps_X ^ max (subdegree f) (subdegree g)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1461
proof -
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1462
  let ?m = "max (subdegree f) (subdegree g)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1463
  show "lcm f g = fps_X ^ ?m"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1464
  proof (rule sym, rule lcmI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1465
    fix d assume "f dvd d" "g dvd d"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1466
    thus "fps_X ^ ?m dvd d" by (cases "d = 0") (auto simp: fps_dvd_iff)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1467
  qed (simp_all add: fps_dvd_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1468
qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1469
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1470
lemma fps_lcm_altdef: "lcm (f :: 'a :: field fps) g =
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1471
  (if f = 0 \<or> g = 0 then 0 else fps_X ^ max (subdegree f) (subdegree g))"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1472
  by (simp add: fps_lcm)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1473
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1474
lemma fps_Gcd:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1475
  assumes "A - {0} \<noteq> {}"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1476
  shows   "Gcd A = fps_X ^ (INF f:A-{0}. subdegree f)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1477
proof (rule sym, rule GcdI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1478
  fix f assume "f \<in> A"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1479
  thus "fps_X ^ (INF f:A - {0}. subdegree f) dvd f"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1480
    by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cINF_lower)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1481
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1482
  fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> d dvd f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1483
  from assms obtain f where "f \<in> A - {0}" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1484
  with d[of f] have [simp]: "d \<noteq> 0" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1485
  from d assms have "subdegree d \<le> (INF f:A-{0}. subdegree f)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1486
    by (intro cINF_greatest) (auto simp: fps_dvd_iff[symmetric])
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1487
  with d assms show "d dvd fps_X ^ (INF f:A-{0}. subdegree f)" by (simp add: fps_dvd_iff)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1488
qed simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1489
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1490
lemma fps_Gcd_altdef: "Gcd (A :: 'a :: field fps set) =
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1491
  (if A \<subseteq> {0} then 0 else fps_X ^ (INF f:A-{0}. subdegree f))"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1492
  using fps_Gcd by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1493
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1494
lemma fps_Lcm:
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1495
  assumes "A \<noteq> {}" "0 \<notin> A" "bdd_above (subdegree`A)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1496
  shows   "Lcm A = fps_X ^ (SUP f:A. subdegree f)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1497
proof (rule sym, rule LcmI)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1498
  fix f assume "f \<in> A"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1499
  moreover from assms(3) have "bdd_above (subdegree ` A)" by auto
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1500
  ultimately show "f dvd fps_X ^ (SUP f:A. subdegree f)" using assms(2)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1501
    by (cases "f = 0") (auto simp: fps_dvd_iff intro!: cSUP_upper)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1502
next
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1503
  fix d assume d: "\<And>f. f \<in> A \<Longrightarrow> f dvd d"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1504
  from assms obtain f where f: "f \<in> A" "f \<noteq> 0" by auto
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1505
  show "fps_X ^ (SUP f:A. subdegree f) dvd d"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1506
  proof (cases "d = 0")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1507
    assume "d \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1508
    moreover from d have "\<And>f. f \<in> A \<Longrightarrow> f \<noteq> 0 \<Longrightarrow> f dvd d" by blast
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1509
    ultimately have "subdegree d \<ge> (SUP f:A. subdegree f)" using assms
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1510
      by (intro cSUP_least) (auto simp: fps_dvd_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1511
    with \<open>d \<noteq> 0\<close> show ?thesis by (simp add: fps_dvd_iff)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1512
  qed simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1513
qed simp_all
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1514
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1515
lemma fps_Lcm_altdef:
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  1516
  "Lcm (A :: 'a :: field fps set) =
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1517
     (if 0 \<in> A \<or> \<not>bdd_above (subdegree`A) then 0 else
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1518
      if A = {} then 1 else fps_X ^ (SUP f:A. subdegree f))"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1519
proof (cases "bdd_above (subdegree`A)")
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1520
  assume unbounded: "\<not>bdd_above (subdegree`A)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1521
  have "Lcm A = 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1522
  proof (rule ccontr)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1523
    assume "Lcm A \<noteq> 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1524
    from unbounded obtain f where f: "f \<in> A" "subdegree (Lcm A) < subdegree f"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1525
      unfolding bdd_above_def by (auto simp: not_le)
63539
70d4d9e5707b tuned proofs -- avoid improper use of "this";
wenzelm
parents: 63417
diff changeset
  1526
    moreover from f and \<open>Lcm A \<noteq> 0\<close> have "subdegree f \<le> subdegree (Lcm A)"
62422
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1527
      by (intro dvd_imp_subdegree_le dvd_Lcm) simp_all
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1528
    ultimately show False by simp
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1529
  qed
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1530
  with unbounded show ?thesis by simp
62422
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1531
qed (simp_all add: fps_Lcm Lcm_eq_0_I)
4aa35fd6c152 Tuned Euclidean rings
eberlm
parents: 62390
diff changeset
  1532
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1533
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1534
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1535
subsection \<open>Formal Derivatives, and the MacLaurin theorem around 0\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1536
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1537
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
  1538
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1539
lemma fps_deriv_nth[simp]: "fps_deriv f $ n = of_nat (n +1) * f $ (n + 1)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1540
  by (simp add: fps_deriv_def)
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1541
65398
eberlm <eberlm@in.tum.de>
parents: 65396
diff changeset
  1542
lemma fps_0th_higher_deriv: 
eberlm <eberlm@in.tum.de>
parents: 65396
diff changeset
  1543
  "(fps_deriv ^^ n) f $ 0 = (fact n * f $ n :: 'a :: {comm_ring_1, semiring_char_0})"
eberlm <eberlm@in.tum.de>
parents: 65396
diff changeset
  1544
  by (induction n arbitrary: f) (simp_all del: funpow.simps add: funpow_Suc_right algebra_simps)
eberlm <eberlm@in.tum.de>
parents: 65396
diff changeset
  1545
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1546
lemma fps_deriv_linear[simp]:
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1547
  "fps_deriv (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) =
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1548
    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
  1549
  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
  1550
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1551
lemma fps_deriv_mult[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1552
  fixes f :: "'a::comm_ring_1 fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1553
  shows "fps_deriv (f * g) = f * fps_deriv g + fps_deriv f * g"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1554
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1555
  let ?D = "fps_deriv"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1556
  have "(f * ?D g + ?D f * g) $ n = ?D (f*g) $ n" for n
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1557
  proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1558
    let ?Zn = "{0 ..n}"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1559
    let ?Zn1 = "{0 .. n + 1}"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1560
    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
  1561
        of_nat (i+1)* f $ (i+1) * g $ (n - i)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1562
    let ?h = "\<lambda>i. of_nat i * g $ i * f $ ((n+1) - i) +
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1563
        of_nat i* f $ i * g $ ((n + 1) - i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1564
    have s0: "sum (\<lambda>i. of_nat i * f $ i * g $ (n + 1 - i)) ?Zn1 =
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1565
      sum (\<lambda>i. of_nat (n + 1 - i) * f $ (n + 1 - i) * g $ i) ?Zn1"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1566
       by (rule sum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1567
    have s1: "sum (\<lambda>i. f $ i * g $ (n + 1 - i)) ?Zn1 =
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1568
      sum (\<lambda>i. f $ (n + 1 - i) * g $ i) ?Zn1"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1569
       by (rule sum.reindex_bij_witness[where i="op - (n + 1)" and j="op - (n + 1)"]) auto
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1570
    have "(f * ?D g + ?D f * g)$n = (?D g * f + ?D f * g)$n"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  1571
      by (simp only: mult.commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1572
    also have "\<dots> = (\<Sum>i = 0..n. ?g i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1573
      by (simp add: fps_mult_nth sum.distrib[symmetric])
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1574
    also have "\<dots> = sum ?h {0..n+1}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1575
      by (rule sum.reindex_bij_witness_not_neutral
57129
7edb7550663e introduce more powerful reindexing rules for big operators
hoelzl
parents: 56480
diff changeset
  1576
            [where S'="{}" and T'="{0}" and j="Suc" and i="\<lambda>i. i - 1"]) auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1577
    also have "\<dots> = (fps_deriv (f * g)) $ n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1578
      apply (simp only: fps_deriv_nth fps_mult_nth sum.distrib)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1579
      unfolding s0 s1
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1580
      unfolding sum.distrib[symmetric] sum_distrib_left
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1581
      apply (rule sum.cong)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1582
      apply (auto simp add: of_nat_diff field_simps)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1583
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1584
    finally show ?thesis .
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1585
  qed
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1586
  then show ?thesis
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  1587
    unfolding fps_eq_iff by auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1588
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1589
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1590
lemma fps_deriv_fps_X[simp]: "fps_deriv fps_X = 1"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1591
  by (simp add: fps_deriv_def fps_X_def fps_eq_iff)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
  1592
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1593
lemma fps_deriv_neg[simp]:
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1594
  "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
  1595
  by (simp add: fps_eq_iff fps_deriv_def)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1596
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1597
lemma fps_deriv_add[simp]:
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1598
  "fps_deriv ((f:: 'a::comm_ring_1 fps) + g) = fps_deriv f + fps_deriv g"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1599
  using fps_deriv_linear[of 1 f 1 g] by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1600
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1601
lemma fps_deriv_sub[simp]:
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1602
  "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
  1603
  using fps_deriv_add [of f "- g"] by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1604
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1605
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
  1606
  by (simp add: fps_ext fps_deriv_def fps_const_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1607
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1608
lemma fps_deriv_of_nat [simp]: "fps_deriv (of_nat n) = 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1609
  by (simp add: fps_of_nat [symmetric])
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1610
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1611
lemma fps_deriv_numeral [simp]: "fps_deriv (numeral n) = 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1612
  by (simp add: numeral_fps_const)    
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  1613
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1614
lemma fps_deriv_mult_const_left[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1615
  "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
  1616
  by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1617
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1618
lemma fps_deriv_0[simp]: "fps_deriv 0 = 0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1619
  by (simp add: fps_deriv_def fps_eq_iff)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1620
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1621
lemma fps_deriv_1[simp]: "fps_deriv 1 = 0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1622
  by (simp add: fps_deriv_def fps_eq_iff )
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1623
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1624
lemma fps_deriv_mult_const_right[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1625
  "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
  1626
  by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1627
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1628
lemma fps_deriv_sum:
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1629
  "fps_deriv (sum f S) = sum (\<lambda>i. fps_deriv (f i :: 'a::comm_ring_1 fps)) S"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1630
proof (cases "finite S")
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1631
  case False
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 True
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1635
  show ?thesis by (induct rule: finite_induct [OF True]) simp_all
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1636
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1637
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1638
lemma fps_deriv_eq_0_iff [simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1639
  "fps_deriv f = 0 \<longleftrightarrow> f = fps_const (f$0 :: 'a::{idom,semiring_char_0})"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1640
  (is "?lhs \<longleftrightarrow> ?rhs")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1641
proof
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1642
  show ?lhs if ?rhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1643
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1644
    from that have "fps_deriv f = fps_deriv (fps_const (f$0))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1645
      by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1646
    then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1647
      by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1648
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1649
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1650
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1651
    from that have "\<forall>n. (fps_deriv f)$n = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1652
      by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1653
    then have "\<forall>n. f$(n+1) = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1654
      by (simp del: of_nat_Suc of_nat_add One_nat_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1655
    then show ?thesis
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1656
      apply (clarsimp simp add: fps_eq_iff fps_const_def)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1657
      apply (erule_tac x="n - 1" in allE)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1658
      apply simp
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1659
      done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1660
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1661
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1662
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1663
lemma fps_deriv_eq_iff:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1664
  fixes f :: "'a::{idom,semiring_char_0} fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1665
  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
  1666
proof -
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1667
  have "fps_deriv f = fps_deriv g \<longleftrightarrow> fps_deriv (f - g) = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1668
    by simp
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1669
  also have "\<dots> \<longleftrightarrow> f - g = fps_const ((f - g) $ 0)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1670
    unfolding fps_deriv_eq_0_iff ..
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1671
  finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1672
    by (simp add: field_simps)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1673
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1674
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1675
lemma fps_deriv_eq_iff_ex:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1676
  "(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
  1677
  by (auto simp: fps_deriv_eq_iff)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1678
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1679
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1680
fun fps_nth_deriv :: "nat \<Rightarrow> 'a::semiring_1 fps \<Rightarrow> 'a fps"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1681
where
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1682
  "fps_nth_deriv 0 f = f"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1683
| "fps_nth_deriv (Suc n) f = fps_nth_deriv n (fps_deriv f)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1684
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1685
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
  1686
  by (induct n arbitrary: f) auto
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1687
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1688
lemma fps_nth_deriv_linear[simp]:
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1689
  "fps_nth_deriv n (fps_const (a::'a::comm_semiring_1) * f + fps_const b * g) =
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1690
    fps_const a * fps_nth_deriv n f + fps_const b * fps_nth_deriv n g"
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1691
  by (induct n arbitrary: f g) (auto simp add: fps_nth_deriv_commute)
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1692
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1693
lemma fps_nth_deriv_neg[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1694
  "fps_nth_deriv n (- (f :: 'a::comm_ring_1 fps)) = - (fps_nth_deriv n f)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1695
  by (induct n arbitrary: f) simp_all
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1696
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1697
lemma fps_nth_deriv_add[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1698
  "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
  1699
  using fps_nth_deriv_linear[of n 1 f 1 g] by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1700
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1701
lemma fps_nth_deriv_sub[simp]:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1702
  "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
  1703
  using fps_nth_deriv_add [of n f "- g"] by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1704
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1705
lemma fps_nth_deriv_0[simp]: "fps_nth_deriv n 0 = 0"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1706
  by (induct n) simp_all
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1707
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1708
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
  1709
  by (induct n) simp_all
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1710
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1711
lemma fps_nth_deriv_const[simp]:
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1712
  "fps_nth_deriv n (fps_const c) = (if n = 0 then fps_const c else 0)"
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1713
  by (cases n) simp_all
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1714
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1715
lemma fps_nth_deriv_mult_const_left[simp]:
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1716
  "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
  1717
  using fps_nth_deriv_linear[of n "c" f 0 0 ] by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1718
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1719
lemma fps_nth_deriv_mult_const_right[simp]:
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1720
  "fps_nth_deriv n (f * fps_const (c::'a::comm_ring_1)) = fps_nth_deriv n f * fps_const c"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  1721
  using fps_nth_deriv_linear[of n "c" f 0 0] by (simp add: mult.commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1722
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1723
lemma fps_nth_deriv_sum:
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1724
  "fps_nth_deriv n (sum f S) = sum (\<lambda>i. fps_nth_deriv n (f i :: 'a::comm_ring_1 fps)) S"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1725
proof (cases "finite S")
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1726
  case True
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1727
  show ?thesis by (induct rule: finite_induct [OF True]) simp_all
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1728
next
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1729
  case False
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1730
  then show ?thesis by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1731
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1732
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1733
lemma fps_deriv_maclauren_0:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1734
  "(fps_nth_deriv k (f :: 'a::comm_semiring_1 fps)) $ 0 = of_nat (fact k) * f $ k"
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  1735
  by (induct k arbitrary: f) (auto simp add: field_simps)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1736
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1737
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1738
subsection \<open>Powers\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1739
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1740
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
  1741
  by (induct n) (auto simp add: expand_fps_eq fps_mult_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1742
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1743
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
  1744
proof (induct n)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1745
  case 0
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1746
  then show ?case by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1747
next
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1748
  case (Suc n)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1749
  show ?case unfolding power_Suc fps_mult_nth
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1750
    using Suc.hyps[OF \<open>a$0 = 1\<close>] \<open>a$0 = 1\<close> fps_power_zeroth_eq_one[OF \<open>a$0=1\<close>]
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1751
    by (simp add: field_simps)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1752
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1753
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1754
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
  1755
  by (induct n) (auto simp add: fps_mult_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1756
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1757
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
  1758
  by (induct n) (auto simp add: fps_mult_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1759
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1760
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
  1761
  by (induct n) (auto simp add: fps_mult_nth)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1762
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1763
lemma startsby_zero_power_iff[simp]: "a^n $0 = (0::'a::idom) \<longleftrightarrow> n \<noteq> 0 \<and> a$0 = 0"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1764
  apply (rule iffI)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1765
  apply (induct n)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1766
  apply (auto simp add: fps_mult_nth)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1767
  apply (rule startsby_zero_power, simp_all)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1768
  done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1769
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1770
lemma startsby_zero_power_prefix:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1771
  assumes a0: "a $ 0 = (0::'a::idom)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1772
  shows "\<forall>n < k. a ^ k $ n = 0"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1773
  using a0
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1774
proof (induct k rule: nat_less_induct)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1775
  fix k
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1776
  assume H: "\<forall>m<k. a $0 =  0 \<longrightarrow> (\<forall>n<m. a ^ m $ n = 0)" and a0: "a $ 0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1777
  show "\<forall>m<k. a ^ k $ m = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1778
  proof (cases k)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1779
    case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1780
    then show ?thesis by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1781
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1782
    case (Suc l)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1783
    have "a^k $ m = 0" if mk: "m < k" for m
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1784
    proof (cases "m = 0")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1785
      case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1786
      then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1787
        using startsby_zero_power[of a k] Suc a0 by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1788
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1789
      case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1790
      have "a ^k $ m = (a^l * a) $m"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1791
        by (simp add: Suc mult.commute)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1792
      also have "\<dots> = (\<Sum>i = 0..m. a ^ l $ i * a $ (m - i))"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1793
        by (simp add: fps_mult_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1794
      also have "\<dots> = 0"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1795
        apply (rule sum.neutral)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1796
        apply auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1797
        apply (case_tac "x = m")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1798
        using a0 apply simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1799
        apply (rule H[rule_format])
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1800
        using a0 Suc mk apply auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1801
        done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1802
      finally show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1803
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1804
    then show ?thesis by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1805
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1806
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1807
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1808
lemma startsby_zero_sum_depends:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1809
  assumes a0: "a $0 = (0::'a::idom)"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1810
    and kn: "n \<ge> k"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1811
  shows "sum (\<lambda>i. (a ^ i)$k) {0 .. n} = sum (\<lambda>i. (a ^ i)$k) {0 .. k}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1812
  apply (rule sum.mono_neutral_right)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1813
  using kn
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1814
  apply auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1815
  apply (rule startsby_zero_power_prefix[rule_format, OF a0])
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1816
  apply arith
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1817
  done
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1818
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1819
lemma startsby_zero_power_nth_same:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1820
  assumes a0: "a$0 = (0::'a::idom)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1821
  shows "a^n $ n = (a$1) ^ n"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1822
proof (induct n)
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1823
  case 0
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1824
  then show ?case by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1825
next
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1826
  case (Suc n)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1827
  have "a ^ Suc n $ (Suc n) = (a^n * a)$(Suc n)"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1828
    by (simp add: field_simps)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1829
  also have "\<dots> = sum (\<lambda>i. a^n$i * a $ (Suc n - i)) {0.. Suc n}"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1830
    by (simp add: fps_mult_nth)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1831
  also have "\<dots> = sum (\<lambda>i. a^n$i * a $ (Suc n - i)) {n .. Suc n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1832
    apply (rule sum.mono_neutral_right)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1833
    apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1834
    apply clarsimp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1835
    apply clarsimp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1836
    apply (rule startsby_zero_power_prefix[rule_format, OF a0])
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1837
    apply arith
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1838
    done
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1839
  also have "\<dots> = a^n $ n * a$1"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1840
    using a0 by simp
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1841
  finally show ?case
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1842
    using Suc.hyps by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1843
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1844
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1845
lemma fps_inverse_power:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1846
  fixes a :: "'a::field fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1847
  shows "inverse (a^n) = inverse a ^ n"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1848
  by (induction n) (simp_all add: fps_inverse_mult)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1849
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1850
lemma fps_deriv_power:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1851
  "fps_deriv (a ^ n) = fps_const (of_nat n :: 'a::comm_ring_1) * fps_deriv a * a ^ (n - 1)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1852
  apply (induct n)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1853
  apply (auto simp add: field_simps fps_const_add[symmetric] simp del: fps_const_add)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1854
  apply (case_tac n)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  1855
  apply (auto simp add: field_simps)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1856
  done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1857
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1858
lemma fps_inverse_deriv:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1859
  fixes a :: "'a::field fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1860
  assumes a0: "a$0 \<noteq> 0"
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  1861
  shows "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1862
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1863
  from inverse_mult_eq_1[OF a0]
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1864
  have "fps_deriv (inverse a * a) = 0" by simp
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  1865
  then have "inverse a * fps_deriv a + fps_deriv (inverse a) * a = 0"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  1866
    by simp
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  1867
  then have "inverse a * (inverse a * fps_deriv a + fps_deriv (inverse a) * a) = 0"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  1868
    by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1869
  with inverse_mult_eq_1[OF a0]
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  1870
  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
  1871
    unfolding power2_eq_square
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  1872
    apply (simp add: field_simps)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  1873
    apply (simp add: mult.assoc[symmetric])
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1874
    done
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  1875
  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
  1876
      0 - fps_deriv a * (inverse a)\<^sup>2"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1877
    by simp
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  1878
  then show "fps_deriv (inverse a) = - fps_deriv a * (inverse a)\<^sup>2"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1879
    by (simp add: field_simps)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1880
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1881
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1882
lemma fps_inverse_deriv':
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1883
  fixes a :: "'a::field fps"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1884
  assumes a0: "a $ 0 \<noteq> 0"
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  1885
  shows "fps_deriv (inverse a) = - fps_deriv a / a\<^sup>2"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1886
  using fps_inverse_deriv[OF a0] a0
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1887
  by (simp add: fps_divide_unit power2_eq_square fps_inverse_mult)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1888
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1889
lemma inverse_mult_eq_1':
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1890
  assumes f0: "f$0 \<noteq> (0::'a::field)"
60567
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
  1891
  shows "f * inverse f = 1"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  1892
  by (metis mult.commute inverse_mult_eq_1 f0)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1893
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1894
lemma fps_inverse_minus [simp]: "inverse (-f) = -inverse (f :: 'a :: field fps)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1895
  by (cases "f$0 = 0") (auto intro: fps_inverse_unique simp: inverse_mult_eq_1' fps_inverse_eq_0)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1896
  
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1897
lemma divide_fps_const [simp]: "f / fps_const (c :: 'a :: field) = fps_const (inverse c) * f"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1898
  by (cases "c = 0") (simp_all add: fps_divide_unit fps_const_inverse)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1899
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1900
(* FIfps_XME: The last part of this proof should go through by simp once we have a proper
61804
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1901
   theorem collection for simplifying division on rings *)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1902
lemma fps_divide_deriv:
61804
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1903
  assumes "b dvd (a :: 'a :: field fps)"
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1904
  shows   "fps_deriv (a / b) = (fps_deriv a * b - a * fps_deriv b) / b^2"
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1905
proof -
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1906
  have eq_divide_imp: "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b div c" for a b c :: "'a :: field fps"
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1907
    by (drule sym) (simp add: mult.assoc)
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1908
  from assms have "a = a / b * b" by simp
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1909
  also have "fps_deriv (a / b * b) = fps_deriv (a / b) * b + a / b * fps_deriv b" by simp
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1910
  finally have "fps_deriv (a / b) * b^2 = fps_deriv a * b - a * fps_deriv b" using assms
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1911
    by (simp add: power2_eq_square algebra_simps)
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1912
  thus ?thesis by (cases "b = 0") (auto simp: eq_divide_imp)
67381557cee8 Generalised derivative rule for division on formal power series
eberlm
parents: 61799
diff changeset
  1913
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1914
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1915
lemma fps_inverse_gp': "inverse (Abs_fps (\<lambda>n. 1::'a::field)) = 1 - fps_X"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1916
  by (simp add: fps_inverse_gp fps_eq_iff fps_X_def)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1917
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1918
lemma fps_one_over_one_minus_fps_X_squared:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1919
  "inverse ((1 - fps_X)^2 :: 'a :: field fps) = Abs_fps (\<lambda>n. of_nat (n+1))"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1920
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1921
  have "inverse ((1 - fps_X)^2 :: 'a fps) = fps_deriv (inverse (1 - fps_X))"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1922
    by (subst fps_inverse_deriv) (simp_all add: fps_inverse_power)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1923
  also have "inverse (1 - fps_X :: 'a fps) = Abs_fps (\<lambda>_. 1)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1924
    by (subst fps_inverse_gp' [symmetric]) simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1925
  also have "fps_deriv \<dots> = Abs_fps (\<lambda>n. of_nat (n + 1))"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1926
    by (simp add: fps_deriv_def)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1927
  finally show ?thesis .
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1928
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  1929
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1930
lemma fps_nth_deriv_fps_X[simp]: "fps_nth_deriv n fps_X = (if n = 0 then fps_X else if n=1 then 1 else 0)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  1931
  by (cases n) simp_all
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1932
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1933
lemma fps_inverse_fps_X_plus1: "inverse (1 + fps_X) = Abs_fps (\<lambda>n. (- (1::'a::field)) ^ n)"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1934
  (is "_ = ?r")
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1935
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1936
  have eq: "(1 + fps_X) * ?r = 1"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1937
    unfolding minus_one_power_iff
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  1938
    by (auto simp add: field_simps fps_eq_iff)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1939
  show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1940
    by (auto simp add: eq intro: fps_inverse_unique)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1941
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1942
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1943
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1944
subsection \<open>Integration\<close>
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  1945
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1946
definition fps_integral :: "'a::field_char_0 fps \<Rightarrow> 'a \<Rightarrow> 'a fps"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  1947
  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
  1948
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  1949
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
  1950
  unfolding fps_integral_def fps_deriv_def
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  1951
  by (simp add: fps_eq_iff del: of_nat_Suc)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1952
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  1953
lemma fps_integral_linear:
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  1954
  "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
  1955
    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
  1956
  (is "?l = ?r")
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1957
proof -
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1958
  have "fps_deriv ?l = fps_deriv ?r"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1959
    by (simp add: fps_deriv_fps_integral)
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1960
  moreover have "?l$0 = ?r$0"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1961
    by (simp add: fps_integral_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1962
  ultimately show ?thesis
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1963
    unfolding fps_deriv_eq_iff by auto
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1964
qed
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1965
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1966
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1967
subsection \<open>Composition of FPSs\<close>
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  1968
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1969
definition fps_compose :: "'a::semiring_1 fps \<Rightarrow> 'a fps \<Rightarrow> 'a fps"  (infixl "oo" 55)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1970
  where "a oo b = Abs_fps (\<lambda>n. sum (\<lambda>i. a$i * (b^i$n)) {0..n})"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1971
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1972
lemma fps_compose_nth: "(a oo b)$n = sum (\<lambda>i. a$i * (b^i$n)) {0..n}"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  1973
  by (simp add: fps_compose_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1974
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1975
lemma fps_compose_nth_0 [simp]: "(f oo g) $ 0 = f $ 0"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1976
  by (simp add: fps_compose_nth)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  1977
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1978
lemma fps_compose_fps_X[simp]: "a oo fps_X = (a :: 'a::comm_ring_1 fps)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1979
  by (simp add: fps_ext fps_compose_def mult_delta_right sum.delta')
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1980
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  1981
lemma fps_const_compose[simp]: "fps_const (a::'a::comm_ring_1) oo b = fps_const a"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1982
  by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1983
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1984
lemma numeral_compose[simp]: "(numeral k :: 'a::comm_ring_1 fps) oo b = numeral k"
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
  1985
  unfolding numeral_fps_const by simp
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
  1986
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  1987
lemma neg_numeral_compose[simp]: "(- numeral k :: 'a::comm_ring_1 fps) oo b = - numeral k"
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
  1988
  unfolding neg_numeral_fps_const by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  1989
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  1990
lemma fps_X_fps_compose_startby0[simp]: "a$0 = 0 \<Longrightarrow> fps_X oo a = (a :: 'a::comm_ring_1 fps)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1991
  by (simp add: fps_eq_iff fps_compose_def mult_delta_left sum.delta not_le)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1992
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1993
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1994
subsection \<open>Rules from Herbert Wilf's Generatingfunctionology\<close>
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1995
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  1996
subsubsection \<open>Rule 1\<close>
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  1997
  (* {a_{n+k}}_0^infty Corresponds to (f - sum (\<lambda>i. a_i * x^i))/x^h, for h>0*)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  1998
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  1999
lemma fps_power_mult_eq_shift:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2000
  "fps_X^Suc k * Abs_fps (\<lambda>n. a (n + Suc k)) =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2001
    Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a::comm_ring_1) * fps_X^i) {0 .. k}"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2002
  (is "?lhs = ?rhs")
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2003
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2004
  have "?lhs $ n = ?rhs $ n" for n :: nat
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2005
  proof -
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2006
    have "?lhs $ n = (if n < Suc k then 0 else a n)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2007
      unfolding fps_X_power_mult_nth by auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2008
    also have "\<dots> = ?rhs $ n"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2009
    proof (induct k)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2010
      case 0
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2011
      then show ?case
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2012
        by (simp add: fps_sum_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2013
    next
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2014
      case (Suc k)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2015
      have "(Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a) * fps_X^i) {0 .. Suc k})$n =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2016
        (Abs_fps a - sum (\<lambda>i. fps_const (a i :: 'a) * fps_X^i) {0 .. k} -
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2017
          fps_const (a (Suc k)) * fps_X^ Suc k) $ n"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2018
        by (simp add: field_simps)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2019
      also have "\<dots> = (if n < Suc k then 0 else a n) - (fps_const (a (Suc k)) * fps_X^ Suc k)$n"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2020
        using Suc.hyps[symmetric] unfolding fps_sub_nth by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2021
      also have "\<dots> = (if n < Suc (Suc k) then 0 else a n)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2022
        unfolding fps_X_power_mult_right_nth
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2023
        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
  2024
        apply (rule cong[of a a, OF refl])
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2025
        apply arith
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2026
        done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2027
      finally show ?case
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2028
        by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2029
    qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2030
    finally show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2031
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2032
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2033
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2034
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2035
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2036
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  2037
subsubsection \<open>Rule 2\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2038
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2039
  (* 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
  2040
  (* If f reprents {a_n} and P is a polynomial, then
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2041
        P(xD) f represents {P(n) a_n}*)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2042
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2043
definition "fps_XD = op * fps_X \<circ> fps_deriv"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2044
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2045
lemma fps_XD_add[simp]:"fps_XD (a + b) = fps_XD a + fps_XD (b :: 'a::comm_ring_1 fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2046
  by (simp add: fps_XD_def field_simps)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2047
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2048
lemma fps_XD_mult_const[simp]:"fps_XD (fps_const (c::'a::comm_ring_1) * a) = fps_const c * fps_XD a"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2049
  by (simp add: fps_XD_def field_simps)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2050
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2051
lemma fps_XD_linear[simp]: "fps_XD (fps_const c * a + fps_const d * b) =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2052
    fps_const c * fps_XD a + fps_const d * fps_XD (b :: 'a::comm_ring_1 fps)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2053
  by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2054
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2055
lemma fps_XDN_linear:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2056
  "(fps_XD ^^ n) (fps_const c * a + fps_const d * b) =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2057
    fps_const c * (fps_XD ^^ n) a + fps_const d * (fps_XD ^^ n) (b :: 'a::comm_ring_1 fps)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2058
  by (induct n) simp_all
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2059
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2060
lemma fps_mult_fps_X_deriv_shift: "fps_X* fps_deriv a = Abs_fps (\<lambda>n. of_nat n* a$n)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2061
  by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2062
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2063
lemma fps_mult_fps_XD_shift:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2064
  "(fps_XD ^^ k) (a :: 'a::comm_ring_1 fps) = Abs_fps (\<lambda>n. (of_nat n ^ k) * a$n)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2065
  by (induct k arbitrary: a) (simp_all add: fps_XD_def fps_eq_iff field_simps del: One_nat_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2066
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2067
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2068
subsubsection \<open>Rule 3\<close>
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2069
61585
a9599d3d7610 isabelle update_cartouches -c -t;
wenzelm
parents: 61552
diff changeset
  2070
text \<open>Rule 3 is trivial and is given by \<open>fps_times_def\<close>.\<close>
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2071
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  2072
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2073
subsubsection \<open>Rule 5 --- summation and "division" by (1 - fps_X)\<close>
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2074
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2075
lemma fps_divide_fps_X_minus1_sum_lemma:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2076
  "a = ((1::'a::comm_ring_1 fps) - fps_X) * Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2077
proof -
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2078
  let ?sa = "Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2079
  have th0: "\<And>i. (1 - (fps_X::'a fps)) $ i = (if i = 0 then 1 else if i = 1 then - 1 else 0)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2080
    by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2081
  have "a$n = ((1 - fps_X) * ?sa) $ n" for n
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2082
  proof (cases "n = 0")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2083
    case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2084
    then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2085
      by (simp add: fps_mult_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2086
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2087
    case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2088
    then have u: "{0} \<union> ({1} \<union> {2..n}) = {0..n}" "{1} \<union> {2..n} = {1..n}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2089
      "{0..n - 1} \<union> {n} = {0..n}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2090
      by (auto simp: set_eq_iff)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2091
    have d: "{0} \<inter> ({1} \<union> {2..n}) = {}" "{1} \<inter> {2..n} = {}" "{0..n - 1} \<inter> {n} = {}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2092
      using False by simp_all
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2093
    have f: "finite {0}" "finite {1}" "finite {2 .. n}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2094
      "finite {0 .. n - 1}" "finite {n}" by simp_all
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2095
    have "((1 - fps_X) * ?sa) $ n = sum (\<lambda>i. (1 - fps_X)$ i * ?sa $ (n - i)) {0 .. n}"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2096
      by (simp add: fps_mult_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2097
    also have "\<dots> = a$n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2098
      unfolding th0
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2099
      unfolding sum.union_disjoint[OF f(1) finite_UnI[OF f(2,3)] d(1), unfolded u(1)]
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2100
      unfolding sum.union_disjoint[OF f(2) f(3) d(2)]
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2101
      apply (simp)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2102
      unfolding sum.union_disjoint[OF f(4,5) d(3), unfolded u(3)]
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2103
      apply simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2104
      done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2105
    finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2106
      by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2107
  qed
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2108
  then show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2109
    unfolding fps_eq_iff by blast
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2110
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2111
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2112
lemma fps_divide_fps_X_minus1_sum:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2113
  "a /((1::'a::field fps) - fps_X) = Abs_fps (\<lambda>n. sum (\<lambda>i. a $ i) {0..n})"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2114
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2115
  let ?fps_X = "1 - (fps_X::'a fps)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2116
  have th0: "?fps_X $ 0 \<noteq> 0"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2117
    by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2118
  have "a /?fps_X = ?fps_X *  Abs_fps (\<lambda>n::nat. sum (op $ a) {0..n}) * inverse ?fps_X"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2119
    using fps_divide_fps_X_minus1_sum_lemma[of a, symmetric] th0
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  2120
    by (simp add: fps_divide_def mult.assoc)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2121
  also have "\<dots> = (inverse ?fps_X * ?fps_X) * Abs_fps (\<lambda>n::nat. sum (op $ a) {0..n}) "
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  2122
    by (simp add: ac_simps)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2123
  finally show ?thesis
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2124
    by (simp add: inverse_mult_eq_1[OF th0])
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2125
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2126
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2127
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2128
subsubsection \<open>Rule 4 in its more general form: generalizes Rule 3 for an arbitrary
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  2129
  finite product of FPS, also the relvant instance of powers of a FPS\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2130
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2131
definition "natpermute n k = {l :: nat list. length l = k \<and> sum_list l = n}"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2132
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2133
lemma natlist_trivial_1: "natpermute n 1 = {[n]}"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2134
  apply (auto simp add: natpermute_def)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2135
  apply (case_tac x)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2136
  apply auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2137
  done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2138
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2139
lemma append_natpermute_less_eq:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2140
  assumes "xs @ ys \<in> natpermute n k"
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2141
  shows "sum_list xs \<le> n"
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2142
    and "sum_list ys \<le> n"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2143
proof -
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2144
  from assms have "sum_list (xs @ ys) = n"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2145
    by (simp add: natpermute_def)
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2146
  then have "sum_list xs + sum_list ys = n"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2147
    by simp
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2148
  then show "sum_list xs \<le> n" and "sum_list ys \<le> n"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2149
    by simp_all
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2150
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2151
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2152
lemma natpermute_split:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2153
  assumes "h \<le> k"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2154
  shows "natpermute n k =
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2155
    (\<Union>m \<in>{0..n}. {l1 @ l2 |l1 l2. l1 \<in> natpermute m h \<and> l2 \<in> natpermute (n - m) (k - h)})"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2156
  (is "?L = ?R" is "_ = (\<Union>m \<in>{0..n}. ?S m)")
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2157
proof
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2158
  show "?R \<subseteq> ?L"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2159
  proof
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2160
    fix l
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2161
    assume l: "l \<in> ?R"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2162
    from l obtain m xs ys where h: "m \<in> {0..n}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2163
      and xs: "xs \<in> natpermute m h"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2164
      and ys: "ys \<in> natpermute (n - m) (k - h)"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2165
      and leq: "l = xs@ys" by blast
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2166
    from xs have xs': "sum_list xs = m"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2167
      by (simp add: natpermute_def)
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2168
    from ys have ys': "sum_list ys = n - m"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2169
      by (simp add: natpermute_def)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2170
    show "l \<in> ?L" using leq xs ys h
46131
ab07a3ef821c prefer listsum over foldl plus 0
haftmann
parents: 44174
diff changeset
  2171
      apply (clarsimp simp add: natpermute_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2172
      unfolding xs' ys'
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2173
      using assms xs ys
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2174
      unfolding natpermute_def
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2175
      apply simp
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2176
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2177
  qed
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2178
  show "?L \<subseteq> ?R"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2179
  proof
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2180
    fix l
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2181
    assume l: "l \<in> natpermute n k"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2182
    let ?xs = "take h l"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2183
    let ?ys = "drop h l"
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2184
    let ?m = "sum_list ?xs"
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2185
    from l have ls: "sum_list (?xs @ ?ys) = n"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2186
      by (simp add: natpermute_def)
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2187
    have xs: "?xs \<in> natpermute ?m h" using l assms
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2188
      by (simp add: natpermute_def)
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2189
    have l_take_drop: "sum_list l = sum_list (take h l @ drop h l)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2190
      by simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2191
    then have ys: "?ys \<in> natpermute (n - ?m) (k - h)"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2192
      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
  2193
    from ls have m: "?m \<in> {0..n}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2194
      by (simp add: l_take_drop del: append_take_drop_id)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2195
    from xs ys ls show "l \<in> ?R"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2196
      apply auto
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2197
      apply (rule bexI [where x = "?m"])
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2198
      apply (rule exI [where x = "?xs"])
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2199
      apply (rule exI [where x = "?ys"])
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  2200
      using ls l
46131
ab07a3ef821c prefer listsum over foldl plus 0
haftmann
parents: 44174
diff changeset
  2201
      apply (auto simp add: natpermute_def l_take_drop simp del: append_take_drop_id)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2202
      apply simp
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2203
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2204
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2205
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2206
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2207
lemma natpermute_0: "natpermute n 0 = (if n = 0 then {[]} else {})"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2208
  by (auto simp add: natpermute_def)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2209
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2210
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
  2211
  apply (auto simp add: set_replicate_conv_if natpermute_def)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2212
  apply (rule nth_equalityI)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2213
  apply simp_all
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2214
  done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2215
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2216
lemma natpermute_finite: "finite (natpermute n k)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2217
proof (induct k arbitrary: n)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2218
  case 0
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2219
  then show ?case
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2220
    apply (subst natpermute_split[of 0 0, simplified])
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2221
    apply (simp add: natpermute_0)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2222
    done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2223
next
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2224
  case (Suc k)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2225
  then show ?case unfolding natpermute_split [of k "Suc k", simplified]
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2226
    apply -
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2227
    apply (rule finite_UN_I)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2228
    apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2229
    unfolding One_nat_def[symmetric] natlist_trivial_1
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2230
    apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2231
    done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2232
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2233
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2234
lemma natpermute_contain_maximal:
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2235
  "{xs \<in> natpermute n (k + 1). n \<in> set xs} = (\<Union>i\<in>{0 .. k}. {(replicate (k + 1) 0) [i:=n]})"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2236
  (is "?A = ?B")
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2237
proof
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2238
  show "?A \<subseteq> ?B"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2239
  proof
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2240
    fix xs
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2241
    assume "xs \<in> ?A"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2242
    then have H: "xs \<in> natpermute n (k + 1)" and n: "n \<in> set xs"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2243
      by blast+
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2244
    then obtain i where i: "i \<in> {0.. k}" "xs!i = n"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2245
      unfolding in_set_conv_nth by (auto simp add: less_Suc_eq_le natpermute_def)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2246
    have eqs: "({0..k} - {i}) \<union> {i} = {0..k}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2247
      using i by auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2248
    have f: "finite({0..k} - {i})" "finite {i}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2249
      by auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2250
    have d: "({0..k} - {i}) \<inter> {i} = {}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2251
      using i by auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2252
    from H have "n = sum (nth xs) {0..k}"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2253
      apply (simp add: natpermute_def)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2254
      apply (auto simp add: atLeastLessThanSuc_atLeastAtMost sum_list_sum_nth)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2255
      done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2256
    also have "\<dots> = n + sum (nth xs) ({0..k} - {i})"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2257
      unfolding sum.union_disjoint[OF f d, unfolded eqs] using i by simp
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2258
    finally have zxs: "\<forall> j\<in> {0..k} - {i}. xs!j = 0"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2259
      by auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2260
    from H have xsl: "length xs = k+1"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2261
      by (simp add: natpermute_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2262
    from i have i': "i < length (replicate (k+1) 0)"   "i < k+1"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2263
      unfolding length_replicate by presburger+
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2264
    have "xs = replicate (k+1) 0 [i := n]"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2265
      apply (rule nth_equalityI)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2266
      unfolding xsl length_list_update length_replicate
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2267
      apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2268
      apply clarify
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2269
      unfolding nth_list_update[OF i'(1)]
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2270
      using i zxs
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2271
      apply (case_tac "ia = i")
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2272
      apply (auto simp del: replicate.simps)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2273
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2274
    then show "xs \<in> ?B" using i by blast
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2275
  qed
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2276
  show "?B \<subseteq> ?A"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2277
  proof
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2278
    fix xs
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2279
    assume "xs \<in> ?B"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2280
    then obtain i where i: "i \<in> {0..k}" and xs: "xs = replicate (k + 1) 0 [i:=n]"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2281
      by auto
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2282
    have nxs: "n \<in> set xs"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2283
      unfolding xs
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2284
      apply (rule set_update_memI)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2285
      using i apply simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2286
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2287
    have xsl: "length xs = k + 1"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2288
      by (simp only: xs length_replicate length_list_update)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2289
    have "sum_list xs = sum (nth xs) {0..<k+1}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2290
      unfolding sum_list_sum_nth xsl ..
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2291
    also have "\<dots> = sum (\<lambda>j. if j = i then n else 0) {0..< k+1}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2292
      by (rule sum.cong) (simp_all add: xs del: replicate.simps)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2293
    also have "\<dots> = n" using i by (simp add: sum.delta)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2294
    finally have "xs \<in> natpermute n (k + 1)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2295
      using xsl unfolding natpermute_def mem_Collect_eq by blast
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2296
    then show "xs \<in> ?A"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2297
      using nxs by blast
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2298
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2299
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2300
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2301
text \<open>The general form.\<close>
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2302
lemma fps_prod_nth:
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2303
  fixes m :: nat
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2304
    and a :: "nat \<Rightarrow> 'a::comm_ring_1 fps"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2305
  shows "(prod a {0 .. m}) $ n =
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2306
    sum (\<lambda>v. prod (\<lambda>j. (a j) $ (v!j)) {0..m}) (natpermute n (m+1))"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2307
  (is "?P m n")
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2308
proof (induct m arbitrary: n rule: nat_less_induct)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2309
  fix m n assume H: "\<forall>m' < m. \<forall>n. ?P m' n"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2310
  show "?P m n"
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2311
  proof (cases m)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2312
    case 0
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2313
    then show ?thesis
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2314
      apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2315
      unfolding natlist_trivial_1[where n = n, unfolded One_nat_def]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2316
      apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2317
      done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2318
  next
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2319
    case (Suc k)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2320
    then have km: "k < m" by arith
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2321
    have u0: "{0 .. k} \<union> {m} = {0..m}"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2322
      using Suc by (simp add: set_eq_iff) presburger
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2323
    have f0: "finite {0 .. k}" "finite {m}" by auto
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2324
    have d0: "{0 .. k} \<inter> {m} = {}" using Suc by auto
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2325
    have "(prod a {0 .. m}) $ n = (prod a {0 .. k} * a m) $ n"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2326
      unfolding prod.union_disjoint[OF f0 d0, unfolded u0] by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2327
    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
  2328
      unfolding fps_mult_nth H[rule_format, OF km] ..
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2329
    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
  2330
      apply (simp add: Suc)
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2331
      unfolding natpermute_split[of m "m + 1", simplified, of n,
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2332
        unfolded natlist_trivial_1[unfolded One_nat_def] Suc]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2333
      apply (subst sum.UNION_disjoint)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2334
      apply simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2335
      apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2336
      unfolding image_Collect[symmetric]
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2337
      apply clarsimp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2338
      apply (rule finite_imageI)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2339
      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
  2340
      apply (clarsimp simp add: set_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2341
      apply auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2342
      apply (rule sum.cong)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 57129
diff changeset
  2343
      apply (rule refl)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2344
      unfolding sum_distrib_right
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2345
      apply (rule sym)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2346
      apply (rule_tac l = "\<lambda>xs. xs @ [n - x]" in sum.reindex_cong)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2347
      apply (simp add: inj_on_def)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2348
      apply auto
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2349
      unfolding prod.union_disjoint[OF f0 d0, unfolded u0, unfolded Suc]
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2350
      apply (clarsimp simp add: natpermute_def nth_append)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2351
      done
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2352
    finally show ?thesis .
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2353
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2354
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2355
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2356
text \<open>The special form for powers.\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2357
lemma fps_power_nth_Suc:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2358
  fixes m :: nat
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2359
    and a :: "'a::comm_ring_1 fps"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2360
  shows "(a ^ Suc m)$n = sum (\<lambda>v. prod (\<lambda>j. a $ (v!j)) {0..m}) (natpermute n (m+1))"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2361
proof -
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2362
  have th0: "a^Suc m = prod (\<lambda>i. a) {0..m}"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2363
    by (simp add: prod_constant)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2364
  show ?thesis unfolding th0 fps_prod_nth ..
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2365
qed
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2366
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2367
lemma fps_power_nth:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2368
  fixes m :: nat
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2369
    and a :: "'a::comm_ring_1 fps"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2370
  shows "(a ^m)$n =
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2371
    (if m=0 then 1$n else sum (\<lambda>v. prod (\<lambda>j. a $ (v!j)) {0..m - 1}) (natpermute n m))"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2372
  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
  2373
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2374
lemma fps_nth_power_0:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2375
  fixes m :: nat
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2376
    and a :: "'a::comm_ring_1 fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2377
  shows "(a ^m)$0 = (a$0) ^ m"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2378
proof (cases m)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2379
  case 0
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2380
  then show ?thesis by simp
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2381
next
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2382
  case (Suc n)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2383
  then have c: "m = card {0..n}" by simp
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2384
  have "(a ^m)$0 = prod (\<lambda>i. a$0) {0..n}"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2385
    by (simp add: Suc fps_power_nth del: replicate.simps power_Suc)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2386
  also have "\<dots> = (a$0) ^ m"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2387
   unfolding c by (rule prod_constant)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  2388
 finally show ?thesis .
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2389
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2390
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2391
lemma natpermute_max_card:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2392
  assumes n0: "n \<noteq> 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2393
  shows "card {xs \<in> natpermute n (k + 1). n \<in> set xs} = k + 1"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2394
  unfolding natpermute_contain_maximal
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2395
proof -
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2396
  let ?A = "\<lambda>i. {replicate (k + 1) 0[i := n]}"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2397
  let ?K = "{0 ..k}"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2398
  have fK: "finite ?K"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2399
    by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2400
  have fAK: "\<forall>i\<in>?K. finite (?A i)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2401
    by auto
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2402
  have d: "\<forall>i\<in> ?K. \<forall>j\<in> ?K. i \<noteq> j \<longrightarrow>
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2403
    {replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2404
  proof clarify
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2405
    fix i j
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2406
    assume i: "i \<in> ?K" and j: "j \<in> ?K" and ij: "i \<noteq> j"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2407
    have False if eq: "replicate (k+1) 0 [i:=n] = replicate (k+1) 0 [j:= n]"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2408
    proof -
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2409
      have "(replicate (k+1) 0 [i:=n] ! i) = n"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2410
        using i by (simp del: replicate.simps)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2411
      moreover
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2412
      have "(replicate (k+1) 0 [j:=n] ! i) = 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2413
        using i ij by (simp del: replicate.simps)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2414
      ultimately show ?thesis
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2415
        using eq n0 by (simp del: replicate.simps)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2416
    qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2417
    then show "{replicate (k + 1) 0[i := n]} \<inter> {replicate (k + 1) 0[j := n]} = {}"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2418
      by auto
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2419
  qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2420
  from card_UN_disjoint[OF fK fAK d]
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2421
  show "card (\<Union>i\<in>{0..k}. {replicate (k + 1) 0[i := n]}) = k + 1"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2422
    by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2423
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2424
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2425
lemma fps_power_Suc_nth:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2426
  fixes f :: "'a :: comm_ring_1 fps"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2427
  assumes k: "k > 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2428
  shows "(f ^ Suc m) $ k = 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2429
           of_nat (Suc m) * (f $ k * (f $ 0) ^ m) +
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2430
           (\<Sum>v\<in>{v\<in>natpermute k (m+1). k \<notin> set v}. \<Prod>j = 0..m. f $ v ! j)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2431
proof -
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2432
  define A B 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2433
    where "A = {v\<in>natpermute k (m+1). k \<in> set v}" 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2434
      and  "B = {v\<in>natpermute k (m+1). k \<notin> set v}"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2435
  have [simp]: "finite A" "finite B" "A \<inter> B = {}" by (auto simp: A_def B_def natpermute_finite)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2436
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2437
  from natpermute_max_card[of k m] k have card_A: "card A = m + 1" by (simp add: A_def)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2438
  {
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2439
    fix v assume v: "v \<in> A"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2440
    from v have [simp]: "length v = Suc m" by (simp add: A_def natpermute_def)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2441
    from v have "\<exists>j. j \<le> m \<and> v ! j = k" 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2442
      by (auto simp: set_conv_nth A_def natpermute_def less_Suc_eq_le)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2443
    then guess j by (elim exE conjE) note j = this
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2444
    
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2445
    from v have "k = sum_list v" by (simp add: A_def natpermute_def)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2446
    also have "\<dots> = (\<Sum>i=0..m. v ! i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2447
      by (simp add: sum_list_sum_nth atLeastLessThanSuc_atLeastAtMost del: sum_op_ivl_Suc)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2448
    also from j have "{0..m} = insert j ({0..m}-{j})" by auto
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2449
    also from j have "(\<Sum>i\<in>\<dots>. v ! i) = k + (\<Sum>i\<in>{0..m}-{j}. v ! i)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2450
      by (subst sum.insert) simp_all
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2451
    finally have "(\<Sum>i\<in>{0..m}-{j}. v ! i) = 0" by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2452
    hence zero: "v ! i = 0" if "i \<in> {0..m}-{j}" for i using that
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2453
      by (subst (asm) sum_eq_0_iff) auto
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2454
      
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2455
    from j have "{0..m} = insert j ({0..m} - {j})" by auto
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2456
    also from j have "(\<Prod>i\<in>\<dots>. f $ (v ! i)) = f $ k * (\<Prod>i\<in>{0..m} - {j}. f $ (v ! i))"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2457
      by (subst prod.insert) auto
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2458
    also have "(\<Prod>i\<in>{0..m} - {j}. f $ (v ! i)) = (\<Prod>i\<in>{0..m} - {j}. f $ 0)"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2459
      by (intro prod.cong) (simp_all add: zero)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2460
    also from j have "\<dots> = (f $ 0) ^ m" by (subst prod_constant) simp_all
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2461
    finally have "(\<Prod>j = 0..m. f $ (v ! j)) = f $ k * (f $ 0) ^ m" .
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2462
  } note A = this
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2463
  
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2464
  have "(f ^ Suc m) $ k = (\<Sum>v\<in>natpermute k (m + 1). \<Prod>j = 0..m. f $ v ! j)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2465
    by (rule fps_power_nth_Suc)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2466
  also have "natpermute k (m+1) = A \<union> B" unfolding A_def B_def by blast
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2467
  also have "(\<Sum>v\<in>\<dots>. \<Prod>j = 0..m. f $ (v ! j)) = 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2468
               (\<Sum>v\<in>A. \<Prod>j = 0..m. f $ (v ! j)) + (\<Sum>v\<in>B. \<Prod>j = 0..m. f $ (v ! j))"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2469
    by (intro sum.union_disjoint) simp_all   
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2470
  also have "(\<Sum>v\<in>A. \<Prod>j = 0..m. f $ (v ! j)) = of_nat (Suc m) * (f $ k * (f $ 0) ^ m)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2471
    by (simp add: A card_A)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2472
  finally show ?thesis by (simp add: B_def)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2473
qed 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2474
  
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2475
lemma fps_power_Suc_eqD:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2476
  fixes f g :: "'a :: {idom,semiring_char_0} fps"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2477
  assumes "f ^ Suc m = g ^ Suc m" "f $ 0 = g $ 0" "f $ 0 \<noteq> 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2478
  shows   "f = g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2479
proof (rule fps_ext)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2480
  fix k :: nat
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2481
  show "f $ k = g $ k"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2482
  proof (induction k rule: less_induct)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2483
    case (less k)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2484
    show ?case
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2485
    proof (cases "k = 0")
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2486
      case False
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2487
      let ?h = "\<lambda>f. (\<Sum>v | v \<in> natpermute k (m + 1) \<and> k \<notin> set v. \<Prod>j = 0..m. f $ v ! j)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2488
      from False fps_power_Suc_nth[of k f m] fps_power_Suc_nth[of k g m]
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2489
        have "f $ k * (of_nat (Suc m) * (f $ 0) ^ m) + ?h f =
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2490
                g $ k * (of_nat (Suc m) * (f $ 0) ^ m) + ?h g" using assms 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2491
        by (simp add: mult_ac del: power_Suc of_nat_Suc)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2492
      also have "v ! i < k" if "v \<in> {v\<in>natpermute k (m+1). k \<notin> set v}" "i \<le> m" for v i
66311
037aaa0b6daf added lemmas
nipkow
parents: 66089
diff changeset
  2493
        using that elem_le_sum_list[of i v] unfolding natpermute_def
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2494
        by (auto simp: set_conv_nth dest!: spec[of _ i])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2495
      hence "?h f = ?h g"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2496
        by (intro sum.cong refl prod.cong less lessI) (auto simp: natpermute_def)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2497
      finally have "f $ k * (of_nat (Suc m) * (f $ 0) ^ m) = g $ k * (of_nat (Suc m) * (f $ 0) ^ m)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2498
        by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2499
      with assms show "f $ k = g $ k" 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2500
        by (subst (asm) mult_right_cancel) (auto simp del: of_nat_Suc)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2501
    qed (simp_all add: assms)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2502
  qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2503
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2504
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2505
lemma fps_power_Suc_eqD':
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2506
  fixes f g :: "'a :: {idom,semiring_char_0} fps"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2507
  assumes "f ^ Suc m = g ^ Suc m" "f $ subdegree f = g $ subdegree g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2508
  shows   "f = g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2509
proof (cases "f = 0")
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2510
  case False
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2511
  have "Suc m * subdegree f = subdegree (f ^ Suc m)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2512
    by (rule subdegree_power [symmetric])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2513
  also have "f ^ Suc m = g ^ Suc m" by fact
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2514
  also have "subdegree \<dots> = Suc m * subdegree g" by (rule subdegree_power)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2515
  finally have [simp]: "subdegree f = subdegree g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2516
    by (subst (asm) Suc_mult_cancel1)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2517
  have "fps_shift (subdegree f) f * fps_X ^ subdegree f = f"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2518
    by (rule subdegree_decompose [symmetric])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2519
  also have "\<dots> ^ Suc m = g ^ Suc m" by fact
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  2520
  also have "g = fps_shift (subdegree g) g * fps_X ^ subdegree g"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2521
    by (rule subdegree_decompose)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2522
  also have "subdegree f = subdegree g" by fact
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2523
  finally have "fps_shift (subdegree g) f ^ Suc m = fps_shift (subdegree g) g ^ Suc m"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2524
    by (simp add: algebra_simps power_mult_distrib del: power_Suc)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2525
  hence "fps_shift (subdegree g) f = fps_shift (subdegree g) g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2526
    by (rule fps_power_Suc_eqD) (insert assms False, auto)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2527
  with subdegree_decompose[of f] subdegree_decompose[of g] show ?thesis by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2528
qed (insert assms, simp_all)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2529
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2530
lemma fps_power_eqD':
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2531
  fixes f g :: "'a :: {idom,semiring_char_0} fps"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2532
  assumes "f ^ m = g ^ m" "f $ subdegree f = g $ subdegree g" "m > 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2533
  shows   "f = g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2534
  using fps_power_Suc_eqD'[of f "m-1" g] assms by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2535
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2536
lemma fps_power_eqD:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2537
  fixes f g :: "'a :: {idom,semiring_char_0} fps"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2538
  assumes "f ^ m = g ^ m" "f $ 0 = g $ 0" "f $ 0 \<noteq> 0" "m > 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2539
  shows   "f = g"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2540
  by (rule fps_power_eqD'[of f m g]) (insert assms, simp_all)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  2541
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2542
lemma fps_compose_inj_right:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2543
  assumes a0: "a$0 = (0::'a::idom)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2544
    and a1: "a$1 \<noteq> 0"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2545
  shows "(b oo a = c oo a) \<longleftrightarrow> b = c"
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2546
  (is "?lhs \<longleftrightarrow>?rhs")
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2547
proof
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2548
  show ?lhs if ?rhs using that by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2549
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2550
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2551
    have "b$n = c$n" for n
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2552
    proof (induct n rule: nat_less_induct)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2553
      fix n
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2554
      assume H: "\<forall>m<n. b$m = c$m"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2555
      show "b$n = c$n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2556
      proof (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2557
        case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2558
        from \<open>?lhs\<close> have "(b oo a)$n = (c oo a)$n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2559
          by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2560
        then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2561
          using 0 by (simp add: fps_compose_nth)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2562
      next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2563
        case (Suc n1)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2564
        have f: "finite {0 .. n1}" "finite {n}" by simp_all
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2565
        have eq: "{0 .. n1} \<union> {n} = {0 .. n}" using Suc by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2566
        have d: "{0 .. n1} \<inter> {n} = {}" using Suc by auto
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2567
        have seq: "(\<Sum>i = 0..n1. b $ i * a ^ i $ n) = (\<Sum>i = 0..n1. c $ i * a ^ i $ n)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2568
          apply (rule sum.cong)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2569
          using H Suc
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2570
          apply auto
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2571
          done
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2572
        have th0: "(b oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + b$n * (a$1)^n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2573
          unfolding fps_compose_nth sum.union_disjoint[OF f d, unfolded eq] seq
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2574
          using startsby_zero_power_nth_same[OF a0]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2575
          by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2576
        have th1: "(c oo a) $n = (\<Sum>i = 0..n1. c $ i * a ^ i $ n) + c$n * (a$1)^n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2577
          unfolding fps_compose_nth sum.union_disjoint[OF f d, unfolded eq]
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2578
          using startsby_zero_power_nth_same[OF a0]
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2579
          by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2580
        from \<open>?lhs\<close>[unfolded fps_eq_iff, rule_format, of n] th0 th1 a1
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2581
        show ?thesis by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2582
      qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2583
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2584
    then show ?rhs by (simp add: fps_eq_iff)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2585
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2586
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2587
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2588
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  2589
subsection \<open>Radicals\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2590
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2591
declare prod.cong [fundef_cong]
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2592
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2593
function radical :: "(nat \<Rightarrow> 'a \<Rightarrow> 'a) \<Rightarrow> nat \<Rightarrow> 'a::field fps \<Rightarrow> nat \<Rightarrow> 'a"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2594
where
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2595
  "radical r 0 a 0 = 1"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2596
| "radical r 0 a (Suc n) = 0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2597
| "radical r (Suc k) a 0 = r (Suc k) (a$0)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2598
| "radical r (Suc k) a (Suc n) =
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2599
    (a$ Suc n - sum (\<lambda>xs. prod (\<lambda>j. radical r (Suc k) a (xs ! j)) {0..k})
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2600
      {xs. xs \<in> natpermute (Suc n) (Suc k) \<and> Suc n \<notin> set xs}) /
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2601
    (of_nat (Suc k) * (radical r (Suc k) a 0)^k)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2602
  by pat_completeness auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2603
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2604
termination radical
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2605
proof
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2606
  let ?R = "measure (\<lambda>(r, k, a, n). n)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2607
  {
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2608
    show "wf ?R" by auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2609
  next
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2610
    fix r k a n xs i
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2611
    assume xs: "xs \<in> {xs \<in> natpermute (Suc n) (Suc k). Suc n \<notin> set xs}" and i: "i \<in> {0..k}"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2612
    have False if c: "Suc n \<le> xs ! i"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2613
    proof -
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2614
      from xs i have "xs !i \<noteq> Suc n"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2615
        by (auto simp add: in_set_conv_nth natpermute_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2616
      with c have c': "Suc n < xs!i" by arith
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2617
      have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2618
        by simp_all
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2619
      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
  2620
        by auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2621
      have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2622
        using i by auto
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2623
      from xs have "Suc n = sum_list xs"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2624
        by (simp add: natpermute_def)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2625
      also have "\<dots> = sum (nth xs) {0..<Suc k}" using xs
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2626
        by (simp add: natpermute_def sum_list_sum_nth)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2627
      also have "\<dots> = xs!i + sum (nth xs) {0..<i} + sum (nth xs) {i+1..<Suc k}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2628
        unfolding eqs  sum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)]
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2629
        unfolding sum.union_disjoint[OF fths(2) fths(3) d(2)]
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2630
        by simp
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2631
      finally show ?thesis using c' by simp
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2632
    qed
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2633
    then show "((r, Suc k, a, xs!i), r, Suc k, a, Suc n) \<in> ?R"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2634
      apply auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2635
      apply (metis not_less)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2636
      done
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2637
  next
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2638
    fix r k a n
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2639
    show "((r, Suc k, a, 0), r, Suc k, a, Suc n) \<in> ?R" by simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2640
  }
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2641
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2642
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2643
definition "fps_radical r n a = Abs_fps (radical r n a)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2644
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2645
lemma fps_radical0[simp]: "fps_radical r 0 a = 1"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2646
  apply (auto simp add: fps_eq_iff fps_radical_def)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2647
  apply (case_tac n)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2648
  apply auto
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2649
  done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2650
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2651
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
  2652
  by (cases n) (simp_all add: fps_radical_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2653
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2654
lemma fps_radical_power_nth[simp]:
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2655
  assumes r: "(r k (a$0)) ^ k = a$0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2656
  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
  2657
proof (cases k)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2658
  case 0
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2659
  then show ?thesis by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2660
next
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2661
  case (Suc h)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2662
  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
  2663
    unfolding fps_power_nth Suc by simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2664
  also have "\<dots> = (\<Prod>j\<in>{0..h}. r k (a$0))"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2665
    apply (rule prod.cong)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2666
    apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2667
    using Suc
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2668
    apply (subgoal_tac "replicate k 0 ! x = 0")
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2669
    apply (auto intro: nth_replicate simp del: replicate.simps)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2670
    done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2671
  also have "\<dots> = a$0"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2672
    using r Suc by (simp add: prod_constant)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2673
  finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2674
    using Suc by simp
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2675
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2676
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2677
lemma power_radical:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  2678
  fixes a:: "'a::field_char_0 fps"
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2679
  assumes a0: "a$0 \<noteq> 0"
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2680
  shows "(r (Suc k) (a$0)) ^ Suc k = a$0 \<longleftrightarrow> (fps_radical r (Suc k) a) ^ (Suc k) = a"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2681
    (is "?lhs \<longleftrightarrow> ?rhs")
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2682
proof
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2683
  let ?r = "fps_radical r (Suc k) a"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2684
  show ?rhs if r0: ?lhs
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2685
  proof -
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2686
    from a0 r0 have r00: "r (Suc k) (a$0) \<noteq> 0" by auto
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2687
    have "?r ^ Suc k $ z = a$z" for z
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2688
    proof (induct z rule: nat_less_induct)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2689
      fix n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2690
      assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2691
      show "?r ^ Suc k $ n = a $n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2692
      proof (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2693
        case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2694
        then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2695
          using fps_radical_power_nth[of r "Suc k" a, OF r0] by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2696
      next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2697
        case (Suc n1)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2698
        then have "n \<noteq> 0" by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2699
        let ?Pnk = "natpermute n (k + 1)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2700
        let ?Pnkn = "{xs \<in> ?Pnk. n \<in> set xs}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2701
        let ?Pnknn = "{xs \<in> ?Pnk. n \<notin> set xs}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2702
        have eq: "?Pnkn \<union> ?Pnknn = ?Pnk" by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2703
        have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2704
        have f: "finite ?Pnkn" "finite ?Pnknn"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2705
          using finite_Un[of ?Pnkn ?Pnknn, unfolded eq]
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2706
          by (metis natpermute_finite)+
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2707
        let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2708
        have "sum ?f ?Pnkn = sum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2709
        proof (rule sum.cong)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2710
          fix v assume v: "v \<in> {xs \<in> natpermute n (k + 1). n \<in> set xs}"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2711
          let ?ths = "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2712
            fps_radical r (Suc k) a $ n * r (Suc k) (a $ 0) ^ k"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2713
          from v obtain i where i: "i \<in> {0..k}" "v = replicate (k+1) 0 [i:= n]"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2714
            unfolding natpermute_contain_maximal by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2715
          have "(\<Prod>j\<in>{0..k}. fps_radical r (Suc k) a $ v ! j) =
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2716
              (\<Prod>j\<in>{0..k}. if j = i then fps_radical r (Suc k) a $ n else r (Suc k) (a$0))"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2717
            apply (rule prod.cong, simp)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2718
            using i r0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2719
            apply (simp del: replicate.simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2720
            done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2721
          also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2722
            using i r0 by (simp add: prod_gen_delta)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2723
          finally show ?ths .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2724
        qed rule
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2725
        then have "sum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2726
          by (simp add: natpermute_max_card[OF \<open>n \<noteq> 0\<close>, simplified])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2727
        also have "\<dots> = a$n - sum ?f ?Pnknn"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2728
          unfolding Suc using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2729
        finally have fn: "sum ?f ?Pnkn = a$n - sum ?f ?Pnknn" .
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2730
        have "(?r ^ Suc k)$n = sum ?f ?Pnkn + sum ?f ?Pnknn"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2731
          unfolding fps_power_nth_Suc sum.union_disjoint[OF f d, unfolded eq] ..
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2732
        also have "\<dots> = a$n" unfolding fn by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2733
        finally show ?thesis .
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2734
      qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2735
    qed
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2736
    then show ?thesis using r0 by (simp add: fps_eq_iff)
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2737
  qed
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2738
  show ?lhs if ?rhs
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2739
  proof -
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2740
    from that have "((fps_radical r (Suc k) a) ^ (Suc k))$0 = a$0"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2741
      by simp
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2742
    then show ?thesis
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2743
      unfolding fps_power_nth_Suc
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2744
      by (simp add: prod_constant del: replicate.simps)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2745
  qed
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2746
qed
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2747
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2748
(*
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2749
lemma power_radical:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  2750
  fixes a:: "'a::field_char_0 fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2751
  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
  2752
  shows "(fps_radical r (Suc k) a) ^ (Suc k) = a"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2753
proof-
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2754
  let ?r = "fps_radical r (Suc k) a"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2755
  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
  2756
  {fix z have "?r ^ Suc k $ z = a$z"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2757
    proof(induct z rule: nat_less_induct)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2758
      fix n assume H: "\<forall>m<n. ?r ^ Suc k $ m = a$m"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2759
      {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
  2760
          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
  2761
      moreover
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2762
      {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
  2763
        have fK: "finite {0..k}" by simp
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2764
        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
  2765
        let ?Pnk = "natpermute n (k + 1)"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2766
        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
  2767
        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
  2768
        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
  2769
        have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2770
        have f: "finite ?Pnkn" "finite ?Pnknn"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2771
          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
  2772
          by (metis natpermute_finite)+
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2773
        let ?f = "\<lambda>v. \<Prod>j\<in>{0..k}. ?r $ v ! j"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2774
        have "sum ?f ?Pnkn = sum (\<lambda>v. ?r $ n * r (Suc k) (a $ 0) ^ k) ?Pnkn"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2775
        proof(rule sum.cong2)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2776
          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
  2777
          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
  2778
          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
  2779
            unfolding natpermute_contain_maximal by auto
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2780
          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))"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2781
            apply (rule prod.cong, simp)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2782
            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
  2783
          also have "\<dots> = (fps_radical r (Suc k) a $ n) * r (Suc k) (a$0) ^ k"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2784
            unfolding prod_gen_delta[OF fK] using i r0 by simp
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2785
          finally show ?ths .
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2786
        qed
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2787
        then have "sum ?f ?Pnkn = of_nat (k+1) * ?r $ n * r (Suc k) (a $ 0) ^ k"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2788
          by (simp add: natpermute_max_card[OF nz, simplified])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2789
        also have "\<dots> = a$n - sum ?f ?Pnknn"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2790
          unfolding n1 using r00 a0 by (simp add: field_simps fps_radical_def del: of_nat_Suc )
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2791
        finally have fn: "sum ?f ?Pnkn = a$n - sum ?f ?Pnknn" .
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2792
        have "(?r ^ Suc k)$n = sum ?f ?Pnkn + sum ?f ?Pnknn"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2793
          unfolding fps_power_nth_Suc sum.union_disjoint[OF f d, unfolded eq] ..
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2794
        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
  2795
        finally have "?r ^ Suc k $ n = a $n" .}
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2796
      ultimately  show "?r ^ Suc k $ n = a $n" by (cases n, auto)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2797
  qed }
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2798
  then show ?thesis by (simp add: fps_eq_iff)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2799
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2800
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2801
*)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2802
lemma eq_divide_imp':
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2803
  fixes c :: "'a::field"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2804
  shows "c \<noteq> 0 \<Longrightarrow> a * c = b \<Longrightarrow> a = b / c"
56480
093ea91498e6 field_simps: better support for negation and division, and power
hoelzl
parents: 56479
diff changeset
  2805
  by (simp add: field_simps)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2806
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2807
lemma radical_unique:
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2808
  assumes r0: "(r (Suc k) (b$0)) ^ Suc k = b$0"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2809
    and a0: "r (Suc k) (b$0 ::'a::field_char_0) = a$0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2810
    and b0: "b$0 \<noteq> 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2811
  shows "a^(Suc k) = b \<longleftrightarrow> a = fps_radical r (Suc k) b"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2812
    (is "?lhs \<longleftrightarrow> ?rhs" is "_ \<longleftrightarrow> a = ?r")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2813
proof
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2814
  show ?lhs if ?rhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2815
    using that using power_radical[OF b0, of r k, unfolded r0] by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2816
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2817
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2818
    have r00: "r (Suc k) (b$0) \<noteq> 0" using b0 r0 by auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2819
    have ceq: "card {0..k} = Suc k" by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2820
    from a0 have a0r0: "a$0 = ?r$0" by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2821
    have "a $ n = ?r $ n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2822
    proof (induct n rule: nat_less_induct)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2823
      fix n
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2824
      assume h: "\<forall>m<n. a$m = ?r $m"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2825
      show "a$n = ?r $ n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2826
      proof (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2827
        case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2828
        then show ?thesis using a0 by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2829
      next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2830
        case (Suc n1)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2831
        have fK: "finite {0..k}" by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2832
        have nz: "n \<noteq> 0" using Suc by simp
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2833
        let ?Pnk = "natpermute n (Suc k)"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2834
        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
  2835
        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
  2836
        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
  2837
        have d: "?Pnkn \<inter> ?Pnknn = {}" by blast
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2838
        have f: "finite ?Pnkn" "finite ?Pnknn"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2839
          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
  2840
          by (metis natpermute_finite)+
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2841
        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
  2842
        let ?g = "\<lambda>v. \<Prod>j\<in>{0..k}. a $ v ! j"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2843
        have "sum ?g ?Pnkn = sum (\<lambda>v. a $ n * (?r$0)^k) ?Pnkn"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2844
        proof (rule sum.cong)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2845
          fix v
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2846
          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
  2847
          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
  2848
          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
  2849
            unfolding Suc_eq_plus1 natpermute_contain_maximal
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2850
            by (auto simp del: replicate.simps)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2851
          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))"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2852
            apply (rule prod.cong, simp)
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2853
            using i a0
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2854
            apply (simp del: replicate.simps)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2855
            done
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2856
          also have "\<dots> = a $ n * (?r $ 0)^k"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2857
            using i by (simp add: prod_gen_delta)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2858
          finally show ?ths .
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 57129
diff changeset
  2859
        qed rule
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2860
        then have th0: "sum ?g ?Pnkn = of_nat (k+1) * a $ n * (?r $ 0)^k"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2861
          by (simp add: natpermute_max_card[OF nz, simplified])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2862
        have th1: "sum ?g ?Pnknn = sum ?f ?Pnknn"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  2863
        proof (rule sum.cong, rule refl, rule prod.cong, simp)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2864
          fix xs i
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2865
          assume xs: "xs \<in> ?Pnknn" and i: "i \<in> {0..k}"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2866
          have False if c: "n \<le> xs ! i"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2867
          proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2868
            from xs i have "xs ! i \<noteq> n"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2869
              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
  2870
            with c have c': "n < xs!i" by arith
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2871
            have fths: "finite {0 ..< i}" "finite {i}" "finite {i+1..<Suc k}"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2872
              by simp_all
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2873
            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
  2874
              by auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2875
            have eqs: "{0..<Suc k} = {0 ..< i} \<union> ({i} \<union> {i+1 ..< Suc k})"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2876
              using i by auto
63882
018998c00003 renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents: 63589
diff changeset
  2877
            from xs have "n = sum_list xs"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2878
              by (simp add: natpermute_def)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2879
            also have "\<dots> = sum (nth xs) {0..<Suc k}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2880
              using xs by (simp add: natpermute_def sum_list_sum_nth)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2881
            also have "\<dots> = xs!i + sum (nth xs) {0..<i} + sum (nth xs) {i+1..<Suc k}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2882
              unfolding eqs  sum.union_disjoint[OF fths(1) finite_UnI[OF fths(2,3)] d(1)]
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2883
              unfolding sum.union_disjoint[OF fths(2) fths(3) d(2)]
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2884
              by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2885
            finally show ?thesis using c' by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2886
          qed
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  2887
          then have thn: "xs!i < n" by presburger
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2888
          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
  2889
        qed
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2890
        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
  2891
          by (simp add: field_simps del: of_nat_Suc)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2892
        from \<open>?lhs\<close> have "b$n = a^Suc k $ n"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2893
          by (simp add: fps_eq_iff)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2894
        also have "a ^ Suc k$n = sum ?g ?Pnkn + sum ?g ?Pnknn"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2895
          unfolding fps_power_nth_Suc
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2896
          using sum.union_disjoint[OF f d, unfolded Suc_eq_plus1[symmetric],
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2897
            unfolded eq, of ?g] by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2898
        also have "\<dots> = of_nat (k+1) * a $ n * (?r $ 0)^k + sum ?f ?Pnknn"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2899
          unfolding th0 th1 ..
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2900
        finally have "of_nat (k+1) * a $ n * (?r $ 0)^k = b$n - sum ?f ?Pnknn"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2901
          by simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  2902
        then have "a$n = (b$n - sum ?f ?Pnknn) / (of_nat (k+1) * (?r $ 0)^k)"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2903
          apply -
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2904
          apply (rule eq_divide_imp')
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2905
          using r00
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2906
          apply (simp del: of_nat_Suc)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  2907
          apply (simp add: ac_simps)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2908
          done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2909
        then show ?thesis
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  2910
          apply (simp del: of_nat_Suc)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2911
          unfolding fps_radical_def Suc
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2912
          apply (simp add: field_simps Suc th00 del: of_nat_Suc)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2913
          done
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2914
      qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2915
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2916
    then show ?rhs by (simp add: fps_eq_iff)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2917
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2918
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2919
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2920
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2921
lemma radical_power:
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2922
  assumes r0: "r (Suc k) ((a$0) ^ Suc k) = a$0"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2923
    and a0: "(a$0 :: 'a::field_char_0) \<noteq> 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2924
  shows "(fps_radical r (Suc k) (a ^ Suc k)) = a"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2925
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2926
  let ?ak = "a^ Suc k"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2927
  have ak0: "?ak $ 0 = (a$0) ^ Suc k"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2928
    by (simp add: fps_nth_power_0 del: power_Suc)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2929
  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
  2930
    using ak0 by auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2931
  from r0 ak0 have th1: "r (Suc k) (a ^ Suc k $ 0) = a $ 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2932
    by auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2933
  from ak0 a0 have ak00: "?ak $ 0 \<noteq>0 "
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2934
    by auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2935
  from radical_unique[of r k ?ak a, OF th0 th1 ak00] show ?thesis
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2936
    by metis
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2937
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2938
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2939
lemma fps_deriv_radical:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2940
  fixes a :: "'a::field_char_0 fps"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2941
  assumes r0: "(r (Suc k) (a$0)) ^ Suc k = a$0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2942
    and a0: "a$0 \<noteq> 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2943
  shows "fps_deriv (fps_radical r (Suc k) a) =
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  2944
    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
  2945
proof -
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2946
  let ?r = "fps_radical r (Suc k) a"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2947
  let ?w = "(fps_const (of_nat (Suc k)) * ?r ^ k)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2948
  from a0 r0 have r0': "r (Suc k) (a$0) \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2949
    by auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2950
  from r0' have w0: "?w $ 0 \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2951
    by (simp del: of_nat_Suc)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2952
  note th0 = inverse_mult_eq_1[OF w0]
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2953
  let ?iw = "inverse ?w"
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  2954
  from iffD1[OF power_radical[of a r], OF a0 r0]
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2955
  have "fps_deriv (?r ^ Suc k) = fps_deriv a"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2956
    by simp
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2957
  then have "fps_deriv ?r * ?w = fps_deriv a"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  2958
    by (simp add: fps_deriv_power ac_simps del: power_Suc)
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  2959
  then have "?iw * fps_deriv ?r * ?w = ?iw * fps_deriv a"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2960
    by simp
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  2961
  with a0 r0 have "fps_deriv ?r * (?iw * ?w) = fps_deriv a / ?w"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  2962
    by (subst fps_divide_unit) (auto simp del: of_nat_Suc)
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2963
  then show ?thesis unfolding th0 by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2964
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  2965
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  2966
lemma radical_mult_distrib:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  2967
  fixes a :: "'a::field_char_0 fps"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2968
  assumes k: "k > 0"
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2969
    and ra0: "r k (a $ 0) ^ k = a $ 0"
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2970
    and rb0: "r k (b $ 0) ^ k = b $ 0"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2971
    and a0: "a $ 0 \<noteq> 0"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2972
    and b0: "b $ 0 \<noteq> 0"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  2973
  shows "r k ((a * b) $ 0) = r k (a $ 0) * r k (b $ 0) \<longleftrightarrow>
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2974
    fps_radical r k (a * b) = fps_radical r k a * fps_radical r k b"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2975
    (is "?lhs \<longleftrightarrow> ?rhs")
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2976
proof
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2977
  show ?rhs if r0': ?lhs
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2978
  proof -
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2979
    from r0' have r0: "(r k ((a * b) $ 0)) ^ k = (a * b) $ 0"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2980
      by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2981
    show ?thesis
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2982
    proof (cases k)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2983
      case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2984
      then show ?thesis using r0' by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2985
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2986
      case (Suc h)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2987
      let ?ra = "fps_radical r (Suc h) a"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2988
      let ?rb = "fps_radical r (Suc h) b"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2989
      have th0: "r (Suc h) ((a * b) $ 0) = (fps_radical r (Suc h) a * fps_radical r (Suc h) b) $ 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2990
        using r0' Suc by (simp add: fps_mult_nth)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2991
      have ab0: "(a*b) $ 0 \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  2992
        using a0 b0 by (simp add: fps_mult_nth)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2993
      from radical_unique[of r h "a*b" "fps_radical r (Suc h) a * fps_radical r (Suc h) b", OF r0[unfolded Suc] th0 ab0, symmetric]
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2994
        iffD1[OF power_radical[of _ r], OF a0 ra0[unfolded Suc]] iffD1[OF power_radical[of _ r], OF b0 rb0[unfolded Suc]] Suc r0'
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2995
      show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2996
        by (auto simp add: power_mult_distrib simp del: power_Suc)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  2997
    qed
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2998
  qed
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  2999
  show ?lhs if ?rhs
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3000
  proof -
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3001
    from that 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
  3002
      by simp
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3003
    then show ?thesis
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3004
      using k by (simp add: fps_mult_nth)
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3005
  qed
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3006
qed
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3007
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3008
(*
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3009
lemma radical_mult_distrib:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  3010
  fixes a:: "'a::field_char_0 fps"
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3011
  assumes
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3012
  ra0: "r k (a $ 0) ^ k = a $ 0"
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3013
  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
  3014
  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
  3015
  and a0: "a$0 \<noteq> 0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3016
  and b0: "b$0 \<noteq> 0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3017
  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
  3018
proof-
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3019
  from r0' have r0: "(r (k) ((a*b)$0)) ^ k = (a*b)$0"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3020
    by (simp add: fps_mult_nth ra0 rb0 power_mult_distrib)
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3021
  {assume "k=0" then have ?thesis by simp}
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3022
  moreover
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3023
  {fix h assume k: "k = Suc h"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3024
  let ?ra = "fps_radical r (Suc h) a"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3025
  let ?rb = "fps_radical r (Suc h) b"
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3026
  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
  3027
    using r0' k by (simp add: fps_mult_nth)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3028
  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
  3029
  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
  3030
    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
  3031
  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
  3032
ultimately show ?thesis by (cases k, auto)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3033
qed
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3034
*)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3035
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3036
lemma fps_divide_1 [simp]: "(a :: 'a::field fps) / 1 = a"
64240
eabf80376aab more standardized names
haftmann
parents: 63918
diff changeset
  3037
  by (fact div_by_1)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3038
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3039
lemma radical_divide:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  3040
  fixes a :: "'a::field_char_0 fps"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3041
  assumes kp: "k > 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3042
    and ra0: "(r k (a $ 0)) ^ k = a $ 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3043
    and rb0: "(r k (b $ 0)) ^ k = b $ 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3044
    and a0: "a$0 \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3045
    and b0: "b$0 \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3046
  shows "r k ((a $ 0) / (b$0)) = r k (a$0) / r k (b $ 0) \<longleftrightarrow>
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3047
    fps_radical r k (a/b) = fps_radical r k a / fps_radical r k b"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3048
  (is "?lhs = ?rhs")
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3049
proof
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3050
  let ?r = "fps_radical r k"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3051
  from kp obtain h where k: "k = Suc h"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  3052
    by (cases k) auto
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3053
  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
  3054
  have rb0': "r k (b$0) \<noteq> 0" using b0 rb0 k by auto
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3055
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3056
  show ?lhs if ?rhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3057
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3058
    from that have "?r (a/b) $ 0 = (?r a / ?r b)$0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3059
      by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3060
    then show ?thesis
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3061
      using k a0 b0 rb0' by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def divide_inverse)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3062
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3063
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3064
  proof -
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3065
    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
  3066
      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
  3067
    have th0: "r k ((a/b)$0) ^ k = (a/b)$0"
60867
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
  3068
      by (simp add: \<open>?lhs\<close> power_divide ra0 rb0)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3069
    from a0 b0 ra0' rb0' kp \<open>?lhs\<close>
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3070
    have th1: "r k ((a / b) $ 0) = (fps_radical r k a / fps_radical r k b) $ 0"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3071
      by (simp add: fps_divide_unit 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
  3072
    from a0 b0 ra0' rb0' kp have ab0': "(a / b) $ 0 \<noteq> 0"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3073
      by (simp add: fps_divide_unit fps_mult_nth fps_inverse_def nonzero_imp_inverse_nonzero)
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3074
    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
  3075
    note thb[simp] = iffD1[OF power_radical[where r=r and k=h], OF b0 rb0[unfolded k], unfolded k[symmetric]]
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3076
    from b0 rb0' have th2: "(?r a / ?r b)^k = a/b"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3077
      by (simp add: fps_divide_unit power_mult_distrib fps_inverse_power[symmetric])
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  3078
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  3079
    from iffD1[OF radical_unique[where r=r and a="?r a / ?r b" and b="a/b" and k=h], symmetric, unfolded k[symmetric], OF th0 th1 ab0' th2]
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3080
    show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3081
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3082
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3083
31073
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3084
lemma radical_inverse:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  3085
  fixes a :: "'a::field_char_0 fps"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3086
  assumes k: "k > 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3087
    and ra0: "r k (a $ 0) ^ k = a $ 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3088
    and r1: "(r k 1)^k = 1"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3089
    and a0: "a$0 \<noteq> 0"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3090
  shows "r k (inverse (a $ 0)) = r k 1 / (r k (a $ 0)) \<longleftrightarrow>
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3091
    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
  3092
  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
  3093
  by (simp add: divide_inverse fps_divide_def)
4b44c4d08aa6 Generalized distributivity theorems of radicals over multiplication, division and inverses
chaieb
parents: 31021
diff changeset
  3094
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3095
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3096
subsection \<open>Derivative of composition\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3097
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3098
lemma fps_compose_deriv:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3099
  fixes a :: "'a::idom fps"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3100
  assumes b0: "b$0 = 0"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3101
  shows "fps_deriv (a oo b) = ((fps_deriv a) oo b) * fps_deriv b"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3102
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3103
  have "(fps_deriv (a oo b))$n = (((fps_deriv a) oo b) * (fps_deriv b)) $n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3104
  proof -
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3105
    have "(fps_deriv (a oo b))$n = sum (\<lambda>i. a $ i * (fps_deriv (b^i))$n) {0.. Suc n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3106
      by (simp add: fps_compose_def field_simps sum_distrib_left del: of_nat_Suc)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3107
    also have "\<dots> = sum (\<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
  3108
      by (simp add: field_simps fps_deriv_power del: fps_mult_left_const_nth of_nat_Suc)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3109
    also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (((b^(i - 1)) * fps_deriv b))$n) {0.. Suc n}"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3110
      unfolding fps_mult_left_const_nth  by (simp add: field_simps)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3111
    also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (sum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {0.. Suc n}"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3112
      unfolding fps_mult_nth ..
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3113
    also have "\<dots> = sum (\<lambda>i. of_nat i * a$i * (sum (\<lambda>j. (b^ (i - 1))$j * (fps_deriv b)$(n - j)) {0..n})) {1.. Suc n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3114
      apply (rule sum.mono_neutral_right)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3115
      apply (auto simp add: mult_delta_left sum.delta not_le)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3116
      done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3117
    also have "\<dots> = sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3118
      unfolding fps_deriv_nth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3119
      by (rule sum.reindex_cong [of Suc]) (auto simp add: mult.assoc)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3120
    finally have th0: "(fps_deriv (a oo b))$n =
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3121
      sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}" .
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3122
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3123
    have "(((fps_deriv a) oo b) * (fps_deriv b))$n = sum (\<lambda>i. (fps_deriv b)$ (n - i) * ((fps_deriv a) oo b)$i) {0..n}"
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  3124
      unfolding fps_mult_nth by (simp add: ac_simps)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3125
    also have "\<dots> = sum (\<lambda>i. sum (\<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}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3126
      unfolding fps_deriv_nth fps_compose_nth sum_distrib_left mult.assoc
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3127
      apply (rule sum.cong)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 57129
diff changeset
  3128
      apply (rule refl)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3129
      apply (rule sum.mono_neutral_left)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3130
      apply (simp_all add: subset_eq)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3131
      apply clarify
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3132
      apply (subgoal_tac "b^i$x = 0")
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3133
      apply simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3134
      apply (rule startsby_zero_power_prefix[OF b0, rule_format])
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3135
      apply simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3136
      done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3137
    also have "\<dots> = sum (\<lambda>i. of_nat (i + 1) * a$(i+1) * (sum (\<lambda>j. (b^ i)$j * of_nat (n - j + 1) * b$(n - j + 1)) {0..n})) {0.. n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3138
      unfolding sum_distrib_left
66804
3f9bb52082c4 avoid name clashes on interpretation of abstract locales
haftmann
parents: 66550
diff changeset
  3139
      apply (subst sum.swap)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3140
      apply (rule sum.cong, rule refl)+
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3141
      apply simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3142
      done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3143
    finally show ?thesis
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3144
      unfolding th0 by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3145
  qed
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3146
  then show ?thesis by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3147
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3148
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3149
lemma fps_mult_fps_X_plus_1_nth:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3150
  "((1+fps_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
  3151
proof (cases n)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3152
  case 0
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3153
  then show ?thesis
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3154
    by (simp add: fps_mult_nth)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3155
next
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3156
  case (Suc m)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3157
  have "((1 + fps_X)*a) $ n = sum (\<lambda>i. (1 + fps_X) $ i * a $ (n - i)) {0..n}"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3158
    by (simp add: fps_mult_nth)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3159
  also have "\<dots> = sum (\<lambda>i. (1+fps_X)$i * a$(n-i)) {0.. 1}"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3160
    unfolding Suc by (rule sum.mono_neutral_right) auto
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3161
  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
  3162
    by (simp add: Suc)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3163
  finally show ?thesis .
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3164
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3165
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3166
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3167
subsection \<open>Finite FPS (i.e. polynomials) and fps_X\<close>
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3168
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3169
lemma fps_poly_sum_fps_X:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3170
  assumes "\<forall>i > n. a$i = (0::'a::comm_ring_1)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3171
  shows "a = sum (\<lambda>i. fps_const (a$i) * fps_X^i) {0..n}" (is "a = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3172
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3173
  have "a$i = ?r$i" for i
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3174
    unfolding fps_sum_nth fps_mult_left_const_nth fps_X_power_nth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3175
    by (simp add: mult_delta_right sum.delta' assms)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3176
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3177
    unfolding fps_eq_iff by blast
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3178
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3179
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3180
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3181
subsection \<open>Compositional inverses\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3182
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3183
fun compinv :: "'a fps \<Rightarrow> nat \<Rightarrow> 'a::field"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3184
where
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3185
  "compinv a 0 = fps_X$0"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3186
| "compinv a (Suc n) =
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3187
    (fps_X$ Suc n - sum (\<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
  3188
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3189
definition "fps_inv a = Abs_fps (compinv a)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3190
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3191
lemma fps_inv:
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3192
  assumes a0: "a$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3193
    and a1: "a$1 \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3194
  shows "fps_inv a oo a = fps_X"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3195
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3196
  let ?i = "fps_inv a oo a"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3197
  have "?i $n = fps_X$n" for n
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3198
  proof (induct n rule: nat_less_induct)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3199
    fix n
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3200
    assume h: "\<forall>m<n. ?i$m = fps_X$m"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3201
    show "?i $ n = fps_X$n"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3202
    proof (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3203
      case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3204
      then show ?thesis using a0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3205
        by (simp add: fps_compose_nth fps_inv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3206
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3207
      case (Suc n1)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3208
      have "?i $ n = sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} + fps_inv a $ Suc n1 * (a $ 1)^ Suc n1"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3209
        by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3210
      also have "\<dots> = sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1} +
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3211
        (fps_X$ Suc n1 - sum (\<lambda>i. (fps_inv a $ i) * (a^i)$n) {0 .. n1})"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3212
        using a0 a1 Suc by (simp add: fps_inv_def)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3213
      also have "\<dots> = fps_X$n" using Suc by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3214
      finally show ?thesis .
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3215
    qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3216
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3217
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3218
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3219
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3220
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3221
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3222
fun gcompinv :: "'a fps \<Rightarrow> 'a fps \<Rightarrow> nat \<Rightarrow> 'a::field"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3223
where
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3224
  "gcompinv b a 0 = b$0"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3225
| "gcompinv b a (Suc n) =
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3226
    (b$ Suc n - sum (\<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
  3227
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3228
definition "fps_ginv b a = Abs_fps (gcompinv b a)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3229
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3230
lemma fps_ginv:
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3231
  assumes a0: "a$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3232
    and a1: "a$1 \<noteq> 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3233
  shows "fps_ginv b a oo a = b"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3234
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3235
  let ?i = "fps_ginv b a oo a"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3236
  have "?i $n = b$n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3237
  proof (induct n rule: nat_less_induct)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3238
    fix n
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3239
    assume h: "\<forall>m<n. ?i$m = b$m"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3240
    show "?i $ n = b$n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3241
    proof (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3242
      case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3243
      then show ?thesis using a0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3244
        by (simp add: fps_compose_nth fps_ginv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3245
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3246
      case (Suc n1)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3247
      have "?i $ n = sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} + fps_ginv b a $ Suc n1 * (a $ 1)^ Suc n1"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3248
        by (simp only: fps_compose_nth) (simp add: Suc startsby_zero_power_nth_same [OF a0] del: power_Suc)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3249
      also have "\<dots> = sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1} +
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3250
        (b$ Suc n1 - sum (\<lambda>i. (fps_ginv b a $ i) * (a^i)$n) {0 .. n1})"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3251
        using a0 a1 Suc by (simp add: fps_ginv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3252
      also have "\<dots> = b$n" using Suc by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3253
      finally show ?thesis .
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3254
    qed
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3255
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3256
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3257
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3258
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3259
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3260
lemma fps_inv_ginv: "fps_inv = fps_ginv fps_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
  3261
  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
  3262
  apply (induct_tac n rule: nat_less_induct)
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  3263
  apply auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3264
  apply (case_tac na)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3265
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3266
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3267
  done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3268
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3269
lemma fps_compose_1[simp]: "1 oo a = 1"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3270
  by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3271
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3272
lemma fps_compose_0[simp]: "0 oo a = 0"
29913
89eadbe71e97 add mult_delta lemmas; simplify some proofs
huffman
parents: 29912
diff changeset
  3273
  by (simp add: fps_eq_iff fps_compose_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3274
60867
86e7560e07d0 slight cleanup of lemmas
haftmann
parents: 60679
diff changeset
  3275
lemma fps_compose_0_right[simp]: "a oo 0 = fps_const (a $ 0)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3276
  by (auto simp add: fps_eq_iff fps_compose_nth power_0_left sum.neutral)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3277
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3278
lemma fps_compose_add_distrib: "(a + b) oo c = (a oo c) + (b oo c)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3279
  by (simp add: fps_eq_iff fps_compose_nth field_simps sum.distrib)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3280
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3281
lemma fps_compose_sum_distrib: "(sum f S) oo a = sum (\<lambda>i. f i oo a) S"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3282
proof (cases "finite S")
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3283
  case True
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3284
  show ?thesis
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3285
  proof (rule finite_induct[OF True])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3286
    show "sum f {} oo a = (\<Sum>i\<in>{}. f i oo a)"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3287
      by simp
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3288
  next
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3289
    fix x F
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3290
    assume fF: "finite F"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3291
      and xF: "x \<notin> F"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3292
      and h: "sum f F oo a = sum (\<lambda>i. f i oo a) F"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3293
    show "sum f (insert x F) oo a  = sum (\<lambda>i. f i oo a) (insert x F)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3294
      using fF xF h by (simp add: fps_compose_add_distrib)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3295
  qed
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3296
next
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3297
  case False
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3298
  then show ?thesis by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3299
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3300
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3301
lemma convolution_eq:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3302
  "sum (\<lambda>i. a (i :: nat) * b (n - i)) {0 .. n} =
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3303
    sum (\<lambda>(i,j). a i * b j) {(i,j). i \<le> n \<and> j \<le> n \<and> i + j = n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3304
  by (rule sum.reindex_bij_witness[where i=fst and j="\<lambda>i. (i, n - i)"]) auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3305
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3306
lemma product_composition_lemma:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3307
  assumes c0: "c$0 = (0::'a::idom)"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3308
    and d0: "d$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3309
  shows "((a oo c) * (b oo d))$n =
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3310
    sum (\<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
  3311
proof -
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3312
  let ?S = "{(k::nat, m::nat). k + m \<le> n}"
61943
7fba644ed827 discontinued ASCII replacement syntax <*>;
wenzelm
parents: 61804
diff changeset
  3313
  have s: "?S \<subseteq> {0..n} \<times> {0..n}" by (auto simp add: subset_eq)
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3314
  have f: "finite {(k::nat, m::nat). k + m \<le> n}"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3315
    apply (rule finite_subset[OF s])
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3316
    apply auto
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3317
    done
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3318
  have "?r =  sum (\<lambda>i. sum (\<lambda>(k,m). a$k * (c^k)$i * b$m * (d^m) $ (n - i)) {(k,m). k + m \<le> n}) {0..n}"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3319
    apply (simp add: fps_mult_nth sum_distrib_left)
66804
3f9bb52082c4 avoid name clashes on interpretation of abstract locales
haftmann
parents: 66550
diff changeset
  3320
    apply (subst sum.swap)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3321
    apply (rule sum.cong)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3322
    apply (auto simp add: field_simps)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3323
    done
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3324
  also have "\<dots> = ?l"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3325
    apply (simp add: fps_mult_nth fps_compose_nth sum_product)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3326
    apply (rule sum.cong)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 57129
diff changeset
  3327
    apply (rule refl)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3328
    apply (simp add: sum.cartesian_product mult.assoc)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3329
    apply (rule sum.mono_neutral_right[OF f])
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3330
    apply (simp add: subset_eq)
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3331
    apply presburger
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3332
    apply clarsimp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3333
    apply (rule ccontr)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3334
    apply (clarsimp simp add: not_le)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3335
    apply (case_tac "x < aa")
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3336
    apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3337
    apply (frule_tac startsby_zero_power_prefix[rule_format, OF c0])
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3338
    apply blast
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3339
    apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3340
    apply (frule_tac startsby_zero_power_prefix[rule_format, OF d0])
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3341
    apply blast
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3342
    done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3343
  finally show ?thesis by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3344
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3345
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3346
lemma product_composition_lemma':
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3347
  assumes c0: "c$0 = (0::'a::idom)"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3348
    and d0: "d$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3349
  shows "((a oo c) * (b oo d))$n =
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3350
    sum (\<lambda>k. sum (\<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
  3351
  unfolding product_composition_lemma[OF c0 d0]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3352
  unfolding sum.cartesian_product
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3353
  apply (rule sum.mono_neutral_left)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3354
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3355
  apply (clarsimp simp add: subset_eq)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3356
  apply clarsimp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3357
  apply (rule ccontr)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3358
  apply (subgoal_tac "(c^aa * d^ba) $ n = 0")
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3359
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3360
  unfolding fps_mult_nth
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3361
  apply (rule sum.neutral)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3362
  apply (clarsimp simp add: not_le)
51489
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51107
diff changeset
  3363
  apply (case_tac "x < aa")
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3364
  apply (rule startsby_zero_power_prefix[OF c0, rule_format])
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3365
  apply simp
51489
f738e6dbd844 fundamental revision of big operators on sets
haftmann
parents: 51107
diff changeset
  3366
  apply (subgoal_tac "n - x < ba")
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3367
  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
  3368
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3369
  apply arith
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3370
  done
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3371
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3372
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3373
lemma sum_pair_less_iff:
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3374
  "sum (\<lambda>((k::nat),m). a k * b m * c (k + m)) {(k,m). k + m \<le> n} =
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3375
    sum (\<lambda>s. sum (\<lambda>i. a i * b (s - i) * c s) {0..s}) {0..n}"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3376
  (is "?l = ?r")
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3377
proof -
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3378
  let ?KM = "{(k,m). k + m \<le> n}"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3379
  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
  3380
  have th0: "?KM = UNION {0..n} ?f"
62343
24106dc44def prefer abbreviations for compound operators INFIMUM and SUPREMUM
haftmann
parents: 62102
diff changeset
  3381
    by auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3382
  show "?l = ?r "
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3383
    unfolding th0
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3384
    apply (subst sum.UNION_disjoint)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3385
    apply auto
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3386
    apply (subst sum.UNION_disjoint)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3387
    apply auto
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3388
    done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3389
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3390
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3391
lemma fps_compose_mult_distrib_lemma:
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3392
  assumes c0: "c$0 = (0::'a::idom)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3393
  shows "((a oo c) * (b oo c))$n = sum (\<lambda>s. sum (\<lambda>i. a$i * b$(s - i) * (c^s) $ n) {0..s}) {0..n}"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3394
  unfolding product_composition_lemma[OF c0 c0] power_add[symmetric]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3395
  unfolding sum_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
  3396
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3397
lemma fps_compose_mult_distrib:
54489
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54452
diff changeset
  3398
  assumes c0: "c $ 0 = (0::'a::idom)"
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54452
diff changeset
  3399
  shows "(a * b) oo c = (a oo c) * (b oo c)"
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54452
diff changeset
  3400
  apply (simp add: fps_eq_iff fps_compose_mult_distrib_lemma [OF c0])
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3401
  apply (simp add: fps_compose_nth fps_mult_nth sum_distrib_right)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3402
  done
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3403
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  3404
lemma fps_compose_prod_distrib:
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3405
  assumes c0: "c$0 = (0::'a::idom)"
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  3406
  shows "prod a S oo c = prod (\<lambda>k. a k oo c) S"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3407
  apply (cases "finite S")
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3408
  apply simp_all
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3409
  apply (induct S rule: finite_induct)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3410
  apply simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3411
  apply (simp add: fps_compose_mult_distrib[OF c0])
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3412
  done
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3413
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3414
lemma fps_compose_divide:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3415
  assumes [simp]: "g dvd f" "h $ 0 = 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3416
  shows   "fps_compose f h = fps_compose (f / g :: 'a :: field fps) h * fps_compose g h"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3417
proof -
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3418
  have "f = (f / g) * g" by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3419
  also have "fps_compose \<dots> h = fps_compose (f / g) h * fps_compose g h"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3420
    by (subst fps_compose_mult_distrib) simp_all
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3421
  finally show ?thesis .
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3422
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3423
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3424
lemma fps_compose_divide_distrib:
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3425
  assumes "g dvd f" "h $ 0 = 0" "fps_compose g h \<noteq> 0"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3426
  shows   "fps_compose (f / g :: 'a :: field fps) h = fps_compose f h / fps_compose g h"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3427
  using fps_compose_divide[OF assms(1,2)] assms(3) by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3428
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3429
lemma fps_compose_power:
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3430
  assumes c0: "c$0 = (0::'a::idom)"
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3431
  shows "(a oo c)^n = a^n oo c"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3432
proof (cases n)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3433
  case 0
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3434
  then show ?thesis by simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3435
next
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3436
  case (Suc m)
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  3437
  have th0: "a^n = prod (\<lambda>k. a) {0..m}" "(a oo c) ^ n = prod (\<lambda>k. a oo c) {0..m}"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  3438
    by (simp_all add: prod_constant Suc)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3439
  then show ?thesis
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  3440
    by (simp add: fps_compose_prod_distrib[OF c0])
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3441
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3442
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3443
lemma fps_compose_uminus: "- (a::'a::ring_1 fps) oo c = - (a oo c)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3444
  by (simp add: fps_eq_iff fps_compose_nth field_simps sum_negf[symmetric])
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3445
    
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3446
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
  3447
  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
  3448
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3449
lemma fps_X_fps_compose: "fps_X oo a = Abs_fps (\<lambda>n. if n = 0 then (0::'a::comm_ring_1) else a$n)"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3450
  by (simp add: fps_eq_iff fps_compose_nth mult_delta_left sum.delta)
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3451
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3452
lemma fps_inverse_compose:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3453
  assumes b0: "(b$0 :: 'a::field) = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3454
    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
  3455
  shows "inverse a oo b = inverse (a oo b)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3456
proof -
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3457
  let ?ia = "inverse a"
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3458
  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
  3459
  let ?iab = "inverse ?ab"
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3460
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3461
  from a0 have ia0: "?ia $ 0 \<noteq> 0" by simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3462
  from a0 have ab0: "?ab $ 0 \<noteq> 0" by (simp add: fps_compose_def)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3463
  have "(?ia oo b) *  (a oo b) = 1"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3464
    unfolding fps_compose_mult_distrib[OF b0, symmetric]
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3465
    unfolding inverse_mult_eq_1[OF a0]
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3466
    fps_compose_1 ..
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3467
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3468
  then have "(?ia oo b) *  (a oo b) * ?iab  = 1 * ?iab" by simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3469
  then have "(?ia oo b) *  (?iab * (a oo b))  = ?iab" by simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3470
  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
  3471
qed
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3472
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3473
lemma fps_divide_compose:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3474
  assumes c0: "(c$0 :: 'a::field) = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3475
    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
  3476
  shows "(a/b) oo c = (a oo c) / (b oo c)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3477
    using b0 c0 by (simp add: fps_divide_unit fps_inverse_compose fps_compose_mult_distrib)
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3478
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3479
lemma gp:
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3480
  assumes a0: "a$0 = (0::'a::field)"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3481
  shows "(Abs_fps (\<lambda>n. 1)) oo a = 1/(1 - a)"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3482
    (is "?one oo a = _")
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3483
proof -
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3484
  have o0: "?one $ 0 \<noteq> 0" by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3485
  have th0: "(1 - fps_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
  3486
  from fps_inverse_gp[where ?'a = 'a]
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3487
  have "inverse ?one = 1 - fps_X" by (simp add: fps_eq_iff)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3488
  then have "inverse (inverse ?one) = inverse (1 - fps_X)" by simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3489
  then have th: "?one = 1/(1 - fps_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
  3490
    by (simp add: fps_divide_def)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3491
  show ?thesis
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3492
    unfolding th
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3493
    unfolding fps_divide_compose[OF a0 th0]
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3494
    fps_compose_1 fps_compose_sub_distrib fps_X_fps_compose_startby0[OF a0] ..
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3495
qed
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3496
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3497
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
  3498
  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
  3499
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3500
lemma fps_compose_radical:
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  3501
  assumes b0: "b$0 = (0::'a::field_char_0)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3502
    and ra0: "r (Suc k) (a$0) ^ Suc k = a$0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3503
    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
  3504
  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
  3505
proof -
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3506
  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
  3507
  let ?ab = "a oo b"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3508
  have ab0: "?ab $ 0 = a$0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3509
    by (simp add: fps_compose_def)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3510
  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
  3511
    by simp_all
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3512
  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
  3513
    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
  3514
  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
  3515
    unfolding fps_compose_power[OF b0]
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3516
    unfolding iffD1[OF power_radical[of a r k], OF a0 ra0]  ..
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3517
  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
  3518
  show ?thesis  .
31199
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3519
qed
10d413b08fa7 FPS composition distributes over inverses, division and arbitrary nth roots. General geometric series theorem
chaieb
parents: 31148
diff changeset
  3520
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3521
lemma fps_const_mult_apply_left: "fps_const c * (a oo b) = (fps_const c * a) oo b"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3522
  by (simp add: fps_eq_iff fps_compose_nth sum_distrib_left mult.assoc)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3523
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3524
lemma fps_const_mult_apply_right:
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3525
  "(a oo b) * fps_const (c::'a::comm_semiring_1) = (fps_const c * a) oo b"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  3526
  by (auto simp add: fps_const_mult_apply_left mult.commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3527
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  3528
lemma fps_compose_assoc:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3529
  assumes c0: "c$0 = (0::'a::idom)"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3530
    and b0: "b$0 = 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3531
  shows "a oo (b oo c) = a oo b oo c" (is "?l = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3532
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3533
  have "?l$n = ?r$n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3534
  proof -
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3535
    have "?l$n = (sum (\<lambda>i. (fps_const (a$i) * b^i) oo c) {0..n})$n"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3536
      by (simp add: fps_compose_nth fps_compose_power[OF c0] fps_const_mult_apply_left
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3537
        sum_distrib_left mult.assoc fps_sum_nth)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3538
    also have "\<dots> = ((sum (\<lambda>i. fps_const (a$i) * b^i) {0..n}) oo c)$n"
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3539
      by (simp add: fps_compose_sum_distrib)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3540
    also have "\<dots> = ?r$n"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3541
      apply (simp add: fps_compose_nth fps_sum_nth sum_distrib_right mult.assoc)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3542
      apply (rule sum.cong)
57418
6ab1c7cb0b8d fact consolidation
haftmann
parents: 57129
diff changeset
  3543
      apply (rule refl)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3544
      apply (rule sum.mono_neutral_right)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3545
      apply (auto simp add: not_le)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3546
      apply (erule startsby_zero_power_prefix[OF b0, rule_format])
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3547
      done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3548
    finally show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3549
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3550
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3551
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3552
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3553
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3554
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3555
lemma fps_X_power_compose:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3556
  assumes a0: "a$0=0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3557
  shows "fps_X^k oo a = (a::'a::idom fps)^k"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3558
  (is "?l = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3559
proof (cases k)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3560
  case 0
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3561
  then show ?thesis by simp
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3562
next
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3563
  case (Suc h)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3564
  have "?l $ n = ?r $n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3565
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3566
    consider "k > n" | "k \<le> n" by arith
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3567
    then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3568
    proof cases
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3569
      case 1
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3570
      then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3571
        using a0 startsby_zero_power_prefix[OF a0] Suc
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3572
        by (simp add: fps_compose_nth del: power_Suc)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3573
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3574
      case 2
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3575
      then show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3576
        by (simp add: fps_compose_nth mult_delta_left sum.delta)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3577
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3578
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3579
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3580
    unfolding fps_eq_iff by blast
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3581
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3582
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3583
lemma fps_inv_right:
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3584
  assumes a0: "a$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3585
    and a1: "a$1 \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3586
  shows "a oo fps_inv a = fps_X"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3587
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3588
  let ?ia = "fps_inv a"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3589
  let ?iaa = "a oo fps_inv a"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3590
  have th0: "?ia $ 0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3591
    by (simp add: fps_inv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3592
  have th1: "?iaa $ 0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3593
    using a0 a1 by (simp add: fps_inv_def fps_compose_nth)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3594
  have th2: "fps_X$0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3595
    by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3596
  from fps_inv[OF a0 a1] have "a oo (fps_inv a oo a) = a oo fps_X"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3597
    by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3598
  then have "(a oo fps_inv a) oo a = fps_X oo a"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3599
    by (simp add: fps_compose_assoc[OF a0 th0] fps_X_fps_compose_startby0[OF a0])
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3600
  with fps_compose_inj_right[OF a0 a1] show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3601
    by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3602
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3603
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3604
lemma fps_inv_deriv:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3605
  assumes a0: "a$0 = (0::'a::field)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3606
    and a1: "a$1 \<noteq> 0"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3607
  shows "fps_deriv (fps_inv a) = inverse (fps_deriv a oo fps_inv a)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3608
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3609
  let ?ia = "fps_inv a"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3610
  let ?d = "fps_deriv a oo ?ia"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3611
  let ?dia = "fps_deriv ?ia"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3612
  have ia0: "?ia$0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3613
    by (simp add: fps_inv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3614
  have th0: "?d$0 \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3615
    using a1 by (simp add: fps_compose_nth)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3616
  from fps_inv_right[OF a0 a1] have "?d * ?dia = 1"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3617
    by (simp add: fps_compose_deriv[OF ia0, of a, symmetric] )
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3618
  then have "inverse ?d * ?d * ?dia = inverse ?d * 1"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3619
    by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3620
  with inverse_mult_eq_1 [OF th0] show "?dia = inverse ?d"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3621
    by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3622
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3623
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3624
lemma fps_inv_idempotent:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3625
  assumes a0: "a$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3626
    and a1: "a$1 \<noteq> 0"
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3627
  shows "fps_inv (fps_inv a) = a"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3628
proof -
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3629
  let ?r = "fps_inv"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3630
  have ra0: "?r a $ 0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3631
    by (simp add: fps_inv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3632
  from a1 have ra1: "?r a $ 1 \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3633
    by (simp add: fps_inv_def field_simps)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3634
  have fps_X0: "fps_X$0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3635
    by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3636
  from fps_inv[OF ra0 ra1] have "?r (?r a) oo ?r a = fps_X" .
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3637
  then have "?r (?r a) oo ?r a oo a = fps_X oo a"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3638
    by simp
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3639
  then have "?r (?r a) oo (?r a oo a) = a"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3640
    unfolding fps_X_fps_compose_startby0[OF a0]
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3641
    unfolding fps_compose_assoc[OF a0 ra0, symmetric] .
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3642
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3643
    unfolding fps_inv[OF a0 a1] by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3644
qed
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3645
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3646
lemma fps_ginv_ginv:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3647
  assumes a0: "a$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3648
    and a1: "a$1 \<noteq> 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3649
    and c0: "c$0 = 0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3650
    and  c1: "c$1 \<noteq> 0"
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3651
  shows "fps_ginv b (fps_ginv c a) = b oo a oo fps_inv c"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3652
proof -
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3653
  let ?r = "fps_ginv"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3654
  from c0 have rca0: "?r c a $0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3655
    by (simp add: fps_ginv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3656
  from a1 c1 have rca1: "?r c a $ 1 \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3657
    by (simp add: fps_ginv_def field_simps)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3658
  from fps_ginv[OF rca0 rca1]
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3659
  have "?r b (?r c a) oo ?r c a = b" .
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3660
  then have "?r b (?r c a) oo ?r c a oo a = b oo a"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3661
    by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3662
  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
  3663
    apply (subst fps_compose_assoc)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3664
    using a0 c0
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3665
    apply (auto simp add: fps_ginv_def)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3666
    done
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3667
  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
  3668
    unfolding fps_ginv[OF a0 a1] .
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3669
  then have "?r b (?r c a) oo c oo fps_inv c= b oo a oo fps_inv c"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3670
    by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3671
  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
  3672
    apply (subst fps_compose_assoc)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3673
    using a0 c0
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3674
    apply (auto simp add: fps_inv_def)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3675
    done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3676
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3677
    unfolding fps_inv_right[OF c0 c1] by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3678
qed
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3679
32410
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3680
lemma fps_ginv_deriv:
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  3681
  assumes a0:"a$0 = (0::'a::field)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3682
    and a1: "a$1 \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3683
  shows "fps_deriv (fps_ginv b a) = (fps_deriv b / fps_deriv a) oo fps_ginv fps_X a"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3684
proof -
32410
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3685
  let ?ia = "fps_ginv b a"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3686
  let ?ifps_Xa = "fps_ginv fps_X a"
32410
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3687
  let ?d = "fps_deriv"
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3688
  let ?dia = "?d ?ia"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3689
  have ifps_Xa0: "?ifps_Xa $ 0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3690
    by (simp add: fps_ginv_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3691
  have da0: "?d a $ 0 \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3692
    using a1 by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3693
  from fps_ginv[OF a0 a1, of b] have "?d (?ia oo a) = fps_deriv b"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3694
    by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3695
  then have "(?d ?ia oo a) * ?d a = ?d b"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3696
    unfolding fps_compose_deriv[OF a0] .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3697
  then have "(?d ?ia oo a) * ?d a * inverse (?d a) = ?d b * inverse (?d a)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3698
    by simp
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3699
  with a1 have "(?d ?ia oo a) * (inverse (?d a) * ?d a) = ?d b / ?d a"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3700
    by (simp add: fps_divide_unit)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3701
  then have "(?d ?ia oo a) oo ?ifps_Xa =  (?d b / ?d a) oo ?ifps_Xa"
32410
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3702
    unfolding inverse_mult_eq_1[OF da0] by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3703
  then have "?d ?ia oo (a oo ?ifps_Xa) =  (?d b / ?d a) oo ?ifps_Xa"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3704
    unfolding fps_compose_assoc[OF ifps_Xa0 a0] .
32410
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3705
  then show ?thesis unfolding fps_inv_ginv[symmetric]
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3706
    unfolding fps_inv_right[OF a0 a1] by simp
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3707
qed
624bd2ea7c1e Derivative of general reverses
chaieb
parents: 31075
diff changeset
  3708
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3709
lemma fps_compose_linear:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3710
  "fps_compose (f :: 'a :: comm_ring_1 fps) (fps_const c * fps_X) = Abs_fps (\<lambda>n. c^n * f $ n)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  3711
  by (simp add: fps_eq_iff fps_compose_def power_mult_distrib
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  3712
                if_distrib sum.delta' cong: if_cong)
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3713
              
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3714
lemma fps_compose_uminus': 
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3715
  "fps_compose f (-fps_X :: 'a :: comm_ring_1 fps) = Abs_fps (\<lambda>n. (-1)^n * f $ n)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3716
  using fps_compose_linear[of f "-1"] 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3717
  by (simp only: fps_const_neg [symmetric] fps_const_1_eq_1) simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3718
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3719
subsection \<open>Elementary series\<close>
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3720
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3721
subsubsection \<open>Exponential series\<close>
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3722
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3723
definition "fps_exp x = Abs_fps (\<lambda>n. x^n / of_nat (fact n))"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3724
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3725
lemma fps_exp_deriv[simp]: "fps_deriv (fps_exp a) = fps_const (a::'a::field_char_0) * fps_exp a" 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3726
  (is "?l = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3727
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3728
  have "?l$n = ?r $ n" for n
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3729
    apply (auto simp add: fps_exp_def field_simps power_Suc[symmetric]
63367
6c731c8b7f03 simplified definitions of combinatorial functions
haftmann
parents: 63317
diff changeset
  3730
      simp del: fact_Suc of_nat_Suc power_Suc)
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  3731
    apply (simp add: field_simps)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3732
    done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3733
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3734
    by (simp add: fps_eq_iff)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3735
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3736
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3737
lemma fps_exp_unique_ODE:
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3738
  "fps_deriv a = fps_const c * a \<longleftrightarrow> a = fps_const (a$0) * fps_exp (c::'a::field_char_0)"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3739
  (is "?lhs \<longleftrightarrow> ?rhs")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3740
proof
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3741
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3742
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3743
    from that have th: "\<And>n. a $ Suc n = c * a$n / of_nat (Suc n)"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3744
      by (simp add: fps_deriv_def fps_eq_iff field_simps del: of_nat_Suc)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3745
    have th': "a$n = a$0 * c ^ n/ (fact n)" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3746
    proof (induct n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3747
      case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3748
      then show ?case by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3749
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3750
      case Suc
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3751
      then show ?case
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3752
        unfolding th
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3753
        using fact_gt_zero
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3754
        apply (simp add: field_simps del: of_nat_Suc fact_Suc)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3755
        apply simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3756
        done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3757
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3758
    show ?thesis
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3759
      by (auto simp add: fps_eq_iff fps_const_mult_left fps_exp_def intro: th')
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3760
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3761
  show ?lhs if ?rhs
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3762
    using that by (metis fps_exp_deriv fps_deriv_mult_const_left mult.left_commute)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3763
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3764
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3765
lemma fps_exp_add_mult: "fps_exp (a + b) = fps_exp (a::'a::field_char_0) * fps_exp b" (is "?l = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3766
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3767
  have "fps_deriv ?r = fps_const (a + b) * ?r"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  3768
    by (simp add: fps_const_add[symmetric] field_simps del: fps_const_add)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3769
  then have "?r = ?l"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3770
    by (simp only: fps_exp_unique_ODE) (simp add: fps_mult_nth fps_exp_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3771
  then show ?thesis ..
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3772
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3773
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3774
lemma fps_exp_nth[simp]: "fps_exp a $ n = a^n / of_nat (fact n)"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3775
  by (simp add: fps_exp_def)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3776
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3777
lemma fps_exp_0[simp]: "fps_exp (0::'a::field) = 1"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3778
  by (simp add: fps_eq_iff power_0_left)
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3779
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3780
lemma fps_exp_neg: "fps_exp (- a) = inverse (fps_exp (a::'a::field_char_0))"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3781
proof -
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3782
  from fps_exp_add_mult[of a "- a"] have th0: "fps_exp a * fps_exp (- a) = 1" by simp
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  3783
  from fps_inverse_unique[OF th0] show ?thesis by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3784
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3785
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3786
lemma fps_exp_nth_deriv[simp]: 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3787
  "fps_nth_deriv n (fps_exp (a::'a::field_char_0)) = (fps_const a)^n * (fps_exp a)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  3788
  by (induct n) auto
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3789
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3790
lemma fps_X_compose_fps_exp[simp]: "fps_X oo fps_exp (a::'a::field) = fps_exp a - 1"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3791
  by (simp add: fps_eq_iff fps_X_fps_compose)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3792
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3793
lemma fps_inv_fps_exp_compose:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3794
  assumes a: "a \<noteq> 0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3795
  shows "fps_inv (fps_exp a - 1) oo (fps_exp a - 1) = fps_X"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3796
    and "(fps_exp a - 1) oo fps_inv (fps_exp a - 1) = fps_X"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3797
proof -
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3798
  let ?b = "fps_exp a - 1"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3799
  have b0: "?b $ 0 = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3800
    by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3801
  have b1: "?b $ 1 \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3802
    by (simp add: a)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3803
  from fps_inv[OF b0 b1] show "fps_inv (fps_exp a - 1) oo (fps_exp a - 1) = fps_X" .
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3804
  from fps_inv_right[OF b0 b1] show "(fps_exp a - 1) oo fps_inv (fps_exp a - 1) = fps_X" .
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3805
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3806
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3807
lemma fps_exp_power_mult: "(fps_exp (c::'a::field_char_0))^n = fps_exp (of_nat n * c)"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3808
  by (induct n) (auto simp add: field_simps fps_exp_add_mult)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3809
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3810
lemma radical_fps_exp:
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3811
  assumes r: "r (Suc k) 1 = 1"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3812
  shows "fps_radical r (Suc k) (fps_exp (c::'a::field_char_0)) = fps_exp (c / of_nat (Suc k))"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3813
proof -
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3814
  let ?ck = "(c / of_nat (Suc k))"
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3815
  let ?r = "fps_radical r (Suc k)"
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3816
  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
  3817
    by (simp_all del: of_nat_Suc)
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3818
  have th0: "fps_exp ?ck ^ (Suc k) = fps_exp c" unfolding fps_exp_power_mult eq0 ..
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3819
  have th: "r (Suc k) (fps_exp c $0) ^ Suc k = fps_exp c $ 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3820
    "r (Suc k) (fps_exp c $ 0) = fps_exp ?ck $ 0" "fps_exp c $ 0 \<noteq> 0" using r by simp_all
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3821
  from th0 radical_unique[where r=r and k=k, OF th] show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3822
    by auto
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3823
qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3824
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3825
lemma fps_exp_compose_linear [simp]: 
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3826
  "fps_exp (d::'a::field_char_0) oo (fps_const c * fps_X) = fps_exp (c * d)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3827
  by (simp add: fps_compose_linear fps_exp_def fps_eq_iff power_mult_distrib)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3828
  
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3829
lemma fps_fps_exp_compose_minus [simp]: 
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3830
  "fps_compose (fps_exp c) (-fps_X) = fps_exp (-c :: 'a :: field_char_0)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3831
  using fps_exp_compose_linear[of c "-1 :: 'a"] 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3832
  unfolding fps_const_neg [symmetric] fps_const_1_eq_1 by simp
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3833
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3834
lemma fps_exp_eq_iff [simp]: "fps_exp c = fps_exp d \<longleftrightarrow> c = (d :: 'a :: field_char_0)"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3835
proof
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3836
  assume "fps_exp c = fps_exp d"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3837
  from arg_cong[of _ _ "\<lambda>F. F $ 1", OF this] show "c = d" by simp
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3838
qed simp_all
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3839
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3840
lemma fps_exp_eq_fps_const_iff [simp]: 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3841
  "fps_exp (c :: 'a :: field_char_0) = fps_const c' \<longleftrightarrow> c = 0 \<and> c' = 1"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3842
proof
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3843
  assume "c = 0 \<and> c' = 1"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3844
  thus "fps_exp c = fps_const c'" by (auto simp: fps_eq_iff)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3845
next
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3846
  assume "fps_exp c = fps_const c'"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3847
  from arg_cong[of _ _ "\<lambda>F. F $ 1", OF this] arg_cong[of _ _ "\<lambda>F. F $ 0", OF this] 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3848
    show "c = 0 \<and> c' = 1" by simp_all
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3849
qed
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3850
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3851
lemma fps_exp_neq_0 [simp]: "\<not>fps_exp (c :: 'a :: field_char_0) = 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3852
  unfolding fps_const_0_eq_0 [symmetric] fps_exp_eq_fps_const_iff by simp  
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3853
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3854
lemma fps_exp_eq_1_iff [simp]: "fps_exp (c :: 'a :: field_char_0) = 1 \<longleftrightarrow> c = 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3855
  unfolding fps_const_1_eq_1 [symmetric] fps_exp_eq_fps_const_iff by simp
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3856
    
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3857
lemma fps_exp_neq_numeral_iff [simp]: 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3858
  "fps_exp (c :: 'a :: field_char_0) = numeral n \<longleftrightarrow> c = 0 \<and> n = Num.One"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3859
  unfolding numeral_fps_const fps_exp_eq_fps_const_iff by simp
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3860
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  3861
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3862
subsubsection \<open>Logarithmic series\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3863
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3864
lemma Abs_fps_if_0:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3865
  "Abs_fps (\<lambda>n. if n = 0 then (v::'a::ring_1) else f n) =
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3866
    fps_const v + fps_X * Abs_fps (\<lambda>n. f (Suc n))"
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3867
  by (auto simp add: fps_eq_iff)
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3868
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3869
definition fps_ln :: "'a::field_char_0 \<Rightarrow> 'a fps"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3870
  where "fps_ln c = fps_const (1/c) * Abs_fps (\<lambda>n. if n = 0 then 0 else (- 1) ^ (n - 1) / of_nat n)"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3871
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3872
lemma fps_ln_deriv: "fps_deriv (fps_ln c) = fps_const (1/c) * inverse (1 + fps_X)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3873
  unfolding fps_inverse_fps_X_plus1
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3874
  by (simp add: fps_ln_def fps_eq_iff del: of_nat_Suc)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3875
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3876
lemma fps_ln_nth: "fps_ln c $ n = (if n = 0 then 0 else 1/c * ((- 1) ^ (n - 1) / of_nat n))"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3877
  by (simp add: fps_ln_def field_simps)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3878
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3879
lemma fps_ln_0 [simp]: "fps_ln c $ 0 = 0" by (simp add: fps_ln_def)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3880
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3881
lemma fps_ln_fps_exp_inv:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3882
  fixes a :: "'a::field_char_0"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3883
  assumes a: "a \<noteq> 0"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3884
  shows "fps_ln a = fps_inv (fps_exp a - 1)"  (is "?l = ?r")
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3885
proof -
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3886
  let ?b = "fps_exp a - 1"
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3887
  have b0: "?b $ 0 = 0" by simp
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3888
  have b1: "?b $ 1 \<noteq> 0" by (simp add: a)
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3889
  have "fps_deriv (fps_exp a - 1) oo fps_inv (fps_exp a - 1) =
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3890
    (fps_const a * (fps_exp a - 1) + fps_const a) oo fps_inv (fps_exp a - 1)"
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  3891
    by (simp add: field_simps)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3892
  also have "\<dots> = fps_const a * (fps_X + 1)"
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3893
    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
  3894
    apply (simp add: field_simps)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3895
    done
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3896
  finally have eq: "fps_deriv (fps_exp a - 1) oo fps_inv (fps_exp a - 1) = fps_const a * (fps_X + 1)" .
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3897
  from fps_inv_deriv[OF b0 b1, unfolded eq]
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3898
  have "fps_deriv (fps_inv ?b) = fps_const (inverse a) / (fps_X + 1)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3899
    using a by (simp add: fps_const_inverse eq fps_divide_def fps_inverse_mult)
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  3900
  then have "fps_deriv ?l = fps_deriv ?r"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3901
    by (simp add: fps_ln_deriv add.commute fps_divide_def divide_inverse)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3902
  then show ?thesis unfolding fps_deriv_eq_iff
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3903
    by (simp add: fps_ln_nth fps_inv_def)
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3904
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  3905
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3906
lemma fps_ln_mult_add:
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3907
  assumes c0: "c\<noteq>0"
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3908
    and d0: "d\<noteq>0"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3909
  shows "fps_ln c + fps_ln d = fps_const (c+d) * fps_ln (c*d)"
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3910
  (is "?r = ?l")
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3911
proof-
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  3912
  from c0 d0 have eq: "1/c + 1/d = (c+d)/(c*d)" by (simp add: field_simps)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3913
  have "fps_deriv ?r = fps_const (1/c + 1/d) * inverse (1 + fps_X)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3914
    by (simp add: fps_ln_deriv fps_const_add[symmetric] algebra_simps del: fps_const_add)
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3915
  also have "\<dots> = fps_deriv ?l"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3916
    apply (simp add: fps_ln_deriv)
52903
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3917
    apply (simp add: fps_eq_iff eq)
6c89225ddeba tuned proofs;
wenzelm
parents: 52902
diff changeset
  3918
    done
31369
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3919
  finally show ?thesis
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3920
    unfolding fps_deriv_eq_iff by simp
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3921
qed
8b460fd12100 Reverses idempotent; radical of E; generalized logarithm;
chaieb
parents: 31199
diff changeset
  3922
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3923
lemma fps_X_dvd_fps_ln [simp]: "fps_X dvd fps_ln c"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3924
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3925
  have "fps_ln c = fps_X * Abs_fps (\<lambda>n. (-1) ^ n / (of_nat (Suc n) * c))"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3926
    by (intro fps_ext) (auto simp: fps_ln_def of_nat_diff)
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3927
  thus ?thesis by simp
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3928
qed
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  3929
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3930
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3931
subsubsection \<open>Binomial series\<close>
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3932
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3933
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
  3934
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3935
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
  3936
  by (simp add: fps_binomial_def)
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3937
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3938
lemma fps_binomial_ODE_unique:
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3939
  fixes c :: "'a::field_char_0"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3940
  shows "fps_deriv a = (fps_const c * a) / (1 + fps_X) \<longleftrightarrow> a = fps_const (a$0) * fps_binomial c"
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3941
  (is "?lhs \<longleftrightarrow> ?rhs")
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3942
proof
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3943
  let ?da = "fps_deriv a"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  3944
  let ?x1 = "(1 + fps_X):: 'a fps"
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3945
  let ?l = "?x1 * ?da"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3946
  let ?r = "fps_const c * a"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3947
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3948
  have eq: "?l = ?r \<longleftrightarrow> ?lhs"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3949
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3950
    have x10: "?x1 $ 0 \<noteq> 0" by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3951
    have "?l = ?r \<longleftrightarrow> inverse ?x1 * ?l = inverse ?x1 * ?r" by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3952
    also have "\<dots> \<longleftrightarrow> ?da = (fps_const c * a) / ?x1"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3953
      apply (simp only: fps_divide_def  mult.assoc[symmetric] inverse_mult_eq_1[OF x10])
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3954
      apply (simp add: field_simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3955
      done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3956
    finally show ?thesis .
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3957
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3958
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3959
  show ?rhs if ?lhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3960
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3961
    from eq that have h: "?l = ?r" ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3962
    have th0: "a$ Suc n = ((c - of_nat n) / of_nat (Suc n)) * a $n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3963
    proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3964
      from h have "?l $ n = ?r $ n" by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3965
      then show ?thesis
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  3966
        apply (simp add: field_simps del: of_nat_Suc)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3967
        apply (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3968
        apply (simp_all add: field_simps del: of_nat_Suc)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3969
        done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3970
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3971
    have th1: "a $ n = (c gchoose n) * a $ 0" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3972
    proof (induct n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3973
      case 0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3974
      then show ?case by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3975
    next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3976
      case (Suc m)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3977
      then show ?case
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3978
        unfolding th0
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3979
        apply (simp add: field_simps del: of_nat_Suc)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3980
        unfolding mult.assoc[symmetric] gbinomial_mult_1
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3981
        apply (simp add: field_simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3982
        done
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3983
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3984
    show ?thesis
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3985
      apply (simp add: fps_eq_iff)
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  3986
      apply (subst th1)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3987
      apply (simp add: field_simps)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  3988
      done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3989
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3990
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3991
  show ?lhs if ?rhs
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3992
  proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3993
    have th00: "x * (a $ 0 * y) = a $ 0 * (x * y)" for x y
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  3994
      by (simp add: mult.commute)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  3995
    have "?l = ?r"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3996
      apply (subst \<open>?rhs\<close>)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  3997
      apply (subst (2) \<open>?rhs\<close>)
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  3998
      apply (clarsimp simp add: fps_eq_iff field_simps)
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  3999
      unfolding mult.assoc[symmetric] th00 gbinomial_mult_1
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4000
      apply (simp add: field_simps gbinomial_mult_1)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4001
      done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4002
    with eq show ?thesis ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4003
  qed
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4004
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4005
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4006
lemma fps_binomial_ODE_unique':
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4007
  "(fps_deriv a = fps_const c * a / (1 + fps_X) \<and> a $ 0 = 1) \<longleftrightarrow> (a = fps_binomial c)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4008
  by (subst fps_binomial_ODE_unique) auto
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4009
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4010
lemma fps_binomial_deriv: "fps_deriv (fps_binomial c) = fps_const c * fps_binomial c / (1 + fps_X)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4011
proof -
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4012
  let ?a = "fps_binomial c"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4013
  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
  4014
  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
  4015
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4016
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4017
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
  4018
proof -
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4019
  let ?P = "?r - ?l"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4020
  let ?b = "fps_binomial"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4021
  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
  4022
  have "fps_deriv ?P = ?db c * ?b d + ?b c * ?db d - ?db (c + d)"  by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4023
  also have "\<dots> = inverse (1 + fps_X) *
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4024
      (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
  4025
    unfolding fps_binomial_deriv
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  4026
    by (simp add: fps_divide_def field_simps)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4027
  also have "\<dots> = (fps_const (c + d)/ (1 + fps_X)) * ?P"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4028
    by (simp add: field_simps fps_divide_unit fps_const_add[symmetric] del: fps_const_add)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4029
  finally have th0: "fps_deriv ?P = fps_const (c+d) * ?P / (1 + fps_X)"
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4030
    by (simp add: fps_divide_def)
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4031
  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
  4032
    unfolding fps_binomial_ODE_unique[symmetric]
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4033
    using th0 by simp
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4034
  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
  4035
  then show ?thesis by simp
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4036
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4037
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4038
lemma fps_binomial_minus_one: "fps_binomial (- 1) = inverse (1 + fps_X)"
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4039
  (is "?l = inverse ?r")
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4040
proof-
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4041
  have th: "?r$0 \<noteq> 0" by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4042
  have th': "fps_deriv (inverse ?r) = fps_const (- 1) * inverse ?r / (1 + fps_X)"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4043
    by (simp add: fps_inverse_deriv[OF th] fps_divide_def
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57418
diff changeset
  4044
      power2_eq_square mult.commute fps_const_neg[symmetric] del: fps_const_neg)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4045
  have eq: "inverse ?r $ 0 = 1"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4046
    by (simp add: fps_inverse_def)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4047
  from iffD1[OF fps_binomial_ODE_unique[of "inverse (1 + fps_X)" "- 1"] th'] eq
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4048
  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
  4049
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4050
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4051
lemma fps_binomial_of_nat: "fps_binomial (of_nat n) = (1 + fps_X :: 'a :: field_char_0 fps) ^ n"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4052
proof (cases "n = 0")
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4053
  case [simp]: True
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4054
  have "fps_deriv ((1 + fps_X) ^ n :: 'a fps) = 0" by simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4055
  also have "\<dots> = fps_const (of_nat n) * (1 + fps_X) ^ n / (1 + fps_X)" by (simp add: fps_binomial_def)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4056
  finally show ?thesis by (subst sym, subst fps_binomial_ODE_unique' [symmetric]) simp_all
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4057
next
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4058
  case False
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4059
  have "fps_deriv ((1 + fps_X) ^ n :: 'a fps) = fps_const (of_nat n) * (1 + fps_X) ^ (n - 1)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4060
    by (simp add: fps_deriv_power)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4061
  also have "(1 + fps_X :: 'a fps) $ 0 \<noteq> 0" by simp
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4062
  hence "(1 + fps_X :: 'a fps) \<noteq> 0" by (intro notI) (simp only: , simp)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4063
  with False have "(1 + fps_X :: 'a fps) ^ (n - 1) = (1 + fps_X) ^ n / (1 + fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4064
    by (cases n) (simp_all )
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4065
  also have "fps_const (of_nat n :: 'a) * ((1 + fps_X) ^ n / (1 + fps_X)) =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4066
               fps_const (of_nat n) * (1 + fps_X) ^ n / (1 + fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4067
    by (simp add: unit_div_mult_swap)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4068
  finally show ?thesis
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4069
    by (subst sym, subst fps_binomial_ODE_unique' [symmetric]) (simp_all add: fps_power_nth)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4070
qed
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4071
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4072
lemma fps_binomial_0 [simp]: "fps_binomial 0 = 1"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4073
  using fps_binomial_of_nat[of 0] by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4074
  
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4075
lemma fps_binomial_power: "fps_binomial a ^ n = fps_binomial (of_nat n * a)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4076
  by (induction n) (simp_all add: fps_binomial_add_mult ring_distribs)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4077
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4078
lemma fps_binomial_1: "fps_binomial 1 = 1 + fps_X"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4079
  using fps_binomial_of_nat[of 1] by simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4080
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4081
lemma fps_binomial_minus_of_nat:
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4082
  "fps_binomial (- of_nat n) = inverse ((1 + fps_X :: 'a :: field_char_0 fps) ^ n)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4083
  by (rule sym, rule fps_inverse_unique)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4084
     (simp add: fps_binomial_of_nat [symmetric] fps_binomial_add_mult [symmetric])
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4085
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4086
lemma one_minus_const_fps_X_power:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4087
  "c \<noteq> 0 \<Longrightarrow> (1 - fps_const c * fps_X) ^ n =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4088
     fps_compose (fps_binomial (of_nat n)) (-fps_const c * fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4089
  by (subst fps_binomial_of_nat)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4090
     (simp add: fps_compose_power [symmetric] fps_compose_add_distrib fps_const_neg [symmetric] 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4091
           del: fps_const_neg)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4092
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4093
lemma one_minus_fps_X_const_neg_power:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4094
  "inverse ((1 - fps_const c * fps_X) ^ n) = 
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4095
       fps_compose (fps_binomial (-of_nat n)) (-fps_const c * fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4096
proof (cases "c = 0")
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4097
  case False
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4098
  thus ?thesis
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4099
  by (subst fps_binomial_minus_of_nat)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4100
     (simp add: fps_compose_power [symmetric] fps_inverse_compose fps_compose_add_distrib
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4101
                fps_const_neg [symmetric] del: fps_const_neg)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4102
qed simp
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4103
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4104
lemma fps_X_plus_const_power:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4105
  "c \<noteq> 0 \<Longrightarrow> (fps_X + fps_const c) ^ n =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4106
     fps_const (c^n) * fps_compose (fps_binomial (of_nat n)) (fps_const (inverse c) * fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4107
  by (subst fps_binomial_of_nat)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4108
     (simp add: fps_compose_power [symmetric] fps_binomial_of_nat fps_compose_add_distrib
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4109
                fps_const_power [symmetric] power_mult_distrib [symmetric] 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4110
                algebra_simps inverse_mult_eq_1' del: fps_const_power)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4111
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4112
lemma fps_X_plus_const_neg_power:
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4113
  "c \<noteq> 0 \<Longrightarrow> inverse ((fps_X + fps_const c) ^ n) =
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4114
     fps_const (inverse c^n) * fps_compose (fps_binomial (-of_nat n)) (fps_const (inverse c) * fps_X)"
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4115
  by (subst fps_binomial_minus_of_nat)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4116
     (simp add: fps_compose_power [symmetric] fps_binomial_of_nat fps_compose_add_distrib
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4117
                fps_const_power [symmetric] power_mult_distrib [symmetric] fps_inverse_compose 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4118
                algebra_simps fps_const_inverse [symmetric] fps_inverse_mult [symmetric]
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4119
                fps_inverse_power [symmetric] inverse_mult_eq_1'
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4120
           del: fps_const_power)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4121
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4122
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4123
lemma one_minus_const_fps_X_neg_power':
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4124
  "n > 0 \<Longrightarrow> inverse ((1 - fps_const (c :: 'a :: field_char_0) * fps_X) ^ n) =
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4125
       Abs_fps (\<lambda>k. of_nat ((n + k - 1) choose k) * c^k)"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4126
  apply (rule fps_ext)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4127
  apply (subst one_minus_fps_X_const_neg_power, subst fps_const_neg, subst fps_compose_linear)
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4128
  apply (simp add: power_mult_distrib [symmetric] mult.assoc [symmetric] 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4129
                   gbinomial_minus binomial_gbinomial of_nat_diff)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4130
  done
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4131
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4132
text \<open>Vandermonde's Identity as a consequence.\<close>
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4133
lemma gbinomial_Vandermonde:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4134
  "sum (\<lambda>k. (a gchoose k) * (b gchoose (n - k))) {0..n} = (a + b) gchoose n"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4135
proof -
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4136
  let ?ba = "fps_binomial a"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4137
  let ?bb = "fps_binomial b"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4138
  let ?bab = "fps_binomial (a + b)"
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4139
  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
  4140
  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
  4141
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4142
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4143
lemma binomial_Vandermonde:
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4144
  "sum (\<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
  4145
  using gbinomial_Vandermonde[of "(of_nat a)" "of_nat b" n]
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61610
diff changeset
  4146
  by (simp only: binomial_gbinomial[symmetric] of_nat_mult[symmetric]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4147
                 of_nat_sum[symmetric] of_nat_add[symmetric] of_nat_eq_iff)
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4148
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4149
lemma binomial_Vandermonde_same: "sum (\<lambda>k. (n choose k)\<^sup>2) {0..n} = (2 * n) choose n"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4150
  using binomial_Vandermonde[of n n n, symmetric]
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4151
  unfolding mult_2
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4152
  apply (simp add: power2_eq_square)
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4153
  apply (rule sum.cong)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4154
  apply (auto intro:  binomial_symmetric)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4155
  done
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4156
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4157
lemma Vandermonde_pochhammer_lemma:
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4158
  fixes a :: "'a::field_char_0"
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4159
  assumes b: "\<forall>j\<in>{0 ..<n}. b \<noteq> of_nat j"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4160
  shows "sum (\<lambda>k. (pochhammer (- a) k * pochhammer (- (of_nat n)) k) /
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4161
      (of_nat (fact k) * pochhammer (b - of_nat n + 1) k)) {0..n} =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4162
    pochhammer (- (a + b)) n / pochhammer (- b) n"
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4163
  (is "?l = ?r")
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4164
proof -
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4165
  let ?m1 = "\<lambda>m. (- 1 :: 'a) ^ m"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4166
  let ?f = "\<lambda>m. of_nat (fact m)"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4167
  let ?p = "\<lambda>(x::'a). pochhammer (- x)"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4168
  from b have bn0: "?p b n \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4169
    unfolding pochhammer_eq_0_iff by simp
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4170
  have th00:
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4171
    "b gchoose (n - k) =
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4172
        (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4173
      (is ?gchoose)
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4174
    "pochhammer (1 + b - of_nat n) k \<noteq> 0"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4175
      (is ?pochhammer)
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4176
    if kn: "k \<in> {0..n}" for k
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4177
  proof -
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4178
    from kn have "k \<le> n" by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4179
    have nz: "pochhammer (1 + b - of_nat n) n \<noteq> 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4180
    proof
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4181
      assume "pochhammer (1 + b - of_nat n) n = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4182
      then have c: "pochhammer (b - of_nat n + 1) n = 0"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4183
        by (simp add: algebra_simps)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4184
      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
  4185
        unfolding pochhammer_eq_0_iff by blast
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4186
      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
  4187
        by (simp add: algebra_simps)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4188
      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
  4189
        using j kn by (simp add: of_nat_diff)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4190
      with b show False using j by auto
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4191
    qed
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4192
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4193
    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
  4194
      by (rule pochhammer_neq_0_mono)
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4195
60567
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
  4196
    consider "k = 0 \<or> n = 0" | "k \<noteq> 0" "n \<noteq> 0"
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
  4197
      by blast
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4198
    then have "b gchoose (n - k) =
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4199
      (?m1 n * ?p b n * ?m1 k * ?p (of_nat n) k) / (?f n * pochhammer (b - of_nat n + 1) k)"
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4200
    proof cases
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4201
      case 1
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4202
      then show ?thesis
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4203
        using kn by (cases "k = 0") (simp_all add: gbinomial_pochhammer)
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4204
    next
60567
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
  4205
      case neq: 2
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4206
      then obtain m where m: "n = Suc m"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4207
        by (cases n) auto
60567
19c277ea65ae tuned proofs -- less digits;
wenzelm
parents: 60558
diff changeset
  4208
      from neq(1) obtain h where h: "k = Suc h"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4209
        by (cases k) auto
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4210
      show ?thesis
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4211
      proof (cases "k = n")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4212
        case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4213
        then show ?thesis
59862
44b3f4fa33ca New material and binomial fix
paulson <lp15@cam.ac.uk>
parents: 59815
diff changeset
  4214
          using pochhammer_minus'[where k=k and b=b]
44b3f4fa33ca New material and binomial fix
paulson <lp15@cam.ac.uk>
parents: 59815
diff changeset
  4215
          apply (simp add: pochhammer_same)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4216
          using bn0
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4217
          apply (simp add: field_simps power_add[symmetric])
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4218
          done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4219
      next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4220
        case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4221
        with kn have kn': "k < n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4222
          by simp
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4223
        have m1nk: "?m1 n = prod (\<lambda>i. - 1) {..m}" "?m1 k = prod (\<lambda>i. - 1) {0..h}"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4224
          by (simp_all add: prod_constant m h)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4225
        have bnz0: "pochhammer (b - of_nat n + 1) k \<noteq> 0"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4226
          using bn0 kn
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4227
          unfolding pochhammer_eq_0_iff
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4228
          apply auto
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4229
          apply (erule_tac x= "n - ka - 1" in allE)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4230
          apply (auto simp add: algebra_simps of_nat_diff)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4231
          done
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4232
        have eq1: "prod (\<lambda>k. (1::'a) + of_nat m - of_nat k) {..h} =
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4233
          prod of_nat {Suc (m - h) .. Suc m}"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4234
          using kn' h m
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4235
          by (intro prod.reindex_bij_witness[where i="\<lambda>k. Suc m - k" and j="\<lambda>k. Suc m - k"])
57129
7edb7550663e introduce more powerful reindexing rules for big operators
hoelzl
parents: 56480
diff changeset
  4236
             (auto simp: of_nat_diff)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4237
        have th1: "(?m1 k * ?p (of_nat n) k) / ?f n = 1 / of_nat(fact (n - k))"
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4238
          apply (simp add: pochhammer_minus field_simps)
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4239
          using \<open>k \<le> n\<close> apply (simp add: fact_split [of k n])
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4240
          apply (simp add: pochhammer_prod)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4241
          using prod.atLeast_lessThan_shift_bounds [where ?'a = 'a, of "\<lambda>i. 1 + of_nat i" 0 "n - k" k]
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4242
          apply (auto simp add: of_nat_diff field_simps)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4243
          done
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4244
        have th20: "?m1 n * ?p b n = prod (\<lambda>i. b - of_nat i) {0..m}"
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4245
          apply (simp add: pochhammer_minus field_simps m)
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4246
          apply (auto simp add: pochhammer_prod_rev of_nat_diff prod.atLeast_Suc_atMost_Suc_shift)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4247
          done
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4248
        have th21:"pochhammer (b - of_nat n + 1) k = prod (\<lambda>i. b - of_nat i) {n - k .. n - 1}"
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4249
          using kn apply (simp add: pochhammer_prod_rev m h prod.atLeast_Suc_atMost_Suc_shift)
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4250
          using prod.atLeast_atMost_shift_0 [of "m - h" m, where ?'a = 'a]
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4251
          apply (auto simp add: of_nat_diff field_simps)
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4252
          done
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4253
        have "?m1 n * ?p b n =
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4254
          prod (\<lambda>i. b - of_nat i) {0.. n - k - 1} * pochhammer (b - of_nat n + 1) k"
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4255
          using kn' m h unfolding th20 th21 apply simp
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4256
          apply (subst prod.union_disjoint [symmetric])
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4257
          apply auto
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4258
          apply (rule prod.cong)
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4259
          apply auto
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32456
diff changeset
  4260
          done
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4261
        then have th2: "(?m1 n * ?p b n)/pochhammer (b - of_nat n + 1) k =
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4262
          prod (\<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
  4263
          using nz' by (simp add: field_simps)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4264
        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
  4265
          ((?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
  4266
          using bnz0
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  4267
          by (simp add: field_simps)
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4268
        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
  4269
          unfolding th1 th2
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4270
          using kn' m h
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4271
          apply (simp add: field_simps gbinomial_mult_fact)
64272
f76b6dda2e56 setprod -> prod
nipkow
parents: 64267
diff changeset
  4272
          apply (rule prod.cong)
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4273
          apply auto
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4274
          done
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4275
        finally show ?thesis by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4276
      qed
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4277
    qed
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4278
    then show ?gchoose and ?pochhammer
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4279
      apply (cases "n = 0")
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4280
      using nz'
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4281
      apply auto
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4282
      done
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4283
  qed
60504
17741c71a731 tuned proofs;
wenzelm
parents: 60501
diff changeset
  4284
  have "?r = ((a + b) gchoose n) * (of_nat (fact n) / (?m1 n * pochhammer (- b) n))"
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4285
    unfolding gbinomial_pochhammer
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36311
diff changeset
  4286
    using bn0 by (auto simp add: field_simps)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4287
  also have "\<dots> = ?l"
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4288
    unfolding gbinomial_Vandermonde[symmetric]
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4289
    apply (simp add: th00)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4290
    unfolding gbinomial_pochhammer
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4291
    using bn0
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4292
    apply (simp add: sum_distrib_right sum_distrib_left field_simps)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4293
    done
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4294
  finally show ?thesis by simp
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4295
qed
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4296
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4297
lemma Vandermonde_pochhammer:
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4298
  fixes a :: "'a::field_char_0"
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4299
  assumes c: "\<forall>i \<in> {0..< n}. c \<noteq> - of_nat i"
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4300
  shows "sum (\<lambda>k. (pochhammer a k * pochhammer (- (of_nat n)) k) /
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4301
    (of_nat (fact k) * pochhammer c k)) {0..n} = pochhammer (c - a) n / pochhammer c n"
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4302
proof -
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4303
  let ?a = "- a"
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4304
  let ?b = "c + of_nat n - 1"
60558
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4305
  have h: "\<forall> j \<in>{0..< n}. ?b \<noteq> of_nat j"
4fcc6861e64f tuned proofs;
wenzelm
parents: 60504
diff changeset
  4306
    using c
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4307
    apply (auto simp add: algebra_simps of_nat_diff)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4308
    apply (erule_tac x = "n - j - 1" in ballE)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4309
    apply (auto simp add: of_nat_diff algebra_simps)
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4310
    done
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4311
  have th0: "pochhammer (- (?a + ?b)) n = (- 1)^n * pochhammer (c - a) n"
59862
44b3f4fa33ca New material and binomial fix
paulson <lp15@cam.ac.uk>
parents: 59815
diff changeset
  4312
    unfolding pochhammer_minus
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4313
    by (simp add: algebra_simps)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4314
  have th1: "pochhammer (- ?b) n = (- 1)^n * pochhammer c n"
59862
44b3f4fa33ca New material and binomial fix
paulson <lp15@cam.ac.uk>
parents: 59815
diff changeset
  4315
    unfolding pochhammer_minus
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4316
    by simp
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4317
  have nz: "pochhammer c n \<noteq> 0" using c
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4318
    by (simp add: pochhammer_eq_0_iff)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4319
  from Vandermonde_pochhammer_lemma[where a = "?a" and b="?b" and n=n, OF h, unfolded th0 th1]
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4320
  show ?thesis
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4321
    using nz by (simp add: field_simps sum_distrib_left)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4322
qed
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4323
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4324
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4325
subsubsection \<open>Formal trigonometric functions\<close>
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4326
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  4327
definition "fps_sin (c::'a::field_char_0) =
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4328
  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
  4329
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  4330
definition "fps_cos (c::'a::field_char_0) =
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  4331
  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
  4332
66466
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4333
lemma fps_sin_0 [simp]: "fps_sin 0 = 0"
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4334
  by (intro fps_ext) (auto simp: fps_sin_def elim!: oddE)
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4335
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4336
lemma fps_cos_0 [simp]: "fps_cos 0 = 1"
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4337
  by (intro fps_ext) (auto simp: fps_cos_def)
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4338
30488
5c4c3a9e9102 remove trailing spaces
huffman
parents: 30273
diff changeset
  4339
lemma fps_sin_deriv:
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4340
  "fps_deriv (fps_sin c) = fps_const c * fps_cos c"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4341
  (is "?lhs = ?rhs")
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  4342
proof (rule fps_ext)
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4343
  fix n :: nat
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4344
  show "?lhs $ n = ?rhs $ n"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4345
  proof (cases "even n")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4346
    case True
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4347
    have "?lhs$n = of_nat (n+1) * (fps_sin c $ (n+1))" by simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4348
    also have "\<dots> = of_nat (n+1) * ((- 1)^(n div 2) * c^Suc n / of_nat (fact (Suc n)))"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4349
      using True by (simp add: fps_sin_def)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4350
    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
  4351
      unfolding fact_Suc of_nat_mult
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4352
      by (simp add: field_simps del: of_nat_add of_nat_Suc)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4353
    also have "\<dots> = (- 1)^(n div 2) *c^Suc n / of_nat (fact n)"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4354
      by (simp add: field_simps del: of_nat_add of_nat_Suc)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4355
    finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4356
      using True by (simp add: fps_cos_def field_simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4357
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4358
    case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4359
    then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4360
      by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4361
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4362
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4363
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4364
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
  4365
  (is "?lhs = ?rhs")
31273
da95bc889ad2 use class field_char_0 for fps definitions
huffman
parents: 31199
diff changeset
  4366
proof (rule fps_ext)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4367
  have th0: "- ((- 1::'a) ^ n) = (- 1)^Suc n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4368
    by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4369
  show "?lhs $ n = ?rhs $ n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4370
  proof (cases "even n")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4371
    case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4372
    then have n0: "n \<noteq> 0" by presburger
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4373
    from False have th1: "Suc ((n - 1) div 2) = Suc n div 2"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4374
      by (cases n) simp_all
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4375
    have "?lhs$n = of_nat (n+1) * (fps_cos c $ (n+1))" by simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4376
    also have "\<dots> = of_nat (n+1) * ((- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact (Suc n)))"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4377
      using False by (simp add: fps_cos_def)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4378
    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
  4379
      unfolding fact_Suc of_nat_mult
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4380
      by (simp add: field_simps del: of_nat_add of_nat_Suc)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4381
    also have "\<dots> = (- 1)^((n + 1) div 2) * c^Suc n / of_nat (fact n)"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4382
      by (simp add: field_simps del: of_nat_add of_nat_Suc)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4383
    also have "\<dots> = (- ((- 1)^((n - 1) div 2))) * c^Suc n / of_nat (fact n)"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4384
      unfolding th0 unfolding th1 by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4385
    finally show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4386
      using False by (simp add: fps_sin_def field_simps)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4387
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4388
    case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4389
    then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4390
      by (simp_all add: fps_deriv_def fps_sin_def fps_cos_def)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4391
  qed
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4392
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4393
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4394
lemma fps_sin_cos_sum_of_squares: "(fps_cos c)\<^sup>2 + (fps_sin c)\<^sup>2 = 1"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4395
  (is "?lhs = _")
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  4396
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4397
  have "fps_deriv ?lhs = 0"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4398
    apply (simp add:  fps_deriv_power fps_sin_deriv fps_cos_deriv)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4399
    apply (simp add: field_simps fps_const_neg[symmetric] del: fps_const_neg)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4400
    done
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4401
  then have "?lhs = fps_const (?lhs $ 0)"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4402
    unfolding fps_deriv_eq_0_iff .
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4403
  also have "\<dots> = 1"
30960
fec1a04b7220 power operation defined generic
haftmann
parents: 30952
diff changeset
  4404
    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
  4405
  finally show ?thesis .
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4406
qed
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4407
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4408
lemma fps_sin_nth_0 [simp]: "fps_sin c $ 0 = 0"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4409
  unfolding fps_sin_def by simp
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4410
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4411
lemma fps_sin_nth_1 [simp]: "fps_sin c $ 1 = c"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4412
  unfolding fps_sin_def by simp
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4413
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4414
lemma fps_sin_nth_add_2:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4415
    "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
  4416
  unfolding fps_sin_def
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4417
  apply (cases n)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4418
  apply simp
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  4419
  apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc)
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4420
  apply simp
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4421
  done
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4422
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4423
lemma fps_cos_nth_0 [simp]: "fps_cos c $ 0 = 1"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4424
  unfolding fps_cos_def by simp
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4425
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4426
lemma fps_cos_nth_1 [simp]: "fps_cos c $ 1 = 0"
53195
e4b18828a817 tuned proofs;
wenzelm
parents: 53077
diff changeset
  4427
  unfolding fps_cos_def by simp
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4428
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4429
lemma fps_cos_nth_add_2:
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4430
  "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
  4431
  unfolding fps_cos_def
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  4432
  apply (simp add: nonzero_divide_eq_eq nonzero_eq_divide_eq del: of_nat_Suc fact_Suc)
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4433
  apply simp
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4434
  done
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4435
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4436
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
  4437
  unfolding One_nat_def numeral_2_eq_2
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4438
  apply (induct n rule: nat_less_induct)
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4439
  apply (case_tac n)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4440
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4441
  apply (rename_tac m)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4442
  apply (case_tac m)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4443
  apply simp
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4444
  apply (rename_tac k)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4445
  apply (case_tac k)
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4446
  apply simp_all
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4447
  done
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4448
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4449
lemma nat_add_1_add_1: "(n::nat) + 1 + 1 = n + 2"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4450
  by simp
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4451
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4452
lemma eq_fps_sin:
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4453
  assumes 0: "a $ 0 = 0"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4454
    and 1: "a $ 1 = c"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4455
    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
  4456
  shows "a = fps_sin c"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4457
  apply (rule fps_ext)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4458
  apply (induct_tac n rule: nat_induct2)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4459
  apply (simp add: 0)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4460
  apply (simp add: 1 del: One_nat_def)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4461
  apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2])
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4462
  apply (simp add: nat_add_1_add_1 fps_sin_nth_add_2
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4463
              del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc')
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4464
  apply (subst minus_divide_left)
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  4465
  apply (subst nonzero_eq_divide_eq)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4466
  apply (simp del: of_nat_add of_nat_Suc)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  4467
  apply (simp only: ac_simps)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4468
  done
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4469
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4470
lemma eq_fps_cos:
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4471
  assumes 0: "a $ 0 = 1"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4472
    and 1: "a $ 1 = 0"
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4473
    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
  4474
  shows "a = fps_cos c"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4475
  apply (rule fps_ext)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4476
  apply (induct_tac n rule: nat_induct2)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4477
  apply (simp add: 0)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4478
  apply (simp add: 1 del: One_nat_def)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4479
  apply (rename_tac m, cut_tac f="\<lambda>a. a $ m" in arg_cong [OF 2])
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4480
  apply (simp add: nat_add_1_add_1 fps_cos_nth_add_2
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4481
              del: One_nat_def of_nat_Suc of_nat_add add_2_eq_Suc')
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4482
  apply (subst minus_divide_left)
60162
645058aa9d6f tidying some messy proofs
paulson <lp15@cam.ac.uk>
parents: 60017
diff changeset
  4483
  apply (subst nonzero_eq_divide_eq)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4484
  apply (simp del: of_nat_add of_nat_Suc)
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  4485
  apply (simp only: ac_simps)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4486
  done
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4487
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4488
lemma mult_nth_0 [simp]: "(a * b) $ 0 = a $ 0 * b $ 0"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4489
  by (simp add: fps_mult_nth)
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4490
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4491
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
  4492
  by (simp add: fps_mult_nth)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4493
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4494
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
  4495
  apply (rule eq_fps_sin [symmetric], simp, simp del: One_nat_def)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4496
  apply (simp del: fps_const_neg fps_const_add fps_const_mult
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4497
              add: fps_const_add [symmetric] fps_const_neg [symmetric]
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4498
                   fps_sin_deriv fps_cos_deriv algebra_simps)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4499
  done
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4500
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4501
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
  4502
  apply (rule eq_fps_cos [symmetric], simp, simp del: One_nat_def)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4503
  apply (simp del: fps_const_neg fps_const_add fps_const_mult
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4504
              add: fps_const_add [symmetric] fps_const_neg [symmetric]
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4505
                   fps_sin_deriv fps_cos_deriv algebra_simps)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4506
  done
31274
d2b5c6b07988 addition formulas for fps_sin, fps_cos
huffman
parents: 31273
diff changeset
  4507
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
  4508
lemma fps_sin_even: "fps_sin (- c) = - fps_sin c"
56479
91958d4b30f7 revert c1bbd3e22226, a14831ac3023, and 36489d77c484: divide_minus_left/right are again simp rules
hoelzl
parents: 56410
diff changeset
  4509
  by (auto simp add: fps_eq_iff fps_sin_def)
31968
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
  4510
0314441a53a6 FPS form a metric space, which justifies the infinte sum notation
chaieb
parents: 31790
diff changeset
  4511
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
  4512
  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
  4513
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4514
definition "fps_tan c = fps_sin c / fps_cos c"
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4515
66466
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4516
lemma fps_tan_0 [simp]: "fps_tan 0 = 0"
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4517
  by (simp add: fps_tan_def)
aec5d9c88d69 More lemmas for HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 66373
diff changeset
  4518
53077
a1b3784f8129 more symbols;
wenzelm
parents: 52903
diff changeset
  4519
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
  4520
proof -
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4521
  have th0: "fps_cos c $ 0 \<noteq> 0" by (simp add: fps_cos_def)
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4522
  from this have "fps_cos c \<noteq> 0" by (intro notI) simp
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  4523
  hence "fps_deriv (fps_tan c) =
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4524
           fps_const c * (fps_cos c^2 + fps_sin c^2) / (fps_cos c^2)"
62102
877463945ce9 fix code generation for uniformity: uniformity is a non-computable pure data.
hoelzl
parents: 62101
diff changeset
  4525
    by (simp add: fps_tan_def fps_divide_deriv power2_eq_square algebra_simps
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4526
                  fps_sin_deriv fps_cos_deriv fps_const_neg[symmetric] div_mult_swap
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4527
             del: fps_const_neg)
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4528
  also note fps_sin_cos_sum_of_squares
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4529
  finally show ?thesis by simp
29687
4d934a895d11 A formalization of formal power series
chaieb
parents:
diff changeset
  4530
qed
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
  4531
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4532
text \<open>Connection to @{const "fps_exp"} over the complex numbers --- Euler and de Moivre.\<close>
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4533
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4534
lemma fps_exp_ii_sin_cos: "fps_exp (\<i> * c) = fps_cos c + fps_const \<i> * fps_sin c"
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4535
  (is "?l = ?r")
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4536
proof -
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4537
  have "?l $ n = ?r $ n" for n
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4538
  proof (cases "even n")
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4539
    case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4540
    then obtain m where m: "n = 2 * m" ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4541
    show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4542
      by (simp add: m fps_sin_def fps_cos_def power_mult_distrib power_mult power_minus [of "c ^ 2"])
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4543
  next
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4544
    case False
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4545
    then obtain m where m: "n = 2 * m + 1" ..
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4546
    show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4547
      by (simp add: m fps_sin_def fps_cos_def power_mult_distrib
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4548
        power_mult power_minus [of "c ^ 2"])
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4549
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4550
  then show ?thesis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4551
    by (simp add: fps_eq_iff)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4552
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4553
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4554
lemma fps_exp_minus_ii_sin_cos: "fps_exp (- (\<i> * c)) = fps_cos c - fps_const \<i> * fps_sin c"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4555
  unfolding minus_mult_right fps_exp_ii_sin_cos by (simp add: fps_sin_even fps_cos_odd)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4556
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4557
lemma fps_const_minus: "fps_const (c::'a::group_add) - fps_const d = fps_const (c - d)"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4558
  by (fact fps_const_sub)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4559
63317
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4560
lemma fps_of_int: "fps_const (of_int c) = of_int c"
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4561
  by (induction c) (simp_all add: fps_const_minus [symmetric] fps_of_nat fps_const_neg [symmetric] 
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4562
                             del: fps_const_minus fps_const_neg)
ca187a9f66da Various additions to polynomials, FPSs, Gamma function
eberlm
parents: 63040
diff changeset
  4563
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4564
lemma fps_deriv_of_int [simp]: "fps_deriv (of_int n) = 0"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4565
  by (simp add: fps_of_int [symmetric])
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4566
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  4567
lemma fps_numeral_fps_const: "numeral i = fps_const (numeral i :: 'a::comm_ring_1)"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4568
  by (fact numeral_fps_const) (* FIfps_XME: duplicate *)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4569
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4570
lemma fps_cos_fps_exp_ii: "fps_cos c = (fps_exp (\<i> * c) + fps_exp (- \<i> * c)) / fps_const 2"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4571
proof -
52891
b8dede3a4f1d tuned proofs;
wenzelm
parents: 51542
diff changeset
  4572
  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
  4573
    by (simp add: numeral_fps_const)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4574
  show ?thesis
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4575
    unfolding fps_exp_ii_sin_cos minus_mult_commute
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4576
    by (simp add: fps_sin_even fps_cos_odd numeral_fps_const fps_divide_unit fps_const_inverse th)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4577
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4578
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4579
lemma fps_sin_fps_exp_ii: "fps_sin c = (fps_exp (\<i> * c) - fps_exp (- \<i> * c)) / fps_const (2*\<i>)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4580
proof -
63589
58aab4745e85 more symbols;
wenzelm
parents: 63539
diff changeset
  4581
  have th: "fps_const \<i> * fps_sin c + fps_const \<i> * fps_sin c = fps_sin c * fps_const (2 * \<i>)"
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 46757
diff changeset
  4582
    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
  4583
  show ?thesis
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4584
    unfolding fps_exp_ii_sin_cos minus_mult_commute
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4585
    by (simp add: fps_sin_even fps_cos_odd fps_divide_unit fps_const_inverse th)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4586
qed
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4587
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4588
lemma fps_tan_fps_exp_ii:
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4589
  "fps_tan c = (fps_exp (\<i> * c) - fps_exp (- \<i> * c)) / 
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4590
      (fps_const \<i> * (fps_exp (\<i> * c) + fps_exp (- \<i> * c)))"
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4591
  unfolding fps_tan_def fps_sin_fps_exp_ii fps_cos_fps_exp_ii mult_minus_left fps_exp_neg
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4592
  apply (simp add: fps_divide_unit fps_inverse_mult fps_const_mult[symmetric] fps_const_inverse del: fps_const_mult)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4593
  apply simp
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4594
  done
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4595
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4596
lemma fps_demoivre:
63589
58aab4745e85 more symbols;
wenzelm
parents: 63539
diff changeset
  4597
  "(fps_cos a + fps_const \<i> * fps_sin a)^n =
58aab4745e85 more symbols;
wenzelm
parents: 63539
diff changeset
  4598
    fps_cos (of_nat n * a) + fps_const \<i> * fps_sin (of_nat n * a)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4599
  unfolding fps_exp_ii_sin_cos[symmetric] fps_exp_power_mult
57514
bdc2c6b40bf2 prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents: 57512
diff changeset
  4600
  by (simp add: ac_simps)
32157
adea7a729c7a Moved important theorems from FPS_Examples to FPS --- they are not
chaieb
parents: 31968
diff changeset
  4601
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4602
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  4603
subsection \<open>Hypergeometric series\<close>
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4604
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4605
definition "fps_hypergeo as bs (c::'a::{field_char_0,field}) =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4606
  Abs_fps (\<lambda>n. (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) /
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4607
    (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n)))"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4608
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4609
lemma fps_hypergeo_nth[simp]: "fps_hypergeo as bs c $ n =
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4610
  (foldl (\<lambda>r a. r* pochhammer a n) 1 as * c^n) /
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4611
    (foldl (\<lambda>r b. r * pochhammer b n) 1 bs * of_nat (fact n))"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4612
  by (simp add: fps_hypergeo_def)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4613
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4614
lemma foldl_mult_start:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4615
  fixes v :: "'a::comm_ring_1"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4616
  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
  4617
  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
  4618
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4619
lemma foldr_mult_foldl:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4620
  fixes v :: "'a::comm_ring_1"
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4621
  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
  4622
  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
  4623
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4624
lemma fps_hypergeo_nth_alt:
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4625
  "fps_hypergeo 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
  4626
    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
  4627
  by (simp add: foldl_mult_start foldr_mult_foldl)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4628
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4629
lemma fps_hypergeo_fps_exp[simp]: "fps_hypergeo [] [] c = fps_exp c"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4630
  by (simp add: fps_eq_iff)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4631
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4632
lemma fps_hypergeo_1_0[simp]: "fps_hypergeo [1] [] c = 1/(1 - fps_const c * fps_X)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4633
proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4634
  let ?a = "(Abs_fps (\<lambda>n. 1)) oo (fps_const c * fps_X)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4635
  have th0: "(fps_const c * fps_X) $ 0 = 0" by simp
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4636
  show ?thesis unfolding gp[OF th0, symmetric]
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4637
    by (auto simp add: fps_eq_iff pochhammer_fact[symmetric]
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4638
      fps_compose_nth power_mult_distrib cond_value_iff sum.delta' cong del: if_weak_cong)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4639
qed
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4640
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4641
lemma fps_hypergeo_B[simp]: "fps_hypergeo [-a] [] (- 1) = fps_binomial a"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4642
  by (simp add: fps_eq_iff gbinomial_pochhammer algebra_simps)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4643
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4644
lemma fps_hypergeo_0[simp]: "fps_hypergeo as bs c $ 0 = 1"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4645
  apply simp
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4646
  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
  4647
  apply auto
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  4648
  apply (induct_tac as)
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  4649
  apply auto
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4650
  done
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4651
53196
942a1b48bb31 tuned proofs;
wenzelm
parents: 53195
diff changeset
  4652
lemma foldl_prod_prod:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4653
  "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
  4654
    foldl (\<lambda>r x. r * f x * g x) (v * w) as"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  4655
  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
  4656
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4657
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4658
lemma fps_hypergeo_rec:
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4659
  "fps_hypergeo as bs c $ Suc n = ((foldl (\<lambda>r a. r* (a + of_nat n)) c as) /
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4660
    (foldl (\<lambda>r b. r * (b + of_nat n)) (of_nat (Suc n)) bs )) * fps_hypergeo as bs c $ n"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4661
  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
  4662
  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
  4663
  unfolding foldl_prod_prod[unfolded foldl_mult_start] pochhammer_Suc
63417
c184ec919c70 more lemmas to emphasize {0::nat..(<)n} as canonical representation of intervals on nat
haftmann
parents: 63367
diff changeset
  4664
  apply (simp add: algebra_simps)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4665
  done
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4666
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4667
lemma fps_XD_nth[simp]: "fps_XD a $ n = (if n = 0 then 0 else of_nat n * a$n)"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4668
  by (simp add: fps_XD_def)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4669
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4670
lemma fps_XD_0th[simp]: "fps_XD a $ 0 = 0"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4671
  by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4672
lemma fps_XD_Suc[simp]:" fps_XD a $ Suc n = of_nat (Suc n) * a $ Suc n"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4673
  by simp
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4674
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4675
definition "fps_XDp c a = fps_XD a + fps_const c * a"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4676
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4677
lemma fps_XDp_nth[simp]: "fps_XDp c a $ n = (c + of_nat n) * a$n"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4678
  by (simp add: fps_XDp_def algebra_simps)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4679
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4680
lemma fps_XDp_commute: "fps_XDp b \<circ> fps_XDp (c::'a::comm_ring_1) = fps_XDp c \<circ> fps_XDp b"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4681
  by (auto simp add: fps_XDp_def fun_eq_iff fps_eq_iff algebra_simps)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4682
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4683
lemma fps_XDp0 [simp]: "fps_XDp 0 = fps_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
  4684
  by (simp add: fun_eq_iff fps_eq_iff)
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4685
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4686
lemma fps_XDp_fps_integral [simp]: "fps_XDp 0 (fps_integral a c) = fps_X * a"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4687
  by (simp add: fps_eq_iff fps_integral_def)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4688
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4689
lemma fps_hypergeo_minus_nat:
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4690
  "fps_hypergeo [- of_nat n] [- of_nat (n + m)] (c::'a::{field_char_0,field}) $ k =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4691
    (if k \<le> n then
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4692
      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
  4693
     else 0)"
65396
b42167902f57 moved AFP material to Formal_Power_Series; renamed E/L/F in Formal_Power_Series
eberlm <eberlm@in.tum.de>
parents: 64786
diff changeset
  4694
  "fps_hypergeo [- of_nat m] [- of_nat (m + n)] (c::'a::{field_char_0,field}) $ k =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4695
    (if k \<le> m then
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4696
      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
  4697
     else 0)"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4698
  by (auto simp add: pochhammer_eq_0_iff)
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4699
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4700
lemma sum_eq_if: "sum f {(n::nat) .. m} = (if m < n then 0 else f n + sum f {n+1 .. m})"
32160
63686057cbe8 Vandermonde vs Pochhammer; Hypergeometric series - very basic facts
chaieb
parents: 32157
diff changeset
  4701
  apply simp
64267
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4702
  apply (subst sum.insert[symmetric])
b9a1486e79be setsum -> sum
nipkow
parents: 64242
diff changeset
  4703
  apply (auto simp add: not_less sum_head_Suc)
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4704
  done
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4705
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4706
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
  4707
  by (cases n) (simp_all add: pochhammer_rec)
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4708
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4709
lemma fps_XDp_foldr_nth [simp]: "foldr (\<lambda>c r. fps_XDp c \<circ> r) cs (\<lambda>c. fps_XDp c a) c0 $ n =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4710
    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
  4711
  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
  4712
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4713
lemma genric_fps_XDp_foldr_nth:
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4714
  assumes f: "\<forall>n c a. f c a $ n = (of_nat n + k c) * a$n"
54681
8a8e6db7f391 tuned proofs;
wenzelm
parents: 54489
diff changeset
  4715
  shows "foldr (\<lambda>c r. f c \<circ> r) cs (\<lambda>c. g c a) c0 $ n =
54452
f3090621446e tuned proofs;
wenzelm
parents: 54263
diff changeset
  4716
    foldr (\<lambda>c r. (k c + of_nat n) * r) cs (g c0 a $ n)"
48757
1232760e208e tuned proofs;
wenzelm
parents: 47217
diff changeset
  4717
  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
  4718
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4719
lemma dist_less_imp_nth_equal:
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4720
  assumes "dist f g < inverse (2 ^ i)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4721
    and"j \<le> i"
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4722
  shows "f $ j = g $ j"
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
  4723
proof (rule ccontr)
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
  4724
  assume "f $ j \<noteq> g $ j"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4725
  hence "f \<noteq> g" by auto
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4726
  with assms have "i < subdegree (f - g)"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
  4727
    by (simp add: if_split_asm dist_fps_def)
54263
c4159fe6fa46 move Lubs from HOL to HOL-Library (replaced by conditionally complete lattices)
hoelzl
parents: 54230
diff changeset
  4728
  also have "\<dots> \<le> j"
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4729
    using \<open>f $ j \<noteq> g $ j\<close> by (intro subdegree_leI) simp_all
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  4730
  finally show False using \<open>j \<le> i\<close> by simp
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4731
qed
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4732
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4733
lemma nth_equal_imp_dist_less:
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4734
  assumes "\<And>j. j \<le> i \<Longrightarrow> f $ j = g $ j"
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4735
  shows "dist f g < inverse (2 ^ i)"
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4736
proof (cases "f = g")
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4737
  case True
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4738
  then show ?thesis by simp
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4739
next
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4740
  case False
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4741
  with assms have "dist f g = inverse (2 ^ subdegree (f - g))"
62390
842917225d56 more canonical names
nipkow
parents: 62343
diff changeset
  4742
    by (simp add: if_split_asm dist_fps_def)
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4743
  moreover
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4744
  from assms and False have "i < subdegree (f - g)"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4745
    by (intro subdegree_greaterI) simp_all
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4746
  ultimately show ?thesis by simp
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4747
qed
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4748
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4749
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
  4750
  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
  4751
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4752
instance fps :: (comm_ring_1) complete_space
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4753
proof
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4754
  fix fps_X :: "nat \<Rightarrow> 'a fps"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4755
  assume "Cauchy fps_X"
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4756
  obtain M where M: "\<forall>i. \<forall>m \<ge> M i. \<forall>j \<le> i. fps_X (M i) $ j = fps_X m $ j"
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4757
  proof -
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4758
    have "\<exists>M. \<forall>m \<ge> M. \<forall>j\<le>i. fps_X M $ j = fps_X m $ j" for i
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4759
    proof -
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4760
      have "0 < inverse ((2::real)^i)" by simp
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4761
      from metric_CauchyD[OF \<open>Cauchy fps_X\<close> this] dist_less_imp_nth_equal
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4762
      show ?thesis by blast
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4763
    qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4764
    then show ?thesis using that by metis
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4765
  qed
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4766
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4767
  show "convergent fps_X"
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4768
  proof (rule convergentI)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4769
    show "fps_X \<longlonglongrightarrow> Abs_fps (\<lambda>i. fps_X (M i) $ i)"
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4770
      unfolding tendsto_iff
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4771
    proof safe
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4772
      fix e::real assume e: "0 < e"
61969
e01015e49041 more symbols;
wenzelm
parents: 61943
diff changeset
  4773
      have "(\<lambda>n. inverse (2 ^ n) :: real) \<longlonglongrightarrow> 0" by (rule LIMSEQ_inverse_realpow_zero) simp_all
61608
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4774
      from this and e have "eventually (\<lambda>i. inverse (2 ^ i) < e) sequentially"
a0487caabb4a subdegree/shift/cutoff and Euclidean ring instance for formal power series
eberlm
parents: 61585
diff changeset
  4775
        by (rule order_tendstoD)
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4776
      then obtain i where "inverse (2 ^ i) < e"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4777
        by (auto simp: eventually_sequentially)
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4778
      have "eventually (\<lambda>x. M i \<le> x) sequentially"
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4779
        by (auto simp: eventually_sequentially)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4780
      then show "eventually (\<lambda>x. dist (fps_X x) (Abs_fps (\<lambda>i. fps_X (M i) $ i)) < e) sequentially"
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4781
      proof eventually_elim
52902
7196e1ce1cd8 tuned proofs;
wenzelm
parents: 52891
diff changeset
  4782
        fix x
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4783
        assume x: "M i \<le> x"
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4784
        have "fps_X (M i) $ j = fps_X (M j) $ j" if "j \<le> i" for j
60501
839169c70e92 tuned proofs;
wenzelm
parents: 60500
diff changeset
  4785
          using M that by (metis nat_le_linear)
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4786
        with x have "dist (fps_X x) (Abs_fps (\<lambda>j. fps_X (M j) $ j)) < inverse (2 ^ i)"
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4787
          using M by (force simp: dist_less_eq_nth_equal)
60500
903bb1495239 isabelle update_cartouches;
wenzelm
parents: 60162
diff changeset
  4788
        also note \<open>inverse (2 ^ i) < e\<close>
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4789
        finally show "dist (fps_X x) (Abs_fps (\<lambda>j. fps_X (M j) $ j)) < e" .
51107
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4790
      qed
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4791
    qed
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4792
  qed
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4793
qed
3f9dbd2cc475 complete metric for formal power series
immler
parents: 49962
diff changeset
  4794
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4795
(* TODO: Figure out better notation for this thing *)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4796
no_notation fps_nth (infixl "$" 75)
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4797
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4798
bundle fps_notation
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4799
begin
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4800
notation fps_nth (infixl "$" 75)
29911
c790a70a3d19 declare fps_nth as a typedef morphism; clean up instance proofs
huffman
parents: 29906
diff changeset
  4801
end
66480
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4802
4b8d1df8933b HOL-Analysis: Convergent FPS and infinite sums
Manuel Eberl <eberlm@in.tum.de>
parents: 66466
diff changeset
  4803
end