(`(\n. (-- &1) pow n / &(2 * n + 1)) sums (pi / &4)`,
REWRITE_TAC[GSYM
ATN_1] THEN
ASSUME_TAC(MATCH_MP
SUMMABLE_SUM SUMMABLE_LEIBNIZ) THEN
ABBREV_TAC `s = suminf(\n. (-- &1) pow n / &(2 * n + 1))` THEN
SUBGOAL_THEN `s = atn(&1)` (fun th -> ASM_MESON_TAC[th]) THEN
MATCH_MP_TAC(REAL_ARITH `~(&0 < abs(x - y)) ==> x = y`) THEN
ABBREV_TAC `e = abs(s - atn(&1))` THEN DISCH_TAC THEN
FIRST_ASSUM(MP_TAC o MATCH_MP
SUM_SUMMABLE) THEN
REWRITE_TAC[
SER_CAUCHY] THEN DISCH_THEN(MP_TAC o SPEC `e / &7`) THEN
ASM_SIMP_TAC[
REAL_LT_DIV;
REAL_OF_NUM_LT; ARITH] THEN
DISCH_THEN(X_CHOOSE_THEN `N:num` STRIP_ASSUME_TAC) THEN
SUBGOAL_THEN
`(\x. sum(0,N) (\n. (-- &1) pow n / &(2 * n + 1) * x pow (2 * n + 1)))
contl (&1)`
MP_TAC THENL
[MATCH_MP_TAC
DIFF_CONT THEN EXISTS_TAC
`sum(0,N) (\n. (-- &1) pow n * &1 pow (2 * n))` THEN
MATCH_MP_TAC
DIFF_SUM THEN X_GEN_TAC `k:num` THEN STRIP_TAC THEN
REWRITE_TAC[
real_div; GSYM REAL_MUL_ASSOC] THEN
MATCH_MP_TAC
DIFF_CMUL THEN
MP_TAC(SPECL [`2 * k + 1`; `&1`]
DIFF_POW) THEN
DISCH_THEN(MP_TAC o SPEC `inv(&(2 * k + 1))` o MATCH_MP
DIFF_CMUL) THEN
MATCH_MP_TAC(TAUT `a = b ==> a ==> b`) THEN
REWRITE_TAC[
ADD_SUB] THEN AP_THM_TAC THEN AP_TERM_TAC THEN
REWRITE_TAC[GSYM REAL_OF_NUM_ADD; GSYM REAL_OF_NUM_MUL] THEN
REWRITE_TAC[
REAL_POW_ONE] THEN CONV_TAC REAL_FIELD;
ALL_TAC] THEN
SUBGOAL_THEN `atn contl (&1)` MP_TAC THENL
[MESON_TAC[
DIFF_CONT;
DIFF_ATN]; ALL_TAC] THEN
REWRITE_TAC[
CONTL_LIM;
LIM] THEN
REWRITE_TAC[TAUT `a ==> ~b <=> ~(a /\ b)`;
AND_FORALL_THM] THEN
DISCH_THEN(MP_TAC o SPEC `e / &6`) THEN
ASM_SIMP_TAC[
REAL_LT_DIV;
REAL_OF_NUM_LT; ARITH; GSYM
SUM_SUB] THEN
ONCE_REWRITE_TAC[GSYM
REAL_ABS_NEG] THEN
REWRITE_TAC[GSYM
SUM_NEG;
REAL_NEG_SUB; GSYM
REAL_MUL_RNEG] THEN
REWRITE_TAC[
REAL_POW_ONE; GSYM
REAL_SUB_LDISTRIB] THEN DISCH_THEN
(CONJUNCTS_THEN2 (X_CHOOSE_THEN `d1:real` STRIP_ASSUME_TAC)
(X_CHOOSE_THEN `d2:real` STRIP_ASSUME_TAC)) THEN
ABBREV_TAC `x = &1 - min (min (d1 / &2) (d2 / &2)) (&1 / &2)` THEN
REPEAT(FIRST_X_ASSUM (MP_TAC o SPEC `x:real`) THEN ANTS_TAC THENL
[ASM_REAL_ARITH_TAC; DISCH_TAC]) THEN
SUBGOAL_THEN `&0 < x /\ x < &1 /\ abs x < &1` STRIP_ASSUME_TAC THENL
[ASM_REAL_ARITH_TAC; ALL_TAC] THEN
FIRST_X_ASSUM(MP_TAC o MATCH_MP
REAL_ATN_POWSER_ALT) THEN
REWRITE_TAC[sums;
SEQ] THEN DISCH_THEN(MP_TAC o SPEC `e / &6`) THEN
ASM_SIMP_TAC[
REAL_LT_DIV;
REAL_OF_NUM_LT; ARITH] THEN
DISCH_THEN(X_CHOOSE_TAC `N1:num`) THEN
FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [sums]) THEN
REWRITE_TAC[
SEQ] THEN DISCH_THEN(MP_TAC o SPEC `e / &6`) THEN
ASM_SIMP_TAC[
REAL_LT_DIV;
REAL_OF_NUM_LT; ARITH] THEN
DISCH_THEN(X_CHOOSE_TAC `N2:num`) THEN
REPEAT(FIRST_X_ASSUM(MP_TAC o SPEC `N + N1 + N2:num`) THEN
ANTS_TAC THENL [ARITH_TAC; ALL_TAC]) THEN
REWRITE_TAC[] THEN ONCE_REWRITE_TAC[GSYM
SUM_SPLIT] THEN
REWRITE_TAC[
ADD_CLAUSES] THEN REPEAT STRIP_TAC THEN
SUBGOAL_THEN
`abs(sum(N,N1+N2) (\n. -- &1 pow n / &(2 * n + 1) * x pow (2 * n + 1)))
< e / &6`
ASSUME_TAC THENL
[ASM_CASES_TAC `N1 + N2 = 0` THENL
[ASM_SIMP_TAC[sum;
REAL_LT_DIV;
REAL_OF_NUM_LT;
REAL_ABS_NUM; ARITH];
ALL_TAC] THEN
MATCH_MP_TAC(REAL_ARITH `x <= e / &7 /\ &0 < e ==> x < e / &6`) THEN
ASM_REWRITE_TAC[] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN EXISTS_TAC
`e / &7 * abs(x pow (2 * N + 1))` THEN
CONJ_TAC THENL
[ALL_TAC;
GEN_REWRITE_TAC RAND_CONV [GSYM
REAL_MUL_RID] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN REWRITE_TAC[
REAL_ABS_POS] THEN
ASM_SIMP_TAC[
REAL_LT_IMP_LE;
REAL_LT_DIV;
REAL_OF_NUM_LT; ARITH] THEN
REWRITE_TAC[
REAL_ABS_POW;
REAL_ABS_NUM] THEN
MATCH_MP_TAC
REAL_POW_1_LE THEN
MAP_EVERY UNDISCH_TAC [`&0 < x`; `x < &1`] THEN REAL_ARITH_TAC] THEN
ASM_SIMP_TAC[
PSUM_SUM_NUMSEG] THEN MATCH_MP_TAC
SUM_BOUND_LEMMA THEN
CONJ_TAC THENL [UNDISCH_TAC `~(N1 + N2 = 0)` THEN ARITH_TAC; ALL_TAC] THEN
REPEAT STRIP_TAC THENL
[ASM_SIMP_TAC[
REAL_LT_IMP_LE;
REAL_POW_LT];
REWRITE_TAC[ARITH_RULE `2 * (m + 1) + 1 = (2 * m + 1) + 2`] THEN
GEN_REWRITE_TAC LAND_CONV [
REAL_POW_ADD] THEN
GEN_REWRITE_TAC RAND_CONV [GSYM
REAL_MUL_RID] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN
ASM_SIMP_TAC[
REAL_POW_LE;
REAL_POW_1_LE;
REAL_LT_IMP_LE];
MATCH_MP_TAC
REAL_LT_IMP_LE THEN
FIRST_X_ASSUM(MP_TAC o SPECL [`N:num`; `(k - N:num) + 1`]) THEN
SIMP_TAC[
PSUM_SUM_NUMSEG;
ADD_EQ_0;
ARITH_EQ] THEN
ASM_SIMP_TAC[ARITH_RULE `N <= k ==> (N + (k - N) + 1) - 1 = k`] THEN
REWRITE_TAC[
GE;
LE_REFL;
REAL_LT_IMP_LE]];
ALL_TAC] THEN
FIRST_X_ASSUM(MP_TAC o SPECL [`N:num`; `N1 + N2:num`]) THEN
REWRITE_TAC[
GE;
LE_REFL] THEN
FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
`abs((slo + shi) - s) < e / &6
==> ~(abs(slo - s) < e / &3) ==> ~(abs(shi) < e / &7)`)) THEN
RULE_ASSUM_TAC(REWRITE_RULE[
REAL_SUB_LDISTRIB;
SUM_SUB;
REAL_MUL_RID]) THEN
FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (REAL_ARITH
`abs(s1 - sx) < e / &6
==> ~(abs(sx - s) < e / &2) ==> ~(abs(s1 - s) < e / &3)`)) THEN
ASM_REAL_ARITH_TAC);;