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