src/HOL/Hyperreal/HSeries.thy
author avigad
Tue, 12 Jul 2005 17:56:03 +0200
changeset 16775 c1b87ef4a1c3
parent 15543 0024472afce7
child 17298 ad73fb6144cf
permissions -rw-r--r--
added lemmas to OrderedGroup.thy (reasoning about signs, absolute value, triangle inequalities) added lemmas to Ring_and_Field.thy (reasoning about signs, fractions, etc.) renamed simplification rules for abs (abs_of_pos, etc.) renamed rules for multiplication and signs (mult_pos_pos, etc.) moved lemmas involving fractions from NatSimprocs.thy added setsum_mono3 to FiniteSet.thy added simplification rules for powers to Parity.thy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     1
(*  Title       : HSeries.thy
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     3
    Copyright   : 1998  University of Cambridge
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
     4
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
     5
Converted to Isar and polished by lcp    
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     6
*) 
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     7
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
     8
header{*Finite Summation and Infinite Series for Hyperreals*}
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     9
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15047
diff changeset
    10
theory HSeries
15140
322485b816ac import -> imports
nipkow
parents: 15131
diff changeset
    11
imports Series
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15047
diff changeset
    12
begin
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    13
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    14
constdefs 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    15
  sumhr :: "(hypnat * hypnat * (nat=>real)) => hypreal"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    16
   "sumhr p == 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    17
      (%(M,N,f). Abs_hypreal(\<Union>X \<in> Rep_hypnat(M). \<Union>Y \<in> Rep_hypnat(N).  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    18
                             hyprel ``{%n::nat. setsum f {X n..<Y n}})) p"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    19
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    20
  NSsums  :: "[nat=>real,real] => bool"     (infixr "NSsums" 80)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    21
   "f NSsums s  == (%n. setsum f {0..<n}) ----NS> s"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    22
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    23
  NSsummable :: "(nat=>real) => bool"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    24
   "NSsummable f == (\<exists>s. f NSsums s)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    25
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    26
  NSsuminf   :: "(nat=>real) => real"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    27
   "NSsuminf f == (@s. f NSsums s)"
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    28
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    29
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    30
lemma sumhr: 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    31
     "sumhr(Abs_hypnat(hypnatrel``{%n. M n}),  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    32
            Abs_hypnat(hypnatrel``{%n. N n}), f) =  
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    33
      Abs_hypreal(hyprel `` {%n. setsum f {M n..<N n}})"
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    34
apply (simp add: sumhr_def)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    35
apply (rule arg_cong [where f = Abs_hypreal])
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    36
apply (auto, ultra)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    37
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    38
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    39
text{*Base case in definition of @{term sumr}*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    40
lemma sumhr_zero [simp]: "sumhr (m,0,f) = 0"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    41
apply (cases m)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    42
apply (simp add: hypnat_zero_def sumhr symmetric hypreal_zero_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    43
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    44
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    45
text{*Recursive case in definition of @{term sumr}*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    46
lemma sumhr_if: 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    47
     "sumhr(m,n+1,f) = 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    48
      (if n + 1 \<le> m then 0 else sumhr(m,n,f) + ( *fNat* f) n)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    49
apply (cases m, cases n)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    50
apply (auto simp add: hypnat_one_def sumhr hypnat_add hypnat_le starfunNat
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    51
           hypreal_add hypreal_zero_def,   ultra+)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    52
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    53
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    54
lemma sumhr_Suc_zero [simp]: "sumhr (n + 1, n, f) = 0"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    55
apply (cases n)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    56
apply (simp add: hypnat_one_def sumhr hypnat_add hypreal_zero_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    57
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    58
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    59
lemma sumhr_eq_bounds [simp]: "sumhr (n,n,f) = 0"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    60
apply (cases n)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    61
apply (simp add: sumhr hypreal_zero_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    62
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    63
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    64
lemma sumhr_Suc [simp]: "sumhr (m,m + 1,f) = ( *fNat* f) m"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    65
apply (cases m)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    66
apply (simp add: sumhr hypnat_one_def  hypnat_add starfunNat)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    67
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    68
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    69
lemma sumhr_add_lbound_zero [simp]: "sumhr(m+k,k,f) = 0"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    70
apply (cases m, cases k)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    71
apply (simp add: sumhr hypnat_add hypreal_zero_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    72
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    73
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    74
lemma sumhr_add: "sumhr (m,n,f) + sumhr(m,n,g) = sumhr(m,n,%i. f i + g i)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    75
apply (cases m, cases n)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
    76
apply (simp add: sumhr hypreal_add setsum_addf)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    77
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    78
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    79
lemma sumhr_mult: "hypreal_of_real r * sumhr(m,n,f) = sumhr(m,n,%n. r * f n)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    80
apply (cases m, cases n)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
    81
apply (simp add: sumhr hypreal_of_real_def hypreal_mult setsum_mult)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    82
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    83
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    84
lemma sumhr_split_add: "n < p ==> sumhr(0,n,f) + sumhr(n,p,f) = sumhr(0,p,f)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    85
apply (cases n, cases p)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    86
apply (auto elim!: FreeUltrafilterNat_subset simp 
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
    87
            add: hypnat_zero_def sumhr hypreal_add hypnat_less setsum_add_nat_ivl)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    88
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    89
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    90
lemma sumhr_split_diff: "n<p ==> sumhr(0,p,f) - sumhr(0,n,f) = sumhr(n,p,f)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    91
by (drule_tac f1 = f in sumhr_split_add [symmetric], simp)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    92
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    93
lemma sumhr_hrabs: "abs(sumhr(m,n,f)) \<le> sumhr(m,n,%i. abs(f i))"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
    94
apply (cases n, cases m)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
    95
apply (simp add: sumhr hypreal_le hypreal_hrabs setsum_abs)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    96
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    97
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    98
text{* other general version also needed *}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
    99
lemma sumhr_fun_hypnat_eq:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   100
   "(\<forall>r. m \<le> r & r < n --> f r = g r) -->  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   101
      sumhr(hypnat_of_nat m, hypnat_of_nat n, f) =  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   102
      sumhr(hypnat_of_nat m, hypnat_of_nat n, g)"
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
   103
by (fastsimp simp add: sumhr hypnat_of_nat_eq intro:setsum_cong)
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
   104
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   105
15047
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   106
lemma sumhr_const:
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   107
     "sumhr(0, n, %i. r) = hypreal_of_hypnat n * hypreal_of_real r"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
   108
apply (cases n)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   109
apply (simp add: sumhr hypnat_zero_def hypreal_of_real_def hypreal_of_hypnat 
15047
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   110
                 hypreal_mult real_of_nat_def)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   111
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   112
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   113
lemma sumhr_less_bounds_zero [simp]: "n < m ==> sumhr(m,n,f) = 0"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
   114
apply (cases m, cases n)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   115
apply (auto elim: FreeUltrafilterNat_subset 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   116
            simp add: sumhr hypnat_less hypreal_zero_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   117
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   118
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   119
lemma sumhr_minus: "sumhr(m, n, %i. - f i) = - sumhr(m, n, f)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
   120
apply (cases m, cases n)
15536
3ce1cb7a24f0 starting to get rid of sumr
nipkow
parents: 15140
diff changeset
   121
apply (simp add: sumhr hypreal_minus setsum_negf)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   122
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   123
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   124
lemma sumhr_shift_bounds:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   125
     "sumhr(m+hypnat_of_nat k,n+hypnat_of_nat k,f) = sumhr(m,n,%i. f(i + k))"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
   126
apply (cases m, cases n)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   127
apply (simp add: sumhr hypnat_add setsum_shift_bounds_nat_ivl hypnat_of_nat_eq)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   128
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   129
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   130
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   131
subsection{*Nonstandard Sums*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   132
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   133
text{*Infinite sums are obtained by summing to some infinite hypernatural
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   134
 (such as @{term whn})*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   135
lemma sumhr_hypreal_of_hypnat_omega: 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   136
      "sumhr(0,whn,%i. 1) = hypreal_of_hypnat whn"
15047
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   137
by (simp add: hypnat_omega_def hypnat_zero_def sumhr hypreal_of_hypnat
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   138
              real_of_nat_def)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   139
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   140
lemma sumhr_hypreal_omega_minus_one: "sumhr(0, whn, %i. 1) = omega - 1"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   141
by (simp add: hypnat_omega_def hypnat_zero_def omega_def hypreal_one_def
15047
fa62de5862b9 redefining sumr to be a translation to setsum
paulson
parents: 14468
diff changeset
   142
              sumhr hypreal_diff real_of_nat_def)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   143
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   144
lemma sumhr_minus_one_realpow_zero [simp]: 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   145
     "sumhr(0, whn + whn, %i. (-1) ^ (i+1)) = 0"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   146
by (simp del: realpow_Suc 
14435
9e22eeccf129 Conversion of Poly to Isar script, and other tidying of HOL/Hyperreal
paulson
parents: 14413
diff changeset
   147
         add: sumhr hypnat_add nat_mult_2 [symmetric] hypreal_zero_def 
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   148
              hypnat_zero_def hypnat_omega_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   149
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   150
lemma sumhr_interval_const:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   151
     "(\<forall>n. m \<le> Suc n --> f n = r) & m \<le> na  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   152
      ==> sumhr(hypnat_of_nat m,hypnat_of_nat na,f) =  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   153
          (hypreal_of_nat (na - m) * hypreal_of_real r)"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   154
by(simp add: sumhr hypreal_of_nat_eq hypnat_of_nat_eq hypreal_of_real_def
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   155
             real_of_nat_def hypreal_mult cong: setsum_ivl_cong)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   156
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   157
lemma starfunNat_sumr: "( *fNat* (%n. setsum f {0..<n})) N = sumhr(0,N,f)"
14468
6be497cacab5 heavy tidying
paulson
parents: 14435
diff changeset
   158
apply (cases N)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   159
apply (simp add: hypnat_zero_def starfunNat sumhr)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   160
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   161
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   162
lemma sumhr_hrabs_approx [simp]: "sumhr(0, M, f) @= sumhr(0, N, f)  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   163
      ==> abs (sumhr(M, N, f)) @= 0"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   164
apply (cut_tac x = M and y = N in linorder_less_linear)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   165
apply (auto simp add: approx_refl)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   166
apply (drule approx_sym [THEN approx_minus_iff [THEN iffD1]])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   167
apply (auto dest: approx_hrabs 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   168
            simp add: sumhr_split_diff diff_minus [symmetric])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   169
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   170
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   171
(*----------------------------------------------------------------
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   172
      infinite sums: Standard and NS theorems
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   173
 ----------------------------------------------------------------*)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   174
lemma sums_NSsums_iff: "(f sums l) = (f NSsums l)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   175
by (simp add: sums_def NSsums_def LIMSEQ_NSLIMSEQ_iff)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   176
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   177
lemma summable_NSsummable_iff: "(summable f) = (NSsummable f)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   178
by (simp add: summable_def NSsummable_def sums_NSsums_iff)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   179
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   180
lemma suminf_NSsuminf_iff: "(suminf f) = (NSsuminf f)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   181
by (simp add: suminf_def NSsuminf_def sums_NSsums_iff)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   182
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   183
lemma NSsums_NSsummable: "f NSsums l ==> NSsummable f"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   184
by (simp add: NSsums_def NSsummable_def, blast)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   185
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   186
lemma NSsummable_NSsums: "NSsummable f ==> f NSsums (NSsuminf f)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   187
apply (simp add: NSsummable_def NSsuminf_def)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   188
apply (blast intro: someI2)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   189
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   190
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   191
lemma NSsums_unique: "f NSsums s ==> (s = NSsuminf f)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   192
by (simp add: suminf_NSsuminf_iff [symmetric] sums_NSsums_iff sums_unique)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   193
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   194
lemma NSseries_zero:
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15536
diff changeset
   195
  "\<forall>m. n \<le> Suc m --> f(m) = 0 ==> f NSsums (setsum f {0..<n})"
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   196
by (simp add: sums_NSsums_iff [symmetric] series_zero)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   197
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   198
lemma NSsummable_NSCauchy:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   199
     "NSsummable f =  
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   200
      (\<forall>M \<in> HNatInfinite. \<forall>N \<in> HNatInfinite. abs (sumhr(M,N,f)) @= 0)"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   201
apply (auto simp add: summable_NSsummable_iff [symmetric] 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   202
       summable_convergent_sumr_iff convergent_NSconvergent_iff 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   203
       NSCauchy_NSconvergent_iff [symmetric] NSCauchy_def starfunNat_sumr)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   204
apply (cut_tac x = M and y = N in linorder_less_linear)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   205
apply (auto simp add: approx_refl)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   206
apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   207
apply (rule_tac [2] approx_minus_iff [THEN iffD2])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   208
apply (auto dest: approx_hrabs_zero_cancel 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   209
            simp add: sumhr_split_diff diff_minus [symmetric])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   210
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   211
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   212
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   213
text{*Terms of a convergent series tend to zero*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   214
lemma NSsummable_NSLIMSEQ_zero: "NSsummable f ==> f ----NS> 0"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   215
apply (auto simp add: NSLIMSEQ_def NSsummable_NSCauchy)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   216
apply (drule bspec, auto)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   217
apply (drule_tac x = "N + 1 " in bspec)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   218
apply (auto intro: HNatInfinite_add_one approx_hrabs_zero_cancel)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   219
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   220
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   221
text{* Easy to prove stsandard case now *}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   222
lemma summable_LIMSEQ_zero: "summable f ==> f ----> 0"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   223
by (simp add: summable_NSsummable_iff LIMSEQ_NSLIMSEQ_iff NSsummable_NSLIMSEQ_zero)
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   224
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   225
text{*Nonstandard comparison test*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   226
lemma NSsummable_comparison_test:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   227
     "[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] ==> NSsummable f"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   228
by (auto intro: summable_comparison_test 
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   229
         simp add: summable_NSsummable_iff [symmetric])
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   230
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   231
lemma NSsummable_rabs_comparison_test:
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   232
     "[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |]
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   233
      ==> NSsummable (%k. abs (f k))"
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   234
apply (rule NSsummable_comparison_test)
15543
0024472afce7 more setsum tuning
nipkow
parents: 15542
diff changeset
   235
apply (auto)
14413
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   236
done
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   237
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   238
ML
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   239
{*
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   240
val sumhr = thm "sumhr";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   241
val sumhr_zero = thm "sumhr_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   242
val sumhr_if = thm "sumhr_if";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   243
val sumhr_Suc_zero = thm "sumhr_Suc_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   244
val sumhr_eq_bounds = thm "sumhr_eq_bounds";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   245
val sumhr_Suc = thm "sumhr_Suc";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   246
val sumhr_add_lbound_zero = thm "sumhr_add_lbound_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   247
val sumhr_add = thm "sumhr_add";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   248
val sumhr_mult = thm "sumhr_mult";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   249
val sumhr_split_add = thm "sumhr_split_add";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   250
val sumhr_split_diff = thm "sumhr_split_diff";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   251
val sumhr_hrabs = thm "sumhr_hrabs";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   252
val sumhr_fun_hypnat_eq = thm "sumhr_fun_hypnat_eq";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   253
val sumhr_less_bounds_zero = thm "sumhr_less_bounds_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   254
val sumhr_minus = thm "sumhr_minus";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   255
val sumhr_shift_bounds = thm "sumhr_shift_bounds";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   256
val sumhr_hypreal_of_hypnat_omega = thm "sumhr_hypreal_of_hypnat_omega";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   257
val sumhr_hypreal_omega_minus_one = thm "sumhr_hypreal_omega_minus_one";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   258
val sumhr_minus_one_realpow_zero = thm "sumhr_minus_one_realpow_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   259
val sumhr_interval_const = thm "sumhr_interval_const";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   260
val starfunNat_sumr = thm "starfunNat_sumr";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   261
val sumhr_hrabs_approx = thm "sumhr_hrabs_approx";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   262
val sums_NSsums_iff = thm "sums_NSsums_iff";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   263
val summable_NSsummable_iff = thm "summable_NSsummable_iff";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   264
val suminf_NSsuminf_iff = thm "suminf_NSsuminf_iff";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   265
val NSsums_NSsummable = thm "NSsums_NSsummable";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   266
val NSsummable_NSsums = thm "NSsummable_NSsums";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   267
val NSsums_unique = thm "NSsums_unique";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   268
val NSseries_zero = thm "NSseries_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   269
val NSsummable_NSCauchy = thm "NSsummable_NSCauchy";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   270
val NSsummable_NSLIMSEQ_zero = thm "NSsummable_NSLIMSEQ_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   271
val summable_LIMSEQ_zero = thm "summable_LIMSEQ_zero";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   272
val NSsummable_comparison_test = thm "NSsummable_comparison_test";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   273
val NSsummable_rabs_comparison_test = thm "NSsummable_rabs_comparison_test";
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   274
*}
7ce47ab455eb converted Hyperreal/HSeries to Isar script
paulson
parents: 10834
diff changeset
   275
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
   276
end