(`~(integer x)
==> (\n. (&2 * x pow 2) / (x pow 2 - &n pow 2)) sums
((pi * x) * cot(pi * x) + &1)`,
REPEAT STRIP_TAC THEN
SUBGOAL_THEN `~(x = &0)` ASSUME_TAC THENL
[UNDISCH_TAC `~(integer x)` THEN
REWRITE_TAC[TAUT `(~b ==> ~a) <=> (a ==> b)`] THEN
SIMP_TAC[integer;
REAL_ABS_NUM; REAL_OF_NUM_EQ; GSYM
EXISTS_REFL];
ALL_TAC] THEN
ABBREV_TAC
`A = \n k. (pi * x / &2 pow n) * cot(pi * x / &2 pow n) +
(pi * x / &2 pow (n + 1)) *
sum(1,k) (\m. cot (pi * (x + &m) / &2 pow (n + 1)) +
cot (pi * (x - &m) / &2 pow (n + 1)))` THEN
ABBREV_TAC
`B = \n k. (pi * x / &2 pow (n + 1)) *
sum(k + 1,2
EXP n - 1 - k)
(\m. cot(pi * (x + &m) / &2 pow (n + 1)) +
cot(pi * (x - &m) / &2 pow (n + 1)))` THEN
SUBGOAL_THEN `!n. ~(x - &n = &0)` ASSUME_TAC THENL
[X_GEN_TAC `n:num` THEN UNDISCH_TAC `~(integer x)` THEN
REWRITE_TAC[TAUT `~a ==> ~b <=> b ==> a`] THEN DISCH_TAC THEN
SUBGOAL_THEN `x = (x - &n) + &n` SUBST1_TAC THENL
[REAL_ARITH_TAC; ASM_SIMP_TAC[integer;
REAL_INTEGER_CLOSURES]];
ALL_TAC] THEN
SUBGOAL_THEN `!n. ~(x + &n = &0)` ASSUME_TAC THENL
[X_GEN_TAC `n:num` THEN UNDISCH_TAC `~(integer x)` THEN
REWRITE_TAC[TAUT `~a ==> ~b <=> b ==> a`] THEN DISCH_TAC THEN
SUBGOAL_THEN `x = (x + &n) - &n` SUBST1_TAC THENL
[REAL_ARITH_TAC; ASM_SIMP_TAC[integer;
REAL_INTEGER_CLOSURES]];
ALL_TAC] THEN
SUBGOAL_THEN `!n. ~(x pow 2 - &n pow 2 = &0)` ASSUME_TAC THENL
[GEN_TAC THEN REWRITE_TAC[REAL_POW_2] THEN
ONCE_REWRITE_TAC[REAL_ARITH `a * a - b * b = (a + b) * (a - b)`] THEN
ASM_REWRITE_TAC[
REAL_ENTIRE; DE_MORGAN_THM]; ALL_TAC] THEN
SUBGOAL_THEN
`!n. (&2 * x) / (x pow 2 - &n pow 2) = inv(x + &n) + inv(x - &n)`
ASSUME_TAC THENL
[X_GEN_TAC `n:num` THEN MATCH_MP_TAC
REAL_EQ_LCANCEL_IMP THEN
EXISTS_TAC `x pow 2 - &n pow 2` THEN ASM_SIMP_TAC[
REAL_DIV_LMUL] THEN
REWRITE_TAC[REAL_POW_2; REAL_ADD_LDISTRIB] THEN
ONCE_REWRITE_TAC[REAL_ARITH `a * a - b * b = (a + b) * (a - b)`] THEN
ONCE_REWRITE_TAC[REAL_ARITH
`(p * m) * p' + (p * m) * m' = m * p * p' + p * m * m'`] THEN
ASM_SIMP_TAC[
REAL_MUL_RINV;
REAL_MUL_RID] THEN REAL_ARITH_TAC;
ALL_TAC] THEN
SUBGOAL_THEN `!k. (\n. A n k)
tends_num_real
(&1 + sum(1,k) (\n. (&2 * x pow 2) / (x pow 2 - &n pow 2)))`
ASSUME_TAC THENL
[X_GEN_TAC `k:num` THEN EXPAND_TAC "A" THEN REWRITE_TAC[] THEN
MATCH_MP_TAC
SEQ_ADD THEN CONJ_TAC THENL
[REWRITE_TAC[
real_div; REAL_MUL_ASSOC] THEN
REWRITE_TAC[GSYM
real_div] THEN
MATCH_MP_TAC
COT_LIMIT_LEMMA THEN
ASM_SIMP_TAC[
REAL_ENTIRE;
PI_POS;
REAL_LT_IMP_NZ];
ALL_TAC] THEN
REWRITE_TAC[GSYM
SUM_CMUL] THEN MATCH_MP_TAC
SEQ_SUM THEN
X_GEN_TAC `r:num` THEN STRIP_TAC THEN
REWRITE_TAC[REAL_POW_2;
real_div] THEN
ONCE_REWRITE_TAC[REAL_ARITH `(&2 * x * x) * d = x * (&2 * x) * d`] THEN
REWRITE_TAC[GSYM REAL_POW_2; GSYM
real_div] THEN
ASM_REWRITE_TAC[] THEN REWRITE_TAC[REAL_ADD_LDISTRIB] THEN
MATCH_MP_TAC
SEQ_ADD THEN
REWRITE_TAC[
real_div] THEN
ONCE_REWRITE_TAC[REAL_ARITH `(p * x * d) * cc = x * (p * d) * cc`] THEN
CONJ_TAC THEN MATCH_MP_TAC
SEQ_MUL THEN REWRITE_TAC[
SEQ_CONST] THEN
REWRITE_TAC[GSYM
real_div] THEN
ASM_SIMP_TAC[
COT_LIMIT_LEMMA1]; ALL_TAC] THEN
SUBGOAL_THEN
`!k n. &6 * abs(x) < &k
==> abs(B n k)
<= abs((pi * x / &2 pow (n + 1)) *
cot(pi * x / &2 pow (n + 1))) *
sum(k + 1,2
EXP n - 1 - k)
(\m. (&72 * x pow 2) / (&m pow 2 - &36 * x pow 2))`
ASSUME_TAC THENL
[REPEAT STRIP_TAC THEN
EXPAND_TAC "B" THEN REWRITE_TAC[GSYM
SUM_CMUL] THEN
W(fun (asl,w) -> MP_TAC(PART_MATCH lhand
SUM_ABS_LE (lhand w))) THEN
MATCH_MP_TAC(REAL_ARITH `a <= b ==> x <= a ==> x <= b`) THEN
MATCH_MP_TAC
SUM_LE THEN X_GEN_TAC `r:num` THEN
REWRITE_TAC[ARITH_RULE
`k + 1 <= r /\ r < (p - 1 - k) + k + 1 <=> k < r /\ r < p`] THEN
STRIP_TAC THEN ONCE_REWRITE_TAC[
REAL_ABS_MUL] THEN
REWRITE_TAC[GSYM REAL_MUL_ASSOC] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN REWRITE_TAC[
REAL_ABS_POS] THEN
MATCH_MP_TAC
REAL_LE_RCANCEL_IMP THEN
EXISTS_TAC `abs(inv(&2 pow (n + 1)))` THEN
REWRITE_TAC[GSYM
REAL_ABS_MUL] THEN REWRITE_TAC[GSYM
real_div] THEN
SIMP_TAC[REAL_ARITH `&0 < x ==> &0 < abs(x)`;
REAL_LT_INV_EQ;
REAL_POW2_CLAUSES] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC
`abs(cot (pi * x / &2 pow (n + 1)) / &2 pow n) *
(&36 * x pow 2) / (&r pow 2 - &36 * x pow 2)` THEN
CONJ_TAC THENL
[MATCH_MP_TAC
KNOPP_TERM_BOUND THEN ASM_REWRITE_TAC[] THEN
MATCH_MP_TAC
REAL_LT_TRANS THEN
EXISTS_TAC `&k` THEN ASM_REWRITE_TAC[
REAL_OF_NUM_LT]; ALL_TAC] THEN
REWRITE_TAC[
real_div; GSYM REAL_MUL_ASSOC;
REAL_POW_ADD;
REAL_ABS_MUL;
REAL_INV_MUL] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN REWRITE_TAC[
REAL_ABS_POS] THEN
GEN_REWRITE_TAC RAND_CONV
[AC
REAL_MUL_AC `a * b * c * d * e = b * c * d * a * e`] THEN
CONV_TAC REAL_RAT_REDUCE_CONV THEN
REWRITE_TAC[
REAL_MUL_AC;
REAL_LE_REFL]; ALL_TAC] THEN
SUBGOAL_THEN
`!e. &0 < e
==> ?N. !n k:num. N <= k /\ pi * abs(x) <= &2 pow (n + 1)
==> abs(B n k) < e`
ASSUME_TAC THENL
[X_CHOOSE_TAC `Bd:real`
COT_X_BOUND_LEMMA THEN
SUBGOAL_THEN
`!k n. &9 * abs x < &k
==> abs(sum(k + 1,2
EXP n - 1 - k)
(\m. (&72 * x pow 2) / (&m pow 2 - &36 * x pow 2)))
<= &144 * x pow 2 / &k`
ASSUME_TAC THENL
[REPEAT STRIP_TAC THEN REWRITE_TAC[
real_div;
SUM_CMUL] THEN
REWRITE_TAC[
REAL_ABS_MUL;
REAL_ABS_NUM;
REAL_ABS_POW;
REAL_POW2_ABS] THEN
REWRITE_TAC[GSYM REAL_MUL_ASSOC] THEN
ONCE_REWRITE_TAC[REAL_ARITH `&144 * x * y = &72 * x * &2 * y`] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN REWRITE_TAC[
REAL_POS] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN
REWRITE_TAC[
REAL_LE_SQUARE; REAL_POW_2] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC `&2 * sum(k + 1,2
EXP n - 1 - k) (\m. inv(&m * &m))` THEN
CONJ_TAC THENL
[REWRITE_TAC[GSYM
SUM_CMUL] THEN
W(fun (asl,w) -> MP_TAC(PART_MATCH lhand
SUM_ABS_LE (lhand w))) THEN
MATCH_MP_TAC(REAL_ARITH `a <= b ==> x <= a ==> x <= b`) THEN
MATCH_MP_TAC
SUM_LE THEN X_GEN_TAC `r:num` THEN STRIP_TAC THEN
REWRITE_TAC[] THEN
SUBGOAL_THEN `&0 < &r * &r - &36 * x * x` ASSUME_TAC THENL
[REWRITE_TAC[GSYM REAL_POW_2] THEN
ONCE_REWRITE_TAC[GSYM
REAL_POW2_ABS] THEN
REWRITE_TAC[REAL_POW_2] THEN
REWRITE_TAC[REAL_ARITH
`&0 < r * r - &36 * x * x <=> (&6 * x) * (&6 * x) < r * r`] THEN
MATCH_MP_TAC
REAL_LT_MUL2 THEN
SIMP_TAC[
REAL_LE_MUL;
REAL_POS;
REAL_ABS_POS] THEN
MATCH_MP_TAC
REAL_LTE_TRANS THEN EXISTS_TAC `&k` THEN
ASM_REWRITE_TAC[
REAL_ABS_NUM] THEN
REWRITE_TAC[REAL_OF_NUM_LE] THEN
ASM_SIMP_TAC[REAL_ARITH `&9 * abs(x) < a ==> &6 * abs(x) < a`] THEN
UNDISCH_TAC `k + 1 <= r` THEN ARITH_TAC; ALL_TAC] THEN
ASM_SIMP_TAC[
real_abs;
REAL_LT_IMP_LE;
REAL_LE_INV_EQ] THEN
GEN_REWRITE_TAC LAND_CONV [GSYM REAL_MUL_LID] THEN
ASM_SIMP_TAC[GSYM
real_div;
REAL_LE_LDIV_EQ] THEN
REWRITE_TAC[
real_div] THEN
ONCE_REWRITE_TAC[AC
REAL_MUL_AC `(a * b) * c = (a * c) * b`] THEN
REWRITE_TAC[GSYM
real_div] THEN
SUBGOAL_THEN `&0 < &r` ASSUME_TAC THENL
[UNDISCH_TAC `k + 1 <= r` THEN REWRITE_TAC[
REAL_OF_NUM_LT] THEN
ARITH_TAC; ALL_TAC] THEN
ASM_SIMP_TAC[
REAL_LE_RDIV_EQ;
REAL_LT_MUL] THEN
REWRITE_TAC[REAL_ARITH `&1 * x <= &2 * (x - y) <=> &2 * y <= x`] THEN
MATCH_MP_TAC(REAL_ARITH
`&0 <= x /\ &81 * x <= y ==> &2 * &36 * x <= y`) THEN
REWRITE_TAC[
REAL_LE_SQUARE] THEN
REWRITE_TAC[REAL_ARITH `&81 * x * x = (&9 * x) * (&9 * x)`] THEN
REWRITE_TAC[GSYM REAL_POW_2] THEN
ONCE_REWRITE_TAC[GSYM
REAL_POW2_ABS] THEN
MATCH_MP_TAC
REAL_POW_LE2 THEN REWRITE_TAC[
REAL_ABS_POS] THEN
REWRITE_TAC[
REAL_ABS_MUL;
REAL_ABS_NUM] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN EXISTS_TAC `&k` THEN
ASM_SIMP_TAC[
REAL_LT_IMP_LE] THEN
UNDISCH_TAC `k + 1 <= r` THEN REWRITE_TAC[REAL_OF_NUM_LE] THEN
ARITH_TAC;
ALL_TAC] THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN REWRITE_TAC[
REAL_POS] THEN
REWRITE_TAC[
SUM_REINDEX] THEN
SUBGOAL_THEN `?d. k = 1 + d` (CHOOSE_THEN SUBST1_TAC) THENL
[REWRITE_TAC[GSYM
LE_EXISTS] THEN
MATCH_MP_TAC(ARITH_RULE `0 < k ==> 1 <= k`) THEN
REWRITE_TAC[GSYM
REAL_OF_NUM_LT] THEN
UNDISCH_TAC `&9 * abs(x) < &k` THEN REAL_ARITH_TAC; ALL_TAC] THEN
SPEC_TAC(`2
EXP n - 1 - (1 + d)`,`n:num`) THEN
POP_ASSUM_LIST(K ALL_TAC) THEN GEN_TAC THEN
GEN_REWRITE_TAC (LAND_CONV o LAND_CONV o LAND_CONV) [
ADD_SYM] THEN
REWRITE_TAC[
SUM_REINDEX] THEN
REWRITE_TAC[ARITH_RULE `(r + 1) + 1 = r + 2`] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC `sum(d,n) (\r. inv(&(r + 1) * &(r + 2)))` THEN
CONJ_TAC THENL
[MATCH_MP_TAC
SUM_LE THEN REPEAT STRIP_TAC THEN
SIMP_TAC[
REAL_LE_RMUL_EQ;
REAL_LT_INV_EQ;
REAL_OF_NUM_LT;
REAL_INV_MUL; ARITH_RULE `0 < n + 2`] THEN
MATCH_MP_TAC
REAL_LE_INV2 THEN
REWRITE_TAC[
REAL_OF_NUM_LT; REAL_OF_NUM_LE] THEN ARITH_TAC;
ALL_TAC] THEN
SUBGOAL_THEN
`!n. sum(d,n) (\r. inv (&(r + 1) * &(r + 2))) =
inv(&(d + 1)) - inv(&(d + n + 1))`
(fun th -> REWRITE_TAC[th])
THENL
[INDUCT_TAC THEN REWRITE_TAC[sum;
ADD_CLAUSES;
REAL_SUB_REFL] THEN
ASM_REWRITE_TAC[REAL_ARITH
`((a - x) + y = a - z) <=> (y + z = x)`] THEN
REWRITE_TAC[GSYM
ADD_ASSOC;
REAL_INV_MUL;
ARITH_RULE `SUC(d + n + 1) = d + n + 2`] THEN
MATCH_MP_TAC
REAL_EQ_RCANCEL_IMP THEN
EXISTS_TAC `&(d + n + 1) * &(d + n + 2)` THEN
REWRITE_TAC[REAL_ARITH
`(dn1' * dn2' + dn2') * (dn1 * dn2) =
(dn1 * dn1' + dn1) * (dn2 * dn2')`] THEN
SIMP_TAC[
REAL_ENTIRE;
REAL_MUL_RINV; REAL_OF_NUM_EQ;
ARITH_RULE `~(d + n + 1 = 0) /\ ~(d + n + 2 = 0)`] THEN
SIMP_TAC[REAL_MUL_ASSOC; REAL_MUL_LINV;
REAL_OF_NUM_EQ; ARITH_RULE `~(d + n + 1 = 0)`] THEN
REWRITE_TAC[REAL_OF_NUM_MUL; REAL_OF_NUM_ADD; REAL_OF_NUM_EQ] THEN
ARITH_TAC; ALL_TAC] THEN
REWRITE_TAC[
ADD_AC] THEN
MATCH_MP_TAC(REAL_ARITH `&0 <= y ==> x - y <= x`) THEN
REWRITE_TAC[
REAL_LE_INV_EQ;
REAL_POS]; ALL_TAC] THEN
X_GEN_TAC `e:real` THEN DISCH_TAC THEN
SUBGOAL_THEN
`?N. &9 * abs(x) + &1 <= &N /\
(Bd * &144 * x pow 2) / e + &1 <= &N`
(X_CHOOSE_THEN `N:num` STRIP_ASSUME_TAC)
THENL
[X_CHOOSE_TAC `N1:num` (SPEC `&9 * abs(x) + &1`
REAL_ARCH_SIMPLE) THEN
X_CHOOSE_TAC `N2:num`
(SPEC `(Bd * &144 * x pow 2) / e + &1`
REAL_ARCH_SIMPLE) THEN
EXISTS_TAC `N1 + N2:num` THEN REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN
ASM_MESON_TAC[
REAL_POS;
REAL_ARITH `a <= m /\ b <= n /\ &0 <= m /\ &0 <= n
==> a <= m + n /\ b <= m + n`];
ALL_TAC] THEN
EXISTS_TAC `N:num` THEN
MAP_EVERY X_GEN_TAC [`n:num`; `k:num`] THEN
STRIP_TAC THEN
MATCH_MP_TAC
REAL_LET_TRANS THEN
EXISTS_TAC
`abs((pi * x / &2 pow (n + 1)) * cot (pi * x / &2 pow (n + 1))) *
sum(k + 1,2
EXP n - 1 - k)
(\m. (&72 * x pow 2) / (&m pow 2 - &36 * x pow 2))` THEN
CONJ_TAC THENL
[FIRST_ASSUM MATCH_MP_TAC THEN
MATCH_MP_TAC
REAL_LTE_TRANS THEN
EXISTS_TAC `&N` THEN ASM_REWRITE_TAC[REAL_OF_NUM_LE] THEN
UNDISCH_TAC `&9 * abs x + &1 <= &N` THEN REAL_ARITH_TAC;
ALL_TAC] THEN
MATCH_MP_TAC
REAL_LET_TRANS THEN
EXISTS_TAC `Bd * &144 * x pow 2 / &k` THEN CONJ_TAC THENL
[ALL_TAC;
REWRITE_TAC[
real_div; REAL_MUL_ASSOC] THEN
REWRITE_TAC[GSYM
real_div] THEN
SUBGOAL_THEN `&0 < &k` (fun th -> SIMP_TAC[
REAL_LT_LDIV_EQ; th]) THENL
[MATCH_MP_TAC
REAL_LTE_TRANS THEN EXISTS_TAC `&N` THEN
ASM_REWRITE_TAC[REAL_OF_NUM_LE] THEN
UNDISCH_TAC `&9 * abs x + &1 <= &N` THEN REAL_ARITH_TAC; ALL_TAC] THEN
GEN_REWRITE_TAC RAND_CONV [REAL_MUL_SYM] THEN
ASM_SIMP_TAC[GSYM
REAL_LT_LDIV_EQ] THEN
REWRITE_TAC[
real_div; REAL_MUL_ASSOC] THEN
REWRITE_TAC[GSYM
real_div] THEN
MATCH_MP_TAC
REAL_LTE_TRANS THEN EXISTS_TAC `&N` THEN
ASM_REWRITE_TAC[GSYM REAL_MUL_ASSOC; REAL_OF_NUM_LE] THEN
ASM_SIMP_TAC[REAL_ARITH `x + &1 <= y ==> x < y`]] THEN
MATCH_MP_TAC(REAL_ARITH `abs(x) <= a ==> x <= a`) THEN
ONCE_REWRITE_TAC[
REAL_ABS_MUL] THEN
MATCH_MP_TAC
REAL_LE_MUL2 THEN REWRITE_TAC[
REAL_ABS_POS] THEN
CONJ_TAC THENL
[REWRITE_TAC[
REAL_ABS_ABS] THEN FIRST_ASSUM MATCH_MP_TAC THEN
ASM_SIMP_TAC[
real_div;
REAL_ENTIRE;
REAL_LT_IMP_NZ;
REAL_POW2_CLAUSES;
REAL_MUL_ASSOC;
REAL_LT_INV_EQ;
PI_POS] THEN
SIMP_TAC[GSYM
real_div;
REAL_ABS_DIV;
REAL_ABS_POW;
REAL_ABS_NUM] THEN
SIMP_TAC[
REAL_LE_LDIV_EQ;
REAL_POW2_CLAUSES; REAL_MUL_LID] THEN
REWRITE_TAC[
REAL_ABS_MUL] THEN
SIMP_TAC[
real_abs;
REAL_LT_IMP_LE;
PI_POS] THEN
ASM_REWRITE_TAC[GSYM
real_abs]; ALL_TAC] THEN
FIRST_ASSUM MATCH_MP_TAC THEN
MATCH_MP_TAC
REAL_LTE_TRANS THEN EXISTS_TAC `&N:real` THEN
ASM_REWRITE_TAC[REAL_OF_NUM_LE] THEN
UNDISCH_TAC `&9 * abs x + &1 <= &N` THEN
REAL_ARITH_TAC; ALL_TAC] THEN
SUBGOAL_THEN
`!n k. k < 2
EXP n
==> ((pi * x) *
(cot (pi * x / &2 pow n) / &2 pow n +
sum (1,2
EXP n - 1)
(\k. cot(pi * (x + &k) / &2 pow (n + 1)) +
cot(pi * (x - &k) / &2 pow (n + 1))) /
&2 pow (n + 1)) = A n k + B n k)`
MP_TAC THENL
[REPEAT GEN_TAC THEN DISCH_TAC THEN
MAP_EVERY EXPAND_TAC ["A";