(`!s t. 0
t)
==> schnirelmann(s +++ t)
>= (schnirelmann s + schnirelmann t) -
schnirelmann s * schnirelmann t`,
REWRITE_TAC[
IN_INTER] THEN REPEAT STRIP_TAC THEN REWRITE_TAC[
real_ge] THEN
MATCH_MP_TAC SCHNIRELMANN_LBOUND THEN X_GEN_TAC `n:num` THEN STRIP_TAC THEN
ASM_SIMP_TAC[
REAL_LE_RDIV_EQ;
REAL_OF_NUM_LT;
LE_1] THEN
MP_TAC(SPECL [`count s n`; `s
INTER (1..n)`; `n:num`]
ENUMERATION_LEMMA) THEN
SIMP_TAC[count;
HAS_SIZE;
FINITE_INTER;
FINITE_NUMSEG] THEN
SIMP_TAC[
IN_INTER;
IN_NUMSEG] THEN
DISCH_THEN(X_CHOOSE_THEN `a:num->num` STRIP_ASSUME_TAC) THEN
ABBREV_TAC `A =
CARD(s
INTER (1..n))` THEN
SUBGOAL_THEN `!k. k <= A ==> (a:num->num)(k)
IN s /\ a(k) <= n`
ASSUME_TAC THENL
[GEN_TAC THEN DISCH_TAC THEN
FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [
EXTENSION]) THEN
DISCH_THEN(MP_TAC o SPEC `(a:num->num)(k)`) THEN
DISJ_CASES_TAC(ARITH_RULE `k = 0 \/ 1 <= k`) THEN
ASM_REWRITE_TAC[
LE_0;
IN_INTER;
IN_NUMSEG] THEN
MATCH_MP_TAC(TAUT `d ==> (a /\ b /\ c <=> d) ==> a /\ c`) THEN
REWRITE_TAC[
IN_IMAGE;
IN_NUMSEG] THEN ASM_MESON_TAC[];
ALL_TAC] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC `&(
CARD ((s +++ t)
INTER (0..n))) - &1` THEN CONJ_TAC THENL
[ALL_TAC;
ASM_SIMP_TAC[
CARD_INTER_0_1;
SUMSET_0; GSYM
REAL_OF_NUM_SUC] THEN
REAL_ARITH_TAC] THEN
REWRITE_TAC[
REAL_LE_SUB_LADD] THEN MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC
`&(
CARD(
UNIONS(
IMAGE (\i. (
IMAGE (\b. a i + b)
(t
INTER (0..(a(i+1) - a(i) - 1)))))
(0..A))))` THEN
CONJ_TAC THENL
[ALL_TAC;
REWRITE_TAC[REAL_OF_NUM_LE] THEN MATCH_MP_TAC
CARD_SUBSET THEN
SIMP_TAC[
FINITE_INTER;
FINITE_NUMSEG;
UNIONS_SUBSET;
FORALL_IN_IMAGE] THEN
REWRITE_TAC[
SUBSET;
FORALL_IN_IMAGE] THEN
X_GEN_TAC `k:num` THEN DISCH_TAC THEN X_GEN_TAC `l:num` THEN
REWRITE_TAC[
IN_INTER] THEN REPEAT STRIP_TAC THEN
RULE_ASSUM_TAC(REWRITE_RULE[
IN_NUMSEG]) THENL
[REWRITE_TAC[sumset;
IN_ELIM_THM] THEN ASM_MESON_TAC[]; ALL_TAC] THEN
REWRITE_TAC[
IN_NUMSEG;
LE_0] THEN
MATCH_MP_TAC(ARITH_RULE
`a(k) < a(k + 1) /\ a(k + 1) <= n + 1 /\ l <= a(k + 1) - a(k) - 1
==> a(k) + l <= n`) THEN
ASM_REWRITE_TAC[] THEN CONJ_TAC THENL
[FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC; ALL_TAC] THEN
ASM_CASES_TAC `k:num = A` THEN ASM_REWRITE_TAC[
LE_REFL] THEN
REPEAT(FIRST_X_ASSUM(MP_TAC o SPEC `k + 1`)) THEN ASM_ARITH_TAC] THEN
W(MP_TAC o PART_MATCH (lhs o rand)
CARD_UNIONS o rand o rand o snd) THEN
REWRITE_TAC[
FORALL_IN_IMAGE;
IMP_CONJ;
RIGHT_FORALL_IMP_THM] THEN
SIMP_TAC[
FINITE_IMAGE;
FINITE_NUMSEG;
FINITE_INTER] THEN
SUBGOAL_THEN
`!i j. i
IN 0..A /\ j
IN 0..A /\ ~(i = j)
==>
IMAGE (\b. a i + b) (t
INTER (0..a (i + 1) - a i - 1))
INTER
IMAGE (\b. a j + b) (t
INTER (0..a (j + 1) - a j - 1)) = {}`
(LABEL_TAC "*") THENL
[MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN STRIP_TAC THEN
REWRITE_TAC[SET_RULE
`
IMAGE f s
INTER t = {} <=> !x. x
IN s ==> ~(f x
IN t)`] THEN
X_GEN_TAC `k:num` THEN DISCH_TAC THEN REWRITE_TAC[
IN_IMAGE] THEN
DISCH_THEN(X_CHOOSE_THEN `l:num` STRIP_ASSUME_TAC) THEN
RULE_ASSUM_TAC(REWRITE_RULE[
IN_NUMSEG;
IN_INTER]) THEN
SUBGOAL_THEN `a(i + 1):num <= a(j) \/ a(j + 1) <= a(i)` MP_TAC THENL
[FIRST_X_ASSUM(DISJ_CASES_TAC o MATCH_MP (ARITH_RULE
`~(i = j) ==> i + 1 <= j \/ j + 1 <= i`))
THENL [DISJ1_TAC; DISJ2_TAC] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN
ASM_ARITH_TAC;
ALL_TAC] THEN
SUBGOAL_THEN `(a:num->num)(i) < a(i + 1) /\ a(j) < a(j + 1)`
STRIP_ASSUME_TAC THENL
[CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC; ALL_TAC] THEN
ASM_ARITH_TAC;
ALL_TAC] THEN
ANTS_TAC THENL
[X_GEN_TAC `i:num` THEN DISCH_TAC THEN
X_GEN_TAC `j:num` THEN DISCH_TAC THEN
ASM_CASES_TAC `i:num = j` THEN ASM_REWRITE_TAC[] THEN ASM_MESON_TAC[];
ALL_TAC] THEN
DISCH_THEN SUBST1_TAC THEN
W(MP_TAC o PART_MATCH (lhs o rand)
NSUM_IMAGE_NONZERO o
rand o rand o snd) THEN
REWRITE_TAC[] THEN ANTS_TAC THENL
[REWRITE_TAC[
FINITE_NUMSEG] THEN MAP_EVERY X_GEN_TAC [`i:num`; `j:num`] THEN
STRIP_TAC THEN REMOVE_THEN "*" (MP_TAC o SPECL [`i:num`; `j:num`]) THEN
ASM_REWRITE_TAC[
INTER_ACI] THEN SIMP_TAC[
CARD_CLAUSES];
ALL_TAC] THEN
DISCH_THEN SUBST1_TAC THEN REWRITE_TAC[
o_DEF] THEN
SIMP_TAC[
EQ_ADD_LCANCEL;
CARD_IMAGE_INJ;
FINITE_INTER;
FINITE_NUMSEG] THEN
SIMP_TAC[
REAL_OF_NUM_SUM;
FINITE_INTER;
FINITE_NUMSEG] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC
`sum(0..A) (\i. schnirelmann t * &(a(i + 1) - a(i) - 1) + &1)` THEN
CONJ_TAC THENL
[ALL_TAC;
MATCH_MP_TAC
SUM_LE_NUMSEG THEN REWRITE_TAC[] THEN
ASM_SIMP_TAC[
CARD_INTER_0_1;
SUMSET_0; GSYM
REAL_OF_NUM_SUC] THEN
SIMP_TAC[GSYM count;
SCHNIRELMANN_UBOUND_MUL;
REAL_LE_RADD]] THEN
REWRITE_TAC[
SUM_ADD_NUMSEG;
SUM_CONST_NUMSEG] THEN
REWRITE_TAC[
SUB_0; GSYM REAL_OF_NUM_ADD;
REAL_MUL_RID] THEN
REWRITE_TAC[REAL_ADD_ASSOC;
REAL_LE_RADD] THEN
MATCH_MP_TAC
REAL_LE_TRANS THEN
EXISTS_TAC
`sum(0..A) (\i. schnirelmann t * (&(a(i + 1)) - &(a i) - &1)) + &A` THEN
CONJ_TAC THENL
[ALL_TAC;
REWRITE_TAC[
REAL_LE_RADD] THEN MATCH_MP_TAC
SUM_LE_NUMSEG THEN
X_GEN_TAC `i:num` THEN STRIP_TAC THEN
SUBGOAL_THEN `a(i):num < a(i + 1)` ASSUME_TAC THENL
[FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_ARITH_TAC; ALL_TAC] THEN
ASM_SIMP_TAC[
REAL_OF_NUM_SUB;
LT_IMP_LE; ARITH_RULE `a < b ==> 1 <= b - a`;
REAL_LE_REFL]] THEN
REWRITE_TAC[
SUM_LMUL] THEN
ONCE_REWRITE_TAC[REAL_ARITH `a - b - c:real = --((b - a) + c)`] THEN
REWRITE_TAC[
SUM_NEG;
SUM_ADD_NUMSEG;
SUM_DIFFS;
LE_0] THEN
ASM_REWRITE_TAC[REAL_ARITH `--(&0 - a + b) = a - b`;
SUM_CONST_NUMSEG] THEN
REWRITE_TAC[
SUB_0; GSYM REAL_OF_NUM_ADD;
REAL_MUL_RID] THEN
REWRITE_TAC[REAL_ARITH `(n + &1) - (a + &1) = n - a`] THEN
MATCH_MP_TAC(REAL_ARITH
`(&1 - t) * s * n <= (&1 - t) * a
==> ((s + t) - s * t) * n <= t * (n - a) + a`) THEN
MATCH_MP_TAC
REAL_LE_LMUL THEN EXPAND_TAC "A" THEN
REWRITE_TAC[
REAL_SUB_LE;
SCHNIRELMANN_UBOUND_MUL; GSYM count] THEN
REWRITE_TAC[
SCHNIRELMANN_BOUNDS]);;