needs "Library/analysis.ml";; needs "Library/transc.ml";; needs "Library/floor.ml";; needs "Library/calc_real.ml";; needs "Examples/machin.ml";; (* ----- definitions used in external theorems *) let log2 = new_definition ` log2 x = (ln x) / (ln (&2)) `;; let ceil = new_definition ` ceil x = -- floor(--x) `;; let o1_seq = new_definition ` o1_seq (f:num->real) <=> !e:real. &0 < e ==> ?m:num. !i:num. m <= i ==> abs(f(i)) <= e `;; parse_as_infix("powreal",(24,"left"));; let powreal = new_definition ` x powreal y = exp(y * ln x) `;; let bkzdelta = new_definition ` bkzdelta x = (x * ((pi*x) powreal (&1 / x))/(&2 * pi * exp(&1))) powreal (&1 / (&2 * (x - &1))) `;; let standardratio = new_definition ` standardratio n q s k x = ( ((n + k)*(s pow 2) + &1) powreal (&1 / &2) ) / ( (((n + k + &1)/x) powreal (&1 / &2)) * ((bkzdelta x) powreal (&2 * x - (n + k + &1) - &1)) * (q powreal (k/(n + k + &1))) ) `;; (* ----- definitions used internally *) parse_as_infix("pow_num",(24,"left"));; let pow_num = define ` ((p:A->A) pow_num n) = if n = 0 then (I:A->A) else (p o (p pow_num(n-1))) `;; (* ----- tactics *) let proven_if t = ASM_CASES_TAC t THENL [ASM_MESON_TAC []; ALL_TAC];; let notetac t tac = SUBGOAL_THEN t MP_TAC THENL [tac; ALL_TAC] THEN DISCH_THEN(fun th -> ASSUME_TAC th);; let note t why = notetac t(ASM_MESON_TAC why);; let note_eqlambda t why = notetac t(MATCH_MP_TAC EQ_EXT THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC why);; let specialize v th = ASSUME_TAC(UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (ISPECL v th)));; let specialize_forward v th = ASSUME_TAC(UNDISCH_ALL (fst (EQ_IMP_RULE (UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (ISPECL v th))))));; let specialize_reverse v th = ASSUME_TAC(UNDISCH_ALL (snd (EQ_IMP_RULE (UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (ISPECL v th))))));; let choose_specializing t v th = X_CHOOSE_TAC t(UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (ISPECL v th)));; let specialize_forward_strip v th = STRIP_ASSUME_TAC(UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (fst (EQ_IMP_RULE (ISPECL v th)))));; let specialize_strip v th = STRIP_ASSUME_TAC(UNDISCH_ALL (REWRITE_RULE [IMP_CONJ] (ISPECL v th)));; let real_cancel t = specialize[](REAL_FIELD t);; let real_linear t = specialize[](REAL_ARITH t);; let def n d = X_CHOOSE_TAC n(MESON [] (mk_exists (n, mk_eq (n, d))));; let choose n p why = note(mk_exists (n, p)) why THEN X_CHOOSE_TAC n(UNDISCH (TAUT (mk_imp (mk_exists (n, p), mk_exists (n, p)))));; (* ----- sets *) let element_implies_nonempty = prove(` !S:real->bool x:real. S x ==> ~(S = {}) `, REWRITE_TAC [GSYM EMPTY_GSPEC] THEN REWRITE_TAC [EXTENSION] THEN REWRITE_TAC [IN_ELIM_THM] THEN REWRITE_TAC [IN] THEN MESON_TAC []);; let element_implies_nonempty2 = prove(` !S:real->bool x:real. x IN S ==> ~(S = {}) `, MESON_TAC [IN; element_implies_nonempty]);; let singleton_not_empty = prove(` !a:A. ~({a} = {}) `, REWRITE_TAC [GSYM EMPTY_GSPEC] THEN REWRITE_TAC [GSYM SING_GSPEC] THEN REWRITE_TAC [INSERT] THEN REWRITE_TAC [IN_ELIM_THM] THEN REWRITE_TAC [EXTENSION] THEN REWRITE_TAC [IN_ELIM_THM] THEN MESON_TAC []);; let singleton_union_not_empty = prove(` !a:A S. ~({a} UNION S = {}) `, MESON_TAC [EMPTY_UNION; singleton_not_empty]);; let num_chop_infinite = prove(` !P:num->bool m:num. INFINITE {i | P(i)} ==> INFINITE {i | m <= i /\ P(i)} `, REPEAT STRIP_TAC THEN notetac `{i:num | P(i)} = {i | i < m /\ P(i)} UNION {i | m <= i /\ P(i)}` (REWRITE_TAC [ARITH_RULE `i:num < m <=> ~(m <= i)`] THEN SET_TAC []) THEN note `FINITE {i:num | i < m}` [FINITE_NUMSEG_LT] THEN notetac `{i:num | i < m /\ P(i)} SUBSET {i:num | i < m}` (SET_TAC []) THEN note `FINITE {i:num | i < m /\ P(i)}` [FINITE_SUBSET] THEN ASM_MESON_TAC [FINITE_UNION; INFINITE]);; (* ----- integer arithmetic *) let max_le = prove(` !a:num b:num c:num. MAX a b <= c <=> a <= c /\ b <= c `, REWRITE_TAC [MAX] THEN MESON_TAC [LE_TRANS; NOT_LE; LT_IMP_LE]);; let le_min = prove(` !a:num b:num c:num. c <= MIN a b <=> c <= a /\ c <= b `, REWRITE_TAC [MIN] THEN MESON_TAC [LE_TRANS; NOT_LE; LT_IMP_LE]);; (* ----- real-number arithmetic *) let pos_times_neg = prove(` !x y. &0 < x /\ y < &0 ==> x*y < &0 `, MESON_TAC [REAL_NEG_GT0; REAL_NEG_RMUL; REAL_LT_MUL]);; let neg_times_pos = prove(` !x y. &0 < x /\ y < &0 ==> y*x < &0 `, MESON_TAC [REAL_NEG_GT0; REAL_NEG_LMUL; REAL_LT_MUL]);; let neg_over_pos = prove(` !x y. &0 < x /\ y < &0 ==> y/x < &0 `, MESON_TAC [real_div; neg_times_pos; REAL_LT_INV]);; let recipflip = prove(` !x:real y:real. &0 < x /\ &0 < y /\ &1/x <= y ==> &1/y <= x `, MESON_TAC [REAL_MUL_SYM; REAL_LE_RDIV_EQ; REAL_LE_LDIV_EQ]);; let divltflip = prove(` !x y z. &0 < x /\ &0 < y /\ z / y < x ==> z / x < y `, MESON_TAC [REAL_LT_RDIV_EQ; REAL_LT_LDIV_EQ; REAL_MUL_SYM]);; let ltdivflip = prove(` !x y z. &0 < x /\ &0 < y /\ x < z / y ==> y < z / x `, MESON_TAC [REAL_LT_RDIV_EQ; REAL_LT_LDIV_EQ; REAL_MUL_SYM]);; let eqdivflip = prove(` !x y z. &0 < x /\ &0 < y /\ x = z / y ==> y = z / x `, MESON_TAC [REAL_EQ_RDIV_EQ; REAL_EQ_LDIV_EQ; REAL_MUL_SYM]);; let pos_1over = prove(` !x:real. &0 < x ==> &0 < &1 / x `, MESON_TAC [REAL_INV_POS; REAL_FIELD `&1 / x = inv x`]);; let nz_1over = prove(` !x:real. ~(x = &0) ==> ~(&1 / x = &0) `, MESON_TAC [REAL_INV_NZ; REAL_FIELD `&1 / x = inv x`]);; let lt_1over = prove(` !x:real y:real. &0 < x /\ x < y ==> &1 / y < &1 / x `, MESON_TAC [REAL_LT_INV2; REAL_FIELD `&1 / x = inv x`]);; let le_1over = prove(` !x:real y:real. &0 < x /\ x <= y ==> &1 / y <= &1 / x `, MESON_TAC [REAL_LE_INV2; REAL_FIELD `&1 / x = inv x`]);; let le_1over_reverse = prove(` !x:real y:real. &0 < x /\ &1 / x <= &1 / y ==> y <= x `, REPEAT STRIP_TAC THEN specialize [`x:real`] pos_1over THEN specialize [`&1/x`; `&1/y`] le_1over THEN ASM_MESON_TAC [REAL_FIELD `&1 / (&1 / z) = z`]);; let mono_min = prove(` !x y f:real->real. (!a b. a <= b ==> f(a) <= f(b)) ==> min (f(x)) (f(y)) = f(min x y) `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `x <= y` THENL [REWRITE_TAC [real_min] THEN ASM_MESON_TAC []; ASSUME_TAC (UNDISCH (fst (EQ_IMP_RULE (ISPECL [`x:real`; `y:real`] REAL_NOT_LE)))) THEN ASSUME_TAC (UNDISCH (ISPECL [`y:real`; `x:real`] REAL_LT_IMP_LE)) THEN ONCE_REWRITE_TAC [REAL_MIN_SYM] THEN REWRITE_TAC [real_min] THEN ASM_MESON_TAC []]);; (* ----- ceil *) let ceil_pos = prove(` !x. &0 < x <=> &1 <= ceil(x) `, REWRITE_TAC [ceil] THEN MESON_TAC [REAL_ARITH `--(-- &1) = &1`; REAL_ARITH `&0 < x <=> --x - &1 < -- &1`; prove (` integer(-- &1) `, MESON_TAC [INTEGER_CASES]); REAL_FLOOR_LE; REAL_ARITH ` floor(--x) <= -- &1 <=> &1 <= -- floor(--x) `]);; let ceil_mono = prove(` !x y. x <= y ==> ceil x <= ceil y `, REWRITE_TAC [ceil] THEN MESON_TAC [FLOOR_MONO; REAL_LE_NEG2]);; let ceil_isinteger = prove(` !x. integer(ceil x) `, REWRITE_TAC [ceil] THEN MESON_TAC [FLOOR; INTEGER_NEG]);; let ceil_ge = prove(` !x. x <= ceil(x) `, REWRITE_TAC [ceil] THEN MESON_TAC [FLOOR; REAL_LE_NEG2; REAL_NEG_NEG]);; let ceil_lt_plus1 = prove(` !x. ceil(x) < x + &1 `, REWRITE_TAC [ceil] THEN MESON_TAC [FLOOR; REAL_LT_NEG2; REAL_ARITH `--x < y + &1 ==> --y < x + &1`]);; (* ----- continuity *) (* copied from CONT_MUL in Library/analysis.ml *) (* but includes f and g explicitly for easy specialization *) let cont_mul_fullvariables = prove(` !x f g. f contl x /\ g contl x ==> (\x. f(x) * g(x)) contl x `, GEN_TAC THEN REWRITE_TAC [CONTL_LIM] THEN BETA_TAC THEN MATCH_ACCEPT_TAC LIM_MUL);; let cont_const_fullvariables = prove(` !x k. (\x. k) contl x `, REPEAT GEN_TAC THEN REWRITE_TAC [CONTL_LIM] THEN MATCH_ACCEPT_TAC LIM_CONST);; let cont_add_fullvariables = prove(` !x f g. f contl x /\ g contl x ==> (\x. f(x) + g(x)) contl x `, GEN_TAC THEN REWRITE_TAC [CONTL_LIM] THEN BETA_TAC THEN MATCH_ACCEPT_TAC LIM_ADD);; let cont_neg_fullvariables = prove(` !x f. f contl x ==> (\x. --(f(x))) contl x `, GEN_TAC THEN REWRITE_TAC [CONTL_LIM] THEN BETA_TAC THEN REWRITE_TAC [GSYM LIM_NEG]);; let cont_div_fullvariables = prove(` !x f g. f contl x /\ g contl x /\ ~(g x = &0) ==> (\x. f(x) / g(x)) contl x `, GEN_TAC THEN REWRITE_TAC [CONTL_LIM] THEN BETA_TAC THEN MATCH_ACCEPT_TAC LIM_DIV);; let cont_consttimes = prove(` !x:real c:real. (\x. c * x) contl x `, MESON_TAC [ISPECL [`x:real`; `\(x:real).(c:real)`; `\(x:real).x`] cont_mul_fullvariables; CONT_X; CONT_CONST]);; let cont_1overcplusx = prove(` !x:real c:real. ~(c + x = &0) ==> (\x. &1 / (c + x)) contl x `, REPEAT GEN_TAC THEN MESON_TAC [ISPECL [`x:real`] CONT_X; ISPECL [`x:real`; `&1:real`] cont_const_fullvariables; ISPECL [`x:real`; `c:real`] cont_const_fullvariables; ISPECL [`x:real`; `\(x:real).(c:real)`; `\(x:real).x`] cont_add_fullvariables; ISPECL [`x:real`; `\(x:real).(&1:real)`; `\(x:real).c+x`] cont_div_fullvariables]);; let cont_1overcplusx_at0 = prove(` !c:real. ~(c = &0) ==> (\x. &1 / (c + x)) contl &0 `, MESON_TAC [cont_1overcplusx; REAL_ARITH `~(c = &0) ==> ~(c + &0 = &0)`]);; (* ----- derivatives *) let deriv_positive = prove(` !f f' a b z. a < z /\ z < b /\ (f b - f a = (b - a) * f'(z)) /\ &0 < f'(z) ==> f(a) < f(b) `, MESON_TAC [REAL_LT_TRANS; REAL_ARITH `a < b <=> &0 < b - a`; REAL_LT_MUL]);; let deriv_negative = prove(` !f f' a b z. a < z /\ z < b /\ (f b - f a = (b - a) * f'(z)) /\ f'(z) < &0 ==> f(b) < f(a) `, MESON_TAC [REAL_LT_TRANS; REAL_ARITH `a < b <=> &0 < b - a`; pos_times_neg; REAL_ARITH `b - a < &0 ==> b < a`]);; let deriv_positive2 = prove(` !f f' a b. (!x. a <= x /\ x <= b ==> &0 < f'(x)) /\ (?z. a < z /\ z < b /\ (f b - f a = (b - a) * f'(z))) ==> f(a) < f(b) `, MESON_TAC [deriv_positive; REAL_LT_IMP_LE]);; let deriv_negative2 = prove(` !f f' a b. (!x. a <= x /\ x <= b ==> f'(x) < &0) /\ (?z. a < z /\ z < b /\ (f b - f a = (b - a) * f'(z))) ==> f(b) < f(a) `, MESON_TAC [deriv_negative; REAL_LT_IMP_LE]);; let deriv_positive3 = prove(` !f f' a b. a < b /\ (!x. a <= x /\ x <= b ==> (f diffl f'(x))(x)) /\ (!x. a <= x /\ x <= b ==> &0 < f'(x)) ==> f(a) < f(b) `, REPEAT STRIP_TAC THEN ASSUME_TAC (ISPECL [`f:real->real`; `f':real->real`; `a:real`; `b:real`] MVT_ALT) THEN ASSUME_TAC (ISPECL [`f:real->real`; `f':real->real`; `a:real`; `b:real`] deriv_positive2) THEN ASM_MESON_TAC []);; let deriv_negative3 = prove(` !f f' a b. a < b /\ (!x. a <= x /\ x <= b ==> (f diffl f'(x))(x)) /\ (!x. a <= x /\ x <= b ==> f'(x) < &0) ==> f(b) < f(a) `, REPEAT STRIP_TAC THEN ASSUME_TAC (ISPECL [`f:real->real`; `f':real->real`; `a:real`; `b:real`] MVT_ALT) THEN ASSUME_TAC (ISPECL [`f:real->real`; `f':real->real`; `a:real`; `b:real`] deriv_negative2) THEN ASM_MESON_TAC []);; let deriv_negative4 = prove(` !f f' a b. a <= b /\ (!x. a <= x /\ x <= b ==> (f diffl f'(x))(x)) /\ (!x. a <= x /\ x <= b ==> f'(x) < &0) ==> f(b) <= f(a) `, REPEAT STRIP_TAC THEN DISJ_CASES_TAC (ISPECL [`a:real`; `b:real`] REAL_LT_TOTAL) THENL [ASM_MESON_TAC [REAL_ARITH `f(x:real):real = f y ==> f x <= f y`]; ASM_MESON_TAC [deriv_negative3; real_lt; REAL_LT_IMP_LE]]);; let mvt_twosided = prove(` !f f' a b d. &0 < d /\ (!x. abs(x - a) < d ==> (f diffl f'(x))(x)) /\ abs(b - a) < d ==> ?z. abs(z - a) <= abs(b - a) /\ (f(b) - f(a) = (b-a) * f'(z)) `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `b = a:real` THENL [EXISTS_TAC `a:real` THEN ASM_MESON_TAC [REAL_LE_REFL; REAL_ARITH `x - x = &0`; REAL_ARITH `&0 * x = &0`]; ALL_TAC] THEN ASM_CASES_TAC `a < b:real` THENL [note `!x:real. a <= x /\ x <= b ==> (f diffl f'(x))(x)` [REAL_ARITH `abs(b - a) < d /\ a <= x /\ x <= b ==> abs(x - a) < d`] THEN choose `z:real` `a:real < z /\ z < b /\ (f b - f a = (b - a) * f'(z))` [MVT_ALT] THEN EXISTS_TAC `z:real` THEN ASM_MESON_TAC [REAL_ARITH `a < z /\ z < b ==> abs(z - a) <= abs(b - a)`]; note `b < a` [REAL_ARITH `~(b = a) /\ ~(a < b) ==> b < a`] THEN note `!x:real. b <= x /\ x <= a ==> (f diffl f'(x))(x)` [REAL_ARITH `abs(b - a) < d /\ b <= x /\ x <= a ==> abs(x - a) < d`] THEN choose `z:real` `b:real < z /\ z < a /\ (f a - f b = (a - b) * f'(z))` [MVT_ALT] THEN EXISTS_TAC `z:real` THEN ASM_MESON_TAC [REAL_ARITH `b < z /\ z < a ==> abs(z - a) <= abs(b - a)`; REAL_ARITH `fa - fb = (b - a) * c ==> fb - fa = (a - b) * c`]]);; (* ----- bounded sequence has convergent subsequence *) (* This theorem is due to 1817 Bolzano. Weierstrass was born in 1815. The following proof starts with the proof in 2018 Eidolon--Oman (https://www.tandfonline.com/doi/abs/10.4169/college.math.j.48.4.288), removes unnecessary proof-by-contradiction steps, adapts to sequences. Define L_i = inf{s_i,s_{i+1},...}. Case 1: For some i, L_i isn't in {s_i,s_{i+1},...}. Then (s_i,s_{i+1},...) has a subsequence converging (down) to L_i. Case 2: For each i, L_i is in {s_i,s_{i+1},...}. Define f(i) = min{j in {i,i+1,...}: s_j = L_i}. Then the infinite subsequence (s_{f(0)},s_{f(f(0)+1)},...) of s is exactly (L_0,L_{f(0)+1},L_{f(f(0)+1)},...) which is nondecreasing and bounded, hence converges (up) to its sup. Q.E.D. For comparison, in the usual "valley" proof (which is the usual "peak" proof modulo exchanging < and >), a "valley" is an index i for which s_i = inf {s_i,s_{i+1},...}. That's equivalent to s_i = L_i, or in other words f(i) = i, but the case split is defined by finitely vs. infinitely many valleys. In the finite case, one then takes an index past all the valleys and recursively constructs a sequence converging downwards. There's also the "bisection" proof, which has a different flavor. The HOL Light library has a few Bolzano variants, but it's not clear that using them is easier than giving a direct proof. *) let hasinf_union = prove(` !s t L. ~(s = {}) /\ ~(t = {}) /\ (s UNION t) has_inf L ==> L = min (inf s) (inf t) `, REPEAT STRIP_TAC THEN note `L:real = inf(s UNION t)` [HAS_INF_INF] THEN note `!x:real. x IN (s UNION t) ==> L <= x` [HAS_INF] THEN note `!x:real. x IN s ==> x IN (s UNION t)` [IN_UNION] THEN note `!x:real. x IN t ==> x IN (s UNION t)` [IN_UNION] THEN note `?r. !x:real. x IN s ==> r <= x` [] THEN note `?r. !x:real. x IN t ==> r <= x` [] THEN specialize [`s:real->bool`; `t:real->bool`] INF_UNION THEN ASM_MESON_TAC []);; let hasinf_union_avoiding_finite = prove(` !s t L. ~(t = {}) /\ (s UNION t) has_inf L /\ FINITE s /\ ~(L IN s) ==> t has_inf L `, REPEAT STRIP_TAC THEN note `s:real->bool = {} ==> s UNION t = t` [UNION_EMPTY] THEN proven_if `s:real->bool = {}` THEN note `L = min (inf s) (inf t)` [hasinf_union] THEN note `inf s IN s` [INF_FINITE] THEN note `~(L = inf s)` [] THEN note `L = inf t` [REAL_ARITH `L = min x y /\ ~(L = x) ==> L = y`] THEN note `!x:real. x IN t ==> x IN (s UNION t)` [IN_UNION] THEN note `!x:real. x IN (s UNION t) ==> L <= x` [HAS_INF] THEN ASM_MESON_TAC [HAS_INF_INF]);; let seq_chop_range = prove(` !s:num->real a b. a <= b ==> {s(j) | a <= j} = {s(j) | a <= j /\ j < b} UNION {s(j) | b <= j} `, REWRITE_TAC [UNION; IN_ELIM_THM; EXTENSION] THEN MESON_TAC [ARITH_RULE `a <= b:num /\ b <= j ==> a <= j`; NOT_LT]);; let seq_chop_hasinf = prove(` !s:num->real a b L. a <= b /\ {s(j) | a <= j} has_inf L /\ ~(L IN {s(j) | a <= j /\ j < b}) ==> {s(j) | b <= j} has_inf L `, REPEAT STRIP_TAC THEN note `FINITE {j:num | j < b}` [FINITE_NUMSEG_LT] THEN notetac `{j:num | a <= j /\ j < b} SUBSET {j | j < b}` (SET_TAC []) THEN note `FINITE {j:num | a <= j /\ j < b}` [FINITE_SUBSET] THEN note `FINITE (IMAGE (s:num->real) {j:num | a <= j /\ j < b})` [FINITE_IMAGE] THEN note `{s(j:num):real | a <= j /\ j < b} = IMAGE s {j:num | a <= j /\ j < b}` [ISPECL [`s:num->real`; `\j:num. a <= j /\ j < b`] SIMPLE_IMAGE_GEN] THEN note `FINITE {s(j:num):real | a <= j /\ j < b}` [] THEN note `{s(j:num):real | a <= j} = {s(j) | a <= j /\ j < b} UNION {s(j) | b <= j}` [seq_chop_range] THEN notetac `~({s(j:num):real | b <= j} = {})` (SET_TAC [ARITH_RULE `b:num <= b`]) THEN note `{s(j:num):real | a <= j /\ j < b} UNION {s j | b <= j} has_inf L` [] THEN specialize [`{s(j:num):real | a <= j /\ j < b}`; `{s(j:num):real | b <= j}`; `L:real`] hasinf_union_avoiding_finite THEN ASM_MESON_TAC []);; let seq_chop_hasinf2 = prove(` !s:num->real a b L. a <= b /\ {s(j) | a <= j} has_inf L /\ ~(L IN {s(j) | a <= j}) ==> {s(j) | b <= j} has_inf L `, REPEAT STRIP_TAC THEN notetac `~(L IN {s(j:num):real | a <= j}) ==> ~(L IN {s(j) | a <= j /\ j < b})` (SET_TAC []) THEN ASM_MESON_TAC [seq_chop_hasinf]);; let seq_chop_hasinf_approach = prove(` !s:num->real a L c. {s(j) | a <= j} has_inf L /\ ~(L IN {s(j) | a <= j}) ==> ?k. c < k /\ s(k) < L + &1 / &(c+1) `, REPEAT STRIP_TAC THEN def `b:num` `MAX a (c+1)` THEN notetac `a <= MAX a (c+1)` ARITH_TAC THEN note `a:num <= b` [] THEN note `{s(j:num) | b <= j} has_inf L` [seq_chop_hasinf2] THEN notetac `c < MAX a (c+1)` ARITH_TAC THEN note `c:num < b` [] THEN notetac `0 < c + 1` ARITH_TAC THEN note `&0 < &(c+1)` [REAL_OF_NUM_LT] THEN note `&0 < &1 / &(c+1)` [pos_1over] THEN real_linear `&0 < &1 / &(c+1) ==> L < L + &1 / &(c+1)` THEN choose_specializing `x:real` [`{s(j:num):real | b <= j}`; `L:real`; `L + &1 / &(c+1)`] HAS_INF_APPROACH THEN notetac `x IN {s(j:num):real | b <= j} ==> ?j. b <= j /\ x = s(j)` (SET_TAC []) THEN ASM_MESON_TAC [LTE_TRANS]);; let seq_increasing_jump = prove(` !f:num->num. (!n. f(n) < f(n+1)) ==> !m n. m < n ==> f(m) < f(n) `, GEN_TAC THEN DISCH_TAC THEN GEN_TAC THEN INDUCT_TAC THENL [ARITH_TAC; REWRITE_TAC [ARITH_RULE `SUC n = n + 1`] THEN DISCH_TAC THEN ASM_CASES_TAC `m < n:num` THENL [note `f(m) < f(n:num):num` [] THEN ASM_MESON_TAC [LT_TRANS]; note `m = n:num` [ARITH_RULE `m < n + 1 /\ ~(m < n) ==> m = n`] THEN ASM_MESON_TAC []]]);; let seq_increasing_jump_le = prove(` !f:num->num. (!n. f(n) < f(n+1)) ==> !m n. m <= n ==> f(m) <= f(n) `, REPEAT STRIP_TAC THEN note `f(m) <= f(m:num):num` [LE_REFL] THEN proven_if `m = n:num` THEN note `m < n:num` [ARITH_RULE `m <= n /\ ~(m = n) ==> m < n:num`] THEN ASM_MESON_TAC [seq_increasing_jump; LT_IMP_LE]);; let seq_increasing_gediagonal = prove(` !f:num->num. (!n. f(n) < f(n+1)) ==> !n. n <= f(n) `, GEN_TAC THEN DISCH_TAC THEN INDUCT_TAC THENL [ARITH_TAC; REWRITE_TAC [ARITH_RULE `SUC n = n + 1`] THEN ASM_MESON_TAC [ARITH_RULE `n <= x /\ x < y ==> n + 1 <= y`]]);; let iterate_gtdiagonal = prove(` !f:num->num g:num->num a. (!n. n < f(n)) /\ g = (\n. (f pow_num n)(a)) ==> !n. g(n) < g(n+1) `, REPEAT STRIP_TAC THEN note `g(n) = (f pow_num n)(a:num)` [] THEN note `g(n+1) = (f pow_num (n+1))(a:num)` [] THEN notetac `~(n+1 = 0)` ARITH_TAC THEN notetac `(n+1)-1 = n` ARITH_TAC THEN specialize [`f:num->num`; `n+1`] (GENL [`p:A->A`; `n:num`] pow_num) THEN note `(f:num->num) pow_num (n+1) = f o (f pow_num n)` [] THEN note `(f o (f pow_num n))(a:num):num = f((f pow_num n)(a))` [o_THM] THEN note `g(n+1) = f(g(n:num)):num` [] THEN ASM_MESON_TAC []);; let iterate_gtdiagonal_jump = prove(` !f:num->num g:num->num a. (!n. n < f(n)) /\ g = (\n. (f pow_num n)(a)) ==> !m n. m < n ==> g(m) < g(n) `, MESON_TAC [iterate_gtdiagonal; seq_increasing_jump]);; let iterate_gtdiagonal_gediagonal = prove(` !f:num->num g:num->num a. (!n. n < f(n)) /\ g = (\n. (f pow_num n)(a)) ==> !n. n <= g(n) `, MESON_TAC [iterate_gtdiagonal; seq_increasing_gediagonal]);; let iterate_gtdiagonal_gestart = prove(` !f:num->num g:num->num a. (!n. n < f(n)) /\ g = (\n. (f pow_num n)(a)) ==> !n. a <= g(n) `, REPEAT STRIP_TAC THEN note `!n:num. g(n):num < g(n+1)` [iterate_gtdiagonal] THEN notetac `0 <= n:num` ARITH_TAC THEN note `g(0) <= g(n):num` [seq_increasing_jump_le] THEN note `g(0) = I(a:num)` [pow_num] THEN note `g(0) = a:num` [I_THM] THEN ASM_MESON_TAC []);; let seq_inf_outside_lemma = prove(` !s:num->real a L r:num->num p:num->num m i. (!c. s(r(c)) < L + &1 / &(c+1)) /\ (!n. n < r(n)) /\ ~(m = 0) /\ m <= i ==> s((r pow_num i)(a)) < L + &1 / &m `, REPEAT STRIP_TAC THEN note `~(i = 0)` [ARITH_RULE `~(m = 0) /\ m <= i ==> ~(i = 0)`] THEN note `(r:num->num) pow_num i = r o (r pow_num(i-1))` [pow_num] THEN note `(r pow_num i)(a:num) = r((r pow_num(i-1))(a))` [o_THM] THEN note `i-1 <= (r pow_num(i-1))(a:num)` [iterate_gtdiagonal_gediagonal] THEN note `m <= (r pow_num(i-1))(a:num)+1` [ARITH_RULE `~(i = 0) /\ i-1 <= x /\ m <= i ==> m <= x+1`] THEN note `&m <= &((r pow_num(i-1))(a:num)+1)` [REAL_OF_NUM_LE] THEN note `0 < m` [ARITH_RULE `~(m = 0) ==> 0 < m`] THEN note `&0 < &m` [REAL_OF_NUM_LT] THEN note `&1 / &((r pow_num(i-1))(a:num)+1) <= &1 / &m` [le_1over] THEN note `L + &1 / &((r pow_num(i-1))(a:num)+1) <= L + &1 / &m` [REAL_LE_LADD] THEN ASM_MESON_TAC [REAL_LTE_TRANS]);; let seq_inf_outside = prove(` !s:num->real a L. {s(j) | a <= j} has_inf L /\ ~(L IN {s(j) | a <= j}) ==> ?p:num->num. (!i j. i < j ==> p(i) < p(j)) /\ o1_seq (\i. s(p(i)) - L) `, REPEAT STRIP_TAC THEN note `!x:real. x IN {s(j:num) | a <= j} ==> L <= x` [HAS_INF] THEN notetac `!j. a <= j ==> s(j) IN {s(j:num):real | a <= j}` (SET_TAC []) THEN note `!j:num. a <= j ==> L <= s(j):real` [] THEN def `r:num->num` `\c. minimal k. c < k /\ s(k) < L + &1 / &(c+1)` THEN note `!c. ?k. c < k /\ s(k) < L + &1 / &(c+1)` [seq_chop_hasinf_approach] THEN note `!c:num. c < r(c):num` [MINIMAL] THEN note `!c:num. s(r(c):num) < L + &1 / &(c+1)` [MINIMAL] THEN def `p:num->num` `\i:num. (r pow_num i)(a:num)` THEN specialize [`r:num->num`; `p:num->num`; `a:num`] iterate_gtdiagonal_jump THEN EXISTS_TAC `p:num->num` THEN CONJ_TAC THENL [ASM_SIMP_TAC []; ALL_TAC] THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN choose `m:num` `~(m = 0) /\ &0 < inv(&m) /\ inv(&m) < e` [REAL_ARCH_INV] THEN EXISTS_TAC `m:num` THEN REPEAT STRIP_TAC THEN note `a <= p(i:num):num` [iterate_gtdiagonal_gestart] THEN note `s(p(i:num):num) < L + &1 / &m` [seq_inf_outside_lemma] THEN note `abs(s(p(i:num):num)-L) <= e` [REAL_ARITH `L <= x /\ x < L + &1 / &m /\ inv(&m) < e ==> abs(x - L) <= e`] THEN ASM_MESON_TAC []);; let seq_inf_inside_lemma = prove(` !f:num->num f1:num->num q:num->num p:num->num. f1 = (\a. f(a)+1) /\ q = (\i:num. (f1 pow_num i)(f1(0))) /\ p = (\i:num. q(i)-1) ==> !i. p(i) = f((f1 pow_num i)(0)) /\ q(i) = p(i)+1 `, REPEAT GEN_TAC THEN STRIP_TAC THEN INDUCT_TAC THENL [note `(f1 pow_num 0)(0) = 0` [pow_num; I_THM] THEN note `(f1 pow_num 0)(f1(0)) = f1(0)` [pow_num; I_THM] THEN note `q(0) = f(0)+1` [] THEN note `p(0) = f(0):num` [ARITH_RULE `(f0+1)-1 = f0`] THEN ASM_MESON_TAC []; REWRITE_TAC [ARITH_RULE `SUC n = n + 1`] THEN notetac `~(i + 1 = 0)` ARITH_TAC THEN notetac `(i + 1) - 1 = i` ARITH_TAC THEN note `(f1:num->num) pow_num (i+1) = f1 o (f1 pow_num i)` [pow_num] THEN note `((f1:num->num) pow_num (i+1))(f1(0)) = f1((f1 pow_num i)(f1(0)))` [o_THM] THEN note `((f1:num->num) pow_num (i+1))(0) = f1((f1 pow_num i)(0))` [o_THM] THEN note `q(i+1) = f(q(i))+1` [] THEN note `q(i) = f((f1 pow_num i)(0))+1` [] THEN note `q(i) = f1((f1 pow_num i)(0))` [] THEN note `q(i) = (f1 pow_num (i+1))(0)` [] THEN note `q(i+1) = f((f1 pow_num (i+1))(0))+1` [] THEN note `p(i+1):num = f((f1 pow_num (i+1))(0))` [ARITH_RULE `(x+1)-1 = x`] THEN ASM_MESON_TAC []]);; let has_inf_subset = prove(` !s t l m. s has_inf l /\ t has_inf m /\ t SUBSET s ==> l <= m `, MESON_TAC [SUBSET; HAS_INF_LE; REAL_ARITH `x <= x`]);; let seq_inf_inside_lemma2 = prove(` !s:num->real L:num->real. (!a. {s(j) | a <= j} has_inf L(a)) ==> !a b. a <= b ==> L(a) <= L(b) `, MESON_TAC [prove (` a:num <= b ==> {s(j):real | b <= j} SUBSET {s(j) | a <= j} `, SET_TAC [LE_TRANS]); has_inf_subset]);; let seq_inf_inside = prove(` !s:num->real L:num->real U:real. (!a. {s(j) | a <= j} has_inf L(a)) /\ (!a. L(a) IN {s(j) | a <= j}) /\ {L(a) | a | T} has_sup U ==> ?p:num->num. (!i j. i < j ==> p(i) < p(j)) /\ o1_seq (\i. s(p(i)) - U) `, REPEAT STRIP_TAC THEN notetac `(!a:num. L(a):real IN {s(j) | a <= j}) ==> !a. ?j. a <= j /\ s(j) = L(a)` (SET_TAC []) THEN note `!a:num. ?j. a <= j /\ s(j) = L(a):real` [] THEN def `f:num->num` `\a:num. minimal j. a <= j /\ s(j) = L(a):real` THEN note `!a:num. a <= f(a)` [MINIMAL] THEN note `!a:num. s(f(a):num) = L(a):real` [MINIMAL] THEN def `f1:num->num` `\a:num. f(a)+1` THEN note `!a:num. a < f1(a)` [ARITH_RULE `a <= b ==> a < b+1`] THEN def `q:num->num` `\i:num. (f1 pow_num i)(f1(0))` THEN def `p:num->num` `\i:num. q(i)-1` THEN EXISTS_TAC `p:num->num` THEN specialize [`f1:num->num`; `q:num->num`; `f1(0):num`] iterate_gtdiagonal_jump THEN specialize [`f1:num->num`; `q:num->num`; `f1(0):num`] iterate_gtdiagonal_gestart THEN note `!m n:num. m < n ==> p(m) < p(n):num` [ARITH_RULE `f10 = f0+1 /\ qm < qn /\ f10 <= qm /\ f10 <= qn ==> qm-1 < qn-1`] THEN note `!i. p(i):num = f((f1 pow_num i)(0))` [seq_inf_inside_lemma] THEN note `!i. s(p(i):num):real = L((f1 pow_num i)(0))` [] THEN CONJ_TAC THENL [ASM_MESON_TAC []; ALL_TAC] THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN real_linear `&0 < e ==> U - e < U` THEN specialize [`{L(a:num):real | a | T}`; `U:real`; `U - e:real`] HAS_SUP_APPROACH THEN notetac `(?x:real. x IN {L(a:num) | a:num | T} /\ U - e < x) ==> ?a:num. U - e < L(a)` (SET_TAC []) THEN choose `a:num` `U - e < L(a:num):real` [] THEN EXISTS_TAC `a:num` THEN REPEAT STRIP_TAC THEN note `i <= (f1 pow_num i)(0)` [iterate_gtdiagonal_gediagonal] THEN note `a <= (f1 pow_num i)(0)` [LE_TRANS] THEN note `L(a) <= L((f1 pow_num i)(0)):real` [seq_inf_inside_lemma2] THEN note `U - e < s(p(i:num):num):real` [REAL_LTE_TRANS] THEN note `!x:real. x IN {L(a:num):real | a:num | T} ==> x <= U:real` [HAS_SUP] THEN notetac `!a:num. L(a):real IN {L(a) | a | T}` (SET_TAC []) THEN note `L((f1 pow_num i)(0)):real <= U` [] THEN real_linear `L((f1 pow_num i)(0)):real <= U /\ U - e < L(a) /\ L(a) <= L((f1 pow_num i)(0)) ==> abs(L((f1 pow_num i)(0)) - U) <= e` THEN ASM_MESON_TAC []);; let seq_bolzano = prove(` !s:num->real l u. (!i. l <= s(i)) /\ (!i. s(i) <= u) ==> ?p:num->num t. (!i j. i < j ==> p(i) < p(j)) /\ o1_seq (\i. s(p(i)) - t) `, REPEAT STRIP_TAC THEN def `L:num->real` `\a:num. inf{s(j) | a <= j}` THEN notetac `!a:num b:num. a <= b ==> ~({s(j):real | a <= j} = {})` (SET_TAC []) THEN notetac `!a:num. a <= a` ARITH_TAC THEN note `!a:num. ~({s(j):real | a <= j} = {})` [] THEN notetac `!a:num. !x. x IN {s(j):real | a <= j} ==> ?j. a <= j /\ x = s(j)` (SET_TAC []) THEN note `!a:num. !x. x IN {s(j):real | a <= j} ==> l <= x` [] THEN note `!a:num. {s(j) | a <= j} has_inf L(a)` [HAS_INF_INF] THEN ASM_CASES_TAC `!a:num. L(a):real IN {s(j) | a <= j}` THENL [def `U:real` `sup{L(a:num):real | a | T}` THEN notetac `~({L(a:num):real | a | T} = {})` (SET_TAC []) THEN notetac `!x. x IN {L(a:num):real | a | T} ==> ?a:num. x = L(a)` (SET_TAC []) THEN notetac `!a. L(a) IN {s(j:num):real | a <= j} ==> ?j:num. L(a) = s(j)` (SET_TAC []) THEN note `!x. x IN {L(a:num):real | a | T} ==> ?j:num. x <= u` [] THEN note `{L(a:num):real | a | T} has_sup U` [HAS_SUP_SUP] THEN ASM_MESON_TAC [seq_inf_inside]; choose `a:num` `~(L(a:num):real IN {s(j) | a <= j})` [] THEN ASM_MESON_TAC [seq_inf_outside]]);; (* ----- o1_seq basics *) let o1_seq_lt = prove(` !f:num->real. o1_seq f <=> !e:real. &0 < e ==> ?m:num. !i:num. m <= i ==> abs(f(i)) < e `, REWRITE_TAC [o1_seq] THEN MESON_TAC [REAL_LT_IMP_LE; REAL_ARITH `&0 < e /\ abs x <= e / &2 ==> abs x < e`; REAL_ARITH `&0 < e ==> &0 < e / &2`]);; let o1_seq_use = prove(` !f:num->real e:real. &0 < e /\ o1_seq f ==> ?m:num. !i:num. m <= i ==> abs(f(i)) <= e `, MESON_TAC [o1_seq]);; let o1_seq_lt_use = prove(` !f:num->real e:real. &0 < e /\ o1_seq f ==> ?m:num. !i:num. m <= i ==> abs(f(i)) < e `, MESON_TAC [o1_seq_lt]);; (* sanity check: special case of tends_num_real in library *) let o1_seq_tends = prove(` !f:num->real. o1_seq f <=> f tends_num_real &0 `, REWRITE_TAC [o1_seq_lt] THEN REWRITE_TAC [SEQ] THEN REWRITE_TAC [REAL_ARITH `y - &0 = y`] THEN GEN_TAC THEN MESON_TAC [ARITH_RULE `m <= (i:num) <=> i >= m`]);; (* another sanity check: 1 is not o(1) *) let o1_seq_not_1 = prove(` ~o1_seq (\i. &1) `, REWRITE_TAC [o1_seq] THEN REWRITE_TAC [NOT_FORALL_THM] THEN EXISTS_TAC `&1 / &2` THEN ASM_MESON_TAC [EQ_IMP_LE; REAL_ARITH `&0 < &1 / &2`; REAL_ARITH `~(abs(&1) <= &1 / &2)`]);; (* i |-> 1/i is o(1) *) let inv_is_o1_seq = prove(` o1_seq (\i. inv(&i)) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN X_CHOOSE_TAC `n:num` (UNDISCH (fst (EQ_IMP_RULE (ISPEC `e:real` REAL_ARCH_INV)))) THEN EXISTS_TAC `n:num` THEN REPEAT STRIP_TAC THEN ASSUME_TAC (UNDISCH (ITAUT `~(n = 0) /\ &0 < inv (&n) /\ inv (&n) < e ==> ~(n = 0)`)) THEN ASSUME_TAC (UNDISCH (ITAUT `~(n = 0) /\ &0 < inv (&n) /\ inv (&n) < e ==> inv(&n) < e`)) THEN specialize [] (ARITH_RULE `~(n = 0) ==> 0 < n`) THEN specialize [] (ARITH_RULE `0 < n ==> n <= i ==> 0 < i`) THEN specialize_reverse [`0:num`; `i:num`] REAL_OF_NUM_LT THEN specialize_reverse [`0:num`; `n:num`] REAL_OF_NUM_LT THEN specialize_reverse [`n:num`; `i:num`] REAL_OF_NUM_LE THEN specialize [`&n`; `&i`] REAL_LE_INV2 THEN specialize [`&i`] REAL_LT_INV THEN specialize [`&0`; `inv(&i)`] REAL_LT_IMP_LE THEN specialize_reverse [`inv(&i)`] REAL_ABS_REFL THEN specialize [`inv(&i)`; `inv(&n)`; `e:real`] REAL_LET_TRANS THEN specialize [`inv(&i)`; `e:real`] REAL_LT_IMP_LE THEN ASM_SIMP_TAC []);; let o1_seq_past = prove(` !f:num->real g:num->real X:num. (!i. X <= i ==> f(i) = g(i)) /\ o1_seq f ==> o1_seq g `, REPEAT STRIP_TAC THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN choose_specializing `Y:num` [`f:num->real`; `e:real`] o1_seq_use THEN EXISTS_TAC `MAX X Y` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC []);; let o1_seq_subseq = prove(` !f:num->real p:num->num. o1_seq f /\ (!i j. i < j ==> p(i) < p(j)) ==> o1_seq (f o p) `, REPEAT STRIP_TAC THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN choose_specializing `m:num` [`f:num->real`; `e:real`] o1_seq_use THEN EXISTS_TAC `m:num` THEN REWRITE_TAC [o_THM] THEN note `!i:num. i <= p(i)` [seq_increasing_gediagonal; ARITH_RULE `n < n + 1`] THEN ASM_MESON_TAC [LE_TRANS]);; let o1_seq_0 = prove(` o1_seq (\i. &0) `, REWRITE_TAC [o1_seq; REAL_ABS_0] THEN MESON_TAC [REAL_LT_IMP_LE]);; let limit_above_is_eventually_above = prove(` !f b c. b < c /\ o1_seq (\i. f(i) - c) ==> ?m. !i. m <= i ==> b < f(i) `, REPEAT STRIP_TAC THEN real_linear `b < c ==> &0 < c - b` THEN choose_specializing `A:num` [`\i:num. f(i)-c:real`; `c-b:real`] o1_seq_lt_use THEN EXISTS_TAC `A:num` THEN ASM_MESON_TAC [REAL_ARITH `b < c /\ abs(x - c) < c - b ==> b < x`]);; let positive_limit_is_eventually_positive = prove(` !f c. &0 < c /\ o1_seq (\i. f(i) - c) ==> ?m. !i. m <= i ==> &0 < f(i) `, MESON_TAC [limit_above_is_eventually_above]);; let limit_below_is_eventually_below = prove(` !f c d. c < d /\ o1_seq (\i. f(i) - c) ==> ?m. !i. m <= i ==> f(i) < d `, REPEAT STRIP_TAC THEN real_linear `c < d ==> &0 < d - c` THEN choose_specializing `A:num` [`\i:num. f(i)-c:real`; `d-c:real`] o1_seq_lt_use THEN EXISTS_TAC `A:num` THEN ASM_MESON_TAC [REAL_ARITH `c < d /\ abs(x - c) < d - c ==> x < d`]);; let negative_limit_is_eventually_negative = prove(` !f c. c < &0 /\ o1_seq (\i. f(i) - c) ==> ?m. !i. m <= i ==> f(i) < &0 `, MESON_TAC [limit_below_is_eventually_below]);; (* alternative: track l <= t and t <= u through bolzano proofs *) let seq_bolzano2 = prove(` !s:num->real l u. (!i. l <= s(i)) /\ (!i. s(i) <= u) ==> ?p:num->num t. (!i j. i < j ==> p(i) < p(j)) /\ o1_seq (\i. s(p(i)) - t) /\ l <= t /\ t <= u `, REPEAT STRIP_TAC THEN specialize [`s:num->real`; `l:real`; `u:real`] seq_bolzano THEN choose `p:num->num` `?t. (!i j. i < j:num ==> p(i) < p(j):num) /\ o1_seq (\i. s(p(i)) - t)` [] THEN choose `t:real` `(!i j. i < j:num ==> p(i) < p(j):num) /\ o1_seq (\i. s(p(i)) - t)` [] THEN note `o1_seq (\i:num. s(p(i):num) - t:real)` [] THEN EXISTS_TAC `p:num->num` THEN EXISTS_TAC `t:real` THEN ASM_CASES_TAC `t < l:real` THENL [specialize [`\i:num. s(p(i):num):real`; `t:real`; `l:real`] limit_below_is_eventually_below THEN ASM_MESON_TAC [LE_REFL; REAL_NOT_LE]; ALL_TAC] THEN ASM_CASES_TAC `u < t:real` THENL [specialize [`\i:num. s(p(i):num):real`; `u:real`; `t:real`] limit_above_is_eventually_above THEN ASM_MESON_TAC [LE_REFL; REAL_NOT_LE]; ALL_TAC] THEN ASM_MESON_TAC [REAL_NOT_LT]);; let o1_seq_compose0 = prove(` !f:num->real g:real->real. g contl &0 /\ o1_seq f ==> o1_seq (\i. g(f(i)) - g(&0)) `, REWRITE_TAC [o1_seq_lt] THEN REWRITE_TAC [CONTL] THEN REWRITE_TAC [REAL_ARITH `y - &0 = y`] THEN MESON_TAC []);; let o1_seq_compose = prove(` !f:num->real g:real->real c:real. g contl c /\ o1_seq f ==> o1_seq (\i. g(c+f(i)) - g(c)) `, REWRITE_TAC [o1_seq_lt] THEN REWRITE_TAC [CONTL] THEN REWRITE_TAC [REAL_ARITH `abs(f(i:num)) = abs((c+f(i))-c)`] THEN MESON_TAC []);; let o1_seq_compose_offset = prove(` !f:num->real g:real->real c:real. g contl c /\ o1_seq (\i. f(i)-c) ==> o1_seq (\i. g(f(i)) - g(c)) `, REWRITE_TAC [o1_seq_lt] THEN REWRITE_TAC [CONTL] THEN MESON_TAC []);; let o1_seq_consttimes_0sub = prove(` !f:num->real c:real. o1_seq f ==> o1_seq (\i. c*f(i) - c * &0) `, MESON_TAC [ISPECL [`&0:real`; `c:real`] cont_consttimes; ISPECL [`f:num->real`; `\(x:real). c*x`] o1_seq_compose0]);; let o1_seq_consttimes_rewrite = prove(` !f:num->real c:real. (\i. c*f(i)) = (\i. c*f(i) - c * &0) `, REWRITE_TAC [REAL_ARITH `x - c * &0 = x`]);; let o1_seq_consttimes = prove(` !f:num->real c:real. o1_seq f ==> o1_seq (\i. c*f(i)) `, MESON_TAC [o1_seq_consttimes_rewrite; o1_seq_consttimes_0sub]);; let o1_seq_add_lemma_half = prove(` !o1:num->real. (!e:real. &0 < e ==> (?m:num. !i:num. m <= i ==> abs (o1 i) <= e)) /\ &0 < e / &2 ==> (?m:num. !i:num. m <= i ==> abs (o1 i) <= e / &2) `, MESON_TAC []);; let o1_seq_add_lemma = prove(` !o1 e:real. o1_seq o1 ==> &0 < e ==> ?m. !i. m <= i ==> abs (o1 i) <= e / &2 `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN specialize [] (REAL_ARITH `&0 < e ==> &0 < e / &2`) THEN specialize [`o1:num->real`] o1_seq_add_lemma_half THEN ASM_MESON_TAC []);; let o1_seq_add_lemma2 = prove(` !Ao1 Bo1 e:real Am:num Bm:num. (!i. Am <= i ==> abs (Ao1 i) <= e / &2) /\ (!i. Bm <= i ==> abs (Bo1 i) <= e / &2) ==> ?Cm. !i. Cm <= i ==> abs (Ao1 i) <= e / &2 /\ abs(Bo1 i) <= e / &2 `, REPEAT STRIP_TAC THEN EXISTS_TAC `MAX Am Bm` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC []);; let o1_seq_add_lemma3 = prove(` !x:real y:real e:real. abs(x) <= e / &2 /\ abs(y) <= e / &2 ==> abs(x + y) <= e `, MESON_TAC [REAL_ABS_TRIANGLE; REAL_LE_TRANS; REAL_LE_ADD2; REAL_ARITH `e / &2 + e / &2 = e`]);; let o1_seq_add_lemma4 = prove(` !Ao1 Bo1 e:real Am:num Bm:num. (!i. Am <= i ==> abs (Ao1 i) <= e / &2) /\ (!i. Bm <= i ==> abs (Bo1 i) <= e / &2) ==> ?Cm. !i. Cm <= i ==> abs (Ao1 i + Bo1 i) <= e `, REPEAT STRIP_TAC THEN specialize [`Ao1:num->real`; `Bo1:num->real`; `e:real`; `Am:num`; `Bm:num`] o1_seq_add_lemma2 THEN ASM_MESON_TAC [o1_seq_add_lemma3]);; let o1_seq_add_lemma5 = prove(` !Ao1 Bo1 e:real. o1_seq Ao1 /\ o1_seq Bo1 /\ &0 < e ==> ?m. !i. m <= i ==> abs (Ao1 i + Bo1 i) <= e `, REPEAT STRIP_TAC THEN specialize [`Ao1:num->real`; `e:real`] o1_seq_add_lemma THEN specialize [`Bo1:num->real`; `e:real`] o1_seq_add_lemma THEN ASM_MESON_TAC [o1_seq_add_lemma4]);; let o1_seq_add_extra = prove(` !Ao1 Bo1. o1_seq Ao1 /\ o1_seq Bo1 /\ (!i. Co1(i) = Ao1(i) + Bo1(i)) ==> o1_seq Co1 `, MESON_TAC [o1_seq_add_lemma5; o1_seq]);; let o1_seq_add = prove(` !Ao1 Bo1. o1_seq Ao1 /\ o1_seq Bo1 ==> o1_seq (\i. Ao1(i) + Bo1(i)) `, MESON_TAC [o1_seq_add_extra]);; let o1_seq_add_offset_lemma = prove(` !Ao1 A Bo1 B. (\i. (Ao1(i) - A) + (Bo1(i) - B)) = (\i. (Ao1(i) + Bo1(i)) - (A + B)) `, MESON_TAC [EQ_EXT; REAL_ARITH `(x - a) + (y - b) = (x + y) - (a + b)`]);; let o1_seq_add_offset = prove(` !Ao1 A Bo1 B. o1_seq (\i. Ao1(i) - A) /\ o1_seq (\i. Bo1(i) - B) ==> o1_seq (\i. (Ao1(i)+Bo1(i)) - (A+B)) `, REPEAT STRIP_TAC THEN specialize [`\i:num. Ao1(i) - A`; `\i:num. Bo1(i) - B`] o1_seq_add THEN specialize [`Ao1:num->real`; `A:real`; `Bo1:num->real`; `B:real`] o1_seq_add_offset_lemma THEN ASM_MESON_TAC []);; let o1_seq_sub = prove(` !Ao1 Bo1. o1_seq Ao1 /\ o1_seq Bo1 ==> o1_seq (\i. Ao1(i) - Bo1(i)) `, REPEAT STRIP_TAC THEN specialize [`Bo1:num->real`; `-- &1`] o1_seq_consttimes THEN specialize [`Ao1:num->real`; `\i:num. (-- &1) * Bo1(i)`] o1_seq_add THEN ONCE_REWRITE_TAC [REAL_ARITH `x - y = x + (-- &1) * y`] THEN ASM_MESON_TAC []);; let o1_seq_sub_offset_lemma = prove(` !Ao1 A Bo1 B. (\i. (Ao1(i) - A) - (Bo1(i) - B)) = (\i. (Ao1(i) - Bo1(i)) - (A - B)) `, MESON_TAC [EQ_EXT; REAL_ARITH `(x - a) - (y - b) = (x - y) - (a - b)`]);; let o1_seq_sub_offset = prove(` !Ao1 A Bo1 B. o1_seq (\i. Ao1(i) - A) /\ o1_seq (\i. Bo1(i) - B) ==> o1_seq (\i. (Ao1(i)-Bo1(i)) - (A-B)) `, REPEAT STRIP_TAC THEN specialize [`\i:num. Ao1(i) - A`; `\i:num. Bo1(i) - B`] o1_seq_sub THEN specialize [`Ao1:num->real`; `A:real`; `Bo1:num->real`; `B:real`] o1_seq_sub_offset_lemma THEN ASM_MESON_TAC []);; let o1_seq_1overcplusx_plus0 = prove(` !f:num->real c:real. o1_seq f /\ ~(c = &0) ==> o1_seq (\i. &1 / (c+f(i)) - &1 / (c + &0)) `, MESON_TAC [ISPECL [`c:real`] cont_1overcplusx_at0; ISPECL [`f:num->real`; `\(x:real). &1 / (c+x)`] o1_seq_compose0]);; let o1_seq_1overcplusx_rewrite = prove(` !f:num->real c:real. (\i. &1 / (c+f(i)) - &1 / (c + &0)) = (\i. &1 / (c+f(i)) - &1 / c) `, REWRITE_TAC [REAL_ARITH `c + &0 = c`]);; let o1_seq_1overcplusx = prove(` !f:num->real c:real. o1_seq f /\ ~(c = &0) ==> o1_seq (\i. &1 / (c+f(i)) - &1 / c) `, MESON_TAC [o1_seq_1overcplusx_plus0; o1_seq_1overcplusx_rewrite]);; let o1_seq_bounded_eventually = prove(` !f:num->real g:num->real m:num. o1_seq f /\ (!i. m <= i ==> abs(g(i)) <= abs(f(i))) ==> o1_seq g `, REPEAT STRIP_TAC THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN choose `n:num` `!i:num. n <= i ==> abs(f(i)) <= e` [o1_seq_use] THEN EXISTS_TAC `MAX m n` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [REAL_LE_TRANS]);; let o1_seq_mul_lemma_sqrt = prove(` (!e:real. &0 < e ==> (?m:num. !i:num. m <= i ==> abs (o1 i) <= e)) ==> &0 < sqrt e ==> (?m:num. !i:num. m <= i ==> abs (o1 i) <= sqrt e) `, MESON_TAC []);; let o1_seq_mul_lemma = prove(` !o1 e:real. o1_seq o1 ==> &0 < e ==> ?m. !i. m <= i ==> abs (o1 i) <= sqrt e `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN ASSUME_TAC (UNDISCH o1_seq_mul_lemma_sqrt) THEN ASM_MESON_TAC [SQRT_LT_0]);; let o1_seq_mul_lemma2 = prove(` !Ao1 Bo1 e:real Am:num Bm:num. (!i. Am <= i ==> abs (Ao1 i) <= sqrt e) ==> (!i. Bm <= i ==> abs (Bo1 i) <= sqrt e) ==> ?Cm. !i. Cm <= i ==> abs (Ao1 i) <= sqrt e /\ abs(Bo1 i) <= sqrt e `, REPEAT STRIP_TAC THEN EXISTS_TAC `MAX Am Bm` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC []);; let o1_seq_mul_lemma3 = prove(` !x:real y:real e:real. abs(x) <= sqrt e /\ abs(y) <= sqrt e ==> abs(x * y) <= e `, MESON_TAC [REAL_LE_MUL2; REAL_ABS_MUL; REAL_ABS_POS; REAL_POW_2; SQRT_WORKS_GEN; REAL_LE_TRANS; SQRT_LE_0; REAL_ABS_REFL]);; let o1_seq_mul_lemma4 = prove(` !Ao1 Bo1 e:real Am:num Bm:num. (!i. Am <= i ==> abs (Ao1 i) <= sqrt e) /\ (!i. Bm <= i ==> abs (Bo1 i) <= sqrt e) ==> ?Cm. !i. Cm <= i ==> abs (Ao1 i * Bo1 i) <= e `, REPEAT STRIP_TAC THEN specialize [`Ao1:num->real`; `Bo1:num->real`; `e:real`; `Am:num`; `Bm:num`] o1_seq_mul_lemma2 THEN ASM_MESON_TAC [o1_seq_mul_lemma3]);; let o1_seq_mul_lemma5 = prove(` !Ao1 Bo1 e:real. o1_seq Ao1 /\ o1_seq Bo1 /\ &0 < e ==> ?m. !i. m <= i ==> abs (Ao1 i * Bo1 i) <= e `, REPEAT STRIP_TAC THEN specialize [`Ao1:num->real`; `e:real`] o1_seq_mul_lemma THEN specialize [`Bo1:num->real`; `e:real`] o1_seq_mul_lemma THEN ASM_MESON_TAC [o1_seq_mul_lemma4]);; let o1_seq_mul_extra = prove(` !Ao1 Bo1 Co1. o1_seq Ao1 /\ o1_seq Bo1 /\ (!i. Co1(i) = Ao1(i) * Bo1(i)) ==> o1_seq Co1 `, MESON_TAC [o1_seq_mul_lemma5; o1_seq]);; let o1_seq_mul = prove(` !Ao1 Bo1. o1_seq Ao1 /\ o1_seq Bo1 ==> o1_seq (\i. Ao1(i) * Bo1(i)) `, MESON_TAC [o1_seq_mul_extra]);; let o1_seq_offset_mul = prove(` !c:real co1:num->real d:real do1:num->real. o1_seq co1 /\ o1_seq do1 ==> ?o1. o1_seq o1 /\ !i. (c + co1(i)) * (d + do1(i)) = c*d + o1(i) `, REPEAT STRIP_TAC THEN EXISTS_TAC `\i:num. ((c:real)*do1(i) + d*co1(i)) + co1(i)*do1(i)` THEN CONJ_TAC THENL [ASM_MESON_TAC [ISPECL [`do1:num->real`; `c:real`] o1_seq_consttimes; ISPECL [`co1:num->real`; `d:real`] o1_seq_consttimes; ISPECL [`co1:num->real`; `do1:num->real`] o1_seq_mul; ISPECL [`\i:num. (c:real)*do1(i)`; `\i:num. (d:real)*co1(i)`] o1_seq_add; ISPECL [`\i:num. (c:real)*do1(i)+(d:real)*co1(i)`; `\i:num. co1(i)*do1(i)`] o1_seq_add]; REAL_ARITH_TAC]);; let o1_seq_offset_mul2 = prove(` !f:num->real c:real g:num->real d:real. o1_seq (\i. f(i) - c) /\ o1_seq (\i. g(i) - d) ==> o1_seq (\i. f(i)*g(i) - c*d) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ARITH `f*g-c*d=c*(g-d)+d*(f-c)+(f-c)*(g-d)`] THEN specialize [`\i:num. f(i) - c:real`; `d:real`] o1_seq_consttimes THEN specialize [`\i:num. g(i) - d:real`; `c:real`] o1_seq_consttimes THEN specialize [`\i:num. f(i) - c:real`; `\i:num. g(i) - d:real`] o1_seq_mul THEN specialize [`\i:num. d*(f(i) - c):real`; `\i:num. (f(i) - c:real)*(g(i) - d:real)`] o1_seq_add THEN specialize [`\i:num. c*(g(i) - d):real`; `\i:num. d*(f(i) - c)+(f(i) - c:real)*(g(i) - d:real)`] o1_seq_add THEN ASM_MESON_TAC []);; (* ----- second-order asymptotics *) let asymp2_asymp1_ratio = prove(` !X:num->real A:num->real A0:real A1:real. o1_seq X /\ (!i. ~(X(i) = &0)) /\ o1_seq (\i. (A(i) - A0) / X(i) - A1) ==> o1_seq (\i. A(i) - A0) `, REPEAT STRIP_TAC THEN specialize [`\i:num. (A(i)-A0)/X(i)-A1`; `X:num->real`] o1_seq_mul THEN note_eqlambda `(\i:num. ((A(i)-A0)/X(i)-A1)*X(i)) = (\i:num. A(i)-A0-A1*X(i))` [REAL_FIELD `~(x = &0) ==> (b/x-c)*x = b-c*x`] THEN note `o1_seq (\i:num. A(i)-A0-A1*X(i))` [] THEN note `o1_seq (\i:num. A1*X(i))` [o1_seq_consttimes] THEN specialize [`\i:num. A(i)-A0-A1*X(i):real`; `\i:num. A1*X(i):real`] o1_seq_add THEN note_eqlambda `(\i:num. A(i)-A0-A1*X(i)+A1*X(i):real) = (\i:num. A(i)-A0)` [REAL_ARITH `b - c + c = b`] THEN ASM_MESON_TAC []);; let asymp2_compose = prove(` !f:real->real f':real->real X:num->real A:num->real A0:real A1:real d:real. &0 < d /\ (!x. abs(x - A0) < d ==> (f diffl f'(x))(x)) /\ f' contl A0 /\ o1_seq X /\ (!i. ~(X(i) = &0)) /\ o1_seq (\i. (A(i) - A0) / X(i) - A1) ==> o1_seq (\i. (f(A(i)) - f(A0)) / X(i) - A1 * f'(A0)) `, REPEAT STRIP_TAC THEN note `o1_seq (\i. A(i) - A0)` [asymp2_asymp1_ratio] THEN choose `m:num` `!i:num. m <= i ==> abs(A(i) - A0) < d:real` [o1_seq_lt_use] THEN note `!i:num. m <= i ==> ?z. abs(z - A0) <= abs(A(i) - A0) /\ f(A(i)) - f(A0) = (A(i) - A0) * f'(z)` [mvt_twosided] THEN def `B:num->real` `\i:num. @z. abs(z - A0) <= abs(A(i) - A0) /\ f(A(i)) - f(A0) = (A(i) - A0) * f'(z)` THEN note `!i:num. m <= i ==> abs(B(i) - A0) <= abs(A(i) - A0)` [] THEN specialize [`\i:num. A(i)-A0:real`; `\i:num. B(i)-A0:real`; `m:num`] o1_seq_bounded_eventually THEN specialize [`\i:num. B(i):real`; `f':real->real`; `A0:real`] o1_seq_compose_offset THEN note `!i:num. m <= i ==> f(A(i)) - f(A0) = (A(i) - A0) * f'(B(i):real)` [] THEN specialize [`\i:num. (A(i)-A0)/X(i)`; `A1:real`; `\i:num. f'(B(i):real):real`; `f'(A0:real):real`] o1_seq_offset_mul2 THEN note `!i:num. m <= i ==> (A(i) - A0)/X(i) * f'(B(i):real) - A1*f'(A0) = (f(A(i)) - f(A0))/X(i) - A1*f'(A0)` [REAL_ARITH `(a*b)/x = (a/x)*b`] THEN specialize [`\i:num. (A(i) - A0)/X(i) * f'(B(i):real) - A1*f'(A0):real`; `\i:num. (f(A(i):real) - f(A0))/X(i) - A1*f'(A0):real`; `m:num`] o1_seq_past THEN ASM_MESON_TAC []);; let asymp2_compose2 = prove(` !f:real->real f':real->real X:num->real A:num->real A0:real A1:real d:real. &0 < d /\ (!x. abs(x - A0) < d ==> (f diffl f'(x))(x)) /\ f' contl A0 /\ (!i. ~(X(i) = &0)) /\ o1_seq (\i. &1 / X(i)) /\ o1_seq (\i. (A(i) - A0) * X(i) - A1) ==> o1_seq (\i. (f(A(i)) - f(A0)) * X(i) - A1 * f'(A0)) `, REPEAT STRIP_TAC THEN note `!i:num. ~(&1 / X(i) = &0)` [nz_1over] THEN note_eqlambda `(\i:num. (A(i) - A0) * X(i) - A1) = (\i:num. (A(i) - A0) / (&1 / X(i)) - A1)` [REAL_FIELD `a * b = a / (&1 / b)`] THEN note `o1_seq (\i. (A(i) - A0) / (&1 / X(i)) - A1)` [] THEN specialize [`f:real->real`; `f':real->real`; `\i:num. &1 / X(i)`; `A:num->real`; `A0:real`; `A1:real`; `d:real`] asymp2_compose THEN note_eqlambda `(\i:num. (f(A(i):real) - f(A0)) * X(i) - A1*f'(A0)) = (\i:num. (f(A(i)) - f(A0)) / (&1 / X(i)) - A1*f'(A0))` [REAL_FIELD `a * b = a / (&1 / b)`] THEN ASM_MESON_TAC []);; let asymp2_inv_generic = prove(` !X:num->real A:num->real A0:real A1:real. (!i. ~(X(i) = &0)) /\ o1_seq (\i. &1 / X(i)) /\ ~(A0 = &0) /\ o1_seq (\i. (A(i) - A0) * X(i) - A1) ==> o1_seq (\i. (&1/A(i) - &1/A0) * X(i) - (--(A1)/(A0*A0))) `, REPEAT STRIP_TAC THEN def `d:real` `abs(A0):real` THEN note `&0 < d:real` [REAL_ARITH `~(x = &0) ==> &0 < abs(x)`] THEN note `!x. abs(x - A0) < d ==> ~(x = &0)` [REAL_ARITH `abs(x - c) < abs(c) ==> ~(x = &0)`] THEN note_eqlambda `(\x. inv x) = (\x. &1 / x)` [REAL_ARITH `inv x = &1 / x`] THEN note `!x. ~(x = &0) ==> ((\x. &1 / x) diffl --(&1 / (x*x))) x` [DIFF_XM1; REAL_FIELD `inv x pow 2 = &1 / (x*x)`] THEN note `(\x. x) contl A0` [CONT_X] THEN specialize [`A0:real`; `\x:real. x`; `\x:real. x`] cont_mul_fullvariables THEN note `(\x. x*x) contl A0` [CONT_MUL] THEN specialize [`A0:real`; `&1`] cont_const_fullvariables THEN note `~(A0*A0 = &0)` [REAL_LT_SQUARE; REAL_ARITH `&0 < x ==> ~(x = &0)`] THEN specialize [`A0:real`; `\x:real. &1`; `\x:real. x*x`] cont_div_fullvariables THEN specialize [`A0:real`; `\x:real. &1 / (x*x)`] cont_neg_fullvariables THEN note `!x. abs(x - A0) < d ==> ((\x. &1 / x) diffl --(&1 / (x*x))) x` [] THEN specialize [`\x. &1 / x`; `\x. --(&1/(x*x))`; `X:num->real`; `A:num->real`; `A0:real`; `A1:real`; `d:real`] asymp2_compose2 THEN REWRITE_TAC [REAL_FIELD `--A1/(A0*A0) = A1 * --(&1 / (A0*A0))`] THEN ASM_MESON_TAC []);; let sqrt_cont = prove(` !x:real. &0 < x ==> sqrt contl x `, MESON_TAC [DIFF_SQRT; DIFF_CONT]);; let asymp2_sqrt_generic = prove(` !X:num->real A:num->real A0:real A1:real. (!i. ~(X(i) = &0)) /\ o1_seq (\i. &1 / X(i)) /\ &0 < A0 /\ o1_seq (\i. (A(i) - A0) * X(i) - A1) ==> o1_seq (\i. (sqrt(A(i)) - sqrt(A0)) * X(i) - (A1/(&2*sqrt(A0)))) `, REPEAT STRIP_TAC THEN note `!x. abs(x - A0) < A0 ==> &0 < x` [REAL_ARITH `abs(x - c) < c ==> &0 < x`] THEN note `!x. abs(x - A0) < A0 ==> (sqrt diffl (&1 / (&2 * sqrt(x)))) x` [DIFF_SQRT; REAL_ARITH `inv x = &1 / x`] THEN note `sqrt contl A0` [sqrt_cont] THEN specialize [`A0:real`; `&2`] cont_const_fullvariables THEN specialize [`A0:real`; `\x:real. &2`; `sqrt`] cont_mul_fullvariables THEN specialize [`A0:real`; `&1`] cont_const_fullvariables THEN note `&0 < sqrt A0` [SQRT_LT_0] THEN note `~(&2 * sqrt A0 = &0)` [REAL_ARITH `&0 < x ==> ~(&2 * x = &0)`] THEN specialize [`A0:real`; `\x:real. &1`; `\x:real. &2 * sqrt x`] cont_div_fullvariables THEN specialize [`sqrt`; `\x. &1 / (&2 * sqrt(x))`; `X:num->real`; `A:num->real`; `A0:real`; `A1:real`; `A0:real`] asymp2_compose2 THEN ONCE_REWRITE_TAC [REAL_FIELD `A1/(&2 * sqrt(A0)) = A1 * &1 / (&2 * sqrt A0)`] THEN ASM_MESON_TAC []);; (* ----- exp *) let exp_double = prove(` !x. exp(&2 * x) = exp(x) * exp(x) `, MESON_TAC [REAL_EXP_ADD; REAL_ARITH `&2 * x = x + x`]);; let exp_double2 = prove(` !x. exp(&2 * x) = exp(x) pow 2 `, MESON_TAC [exp_double; REAL_POW_2]);; let exp_lt_abs = prove(` !x y. exp(x) < y ==> abs(exp(x)) < abs(y) `, MESON_TAC [REAL_EXP_POS_LT; REAL_LT_TRANS; REAL_ABS_REFL; REAL_LT_IMP_LE]);; let exp_lt_sq = prove(` !x y. exp(x) < y ==> exp(&2 * x) < y pow 2 `, MESON_TAC [exp_double2; exp_lt_abs; REAL_LT_SQUARE_ABS]);; let exp_min = prove(` !x y. min (exp(x)) (exp(y)) = exp(min x y) `, MESON_TAC [mono_min; REAL_EXP_MONO_LE]);; (* ----- ln *) (* better version of LN_MONO_LT *) let ln_mono_lt = prove(` !x y. &0 < x /\ x < y ==> ln x < ln y `, MESON_TAC [LN_MONO_LT; REAL_ARITH `!x y. &0 < x /\ x < y ==> &0 < y`]);; (* better version of LN_MONO_LE *) let ln_mono_le = prove(` !x y. &0 < x /\ x <= y ==> ln x <= ln y `, MESON_TAC [LN_MONO_LE; REAL_ARITH `!x y. &0 < x /\ x <= y ==> &0 < y`]);; (* like library LN_DIV but bind y *) let ln_div = prove(` !x y. &0 < x /\ &0 < y ==> ln(x / y) = ln x - ln y `, MESON_TAC [LN_DIV]);; let ln_muldiv = prove(` !x y z. &0 < x /\ &0 < y /\ &0 < z ==> ln(x*y/z) = ln x + ln y - ln z `, MESON_TAC [REAL_LT_DIV; LN_MUL; LN_DIV]);; let ln_1over = prove(` !x:real. &0 < x ==> ln(&1 / x) = --ln(x) `, MESON_TAC [LN_INV; REAL_FIELD `&1 / x = inv x`]);; let ln_1over_plus = prove(` !x. &0 < x ==> ln(&1 / x) + ln(x) = &0 `, MESON_TAC [ln_1over; REAL_ARITH `ln(&1 / x) = --ln(x) ==> ln(&1 / x) + ln(x) = &0`]);; let ln_gt1 = prove(` !y. &1 < y ==> &0 < ln y `, MESON_TAC [ln_mono_lt; REAL_ARITH `&0 < &1`; LN_1]);; let ln_ge1 = prove(` !y. &1 <= y ==> &0 <= ln y `, MESON_TAC [ln_mono_le; REAL_ARITH `&0 < &1`; LN_1]);; let ln_le1 = prove(` !y. &0 < y /\ y <= &1 ==> ln y <= &0 `, MESON_TAC [ln_mono_le; LN_1]);; let ln_continuous = prove(` !x. &0 < x ==> ln contl x `, MESON_TAC [DIFF_LN; DIFF_CONT]);; (* ----- ln(2) *) let ln2_positive = prove(` &0 < ln(&2) `, MESON_TAC [LN_POS_LT; REAL_ARITH `&1 < &2`]);; let ln2_nonzero = prove(` ~(ln(&2) = &0) `, MESON_TAC [ln2_positive; REAL_LT_IMP_NZ]);; (* ----- log2 *) let log2ratio_lnratio = prove(` !x y. log2(x)/log2(y) = ln(x)/ln(y) `, REWRITE_TAC [log2] THEN MESON_TAC [ln2_nonzero; REAL_FIELD `~(d = &0) ==> (a/d)/(b/d) = a/b`]);; let log2_2 = prove(` log2(&2) = &1 `, MESON_TAC [log2; REAL_DIV_REFL; ln2_nonzero]);; let log2_1 = prove(` log2(&1) = &0 `, MESON_TAC [log2; LN_1; REAL_FIELD `&0 / y = &0`]);; let log2_mono_le = prove(` !x y. &0 < x /\ x <= y ==> log2 x <= log2 y `, REWRITE_TAC [log2] THEN MESON_TAC [REAL_LE_DIV2_EQ; LN_MONO_LE; ln2_positive; REAL_ARITH `!x y. &0 < x /\ x <= y ==> &0 < y`]);; let log2_mono_lt = prove(` !x y. &0 < x /\ x < y ==> log2 x < log2 y `, REWRITE_TAC [log2] THEN MESON_TAC [REAL_LT_DIV2_EQ; LN_MONO_LT; ln2_positive; REAL_ARITH `!x y. &0 < x /\ x < y ==> &0 < y`]);; let log2_mul = prove(` !x y. &0 < x /\ &0 < y ==> log2(x*y) = log2(x) + log2(y) `, REWRITE_TAC [log2] THEN MESON_TAC [LN_MUL; ln2_positive; REAL_FIELD `&0 < L ==> (a+b)/L = a/L + b/L`]);; let log2_ge2 = prove(` !x. &2 <= x ==> &1 <= log2 x `, MESON_TAC [log2_mono_le; REAL_ARITH `&0 < &2`; log2_2]);; let log2_ge1 = prove(` !x. &1 <= x ==> &0 <= log2 x `, MESON_TAC [log2_mono_le; REAL_ARITH `&0 < &1`; log2_1]);; let log2_le1 = prove(` !x. &0 < x /\ x <= &1 ==> log2 x <= &0 `, MESON_TAC [log2_mono_le; REAL_ARITH `&0 < &1`; log2_1]);; let log2_gt1 = prove(` !x. &1 < x ==> &0 < log2 x `, MESON_TAC [log2_mono_lt; REAL_ARITH `&0 < &1`; log2_1]);; let log2_1over = prove(` !x:real. &0 < x ==> log2(&1 / x) = --log2(x) `, REWRITE_TAC [log2] THEN MESON_TAC [ln_1over; REAL_ARITH `--a/b = --(a/b)`]);; let log2_continuous_lemma = prove(` log2 = \x. ln x * &1 / ln(&2) `, MESON_TAC [EQ_EXT; log2; REAL_ARITH `L / ln(&2) = L * (&1 / ln(&2))`]);; let log2_continuous = prove(` !x. &0 < x ==> log2 contl x `, REPEAT STRIP_TAC THEN specialize [`x:real`; `&1 / ln(&2)`] cont_const_fullvariables THEN specialize [`x:real`] ln_continuous THEN specialize [`x:real`; `ln`; `\x:real. &1 / ln(&2)`] cont_mul_fullvariables THEN ASM_MESON_TAC [log2_continuous_lemma]);; (* ----- exp(1) *) let exp1_, exp1boundgen = REALCALC_CONV ` exp(&1) `;; let exp1bound = thm_eval exp1boundgen(Int 10);; let exp1_8732 = prove(` exp(&1) < &87 / &32 `, MESON_TAC [exp1bound; REAL_ARITH `abs (&2783 - &2 pow 10 * exp (&1)) < &1 ==> exp(&1) < &87 / &32`]);; (* ----- pi *) let pi_30bits = PI_APPROX_BINARY_RULE 30;; let pi_227 = prove(` pi < &22 / &7 `, MESON_TAC [pi_30bits; REAL_ARITH `abs (pi - &1686629713 / &536870912) <= inv (&2 pow 30) ==> pi < &22 / &7`]);; let pi_333106 = prove(` &333 / &106 < pi `, MESON_TAC [pi_30bits; REAL_ARITH `abs (pi - &1686629713 / &536870912) <= inv (&2 pow 30) ==> &333 / &106 < pi`]);; (* ----- more constants *) let exp2bound = prove(` exp(&2 * &1) < (&87 / &32) pow 2 `, MESON_TAC [exp_lt_sq; exp1_8732]);; let exp2bound2 = prove(` exp(&2) < &7569 / &1024 `, MESON_TAC [exp2bound; REAL_ARITH `(&87 / &32) pow 2 = &7569 / &1024`; REAL_ARITH `&2 * &1 = &2`]);; let exp2pibound = prove(` pi * exp(&2) < (&22 / &7) * (&7569 / &1024) `, MESON_TAC [exp2bound2; pi_227; REAL_LT_MUL2; REAL_EXP_POS_LE; PI_POS; REAL_LT_IMP_LE]);; let exp2pibound2 = prove(` &2 * pi * exp(&2) < &60 `, MESON_TAC [exp2pibound; REAL_ARITH `a < (&22 / &7) * (&7569 / &1024) ==> &2 * a < &60`]);; let lnexp2pibound = prove(` ln(&2 * pi * exp(&2)) < ln(&60) `, MESON_TAC [ln_mono_lt; exp2pibound2; PI_POS; REAL_EXP_POS_LT; REAL_ARITH `&0 < &2`; REAL_LT_MUL]);; let lnexp2piexpand = prove(` ln(&2 * pi * exp(&2)) = ln(&2) + ln(pi) + ln(exp(&2)) `, MESON_TAC [LN_MUL; REAL_ARITH `&0 < &2`; REAL_EXP_POS_LT; PI_POS; REAL_LT_MUL]);; let lnexp2piexpand2 = prove(` ln(&2 * pi * exp(&2)) = ln(&2) + ln(pi) + &2 `, MESON_TAC [lnexp2piexpand; LN_EXP]);; let lnexp1piexpand = prove(` ln(&2 * pi * exp(&1)) = ln(&2) + ln(pi) + ln(exp(&1)) `, MESON_TAC [LN_MUL; REAL_ARITH `&0 < &2`; REAL_EXP_POS_LT; PI_POS; REAL_LT_MUL]);; let lnexp1piexpand2 = prove(` ln(&2 * pi * exp(&1)) = ln(&2) + ln(pi) + &1 `, MESON_TAC [lnexp1piexpand; LN_EXP]);; let lnexp1piexp2pi = prove(` ln(&2 * pi * exp(&2)) = &1 + ln(&2 * pi * exp(&1)) `, MESON_TAC [lnexp2piexpand2; lnexp1piexpand2; REAL_ARITH `!x y a b. x = a + b + &2 /\ y = a + b + &1 ==> x = &1 + y`]);; let twopie_pos = prove(` &0 < &2 * pi * exp(&1) `, MESON_TAC [REAL_ARITH `&0 < &2`; REAL_EXP_POS_LT; PI_POS; REAL_LT_MUL]);; let pi60bound2 = prove(` (&333 / &106) * &60 < pi * &60 `, MESON_TAC [pi_333106; REAL_LT_RMUL; REAL_ARITH `&0 < &60`]);; let exp1bound3 = prove(` &43 / &16 < exp(&1) `, MESON_TAC [exp1bound; REAL_ARITH `abs (&2783 - &2 pow 10 * exp (&1)) < &1 ==> &43 / &16 < exp(&1)`]);; let exp30bound = prove(` (&43 / &16) pow 30 < exp(&1) pow 30 `, MESON_TAC [exp1bound3; REAL_POW_LT2; ARITH_RULE `~(30 = 0)`; REAL_ARITH `&0 <= &43 / &16`]);; let exp30bound2 = prove(` (&43 / &16) pow 30 < exp(&30) `, MESON_TAC [exp30bound; REAL_EXP_N; REAL_ARITH `&30 * &1 = &30`]);; let exp30bound3 = prove(` &1000 < exp(&30) `, MESON_TAC [exp30bound2; REAL_ARITH `&1000 < (&43 / &16) pow 30`; REAL_LT_TRANS]);; let pi60bound8 = prove(` &60 * pi < &60 * (&22 / &7) `, MESON_TAC [pi_227; REAL_LT_LMUL; REAL_ARITH `&0 < &60`]);; let pi60bound9 = prove(` &60 * pi < &1000 `, MESON_TAC [pi60bound8; REAL_ARITH `&60 * (&22 / &7) < &1000`; REAL_LT_TRANS]);; let pi60exp30 = prove(` &60 * pi < exp(&30) `, MESON_TAC [exp30bound3; pi60bound9; REAL_LT_TRANS]);; let lnpi60 = prove(` ln(pi* &60)- &60 / &2 < &0 `, MESON_TAC [pi60exp30; LN_MONO_LT; LN_EXP; REAL_ARITH `&0 < pi ==> &0 < &60 * pi`; REAL_EXP_POS_LT; PI_POS; REAL_ARITH `pi * &60 = &60 * pi`; REAL_ARITH `a < &30 ==> a - &60 / &2 < &0`]);; (* ----- powreal *) let powreal_1 = prove(` !x. &0 < x ==> x powreal (&1) = x `, MESON_TAC [powreal; REAL_ARITH `&1 * y = y`; EXP_LN]);; let powreal_ln = prove(` !x y. ln(x powreal y) = y * ln x `, MESON_TAC [powreal; LN_EXP]);; let powreal_log2 = prove(` !x y. log2(x powreal y) = y * log2 x `, REWRITE_TAC [log2] THEN MESON_TAC [powreal_ln; ln2_positive; REAL_ARITH `(y*z)/L = y*(z/L)`]);; let powreal_positive = prove(` !x y. &0 < x powreal y `, MESON_TAC [powreal; REAL_EXP_POS_LT]);; let powreal_pow = prove(` !x y n. (x powreal y) pow n = x powreal (&n * y) `, REWRITE_TAC [powreal; GSYM REAL_EXP_N; REAL_MUL_ASSOC]);; let powreal_lnratio = prove(` !x y. &0 < x /\ &1 < y ==> x = y powreal (ln(x)/ln(y)) `, REWRITE_TAC [powreal] THEN MESON_TAC [LN_POS_LT; REAL_FIELD `&0 < a ==> b / a * a = b`; EXP_LN]);; let powreal_log2ratio = prove(` !x y. &0 < x /\ &1 < y ==> x = y powreal (log2(x)/log2(y)) `, MESON_TAC [log2ratio_lnratio; powreal_lnratio]);; let powreal_cancelbase = prove(` !x y. &0 < x ==> ((&1 / x) powreal y) * (x powreal y) = &1 `, REWRITE_TAC [powreal] THEN REWRITE_TAC [GSYM REAL_EXP_ADD] THEN REWRITE_TAC [GSYM REAL_ADD_LDISTRIB] THEN MESON_TAC [ln_1over_plus; REAL_ARITH `y * &0 = &0`; REAL_EXP_0]);; (* ----- bkzdelta *) let bkzdelta_pos = prove(` !x. &0 < bkzdelta x `, MESON_TAC [bkzdelta; powreal_positive]);; let bkzdelta_ln = prove(` !x. ln(bkzdelta x) = (&1 / (&2 * (x - &1))) * ln(x * ((pi*x) powreal (&1 / x))/(&2 * pi * exp(&1))) `, REWRITE_TAC [bkzdelta; powreal] THEN MESON_TAC [LN_EXP]);; let bkzdelta_ln2 = prove(` !x. ln(bkzdelta x) = ln(x * ((pi*x) powreal (&1 / x))/(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [bkzdelta_ln; REAL_FIELD (`(&1 / a) * b = b / a`)]);; let bkzdelta_ln3 = prove(` !x. &60 <= x ==> ln(bkzdelta x) = (ln(x) + ln((pi*x) powreal (&1 / x)) - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [bkzdelta_ln2; ln_muldiv; REAL_ARITH `&60 <= x ==> &0 < x`; twopie_pos; powreal_positive]);; let bkzdelta_ln4 = prove(` !x. &60 <= x ==> ln(bkzdelta x) = (ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [bkzdelta_ln3; powreal_ln]);; let bkzdelta_ln5 = prove(` !x. &60 <= x ==> ln(bkzdelta x) = (ln(x) + ln(pi*x)/x - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [bkzdelta_ln4; REAL_ARITH `(&1 / a) * b = b / a`]);; let bkzdelta_log2 = prove(` !x. &60 <= x ==> log2(bkzdelta x) = (log2(x) + (&1 / x) * log2(pi*x) - log2(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, REPEAT STRIP_TAC THEN REWRITE_TAC [log2] THEN specialize [`x:real`] bkzdelta_ln4 THEN ASM_MESON_TAC [ln2_positive; REAL_FIELD `&0 < ln(&2) ==> ( (ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) )/ln(&2) = (ln(x)/ln(&2) + (&1 / x) * ln(pi*x)/ln(&2) - ln(&2 * pi * exp(&1))/ln(&2)) / (&2 * (x - &1))`]);; (* ----- standardratio *) let standardratio_positive = prove(` !n q s k x. &0 < standardratio n q s k x `, REWRITE_TAC [standardratio] THEN MESON_TAC [powreal_positive; REAL_LT_MUL; REAL_LT_DIV]);; let standardratio_ln = prove(` !n q s k x. ln(standardratio n q s k x) = ln(((n + k)*(s pow 2) + &1) powreal (&1 / &2)) - (ln(((n + k + &1)/x) powreal (&1 / &2)) + ln((bkzdelta x) powreal (&2 * x - (n + k + &1) - &1)) + ln(q powreal (k/(n + k + &1)))) `, REWRITE_TAC [standardratio] THEN MESON_TAC [LN_MUL; LN_DIV; powreal_positive; REAL_LT_MUL]);; let standardratio_ln2 = prove(` !n q s k x. ln(standardratio n q s k x) = (&1 / &2) * ln((n + k)*(s pow 2) + &1) - ((&1 / &2) * ln((n + k + &1)/x) + (&2 * x - (n + k + &1) - &1) * ln(bkzdelta x) + (k/(n + k + &1)) * ln q) `, MESON_TAC [standardratio_ln; powreal_ln]);; let standardratio_ln3 = prove(` !n q s k x. &60 <= x ==> ln(standardratio n q s k x) = (&1 / &2) * ln((n + k)*(s pow 2) + &1) - ((&1 / &2) * ln((n + k + &1)/x) + (&2 * x - (n + k + &1) - &1) * ((ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) / (&2 * (x - &1))) + (k/(n + k + &1)) * ln q) `, MESON_TAC [bkzdelta_ln4; standardratio_ln2]);; let standardratio_ln4 = prove(` !n q s k x. &60 <= x ==> ln(standardratio n q s k x) = (&1 / &2) * ln((n + k)*(s pow 2) + &1) - ((&1 / &2) * ln((n + k + &1)/x) + (ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) * ( (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1))) + (k/(n + k + &1)) * ln q) `, MESON_TAC [standardratio_ln3; REAL_FIELD `a * b / c = b * a / c`]);; let standardratio_log2 = prove(` !n q s k x. &60 <= x ==> log2(standardratio n q s k x) = (&1 / &2) * log2((n + k)*(s pow 2) + &1) - ( (&1 / &2) * log2((n + k + &1)/x) + (log2(x) + (&1 / x) * log2(pi*x) - log2(&2 * pi * exp(&1))) * ( (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1))) + (k/(n + k + &1)) * log2 q ) `, REPEAT STRIP_TAC THEN REWRITE_TAC [log2] THEN specialize [`n:real`; `q:real`; `s:real`; `k:real`; `x:real`] standardratio_ln4 THEN ASM_MESON_TAC [ln2_positive; REAL_FIELD `&0 < ln(&2) ==> ( (&1 / &2) * ln((n + k)*(s pow 2) + &1) - ((&1 / &2) * ln((n + k + &1)/x) + (ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) * ( (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1))) + (k/(n + k + &1)) * ln q)) / ln(&2) = ( (&1 / &2) * ln((n + k)*(s pow 2) + &1)/ln(&2) - ((&1 / &2) * ln((n + k + &1)/x)/ln(&2) + (ln(x)/ln(&2) + (&1 / x) * ln(pi*x)/ln(&2) - ln(&2 * pi * exp(&1))/ln(&2)) * ( (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1))) + (k/(n + k + &1)) * ln q/ln(&2)))`]);; (* ----- miscellany *) let asymp1_dn_lemma = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) ==> (\i. &1 / n i + (k(i) / n(i) - X0)) = (\i. (n(i) + k(i) + &1) / n(i) - (&1 + X0)) `, MESON_TAC [EQ_EXT; REAL_FIELD `&1 < x ==> (x + y + &1) / x - (&1 + X0) = &1 / x + (y / x - X0)`]);; let asymp1_dn = prove(` !n:num->real k:num->real X0:real. o1_seq (\i. k(i) / n(i) - X0) /\ (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) ==> o1_seq (\i. (n(i) + k(i) + &1) / n(i) - (&1 + X0)) `, REPEAT STRIP_TAC THEN specialize [`\i:num. &1 / n(i)`; `\i:num. k(i) / n(i) - X0:real`] o1_seq_add THEN ASM_MESON_TAC [BETA_THM; asymp1_dn_lemma]);; let asymp1_nd_lemma = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) ==> (\i. &1 / ((&1 + X0) + (n i + k i + &1) / n i - (&1 + X0)) - &1 / (&1 + X0)) = (\i. n i / (n i + k i + &1) - &1 / (&1 + X0)) `, REWRITE_TAC [REAL_ARITH `(&1 + x) + c - (&1 + x) = c`] THEN MESON_TAC [EQ_EXT; REAL_FIELD `&1 < n /\ &0 < k ==> &1 / ((n + k + &1) / n) = n / (n + k + &1)`]);; let asymp1_nd_lemma2 = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < k(i)) /\ o1_seq (\i. (n(i) + k(i) + &1) / n(i) - (&1 + X0)) /\ &0 <= X0 ==> o1_seq (\i. n(i) / (n(i) + k(i) + &1) - &1 / (&1 + X0)) `, REPEAT STRIP_TAC THEN specialize [`X0:real`] (REAL_ARITH `!x. &0 <= x ==> ~(&1 + x = &0)`) THEN specialize [`\i:num. (n(i) + k(i) + &1) / n(i) - (&1 + X0)`; `&1 + X0`] o1_seq_1overcplusx THEN ASM_MESON_TAC [asymp1_nd_lemma]);; let asymp1_nd = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < k(i)) /\ o1_seq (\i. k(i) / n(i) - X0) /\ &0 <= X0 ==> o1_seq (\i. n(i) / (n(i) + k(i) + &1) - &1 / (&1 + X0)) `, MESON_TAC [asymp1_nd_lemma2; asymp1_dn]);; let asymp1_kd_lemma = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) ==> (\i. (k(i) / n(i)) * (n(i) / (n(i) + k(i) + &1)) - X0 * (&1 / (&1 + X0))) = (\i. (k(i) / (n(i) + k(i) + &1)) - X0 / (&1 + X0)) `, MESON_TAC [EQ_EXT; REAL_ARITH `a * (&1 / b) = a / b`; REAL_FIELD `&1 < n(i:num) ==> (k(i) / n(i)) * (n(i) / (n(i) + k(i) + &1)) = k(i)/(n(i) + k(i) + &1)`]);; let asymp1_kd = prove(` !n:num->real k:num->real X0:real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 <= X0 /\ o1_seq (\i. k(i) / n(i) - X0) ==> o1_seq (\i. (k(i) / (n(i) + k(i) + &1)) - X0 / (&1 + X0)) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `k:num->real`; `X0:real`] asymp1_nd THEN specialize [`\i:num. k(i) / n(i)`; `X0:real`; `\i:num. n(i) / (n(i) + k(i) + &1)`; `&1 / (&1 + X0)`] o1_seq_offset_mul2 THEN ASM_MESON_TAC [asymp1_kd_lemma]);; let asymp1_qn = prove(` !n:num->real q:num->real Q0:real qno1:num->real. (!i. &1 < n(i)) /\ (!i. log2(q(i)) = (Q0 + qno1(i)) * log2(n(i))) ==> (!i. log2(q(i))/log2(n(i)) = Q0 + qno1(i)) `, MESON_TAC [REAL_EQ_RDIV_EQ; log2_gt1]);; let o1_seq_offset_div_lemma = prove(` !c:real co1:num->real d:real do1:num->real. o1_seq do1 /\ ~(d = &0) ==> o1_seq co1 ==> ?o1. o1_seq o1 /\ (!i. (c + co1 i) * (&1 / d + (\i. &1 / (d + do1 i) - &1 / d) i) = c * &1 / d + o1 i) `, MESON_TAC [o1_seq_1overcplusx; ISPECL [`c:real`; `co1:num->real`; `&1 / (d:real)`; `\i:num. &1 / (d + do1 i) - &1 / d`] o1_seq_offset_mul]);; let o1_seq_offset_div = prove(` !c:real co1:num->real d:real do1:num->real. o1_seq co1 ==> o1_seq do1 ==> ~(d = &0) ==> ?o1. o1_seq o1 /\ (!i. (c + co1 i) / (d + do1 i) = c / d + o1 i) `, REWRITE_TAC [REAL_FIELD `c / d + x = c * &1 / d + x`] THEN REWRITE_TAC [REAL_FIELD `(c + co1 i) / (d + do1 i) = (c + co1 i) * (&1 / d + (&1 / (d + do1 i) - &1 / d))`] THEN MESON_TAC [o1_seq_offset_div_lemma]);; let o1_seq_offset_div2_lemma = prove(` !f:num->real c:real g:num->real d:real. (\i. f(i)/g(i) - c/d) = (\i. f(i) * &1 / (d + g(i) - d) - c * &1 / d) `, MESON_TAC [EQ_EXT; REAL_FIELD `f/g - c/d = f* &1/(d+g-d) - c * &1/d`]);; let o1_seq_offset_div2 = prove(` !f:num->real c:real g:num->real d:real. o1_seq (\i. f(i) - c) /\ o1_seq (\i. g(i) - d) /\ ~(d = &0) ==> o1_seq (\i. f(i)/g(i) - c/d) `, REPEAT STRIP_TAC THEN specialize [`\i:num. g(i) - d`; `d:real`] o1_seq_1overcplusx THEN specialize [`\i:num. g(i) - d`; `d:real`] o1_seq_1overcplusx THEN specialize [`f:num->real`; `c:real`; `\i:num. &1 / (d + g(i) - d)`; `&1 / d`] o1_seq_offset_mul2 THEN ASM_MESON_TAC [o1_seq_offset_div2_lemma]);; let asymp1_db_lemma = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) ==> (\i. (n(i) + k(i) + &1) / b(i) - (&1 + X0) / Y0) = (\i. ((n(i) + k(i) + &1) / n(i)) / (b(i) / n(i)) - (&1 + X0) / Y0) `, MESON_TAC [EQ_EXT; REAL_FIELD `&1 < x ==> (a/x)/(b/x) = a/b`]);; let asymp1_db_lemma2 = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) /\ o1_seq (\i. (n(i) + k(i) + &1) / n(i) - (&1 + X0)) /\ o1_seq (\i. b(i) / n(i) - Y0) /\ ~(Y0 = &0) ==> o1_seq (\i. (n(i) + k(i) + &1) / b(i) - (&1 + X0) / Y0) `, REPEAT STRIP_TAC THEN specialize [`\i:num. (n(i) + k(i) + &1) / n(i)`; `&1 + X0`; `\i:num. b(i) / n(i)`; `Y0:real`] o1_seq_offset_div2 THEN ASM_MESON_TAC [asymp1_db_lemma]);; let asymp1_db = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. k(i) / n(i) - X0) /\ o1_seq (\i. b(i) / n(i) - Y0) /\ ~(Y0 = &0) ==> o1_seq (\i. (n(i) + k(i) + &1) / b(i) - (&1 + X0) / Y0) `, MESON_TAC [asymp1_db_lemma2; asymp1_dn]);; let asymp1_sn_pow = prove(` !n:num->real s:num->real S0:real sno1:num->real. o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) /\ (!i. &0 < s(i)) /\ (!i. &1 < n(i)) ==> (!i. s(i) = n(i) powreal (S0 + sno1(i))) `, MESON_TAC [powreal_log2ratio]);; let asymp1_sn_pow2 = prove(` !n:num->real s:num->real S0:real sno1:num->real. o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) /\ (!i. &0 < s(i)) /\ (!i. &1 < n(i)) ==> (!i. s(i) pow 2 = n(i) powreal (&2*S0 + &2*sno1(i))) `, MESON_TAC [asymp1_sn_pow; powreal_pow; REAL_ADD_LDISTRIB]);; let lnovero1_lemma1 = prove(` !x:real e:real. &0 < e /\ &1 < x /\ &1 / x <= exp(--(&1/e)) ==> &1 / ln(x) <= e `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x`; ln_mono_le; LN_EXP; LN_POS_LT; ln_1over; pos_1over; REAL_ARITH `--x <= --y <=> y <= x`; recipflip]);; let lnovero1_lemma2 = prove(` !x:real. &0 < e /\ &1 < x /\ abs(&1 / x) <= exp(--(&1/e)) ==> abs(&1 / ln(x)) <= e `, MESON_TAC [lnovero1_lemma1; REAL_ABS_REFL; REAL_ARITH `&1 < x ==> &0 < x`; LN_POS_LT; pos_1over; REAL_ARITH `&0 < y ==> &0 <= y`]);; let lnovero1 = prove(` !n:num->real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) ==> o1_seq (\i. &1 / ln(n(i))) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN X_CHOOSE_TAC `a:num` (UNDISCH_ALL (MESON [REAL_EXP_POS_LT] `(!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= e)) ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= exp(--(&1 / e)))`)) THEN EXISTS_TAC `a:num` THEN ASM_MESON_TAC [lnovero1_lemma2]);; let invlog2_lnln = prove(` !x:real. ln(&2)/ln(x) = &1/log2(x) `, REWRITE_TAC [log2] THEN REWRITE_TAC [REAL_FIELD `&1/(d/e) = e/d`]);; let invlog2_lnln2 = prove(` !x:real. ln(&2)*(&1/ln(x)) = &1/log2(x) `, REWRITE_TAC [REAL_FIELD `ln(&2)*(&1/x) = ln(&2)/x`] THEN MESON_TAC [invlog2_lnln]);; let log2overo1 = prove(` !n:num->real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) ==> o1_seq (\i. &1 / log2(n(i))) `, REWRITE_TAC [GSYM invlog2_lnln2] THEN MESON_TAC [ISPECL [`\i:num. &1 / ln(n(i))`; `ln(&2)`] o1_seq_consttimes; lnovero1]);; let asymp1_nkno1 = prove(` !n:num->real k:num->real X0:real kno1:num->real. (!i. k(i) / n(i) = X0 + kno1(i)) /\ (!i. &1 < n(i)) ==> (!i. (n(i) + k(i)) / n(i) = (&1 + X0) + kno1(i)) `, MESON_TAC [REAL_FIELD `&1 < b /\ a/b = c+d ==> (b+a)/b = (&1+c)+d`]);; let o1_seq_lncplusx = prove(` !f:num->real c:real. o1_seq f /\ &0 < c ==> o1_seq (\i. ln(c+f(i)) - ln(c)) `, MESON_TAC [ln_continuous; ISPECL [`f:num->real`; `ln`] o1_seq_compose]);; let asymp1_ln_nkn = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. (n(i) + k(i)) / n(i) = (&1 + X0) + kno1(i)) /\ &0 < &1 + X0 ==> ?lnkno1. o1_seq lnkno1 /\ (!i. ln((n(i) + k(i)) / n(i)) = ln(&1 + X0) + lnkno1(i)) `, REPEAT STRIP_TAC THEN EXISTS_TAC `\i:num. ln((n(i) + k(i))/n(i)) - ln(&1 + X0:real)` THEN CONJ_TAC THENL [ASM_SIMP_TAC [ISPECL [`kno1:num->real`; `&1+X0:real`] o1_seq_lncplusx]; REAL_ARITH_TAC]);; let asymp1_ln_nkn2 = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. (n(i) + k(i)) / n(i) = (&1 + X0) + kno1(i)) /\ (!i. &0 < n(i)) /\ (!i. &0 < n(i) + k(i)) /\ &0 < &1 + X0 ==> ?lnkno1. o1_seq lnkno1 /\ (!i. ln(n(i) + k(i)) - ln(n(i)) = ln(&1 + X0) + lnkno1(i)) `, MESON_TAC [asymp1_ln_nkn; LN_DIV]);; let asymp1_lnln_nkn_lemma2 = prove(` !n:num->real k:num->real X0:real lnkno1:num->real. (!i. ln(n(i) + k(i)) - ln(n(i)) = ln(&1 + X0) + lnkno1(i)) /\ (!i. &1 < n(i)) ==> (!i. ln(n(i) + k(i))/ln(n(i)) - &1 = ln(&1 + X0)/ln(n(i)) + lnkno1(i)/ln(n(i))) `, MESON_TAC [ln_gt1; REAL_FIELD `&0 < b ==> a - b = c + d ==> a/b - &1 = c/b + d/b`]);; let asymp1_lnln_nkn_lemma3 = prove(` !n:num->real X0:real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) ==> o1_seq (\i:num. ln(&1 + X0)/ln(n(i))) `, ONCE_REWRITE_TAC [REAL_FIELD `x/ln(y) = x*(&1/ln(y))`] THEN MESON_TAC [lnovero1; ISPECL [`\i:num. &1 / ln(n(i))`; `ln(&1 + X0):real`] o1_seq_consttimes]);; let asymp1_lnln_nkn_lemma4 = prove(` !n:num->real lnkno1:num->real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) /\ o1_seq lnkno1 ==> o1_seq (\i:num. lnkno1(i)/ln(n(i))) `, ONCE_REWRITE_TAC [REAL_FIELD `x/ln(y) = x*(&1/ln(y))`] THEN MESON_TAC [lnovero1; ISPECL [`lnkno1:num->real`; `\i:num. &1 / ln(n(i))`] o1_seq_mul]);; let asymp1_lnln_nkn_lemma5 = prove(` !n:num->real X0:real lnkno1:num->real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) /\ o1_seq lnkno1 ==> o1_seq (\i:num. ln(&1 + X0)/ln(n(i))+lnkno1(i)/ln(n(i))) `, MESON_TAC [asymp1_lnln_nkn_lemma3; asymp1_lnln_nkn_lemma4; ISPECL [`\i:num. ln (&1 + X0) / ln (n(i))`; `\i:num. lnkno1 i / ln (n(i))`] o1_seq_add]);; let asymp1_lnln_nkn_lemma6 = prove(` !n:num->real k:num->real X0:real lnkno1:num->real. o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) /\ o1_seq lnkno1 /\ (!i. ln(n(i) + k(i)) - ln(n(i)) = ln(&1 + X0) + lnkno1(i)) ==> o1_seq (\i. ln(n(i) + k(i))/ln(n(i)) - &1) `, SIMP_TAC [asymp1_lnln_nkn_lemma2; asymp1_lnln_nkn_lemma5]);; let asymp1_lnln_nkn_lemma7 = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. (n(i) + k(i)) / n(i) = (&1 + X0) + kno1(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &1 < n(i)) /\ (!i. &0 < n(i) + k(i)) /\ &0 < &1 + X0 ==> o1_seq (\i. ln(n(i) + k(i))/ln(n(i)) - &1) `, MESON_TAC [asymp1_lnln_nkn_lemma6; asymp1_ln_nkn2; REAL_ARITH `&1 < a ==> &0 < a`]);; let asymp1_lnln_nkn_lemma8 = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ &0 < &1 + X0 ==> o1_seq (\i. ln(n(i) + k(i))/ln(n(i)) - &1) `, MESON_TAC [asymp1_lnln_nkn_lemma7; asymp1_nkno1]);; let asymp1_lnln_nkn = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ &0 < &1 + X0 ==> ?lnlnkno1. o1_seq lnlnkno1 /\ (!i. ln(n(i) + k(i))/ln(n(i)) = &1 + lnlnkno1(i)) `, REWRITE_TAC [REAL_ARITH `ln a/ln b = &1 + c <=> ln a/ln b - &1 = c`] THEN MESON_TAC [asymp1_lnln_nkn_lemma8]);; let powreal_from_lnln = prove(` !a b c. &0 < a /\ &1 < b ==> ln(a)/ln(b) = c ==> a = b powreal c `, REWRITE_TAC [powreal] THEN MESON_TAC [REAL_EQ_LDIV_EQ; EXP_LN; ln_gt1]);; let asymp1_nk_powreal_n = prove(` !n:num->real k:num->real X0:real kno1:num->real. o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ &0 < &1 + X0 ==> ?lnlnkno1. o1_seq lnlnkno1 /\ (!i. n(i)+k(i) = n(i) powreal (&1 + lnlnkno1(i))) `, MESON_TAC [asymp1_lnln_nkn; powreal_from_lnln]);; let asymp1_nkss_lemma1 = prove(` !n:num->real s:num->real S0:real sno1:num->real k:num->real X0:real kno1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ &0 < &1 + X0 /\ (!i. &0 < s(i)) /\ o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) ==> ?lnlnkno1. o1_seq lnlnkno1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = (n(i) powreal (&1 + lnlnkno1(i))) * (n(i) powreal (&2*S0 + &2*sno1(i)))) `, MESON_TAC [asymp1_sn_pow2; asymp1_nk_powreal_n]);; let powreal_sum = prove(` !x y z. x powreal (y+z) = (x powreal y)*(x powreal z) `, REWRITE_TAC [powreal] THEN REWRITE_TAC [REAL_ADD_RDISTRIB] THEN REWRITE_TAC [REAL_EXP_ADD]);; let asymp1_nkss_lemma2 = prove(` !n:num->real s:num->real S0:real sno1:num->real k:num->real X0:real kno1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ &0 < &1 + X0 /\ (!i. &0 < s(i)) /\ o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) ==> ?lnlnkno1. o1_seq lnlnkno1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = n(i) powreal ((&1 + &2*S0) + lnlnkno1(i) + &2*sno1(i))) `, ONCE_REWRITE_TAC [REAL_ARITH `(a + b) + c + d = (a + c) + (b + d)`] THEN ONCE_REWRITE_TAC [powreal_sum] THEN MESON_TAC [asymp1_nkss_lemma1]);; let asymp1_nkss_lemma3 = prove(` !n:num->real s:num->real S0:real sno1:num->real k:num->real lnlnkno1:num->real. o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) /\ o1_seq lnlnkno1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = n(i) powreal ((&1 + &2*S0) + lnlnkno1(i) + &2*sno1(i))) ==> ?nksso1. o1_seq nksso1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = n(i) powreal ((&1 + &2*S0) + nksso1(i))) `, REPEAT STRIP_TAC THEN EXISTS_TAC `\i:num. lnlnkno1(i) + &2*sno1(i)` THEN CONJ_TAC THENL [ASM_MESON_TAC [ISPECL [`sno1:num->real`; `&2:real`] o1_seq_consttimes; ISPECL [`lnlnkno1:num->real`; `\i:num. &2*sno1(i)`] o1_seq_add]; ASM_MESON_TAC []]);; let asymp1_nkss_lemma4 = prove(` !n:num->real s:num->real S0:real sno1:num->real k:num->real X0:real kno1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ &0 < &1 + X0 /\ (!i. &0 < s(i)) /\ o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) ==> ?nksso1. o1_seq nksso1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = n(i) powreal ((&1 + &2*S0) + nksso1(i))) `, REPEAT GEN_TAC THEN DISCH_TAC THEN X_CHOOSE_TAC `o1:num->real` (UNDISCH_ALL (ISPECL [`n:num->real`; `s:num->real`; `S0:real`; `sno1:num->real`; `k:num->real`; `X0:real`; `kno1:num->real`] asymp1_nkss_lemma2)) THEN ASM_MESON_TAC [asymp1_nkss_lemma3]);; let exp_bound1 = prove(` !x:real. &0 <= x ==> &1 + x / &2 <= exp(x / &2) `, MESON_TAC [REAL_ARITH `&0 <= (x:real) ==> &0 <= x / &2`; REAL_EXP_LE_X]);; let exp_bound2 = prove(` !x:real. &0 <= x ==> x / &2 < exp(x / &2) `, MESON_TAC [exp_bound1; REAL_ARITH `x / &2 < &1 + x / &2`; REAL_LTE_TRANS]);; let lt_square = prove(` !x:real y:real. &0 <= x /\ x < y ==> x*x < y*y `, MESON_TAC [REAL_LT_MUL2]);; let exp_bound3 = prove(` !x:real. &0 <= x ==> x*x / &4 < exp(x / &2 + x / &2) `, REWRITE_TAC [REAL_ARITH `x*x / &4 = (x / &2) * (x / &2)`] THEN REWRITE_TAC [REAL_EXP_ADD] THEN MESON_TAC [exp_bound2; REAL_ARITH `&0 <= x ==> &0 <= x / &2`; lt_square]);; let exp_bound4 = prove(` !x:real. &0 <= x ==> x*x / &4 < exp(x) `, MESON_TAC [exp_bound3; REAL_ARITH `x / &2 + x / &2 = x`]);; let exp_bound5 = prove(` !x:real a:real. &0 <= x /\ &0 < a ==> a*(x*x / &4) < a*exp(x) `, MESON_TAC [exp_bound4; REAL_LT_LMUL]);; let abx_lemma1 = prove(` !a:real b:real x:real. &0 < a*b*b /\ &4 / (a*b*b) <= x /\ &0 <= x ==> x <= a*(b*x)*(b*x) / &4 `, MESON_TAC [ISPECL [`&4:real`; `x:real`; `a*b*b:real`] REAL_LE_LDIV_EQ; REAL_ARITH `&4 <= x*a*b*b ==> &1 <= (a*b*b)*x / &4`; REAL_LE_LMUL; REAL_ARITH `x * &1 = x`; REAL_ARITH `x*(a*b*b)*x / &4 = a*(b*x)*(b*x) / &4`]);; let abx_lemma2 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 / (a*b*b) <= x ==> x <= a*(b*x)*(b*x) / &4 `, MESON_TAC [abx_lemma1; REAL_LT_MUL; REAL_LT_DIV; REAL_ARITH `&0 < &4`; REAL_LTE_TRANS; REAL_LT_IMP_LE]);; let abx_lemma3 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 / (a*b*b) <= x ==> &0 <= b*x `, MESON_TAC [REAL_LT_MUL; REAL_LT_DIV; REAL_ARITH `&0 < &4`; REAL_LTE_TRANS; REAL_LT_IMP_LE; REAL_LE_MUL]);; let exp_beats_linear = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 / (a*b*b) <= x ==> x < a*exp(b*x) `, MESON_TAC [abx_lemma2; abx_lemma3; exp_bound5; REAL_LET_TRANS]);; let exp_beats_linear_2 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x ==> a*x < exp(b*x) `, MESON_TAC [pos_1over; REAL_FIELD `&0 < a ==> &4 * a / (b*b) = &4 / ((&1 / a) * b*b)`; exp_beats_linear; REAL_LT_LMUL; REAL_FIELD `&0 < a ==> a * (&1 / a) * c = c`]);; let linear_beats_log_lemma = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x ==> &0 < x `, MESON_TAC [REAL_ARITH `&0 < &4`; REAL_LT_MUL; REAL_LT_DIV; REAL_LTE_TRANS]);; let linear_beats_log_lemma2 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x ==> &0 < a*x `, MESON_TAC [REAL_LT_MUL; linear_beats_log_lemma]);; let linear_beats_log = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x ==> ln(a*x) < b*x `, MESON_TAC [exp_beats_linear_2; linear_beats_log_lemma2; ln_mono_lt; LN_EXP]);; let linear_beats_log_2 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x ==> ln(a*x) / x < b `, MESON_TAC [linear_beats_log_lemma; linear_beats_log; ISPECL [`ln(a*x)`; `b*x:real`] REAL_LT_DIV2_EQ; REAL_FIELD `&0 < x ==> (b*x)/x = b`]);; let abb_lemma37 = prove(` !a:real b:real. &0 < a ==> &0 < b ==> &0 < (a * b * b) / &4 `, MESON_TAC [REAL_LT_MUL; REAL_LT_DIV; REAL_ARITH `&0 < &4`]);; let abb_lemma38 = prove(` !a:real b:real. &0 < a ==> &0 < b ==> &0 < (b * b) / (&4 * a) `, MESON_TAC [REAL_LT_MUL; REAL_LT_DIV; REAL_ARITH `&0 < &4`]);; let aby_lemma = prove(` !a:real b:real y:real. &0 < a /\ &0 < b /\ &0 < y /\ y <= (a*b*b) / &4 ==> &4 / (a*b*b) <= &1 / y `, MESON_TAC [REAL_LE_INV2; REAL_FIELD `inv((a*b*b) / &4) = &4 / (a*b*b)`; REAL_FIELD `inv(y) = &1 / y`; ]);; let o1_exp_beats_linear = prove(` !a:real b:real o1:num->real. o1_seq o1 /\ (!i. &0 < o1(i)) /\ &0 < a /\ &0 < b ==> ?m. !i. m <= i ==> &1 /o1(i) < a*exp(b/o1(i)) `, REPEAT STRIP_TAC THEN specialize [`a:real`; `b:real`] abb_lemma37 THEN X_CHOOSE_TAC `a:num` (UNDISCH (ISPEC `(a*b*b)/ &4:real` (UNDISCH (fst (EQ_IMP_RULE (ISPEC `o1:num->real` o1_seq)))))) THEN EXISTS_TAC `a:num` THEN ASM_MESON_TAC [REAL_LT_IMP_LE; REAL_ABS_REFL; pos_1over; aby_lemma; exp_beats_linear; REAL_FIELD `b / x = b * (&1 / x)`]);; let max2_lemma = prove(` !a:real. &0 < a ==> &0 < ln(max (&2) (&1 / a)) `, MESON_TAC [REAL_LT_MAX; REAL_ARITH `&1 < &2`; ln_gt1]);; let o1_pospow_lemma1 = prove(` !x d e. &0 < d /\ &0 < x /\ x <= exp(ln(e) / d) ==> d * ln(x) <= ln(e) `, MESON_TAC [ln_mono_le; LN_EXP; REAL_LE_LMUL; REAL_LT_IMP_LE; REAL_FIELD `&0 < d ==> d * (ln(e) / d) = ln(e)`]);; let real_ge_lmul = prove(` !x y z:real. x <= &0 /\ y <= z ==> x * z <= x * y `, MESON_TAC [REAL_LE_NEG2; REAL_ARITH `-- &0 = &0`; REAL_LE_LMUL; REAL_NEG_LMUL]);; let real_ge_rmul = prove(` !x y z:real. x <= &0 /\ y <= z ==> z * x <= y * x `, MESON_TAC [REAL_LE_NEG2; REAL_ARITH `-- &0 = &0`; REAL_LE_RMUL; REAL_NEG_RMUL]);; let o1_pospow_lemma2 = prove(` !x y d. d <= y /\ &0 < x /\ x <= &1 ==> y * ln(x) <= d * ln(x) `, MESON_TAC [ln_mono_le; LN_1; real_ge_rmul]);; let o1_pospow_lemma3 = prove(` !x y d e. &0 < d /\ &0 < x /\ x <= &1 /\ d <= y /\ x <= exp(ln(e) / d) ==> y * ln(x) <= ln(e) `, MESON_TAC [o1_pospow_lemma1; o1_pospow_lemma2; REAL_LE_TRANS]);; let o1_pospow_lemma4 = prove(` !x y d e. &0 < d /\ &0 < x /\ x <= min (&1) (exp(ln(e)/d)) /\ d <= y ==> y * ln(x) <= ln(e) `, MESON_TAC [o1_pospow_lemma3; REAL_LE_MIN]);; let o1_pospow_lemma5 = prove(` !x y c e. &0 < c /\ &0 < x /\ --c / &2 <= y /\ x <= min (&1) (exp(ln(e)/(c / &2))) ==> (c + y) * ln(x) <= ln(e) `, MESON_TAC [o1_pospow_lemma4; REAL_ARITH `--c / &2 <= y ==> c / &2 <= c + y`; REAL_ARITH `&0 < c ==> &0 < c / &2`]);; let o1_pospow_lemma6 = prove(` !x y c e. abs(y) < c / &2 /\ &0 < x /\ x <= min (&1) (exp(ln(e)/(c / &2))) ==> (c + y) * ln(x) <= ln(e) `, MESON_TAC [o1_pospow_lemma5; REAL_ARITH `abs(y) < c / &2 ==> &0 < c`; REAL_ARITH `abs(y) < c / &2 ==> --c / &2 <= y`]);; let o1_pospow_lemma7 = prove(` !x y c e. &0 < e /\ abs(y) < c / &2 /\ &0 < x /\ x <= min (&1) (exp(ln(e)/(c / &2))) ==> abs(x powreal (c + y)) <= e `, REWRITE_TAC [powreal] THEN MESON_TAC [o1_pospow_lemma6; REAL_EXP_MONO_LE; EXP_LN; REAL_EXP_POS_LT; REAL_ARITH `&0 < x /\ x <= e ==> abs(x) <= e`]);; let o1_pospow_lemma8 = prove(` !x y c e. &0 < e /\ abs(y) < c / &2 /\ &0 < x /\ abs(x) <= min (&1) (exp(ln(e)/(c / &2))) ==> abs(x powreal (c + y)) <= e `, MESON_TAC [o1_pospow_lemma7; REAL_ARITH `&0 < x ==> x = abs(x)`]);; let o1_pospow_lemma9 = prove(` !c e. &0 < min (&1) (exp (ln e / (c / &2))) `, MESON_TAC [REAL_LT_MIN; REAL_ARITH `&0 < &1`; REAL_EXP_POS_LT]);; let o1_pospow = prove(` !a:num->real b:num->real c:real. o1_seq a /\ (!i. &0 < a(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. a(i) powreal (c+b(i))) `, REPEAT STRIP_TAC THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN ASSUME_TAC (UNDISCH (REAL_ARITH `&0 < c ==> &0 < c / &2`)) THEN X_CHOOSE_TAC `B:num` (UNDISCH (ISPEC `c / &2:real` (UNDISCH (fst (EQ_IMP_RULE (ISPEC `b:num->real` o1_seq_lt)))))) THEN ASSUME_TAC (ISPECL [`c:real`; `e:real`] o1_pospow_lemma9) THEN X_CHOOSE_TAC `A:num` (UNDISCH (ISPEC `min (&1) (exp(ln(e)/(c / &2)))` (UNDISCH (fst (EQ_IMP_RULE (ISPEC `a:num->real` o1_seq)))))) THEN EXISTS_TAC `MAX A B` THEN ASM_MESON_TAC [o1_pospow_lemma8; max_le]);; let o1_ln1plus_lemma1 = prove(` !n:num->real b:num->real c:real. o1_seq (\i. &1 / n(i)) /\ (!i. &0 < &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. (&1 / n(i)) powreal (c+b(i))) `, MESON_TAC [ISPECL [`\i:num. &1 / n(i):real`; `b:num->real`; `c:real`] o1_pospow]);; let o1_ln1plus_lemma2 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. ((&1 / n(i)) powreal (c+b(i))) / ln(n(i))) `, ONCE_REWRITE_TAC [REAL_ARITH `x/ln(y) = x * (&1 / ln(y))`] THEN MESON_TAC [lnovero1; pos_1over; REAL_ARITH `&1 < x ==> &0 < x`; o1_ln1plus_lemma1; ISPECL [`\i:num. ((&1 / n(i)) powreal (c+b(i)))`; `\i:num. &1 / ln(n(i))`] o1_seq_mul]);; let bounded_by_o1 = prove(` !f:num->real g:num->real. o1_seq g /\ (!i. abs(f(i)) <= abs(g(i))) ==> o1_seq f `, REWRITE_TAC [o1_seq] THEN MESON_TAC [REAL_LE_TRANS]);; let nonneg_le_o1 = prove(` !f:num->real g:num->real. o1_seq g /\ (!i. &0 <= f(i)) /\ (!i. f(i) <= g(i)) ==> o1_seq f `, MESON_TAC [bounded_by_o1; REAL_ARITH `&0 <= x /\ x <= y ==> abs(x) <= abs(y)`]);; let nonneg_lt_o1 = prove(` !f:num->real g:num->real. o1_seq g /\ (!i. &0 <= f(i)) /\ (!i. f(i) < g(i)) ==> o1_seq f `, MESON_TAC [nonneg_le_o1; REAL_LT_IMP_LE]);; let ln1xo1x_lemma1 = prove(` !x y. &0 < x /\ &0 < y ==> &0 <= ln(&1 + x*y)/x `, MESON_TAC [REAL_LT_MUL; REAL_ARITH `&0 < z ==> &1 <= &1 + z`; ln_ge1; REAL_LT_IMP_LE; REAL_LE_DIV]);; let ln1xo1x_lemma2 = prove(` !x y. &0 < x /\ &0 < y ==> ln(&1 + x*y)/x <= y `, MESON_TAC [REAL_LT_MUL; REAL_LT_IMP_LE; LN_LE; REAL_LE_DIV2_EQ; prove (` &0 < x ==> (x*y)/x = y `, MESON_TAC [REAL_MUL_SYM; REAL_EQ_LDIV_EQ])]);; let ln1xo1x = prove(` !o1:num->real c:num->real. o1_seq o1 /\ (!i. &0 < o1(i)) /\ (!i. &0 < c(i)) ==> o1_seq (\i. ln(&1 + c(i)*o1(i))/c(i)) `, MESON_TAC [nonneg_le_o1; ln1xo1x_lemma1; ln1xo1x_lemma2]);; let ln1xo1x_quo_lemma1 = prove(` !b:num->real c:num->real. o1_seq (\i. b(i)/c(i)) /\ (!i. &0 < b(i)/c(i)) /\ (!i. &0 < c(i)) ==> o1_seq (\i. ln(&1 + c(i)*(b(i)/c(i)))/c(i)) `, SIMP_TAC [ln1xo1x]);; let ln1xo1x_quo_lemma2 = prove(` !b:num->real c:num->real. (!i. &0 < c(i)) ==> (\i. ln(&1 + c(i)*(b(i)/c(i)))) = (\i. ln(&1 + b(i))) `, MESON_TAC [REAL_FIELD `&0 < c(i:num) ==> b(i) = c(i)*(b(i)/c(i))`; EQ_EXT]);; let ln1xo1x_quo = prove(` !b:num->real c:num->real. (!i. &0 < b(i)) /\ (!i. &0 < c(i)) /\ o1_seq (\i. b(i)/c(i)) ==> o1_seq (\i. ln(&1 + b(i))/c(i)) `, MESON_TAC [REAL_LT_DIV; ln1xo1x_quo_lemma1; ln1xo1x_quo_lemma2]);; let o1_ln1plus_lemma3 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c /\ (!i. &0 < (&1 / n(i)) powreal (c+b(i))) /\ (!i. &0 < ln(n(i))) ==> o1_seq (\i. ln(&1 + (&1 / n(i)) powreal (c+b(i)))/(ln(n(i)))) `, SIMP_TAC [o1_ln1plus_lemma2; ln1xo1x_quo]);; let o1_ln1plus_lemma4 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. ln(&1 + (&1 / n(i)) powreal (c+b(i)))/(ln(n(i)))) `, MESON_TAC [o1_ln1plus_lemma3; ln_gt1; powreal_positive]);; let pow1overbase_times_pow_2 = prove(` !x y. &0 < x ==> (&1 + (&1 / x) powreal y) * (x powreal y) = (x powreal y + &1) `, REWRITE_TAC [REAL_ADD_RDISTRIB] THEN MESON_TAC [powreal_cancelbase; REAL_ARITH `&1 * z = z`]);; let pow1overbase_times_pow_3 = prove(` !x y. &0 < x ==> ln(&1 + (&1 / x) powreal y) + ln(x powreal y) = ln(x powreal y + &1) `, MESON_TAC [pow1overbase_times_pow_2; LN_MUL; powreal_positive; pow1overbase_times_pow_2; REAL_ARITH `&0 < z ==> &0 < &1 + z`]);; let pow1overbase_times_pow_4 = prove(` !x y. &0 < x ==> ln(&1 + (&1 / x) powreal y) + y * ln(x) = ln(x powreal y + &1) `, MESON_TAC [pow1overbase_times_pow_3; powreal; LN_EXP]);; let pow1overbase_times_pow_5 = prove(` !x y. &1 < x ==> ln(&1 + (&1 / x) powreal y) / ln(x) + y = ln(x powreal y + &1) / ln(x) `, MESON_TAC [pow1overbase_times_pow_4; REAL_ARITH `&1 < x ==> &0 < x`; ln_gt1; REAL_FIELD `&0 < c ==> (a + b*c)/c = a/c + b`]);; let pow1overbase_times_pow_6 = prove(` !x y. &1 < x ==> ln(&1 + (&1 / x) powreal y) / ln(x) = ln(x powreal y + &1) / ln(x) - y `, MESON_TAC [pow1overbase_times_pow_5; REAL_ARITH `a + y = z ==> a = z - y`]);; let o1_ln1plus_lemma5 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) ==> (\i. ln(&1 + (&1 / n(i)) powreal (c+b(i)))/(ln(n(i)))) = (\i. ln(n(i) powreal (c+b(i)) + &1)/ln(n(i)) - (c+b(i))) `, MESON_TAC [EQ_EXT; pow1overbase_times_pow_6]);; let o1_ln1plus_lemma6 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. ln(n(i) powreal (c+b(i)) + &1)/ln(n(i)) - (c+b(i))) `, MESON_TAC [o1_ln1plus_lemma4; o1_ln1plus_lemma5]);; let o1_ln1plus_lemma7 = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. (ln(n(i) powreal (c+b(i)) + &1)/ln(n(i)) - (c+b(i))) + b(i)) `, MESON_TAC [o1_ln1plus_lemma6; o1_seq_add_extra]);; let o1_ln1plus = prove(` !n:num->real b:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq b /\ &0 < c ==> o1_seq (\i. ln(n(i) powreal (c+b(i)) + &1)/ln(n(i)) - c) `, ONCE_REWRITE_TAC [REAL_ARITH `a - c = (a - (c+b(i:num))) + b(i)`] THEN SIMP_TAC [o1_ln1plus_lemma7]);; let o1_ln1plus_basen_lemma = prove(` !x c d. &1 < x ==> x powreal (c + d) + &1 = x powreal (c + ln (x powreal (c + d) + &1) / ln (x) - c) `, REWRITE_TAC [powreal] THEN REWRITE_TAC [REAL_ARITH `c + m - c = m`] THEN SIMP_TAC [ln_gt1; REAL_FIELD `&0 < d ==> a / d * d = a`; ] THEN MESON_TAC [EXP_LN; REAL_EXP_POS_LT; REAL_ARITH `&0 < e ==> &0 < e + &1`]);; let o1_ln1plus_basen = prove(` !n:num->real f:num->real c:real o1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < c /\ o1_seq o1 /\ (!i. f(i) = n(i) powreal (c + o1(i))) ==> ?newo1. o1_seq newo1 /\ (!i. f(i) + &1 = n(i) powreal (c + newo1(i))) `, REPEAT STRIP_TAC THEN EXISTS_TAC `\i:num. ln(n(i) powreal (c+o1(i)) + &1)/ln(n(i)) - c` THEN CONJ_TAC THEN ASM_SIMP_TAC [o1_ln1plus] THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [o1_ln1plus_basen_lemma]);; let asymp1_nkss_lemma5 = prove(` !n:num->real k:num->real s:num->real S0:real nksso1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < &1 + &2*S0 /\ o1_seq nksso1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) = n(i) powreal ((&1 + &2*S0) + nksso1(i))) ==> ?nkss1o1. o1_seq nkss1o1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) + &1 = n(i) powreal ((&1 + &2*S0) + nkss1o1(i))) `, MESON_TAC [ISPECL [`n:num->real`; `\i:num. (n(i)+k(i))*(s(i) pow 2):real`; `&1 + &2*S0:real`; `nksso1:num->real`] o1_ln1plus_basen]);; let asymp1_nkss_lemma6 = prove(` !n:num->real s:num->real S0:real sno1:num->real k:num->real X0:real kno1:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < n(i) + k(i)) /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ &0 < &1 + X0 /\ (!i. &0 < s(i)) /\ o1_seq sno1 /\ (!i. log2(s(i))/log2(n(i)) = S0 + sno1(i)) ==> &0 < &1 + &2*S0 ==> ?nkss1o1. o1_seq nkss1o1 /\ (!i. (n(i)+k(i))*(s(i) pow 2) + &1 = n(i) powreal ((&1 + &2*S0) + nkss1o1(i))) `, REPEAT GEN_TAC THEN DISCH_TAC THEN X_CHOOSE_TAC `o1:num->real` (UNDISCH_ALL (ISPECL [`n:num->real`; `s:num->real`; `S0:real`; `sno1:num->real`; `k:num->real`; `X0:real`; `kno1:num->real`] asymp1_nkss_lemma4)) THEN ASM_MESON_TAC [asymp1_nkss_lemma5]);; let asymp1_nkss_lemma7 = prove(` !n x y z. &1 < n /\ x = n powreal (y + z) ==> ln(x) / ln(n) - y = z `, REWRITE_TAC [powreal] THEN REPEAT STRIP_TAC THEN specialize [`(y+z)*ln(n)`] LN_EXP THEN specialize [`n:real`] ln_gt1 THEN specialize [] (REAL_FIELD `&0 < ln(n) ==> ((y + z) * ln(n)) / ln(n) - y = z`) THEN ASM_MESON_TAC []);; let asymp1_nkss_lemma8 = prove(` !n:num->real s:num->real k:num->real S0:real o1:num->real. (!i. &1 < n(i)) /\ (!i. (n(i) + k(i)) * s(i) pow 2 + &1 = n(i) powreal ((&1 + &2 * S0) + o1(i))) ==> o1 = (\i. ln ((n(i) + k(i)) * s(i) pow 2 + &1) / ln (n(i)) - (&1 + &2 * S0)) `, MESON_TAC [EQ_EXT; asymp1_nkss_lemma7]);; let asymp1_nkss = prove(` !n:num->real s:num->real k:num->real S0:real X0:real. (!i. &1 < n(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i) / n(i) - X0) ==> o1_seq (\i. ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i)) - (&1 + &2*S0)) `, REPEAT STRIP_TAC THEN specialize [] (REAL_ARITH `&0 <= X0 ==> &0 < &1 + X0`) THEN specialize [`n:num->real`; `k:num->real`] (prove (` !n:num->real k:num->real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) ==> (!i. &0 < n(i) + k(i)) `, MESON_TAC [REAL_ARITH `&1 < x /\ &0 < y ==> &0 < x + y`])) THEN specialize [] (REAL_ARITH `!i. k(i) / n(i) = X0 + (\i:num. k(i) / n(i) - X0)(i)`) THEN specialize [] (REAL_ARITH `!i. log2(s(i))/log2(n(i)) = S0 + (\i:num. log2(s(i))/log2(n(i)) - S0)(i)`) THEN choose_specializing `o1:num->real` [`n:num->real`; `s:num->real`; `S0:real`; `\i:num. log2(s(i))/log2(n(i)) - S0`; `k:num->real`; `X0:real`; `\i:num. k(i) / n(i) - X0`] asymp1_nkss_lemma6 THEN ASM_MESON_TAC [asymp1_nkss_lemma8]);; let asymp1_nkss_2_lemma = prove(` !n:num->real s:num->real k:num->real S0:real X0:real. (\i. &1 / &2 * (ln ((n i + k i) * s i pow 2 + &1) / ln (n i) - (&1 + &2 * S0))) = (\i. &1 / &2 * ln ((n i + k i) * s i pow 2 + &1) / ln (n i) - (&1 / &2 + S0)) `, MESON_TAC [EQ_EXT; REAL_ARITH `(&1 / &2) * (a - (&1 + &2 * b)) = &1 / &2 * a - (&1 / &2 + b)`]);; let asymp1_nkss_2 = prove(` !n:num->real s:num->real k:num->real S0:real X0:real. (!i. &1 < n(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i) / n(i) - X0) ==> o1_seq (\i. (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i)) - (&1 / &2 + S0)) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `s:num->real`; `k:num->real`; `S0:real`; `X0:real`] asymp1_nkss THEN specialize [`\i:num. ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i)) - (&1 + &2*S0)`; `&1 / &2`] o1_seq_consttimes THEN ASM_MESON_TAC [asymp1_nkss_2_lemma]);; let o1_logoverlinear_lemma = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x /\ &0 <= ln(a*x) / x ==> abs(ln(a*x) / x) <= b `, MESON_TAC [linear_beats_log_2; REAL_ABS_REFL; REAL_LT_IMP_LE]);; let o1_logoverlinear_lemma2 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &4 * a / (b*b) <= x /\ &1 <= a*x ==> abs(ln(a*x) / x) <= b `, MESON_TAC [ln_ge1; o1_logoverlinear_lemma; linear_beats_log_lemma; REAL_LT_IMP_LE; REAL_LE_DIV]);; let o1_logoverlinear_lemma3 = prove(` !a:real x:real. &0 < a /\ &1 <= a*x ==> &0 < &1 / x `, MESON_TAC [REAL_ARITH `&1 <= a*x ==> &0 < a*x`; REAL_LT_DIV; REAL_FIELD `&0 < a ==> (a*x)/a = x`; pos_1over]);; let o1_logoverlinear_lemma4 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &1 <= a*x ==> abs(&1 / x) = &1 / x `, MESON_TAC [o1_logoverlinear_lemma3; REAL_LT_IMP_LE; REAL_ABS_REFL]);; let o1_logoverlinear_lemma5 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &1 <= a*x /\ &1 / x <= (b*b) / (&4 * a) ==> &4 * a / (b * b) <= x `, MESON_TAC [o1_logoverlinear_lemma3; REAL_LT_IMP_LE; REAL_LE_INV2; REAL_FIELD `&0 < &1 / x ==> inv(&1 / x) = x`; REAL_FIELD `inv((b*b) / (&4 * a)) = &4 * a/(b*b)`]);; let o1_logoverlinear_lemma6 = prove(` !a:real b:real x:real. &0 < a /\ &0 < b /\ &1 <= a*x /\ abs(&1 / x) <= (b*b) / (&4 * a) ==> abs(ln(a*x) / x) <= b `, MESON_TAC [o1_logoverlinear_lemma2; o1_logoverlinear_lemma4; o1_logoverlinear_lemma5]);; let o1_logoverlinear = prove(` !a:real f:num->real. &0 < a /\ (!i. &1 <= a*f(i)) /\ o1_seq (\i. &1 / f(i)) ==> o1_seq (\i. ln(a*f(i)) / f(i)) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN specialize [`a:real`; `e:real`] abb_lemma38 THEN X_CHOOSE_TAC `a:num` (UNDISCH_ALL (MESON [] `&0 < (e * e) / (&4 * a) ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (&1 / f i) <= e)) ==> (?m:num. !i. m <= i ==> abs (&1 / f i) <= (e*e) / (&4 * a))`)) THEN EXISTS_TAC `a:num` THEN ASM_MESON_TAC [o1_logoverlinear_lemma6]);; let o1_logoverlinear_1 = prove(` !f:num->real. (!i. &1 <= f(i)) /\ o1_seq (\i. &1 / f(i)) ==> o1_seq (\i. ln(f(i)) / f(i)) `, ONCE_REWRITE_TAC [REAL_ARITH `&1 <= x <=> &1 <= &1*x`] THEN ONCE_REWRITE_TAC [MESON [REAL_ARITH `x = &1 * x`] `ln(x) = ln(&1 * x)`] THEN REPEAT STRIP_TAC THEN real_linear `&0 < &1` THEN specialize [`&1`; `f:num->real`] o1_logoverlinear THEN ASM_SIMP_TAC []);; let o1_log2overlinear_1 = prove(` !f:num->real. (!i. &1 <= f(i)) /\ o1_seq (\i. &1 / f(i)) ==> o1_seq (\i. log2(f(i)) / f(i)) `, REPEAT STRIP_TAC THEN specialize [`f:num->real`] o1_logoverlinear_1 THEN specialize [`\i:num. ln(f(i))/f(i)`; `(&1/ln(&2))`] o1_seq_consttimes THEN REWRITE_TAC [log2] THEN REWRITE_TAC [REAL_ARITH `ln(a)/b/c = (&1/b)*(ln(a)/c)`] THEN ASM_SIMP_TAC []);; let asymp1_linearinfinity_lemma = prove(` !e Y0. &0 < Y0 ==> &0 < e ==> &0 < e * Y0 / &2 `, MESON_TAC [REAL_ARITH `&0 < &2`; REAL_LT_MUL; REAL_LT_DIV]);; let le_div = prove(` !w x y z. &0 < w /\ w <= x /\ &0 <= y /\ y <= z ==> y / x <= z / w `, MESON_TAC [le_1over; REAL_LE_LMUL; REAL_ARITH `y * (&1 / x) = y / x`; REAL_LE_DIV2_EQ; REAL_LE_TRANS]);; let asymp1_linearinfinity_lemma2 = prove(` !x y c d e. &0 < y /\ &0 < c / &2 /\ x / y = c + d /\ abs(d) <= c / &2 /\ &1 / y <= e * c / &2 ==> &1 / x <= (e * c / &2) / (c / &2) `, MESON_TAC [pos_1over; REAL_LT_IMP_LE; REAL_ARITH `abs(d) <= c / &2 ==> c / &2 <= c + d`; REAL_FIELD `&0 < y ==> (&1 / y) / (x / y) = &1 / x`; le_div]);; let asymp1_linearinfinity_lemma3 = prove(` !x y c d e. &0 < y /\ &0 < c /\ x / y = c + d /\ abs(d) <= c / &2 /\ &1 / y <= e * c / &2 ==> &1 / x <= e `, MESON_TAC [asymp1_linearinfinity_lemma2; REAL_FIELD `&0 < c ==> &0 < c / &2`; REAL_FIELD `&0 < c / &2 ==> e = (e * c / &2) / (c / &2)`]);; let asymp1_linearinfinity_lemma4 = prove(` !x y c d e. &0 < x /\ &0 < y /\ &0 < c /\ x / y = c + d /\ abs(d) <= c / &2 /\ abs(&1 / y) <= e * c / &2 ==> abs(&1 / x) <= e `, MESON_TAC [asymp1_linearinfinity_lemma3; pos_1over; REAL_LT_IMP_LE; REAL_ABS_REFL]);; let asymp1_linearinfinity = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &0 < n(i)) /\ (!i. &0 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. &1 / b(i)) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN ASSUME_TAC (UNDISCH_ALL (REAL_ARITH `&0 < Y0 ==> &0 < Y0 / &2`)) THEN X_CHOOSE_TAC `B:num` (UNDISCH_ALL (MESON [] `&0 < Y0 / &2 ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (bno1 i) <= e)) ==> (?m:num. !i. m <= i ==> abs (bno1 i) <= Y0 / &2)`)) THEN specialize [`e:real`; `Y0:real`] asymp1_linearinfinity_lemma THEN X_CHOOSE_TAC `N:num` (UNDISCH_ALL (MESON [] `&0 < e * Y0 / &2 ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= e)) ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= e * Y0 / &2)`)) THEN EXISTS_TAC `MAX B N` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [asymp1_linearinfinity_lemma4]);; let asymp1_lnbb = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. ln(pi*b(i)) / b(i)) `, MESON_TAC [pi_333106; REAL_ARITH `&333 / &106 < pi ==> &0 < pi`; REAL_ARITH `&1 < f(i:num) ==> &0 < f(i):real`; ISPECL [`&333 / &106`; `pi`; `&1`; `b(i:num):real`] REAL_LT_MUL2; REAL_ARITH `&0 <= &333 / &106`; REAL_ARITH `&0 <= &1`; REAL_ARITH `(&333 / &106) * &1 < pi*b(i) ==> &1 <= pi*b(i:num)`; ISPECL [`pi`; `b:num->real`] o1_logoverlinear; asymp1_linearinfinity]);; let asymp1_delta_lemma = prove(` !x. &60 <= x ==> &2 * (x - &1) * ln(bkzdelta x) = ln(x) + ln(pi*x)/x - ln(&2 * pi * exp(&1)) `, MESON_TAC [bkzdelta_ln5; REAL_ARITH `&60 <= x ==> &0 < &2 * (x - &1)`; REAL_FIELD `&0 < &2 * (x - &1) ==> &2 * (x - &1) * (b / (&2 * (x - &1))) = b`]);; let asymp1_delta_lemma2 = prove(` !x. &60 <= x ==> &2 * (x - &1) * ln(bkzdelta x) - ln(x) + ln(&2 * pi * exp(&1)) = ln(pi*x)/x `, MESON_TAC [asymp1_delta_lemma; REAL_ARITH `(a + b - c) - a + c = b`]);; let asymp1_delta_lemma3 = prove(` !x. &1 < x ==> abs(&1 / x) <= &1 / &60 ==> &2 * (x - &1) * ln(bkzdelta x) - ln(x) + ln(&2 * pi * exp(&1)) = ln(pi*x)/x `, MESON_TAC [asymp1_delta_lemma2; REAL_ARITH `&1 < x ==> &0 < x`; pos_1over; REAL_LT_IMP_LE; REAL_ABS_REFL; le_1over; REAL_ARITH `&1 / (&1 / &60) = &60`; REAL_FIELD `&0 < x ==> &1 / (&1 / x) = x`]);; let asymp1_delta_lemma4 = prove(` !b:num->real. (!i. &1 < b(i)) /\ o1_seq (\i. &1 / b(i)) /\ o1_seq (\i. ln(pi*b(i)) / b(i)) ==> o1_seq (\i. &2 * (b(i) - &1) * ln(bkzdelta(b(i))) - ln(b(i)) + ln(&2 * pi * exp(&1))) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN ASSUME_TAC (REAL_ARITH `&0 < &1 / &60`) THEN X_CHOOSE_TAC `B:num` (UNDISCH_ALL (MESON [] `&0 < &1 / &60 ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (&1 / b i) <= e)) ==> (?m:num. !i. m <= i ==> abs (&1 / b i) <= &1 / &60)`)) THEN X_CHOOSE_TAC `A:num` (UNDISCH_ALL (MESON [] `&0 < e ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (ln(pi*b(i)) / b(i)) <= e)) ==> (?m:num. !i. m <= i ==> abs (ln(pi*b(i)) / b(i)) <= e)`)) THEN EXISTS_TAC `MAX A B` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [asymp1_delta_lemma3]);; let asymp1_delta_lemma5 = prove(` !n:num->real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) ==> o1_seq (\i. c/ln(n(i))) `, ONCE_REWRITE_TAC [REAL_ARITH `x / ln(y) = x * (&1 / ln(y))`] THEN MESON_TAC [lnovero1; ISPEC `\i:num. &1 / ln(n(i))` o1_seq_consttimes]);; let asymp1_delta_lemma6 = prove(` !r e x. &0 < e /\ &1 < x /\ &1 / x <= exp(r / e) ==> --ln x <= r / e `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x`; pos_1over; ln_1over; ln_mono_le; LN_EXP]);; let asymp1_delta_lemma7 = prove(` !r e x. &0 < e /\ &1 < x /\ --ln x <= r / e ==> --e <= r / ln x `, MESON_TAC [REAL_ARITH `--a <= b ==> --b <= a`; REAL_LE_RDIV; ln_gt1; REAL_LT_DIV; REAL_LT_IMP_LE; REAL_LE_LMUL; REAL_FIELD `&0 < e ==> (e/ln(x))*(r/e) = r/ln(x)`; REAL_FIELD `&0 < ln(x) ==> (e/ln(x))*(--ln(x)) = --e`]);; let asymp1_delta_lemma8 = prove(` !r e x. &0 < e /\ &1 < x /\ &1 / x <= exp(ln(r) / e) ==> --e <= ln(r) / ln x `, MESON_TAC [asymp1_delta_lemma6; asymp1_delta_lemma7]);; let asymp1_delta_lemma9 = prove(` !r e x. &0 < e /\ &1 < x /\ &1 / x <= exp(-- ln(&3 * r) / e) ==> ln(&3 * r) / ln x <= e `, REWRITE_TAC [REAL_FIELD `-- L / y = (-- L) / y`] THEN MESON_TAC [asymp1_delta_lemma6; asymp1_delta_lemma7; REAL_LE_NEG2; REAL_FIELD `(-- L) / D = --(L / D)`]);; let asymp1_delta_lemma10 = prove(` !r e x y. &0 < e /\ &1 < x /\ &1 / x <= exp(ln(r) / e) /\ &1 / x <= exp(-- ln(&3 * r) / e) /\ ln(r) / ln x <= y /\ y <= ln(&3 * r) / ln x ==> abs(y) <= e `, MESON_TAC [asymp1_delta_lemma8; asymp1_delta_lemma9; REAL_LE_TRANS; REAL_ABS_BOUNDS]);; let asymp1_delta_lemma11 = prove(` !r e x y. &0 < e /\ &1 < x /\ &1 / x <= min (exp(ln(r) / e)) (exp(-- ln(&3 * r) / e)) /\ ln(r) / ln x <= y /\ y <= ln(&3 * r) / ln x ==> abs(y) <= e `, MESON_TAC [REAL_LE_MIN; asymp1_delta_lemma10]);; let asymp1_delta_lemma12 = prove(` !r e x y. &0 < e /\ &1 < x /\ &1 / x <= min (exp(ln(r) / e)) (exp(-- ln(&3 * r) / e)) /\ ln(r) / ln x <= y /\ y <= ln(&3 * r) / ln x ==> abs(y) <= e `, MESON_TAC [exp_min; asymp1_delta_lemma11]);; let asymp1_delta_lemma13 = prove(` !n b c d. &1 < n /\ &1 < b /\ &0 < c /\ b / n = c + d /\ abs(d) <= c / &2 ==> ln(c / &2) <= ln b - ln n `, MESON_TAC [REAL_ARITH `abs(d) <= c / &2 ==> c / &2 <= c + d`; REAL_ARITH `&0 < c ==> &0 < c / &2`; REAL_ARITH `&1 < y ==> &0 < y`; ln_mono_le; LN_DIV]);; let asymp1_delta_lemma14 = prove(` !n b c d. &1 < n /\ &1 < b /\ b / n = c + d /\ abs(d) <= c / &2 ==> ln b - ln n <= ln(&3 * c / &2) `, MESON_TAC [REAL_ARITH `abs(d) <= c / &2 ==> c + d <= &3 * c / &2`; REAL_ARITH `&1 < y ==> &0 < y`; REAL_LT_DIV; ln_mono_le; LN_DIV]);; let asymp1_delta_lemma15 = prove(` !n b c d. &1 < n /\ &1 < b /\ &0 < c /\ b / n = c + d /\ abs(d) <= c / &2 ==> ln(c / &2) / ln n <= (ln b - ln n) / ln n `, MESON_TAC [asymp1_delta_lemma13; REAL_LE_DIV2_EQ; ln_gt1]);; let asymp1_delta_lemma16 = prove(` !n b c d. &1 < n /\ &1 < b /\ b / n = c + d /\ abs(d) <= c / &2 ==> (ln b - ln n) / ln n <= ln(&3 * c / &2) / ln n `, MESON_TAC [asymp1_delta_lemma14; REAL_LE_DIV2_EQ; ln_gt1]);; let asymp1_delta_lemma17 = prove(` !n b c e. &1 < n /\ &1 < b /\ &0 < c /\ &0 < e /\ b / n = c + d /\ abs(d) <= c / &2 /\ &1 / n <= min (exp(ln(c / &2) / e)) (exp(-- ln(&3 * (c / &2)) / e)) ==> abs((ln b - ln n) / ln n) <= e `, MESON_TAC [REAL_ARITH `&0 < c ==> &0 < c / &2`; asymp1_delta_lemma12; asymp1_delta_lemma15; asymp1_delta_lemma16]);; let asymp1_delta_lemma18 = prove(` !n b c e. &1 < n /\ &1 < b /\ &0 < c /\ &0 < e /\ b / n = c + d /\ abs(d) <= c / &2 /\ abs(&1 / n) <= min (exp(ln(c / &2) / e)) (exp(-- ln(&3 * (c / &2)) / e)) ==> abs((ln b - ln n) / ln n) <= e `, MESON_TAC [asymp1_delta_lemma17; REAL_ARITH `&1 < n ==> &0 < n`; pos_1over; REAL_LT_IMP_LE; REAL_ABS_REFL]);; let asymp1_delta_lemma19 = prove(` !n b c e. &1 < n /\ &1 < b /\ &0 < c /\ &0 < e /\ b / n = c + d /\ abs(d) <= c / &2 /\ abs(&1 / n) <= min (exp(ln(c / &2) / e)) (exp(-- ln(&3 * (c / &2)) / e)) ==> abs((ln b)/ln(n) - &1) <= e `, MESON_TAC [asymp1_delta_lemma18; ln_gt1; REAL_FIELD `&0 < D ==> (a - D) / D = a/D - &1`]);; let minexpexp_pos = prove(` !x y. &0 < min (exp(x)) (exp(y)) `, MESON_TAC [exp_min; REAL_EXP_POS_LT]);; let asymp1_delta_lemma20 = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. ln(b(i))/ln(n(i)) - &1) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN ASSUME_TAC (UNDISCH_ALL (REAL_ARITH `&0 < Y0 ==> &0 < Y0 / &2`)) THEN X_CHOOSE_TAC `B:num` (UNDISCH_ALL (MESON [] `&0 < Y0 / &2 ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (bno1 i) <= e)) ==> (?m:num. !i. m <= i ==> abs (bno1 i) <= Y0 / &2)`)) THEN ASSUME_TAC (ISPECL [`ln(Y0 / &2) / e`; `-- ln(&3 * (Y0 / &2)) / e`] minexpexp_pos) THEN X_CHOOSE_TAC `A:num` (UNDISCH_ALL (MESON [] `&0 < min (exp(ln(Y0 / &2) / e)) (exp(-- ln(&3 * (Y0 / &2)) / e)) ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= e)) ==> (?m:num. !i. m <= i ==> abs (&1 / n i) <= min (exp(ln(Y0 / &2) / e)) (exp(-- ln(&3 * (Y0 / &2)) / e)))`)) THEN EXISTS_TAC `MAX A B` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [asymp1_delta_lemma19]);; let asymp1_delta_lemma21 = prove(` !n:num->real b:num->real. (!i. &0 < ln(n(i))) ==> (\i. &2 * (b i - &1) * ln (bkzdelta (b i)) / ln (n i) - &1) = (\i. (&2 * (b i - &1) * ln (bkzdelta (b i)) - ln (b i) + ln (&2 * pi * exp (&1))) * &1 / ln (n i) + ln (b i) / ln (n i) - &1 - ln (&2 * pi * exp (&1)) / ln (n i)) `, MESON_TAC [EQ_EXT; REAL_FIELD `&0 < ln(n(i:num)) ==> &2 * (b(i) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - &1 = (&2 * (b(i) - &1) * ln(bkzdelta(b(i))) - ln(b(i)) + ln(&2 * pi * exp(&1))) * (&1 / ln(n(i))) + (ln(b(i)) / ln(n(i)) - &1) - (ln(&2 * pi * exp(&1)) / ln(n(i)))`]);; let asymp1_delta = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. &2 * (b(i) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - &1) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`] (prove (` !n:num->real. (!i. &1 < n(i)) ==> (!i. &0 < n(i)) `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x`])) THEN specialize [`b:num->real`] (prove (` !n:num->real. (!i. &1 < n(i)) ==> (!i. &0 < n(i)) `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x`])) THEN specialize [`n:num->real`] (prove (` !n:num->real. (!i. &1 < n(i)) ==> (!i. &0 < ln(n(i))) `, MESON_TAC [ln_gt1])) THEN specialize [`n:num->real`; `b:num->real`; `Y0:real`; `bno1:num->real`] asymp1_linearinfinity THEN specialize [`n:num->real`; `b:num->real`; `Y0:real`; `bno1:num->real`] asymp1_lnbb THEN specialize [`b:num->real`] asymp1_delta_lemma4 THEN specialize [`n:num->real`; `ln(&2 * pi * exp(&1))`] asymp1_delta_lemma5 THEN specialize [`n:num->real`; `b:num->real`; `Y0:real`; `bno1:num->real`] asymp1_delta_lemma20 THEN specialize [`n:num->real`] lnovero1 THEN specialize [`\i:num. &2 * (b(i) - &1) * ln (bkzdelta (b i)) - ln (b i) + ln (&2 * pi * exp (&1))`; `\i:num. &1 / ln(n(i))`] o1_seq_mul THEN specialize [`\i:num. ln (b i) / ln (n i) - &1`; `\i:num. ln (&2 * pi * exp (&1)) / ln (n i)`] o1_seq_sub THEN specialize [`\i:num. (&2 * (b i - &1) * ln (bkzdelta (b i)) - ln (b i) + ln (&2 * pi * exp (&1))) * &1 / ln (n i)`; `\i:num. ln (b i) / ln (n i) - &1 - ln (&2 * pi * exp (&1)) / ln (n i)`] o1_seq_add THEN ASM_MESON_TAC [asymp1_delta_lemma21]);; let asymp1_b1n_lemma = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. b(i)/n(i) = Y0 + bno1(i)) ==> (\i. (b(i) - &1) / n(i) - Y0) = (\i. bno1(i) - &1 / n(i)) `, MESON_TAC [EQ_EXT; REAL_FIELD `&1 < x /\ y/x = c+d ==> (y - &1)/x - c = d - &1 / x`]);; let asymp1_b1n = prove(` !n:num->real b:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. (b(i) - &1)/n(i) - Y0) `, REPEAT STRIP_TAC THEN specialize [`bno1:num->real`; `\i:num. &1 / n(i)`] o1_seq_sub THEN ASM_MESON_TAC [asymp1_b1n_lemma]);; let asymp1_nkb1_lemma = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real o1:num->real. (!i. &1 < n(i)) /\ (!i. k(i)/n(i) = X0 + kno1(i)) /\ ~(Y0 = &0) /\ (!i. ((&1 + X0) + kno1(i)) / (Y0 + (b(i) - &1) / n(i) - Y0) = (&1 + X0) / Y0 + o1(i)) ==> !i. o1(i) = (n(i) + k(i)) / (b(i) - &1) - (&1 + X0) / Y0 `, REWRITE_TAC [REAL_ARITH `Y0 + x - Y0 = x`] THEN MESON_TAC [REAL_FIELD `~(Y0 = &0) /\ &1 < n /\ k/n = X0 + d /\ ((&1 + X0) + d) / ((b - &1)/n) = (&1 + X0) / Y0 + e ==> e = (n + k) / (b - &1) - (&1 + X0) / Y0`]);; let asymp1_nkb1_lemma2 = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real o1:num->real. (!i. &1 < n(i)) /\ (!i. k(i)/n(i) = X0 + kno1(i)) /\ ~(Y0 = &0) /\ (!i. ((&1 + X0) + kno1(i)) / (Y0 + (b(i) - &1) / n(i) - Y0) = (&1 + X0) / Y0 + o1(i)) ==> o1 = \i. (n(i) + k(i)) / (b(i) - &1) - (&1 + X0) / Y0 `, MESON_TAC [BETA_THM; EQ_EXT; asymp1_nkb1_lemma]);; let asymp1_nkb1 = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. (n(i) + k(i))/(b(i) - &1) - (&1 + X0)/Y0) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `b:num->real`; `Y0:real`; `bno1:num->real`] asymp1_b1n THEN specialize [] (REAL_ARITH `&0 < Y0 ==> ~(Y0 = &0)`) THEN choose_specializing `o1:num->real` [`&1 + X0`; `kno1:num->real`; `Y0:real`; `\i:num. (b(i) - &1)/n(i) - Y0`] o1_seq_offset_div THEN ASM_MESON_TAC [asymp1_nkb1_lemma2]);; let o1_seq_neg = prove(` !o1:num->real. o1_seq o1 ==> o1_seq (\i. -- o1(i)) `, REWRITE_TAC [o1_seq] THEN REWRITE_TAC [REAL_ABS_NEG]);; let asymp1_nkb1_neg = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq (\i. (&1 + X0)/Y0 - (n(i) + k(i))/(b(i) - &1)) `, REWRITE_TAC [REAL_ARITH `(&1 + a)/b - c/d = --(c/d - (&1 + a)/b)`] THEN REPEAT STRIP_TAC THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `kno1:num->real`; `Y0:real`; `bno1:num->real`] asymp1_nkb1 THEN specialize [`\i:num. (n(i) + k(i))/(b(i) - &1) - (&1 + X0)/Y0`] o1_seq_neg THEN ASM_MESON_TAC []);; let asymp1_rho_lemma1 = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real o1:num->real. (!i. &1 < b(i)) /\ (!i. ( (&2 - (&1 + X0)/Y0) + ((&1 + X0)/Y0 - (n(i) + k(i))/(b(i) - &1)) ) * ( &1 + (&2 * (b(i) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - &1) ) = (&2 - (&1 + X0) / Y0) * &1 + o1(i) ) ==> !i. &2 * (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - (&2 - (&1 + X0) / Y0) = o1(i) `, REWRITE_TAC [REAL_ARITH `(&2 - c) + (c - x) = &2 - x`] THEN REWRITE_TAC [REAL_ARITH `&1 + (c - &1) = c`] THEN MESON_TAC [REAL_FIELD `&1 < b ==> (&2 - (n + k)/(b - &1)) * &2 * (b - &1) * c / d = &2 * (&2 * b - (n + k + &1) - &1) * c / d`; REAL_ARITH `a = b * &1 + c ==> a - b = c`]);; let asymp1_rho_lemma2 = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real o1:num->real. (!i. &1 < b(i)) /\ (!i. ( (&2 - (&1 + X0)/Y0) + ((&1 + X0)/Y0 - (n(i) + k(i))/(b(i) - &1)) ) * ( &1 + (&2 * (b(i) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - &1) ) = (&2 - (&1 + X0) / Y0) * &1 + o1(i) ) ==> o1 = \i. &2 * (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - (&2 - (&1 + X0) / Y0) `, MESON_TAC [asymp1_rho_lemma1; BETA_THM; EQ_EXT]);; let asymp1_rho_lemma3 = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq \i. &2 * (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - (&2 - (&1 + X0) / Y0) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `b:num->real`; `Y0:real`; `bno1:num->real`] asymp1_delta THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `kno1:num->real`; `Y0:real`; `bno1:num->real`] asymp1_nkb1_neg THEN choose_specializing `o1:num->real` [`&2 - (&1 + X0)/Y0`; `\i:num. (&1 + X0) / Y0 - (n i + k i) / (b i - &1)`; `&1`; `\i:num. &2 * (b i - &1) * ln (bkzdelta (b i)) / ln (n i) - &1`] o1_seq_offset_mul THEN ASM_MESON_TAC [asymp1_rho_lemma2]);; let asymp1_rho_lemma4 = prove(` !n:num->real k:num->real b:num->real X0:real kno1:num->real Y0:real bno1:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq kno1 /\ (!i. k(i) / n(i) = X0 + kno1(i)) /\ o1_seq bno1 /\ (!i. b(i) / n(i) = Y0 + bno1(i)) ==> o1_seq \i. (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - (&1 - (&1 + X0) / (&2 * Y0)) `, ONCE_REWRITE_TAC [REAL_FIELD `a * b / c - (&1 - d / (&2 * e)) = (&1 / &2) * (&2 * a * b / c - (&2 - d / e))`] THEN REPEAT STRIP_TAC THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `kno1:num->real`; `Y0:real`; `bno1:num->real`] asymp1_rho_lemma3 THEN specialize [`\i:num. &2 * (&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) - (&2 - (&1 + X0) / Y0)`; `&1 / &2`] o1_seq_consttimes THEN ASM_MESON_TAC []);; let asymp1_rho_lemma5 = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < Y0 /\ o1_seq (\i. k(i) / n(i) - X0) /\ o1_seq (\i. b(i) / n(i) - Y0) ==> o1_seq \i. (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) - (&1 - (&1 + X0) / (&2 * Y0)) `, REPEAT STRIP_TAC THEN specialize [] (REAL_ARITH `!i. k(i) / n(i) = X0 + (\i:num. k(i) / n(i) - X0)(i)`) THEN specialize [] (REAL_ARITH `!i. b(i) / n(i) = Y0 + (\i:num. b(i) / n(i) - Y0)(i)`) THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `\i:num. k(i) / n(i) - X0`; `Y0:real`; `\i:num. b(i) / n(i) - Y0`] asymp1_rho_lemma4 THEN ASM_SIMP_TAC []);; let asymp1_kqdn_lemma = prove(` !n:num->real q:num->real k:num->real Q0:real X0:real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) ==> (\i. (k(i) / (n(i) + k(i) + &1)) * ln(q(i))/ln(n(i)) - (X0 / (&1 + X0)) * Q0) = (\i. k(i) / (n(i) + k(i) + &1) * log2(q(i))/log2(n(i)) - X0 / (&1 + X0) * Q0) `, REWRITE_TAC [log2ratio_lnratio] THEN MESON_TAC []);; let asymp1_kqdn = prove(` !n:num->real q:num->real k:num->real Q0:real X0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &1 < q(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ (!i. &0 < k(i)) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) ==> o1_seq (\i. (k(i) / (n(i) + k(i) + &1)) * ln(q(i))/ln(n(i)) - (X0 / (&1 + X0)) * Q0) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `k:num->real`; `X0:real`] asymp1_kd THEN specialize [`\i:num. k(i) / (n(i) + k(i) + &1)`; `X0 / (&1 + X0)`; `\i:num. log2(q(i))/log2(n(i))`; `Q0:real`] o1_seq_offset_mul2 THEN ASM_MESON_TAC [asymp1_kqdn_lemma]);; let asymp1_rho_lemma6 = prove(` !n:num->real q:num->real k:num->real b:num->real Q0:real X0:real Y0:real. (\i. (&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) - (&1 - (&1 + X0) / (&2 * Y0)) + k i / (n i + k i + &1) * ln (q i) / ln (n i) - X0 / (&1 + X0) * Q0) = (\i. ((&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) + k i / (n i + k i + &1) * ln (q i) / ln (n i)) - (&1 - (&1 + X0) / (&2 * Y0) + X0 / (&1 + X0) * Q0)) `, MESON_TAC [EQ_EXT; REAL_ARITH `(a-b)+c-d = (a+c)-(b+d)`]);; let asymp1_rho_lemma7 = prove(` !n:num->real q:num->real k:num->real b:num->real Q0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) ==> o1_seq \i. ( (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i)) ) - ( (&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0 ) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `q:num->real`; `k:num->real`; `Q0:real`; `X0:real`] asymp1_kqdn THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `Y0:real`] asymp1_rho_lemma5 THEN specialize [`\i:num. (&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) - (&1 - (&1 + X0) / (&2 * Y0))`; `\i:num. k i / (n i + k i + &1) * ln (q i) / ln (n i) - X0 / (&1 + X0) * Q0`] o1_seq_add THEN ASM_MESON_TAC [asymp1_rho_lemma6]);; let o1_seq_timesconvergent_lemma = prove(` !x:real y:real e:real c:real. abs(x - c) <= &1 /\ abs(y) <= e / (&1 + abs(c)) ==> abs(x * y) <= e `, REWRITE_TAC [REAL_ABS_MUL] THEN MESON_TAC [REAL_ABS_TRIANGLE; REAL_ARITH `abs((x-c)+c) = abs(x)`; REAL_ARITH `abs(x-c) <= &1 ==> abs(x-c)+abs(c) <= &1+abs(c)`; REAL_LE_TRANS; REAL_ABS_POS; REAL_FIELD `(&1 + abs(c)) * (e / (&1 + abs(c))) = e`; REAL_LE_MUL2]);; let o1_seq_timesconvergent = prove(` !f:num->real c:real g:num->real. o1_seq (\i. f(i) - c) /\ o1_seq g ==> o1_seq (\i. f(i)*g(i)) `, REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN specialize [] (REAL_ARITH `&0 < &1`) THEN specialize [] (REAL_ARITH `&0 < &1 + abs(c)`) THEN specialize [`e:real`; `&1 + abs(c)`] REAL_LT_DIV THEN X_CHOOSE_TAC `A:num` (UNDISCH_ALL (MESON [] `&0 < &1 ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (f(i) - c) <= e)) ==> (?m:num. !i. m <= i ==> abs (f(i) - c) <= &1)`)) THEN X_CHOOSE_TAC `B:num` (UNDISCH_ALL (MESON [] `&0 < e / (&1 + abs(c)) ==> (!e. &0 < e ==> (?m:num. !i. m <= i ==> abs (g(i)) <= e)) ==> (?m:num. !i. m <= i ==> abs (g(i)) <= e / (&1 + abs(c)))`)) THEN EXISTS_TAC `MAX A B` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [o1_seq_timesconvergent_lemma]);; let o1_seq_compose_ln = prove(` !f:num->real c. &0 < c /\ o1_seq (\i. f(i) - c) ==> o1_seq (\i. ln(f(i)) - ln(c)) `, REPEAT STRIP_TAC THEN specialize [`c:real`] ln_continuous THEN specialize [`f:num->real`; `ln`; `c:real`] o1_seq_compose_offset THEN ASM_SIMP_TAC []);; let o1_seq_compose_log2 = prove(` !f:num->real c. &0 < c /\ o1_seq (\i. f(i) - c) ==> o1_seq (\i. log2(f(i)) - log2(c)) `, REPEAT STRIP_TAC THEN specialize [`c:real`] log2_continuous THEN specialize [`f:num->real`; `log2`; `c:real`] o1_seq_compose_offset THEN ASM_SIMP_TAC []);; let o1_seq_timesconvergent_ln = prove(` !f:num->real c:real g:num->real. o1_seq (\i. f(i) - c) /\ &0 < c /\ o1_seq g ==> o1_seq (\i. ln(f(i))*g(i)) `, REPEAT STRIP_TAC THEN specialize [`f:num->real`; `c:real`] o1_seq_compose_ln THEN specialize [`\i:num. ln(f(i))`; `ln(c)`; `g:num->real`] o1_seq_timesconvergent THEN ASM_SIMP_TAC []);; let asymp0_db = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. k(i) / n(i) - X0) /\ o1_seq (\i. b(i) / n(i) - Y0) /\ &0 <= X0 /\ &0 < Y0 ==> o1_seq (\i. ln((n(i) + k(i) + &1) / b(i))/ln(n(i))) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_FIELD `ln(x)/ln(y) = ln(x) * (&1 / ln(y))`] THEN specialize [] (REAL_ARITH `&0 < Y0 ==> ~(Y0 = &0)`) THEN specialize [] (REAL_ARITH `&0 <= X0 ==> &0 < &1 + X0`) THEN specialize [`&1 + X0`; `Y0:real`] REAL_LT_DIV THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `Y0:real`] asymp1_db THEN specialize [`n:num->real`] lnovero1 THEN specialize [`\i:num. (n(i)+k(i) + &1)/b(i)`; `(&1 + X0) / Y0`; `\i:num. &1 / ln(n(i))`] o1_seq_timesconvergent_ln THEN ASM_SIMP_TAC []);; let asymp0_db_half = prove(` !n:num->real k:num->real b:num->real X0:real Y0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. k(i) / n(i) - X0) /\ o1_seq (\i. b(i) / n(i) - Y0) /\ &0 <= X0 /\ &0 < Y0 ==> o1_seq (\i. (&1 / &2) * ln((n(i) + k(i) + &1) / b(i))/ln(n(i))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `Y0:real`] asymp0_db THEN specialize [`\i:num. ln((n(i) + k(i) + &1) / b(i))/ln(n(i))`; `&1 / &2`] o1_seq_consttimes THEN ASM_SIMP_TAC []);; let asymp1_rho_lemma8 = prove(` !n:num->real q:num->real k:num->real b:num->real Q0:real X0:real Y0:real. (\i. (&1 / &2) * ln ((n i + k i + &1) / b i) / ln (n i) + ((&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) + k i / (n i + k i + &1) * ln (q i) / ln (n i)) - (&1 - (&1 + X0) / (&2 * Y0) + X0 / (&1 + X0) * Q0)) = (\i. ((&1 / &2) * ln ((n i + k i + &1) / b i) / ln (n i) + (&2 * b i - (n i + k i + &1) - &1) * ln (bkzdelta (b i)) / ln (n i) + k i / (n i + k i + &1) * ln (q i) / ln (n i)) - (&1 - (&1 + X0) / (&2 * Y0) + X0 / (&1 + X0) * Q0)) `, MESON_TAC [EQ_EXT; REAL_ARITH `a + (b - c) = (a + b) - c`]);; let asymp1_rho_lemma9 = prove(` !n:num->real q:num->real k:num->real b:num->real Q0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) ==> o1_seq \i. ( (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) / ln(n(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i)) ) - ( (&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0 ) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `q:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `X0:real`; `Y0:real`] asymp1_rho_lemma7 THEN specialize [`n:num->real`; `k:num->real`; `b:num->real`; `X0:real`; `Y0:real`] asymp0_db_half THEN specialize [`\i:num. (&1 / &2) * ln((n(i) + k(i) + &1) / b(i))/ln(n(i))`; `\i:num. ( (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i))) - ( (&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0)`] o1_seq_add THEN ASM_MESON_TAC [asymp1_rho_lemma8]);; let asymp1_rho_lemma10 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) ==> o1_seq \i. ( (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i)) - ( (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) / ln(n(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i)) ) ) - ( (&1 / &2 + S0) - ( (&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0 ) ) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `q:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `X0:real`; `Y0:real`] asymp1_rho_lemma9 THEN specialize [`n:num->real`; `s:num->real`; `k:num->real`; `S0:real`; `X0:real`] asymp1_nkss_2 THEN specialize [`\i:num. (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i))`; `&1 / &2 + S0`; `\i:num. (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) / ln(n(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i))`; `(&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0`] o1_seq_sub_offset THEN ASM_SIMP_TAC []);; let asymp1_rho_lemma11 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) ==> (\i. ( (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) - ( (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) ) ) / ln(n(i)) - ( S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 ) ) = (\i. ( (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) / ln(n(i)) - ( (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) / ln(n(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) / ln(n(i)) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) / ln(n(i)) ) ) - ( (&1 / &2 + S0) - ( (&1 - (&1 + X0) / (&2 * Y0)) + (X0 / (&1 + X0)) * Q0 ) ) ) `, MESON_TAC [EQ_EXT; ln_gt1; REAL_FIELD `&0 < a ==> C*c/a - (D*d/a + E*e/a + G*g/a) = (C*c - (D*d + E*e + G*g))/a`; REAL_ARITH `(&1 / &2 + S) - ((&1 - a) + b) = S - &1 / &2 + a - b`]);; let asymp1_rho = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) ==> o1_seq \i. ( (&1 / &2) * ln((n(i)+k(i))*(s(i) pow 2) + &1) - ( (&1 / &2) * ln((n(i) + k(i) + &1) / b(i)) + (&2 * b(i) - (n(i) + k(i) + &1) - &1) * ln(bkzdelta(b(i))) + (k(i) / (n(i) + k(i) + &1)) * ln(q(i)) ) ) / ln(n(i)) - ( S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 ) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `S0:real`; `X0:real`; `Y0:real`] asymp1_rho_lemma10 THEN ASM_MESON_TAC [asymp1_rho_lemma11]);; let asymp1_standardratio = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) ==> o1_seq \i. ln(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / ln(n(i)) - ( S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 ) `, REWRITE_TAC [standardratio_ln2] THEN SIMP_TAC [asymp1_rho]);; let standardratio_below_lemma1 = prove(` !X0 Y0 D. &0 <= X0 /\ &0 < D /\ (&1 + X0) / D < Y0 ==> (&1 + X0) / Y0 < D `, MESON_TAC [REAL_ARITH `&0 <= X0 ==> &0 < &1 + X0`; REAL_LT_TRANS; REAL_LT_DIV; divltflip]);; let standardratio_below_lemma2 = prove(` !Q0 S0 X0 Y0. &0 <= X0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) < Y0 ==> S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 < &0 `, MESON_TAC [standardratio_below_lemma1; REAL_FIELD `(&1 + X0) / Y0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) ==> S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 < &0`]);; let standardratio_below_lemma1_alt = prove(` !X0 Y0 D. &0 < &1 + X0 /\ &0 < D /\ (&1 + X0) / D < Y0 ==> (&1 + X0) / Y0 < D `, MESON_TAC [REAL_LT_TRANS; REAL_LT_DIV; divltflip]);; let standardratio_below_lemma2_alt = prove(` !Q0 S0 X0 Y0. &0 < &1 + X0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) < Y0 ==> S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 < &0 `, MESON_TAC [standardratio_below_lemma1_alt; REAL_FIELD `(&1 + X0) / Y0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) ==> S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 < &0`]);; let standardratio_below_lemma3 = prove(` !x y. &1 < y /\ ln(x) / ln(y) < &0 ==> x < &1 `, MESON_TAC [ln_gt1; ln_ge1; REAL_LT_IMP_LE; REAL_LE_DIV; REAL_NOT_LT]);; let standardratio_below = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) < Y0 ==> ?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) < &1 `, REPEAT STRIP_TAC THEN specialize [`Q0:real`; `S0:real`; `X0:real`; `Y0:real`] standardratio_below_lemma2 THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `S0:real`; `X0:real`; `Y0:real`] asymp1_standardratio THEN specialize [`\i:num. ln (standardratio (n i) (q i) (s i) (k i) (b i)) / ln (n i)`; `S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - X0 / (&1 + X0) * Q0`] negative_limit_is_eventually_negative THEN ASM_MESON_TAC [standardratio_below_lemma3]);; let standardratio_above_lemma2 = prove(` !Q0 S0 X0 Y0. &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Y0 < (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> &0 < S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 `, MESON_TAC [ltdivflip; REAL_FIELD `&1 - &2*S0 + &2*Q0*X0/(&1 + X0) < (&1 + X0) / Y0 ==> &0 < S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0`]);; let standardratio_above_lemma3 = prove(` !x y. &0 < x /\ &1 < y /\ &0 < ln(x) / ln(y) ==> &1 < x `, REPEAT STRIP_TAC THEN specialize [`y:real`] ln_gt1 THEN specialize [`(ln x)/ln y`; `ln y`] REAL_LT_MUL THEN specialize [] (REAL_ARITH `&0 < ln y ==> ~(ln y = &0)`) THEN specialize [`ln x`; `ln y`] REAL_DIV_RMUL THEN ASM_MESON_TAC [REAL_NOT_LT; ln_le1]);; let standardratio_above = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real S0:real X0:real Y0:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. log2(q(i))/log2(n(i)) - Q0) /\ &0 < &1 + &2*S0 /\ o1_seq (\i. log2(s(i))/log2(n(i)) - S0) /\ &0 <= X0 /\ o1_seq (\i. k(i)/n(i) - X0) /\ &0 < Y0 /\ o1_seq (\i. b(i)/n(i) - Y0) /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Y0 < (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> ?m. !i. m <= i ==> &1 < standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) `, REPEAT STRIP_TAC THEN specialize [`Q0:real`; `S0:real`; `X0:real`; `Y0:real`] standardratio_above_lemma2 THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `S0:real`; `X0:real`; `Y0:real`] asymp1_standardratio THEN specialize [`\i:num. ln (standardratio (n i) (q i) (s i) (k i) (b i)) / ln (n i)`; `S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - X0 / (&1 + X0) * Q0`] positive_limit_is_eventually_positive THEN ASM_MESON_TAC [standardratio_above_lemma3; standardratio_positive]);; let asymp1_const = prove(` !n:num->real c:real. o1_seq (\i. (c) - (c)) `, REWRITE_TAC [REAL_ARITH `c-c = &0`; REAL_ARITH `&0 * x = &0`] THEN MESON_TAC [o1_seq_0]);; let asymp1_add = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. ((A(i))+(B(i))) - ((A0)+(B0))) `, MESON_TAC [o1_seq_add_offset]);; let asymp1_sub = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. ((A(i))-(B(i))) - ((A0)-(B0))) `, MESON_TAC [o1_seq_sub_offset]);; let asymp1_mul = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. ((A(i))*(B(i))) - ((A0)*(B0))) `, MESON_TAC [o1_seq_offset_mul2]);; let asymp1_div = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. ~(B0 = &0) /\ o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. ((A(i))/(B(i))) - ((A0)*((&1)/(B0)))) `, REWRITE_TAC [REAL_FIELD `a * (&1 / b) = a / b`] THEN MESON_TAC [o1_seq_offset_div2]);; let asymp1_logn = prove(` !n:num->real A:num->real A0:real. &0 < A0 /\ (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (A(i)) - (A0)) ==> o1_seq (\i. (log2(A(i))/log2(n(i))) - (&0)) `, REWRITE_TAC [log2ratio_lnratio] THEN REPEAT STRIP_TAC THEN ONCE_REWRITE_TAC [REAL_FIELD `x / y - &0 = x * (&1 / y)`] THEN specialize [`n:num->real`] lnovero1 THEN specialize [`\i:num. A(i):real`; `A0:real`; `\i:num. &1 / ln(n(i))`] o1_seq_timesconvergent_ln THEN ASM_MESON_TAC []);; let a_times_n_powreal_b = prove(` !a:real n:real b:real. &0 < a /\ &1 < n ==> a*(n powreal b) = n powreal(ln(a)/ln(n)+b) `, REWRITE_TAC [powreal] THEN REPEAT STRIP_TAC THEN specialize [`n:real`] ln_gt1 THEN REWRITE_TAC [REAL_ADD_RDISTRIB] THEN REWRITE_TAC [REAL_EXP_ADD] THEN specialize [] (REAL_FIELD `&0 < ln n ==> ln a / ln n * ln n = ln a`) THEN ASM_MESON_TAC [EXP_LN]);; let asymp1_logn1plusAtimesntotheB_lemma = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. (!i. &0 < A(i)) /\ (!i. &1 < n(i)) ==> (\i. (ln(&1+(A(i))*(n(i))powreal(B(i)))/ln(n(i))) - (B0)) = (\i. ln(n(i) powreal(B0 + ((ln(A(i))/ln(n(i))+B(i)) - B0)) + &1)/ln(n(i)) - B0) `, REWRITE_TAC [REAL_ARITH `y + (a - y) = a`] THEN REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN ASM_MESON_TAC [a_times_n_powreal_b; REAL_ARITH `&1 + x = x + &1`]);; let asymp1_logn1plusAtimesntotheB_lemma2 = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. (ln(A(i))/ln(n(i)) + B(i)) - B0) `, REWRITE_TAC [GSYM log2ratio_lnratio] THEN REPEAT STRIP_TAC THEN specialize [`n:num->real`; `A:num->real`; `A0:real`] asymp1_logn THEN specialize [`n:num->real`; `\i:num. log2(A(i))/log2(n(i))`; `&0`; `B:num->real`; `B0:real`] asymp1_add THEN ASM_MESON_TAC [REAL_ARITH `&0 + B0 = B0`]);; let asymp1_logn1plusAtimesntotheB = prove(` !n:num->real A:num->real A0:real B:num->real B0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ &0 < B0 /\ (!i. &0 < A(i)) /\ o1_seq (\i. (A(i)) - (A0)) /\ o1_seq (\i. (B(i)) - (B0)) ==> o1_seq (\i. (log2(&1+(A(i))*(n(i))powreal(B(i)))/log2(n(i))) - (B0)) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `B:num->real`; `B0:real`] asymp1_logn1plusAtimesntotheB_lemma2 THEN specialize [`n:num->real`; `\i:num. (ln(A(i))/ln(n(i))+B(i)) - B0`; `B0:real`] o1_ln1plus THEN REWRITE_TAC [log2ratio_lnratio] THEN ASM_MESON_TAC [asymp1_logn1plusAtimesntotheB_lemma]);; let asymp2_const = prove(` !n:num->real c:real. o1_seq (\i. (c - c) * log2(n(i)) - &0) `, REWRITE_TAC [REAL_ARITH `c-c = &0`; REAL_ARITH `&0 * x = &0`; REAL_ARITH `&0 - &0 = &0`] THEN MESON_TAC [o1_seq_0]);; let asymp2_add = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. ((((A(i))+(B(i))) - ((A0)+(B0))) * log2(n(i))) - ((A1)+(B1))) `, REWRITE_TAC [REAL_FIELD `((a+b)-(a0+b0))*L-(a1+b1) = ((a-a0)*L-a1)+((b-b0)*L-b1)`] THEN REPEAT STRIP_TAC THEN specialize [`\i:num. (((A(i)) - (A0)) * log2(n(i))) - (A1)`; `\i:num. (((B(i)) - (B0)) * log2(n(i))) - (B1)`] o1_seq_add THEN ASM_MESON_TAC []);; let asymp2_sub = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. ((((A(i))-(B(i))) - ((A0)-(B0))) * log2(n(i))) - ((A1)-(B1))) `, REWRITE_TAC [REAL_FIELD `((a-b)-(a0-b0))*L-(a1-b1) = ((a-a0)*L-a1)-((b-b0)*L-b1)`] THEN REPEAT STRIP_TAC THEN specialize [`\i:num. (((A(i)) - (A0)) * log2(n(i))) - (A1)`; `\i:num. (((B(i)) - (B0)) * log2(n(i))) - (B1)`] o1_seq_sub THEN ASM_MESON_TAC []);; let asymp2_asymp1_lemma = prove(` !n:real A:real A0:real A1:real. &1 < n ==> A - A0 = ((A - A0) * log2 (n) - A1) * &1 / log2 (n) + A1 * &1 / log2 (n) `, MESON_TAC [log2_gt1; REAL_FIELD `&0 < L ==> A - A0 = ((A - A0) * L - A1) * &1 / L + A1 * &1 / L`]);; let asymp2_asymp1_lemma2 = prove(` !n:num->real A:num->real A0:real A1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) ==> (\i. A(i) - A0) = (\i. ((A i - A0) * log2 (n i) - A1) * &1 / log2 (n i) + A1 * &1 / log2 (n i)) `, MESON_TAC [EQ_EXT; asymp2_asymp1_lemma]);; let asymp2_asymp1 = prove(` !n:num->real A:num->real A0:real A1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) ==> o1_seq (\i. A(i) - A0) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`] log2overo1 THEN specialize [`\i:num. (A i - A0) * log2 (n i) - A1`; `\i:num. &1 / log2(n i)`] o1_seq_mul THEN specialize [`\i:num. &1 / log2(n i)`; `A1:real`] o1_seq_consttimes THEN specialize [`\i:num. ((A i - A0) * log2 (n i) - A1) * &1 / log2 (n i)`; `\i:num. A1 * &1 / log2 (n i)`] o1_seq_add THEN ASM_MESON_TAC [asymp2_asymp1_lemma2]);; let asymp2_mul = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. ((((A(i))*(B(i))) - ((A0)*(B0))) * log2(n(i))) - (((A0)*(B1))+((A1)*(B0)))) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ARITH `(A(i:num) * B i - A0 * B0) * log2 (n i) - (A0 * B1 + A1 * B0) = (((A i - A0) * log2 (n i) - A1) * (B i - B0) + B0 * ((A i - A0) * log2 (n i) - A1)) + A0 * ((B i - B0) * log2 (n i) - B1) + A1 * (B i - B0)`] THEN specialize [`n:num->real`; `B:num->real`; `B0:real`; `B1:real`] asymp2_asymp1 THEN specialize [`\i:num. (A(i)-A0)*log2(n(i))-A1`; `\i:num. B(i)-B0`] o1_seq_mul THEN specialize [`\i:num. (A(i)-A0)*log2(n(i))-A1`; `B0:real`] o1_seq_consttimes THEN specialize [`\i:num. (B(i)-B0)*log2(n(i))-B1`; `A0:real`] o1_seq_consttimes THEN specialize [`\i:num. B(i)-B0`; `A1:real`] o1_seq_consttimes THEN specialize [`\i:num. ((A i - A0) * log2 (n i) - A1) * (B i - B0)`; `\i:num. B0 * ((A i - A0) * log2 (n i) - A1)`] o1_seq_add THEN specialize [`\i:num. A0 * ((B i - B0) * log2 (n i) - B1)`; `\i:num. A1 * (B i - B0)`] o1_seq_add THEN specialize [`\i:num. ((A i - A0) * log2 (n i) - A1) * (B i - B0) + B0 * ((A i - A0) * log2 (n i) - A1)`; `\i:num. A0 * ((B i - B0) * log2 (n i) - B1) + A1 * (B i - B0)`] o1_seq_add THEN ASM_SIMP_TAC []);; let asymp2_mulconst = prove(` !n:num->real A:num->real A0:real A1:real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (A(i) - A0) * log2(n(i)) - A1) ==> o1_seq (\i. (c*A(i) - c*A0) * log2(n(i)) - c*A1) `, REWRITE_TAC [REAL_ARITH `(c*A(i:num) - c*A0) * log2(n(i)) - c*A1 = c*((A(i) - A0) * log2(n(i)) - A1)`] THEN REPEAT STRIP_TAC THEN specialize [`\i:num. (A(i) - A0) * log2(n(i)) - A1`; `c:real`] o1_seq_consttimes THEN ASM_MESON_TAC []);; let asymp2_scaleto1_lemma = prove(` !n:num->real A:num->real A0:real A1:real c:real. (!i. &1 < n(i)) /\ ~(A0 = &0) ==> (\i. (&1 / A0 * A i - &1 / A0 * A0) * log2 (n i) - &1 / A0 * A1) = (\i. (A i / A0 - &1) * log2 (n i) - A1 / A0) `, REWRITE_TAC [REAL_ARITH `&1/x*y = y/x`] THEN REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN REPEAT STRIP_TAC THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [REAL_FIELD `~(x = &0) ==> x/x = &1`]);; let asymp2_scaleto1 = prove(` !n:num->real A:num->real A0:real A1:real c:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ ~(A0 = &0) /\ o1_seq (\i. (A(i) - A0) * log2(n(i)) - A1) ==> o1_seq (\i. (A(i)/A0 - &1) * log2(n(i)) - A1/A0) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `A1:real`; `&1/A0`] asymp2_mulconst THEN ASM_MESON_TAC [asymp2_scaleto1_lemma]);; let asymp2_inv = prove(` !n:num->real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ ~(B0 = &0) /\ o1_seq (\i. (B(i) - B0) * log2(n(i)) - B1) ==> o1_seq (\i. (&1/B(i) - &1/B0) * log2(n(i)) - (--(B1)/(B0*B0))) `, REPEAT STRIP_TAC THEN note `!i:num. ~(log2(n(i)) = &0)` [log2_gt1; REAL_LT_IMP_NZ] THEN specialize [`n:num->real`] log2overo1 THEN specialize [`\i:num. log2(n(i))`; `B:num->real`; `B0:real`; `B1:real`] asymp2_inv_generic THEN ASM_MESON_TAC []);; let asymp2_sqrt = prove(` !n:num->real A:num->real A0:real A1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ o1_seq (\i. (A(i) - A0) * log2(n(i)) - A1) ==> o1_seq (\i. (sqrt(A(i)) - sqrt(A0)) * log2(n(i)) - (A1/(&2*sqrt(A0)))) `, REPEAT STRIP_TAC THEN note `!i:num. ~(log2(n(i)) = &0)` [log2_gt1; REAL_LT_IMP_NZ] THEN specialize [`n:num->real`] log2overo1 THEN specialize [`\i:num. log2(n(i))`; `A:num->real`; `A0:real`; `A1:real`] asymp2_sqrt_generic THEN ASM_MESON_TAC []);; let asymp2_div_lemma = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. (\i. (((A(i) * (&1 / B(i)) - ((A0)*((&1)/(B0)))) * log2(n(i))) - (((A0)*((--(B1))/((B0)*(B0))))+((A1)*((&1)/(B0)))))) = (\i. (((A(i) / B(i) - ((A0)*((&1)/(B0)))) * log2(n(i))) - (((A0)*((--(B1))/((B0)*(B0))))+((A1)*((&1)/(B0)))))) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN STRIP_TAC THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [REAL_FIELD `A(i:num) / B(i) = A(i) * (&1 / B(i))`]);; let asymp2_div = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ ~(B0 = &0) /\ (!i. &0 < B(i)) /\ o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. (((A(i) / B(i) - ((A0)*((&1)/(B0)))) * log2(n(i))) - (((A0)*((--(B1))/((B0)*(B0))))+((A1)*((&1)/(B0)))))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `B:num->real`; `B0:real`; `B1:real`] asymp2_inv THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `A1:real`; `\i:num. &1 / B i`; `&1 / B0`; `--B1/(B0*B0)`] asymp2_mul THEN ASM_MESON_TAC [asymp2_div_lemma]);; let asymp2_logn_lemma = prove(` !n:num->real A:num->real A0:real A1:real. (!i. &1 < n(i)) ==> (\i. (((log2(A(i))/log2(n(i))) - (&0)) * log2(n(i))) - (log2(A0))) = (\i. log2(A(i)) - log2(A0)) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN STRIP_TAC THEN REWRITE_TAC [BETA_THM] THEN REWRITE_TAC [REAL_ARITH `x - &0 = x`] THEN specialize [] (MESON [] `(!i:num. &1 < n(i)) ==> &1 < n(x)`) THEN specialize [`n(x:num):real`] log2_gt1 THEN ASM_MESON_TAC [REAL_FIELD `&0 < L ==> B / L * L = B`]);; let asymp2_logn_mini = prove(` !n:num->real A:num->real A0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ o1_seq (\i. A(i) - A0) ==> o1_seq (\i. (((log2(A(i))/log2(n(i))) - (&0)) * log2(n(i))) - (log2(A0))) `, SIMP_TAC [asymp2_logn_lemma] THEN REPEAT STRIP_TAC THEN specialize [`A:num->real`; `A0:real`] o1_seq_compose_log2 THEN ASM_SIMP_TAC []);; let asymp2_logn = prove(` !n:num->real A:num->real A0:real A1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) ==> o1_seq (\i. (((log2(A(i))/log2(n(i))) - (&0)) * log2(n(i))) - (log2(A0))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `A1:real`] asymp2_asymp1 THEN specialize [`n:num->real`; `A:num->real`; `A0:real`] asymp2_logn_mini THEN ASM_SIMP_TAC []);; let ln1o1_lemma = prove(` (!i:num. &0 < (\i. &1) i) `, MESON_TAC [REAL_ARITH `&0 < &1`]);; let ln1o1_lemma2 = prove(` !o1:num->real. (\i. ln (&1 + &1 * o1(i)) / &1) = (\i. ln(&1 + o1(i))) `, REWRITE_TAC [REAL_ARITH `&1 * x = x`] THEN REWRITE_TAC [REAL_ARITH `x / &1 = x`]);; let ln1o1 = prove(` !o1:num->real. o1_seq o1 /\ (!i. &0 < o1(i)) ==> o1_seq (\i. ln(&1 + o1(i))) `, REPEAT STRIP_TAC THEN specialize [] ln1o1_lemma THEN specialize [`o1:num->real`; `\i:num. &1`] ln1xo1x THEN ASM_MESON_TAC [ln1o1_lemma2]);; let log2_1o1_lemma = prove(` !o1:num->real. (\i. (&1 / ln(&2)) * ln(&1 + o1(i))) = (\i. log2(&1 + o1(i))) `, MESON_TAC [EQ_EXT; REAL_ARITH `(&1 / ln(&2))*x = x/ln(&2)`; log2]);; let log2_1o1 = prove(` !o1:num->real. o1_seq o1 /\ (!i. &0 < o1(i)) ==> o1_seq (\i. log2(&1 + o1(i))) `, REPEAT STRIP_TAC THEN specialize [`o1:num->real`] ln1o1 THEN specialize [`\i:num. ln(&1 + o1(i))`; `&1 / ln(&2)`] o1_seq_consttimes THEN ASM_MESON_TAC [log2_1o1_lemma]);; let ngt1_imp_overngt0 = prove(` !n:num->real. (!i. &1 < n(i)) ==> (!i. &0 < &1 / n(i)) `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x`; pos_1over]);; let asymp2_logn1plusAtimesntotheB_lemma1 = prove(` !n:real A:real B:real B0:real. &1 < n /\ &0 < A ==> log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2 (&1 + n powreal (ln A / ln n + B)) `, REPEAT STRIP_TAC THEN specialize [`n:real`; `ln A / ln n + B`] powreal_positive THEN specialize [`&1 / n`; `ln A / ln n + B`] powreal_positive THEN real_linear `&0 < n powreal (ln A / ln n + B) ==> &0 < &1 + n powreal (ln A / ln n + B)` THEN real_linear `&0 < (&1 / n) powreal (ln A / ln n + B) ==> &0 < &1 + (&1 / n) powreal (ln A / ln n + B)` THEN specialize [`n powreal (ln A / ln n + B)`; `&1 + (&1 / n) powreal (ln A / ln n + B)`] (GSYM log2_mul) THEN real_linear `n powreal (ln A / ln n + B) * (&1 + (&1 / n) powreal (ln A / ln n + B)) = (&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B)` THEN specialize [] (MESON [] `n powreal (ln A / ln n + B) * (&1 + (&1 / n) powreal (ln A / ln n + B)) = (&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B) ==> log2(n powreal (ln A / ln n + B) * (&1 + (&1 / n) powreal (ln A / ln n + B))) = log2((&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B))`) THEN real_linear `&1 < n ==> &0 < n` THEN specialize [`n:real`; `ln A / ln n + B`] powreal_cancelbase THEN specialize [] (MESON [] `log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2 (n powreal (ln A / ln n + B) * (&1 + (&1 / n) powreal (ln A / ln n + B))) /\ log2(n powreal (ln A / ln n + B) * (&1 + (&1 / n) powreal (ln A / ln n + B))) = log2((&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B)) ==> log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2((&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B))`) THEN specialize [] (MESON [] `log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2((&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) + n powreal (ln A / ln n + B)) /\ (&1 / n) powreal (ln A / ln n + B) * n powreal (ln A / ln n + B) = &1 ==> log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2(&1 + n powreal (ln A / ln n + B))`) THEN ASM_MESON_TAC []);; let asymp2_logn1plusAtimesntotheB_lemma2 = prove(` !n:real A:real A0:real A1:real B:real B0:real B1:real. &1 < n /\ &0 < A /\ &0 < A0 ==> (log2 (A) - log2 A0 + (B - B0) * log2 (n) - B1) + log2 (&1 + (&1 / n) powreal ((&0 + B0) + (log2 (A) / log2 (n) + B) - (&0 + B0))) = (log2 (&1 + A * n powreal B) / log2 (n) - B0) * log2 (n) - (log2 A0 + B1) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ARITH `((&0 + B0) + (log2 A / log2 n + B) - (&0 + B0)) = log2(A) / log2(n) + B`] THEN specialize [`A:real`; `n:real`; `B:real`] a_times_n_powreal_b THEN specialize [`n:real`] log2_gt1 THEN real_cancel `&0 < log2(n) ==> (log2 (&1 + n powreal (ln A / ln n + B)) / log2 n - B0) * log2 n - (log2(A0)+B1) = log2(&1 + n powreal (ln A / ln n + B)) - B0 * log2 n - (log2(A0)+B1)` THEN real_linear `(log2 A - log2 A0 + (B - B0) * log2 n - B1) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B)) = ((log2 A + B * log2 n) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1)` THEN specialize [`n:real`; `B:real`] (GSYM powreal_log2) THEN specialize [`n:real`; `B:real`] powreal_positive THEN specialize [`n:real`; `ln A / ln n + B`] powreal_positive THEN specialize [`A:real`; `n powreal B`] (GSYM log2_mul) THEN specialize [`n:real`; `A:real`; `B:real`; `B0:real`] asymp2_logn1plusAtimesntotheB_lemma1 THEN specialize [`A:real`; `n:real`] log2ratio_lnratio THEN specialize [] (MESON [] `B * log2 n = log2(n powreal B) /\ log2 A + log2 (n powreal B) = log2 (A * n powreal B) ==> ((log2 A + B * log2 n) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1) = (log2(A * n powreal B) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1)`) THEN specialize [] (MESON [] `A * n powreal B = n powreal (ln A / ln n + B) /\ log2 A / log2 n = ln A / ln n ==> (log2(A * n powreal B) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1) = (log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B))) - B0 * log2 n - (log2 A0 + B1)`) THEN specialize [] (MESON [] `log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B)) = log2 (&1 + n powreal (ln A / ln n + B)) /\ (log2(A * n powreal B) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1) = (log2 (n powreal (ln A / ln n + B)) + log2 (&1 + (&1 / n) powreal (ln A / ln n + B))) - B0 * log2 n - (log2 A0 + B1) ==> (log2(A * n powreal B) + log2 (&1 + (&1 / n) powreal (log2 A / log2 n + B))) - B0 * log2 n - (log2 A0 + B1) = (log2 (&1 + n powreal (ln A / ln n + B))) - B0 * log2 n - (log2 A0 + B1)`) THEN specialize [] (MESON [] `A * n powreal B = n powreal (ln A / ln n + B) /\ (log2 (&1 + n powreal (ln A / ln n + B)) / log2 n - B0) * log2 n - (log2(A0)+B1) = log2(&1 + n powreal (ln A / ln n + B)) - B0 * log2 n - (log2(A0)+B1) ==> (log2 (&1 + A * n powreal B) / log2 n - B0) * log2 n - (log2 A0 + B1) = log2(&1 + n powreal (ln A / ln n + B)) - B0 * log2 n - (log2(A0)+B1)`) THEN ASM_MESON_TAC []);; let asymp2_logn1plusAtimesntotheB_lemma3 = prove(` !n:num->real A:num->real B:num->real B0:real. !i. &0 < (&1 / n i) powreal ((&0 + B0) + (log2 (A i) / log2 (n i) + B i) - (&0 + B0)) `, MESON_TAC [powreal_positive]);; let asymp2_logn1plusAtimesntotheB_lemma4 = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ (!i. &0 < A(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 ==> (\i. (log2 (A i) - log2 A0 + (B i - B0) * log2 (n i) - B1) + log2 (&1 + (&1 / n i) powreal ((&0 + B0) + (log2 (A i) / log2 (n i) + B i) - (&0 + B0)))) = (\i. (log2 (&1 + A i * n i powreal B i) / log2 (n i) - B0) * log2 (n i) - (log2 A0 + B1)) `, MESON_TAC [EQ_EXT; asymp2_logn1plusAtimesntotheB_lemma2]);; let asymp2_logn1plusAtimesntotheB_mini = prove(` !n:num->real A:num->real A0:real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ &0 < B0 /\ (!i. &0 < A(i)) /\ o1_seq (\i. A(i) - A0) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. (((log2(&1+(A(i))*(n(i))powreal(B(i)))/log2(n(i))) - (B0)) * log2(n(i))) - ((log2(A0))+(B1))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `B:num->real`; `B0:real`; `B1:real`] asymp2_asymp1 THEN specialize [`n:num->real`; `A:num->real`; `A0:real`] asymp1_logn THEN specialize [`A:num->real`; `A0:real`] o1_seq_compose_log2 THEN specialize [`n:num->real`; `\i:num. log2(A(i))/log2(n(i))`; `&0`; `B:num->real`; `B0:real`] asymp1_add THEN real_linear `&0 < B0 ==> &0 < &0 + B0` THEN specialize [`n:num->real`] ngt1_imp_overngt0 THEN specialize [`n:num->real`; `\i:num. (log2 (A i) / log2 (n i) + B i) - (&0 + B0)`; `&0 + B0`] o1_ln1plus_lemma1 THEN specialize [`n:num->real`; `A:num->real`; `B:num->real`; `B0:real`] asymp2_logn1plusAtimesntotheB_lemma3 THEN specialize [`\i:num. (&1 / n i) powreal ((&0 + B0) + (log2 (A i) / log2 (n i) + B i) - (&0 + B0))`] log2_1o1 THEN specialize [`\i:num. log2 (A i) - log2 A0`; `\i:num. (B i - B0) * log2 (n i) - B1`] o1_seq_add THEN specialize [`\i:num. log2 (A i) - log2 A0 + (B i - B0) * log2 (n i) - B1`; `\i:num. log2 (&1 + (&1 / n i) powreal ((&0 + B0) + (log2 (A i) / log2 (n i) + B i) - (&0 + B0)))`] o1_seq_add THEN ASM_MESON_TAC [asymp2_logn1plusAtimesntotheB_lemma4]);; let asymp2_logn1plusAtimesntotheB = prove(` !n:num->real A:num->real A0:real A1:real B:num->real B0:real B1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < A0 /\ &0 < B0 /\ (!i. &0 < A(i)) /\ o1_seq (\i. (((A(i)) - (A0)) * log2(n(i))) - (A1)) /\ o1_seq (\i. (((B(i)) - (B0)) * log2(n(i))) - (B1)) ==> o1_seq (\i. (((log2(&1+(A(i))*(n(i))powreal(B(i)))/log2(n(i))) - (B0)) * log2(n(i))) - ((log2(A0))+(B1))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `A1:real`] asymp2_asymp1 THEN specialize [`n:num->real`; `A:num->real`; `A0:real`; `B:num->real`; `B0:real`; `B1:real`] asymp2_logn1plusAtimesntotheB_mini THEN ASM_MESON_TAC []);; let asymp2_main = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real twopie:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. ((((&1)/(n(i))) - (&0)) * log2(n(i))) - (&0)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ o1_seq (\i:num. ((((b(i))/(n(i))) - (Y0)) * log2(n(i))) - (Y1)) /\ &0 < &2 /\ (!i:num. &0 < &2) /\ ~(&2 = &0) /\ (!i:num. &0 < (&1)+((k(i))/(n(i)))) /\ &0 < (&1)+(X0) /\ &0 < (&1)+((&2)*(S0)) /\ &0 < Y0 /\ (!i:num. &0 < (b(i))/(n(i))) /\ ~(Y0 = &0) /\ &0 < ((&1)+((X0)+(&0)))*((&1)/(Y0)) /\ &0 < (pi)*(Y0) /\ &0 < twopie /\ &0 < (&2)*((Y0)-(&0)) /\ (!i:num. &0 < (&2)*(((b(i))/(n(i)))-((&1)/(n(i))))) /\ ~((&2)*((Y0)-(&0)) = &0) /\ &0 < (&1)+((X0)+(&0)) /\ (!i:num. &0 < (&1)+(((k(i))/(n(i)))+((&1)/(n(i))))) /\ ~((&1)+((X0)+(&0)) = &0) ==> o1_seq (\i:num. ((((((&1)/(&2))*(log2(&1+((&1)+((k(i))/(n(i))))*(n(i))powreal((&1)+((&2)*(log2(s(i))/log2(n(i))))))/log2(n(i))))-((((&1)/(&2))*(log2(((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))))/log2(n(i))))+((((&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))))*(((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i)))))))+((((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))*(log2(q(i))/log2(n(i))))))) - ((((&1)*((&1)/(&2)))*((&1)+((&2)*(S0))))-((((&1)*((&1)/(&2)))*(&0))+((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))))+(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0)))))) * log2(n(i))) - (((((&1)*((&1)/(&2)))*((log2((&1)+(X0)))+((&0)+(((&2)*(S1))+((&0)*(S0))))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*((&1)+((&2)*(S0)))))-(((((&1)*((&1)/(&2)))*(log2(((&1)+((X0)+(&0)))*((&1)/(Y0)))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*(&0)))+(((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+((((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0))))))) `, REPEAT STRIP_TAC THEN specialize [`\i:num. n(i):real`; `&1:real`] asymp2_const THEN specialize [`\i:num. n(i):real`; `&2:real`] asymp2_const THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. &2:real`; `&2:real`; `&0:real`] asymp2_div THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (k(i))/(n(i)):real`; `X0:real`; `X1:real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. log2(s(i))/log2(n(i)):real`; `S0:real`; `S1:real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (&2)*(log2(s(i))/log2(n(i))):real`; `(&2)*(S0):real`; `((&2)*(S1))+((&0)*(S0)):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)+((k(i))/(n(i))):real`; `(&1)+(X0):real`; `(&0)+(X1):real`; `\i:num. (&1)+((&2)*(log2(s(i))/log2(n(i)))):real`; `(&1)+((&2)*(S0)):real`; `(&0)+(((&2)*(S1))+((&0)*(S0))):real`] asymp2_logn1plusAtimesntotheB THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)/(&2):real`; `(&1)*((&1)/(&2)):real`; `((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))):real`; `\i:num. log2(&1+((&1)+((k(i))/(n(i))))*(n(i))powreal((&1)+((&2)*(log2(s(i))/log2(n(i))))))/log2(n(i)):real`; `(&1)+((&2)*(S0)):real`; `(log2((&1)+(X0)))+((&0)+(((&2)*(S1))+((&0)*(S0)))):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (k(i))/(n(i)):real`; `X0:real`; `X1:real`; `\i:num. (&1)/(n(i)):real`; `&0:real`; `&0:real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. ((k(i))/(n(i)))+((&1)/(n(i))):real`; `(X0)+(&0):real`; `(X1)+(&0):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)+(((k(i))/(n(i)))+((&1)/(n(i)))):real`; `(&1)+((X0)+(&0)):real`; `(&0)+((X1)+(&0)):real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`] asymp2_div THEN specialize [`\i:num. n(i):real`; `\i:num. ((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))):real`; `((&1)+((X0)+(&0)))*((&1)/(Y0)):real`; `(((&1)+((X0)+(&0)))*((--(Y1))/((Y0)*(Y0))))+(((&0)+((X1)+(&0)))*((&1)/(Y0))):real`] asymp2_logn THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)/(&2):real`; `(&1)*((&1)/(&2)):real`; `((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))):real`; `\i:num. log2(((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))))/log2(n(i)):real`; `&0:real`; `log2(((&1)+((X0)+(&0)))*((&1)/(Y0))):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`] asymp2_logn THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`] asymp2_div THEN specialize [`\i:num. n(i):real`; `pi:real`] asymp2_const THEN specialize [`\i:num. n(i):real`; `\i:num. pi:real`; `pi:real`; `&0:real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (pi)*((b(i))/(n(i))):real`; `(pi)*(Y0):real`; `((pi)*(Y1))+((&0)*(Y0)):real`] asymp2_logn THEN specialize [`\i:num. n(i):real`; `\i:num. log2((pi)*((b(i))/(n(i))))/log2(n(i)):real`; `&0:real`; `log2((pi)*(Y0)):real`; `\i:num. &1:real`; `&1:real`; `&0:real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)/((b(i))/(n(i))):real`; `(&1)*((&1)/(Y0)):real`; `((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))):real`; `\i:num. (log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1):real`; `(&0)+(&1):real`; `(log2((pi)*(Y0)))+(&0):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)/(n(i)):real`; `&0:real`; `&0:real`; `\i:num. ((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1)):real`; `((&1)*((&1)/(Y0)))*((&0)+(&1)):real`; `(((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1))):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `twopie:real`] asymp2_const THEN specialize [`\i:num. n(i):real`; `\i:num. twopie:real`; `twopie:real`; `&0:real`] asymp2_logn THEN specialize [`\i:num. n(i):real`; `\i:num. ((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))):real`; `(&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))):real`; `((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))):real`; `\i:num. log2(twopie)/log2(n(i)):real`; `&0:real`; `log2(twopie):real`] asymp2_sub THEN specialize [`\i:num. n(i):real`; `\i:num. log2((b(i))/(n(i)))/log2(n(i)):real`; `&0:real`; `log2(Y0):real`; `\i:num. (((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))):real`; `((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0):real`; `(((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i)))):real`; `(&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)):real`; `(log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (&2)*((b(i))/(n(i))):real`; `(&2)*(Y0):real`; `((&2)*(Y1))+((&0)*(Y0)):real`; `\i:num. (&1)+(((k(i))/(n(i)))+((&1)/(n(i)))):real`; `(&1)+((X0)+(&0)):real`; `(&0)+((X1)+(&0)):real`] asymp2_sub THEN specialize [`\i:num. n(i):real`; `\i:num. ((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))):real`; `((&2)*(Y0))-((&1)+((X0)+(&0))):real`; `(((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))):real`; `\i:num. (&1)/(n(i)):real`; `&0:real`; `&0:real`] asymp2_sub THEN specialize [`\i:num. n(i):real`; `\i:num. (b(i))/(n(i)):real`; `Y0:real`; `Y1:real`; `\i:num. (&1)/(n(i)):real`; `&0:real`; `&0:real`] asymp2_sub THEN specialize [`\i:num. n(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. ((b(i))/(n(i)))-((&1)/(n(i))):real`; `(Y0)-(&0):real`; `(Y1)-(&0):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))):real`; `(((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0):real`; `((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0):real`; `\i:num. (&2)*(((b(i))/(n(i)))-((&1)/(n(i)))):real`; `(&2)*((Y0)-(&0)):real`; `((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0))):real`] asymp2_div THEN specialize [`\i:num. n(i):real`; `\i:num. (&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))):real`; `(&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))):real`; `(&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))):real`; `\i:num. ((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i))))):real`; `((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))):real`; `(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))):real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. (k(i))/(n(i)):real`; `X0:real`; `X1:real`; `\i:num. (&1)+(((k(i))/(n(i)))+((&1)/(n(i)))):real`; `(&1)+((X0)+(&0)):real`; `(&0)+((X1)+(&0)):real`] asymp2_div THEN specialize [`\i:num. n(i):real`; `\i:num. ((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))):real`; `(X0)*((&1)/((&1)+((X0)+(&0)))):real`; `((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))):real`; `\i:num. log2(q(i))/log2(n(i)):real`; `Q0:real`; `Q1:real`] asymp2_mul THEN specialize [`\i:num. n(i):real`; `\i:num. ((&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))))*(((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i)))))):real`; `((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))):real`; `(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))):real`; `\i:num. (((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))*(log2(q(i))/log2(n(i))):real`; `((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0):real`; `(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0)):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. ((&1)/(&2))*(log2(((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))))/log2(n(i))):real`; `((&1)*((&1)/(&2)))*(&0):real`; `(((&1)*((&1)/(&2)))*(log2(((&1)+((X0)+(&0)))*((&1)/(Y0)))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*(&0)):real`; `\i:num. (((&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))))*(((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i)))))))+((((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))*(log2(q(i))/log2(n(i)))):real`; `(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))))+(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0)):real`; `((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+((((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0))):real`] asymp2_add THEN specialize [`\i:num. n(i):real`; `\i:num. ((&1)/(&2))*(log2(&1+((&1)+((k(i))/(n(i))))*(n(i))powreal((&1)+((&2)*(log2(s(i))/log2(n(i))))))/log2(n(i))):real`; `((&1)*((&1)/(&2)))*((&1)+((&2)*(S0))):real`; `(((&1)*((&1)/(&2)))*((log2((&1)+(X0)))+((&0)+(((&2)*(S1))+((&0)*(S0))))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*((&1)+((&2)*(S0)))):real`; `\i:num. (((&1)/(&2))*(log2(((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))))/log2(n(i))))+((((&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))))*(((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i)))))))+((((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))*(log2(q(i))/log2(n(i))))):real`; `(((&1)*((&1)/(&2)))*(&0))+((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))))+(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0))):real`; `((((&1)*((&1)/(&2)))*(log2(((&1)+((X0)+(&0)))*((&1)/(Y0)))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*(&0)))+(((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+((((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0)))):real`] asymp2_sub THEN ASM_MESON_TAC []);; let asymp2_simple_lemma = prove(` !n:num->real b:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) ==> (!i. &0 < (&2)*(((b(i))/(n(i)))-((&1)/(n(i))))) `, MESON_TAC [REAL_ARITH `&1 < x ==> &0 < x - &1`; REAL_ARITH `&1 < y ==> &0 < y`; REAL_LT_DIV; REAL_FIELD `&1 < y ==> (x - &1) / y = x/y - &1 / y`; REAL_ARITH `&0 < z ==> &0 < &2 * z`]);; let asymp2_simple_lemma2 = prove(` !n:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) ==> o1_seq (\i:num. ((((&1)/(n(i))) - (&0)) * log2(n(i))) - (&0)) `, REWRITE_TAC [REAL_ARITH `(&1/x - &0)*y - &0 = y/x`] THEN REPEAT STRIP_TAC THEN real_linear `&0 < &1` THEN specialize [] (MESON [REAL_ARITH `&1 < x ==> &1 <= x`] `(!i:num. &1 < n(i)) ==> (!i. &1 <= n(i))`) THEN specialize [`n:num->real`] o1_log2overlinear_1 THEN ASM_SIMP_TAC []);; let asymp2_simple = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real twopie:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ o1_seq (\i:num. ((((b(i))/(n(i))) - (Y0)) * log2(n(i))) - (Y1)) /\ &0 < (&1)+(X0) /\ &0 < (&1)+((&2)*(S0)) /\ &0 < Y0 /\ &0 < twopie ==> o1_seq (\i:num. ((((((&1)/(&2))*(log2(&1+((&1)+((k(i))/(n(i))))*(n(i))powreal((&1)+((&2)*(log2(s(i))/log2(n(i))))))/log2(n(i))))-((((&1)/(&2))*(log2(((&1)+(((k(i))/(n(i)))+((&1)/(n(i)))))/((b(i))/(n(i))))/log2(n(i))))+((((&1)+((log2((b(i))/(n(i)))/log2(n(i)))+((((&1)/(n(i)))*(((&1)/((b(i))/(n(i))))*((log2((pi)*((b(i))/(n(i))))/log2(n(i)))+(&1))))-(log2(twopie)/log2(n(i))))))*(((((&2)*((b(i))/(n(i))))-((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))-((&1)/(n(i))))/((&2)*(((b(i))/(n(i)))-((&1)/(n(i)))))))+((((k(i))/(n(i)))/((&1)+(((k(i))/(n(i)))+((&1)/(n(i))))))*(log2(q(i))/log2(n(i))))))) - ((((&1)*((&1)/(&2)))*((&1)+((&2)*(S0))))-((((&1)*((&1)/(&2)))*(&0))+((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))))+(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0)))))) * log2(n(i))) - (((((&1)*((&1)/(&2)))*((log2((&1)+(X0)))+((&0)+(((&2)*(S1))+((&0)*(S0))))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*((&1)+((&2)*(S0)))))-(((((&1)*((&1)/(&2)))*(log2(((&1)+((X0)+(&0)))*((&1)/(Y0)))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*(&0)))+(((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+((((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0))))))) `, REPEAT STRIP_TAC THEN specialize [] PI_POS THEN specialize [`pi`; `Y0:real`] REAL_LT_MUL THEN real_linear `&0 < &1` THEN specialize [`&1`; `Y0:real`] REAL_LT_DIV THEN real_linear `&0 < &1+X0 ==> &0 < &1+(X0 + &0)` THEN real_linear `&0 < &1+X0 ==> ~(&1+(X0 + &0) = &0)` THEN specialize [`&1+(X0 + &0):real`; `&1/Y0`] REAL_LT_MUL THEN real_linear `&0 < &2` THEN ASSUME_TAC (REAL_ARITH `!i:num. &0 < &2`) THEN real_linear `~(&2 = &0)` THEN real_linear `&0 < Y0 ==> ~(Y0 = &0)` THEN real_linear `&0 < Y0 ==> &0 < (&2)*(Y0 - &0)` THEN real_linear `&0 < Y0 ==> ~((&2)*((Y0)-(&0)) = &0)` THEN specialize [] (MESON [REAL_ARITH `&1 < x ==> &0 < x`; REAL_LT_DIV] `(!i. &1 < n(i)) /\ (!i. &1 < b(i)) ==> (!i:num. &0 < (b(i))/(n(i)))`) THEN specialize [] (MESON [REAL_ARITH `&1 < x ==> &0 < x`; REAL_LT_DIV; REAL_ARITH `&0 < x ==> &0 < &1 + x`] `(!i. &1 < n(i)) /\ (!i. &0 < k(i)) ==> (!i:num. &0 < &1 + k(i)/n(i))`) THEN specialize [] (MESON [REAL_ARITH `&1 < x ==> &0 < x`; REAL_LT_DIV; REAL_LT_ADD; REAL_ARITH `&0 < &1`; REAL_ARITH `&0 < x ==> &0 < &1 + x`] `(!i. &1 < n(i)) /\ (!i. &0 < k(i)) ==> (!i:num. &0 < &1 + (k(i)/n(i) + &1/n(i)))`) THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `twopie:real`] asymp2_main THEN specialize [`n:num->real`; `b:num->real`] asymp2_simple_lemma THEN specialize [`n:num->real`] asymp2_simple_lemma2 THEN ASM_SIMP_TAC []);; let asymp2_simple2_lemma = prove(` !n b. &1 < n /\ &1 < b ==> ln (b * exp (&1 / b * ln (pi * b)) / (&2 * pi * exp (&1))) / ln n = (&1 + ln (b / n) / ln n + &1 / n * (n * &1) / b * (ln (pi * b / n) / ln n + &1) - ln (&2 * pi * exp (&1)) / ln n) `, ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> &1 / n * (n * &1) / x * y = y / x`] THEN REPEAT STRIP_TAC THEN real_linear `&1 < b ==> &0 < b` THEN specialize [`&1 / b * ln(pi*b)`] REAL_EXP_POS_LT THEN real_linear `&0 < &2` THEN specialize [] PI_POS THEN specialize [`&1`] REAL_EXP_POS_LT THEN specialize [`pi`; `exp(&1)`] REAL_LT_MUL THEN specialize [`&2`; `pi*exp(&1)`] REAL_LT_MUL THEN specialize [`exp(&1 / b * ln(pi*b))`; `&2*pi*exp(&1)`] REAL_LT_DIV THEN specialize [`b:real`; `exp(&1 / b * ln(pi*b)) / (&2*pi*exp(&1))`] LN_MUL THEN specialize [`exp(&1 / b * ln(pi*b))`; `(&2*pi*exp(&1))`] ln_div THEN specialize [`&1 / b * ln (pi * b)`] LN_EXP THEN specialize [`n:real`] ln_gt1 THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln(n) ==> (ln (b) + (&1 / b * ln (pi * b)) - ln (&2 * pi * exp (&1))) / ln n = ln (b)/ ln(n) + (ln (pi * b) / ln n) / b - ln (&2 * pi * exp (&1)) / ln n`] THEN real_linear `&1 < n ==> &0 < n` THEN REWRITE_TAC [REAL_ARITH `pi*b/n = (pi*b)/n`] THEN specialize [`pi`; `b:real`] REAL_LT_MUL THEN ASM_SIMP_TAC [ln_div] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln(n) ==> (x - ln(n))/ln(n) + &1 = x / ln(n)`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln(n) ==> &1 + (x - ln(n))/ln(n) + y = x/ln(n) + y`]);; let asymp2_simple2_standardratio = prove(` !n q s k b. &1 < n /\ &1 < b /\ &0 < s ==> ln(standardratio n q s k b)/ln(n) = &1 / &2 * log2 (&1 + (&1 + k / n) * n powreal (&1 + &2 * log2 s / log2 n)) / log2 n - (&1 / &2 * log2 ((&1 + k / n + &1 / n) / (b / n)) / log2 n + (&1 + log2 (b / n) / log2 n + &1 / n * &1 / (b / n) * (log2 (pi * b / n) / log2 n + &1) - log2 (&2 * pi * exp(&1)) / log2 n) * (&2 * b / n - (&1 + k / n + &1 / n) - &1 / n) / (&2 * (b / n - &1 / n)) + k / n / (&1 + k / n + &1 / n) * log2 q / log2 n) `, REWRITE_TAC [log2ratio_lnratio] THEN REWRITE_TAC [standardratio_ln2] THEN REWRITE_TAC [bkzdelta_ln] THEN REWRITE_TAC [powreal] THEN REPEAT STRIP_TAC THEN specialize [`n:real`] ln_gt1 THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln(n) ==> (a + b)/ln(n) = a/ln(n) + b/ln(n)`; REAL_FIELD `&0 < ln(n) ==> (a - b)/ln(n) = a/ln(n) - b/ln(n)`] THEN REWRITE_TAC [REAL_FIELD `a / b / c = a / (b * c)`] THEN REWRITE_TAC [REAL_FIELD `a/(b/n) = (n*a)/b`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> n * (&1 + k / n + &1 / n) = n + k + &1`] THEN REWRITE_TAC [REAL_FIELD `(a*b)/ln n = a*(b/ln n)`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln(n) ==> (&1 + &2 * L / ln(n)) * ln(n) = ln(n) + &2 * L`] THEN REWRITE_TAC [REAL_EXP_ADD] THEN ASM_SIMP_TAC [EXP_LN; REAL_ARITH `&1 < n ==> &0 < n`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> (&1 + k / n) * n * X = (n + k) * X`] THEN REWRITE_TAC [REAL_EXP_N] THEN ASM_SIMP_TAC [EXP_LN] THEN REWRITE_TAC [REAL_ARITH `&1 + x * y pow 2 = x * y pow 2 + &1`] THEN ASM_SIMP_TAC [REAL_ARITH `&1 < n ==> &2 * (b / n - &1 / n) = (&2 * (b - &1)) / n`] THEN REWRITE_TAC [REAL_FIELD `a/(b/n) = (n*a)/b`] THEN REWRITE_TAC [REAL_ARITH `n*(&2*b/n-(&1+k/n+ &1/n)- &1/n) = &2*(n*(b/n))-n*(&1+k/n+ &1/n) - n*(&1/n)`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> n * (&1 + k / n + &1 / n) = n + k + &1`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> n*(b/n) = b`] THEN REWRITE_TAC [REAL_ARITH `(&2 * b - (n + k + &1) - &1) * &1 / (&2 * (b - &1)) * X = X * (&2 * b - (n + k + &1) - &1) / (&2 * (b - &1))`] THEN specialize [`n:real`; `b:real`] asymp2_simple2_lemma THEN ASM_SIMP_TAC []);; let asymp2_simple2_standardratio2 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real. (!i. &1 < n(i)) /\ (!i. &1 < b(i)) /\ (!i. &0 < s(i)) ==> !i. ln(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / ln(n(i)) = &1 / &2 * log2 (&1 + (&1 + k(i) / n(i)) * n(i) powreal (&1 + &2 * log2(s(i)) / log2(n(i)))) / log2(n(i)) - (&1 / &2 * log2 ((&1 + k(i) / n(i) + &1 / n(i)) / (b(i) / n(i))) / log2(n(i)) + (&1 + log2 (b(i) / n(i)) / log2(n(i)) + &1 / n(i) * &1 / (b(i) / n(i)) * (log2 (pi * b(i) / n(i)) / log2(n(i)) + &1) - log2 (&2 * pi * exp(&1)) / log2(n(i))) * (&2 * b(i) / n(i) - (&1 + k(i) / n(i) + &1 / n(i)) - &1 / n(i)) / (&2 * (b(i) / n(i) - &1 / n(i))) + k(i) / n(i) / (&1 + k(i) / n(i) + &1 / n(i)) * log2(q(i))/ log2(n(i))) `, MESON_TAC [asymp2_simple2_standardratio]);; let asymp2_simple2 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ o1_seq (\i:num. ((((b(i))/(n(i))) - (Y0)) * log2(n(i))) - (Y1)) /\ &0 < (&1)+(X0) /\ &0 < (&1)+((&2)*(S0)) /\ &0 < Y0 ==> o1_seq (\i:num. (( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - ((((&1)*((&1)/(&2)))*((&1)+((&2)*(S0))))-((((&1)*((&1)/(&2)))*(&0))+((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0))))))+(((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q0)))))) * log2(n(i))) - (((((&1)*((&1)/(&2)))*((log2((&1)+(X0)))+((&0)+(((&2)*(S1))+((&0)*(S0))))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*((&1)+((&2)*(S0)))))-(((((&1)*((&1)/(&2)))*(log2(((&1)+((X0)+(&0)))*((&1)/(Y0)))))+((((&1)*((--(&0))/((&2)*(&2))))+((&0)*((&1)/(&2))))*(&0)))+(((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*((((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((--(((&2)*((Y1)-(&0)))+((&0)*((Y0)-(&0)))))/(((&2)*((Y0)-(&0)))*((&2)*((Y0)-(&0))))))+((((((&2)*(Y1))+((&0)*(Y0)))-((&0)+((X1)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(&2 * pi * exp(&1))))))*(((((&2)*(Y0))-((&1)+((X0)+(&0))))-(&0))*((&1)/((&2)*((Y0)-(&0)))))))+((((X0)*((&1)/((&1)+((X0)+(&0)))))*(Q1))+((((X0)*((--((&0)+((X1)+(&0))))/(((&1)+((X0)+(&0)))*((&1)+((X0)+(&0))))))+((X1)*((&1)/((&1)+((X0)+(&0))))))*(Q0))))))) `, REPEAT STRIP_TAC THEN REWRITE_TAC [log2ratio_lnratio] THEN real_linear `&0 < &2` THEN specialize [] PI_POS THEN specialize [`&1`] REAL_EXP_POS_LT THEN specialize [`pi`; `exp(&1)`] REAL_LT_MUL THEN specialize [`&2`; `pi*exp(&1)`] REAL_LT_MUL THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `&2 * pi * exp(&1)`] asymp2_simple THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`] asymp2_simple2_standardratio2 THEN ASM_SIMP_TAC []);; let asymp2_simple3_lemma = REAL_FIELD ` !Q0 S0 X0 Y0. &0 < Y0 ==> (&1 * &1 / &2) * (&1 + &2 * S0) - ((&1 * &1 / &2) * &0 + (&1 + &0 + &0 * (&1 * &1 / Y0) * (&0 + &1) - &0) * (&2 * Y0 - (&1 + X0 + &0) - &0) * &1 / (&2 * (Y0 - &0)) + (X0 * &1 / (&1 + X0 + &0)) * Q0) = S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 `;; let asymp2_simple3_lemma2 = prove(` !Q0 S0 X0 Y0 Q1 S1 X1 Y1. &0 < Y0 /\ &0 < &1 + X0 ==> (((&1 * &1 / &2) * (log2 (&1 + X0) + &0 + &2 * S1 + &0 * S0) + (&1 * -- &0 / (&2 * &2) + &0 * &1 / &2) * (&1 + &2 * S0)) - (((&1 * &1 / &2) * log2 ((&1 + X0 + &0) * (&1 / Y0)) + (&1 * -- &0 / (&2 * &2) + &0 * &1 / &2) * &0) + ((&1 + &0 + &0 * (&1 * &1 / Y0) * (&0 + &1) - &0) * ((&2 * Y0 - (&1 + X0 + &0) - &0) * --(&2 * (Y1 - &0) + &0 * (Y0 - &0)) / ((&2 * (Y0 - &0)) * &2 * (Y0 - &0)) + ((&2 * Y1 + &0 * Y0) - (&0 + X1 + &0) - &0) * &1 / (&2 * (Y0 - &0))) + (&0 + log2 Y0 + (&0 * ((&1 * &1 / Y0) * (log2 (pi * Y0) + &0) + (&1 * --Y1 / (Y0 * Y0) + &0 * &1 / Y0) * (&0 + &1)) + &0 * (&1 * &1 / Y0) * (&0 + &1)) - log2 (&2 * pi * exp (&1))) * (&2 * Y0 - (&1 + X0 + &0) - &0) * &1 / (&2 * (Y0 - &0))) + (X0 * &1 / (&1 + X0 + &0)) * Q1 + (X0 * --(&0 + X1 + &0) / ((&1 + X0 + &0) * (&1 + X0 + &0)) + X1 * &1 / (&1 + X0 + &0)) * Q0)) = S1 + (&1 / &2) * (log2(Y0) + X1/Y0 - (&1 + X0)*Y1/(Y0*Y0) - (&2 - (&1 + X0)/Y0)*(log2(Y0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0))) `, SIMP_TAC [MESON [REAL_ARITH `&1 + X0 = &1 + X0 + &0`; log2_mul; pos_1over] `&0 < Y0 /\ &0 < &1 + X0 ==> log2 ((&1 + X0 + &0) * (&1 / Y0)) = log2(&1 + X0 + &0) + log2(&1 / Y0)`] THEN REWRITE_TAC [REAL_ARITH `x - &0 = x`; REAL_ARITH `x + &0 = x`; REAL_ARITH `&0 + x = x`; REAL_ARITH `x * &0 = &0`; REAL_ARITH `&0 * x = &0`; REAL_ARITH `&0 / x = &0`; REAL_ARITH `-- &0 / x = &0`; REAL_ARITH `&1 * x = x`; REAL_ARITH `x * &1 = x`; REAL_ARITH `x + &0 - y = x - y`; REAL_ARITH `x * &1 / y = x / y`] THEN SIMP_TAC [REAL_FIELD `&0 < &1 + X0 ==> (X0 * --X1 / ((&1 + X0) * (&1 + X0)) + X1 / (&1 + X0)) = X1 / ((&1 + X0) * (&1 + X0))`] THEN SIMP_TAC [log2_1over] THEN SIMP_TAC [REAL_FIELD `!Q0 X0 Y0 Q1 S1 X1 Y1. &0 < Y0 /\ &0 < &1 + X0 ==> &1 / &2 * (log2 (&1 + X0) + &2 * S1) - (&1 / &2 * (log2 (&1 + X0) + --log2 Y0) + (((&2 * Y0 - (&1 + X0)) * --(&2 * Y1) / ((&2 * Y0) * &2 * Y0) + (&2 * Y1 - X1) / (&2 * Y0)) + (log2 Y0 - log2 (&2 * pi * exp (&1))) * (&2 * Y0 - (&1 + X0)) / (&2 * Y0)) + X0 / (&1 + X0) * Q1 + X1 / ((&1 + X0) * (&1 + X0)) * Q0) = S1 + &1 / &2 * (log2 Y0 + X1 / Y0 - (&1 + X0) * Y1 / (Y0 * Y0) - (&2 - (&1 + X0) / Y0) * (log2 Y0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0)))`]);; let asymp2_simple3 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ o1_seq (\i:num. ((((b(i))/(n(i))) - (Y0)) * log2(n(i))) - (Y1)) /\ &0 < &1 + X0 /\ &0 < &1 + &2*S0 /\ &0 < Y0 ==> o1_seq (\i:num. ( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - (S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0) ) * log2(n(i)) - (S1 + (&1 / &2) * (log2(Y0) + X1/Y0 - (&1 + X0)*Y1/(Y0*Y0) - (&2 - (&1 + X0)/Y0)*(log2(Y0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) ) `, SIMP_TAC [GSYM asymp2_simple3_lemma] THEN SIMP_TAC [GSYM asymp2_simple3_lemma2] THEN MESON_TAC [asymp2_simple2]);; let asymp2_eventually_negative = prove(` !n f c0 c1. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (f(i) - c0)*log2(n(i)) - c1) /\ c0 < &0 ==> ?m. !i. m <= i ==> f(i) < &0 `, MESON_TAC [asymp2_asymp1; negative_limit_is_eventually_negative]);; let asymp2_eventually_positive = prove(` !n f c0 c1. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (f(i) - c0)*log2(n(i)) - c1) /\ &0 < c0 ==> ?m. !i. m <= i ==> &0 < f(i) `, MESON_TAC [asymp2_asymp1; positive_limit_is_eventually_positive]);; let asymp2_eventually_negative2_lemma = prove(` !n x. &1 < n /\ x*log2(n) < &0 ==> x < &0 `, MESON_TAC [log2_gt1; REAL_LT_DIV2_EQ; REAL_ARITH `&0 / L = &0`; REAL_FIELD `&0 < L ==> (x*L)/L = x`]);; let asymp2_eventually_negative2 = prove(` !n f c1. (!i. &1 < n(i)) /\ o1_seq (\i. (f(i) - &0)*log2(n(i)) - c1) /\ c1 < &0 ==> ?m. !i. m <= i ==> f(i) < &0 `, REWRITE_TAC [REAL_ARITH `x - &0 = x`] THEN REPEAT STRIP_TAC THEN specialize [`\i:num. f(i)*log2(n(i))`; `c1:real`] negative_limit_is_eventually_negative THEN ASM_MESON_TAC [asymp2_eventually_negative2_lemma]);; let asymp2_eventually_positive2_lemma = prove(` !n x. &1 < n /\ &0 < x*log2(n) ==> &0 < x `, MESON_TAC [log2_gt1; REAL_LT_DIV2_EQ; REAL_ARITH `&0 / L = &0`; REAL_FIELD `&0 < L ==> (x*L)/L = x`]);; let asymp2_eventually_positive2 = prove(` !n f c1. (!i. &1 < n(i)) /\ o1_seq (\i. (f(i) - &0)*log2(n(i)) - c1) /\ &0 < c1 ==> ?m. !i. m <= i ==> &0 < f(i) `, REWRITE_TAC [REAL_ARITH `x - &0 = x`] THEN REPEAT STRIP_TAC THEN specialize [`\i:num. f(i)*log2(n(i))`; `c1:real`] positive_limit_is_eventually_positive THEN ASM_MESON_TAC [asymp2_eventually_positive2_lemma]);; let asymp2_abovebelow_lemma1 = prove(` !Q0 S0 X0 Y0 Z0. &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Y0 = Z0 /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> &0 = S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0 `, MESON_TAC [eqdivflip; REAL_FIELD `&1 - &2*S0 + &2*Q0*X0/(&1 + X0) = (&1 + X0) / Y0 ==> &0 = S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0`]);; let asymp2_abovebelow_lemma2 = prove(` !Q0 Q1 S0 S1 X0 X1 Y0 Y1 Z0 Z1. &0 < &1 + X0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z1 = ((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0)) / (&1 + X0) /\ Y0 = Z0 ==> (S1 + (&1 / &2) * (log2(Y0) + X1/Y0 - (&1 + X0)*Y1/(Y0*Y0) - (&2 - (&1 + X0)/Y0)*(log2(Y0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) = (&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0) `, REPEAT STRIP_TAC THEN specialize [`&1 + X0`; `&1 - &2*S0 + &2*Q0*X0/(&1 + X0)`] REAL_LT_DIV THEN real_linear `&0 < (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> &0 < Z0` THEN real_linear `&0 < &2` THEN specialize [`Z0:real`; `Z0:real`] REAL_LT_MUL THEN specialize [`&2`; `Z0*Z0:real`] REAL_LT_MUL THEN specialize_forward [`Z1:real`; `((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0))`; `&1+X0`] REAL_EQ_RDIV_EQ THEN specialize_reverse [`Z1*(&1+X0)`; `S1 + &1 / &2 * (log2 Z0 + X1 / Z0 - (&2 - (&1 + X0) / Z0) * (log2 Z0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0)))`; `&2 * Z0 * Z0`] REAL_EQ_LDIV_EQ THEN real_cancel `&0 < Z0 ==> (&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0) = (Z1 * (&1 + X0)) / (&2 * Z0 * Z0) - (&1 + X0)*Y1 / (&2 *Z0 * Z0)` THEN real_cancel `S1 + &1 / &2 * (log2 Z0 + X1 / Z0 - (&1 + X0) * Y1 / (Z0 * Z0) - (&2 - (&1 + X0) / Z0) * (log2 Z0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0))) = (S1 + &1 / &2 * (log2 Z0 + X1 / Z0 - (&2 - (&1 + X0) / Z0) * (log2 Z0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0)))) - (&1 + X0)*Y1 / (&2 *Z0 * Z0)` THEN ASM_MESON_TAC []);; let asymp2_abovebelow_lemma3 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real Z0:real Z1:real. &0 < &1 + X0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z1 = ((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0)) / (&1 + X0) /\ Y0 = Z0 ==> (\i:num. ( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - (S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0) ) * log2(n(i)) - (S1 + (&1 / &2) * (log2(Y0) + X1/Y0 - (&1 + X0)*Y1/(Y0*Y0) - (&2 - (&1 + X0)/Y0)*(log2(Y0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) ) = (\i:num. ( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - &0 ) * log2(n(i)) - ((&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0)) ) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN specialize [`Q0:real`; `S0:real`; `X0:real`; `Y0:real`] asymp2_abovebelow_lemma1 THEN specialize [`Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `Z0:real`; `Z1:real`] asymp2_abovebelow_lemma2 THEN ASM_MESON_TAC []);; let asymp2_abovebelow_lemma4 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real Z0:real Z1:real. &0 < &1 + X0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z1 = ((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0)) / (&1 + X0) /\ Y0 = Z0 /\ o1_seq (\i:num. ( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - (S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - (X0 / (&1 + X0)) * Q0) ) * log2(n(i)) - (S1 + (&1 / &2) * (log2(Y0) + X1/Y0 - (&1 + X0)*Y1/(Y0*Y0) - (&2 - (&1 + X0)/Y0)*(log2(Y0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) ) ==> o1_seq (\i:num. ( log2(standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i))) / log2(n(i)) - &0 ) * log2(n(i)) - ((&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0)) ) `, MESON_TAC [asymp2_abovebelow_lemma3]);; let asymp2_abovebelow_lemma5 = prove(` !Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real Z0:real Z1:real. &0 < &1 + X0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Y0 = Z0 /\ Y1 < Z1 ==> &0 < (&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0) `, REPEAT STRIP_TAC THEN real_linear `Y1 < Z1 ==> &0 < Z1 - Y1` THEN specialize [`&1 + X0`; `&1 - &2*S0 + &2*Q0*X0/(&1 + X0)`] REAL_LT_DIV THEN real_linear `&0 < (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> &0 < Z0` THEN real_linear `&0 < &2` THEN specialize [`Z0:real`; `Z0:real`] REAL_LT_MUL THEN specialize [`&2`; `Z0*Z0:real`] REAL_LT_MUL THEN specialize [`Z1-Y1:real`; `&2*Z0*Z0`] REAL_LT_DIV THEN specialize [`&1 + X0`; `(Z1-Y1) / (&2*Z0*Z0)`] REAL_LT_MUL THEN ASM_SIMP_TAC []);; let asymp2_abovebelow_lemma6 = prove(` !Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real Z0:real Z1:real. &0 < &1 + X0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Y0 = Z0 /\ Z1 < Y1 ==> (&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0) < &0 `, REPEAT STRIP_TAC THEN real_linear `Z1 < Y1 ==> &0 < Y1 - Z1` THEN specialize [`&1 + X0`; `&1 - &2*S0 + &2*Q0*X0/(&1 + X0)`] REAL_LT_DIV THEN real_linear `&0 < (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) ==> &0 < Z0` THEN real_linear `&0 < &2` THEN specialize [`Z0:real`; `Z0:real`] REAL_LT_MUL THEN specialize [`&2`; `Z0*Z0:real`] REAL_LT_MUL THEN specialize [`Y1-Z1:real`; `&2*Z0*Z0`] REAL_LT_DIV THEN specialize [`&1 + X0`; `(Y1-Z1) / (&2*Z0*Z0)`] REAL_LT_MUL THEN specialize_reverse [`(&1 + X0) * (Y1 - Z1) / (&2 * Z0 * Z0)`; `&0`] REAL_LT_NEG2 THEN real_linear `-- &0 = &0` THEN real_linear `--((&1 + X0) * (Y1 - Z1) / (&2 * Z0 * Z0)) = (&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0)` THEN ASM_MESON_TAC []);; let asymp2_abovebelow = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y0:real Y1:real Z0:real Z1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!i. &1 < b(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ o1_seq (\i:num. ((((b(i))/(n(i))) - (Y0)) * log2(n(i))) - (Y1)) /\ &0 < &1 + X0 /\ &0 < &1 + &2*S0 /\ &0 < Y0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z1 = ((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0)) / (&1 + X0) ==> ( Y0 < Z0 ==> ?m. !i. m <= i ==> &1 < standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) ) /\ ( Y0 = Z0 /\ Y1 < Z1 ==> ?m. !i. m <= i ==> &1 < standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) ) /\ ( Y0 = Z0 /\ Z1 < Y1 ==> ?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) < &1 ) /\ ( Z0 < Y0 ==> ?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) < &1 ) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`] asymp2_simple3 THENL [real_linear `Y0 < Z0 /\ Z0 = (&1 + X0) / (&1 - &2 * S0 + &2 * Q0 * X0 / (&1 + X0)) ==> Y0 < (&1 + X0) / (&1 - &2 * S0 + &2 * Q0 * X0 / (&1 + X0))` THEN specialize [`Q0:real`; `S0:real`; `X0:real`; `Y0:real`] standardratio_above_lemma2 THEN specialize [`n:num->real`; `\i:num. log2 (standardratio (n(i)) (q i) (s i) (k i) (b i)) / log2 (n i)`; `S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - X0 / (&1 + X0) * Q0`; `S1 + &1 / &2 * (log2 Y0 + X1 / Y0 - (&1 + X0) * Y1 / (Y0 * Y0) - (&2 - (&1 + X0) / Y0) * (log2 Y0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0)))`] asymp2_eventually_positive; specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`] asymp2_simple3 THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `Z0:real`; `Z1:real`] asymp2_abovebelow_lemma4 THEN specialize [`Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `Z0:real`; `Z1:real`] asymp2_abovebelow_lemma5 THEN specialize [`n:num->real`; `\i:num. log2 (standardratio (n(i)) (q i) (s i) (k i) (b i)) / log2 (n i)`; `(&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0)`] asymp2_eventually_positive2; specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`] asymp2_simple3 THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `Z0:real`; `Z1:real`] asymp2_abovebelow_lemma4 THEN specialize [`Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`; `Z0:real`; `Z1:real`] asymp2_abovebelow_lemma6 THEN specialize [`n:num->real`; `\i:num. log2 (standardratio (n(i)) (q i) (s i) (k i) (b i)) / log2 (n i)`; `(&1 + X0) * (Z1 - Y1) / (&2 * Z0 * Z0)`] asymp2_eventually_negative2; specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `X0:real`; `X1:real`; `Y0:real`; `Y1:real`] asymp2_simple3 THEN real_linear `Z0 < Y0 /\ Z0 = (&1 + X0) / (&1 - &2 * S0 + &2 * Q0 * X0 / (&1 + X0)) ==> (&1 + X0) / (&1 - &2 * S0 + &2 * Q0 * X0 / (&1 + X0)) < Y0` THEN specialize [`Q0:real`; `S0:real`; `X0:real`; `Y0:real`] standardratio_below_lemma2_alt THEN specialize [`n:num->real`; `\i:num. log2 (standardratio (n(i)) (q i) (s i) (k i) (b i)) / log2 (n i)`; `S0 - &1 / &2 + (&1 + X0) / (&2 * Y0) - X0 / (&1 + X0) * Q0`; `S1 + &1 / &2 * (log2 Y0 + X1 / Y0 - (&1 + X0) * Y1 / (Y0 * Y0) - (&2 - (&1 + X0) / Y0) * (log2 Y0 - log2 (&2 * pi * exp (&1)))) - (Q1 * X0 / (&1 + X0) + Q0 * X1 / ((&1 + X0) * (&1 + X0)))`] asymp2_eventually_negative] THEN ASM_MESON_TAC [log2ratio_lnratio; standardratio_above_lemma3; standardratio_below_lemma3; standardratio_positive]);; let asymp2_below_j = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->num->real Q0:real Q1:real S0:real S1:real X0:real X1:real Y1:num->real Z0:real Z1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ (!i. &0 < k(i)) /\ (!j i. &1 < b j i) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i:num. (((log2(q(i))/log2(n(i))) - (Q0)) * log2(n(i))) - (Q1)) /\ o1_seq (\i:num. (((log2(s(i))/log2(n(i))) - (S0)) * log2(n(i))) - (S1)) /\ o1_seq (\i:num. ((((k(i))/(n(i))) - (X0)) * log2(n(i))) - (X1)) /\ (!j. o1_seq (\i:num. ((((b j i)/(n(i))) - (Z0)) * log2(n(i))) - (Y1 j))) /\ &0 < &1 + X0 /\ &0 < &1 + &2*S0 /\ &0 < Z0 /\ &0 < &1 - &2*S0 + &2*Q0*X0/(&1 + X0) /\ Z0 = (&1 + X0) / (&1 - &2*S0 + &2*Q0*X0/(&1 + X0)) /\ Z1 = ((S1 + (&1 / &2) * (log2(Z0) + X1/Z0 - (&2 - (&1 + X0)/Z0)*(log2(Z0) - log2(&2 * pi * exp(&1)))) - (Q1 * X0/(&1 + X0) + Q0 * X1/((&1 + X0)*(&1 + X0)))) * (&2 * Z0 * Z0)) / (&1 + X0) /\ (!j. Z1 < Y1(j)) ==> !j. ?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b j i) < &1 `, MESON_TAC [asymp2_abovebelow]);; let main_x0_positive = prove(` !Q0:real S0:real x0:real. -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) ==> &0 < x0 `, MESON_TAC [REAL_ARITH `-- &1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2`; REAL_ARITH `&1 / &2 < Q0 + S0 ==> &0 < Q0 + S0 - &1 / &2`; REAL_LT_DIV]);; let main_x0_le1 = prove(` !Q0:real S0:real x0:real. -- &1 / &2 < Q0 - S0 /\ S0 <= &1 / &2 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) ==> x0 <= &1 `, MESON_TAC [REAL_ARITH `-- &1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2`; REAL_ARITH `S0 <= &1 / &2 ==> (Q0 + S0 - &1 / &2) <= &1 * (Q0 - S0 + &1 / &2)`; REAL_LE_LDIV]);; let main_k_integer = prove(` !n:num->real K:num->real x0:real. K = (\i. ceil(x0 * n(i))) ==> (!i. integer(K(i))) `, MESON_TAC [ceil_isinteger]);; let main_k_positive_lemma = prove(` !n:real K:real x0:real. &1 < n /\ &0 < x0 /\ K = ceil(x0 * n) ==> &0 < K `, REPEAT STRIP_TAC THEN real_linear `&1 < n ==> &0 < n` THEN specialize [`x0:real`; `n:real`] REAL_LT_MUL THEN specialize_forward [`x0*n:real`] ceil_pos THEN real_linear `&1 <= ceil(x0*n) ==> &0 < ceil(x0*n)` THEN ASM_SIMP_TAC []);; let main_k_positive = prove(` !n:num->real K:num->real x0:real. (!i. &1 < n(i)) /\ &0 < x0 /\ K = (\i. ceil(x0 * n(i))) ==> (!i. &0 < K(i)) `, MESON_TAC [main_k_positive_lemma]);; let main_k_leceiln_lemma = prove(` !n:real K:real x0:real. &1 < n /\ x0 <= &1 /\ K = ceil(x0 * n) ==> K <= ceil(n) `, REPEAT STRIP_TAC THEN real_linear `&1 < n ==> &0 <= n` THEN specialize [`x0:real`; `&1`; `n:real`] REAL_LE_RMUL THEN real_linear `&1 * n = n` THEN ASM_MESON_TAC [ceil_mono]);; let main_k_leceiln = prove(` !n:num->real K:num->real x0:real. (!i. &1 < n(i)) /\ x0 <= &1 /\ K = (\i. ceil(x0 * n(i))) ==> (!i. K(i) <= ceil(n(i))) `, MESON_TAC [main_k_leceiln_lemma]);; let main_kn_o1_lemma = prove(` !n:real K:real x0:real. &1 < n /\ K = ceil(x0 * n) ==> &0 <= (K/n - x0)*log2(n) `, REPEAT STRIP_TAC THEN specialize [`x0*n:real`] ceil_ge THEN real_linear `&1 < n ==> &0 < n` THEN specialize [`n:real`] log2_gt1 THEN real_linear `&0 < log2(n) ==> &0 <= log2(n)` THEN ASM_MESON_TAC [REAL_LE_RDIV_EQ; REAL_ARITH `x0 <= K/n ==> &0 <= K/n - x0`; REAL_LE_MUL]);; let main_kn_o1_lemma2 = prove(` !n:real K:real x0:real. &1 < n /\ K = ceil(x0 * n) ==> (K/n - x0)*log2(n) < log2(n)/n `, REPEAT STRIP_TAC THEN specialize [`x0*n:real`] ceil_lt_plus1 THEN real_linear `&1 < n ==> &0 < n` THEN real_linear `ceil(x0*n) < x0*n + &1 ==> ceil(x0*n)-x0*n < &1` THEN specialize [`n:real`] log2_gt1 THEN specialize [`log2 n`; `n:real`] REAL_LT_DIV THEN specialize [`ceil(x0*n)-x0*n`; `&1`; `log2(n)/n`] REAL_LT_RMUL THEN real_cancel `&1 < n ==> (ceil(x0*n) - x0*n)*log2(n)/n = (ceil(x0*n)/n - x0)*log2(n)` THEN real_linear `&1 * log2(n) / n = log2(n) / n` THEN ASM_MESON_TAC []);; let main_kn_o1_lemma3 = prove(` !n:num->real K:num->real x0:real. (!i. &1 < n(i)) /\ K = (\i. ceil(x0 * n(i))) ==> !i. &0 <= (K(i)/n(i) - x0)*log2(n(i)) `, MESON_TAC [main_kn_o1_lemma]);; let main_kn_o1_lemma4 = prove(` !n:num->real K:num->real x0:real. (!i. &1 < n(i)) /\ K = (\i. ceil(x0 * n(i))) ==> !i. (K(i)/n(i) - x0)*log2(n(i)) < log2(n(i))/n(i) `, MESON_TAC [main_kn_o1_lemma2]);; let main_kn_o1_lemma5 = prove(` !n:num->real. (!i. &1 < n(i)) ==> (!i. &1 <= n(i)) `, MESON_TAC [REAL_LT_IMP_LE]);; let main_kn_o1 = prove(` !n:num->real K:num->real x0:real. (!i. &1 < n(i)) /\ K = (\i. ceil(x0 * n(i))) /\ o1_seq (\i. &1 / n(i)) ==> o1_seq (\i. (K(i)/n(i) - x0)*log2(n(i)) - &0) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ARITH `x - &0 = x`] THEN specialize [`n:num->real`; `K:num->real`; `x0:real`] main_kn_o1_lemma3 THEN specialize [`n:num->real`; `K:num->real`; `x0:real`] main_kn_o1_lemma4 THEN specialize [`n:num->real`] main_kn_o1_lemma5 THEN specialize [`n:num->real`] o1_log2overlinear_1 THEN specialize [`\i:num. (K(i)/n(i) - x0)*log2(n(i))`; `\i:num. log2(n(i))/n(i)`] nonneg_lt_o1 THEN ASM_SIMP_TAC []);; let main_b_integer = prove(` !n:num->real k:num->real z0:real z1:real b:num->num->real. b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> !j i. integer(b j i) `, MESON_TAC [ceil_isinteger]);; let main_b_gt1_lemma = prove(` !n:real k:real z0:real z1:real b:real. &1 < n /\ &0 < k /\ b = ceil(min (n + k + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n))*n))) ==> &1 < b `, REPEAT STRIP_TAC THEN real_linear `&1 < n /\ &0 < k ==> &2 <= n + k + &1` THEN real_linear `&2 <= n + k + &1 ==> &2 <= min (n + k + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n))*n))` THEN ASM_MESON_TAC [ceil_ge; REAL_LE_TRANS; REAL_ARITH `&2 <= b ==> &1 < b`]);; let main_b_gt1 = prove(` !n:num->real k:num->real z0:real z1:real b:num->num->real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> !j i. &1 < b j i `, MESON_TAC [main_b_gt1_lemma]);; let main_b_lenk1_lemma = prove(` !n:real k:real z0:real z1:real b:real. &1 < n /\ &0 < k /\ b = ceil(min (n + k + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n))*n))) ==> b <= ceil(n + k + &1) `, MESON_TAC [REAL_ARITH `min (n + k + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n))*n)) <= n + k + &1`; ceil_mono]);; let main_b_lenk1 = prove(` !n:num->real k:num->real z0:real z1:real b:num->num->real. (!i. &1 < n(i)) /\ (!i. &0 < k(i)) /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> !j i. b j i <= ceil(n(i) + k(i) + &1) `, MESON_TAC [main_b_lenk1_lemma]);; let main_b_growth_lemma1 = prove(` !L z0 z1. &0 < z1 /\ abs(&1 / L) < z0 / (&2 * z1) ==> --z0 / &2 < z1/L `, REPEAT STRIP_TAC THEN real_cancel `abs(&1 / L) < z0 / (&2 * z1) ==> (-- z0 / &2) / z1 < &1 / L` THEN specialize [`(--z0 / &2)/z1`; `&1/L`; `z1:real`] REAL_LT_RMUL THEN real_cancel `&0 < z1 ==> --z0 / &2 / z1 * z1 = --z0 / &2` THEN real_linear `&1 / L * z1 = z1 / L` THEN ASM_MESON_TAC []);; let main_b_growth_lemma2 = prove(` !L z0 z1. &0 < --z1 /\ abs(&1 / L) < z0 / (-- &2 * z1) ==> --z0 / &2 < z1/L `, REPEAT STRIP_TAC THEN real_cancel `abs(&1 / L) < z0 / (-- &2 * z1) ==> --z0 / (-- &2 * z1) < -- &1 / L` THEN specialize [`--z0 / (-- &2 * z1)`; `-- &1 / L`; `--z1:real`] REAL_LT_RMUL THEN real_cancel `&0 < --z1 ==> --z0 / (-- &2 * z1) * --z1 = --z0 / &2` THEN real_linear `-- &1 / L * --z1 = z1 / L` THEN ASM_MESON_TAC []);; let main_b_growth_lemma3 = prove(` !n:num->real z0:real z1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < z0 ==> ?Z. !i. Z <= i ==> -- z0 / &2 < z1/log2(n(i)) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`] log2overo1 THEN STRUCT_CASES_TAC (SPEC `z1:real` REAL_LT_NEGTOTAL) THENL [EXISTS_TAC `0` THEN REPEAT STRIP_TAC THEN real_linear `&0 < z0 ==> --z0 / &2 < &0 / log2(n(i:num))` THEN ASM_MESON_TAC []; real_linear `&0 < z1 ==> &0 < &2 * z1` THEN specialize [`z0:real`; `&2 * z1`] REAL_LT_DIV THEN choose_specializing `Z:num` [`\i:num. &1 / log2(n i)`; `z0 / (&2 * z1)`] o1_seq_lt_use THEN EXISTS_TAC `Z:num` THEN ASM_MESON_TAC [main_b_growth_lemma1]; real_linear `&0 < --z1 ==> &0 < -- &2 * z1` THEN specialize [`z0:real`; `-- &2 * z1`] REAL_LT_DIV THEN choose_specializing `Z:num` [`\i:num. &1 / log2(n i)`; `z0 / (-- &2 * z1)`] o1_seq_lt_use THEN EXISTS_TAC `Z:num` THEN ASM_MESON_TAC [main_b_growth_lemma2]]);; let main_b_growth_lemma4 = prove(` !n:num->real z0:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < z0 ==> ?Y. !i. Y <= i ==> &1 / n(i) <= z0 / &4 `, REPEAT STRIP_TAC THEN real_linear `&0 < &4` THEN specialize [`z0:real`; `&4`] REAL_LT_DIV THEN choose_specializing `Y:num` [`\i:num. &1 / n(i)`; `z0 / &4`] o1_seq_use THEN EXISTS_TAC `Y:num` THEN ASM_MESON_TAC [REAL_ARITH `abs(a) <= b ==> a <= b`]);; let main_b_growth_lemma5 = prove(` !n:real z0:real z1:real j:num. &1 < n /\ --z0 / &2 < z1/log2(n) /\ &1 / n <= z0 / &4 ==> max (&2) ((z0 + (z1 + exp(-- &j))/log2(n))*n) = (z0 + (z1 + exp(-- &j))/log2(n))*n `, REPEAT STRIP_TAC THEN specialize [`-- &j`] REAL_EXP_POS_LT THEN specialize [`n:real`] log2_gt1 THEN specialize [`exp(-- &j)`; `log2(n)`] REAL_LT_DIV THEN specialize [`--z0 / &2`; `z1/log2(n)`; `&0`; `exp(-- &j) / log2(n)`] REAL_LT_ADD2 THEN real_linear `--z0 / &2 + &0 < z1 / log2 n + exp (-- &j) / log2 n ==> z0 / &2 < z0 + (z1 + exp (-- &j)) / log2 n` THEN real_linear `&1 < n ==> &0 < n` THEN specialize [`z0 / &2`; `z0 + (z1 + exp (-- &j)) / log2 n`; `n:real`] REAL_LT_RMUL THEN real_linear `&1 < n ==> &0 <= &2 * n` THEN specialize [`&1 / n`; `z0 / &4`; `&2 * n`] REAL_LE_RMUL THEN real_cancel `&1 < n /\ &1 / n * &2 * n <= z0 / &4 * &2 * n ==> &2 <= z0 / &2 * n` THEN specialize [`&2`; `z0 / &2 * n`; `(z0 + (z1 + exp (-- &j)) / log2 n) * n`] REAL_LET_TRANS THEN real_linear `&2 < (z0 + (z1 + exp (-- &j)) / log2 n) * n ==> max (&2) ((z0 + (z1 + exp (-- &j)) / log2 n) * n) = ((z0 + (z1 + exp (-- &j)) / log2 n) * n)` THEN ASM_SIMP_TAC []);; let main_b_growth_lemma6 = prove(` !n:num->real k:num->real z0:real z1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ (!i. &0 < k(i)) /\ &0 < z0 ==> ?X. !j. !i. X <= i ==> ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i)))) = ceil(min (n(i) + k(i) + &1) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))) `, REPEAT STRIP_TAC THEN choose_specializing `Z:num` [`n:num->real`; `z0:real`; `z1:real`] main_b_growth_lemma3 THEN choose_specializing `Y:num` [`n:num->real`; `z0:real`] main_b_growth_lemma4 THEN EXISTS_TAC `MAX Z Y` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC [main_b_growth_lemma5]);; let main_b_growth_lemma7 = prove(` !L x0 z0 z1. &0 < z1 + &1 /\ abs(&1 / L) <= (&1 + x0 - z0)/(z1 + &1) ==> (z1 + &1) / L <= &1 + x0 - z0 `, MESON_TAC [REAL_ABS_LE; REAL_LE_TRANS; REAL_LE_LMUL; REAL_LT_IMP_LE; REAL_ARITH `(z1 + &1) * &1 / L = (z1 + &1) / L`; REAL_FIELD `&0 < z1 + &1 ==> (z1 + &1) * (&1 + x0 - z0)/(z1 + &1) = &1 + x0 - z0`]);; let main_b_growth_lemma8 = prove(` !L x0 z0 z1. &0 < --(z1 + &1) /\ abs(&1 / L) <= (&1 + x0 - z0)/(--(z1 + &1)) ==> (z1 + &1) / L <= &1 + x0 - z0 `, REPEAT STRIP_TAC THEN real_linear `abs(&1 / L) <= (&1 + x0 - z0)/(--(z1 + &1)) ==> --(&1 / L) <= (&1 + x0 - z0)/(--(z1 + &1))` THEN real_linear `&0 < --(z1 + &1) ==> &0 <= --(z1 + &1)` THEN specialize [`--(z1 + &1)`; `--(&1 / L)`; `(&1 + x0 - z0) / --(z1 + &1)`] REAL_LE_LMUL THEN real_linear `--(z1 + &1) * --(&1 / L) = (z1 + &1) / L` THEN real_cancel `&0 < --(z1 + &1) ==> --(z1 + &1) * (&1 + x0 - z0) / --(z1 + &1) = &1 + x0 - z0` THEN ASM_MESON_TAC []);; let main_b_growth_lemma9 = prove(` !n:num->real x0:real z0:real z1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ &0 < &1 + x0 - z0 ==> ?Z. !i. Z <= i ==> (z1 + &1)/log2(n(i)) <= &1 + x0 - z0 `, REPEAT STRIP_TAC THEN specialize [`n:num->real`] log2overo1 THEN STRUCT_CASES_TAC (SPEC `z1 + &1` REAL_LT_NEGTOTAL) THENL [EXISTS_TAC `0` THEN REPEAT STRIP_TAC THEN real_linear `&0 < &1 + x0 - z0 ==> &0 / log2(n(i:num)) <= &1 + x0 - z0` THEN ASM_MESON_TAC []; specialize [`&1 + x0 - z0`; `z1 + &1`] REAL_LT_DIV THEN choose_specializing `Z:num` [`\i:num. &1 / log2(n i)`; `(&1 + x0 - z0)/(z1 + &1)`] o1_seq_use THEN EXISTS_TAC `Z:num` THEN ASM_MESON_TAC [main_b_growth_lemma7]; specialize [`&1 + x0 - z0`; `--(z1 + &1)`] REAL_LT_DIV THEN choose_specializing `Z:num` [`\i:num. &1 / log2(n i)`; `(&1 + x0 - z0)/(-- (z1 + &1))`] o1_seq_use THEN EXISTS_TAC `Z:num` THEN ASM_MESON_TAC [main_b_growth_lemma8]]);; let main_b_growth_lemma10 = prove(` !j. exp(-- &j) <= &1 `, MESON_TAC [REAL_EXP_MONO_LE; REAL_EXP_0; REAL_ARITH `-- &j <= &0`]);; let main_b_growth_lemma11 = prove(` !n k x0 z0 z1 j. &1 < n /\ k = ceil(x0*n) /\ (z1 + &1) / log2(n) <= &1 + x0 - z0 ==> min (n + k + &1) ((z0 + (z1 + exp(-- &j))/log2(n))*n) = (z0 + (z1 + exp(-- &j))/log2(n))*n `, REPEAT STRIP_TAC THEN specialize [`j:num`] main_b_growth_lemma10 THEN specialize [`n:real`] log2_gt1 THEN specialize_reverse [`exp(-- &j)`; `&1`; `log2(n)`] REAL_LE_DIV2_EQ THEN real_linear `(z1 + &1) / log2 n <= &1 + x0 - z0 /\ exp (-- &j) / log2 n <= &1 / log2 n ==> z0 + (z1 + exp(-- &j)) / log2 n <= &1 + x0` THEN real_linear `&1 < n ==> &0 <= n` THEN specialize [`z0 + (z1 + exp (-- &j)) / log2 n`; `&1 + x0`; `n:real`] REAL_LE_RMUL THEN specialize [`x0*n:real`] ceil_ge THEN real_linear `k = ceil(x0 * n) /\ x0 * n <= ceil(x0 * n) ==> (&1 + x0) * n <= n + k + &1` THEN ASM_MESON_TAC [REAL_LE_TRANS; REAL_ARITH `a <= b ==> min b a = a`]);; let main_b_growth_lemma12 = prove(` !n:num->real k:num->real x0:real z0:real z1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0*n(i))) /\ &0 < &1 + x0 - z0 ==> ?Y. !j. !i. Y <= i ==> ceil(min (n(i) + k(i) + &1) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))) = ceil((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i)) `, REPEAT STRIP_TAC THEN choose_specializing `Z:num` [`n:num->real`; `x0:real`; `z0:real`; `z1:real`] main_b_growth_lemma9 THEN EXISTS_TAC `Z:num` THEN ASM_MESON_TAC [main_b_growth_lemma11]);; let main_b_growth_lemma13 = prove(` !n:num->real k:num->real x0:real z0:real z1:real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0*n(i))) /\ (!i. &0 < k(i)) /\ &0 < z0 /\ &0 < &1 + x0 - z0 ==> ?Z. !j. !i. Z <= i ==> ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i)))) = ceil((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i)) `, REPEAT STRIP_TAC THEN choose_specializing `X:num` [`n:num->real`; `k:num->real`; `z0:real`; `z1:real`] main_b_growth_lemma6 THEN choose_specializing `Y:num` [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`] main_b_growth_lemma12 THEN EXISTS_TAC `MAX X Y` THEN REWRITE_TAC [max_le] THEN ASM_MESON_TAC []);; let main_b_growth_lemma14 = prove(` !n:real z0:real z1:real j:num. &1 < n ==> &0 <= (ceil((z0 + (z1 + exp(-- &j))/log2(n))*n)/n - z0) * log2(n) - (z1 + exp(-- &j)) `, REPEAT STRIP_TAC THEN specialize [`(z0 + (z1 + exp(-- &j))/log2(n))*n`] ceil_ge THEN specialize [`n:real`] log2_gt1 THEN real_linear `&1 < n ==> &0 < n` THEN real_linear `&0 < log2 n ==> &0 <= log2 n` THEN specialize_reverse [`(z0 + (z1 + exp (-- &j)) / log2 n) * n`; `ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n)`; `n:real`] REAL_LE_DIV2_EQ THEN real_cancel `&0 < n ==> ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n = z0 + (z1 + exp (-- &j)) / log2 n` THEN real_linear `((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n = z0 + (z1 + exp (-- &j)) / log2 n /\ ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n <= ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n ==> (z1 + exp (-- &j)) / log2 n <= ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0` THEN specialize [`(z1 + exp (-- &j)) / log2 n`; `ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0`; `log2 n`] REAL_LE_RMUL THEN real_cancel `&0 < log2 n ==> (z1 + exp (-- &j)) / log2 n * log2 n = z1 + exp(-- &j)` THEN real_linear `(z1 + exp (-- &j)) / log2 n * log2 n = z1 + exp(-- &j) /\ (z1 + exp (-- &j)) / log2 n * log2 n <= (ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0) * log2 n ==> &0 <= (ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0) * log2 n - (z1 + exp(-- &j))` THEN ASM_SIMP_TAC []);; let main_b_growth_lemma15 = prove(` !n:real z0:real z1:real j:num. &1 < n ==> (ceil((z0 + (z1 + exp(-- &j))/log2(n))*n)/n - z0) * log2(n) - (z1 + exp(-- &j)) < log2(n)/n `, REPEAT STRIP_TAC THEN specialize [`(z0 + (z1 + exp(-- &j))/log2(n))*n`] ceil_lt_plus1 THEN specialize [`n:real`] log2_gt1 THEN real_linear `&1 < n ==> &0 < n` THEN specialize_reverse [`ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n)`; `(z0 + (z1 + exp (-- &j)) / log2 n) * n + &1`; `n:real`] REAL_LT_DIV2_EQ THEN real_cancel `&0 < n ==> ((z0 + (z1 + exp (-- &j)) / log2 n) * n + &1) / n = (z0 + (z1 + exp (-- &j)) / log2 n) + &1 / n` THEN real_linear `((z0 + (z1 + exp (-- &j)) / log2 n) * n + &1) / n = (z0 + (z1 + exp (-- &j)) / log2 n) + &1 / n /\ ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n < ((z0 + (z1 + exp (-- &j)) / log2 n) * n + &1) / n ==> ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0 < (z1 + exp (-- &j)) / log2 n + &1 / n` THEN specialize [`ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0`; `(z1 + exp (-- &j)) / log2 n + &1 / n`; `log2 n`] REAL_LT_RMUL THEN real_cancel `&0 < log2 n ==> ((z1 + exp (-- &j)) / log2 n + &1 / n) * log2 n = (z1 + exp (-- &j)) + log2 n / n` THEN real_linear `((z1 + exp (-- &j)) / log2 n + &1 / n) * log2 n = (z1 + exp (-- &j)) + log2 n / n /\ (ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0) * log2 n < ((z1 + exp (-- &j)) / log2 n + &1 / n) * log2 n ==> (ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0) * log2 n - (z1 + exp (-- &j)) < log2 n / n` THEN ASM_SIMP_TAC []);; let main_b_growth_lemma16 = prove(` !n:num->real z0:real z1:real j:num. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) ==> o1_seq (\i. (ceil((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))/n(i) - z0) * log2(n(i)) - (z1 + exp(-- &j))) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`] main_kn_o1_lemma5 THEN specialize [`n:num->real`] o1_log2overlinear_1 THEN ASM_MESON_TAC [main_b_growth_lemma14; main_b_growth_lemma15; nonneg_lt_o1]);; let main_b_growth_lemma17 = prove(` !n:num->real k:num->real z0:real z1:real b:num->real j:num. b = (\i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> (\i. (b i / n i - z0) * log2 (n i) - (z1 + exp (-- &j))) = (\i. (ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i))) / n i - z0) * log2 (n i) - (z1 + exp (-- &j))) `, SIMP_TAC []);; let main_b_growth_lemma18 = prove(` !n:num->real k:num->real x0:real z0:real z1:real b:num->real j:num. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0 * n(i))) /\ (!i. &0 < k(i)) /\ &0 < z0 /\ &0 < &1 + x0 - z0 /\ b = (\i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> o1_seq (\i. (b(i)/n(i) - z0) * log2(n(i)) - (z1 + exp(-- &j))) `, REPEAT STRIP_TAC THEN choose_specializing `Z:num` [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`] main_b_growth_lemma13 THEN specialize [`n:num->real`; `z0:real`; `z1:real`; `j:num`] main_b_growth_lemma16 THEN specialize [`n:num->real`; `k:num->real`; `z0:real`; `z1:real`; `b:num->real`; `j:num`] main_b_growth_lemma17 THEN specialize [] (MESON [] `(!j i:num. Z <= i ==> ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i))) = ceil ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i)) ==> !i. Z <= i ==> (ceil ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i) / n i - z0) * log2 (n i) - (z1 + exp (-- &j)) = (ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i))) / n i - z0) * log2 (n i) - (z1 + exp (-- &j))`) THEN specialize [`\i:num. (ceil ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i) / n i - z0) * log2 (n i) - (z1 + exp (-- &j))`; `\i:num. (ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i))) / n i - z0) * log2 (n i) - (z1 + exp (-- &j))`; `Z:num`] o1_seq_past THEN ASM_MESON_TAC []);; let main_b_growth = prove(` !n:num->real k:num->real x0:real z0:real z1:real b:num->num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0 * n(i))) /\ (!i. &0 < k(i)) /\ &0 < z0 /\ &0 < &1 + x0 - z0 /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> !j. o1_seq (\i. ((b j i)/n(i) - z0) * log2(n(i)) - (z1 + exp(-- &j))) `, REPEAT STRIP_TAC THEN specialize [] (MESON [] `b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) ==> b(j) = (\i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i)))))`) THEN specialize [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`; `(b:num->num->real) j`; `j:num`] main_b_growth_lemma18 THEN ASM_SIMP_TAC []);; let main_z0_positive = prove(` !Q0:real S0:real z0:real. -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> &0 < z0 `, REPEAT STRIP_TAC THEN real_linear `-- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < &2 * Q0` THEN real_linear `-- &1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2` THEN specialize [`Q0 - S0 + &1 / &2`; `Q0 - S0 + &1 / &2`] REAL_LT_MUL THEN ASM_MESON_TAC [REAL_POW_2; REAL_LT_DIV; REAL_ARITH `&2 * a / b = (&2 * a) / b`]);; let main_1x0z0_positive = prove(` !Q0:real S0:real x0:real z0:real. &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> &0 < &1 + x0 - z0 `, REPEAT STRIP_TAC THEN real_linear `&1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < &2 * Q0` THEN real_linear `&1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2` THEN real_linear `&1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 - &1 / &2` THEN real_cancel `&0 < Q0 - S0 + &1 / &2 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> &1 + x0 - z0 = (&2 * Q0) * (Q0 - S0 - &1 / &2) / ((Q0 - S0 + &1 / &2) * (Q0 - S0 + &1 / &2))` THEN ASM_MESON_TAC [REAL_LT_MUL; REAL_LT_DIV]);; let main_SQx_positive_variant = prove(` !Q0:real S0:real x0:real. S0 < &1 / &2 /\ -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ &0 <= x0 ==> &0 < &1 - &2*S0 + &2*Q0*x0/(&1 + x0) `, REPEAT STRIP_TAC THEN real_linear `-- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 <= Q0` THEN real_linear `&0 <= &2` THEN real_linear `&0 <= x0 ==> &0 <= &1 + x0` THEN note `&0 <= x0/(&1 + x0)` [REAL_LE_DIV] THEN note `&0 <= &2*Q0*x0/(&1 + x0)` [REAL_LE_MUL] THEN real_linear `S0 < &1 / &2 /\ &0 <= &2*Q0*x0/(&1 + x0) ==> &0 < &1 - &2*S0 + &2*Q0*x0/(&1 + x0)` THEN ASM_MESON_TAC []);; let main_SQx_positive = prove(` !Q0:real S0:real x0:real. S0 <= &1 / &2 /\ &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ &0 < x0 ==> &0 < &1 - &2*S0 + &2*Q0*x0/(&1 + x0) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC (REAL_ARITH `S0 <= &1 / &2 /\ &0 < &2 * Q0 * x0/(&1 + x0) ==> &0 < &1 - &2*S0 + &2*Q0*x0/(&1 + x0)`) THEN real_linear `&0 < x0 ==> &0 < &1 + x0` THEN real_linear `&0 < &2` THEN ASM_MESON_TAC [REAL_ARITH `&1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < Q0`; REAL_LT_MUL; REAL_LT_DIV]);; let main_zxSQ = REAL_FIELD ` !Q0:real S0:real x0:real z0:real. &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> z0 = (&1 + x0) / (&1 - &2*S0 + &2*Q0*x0/(&1 + x0)) `;; let main_z1formula = prove(` !Q0:real Q1:real S0:real S1:real x0:real z0:real z1:real. &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2)*(log2(z0) - log2(&2 * pi * exp(&1))) - Q1*(Q0 + S0 - &1 / &2)/Q0)*(&2 * Q0)/(Q0 - S0 + &1 / &2) pow 3 ==> z1 = ((S1 + (&1 / &2) * (log2(z0) + &0/z0 - (&2 - (&1 + x0)/z0)*(log2(z0) - log2(&2 * pi * exp(&1)))) - (Q1 * x0/(&1 + x0) + Q0 * &0/((&1 + x0)*(&1 + x0)))) * (&2 * z0 * z0)) / (&1 + x0) `, REPEAT STRIP_TAC THEN real_linear `&1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < Q0` THEN real_cancel `&0 < Q0 /\ &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) ==> x0/(&1 + x0) = (Q0 + S0 - &1 / &2) / (&2 * Q0)` THEN real_cancel `&0 < Q0 /\ &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> (&1 + x0)/z0 = Q0 - S0 + &1 / &2` THEN real_cancel `&1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> &2*z0*z0/(&1+x0) = &4*Q0/(Q0-S0 + &1 / &2) pow 3` THEN real_cancel `x0 / (&1 + x0) = (Q0 + S0 - &1 / &2) / (&2 * Q0) /\ (&1 + x0)/z0 = Q0 - S0 + &1 / &2 /\ &2*z0*z0/(&1+x0) = &4*Q0/(Q0-S0 + &1 / &2) pow 3 /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2)*(log2(z0) - log2(&2 * pi * exp(&1))) - Q1*(Q0 + S0 - &1 / &2)/Q0)*(&2 * Q0)/(Q0 - S0 + &1 / &2) pow 3 ==> z1 = ((S1 + (&1 / &2) * (log2(z0) + &0/z0 - (&2 - (&1 + x0)/z0)*(log2(z0) - log2(&2 * pi * exp(&1)))) - (Q1 * x0/(&1 + x0) + Q0 * &0/((&1 + x0)*(&1 + x0)))) * (&2 * z0 * z0)) / (&1 + x0)` THEN ASM_MESON_TAC []);; let main_z1lt = prove(` !z1:real j. z1 < z1 + exp(-- &j) `, MESON_TAC [REAL_EXP_POS_LT; REAL_ARITH `&0 < e ==> x < x + e`]);; let main_m_le_M = prove(` !m:num->num M:num->num j:num. M = (\j. j + nsum (0..j) m) ==> m(j) <= M(j) `, REPEAT STRIP_TAC THEN DISJ_CASES_TAC (SPEC `j:num` num_CASES) THENL [ASM_MESON_TAC [NSUM_CLAUSES_NUMSEG; ARITH_RULE `x <= 0 + x`]; ASM_MESON_TAC [NSUM_CLAUSES_NUMSEG; ARITH_RULE `0 <= SUC n`; ARITH_RULE `(x:num) <= z + y + x`]]);; let main_M_mono = prove(` !m:num->num M:num->num. M = (\j. j + nsum (0..j) m) ==> !j k. j < k ==> M(j) < M(k) `, REPEAT STRIP_TAC THEN ASM_SIMP_TAC [] THEN specialize [] (ARITH_RULE `0 <= j + 1`) THEN specialize [`m:num->num`; `0`; `j:num`; `k-j:num`] NSUM_ADD_SPLIT THEN specialize [] (ARITH_RULE `j < k ==> j + k - j = k:num`) THEN specialize [] (ARITH_RULE `j < k ==> j + nsum(0..j)m < k + nsum(0..j)m + nsum(j+1..j+k-j) m`) THEN ASM_MESON_TAC []);; let num_mono_ge = prove(` !f:num->num. (!j k. j < k ==> f(j) < f(k)) ==> !t. t <= f(t) `, STRIP_TAC THEN DISCH_TAC THEN INDUCT_TAC THENL [ARITH_TAC; ASM_MESON_TAC [ARITH_RULE `t < SUC t`; ARITH_RULE `x <= y /\ y < z ==> SUC x <= z`]]);; let num_mono_gt = prove(` !f:num->num t. (!j k. j < k ==> f(j) < f(k)) ==> t < f(t+1) `, MESON_TAC [num_mono_ge; ARITH_RULE `t < t + 1`; LET_TRANS]);; let main_M_le = prove(` !M:num->num i:num. M(0) <= i /\ x = (minimal j. i < M(j + 1)) ==> M(x) <= i `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `x = 0` THENL [ASM_MESON_TAC []; choose_specializing `y:num` [] (MESON [num_CASES; ARITH_RULE `SUC n = n + 1`] `~(x = 0) ==> ?y. x = y + 1`) THEN specialize [] (ARITH_RULE `x = y + 1 ==> ~(x <= y)`) THEN specialize [] (MESON [MINIMAL_UBOUND] `x = (minimal j. i:num < M(j + 1)) /\ ~(x <= y) ==> ~(i < M(y + 1))`) THEN ASM_MESON_TAC [NOT_LT]]);; let gluing_pattern = prove(` !m:num->num M:num->num b:num->num->real B:num->real P:num->real->bool. (!j. ?A. !i. A <= i ==> P i (b j i)) /\ m = (\j:num. minimal A. !i. A <= i ==> P i (b j i)) /\ M = (\j. j + nsum (0..j) m) /\ B = (\i:num. b(minimal j. i < M(j+1)) (i)) ==> !i. M(0) <= i ==> P i (B i) `, REPEAT STRIP_TAC THEN def `x:num` `minimal j. i:num < M(j+1)` THEN specialize [`M:num->num`; `i:num`] main_M_le THEN specialize [`m:num->num`; `M:num->num`; `x:num`] main_m_le_M THEN specialize [`m(x:num):num`; `M(x:num):num`; `i:num`] LE_TRANS THEN specialize [] (MESON [] `(!j:num. ?A:num. !i:num. A <= i ==> P i (b j i:real)) ==> ?A. !i. A <= i ==> P i (b x i)`) THEN specialize [`\A:num. !i. A <= i ==> P i (b (x:num) i:real)`] (MESON [MINIMAL] `!P. (?n. P n) ==> P((minimal) P)`) THEN ASM_MESON_TAC []);; let main_B_gt1 = prove(` !b:num->num->real m:num->num B:num->real. (!j i. &1 < b j i) /\ B = (\i. b (minimal j. i < M (j + 1)) i) ==> !i. &1 < B i `, MESON_TAC []);; let main_B_lenk1 = prove(` !n:num->real k:num->real b:num->num->real m:num->num B:num->real. (!j i. b j i <= ceil(n i + k i + &1)) /\ B = (\i. b (minimal j. i < M (j + 1)) i) ==> !i. B i <= ceil(n i + k i + &1) `, MESON_TAC []);; let main_B_growth_lemma = prove(` !n:real z0:real z1:real j:num. &1 < n ==> &0 <= (ceil((z0 + (z1 + exp(-- &j))/log2(n))*n)/n - z0)*log2(n) - z1 `, REPEAT STRIP_TAC THEN specialize [`-- &j`] REAL_EXP_POS_LE THEN specialize [`n:real`] log2_gt1 THEN specialize [`(z0 + (z1 + exp(-- &j))/log2(n))*n`] ceil_ge THEN real_linear `&1 < n ==> &0 < n` THEN specialize [`log2 n`; `n:real`] REAL_LT_DIV THEN real_linear `&0 < log2 n / n ==> &0 <= log2 n / n` THEN specialize [`(z0 + (z1 + exp (-- &j)) / log2 n) * n`; `ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n)`; `(log2 n)/n`] REAL_LE_RMUL THEN real_cancel `&0 < n /\ &0 < log2 n ==> ((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n = z0 * log2 n + z1 + exp(-- &j)` THEN specialize [] (MESON [] `((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n <= ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n /\ ((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n = z0 * log2 n + z1 + exp (-- &j) ==> z0 * log2 n + z1 + exp (-- &j) <= ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n`) THEN real_linear `&0 <= exp(-- &j) /\ z0 * log2 n + z1 + exp (-- &j) <= ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) * log2 n / n ==> &0 <= (ceil ((z0 + (z1 + exp (-- &j)) / log2 n) * n) / n - z0) * log2 n - z1` THEN ASM_SIMP_TAC []);; let main_B_growth_lemma2 = prove(` !n:num->real k:num->real x0:real z0:real z1:real b:num->num->real M:num->num B:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0*n(i))) /\ (!i. &0 < k(i)) /\ &0 < z0 /\ &0 < &1 + x0 - z0 /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) /\ B = (\i:num. b (minimal j. i < M(j+1)) (i)) ==> ?Z. !i. Z <= i ==> &0 <= (B(i)/n(i) - z0)*log2(n(i)) - z1 `, REPEAT STRIP_TAC THEN choose_specializing `Z:num` [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`] main_b_growth_lemma13 THEN EXISTS_TAC `Z:num` THEN REPEAT STRIP_TAC THEN specialize [] (MESON [] `(!i:num. &1 < n i) ==> &1 < n i`) THEN specialize [`n(i:num):real`; `z0:real`; `z1:real`; `minimal j. i:num < M(j+1)`] main_B_growth_lemma THEN specialize [] (MESON [] `(!j:num i:num. Z <= i ==> ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i))) = ceil ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i)) /\ Z <= i ==> (ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &(minimal j. i < M(j + 1)))) / log2 (n i)) * n i))) - z0)*log2(n i) - z1 = (ceil ((z0 + (z1 + exp (-- &(minimal j. i < M(j + 1)))) / log2 (n i)) * n i) - z0)*log2(n i) - z1`) THEN specialize [] (MESON [] `B = (\i:num. b (minimal j. i < M (j + 1)) i) ==> (B i/n i - z0)*log2(n i) - z1 = ((b (minimal j. i < M (j + 1)) i)/n i - z0)*log2(n i) - z1`) THEN specialize [] (MESON [] `b = (\j:num i:num. ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &j)) / log2 (n i)) * n i)))) ==> (b (minimal j. i < M (j + 1)) i/n i - z0) * log2 (n i) - z1 = (ceil (min (n i + k i + &1) (max (&2) ((z0 + (z1 + exp (-- &(minimal j. i < M (j + 1)))) / log2 (n i)) * n i)))/n i - z0) * log2(n i) - z1`) THEN ASM_SIMP_TAC []);; let main_b_mono = prove(` !n:num->real k:num->real z0:real z1:real h:num j:num. (!i. &1 < n(i)) /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) /\ h <= j ==> (!i. b j i <= b h i) `, REPEAT STRIP_TAC THEN note `&1 < n(i:num)` [] THEN real_linear `&1 < n(i:num) ==> &0 <= n(i)` THEN note `&0 < log2(n(i:num))` [log2_gt1] THEN note `&h <= &j` [REAL_OF_NUM_LE] THEN note `-- &j <= -- &h` [REAL_LE_NEG2] THEN note `exp(-- &j) <= exp(-- &h)` [REAL_EXP_MONO_LE] THEN note `z1 + exp(-- &j) <= z1 + exp(-- &h)` [REAL_LE_REFL; REAL_LE_ADD2] THEN note `(z1 + exp(-- &j))/log2(n(i:num)) <= (z1 + exp(-- &h))/log2(n(i))` [REAL_LE_DIV2_EQ] THEN note `z0 + (z1 + exp(-- &j))/log2(n(i:num)) <= z0 + (z1 + exp(-- &h))/log2(n(i))` [REAL_LE_REFL; REAL_LE_ADD2] THEN note `(z0 + (z1 + exp(-- &j))/log2(n(i:num)))*n(i) <= (z0 + (z1 + exp(-- &h))/log2(n(i)))*n(i)` [REAL_LE_RMUL] THEN note `max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i:num)))*n(i)) <= max (&2) ((z0 + (z1 + exp(-- &h))/log2(n(i)))*n(i))` [REAL_ARITH `!x y z. y <= z ==> max x y <= max x z`] THEN note `min (n(i)+k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i:num)))*n(i))) <= min (n(i)+k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &h))/log2(n(i)))*n(i)))` [REAL_ARITH `!x y z. y <= z ==> min x y <= min x z`] THEN note `ceil(min (n(i)+k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i:num)))*n(i)))) <= ceil(min (n(i)+k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &h))/log2(n(i)))*n(i))))` [ceil_mono] THEN ASM_MESON_TAC []);; let mono_lt_imp_le = prove(` !f:num->num. (!j k. j < k ==> f(j) < f(k)) ==> (!j k. j <= k ==> f(j) <= f(k)) `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `j:num < k` THENL [ASM_MESON_TAC [LT_IMP_LE]; note `j = k:num` [ARITH_RULE `j <= k /\ ~(j < k) ==> j = k:num`] THEN ASM_MESON_TAC [LE_REFL]]);; let gluing_mono = prove(` !b:num->num->real M:num->num B:num->real i:num t:num. (!h j. h <= j ==> !c. b j c <= b h c) /\ (!j k. j < k ==> M j < M k) /\ B = (\c:num. b (minimal j. c < M(j+1)) (c)) /\ M(t) <= i ==> B(i) <= b t i `, REPEAT STRIP_TAC THEN note `i < M(i + 1)` [num_mono_gt] THEN specialize [`M:num->num`] mono_lt_imp_le THEN note `!m:num. m < t ==> ~(i:num < M(m+1))` [ARITH_RULE `!m:num. m < t ==> m+1 <= t`; LE_TRANS; NOT_LT] THEN note `?r. i:num < M(r+1)` [] THEN specialize [`\j. i:num < M(j+1)`; `t:num`] MINIMAL_LBOUND THEN ASM_MESON_TAC [main_b_mono]);; let o1_expminus_lemma = prove(` !e:real. &0 < e ==> ?j. exp(-- &j) <= e `, REPEAT STRIP_TAC THEN choose_specializing `j:num` [`--ln(e)`] REAL_ARCH_SIMPLE THEN EXISTS_TAC `j:num` THEN real_linear `--ln(e) <= &j ==> -- &j <= ln(e)` THEN note `exp(-- &j) <= exp(ln(e))` [REAL_EXP_MONO_LE] THEN ASM_MESON_TAC [EXP_LN]);; let main_B_growth_lemma3 = prove(` !n:real z0:real z1:real e:real X:num b:real B:real. &1 < n /\ &0 < e /\ &0 <= (B / n - z0) * log2 (n) - z1 /\ B <= b /\ abs ((b / n - z0) * log2 (n) - (z1 + exp (-- &X))) <= e / &2 /\ exp(-- &X) <= e / &2 ==> abs ((B / n - z0) * log2 (n) - z1) <= e `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ABS_BOUNDS] THEN note `&0 < log2 n` [log2_gt1] THEN real_linear `&0 < e /\ &0 <= (B / n - z0) * log2 (n) - z1 ==> --e <= (B / n - z0) * log2 (n) - z1` THEN real_linear `&1 < n ==> &0 < n` THEN note `B / n <= b / n` [REAL_LE_DIV2_EQ] THEN real_linear `B/n <= b/n ==> B / n - z0 <= b / n - z0` THEN real_linear `&0 < log2 n ==> &0 <= log2 n` THEN note `(B / n - z0) * log2 n <= (b / n - z0) * log2 n` [REAL_LE_RMUL] THEN real_linear `(B / n - z0) * log2 n <= (b / n - z0) * log2 n ==> (B / n - z0) * log2 n - z1 <= (b / n - z0) * log2 n - z1` THEN real_linear `abs ((b / n - z0) * log2 (n) - (z1 + exp (-- &X))) <= e / &2 ==> (b / n - z0) * log2 (n) - z1 <= e / &2 + exp (-- &X)` THEN note `(B / n - z0) * log2 n - z1 <= e / &2 + exp(-- &X)` [REAL_LE_TRANS] THEN real_linear `exp(-- &X) <= e / &2 ==> e / &2 + exp(-- &X) <= e` THEN ASM_MESON_TAC [REAL_LE_TRANS]);; let main_B_growth = prove(` !n:num->real k:num->real x0:real z0:real z1:real b:num->num->real M:num->num B:num->real. (!i. &1 < n(i)) /\ o1_seq (\i. &1 / n(i)) /\ k = (\i. ceil(x0 * n(i))) /\ (!i. &0 < k(i)) /\ &0 < z0 /\ &0 < &1 + x0 - z0 /\ b = (\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))) /\ (!j k. j < k ==> M j < M k) /\ B = (\i:num. b (minimal j. i < M(j+1)) (i)) ==> o1_seq (\i. (B(i)/n(i) - z0) * log2(n(i)) - z1) `, REPEAT STRIP_TAC THEN REWRITE_TAC [o1_seq] THEN REPEAT STRIP_TAC THEN real_linear `&0 < e ==> &0 < e / &2` THEN choose_specializing `X:num` [`e / &2`] o1_expminus_lemma THEN note `o1_seq (\i:num. ((b X i)/n(i) - z0) * log2(n(i)) - (z1 + exp(-- &X)))` [main_b_growth] THEN choose_specializing `Y:num` [`\i:num. ((b X i)/n(i) - z0) * log2(n(i)) - (z1 + exp(-- &X))`; `e / &2`] o1_seq_use THEN choose_specializing `Z:num` [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`; `b:num->num->real`; `M:num->num`; `B:num->real`] main_B_growth_lemma2 THEN EXISTS_TAC `MAX (MAX Y Z) (M(X:num))` THEN REWRITE_TAC [max_le] THEN REPEAT STRIP_TAC THEN note `(!h j:num. h <= j ==> !i:num. b j i <= b h i:real)` [main_b_mono] THEN specialize [`b:num->num->real`; `M:num->num`; `B:num->real`; `i:num`; `X:num`] gluing_mono THEN ASM_MESON_TAC [main_B_growth_lemma3]);; let forward_main = prove(` !n:num->real q:num->real s:num->real Q0:real Q1:real S0:real S1:real x0:real z0:real z1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (log2(q(i))/log2(n(i)) - Q0) * log2(n(i)) - Q1) /\ o1_seq (\i. (log2(s(i))/log2(n(i)) - S0) * log2(n(i)) - S1) /\ -- &1 / &2 < S0 /\ S0 <= &1 / &2 /\ &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2) * (log2(z0) - log2(&2 * pi * exp(&1))) - Q1 * (Q0 + S0 - &1 / &2)/Q0 ) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) ==> ?k:num->real b:num->real. (!i. integer(k(i))) /\ (!i. &0 < k(i)) /\ (!i. k(i) <= ceil(n(i))) /\ o1_seq (\i. (k(i)/n(i) - x0) * log2(n(i)) - &0) /\ (!i. integer(b(i))) /\ (!i. &1 < b(i)) /\ (!i. b(i) <= ceil(n(i) + k(i) + &1)) /\ o1_seq (\i. (b(i)/n(i) - z0) * log2(n(i)) - z1) /\ ?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) < &1 `, REPEAT STRIP_TAC THEN def `k:num->real` `\i:num. ceil(x0*n(i))` THEN EXISTS_TAC `k:num->real` THEN real_linear `-- &1 / &2 < S0 ==> &0 < &1 + &2 * S0` THEN real_linear `&1 / &2 < Q0 - S0 ==> -- &1 / &2 < Q0 - S0` THEN specialize [`Q0:real`; `S0:real`; `x0:real`] main_x0_positive THEN specialize [`Q0:real`; `S0:real`; `x0:real`] main_x0_le1 THEN specialize [`n:num->real`; `k:num->real`; `x0:real`] main_k_integer THEN specialize [`n:num->real`; `k:num->real`; `x0:real`] main_k_positive THEN specialize [`n:num->real`; `k:num->real`; `x0:real`] main_k_leceiln THEN specialize [`n:num->real`; `k:num->real`; `x0:real`] main_kn_o1 THEN def `b:num->num->real` `\j:num i:num. ceil(min (n(i) + k(i) + &1) (max (&2) ((z0 + (z1 + exp(-- &j))/log2(n(i)))*n(i))))` THEN specialize [`n:num->real`; `k:num->real`; `z0:real`; `z1:real`; `b:num->num->real`] main_b_integer THEN specialize [`n:num->real`; `k:num->real`; `z0:real`; `z1:real`; `b:num->num->real`] main_b_gt1 THEN specialize [`n:num->real`; `k:num->real`; `z0:real`; `z1:real`; `b:num->num->real`] main_b_lenk1 THEN specialize [`Q0:real`; `S0:real`; `z0:real`] main_z0_positive THEN specialize [`Q0:real`; `S0:real`; `x0:real`; `z0:real`] main_1x0z0_positive THEN specialize [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`; `b:num->num->real`] main_b_growth THEN real_linear `&0 < x0 ==> &0 < &1 + x0` THEN specialize [`Q0:real`; `S0:real`; `x0:real`] main_SQx_positive THEN specialize [`Q0:real`; `S0:real`; `x0:real`; `z0:real`] main_zxSQ THEN specialize [`Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `x0:real`; `z0:real`; `z1:real`] main_z1formula THEN specialize [`z1:real`] main_z1lt THEN specialize [`n:num->real`; `q:num->real`; `s:num->real`; `k:num->real`; `b:num->num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `x0:real`; `&0`; `\j. z1+exp(-- &j)`; `z0:real`; `z1:real`] asymp2_below_j THEN def `m:num->num` `\j:num. minimal A. !i. A <= i ==> standardratio (n i) (q i) (s i) (k i) (b j i) < &1` THEN def `M:num->num` `\j:num. j + nsum(0..j) m` THEN def `B:num->real` `\i:num. b (minimal j. i < M(j+1)) (i):real` THEN EXISTS_TAC `B:num->real` THEN specialize [`m:num->num`; `M:num->num`; `b:num->num->real`; `B:num->real`; `\i:num beta:real. standardratio (n(i)) (q(i)) (s(i)) (k(i)) (beta) < &1`] gluing_pattern THEN specialize [`b:num->num->real`; `m:num->num`; `B:num->real`] main_B_gt1 THEN specialize [`n:num->real`; `k:num->real`; `b:num->num->real`; `m:num->num`; `B:num->real`] main_B_lenk1 THEN specialize [`m:num->num`; `M:num->num`] main_M_mono THEN specialize [`n:num->real`; `k:num->real`; `x0:real`; `z0:real`; `z1:real`; `b:num->num->real`; `M:num->num`; `B:num->real`] main_B_growth THEN ASM_MESON_TAC []);; (* ----- and working towards converse *) let o1_lower_1 = prove(` !f:num->real. (!e:real. &0 < e ==> FINITE {n | f n < --e}) ==> FINITE {n | f n < -- &1} `, MESON_TAC [REAL_ARITH `&0 < &1`]);; let o1_lower_1_nonempty = prove(` !f:num->real. ~(!n. -- &1 <= f n) ==> ~({n | f n < -- &1} = {}) `, REWRITE_TAC [GSYM EMPTY_GSPEC] THEN REWRITE_TAC [EXTENSION] THEN REWRITE_TAC [IN_ELIM_THM] THEN MESON_TAC [REAL_NOT_LT]);; let o1_lower_1_nonempty_image = prove(` !f:num->real. ~(!n. -- &1 <= f n) ==> ~(IMAGE f {n | f n < -- &1} = {}) `, MESON_TAC [o1_lower_1_nonempty; IMAGE_EQ_EMPTY; SIMPLE_IMAGE_GEN]);; let in_image_rewrite = prove(` !f:num->real L:real. (!x. x IN IMAGE f { n | f n < -- &1} ==> L <= x) ==> !n. f n < -- &1 ==> L <= f n `, REWRITE_TAC [IMAGE] THEN REWRITE_TAC [IN_ELIM_THM] THEN MESON_TAC []);; let o1_lower_1_bound_lemma = prove(` !f:num->real. FINITE {n | f n < -- &1} ==> ?L. !n. f n < -- &1 ==> L <= f n `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `!n:num. -- &1 <= f n` THENL [EXISTS_TAC `-- &1` THEN ASM_MESON_TAC []; EXISTS_TAC `inf(IMAGE f {n:num | f n < -- &1})` THEN ASSUME_TAC (ISPECL [`f:num->real`] o1_lower_1_nonempty_image) THEN ASSUME_TAC (ISPECL [`IMAGE f {n:num | f n < -- &1}`] INF_FINITE) THEN ASSUME_TAC (ISPECL [`f:num->real`; `{n:num | f n < -- &1}`] FINITE_IMAGE) THEN ASSUME_TAC (ISPECL [`f:num->real`; `inf(IMAGE f {n:num | f n < -- &1})`] in_image_rewrite) THEN ASM_MESON_TAC []]);; let o1_lower_1_bound_lemma2 = prove(` !f:num->real L:real. (!n. f n < -- &1 ==> L <= f n) ==> ?M:real. M <= -- &1 /\ (!n. M <= f n) `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `L <= -- &1` THENL [EXISTS_TAC `L:real` THEN ASM_MESON_TAC [REAL_NOT_LT; REAL_LE_TRANS]; EXISTS_TAC `-- &1:real` THEN ASM_MESON_TAC [REAL_NOT_LT; REAL_NOT_LE; REAL_LTE_TRANS; REAL_LT_IMP_LE; REAL_LE_REFL]]);; let o1_lower_bound = prove(` !f:num->real. FINITE {n | f n < -- &1} ==> ?L. L <= -- &1 /\ !n. L <= f n `, MESON_TAC [o1_lower_1_bound_lemma; o1_lower_1_bound_lemma2]);; let o1_lower_fn_in_Tn = prove(` !f:num->real n. f n IN ({&0} UNION (IMAGE f {x | n <= x})) `, REWRITE_TAC [UNION] THEN REWRITE_TAC [IMAGE] THEN REWRITE_TAC [IN_ELIM_THM] THEN ASM_MESON_TAC [LE_REFL]);; let o1_lower_Tn_bound = prove(` !f:num->real L:real n:num x:real. L <= -- &1 /\ (!n. L <= f n) /\ (x IN ({&0} UNION (IMAGE f {x | n <= x}))) ==> L <= x `, REWRITE_TAC [UNION] THEN REWRITE_TAC [IMAGE] THEN REWRITE_TAC [GSYM SING_GSPEC] THEN REWRITE_TAC [IN_ELIM_THM] THEN MESON_TAC [REAL_ARITH `-- &1 <= &0`; REAL_LE_TRANS]);; let o1_lower_gn_le_fn = prove(` !f:num->real L:real. L <= -- &1 /\ (!n. L <= f n) ==> !n. inf ({&0} UNION (IMAGE f {x | n <= x})) <= f(n) `, MESON_TAC [INF; singleton_union_not_empty; o1_lower_fn_in_Tn; o1_lower_Tn_bound]);; let o1_lower_gn_le_fn_2 = prove(` !f:num->real. (!e:real. &0 < e ==> FINITE {n | f n < --e}) ==> !n. inf ({&0} UNION (IMAGE f {x | n <= x})) <= f(n) `, MESON_TAC [o1_lower_gn_le_fn; o1_lower_bound; REAL_ARITH `&0 < &1`]);; let o1_lower_0_in_Tn = prove(` !f:num->real n:num. &0 IN ({&0} UNION (IMAGE f {x | n <= x})) `, MESON_TAC [IN_SING; IN_UNION]);; let o1_lower_Tn_nonempty = prove(` !f:num->real n:num. ~({&0} UNION (IMAGE f {x | n <= x}) = {}) `, MESON_TAC [o1_lower_0_in_Tn; element_implies_nonempty2]);; let o1_lower_gn_le_0 = prove(` !f:num->real L:real. L <= -- &1 /\ (!n. L <= f n) ==> !n. inf ({&0} UNION (IMAGE f {x | n <= x})) <= &0 `, MESON_TAC [INF; singleton_union_not_empty; o1_lower_fn_in_Tn; o1_lower_Tn_bound; o1_lower_0_in_Tn]);; let o1_lower_gn_le_0_2 = prove(` !f:num->real. (!e:real. &0 < e ==> FINITE {n | f n < --e}) ==> !n. inf ({&0} UNION (IMAGE f {x | n <= x})) <= &0 `, MESON_TAC [o1_lower_gn_le_0; o1_lower_bound; REAL_ARITH `&0 < &1`]);; let o1_lower_above_minuse = prove(` !f:num->real e:real a:num n:num y:real. &0 < e /\ SUC a <= n /\ (!x. f x < --e ==> x <= a) /\ y IN ({&0} UNION (IMAGE f {x | n <= x})) ==> --e <= y `, REWRITE_TAC [GSYM SING_GSPEC] THEN REWRITE_TAC [IMAGE] THEN REWRITE_TAC [UNION] THEN REWRITE_TAC [IN_ELIM_THM] THEN MESON_TAC [REAL_ARITH `&0 < e ==> --e <= &0`; REAL_NOT_LT; ARITH_RULE `x <= a /\ SUC a <= n ==> ~(n <= x)`]);; let o1_lower_above_something = prove(` !f:num->real e:real a:num n:num. &0 < e /\ SUC a <= n /\ (!x. f x < --e ==> x <= a) ==> ?b:real. !y:real. y IN ({&0} UNION (IMAGE f {x | n <= x})) ==> b <= y `, REPEAT STRIP_TAC THEN EXISTS_TAC `--e:real` THEN ASM_MESON_TAC [o1_lower_above_minuse]);; let o1_lower_gn_above_minuse = prove(` !f:num->real e:real a:num n:num. &0 < e /\ SUC a <= n /\ (!x. f x < --e ==> x <= a) ==> --e <= inf ({&0} UNION (IMAGE f {x | n <= x})) `, STRIP_TAC THEN STRIP_TAC THEN STRIP_TAC THEN STRIP_TAC THEN STRIP_TAC THEN ASSUME_TAC (ISPECL [`f:num->real`; `e:real`; `a:num`; `n:num`] o1_lower_above_something) THEN ASSUME_TAC (ISPECL [`f:num->real`; `n:num`] o1_lower_Tn_nonempty) THEN ASSUME_TAC (ISPECL [`({&0:real} UNION (IMAGE (f:num->real) {x | n <= x}))`] INF) THEN ASSUME_TAC (ISPECL [`f:num->real`; `e:real`; `a:num`; `n:num`] o1_lower_above_minuse) THEN ASM_MESON_TAC []);; let o1_lower_gn_above_minuse_2 = prove(` !f:num->real e:real L:real. &0 < e /\ FINITE {n | f n < --e} ==> ?m. !n. m <= n ==> --e <= inf ({&0} UNION (IMAGE f {x | n <= x})) `, REWRITE_TAC [num_FINITE] THEN REWRITE_TAC [IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN EXISTS_TAC `SUC a` THEN ASM_MESON_TAC [o1_lower_gn_above_minuse]);; let o1_lower_gn_above_minuse_3 = prove(` !f:num->real e:real L:real. &0 < e /\ FINITE {n | f n < --e} /\ L <= -- &1 /\ (!n. L <= f n) ==> ?m. !n. m <= n ==> abs(inf ({&0} UNION (IMAGE f {x | n <= x}))) <= e `, MESON_TAC [REAL_ARITH `--e <= x /\ x <= &0 ==> abs(x) <= e`; o1_lower_gn_le_0; o1_lower_gn_above_minuse_2]);; let o1_lower_gn_o1 = prove(` !f:num->real. (!e:real. &0 < e ==> FINITE {n | f n < --e}) ==> o1_seq (\n. inf ({&0} UNION (IMAGE f {x | n <= x }))) `, REWRITE_TAC [o1_seq] THEN MESON_TAC [o1_lower_gn_above_minuse_3; o1_lower_bound; REAL_ARITH `&0 < &1`]);; let o1_lower_main = prove(` !f:num->real. (!e:real. &0 < e ==> FINITE {n | f n < --e}) ==> ?g:num->real. (!n. g n <= f n) /\ (!n. g n <= &0) /\ o1_seq g `, REPEAT STRIP_TAC THEN EXISTS_TAC `\n:num. inf ({&0:real} UNION (IMAGE (f:num->real) {x | n <= x}))` THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [o1_lower_gn_le_0_2; o1_lower_gn_le_fn_2; o1_lower_gn_o1] THEN ASSUME_TAC (ISPECL [`f:num->real`] o1_lower_gn_le_fn_2) THEN ASSUME_TAC (ISPECL [`f:num->real`] o1_lower_gn_le_0_2) THEN ASSUME_TAC (ISPECL [`f:num->real`] o1_lower_gn_o1) THEN ASM_MESON_TAC []);; let lnexp2pibound2 = prove(` !x. &60 <= x ==> ln(&2 * pi * exp(&2)) < ln x `, MESON_TAC [ln_mono_le; REAL_ARITH `&0 < &60`; lnexp2pibound; REAL_LTE_TRANS]);; let ln60bound = prove(` !x. &60 <= x ==> &1 < ln x - ln(&2 * pi * exp(&1)) `, MESON_TAC [lnexp2pibound2; lnexp1piexp2pi; REAL_ARITH `&1 + a < b ==> &1 < b - a`]);; let pi60bound = prove(` !x. &60 <= x ==> pi * &60 <= pi * x `, MESON_TAC [REAL_LE_LMUL; PI_POS; REAL_LT_IMP_LE]);; let pi60bound3 = prove(` !x. &60 <= x ==> (&333 / &106) * &60 < pi * x `, MESON_TAC [pi60bound; pi60bound2; REAL_LTE_TRANS]);; let pi60bound4 = prove(` !x. &60 <= x ==> &1 < pi * x `, MESON_TAC [pi60bound3; REAL_ARITH `&1 < (&333 / &106) * &60`; REAL_LT_TRANS]);; let pi60bound5 = prove(` !x. &60 <= x ==> ln(&1) < ln(pi * x) `, MESON_TAC [pi60bound4; ln_mono_lt; REAL_ARITH `&0 < &1`]);; let pi60bound6 = prove(` !x. &60 <= x ==> &0 < ln(pi * x) `, MESON_TAC [pi60bound5; LN_1]);; let pi60bound7 = prove(` !x. &60 <= x ==> &0 < ln(pi * x) / x `, MESON_TAC [pi60bound6; REAL_LT_DIV; REAL_ARITH `&60 <= x ==> &0 < x`]);; let deltabound = prove(` !x. &60 <= x ==> &1 < ln x + ln(pi * x) / x - ln(&2 * pi * exp(&1)) `, MESON_TAC [ln60bound; pi60bound7; REAL_ARITH `&0 < a /\ &1 < b - c ==> &1 < b + a - c`]);; let deltabound2 = prove(` !x. &60 <= x ==> &0 < ln x + ln(pi * x) / x - ln(&2 * pi * exp(&1)) `, MESON_TAC [deltabound; REAL_ARITH `&1 < a ==> &0 < a`]);; let deltabound3 = prove(` !x. &60 <= x ==> &0 < (ln x + ln(pi * x) / x - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [deltabound2; REAL_ARITH `&60 <= x ==> &0 < &2 * (x - &1)`; REAL_LT_DIV]);; let deltabound4 = prove(` !x. &60 <= x ==> &0 < ln(bkzdelta x) `, MESON_TAC [bkzdelta_ln5; deltabound3]);; let deltabound5 = prove(` !x. &60 <= x ==> &1 < bkzdelta x `, MESON_TAC [deltabound4; LN_1; LN_MONO_LT; REAL_ARITH `&0 < &1`; bkzdelta_pos]);; let deltabound6 = prove(` !x. &60 <= x ==> &1 / (&2 * (x - &1)) < (ln(x) + ln(pi*x) / x - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `, MESON_TAC [deltabound; REAL_ARITH `&60 <= x ==> &0 < &2 * (x - &1)`; REAL_LT_DIV2_EQ]);; let bkzdelta_ln6 = prove(` !x. &60 <= x ==> &1 / (&2 * (x - &1)) < ln(bkzdelta x) `, MESON_TAC [deltabound6; bkzdelta_ln5]);; let bkzdelta_ln7 = prove(` !x. &60 <= x ==> &1 / (x - &1) < &2 * ln(bkzdelta x) `, MESON_TAC [bkzdelta_ln6; REAL_FIELD `&1 / (&2 * x) < y ==> &1 / x < &2 * y`]);; let bkzdelta_ln8 = prove(` !x. &60 <= x ==> ln(bkzdelta x) * (&2 * (x - &1)) = ln(x) + ln(pi*x)/x - ln(&2 * pi * exp(&1)) `, MESON_TAC [bkzdelta_ln5; REAL_DIV_RMUL; REAL_ARITH `&60 <= x ==> ~(&2 * (x - &1) = &0)`]);; let xx1_step1 = REAL_ARITH ` (x - &1)*(x + &1) < x pow 2 `;; let x2_positive = prove(` !x. &60 <= x ==> &0 < x pow 2 `, MESON_TAC [REAL_LT_MUL; REAL_ARITH `&60 <= x ==> &0 < x`; REAL_ARITH `x * x = x pow 2`]);; let xx1_step2 = prove(` !x. &60 <= x ==> ((x - &1)*(x + &1))/(x pow 2) < &1 `, MESON_TAC [REAL_LT_LDIV_EQ; x2_positive; xx1_step1; REAL_ARITH `&1 * (x pow 2) = x pow 2`]);; let xx1_step3 = prove(` !x. &60 <= x ==> ((x + &1)/(x pow 2))*(x - &1) < &1 `, MESON_TAC [xx1_step2; REAL_ARITH `(a*b)/c = (b/c)*a`]);; let xx1_step4 = prove(` !x. &60 <= x ==> (x + &1)/(x pow 2) < &1/(x - &1) `, MESON_TAC [REAL_LT_RDIV_EQ; REAL_ARITH `&60 <= x ==> &0 < x - &1`; xx1_step3]);; let xx1_step5 = prove(` !x. &60 <= x ==> (x + &1)/(x pow 2) < &2 * ln(bkzdelta x) `, MESON_TAC [bkzdelta_ln7; xx1_step4; REAL_LT_TRANS]);; let delta_deriv = DIFF_CONV ` \x. (ln(x) + ln(pi*x)/x - ln(&2 * pi * exp(&1))) / (&2 * (x - &1)) `;; let delta_nonzero_2x1 = REAL_ARITH ` !x. &60 <= x ==> ~(&2 * (x - &1) = &0) `;; let delta_nonzero_x = REAL_ARITH ` !x. &60 <= x ==> ~(x = &0) `;; let delta_sign_x = REAL_ARITH ` !x. &60 <= x ==> &0 < x `;; let delta_sign_pix = prove(` !x. &60 <= x ==> &0 < pi * x `, MESON_TAC [delta_sign_x; PI_POS; REAL_LT_MUL]);; let delta_deriv2 = prove(` !x. &60 <= x ==> ((\x. (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) / (&2 * (x - &1))) diffl ((inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / (&2 * (x - &1)) pow 2) x `, MESON_TAC [delta_deriv; delta_nonzero_2x1; delta_nonzero_x; delta_sign_x; delta_sign_pix]);; let sign_lnpixx2 = prove(` !x. &60 <= x ==> &0 < ln(pi*x)/(x pow 2) `, MESON_TAC [pi60bound6; REAL_LT_DIV; x2_positive]);; let xx1_step6 = prove(` !x. &60 <= x ==> (x + &1)/(x pow 2) - ln(pi*x)/(x pow 2) < &2 * ln(bkzdelta x) `, MESON_TAC [sign_lnpixx2; xx1_step5; REAL_ARITH `a < b /\ &0 < c ==> a - c < b`]);; let xx1_step7 = prove(` !x. &60 <= x ==> ((x + &1)/(x pow 2) - ln(pi*x)/(x pow 2)) * &2 * (x - &1) < (&2 * ln(bkzdelta x)) * &2 * (x - &1) `, MESON_TAC [xx1_step6; REAL_LT_RMUL; REAL_ARITH `&60 <= x ==> &0 < &2 * (x - &1)`]);; let xx1_step8 = prove(` !x. &60 <= x ==> (&2 * ln(bkzdelta x)) * &2 * (x - &1) = (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) `, SIMP_TAC [bkzdelta_ln5] THEN CONV_TAC REAL_FIELD);; let xx1_step9 = prove(` !x. &60 <= x ==> ((x + &1)/(x pow 2) - ln(pi*x)/(x pow 2)) * &2 * (x - &1) < (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) `, MESON_TAC [xx1_step7; xx1_step8]);; let xx1_step10 = REAL_FIELD ` !x. &60 <= x /\ &0 < pi ==> ((x + &1)/(x pow 2) - ln(pi*x)/(x pow 2)) * &2 * (x - &1) = (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) `;; let xx1_step11 = prove(` !x. &60 <= x ==> (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) < (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) `, MESON_TAC [xx1_step9; xx1_step10; PI_POS]);; let xx1_step12 = prove(` !x. &60 <= x ==> (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) < &0 `, MESON_TAC [xx1_step11; REAL_ARITH `x < y ==> x - y < &0`]);; let delta_sign_denom = prove(` !x. &60 <= x ==> &0 < (&2 * (x - &1)) pow 2 `, MESON_TAC [REAL_ARITH `&60 <= x ==> &0 < &2 * (x - &1)`; REAL_LT_MUL; REAL_POW_2]);; let delta_deriv_negative = prove(` !x. &60 <= x ==> ( (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / ((&2 * (x - &1)) pow 2) < &0 `, MESON_TAC [xx1_step12; delta_sign_denom; neg_over_pos]);; let delta_decreasing = prove(` !a b. &60 <= a /\ a <= b ==> (\x. (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) / (&2 * (x - &1)))(b) <= (\x. (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1))) / (&2 * (x - &1)))(a) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC deriv_negative4 THEN EXISTS_TAC `\x. ( (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / ((&2 * (x - &1)) pow 2)` THEN REWRITE_TAC [BETA_THM] THEN CONJ_TAC THEN REPEAT STRIP_TAC THEN ASSUME_TAC (REAL_ARITH `&60 <= a /\ a <= x ==> &60 <= x`) THENL [ASM_REWRITE_TAC []; ASSUME_TAC (ISPECL [`x:real`] delta_deriv2) THEN ASM_MESON_TAC []; ASSUME_TAC (ISPECL [`x:real`] delta_deriv_negative) THEN ASM_MESON_TAC []]);; let rho_deriv = DIFF_CONV ` \x. (&1 / &2) * ln((n + k)*(s pow 2) + &1) - ((&1 / &2) * ln((n + k + &1)/x) + (ln(x) + (&1 / x) * ln(pi*x) - ln(&2 * pi * exp(&1))) * ( (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1))) + (k/(n + k + &1)) * ln q) `;; let rho_deriv2_lemma = REAL_ARITH ` !n k. &1 < n /\ &0 < k ==> &0 < n + k + &1 `;; let rho_deriv2_lemma2 = prove(` !n k x. &60 <= x /\ &1 < n /\ &0 < k ==> &0 < (n + k + &1) / x `, MESON_TAC [rho_deriv2_lemma; delta_sign_x; REAL_LT_DIV]);; let rho_deriv2 = prove(` !n q s k x. &60 <= x /\ &1 < n /\ &0 < k ==> ((\x. &1 / &2 * ln ((n + k) * s pow 2 + &1) - (&1 / &2 * ln ((n + k + &1) / x) + (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1))) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + k / (n + k + &1) * ln q)) diffl &0 - ((&0 * ln ((n + k + &1) / x) + (inv ((n + k + &1) / x) * (&0 * x - &1 * (n + k + &1)) / x pow 2) * &1 / &2) + ((inv x * &1 + ((&0 * x - &1 * &1) / x pow 2 * ln (pi * x) + (inv (pi * x) * (&0 * x + &1 * pi)) * &1 / x) - &0) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + (((&0 * x + &1 * &2) - &0 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (&2 * x - (n + k + &1) - &1)) / (&2 * (x - &1)) pow 2 * (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1)))) + &0)) x `, MESON_TAC [rho_deriv; delta_sign_x; delta_sign_pix; delta_nonzero_x; delta_nonzero_2x1; rho_deriv2_lemma2]);; let lnpix_deriv = DIFF_CONV ` \x. ln(pi*x)-x / &2 `;; let lnpix_deriv2 = prove(` !x. &60 <= x ==> &1 / x - &1 / &2 < &0 `, MESON_TAC [REAL_LE_INV2; REAL_ARITH `&0 < &60`; REAL_ARITH `inv x <= inv(&60) ==> &1 / x - &1 / &2 < &0`]);; let lnpix_deriv3 = REAL_FIELD ` ~(x = &0) /\ &0 < pi ==> &1 / x - &1 / &2 = inv (pi * x) * (&0 * x + &1 * pi) - (&1 * &2 - &0 * x) / &2 pow 2 `;; let lnpix_deriv4 = prove(` !x. &60 <= x ==> inv (pi * x) * (&0 * x + &1 * pi) - (&1 * &2 - &0 * x) / &2 pow 2 < &0 `, MESON_TAC [lnpix_deriv3; lnpix_deriv2; PI_POS; REAL_ARITH `&60 <= x ==> ~(x = &0)`]);; let lnpix_decreasing = prove(` !a b. &60 <= a /\ a <= b ==> (\x. ln(pi*x)-x / &2)(b) <= (\x. ln(pi*x)-x / &2)(a) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC deriv_negative4 THEN EXISTS_TAC `\x. inv (pi * x) * (&0 * x + &1 * pi) - (&1 * &2 - &0 * x) / &2 pow 2` THEN REWRITE_TAC [BETA_THM] THEN CONJ_TAC THEN REPEAT STRIP_TAC THEN ASSUME_TAC (REAL_ARITH `~(&2 = &0)`) THEN ASSUME_TAC (pi60bound4) THEN ASSUME_TAC (REAL_ARITH `&1 < pi * x ==> &0 < pi * x`) THEN ASSUME_TAC (REAL_ARITH `&60 <= a /\ a <= x ==> &60 <= x`) THENL [ASM_REWRITE_TAC []; ASSUME_TAC (ISPECL [`x:real`] lnpix_deriv) THEN ASM_MESON_TAC []; ASSUME_TAC (ISPECL [`x:real`] lnpix_deriv4) THEN ASM_MESON_TAC []]);; let lnpix_decreasing2 = prove(` !a b. &60 <= a /\ a <= b ==> ln(pi*b)-b / &2 <= ln(pi*a)-a / &2 `, MESON_TAC [lnpix_decreasing; BETA_THM]);; let lnpix_decreasing3 = prove(` !b. &60 <= b ==> ln(pi*b)-b / &2 <= ln(pi* &60)- &60 / &2 `, MESON_TAC [lnpix_decreasing2; REAL_ARITH `&60 <= &60`]);; let lnpix_negative = prove(` !b. &60 <= b ==> ln(pi*b)-b / &2 < &0 `, MESON_TAC [lnpix_decreasing3; lnpi60; REAL_LET_TRANS]);; let lnpix_negative2 = prove(` !x. &60 <= x ==> (ln(pi*x) - x / &2) / x pow 2 < &0 `, MESON_TAC [neg_over_pos; x2_positive; lnpix_negative]);; let lnpix_negative3 = prove(` !x. &60 <= x ==> ln(pi*x) / x pow 2 - &1 / (&2 * x) < &0 `, MESON_TAC [lnpix_negative2; REAL_FIELD `&60 <= x ==> (ln(pi*x) - x / &2) / x pow 2 = ln(pi*x) / x pow 2 - &1 / (&2 * x)`]);; let overx2_positive = prove(` !x. &60 <= x ==> &0 < inv(x pow 2) `, MESON_TAC [x2_positive; REAL_LT_INV; REAL_ARITH `&60 <= x ==> &0 < x`]);; let nkdelta_deriv_negative = prove(` !n k x. &60 <= x /\ &1 < n /\ &0 < k ==> (n + k) * ( (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / ((&2 * (x - &1)) pow 2) < &0 `, MESON_TAC [delta_deriv_negative; REAL_ARITH `&1 < n /\ &0 < k ==> &0 < n+k`; pos_times_neg]);; let rho_deriv_negative = prove(` !n k x. &60 <= x /\ &1 < n /\ &0 < k ==> ( (ln(pi*x) / x pow 2 - &1 / (&2 * x)) - inv(x pow 2) + (n + k) * ( (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / ((&2 * (x - &1)) pow 2) ) < &0 `, MESON_TAC [lnpix_negative3; overx2_positive; nkdelta_deriv_negative; REAL_ARITH `a < &0 /\ &0 < b /\ c < &0 ==> a - b + c < &0`]);; let rho_deriv_mess = REAL_FIELD ` !n k x. ~(x = &0) /\ ~(n + k + &1 = &0) /\ &0 < pi /\ ~(x - &1 = &0) ==> (ln(pi*x) / x pow 2 - &1 / (&2 * x)) - inv(x pow 2) + (n + k) * ( (inv x * &1 + ((inv (pi * x) * (&0 * x + &1 * pi)) * x - &1 * ln (pi * x)) / x pow 2 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (ln x + ln (pi * x) / x - ln (&2 * pi * exp (&1)))) / ((&2 * (x - &1)) pow 2) = &0 - ((&0 * ln ((n + k + &1) / x) + (inv ((n + k + &1) / x) * (&0 * x - &1 * (n + k + &1)) / x pow 2) * &1 / &2) + ((inv x * &1 + ((&0 * x - &1 * &1) / x pow 2 * ln (pi * x) + (inv (pi * x) * (&0 * x + &1 * pi)) * &1 / x) - &0) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + (((&0 * x + &1 * &2) - &0 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (&2 * x - (n + k + &1) - &1)) / (&2 * (x - &1)) pow 2 * (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1)))) + &0) `;; let rho_deriv_negative2 = prove(` !n k x. &60 <= x /\ &1 < n /\ &0 < k ==> &0 - ((&0 * ln ((n + k + &1) / x) + (inv ((n + k + &1) / x) * (&0 * x - &1 * (n + k + &1)) / x pow 2) * &1 / &2) + ((inv x * &1 + ((&0 * x - &1 * &1) / x pow 2 * ln (pi * x) + (inv (pi * x) * (&0 * x + &1 * pi)) * &1 / x) - &0) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + (((&0 * x + &1 * &2) - &0 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (&2 * x - (n + k + &1) - &1)) / (&2 * (x - &1)) pow 2 * (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1)))) + &0) < &0 `, MESON_TAC [rho_deriv_mess; rho_deriv_negative; REAL_ARITH `&60 <= x ==> ~(x = &0)`; REAL_ARITH `&1 < n /\ &0 < k ==> ~(n + k + &1 = &0)`; PI_POS; REAL_ARITH `&60 <= x ==> ~(x - &1 = &0)`]);; let rho_decreasing = prove(` !n k a b. &60 <= a /\ a <= b /\ &1 < n /\ &0 < k ==> (\x. &1 / &2 * ln ((n + k) * s pow 2 + &1) - (&1 / &2 * ln ((n + k + &1) / x) + (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1))) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + k / (n + k + &1) * ln q)) (b) <= (\x. &1 / &2 * ln ((n + k) * s pow 2 + &1) - (&1 / &2 * ln ((n + k + &1) / x) + (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1))) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + k / (n + k + &1) * ln q)) (a) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC deriv_negative4 THEN EXISTS_TAC `\x. &0 - ((&0 * ln ((n + k + &1) / x) + (inv ((n + k + &1) / x) * (&0 * x - &1 * (n + k + &1)) / x pow 2) * &1 / &2) + ((inv x * &1 + ((&0 * x - &1 * &1) / x pow 2 * ln (pi * x) + (inv (pi * x) * (&0 * x + &1 * pi)) * &1 / x) - &0) * (&2 * x - (n + k + &1) - &1) / (&2 * (x - &1)) + (((&0 * x + &1 * &2) - &0 - &0) * &2 * (x - &1) - (&0 * (x - &1) + (&1 - &0) * &2) * (&2 * x - (n + k + &1) - &1)) / (&2 * (x - &1)) pow 2 * (ln x + &1 / x * ln (pi * x) - ln (&2 * pi * exp (&1)))) + &0)` THEN REWRITE_TAC [BETA_THM] THEN CONJ_TAC THEN REPEAT STRIP_TAC THEN ASSUME_TAC (REAL_ARITH `&60 <= a /\ a <= x ==> &60 <= x`) THENL [ASM_REWRITE_TAC []; ASSUME_TAC (ISPECL [`n:real`; `q:real`; `s:real`; `k:real`; `x:real`] rho_deriv2) THEN ASM_MESON_TAC []; ASSUME_TAC (ISPECL [`n:real`; `k:real`; `x:real`] rho_deriv_negative2) THEN ASM_MESON_TAC []]);; let rho_decreasing2 = prove(` !n k a b. &60 <= a /\ a <= b /\ &1 < n /\ &0 < k ==> (&1 / &2 * ln ((n + k) * s pow 2 + &1) - (&1 / &2 * ln ((n + k + &1) / b) + (ln b + &1 / b * ln (pi * b) - ln (&2 * pi * exp (&1))) * (&2 * b - (n + k + &1) - &1) / (&2 * (b - &1)) + k / (n + k + &1) * ln q)) <= (&1 / &2 * ln ((n + k) * s pow 2 + &1) - (&1 / &2 * ln ((n + k + &1) / a) + (ln a + &1 / a * ln (pi * a) - ln (&2 * pi * exp (&1))) * (&2 * a - (n + k + &1) - &1) / (&2 * (a - &1)) + k / (n + k + &1) * ln q)) `, MESON_TAC [rho_decreasing]);; let rho_decreasing3 = prove(` !n k a b. &60 <= a /\ a <= b /\ &1 < n /\ &0 < k ==> ln(standardratio n q s k b) <= ln(standardratio n q s k a) `, MESON_TAC [rho_decreasing2; standardratio_ln4; REAL_ARITH `&60 <= a /\ a <= b ==> &60 <= b`]);; let rho_decreasing4 = prove(` !n k a b. &60 <= a /\ a <= b /\ &1 < n /\ &0 < k ==> standardratio n q s k b <= standardratio n q s k a `, MESON_TAC [rho_decreasing3; LN_MONO_LE; standardratio_positive]);; let sqrtprod_nonneg = prove(` !x y. &0 <= (sqrt x - sqrt y) pow 2 `, MESON_TAC [REAL_LE_POW_2]);; let sqrtprod_pow2 = REAL_ARITH ` !x y. (sqrt x - sqrt y) pow 2 = (sqrt x) pow 2 + (sqrt y) pow 2 - &2 * sqrt x * sqrt y `;; let sqrtprod_pow2_simplify = prove(` !x y. &0 <= x /\ &0 <= y ==> (sqrt x - sqrt y) pow 2 = x + y - &2 * sqrt(x*y) `, MESON_TAC [sqrtprod_pow2; SQRT_POW_2; SQRT_MUL]);; let sqrtprod_nonneg2 = prove(` !x y. &0 <= x /\ &0 <= y ==> &0 <= x + y - &2 * sqrt(x*y) `, MESON_TAC [sqrtprod_nonneg; sqrtprod_pow2_simplify]);; let sqrtprod_le = prove(` !x y. &0 <= x /\ &0 <= y ==> &2 * sqrt(x*y) <= x + y `, MESON_TAC [sqrtprod_nonneg2; REAL_ARITH `!a b c. &0 <= a + b - c ==> c <= a + b`]);; let kappa_main_sqrt_le = prove(` !n k D Q. ~(n + k + &1 = &0) /\ &0 <= D*(n + k + &1) /\ &0 <= Q*(n + &1)/(n + k + &1) ==> &2 * sqrt((n + &1)*D*Q) <= D*(n + k + &1) + Q*(n + &1)/(n + k + &1) `, MESON_TAC [sqrtprod_le; REAL_FIELD `!n k D Q. ~(n + k + &1 = &0) ==> (D*(n + k + &1))*(Q*(n + &1)/(n + k + &1)) = (n + &1)*D*Q`]);; let kappa_main_reshuffle = REAL_FIELD ` !n k b D Q. ~(n + k + &1 = &0) /\ &2 * sqrt((n + &1)*D*Q) <= D*(n + k + &1) + Q*(n + &1)/(n + k + &1) ==> (&2 * b - n - k - &2)*D + (k / (n + k + &1))*Q <= (&2 * b - &1)*D + (Q*(n + &1)/(n + k + &1) + (k / (n + k + &1))*Q) - &2 * sqrt((n + &1)*D*Q) `;; let kappa_main_reshuffle2 = prove(` !n k b D Q. ~(n + k + &1 = &0) /\ &2 * sqrt((n + &1)*D*Q) <= D*(n + k + &1) + Q*(n + &1)/(n + k + &1) ==> (&2 * b - n - k - &2)*D + (k / (n + k + &1))*Q <= (&2 * b - &1)*D + Q - &2 * sqrt((n + &1)*D*Q) `, REPEAT STRIP_TAC THEN ASSUME_TAC (REAL_FIELD `~(n + k + &1 = &0) ==> Q*(n + &1)/(n + k + &1) + (k / (n + k + &1))*Q = Q`) THEN ASM_MESON_TAC [kappa_main_reshuffle]);; let kappa_main_reshuffle3 = prove(` !n k b D Q. ~(n + k + &1 = &0) /\ &0 <= D*(n + k + &1) /\ &0 <= Q*(n + &1)/(n + k + &1) ==> (&2 * b - n - k - &2)*D + (k / (n + k + &1))*Q <= (&2 * b - &1)*D + Q - &2 * sqrt((n + &1)*D*Q) `, MESON_TAC [kappa_main_sqrt_le; kappa_main_reshuffle2]);; let kappa_n1pos = REAL_ARITH ` !n. &1 < n ==> &0 < n + &1 `;; let kappa_nk1nonzero = REAL_ARITH ` !n k. &1 < n /\ &0 < k ==> ~(n + k + &1 = &0) `;; let kappa_nk1pos = REAL_ARITH ` !n k. &1 < n /\ &0 < k ==> &0 < n + k + &1 `;; let kappa_Dnk1pos = prove(` !n k D. &1 < n /\ &0 < k /\ &0 <= D ==> &0 <= D*(n + k + &1) `, MESON_TAC [kappa_nk1pos; REAL_LE_MUL_EQ]);; let kappa_nk1ratiopos = prove(` !n k. &1 < n /\ &0 < k ==> &0 < (n + &1)/(n + k + &1) `, MESON_TAC [kappa_n1pos; kappa_nk1pos; REAL_LT_DIV]);; let kappa_Qnk1ratiopos = prove(` !n k Q. &1 < n /\ &0 < k /\ &0 < Q ==> &0 <= Q*(n + &1)/(n + k + &1) `, MESON_TAC [kappa_nk1ratiopos; REAL_LT_MUL; REAL_LT_IMP_LE]);; let kappa_main_reshuffle4 = prove(` !n k b D Q. &1 < n /\ &0 < Q /\ &0 <= D /\ &0 < k ==> (&2 * b - n - k - &2)*D + (k / (n + k + &1))*Q <= (&2 * b - &1)*D + Q - &2 * sqrt((n + &1)*D*Q) `, MESON_TAC [kappa_nk1nonzero; kappa_Dnk1pos; kappa_Qnk1ratiopos; kappa_main_reshuffle3]);; let kappa_main = prove(` !n k b d q. &1 < n /\ &1 < q /\ &1 <= d /\ &0 < k ==> (&2 * b - n - k - &2)*log2 d + (k / (n + k + &1))*log2 q <= (&2 * b - &1)*log2 d + log2 q - &2 * sqrt((n + &1)*log2 d*log2 q) `, MESON_TAC [kappa_main_reshuffle4; log2_gt1; log2_ge1]);; let asymp2_2B1D_lemma = prove(` !N:num->real B:num->real Y0:real Y1:real twopie:real. (!i. &1 < N(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. ((((&1)/(N(i))) - (&0)) * log2(N(i))) - (&0)) /\ o1_seq (\i:num. ((((B(i))/(N(i))) - (Y0)) * log2(N(i))) - (Y1)) /\ &0 < ((&2)*(Y0))-((&2)*(&0)) /\ (!i:num. &0 < ((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))) /\ ~(((&2)*(Y0))-((&2)*(&0)) = &0) /\ &0 < Y0 /\ (!i:num. &0 < (B(i))/(N(i))) /\ ~(Y0 = &0) /\ &0 < (pi)*(Y0) /\ &0 < twopie ==> o1_seq (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))) * log2(N(i))) - ((((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))))))+((((((&2)*(Y0))-(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((((&2)*(Y1))+((&0)*(Y0)))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))))) `, REPEAT STRIP_TAC THEN specialize [`\i:num. N(i):real`; `&2:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (&2)*((B(i))/(N(i))):real`; `(&2)*(Y0):real`; `((&2)*(Y1))+((&0)*(Y0)):real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`] asymp2_sub THEN specialize [`\i:num. N(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (&2)*((B(i))/(N(i))):real`; `(&2)*(Y0):real`; `((&2)*(Y1))+((&0)*(Y0)):real`; `\i:num. (&2)*((&1)/(N(i))):real`; `(&2)*(&0):real`; `((&2)*(&0))+((&0)*(&0)):real`] asymp2_sub THEN specialize [`\i:num. N(i):real`; `\i:num. ((&2)*((B(i))/(N(i))))-((&1)/(N(i))):real`; `((&2)*(Y0))-(&0):real`; `(((&2)*(Y1))+((&0)*(Y0)))-(&0):real`; `\i:num. ((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i)))):real`; `((&2)*(Y0))-((&2)*(&0)):real`; `(((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0))):real`] asymp2_div THEN specialize [`\i:num. N(i):real`; `&1:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_div THEN specialize [`\i:num. N(i):real`; `pi:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. pi:real`; `pi:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (pi)*((B(i))/(N(i))):real`; `(pi)*(Y0):real`; `((pi)*(Y1))+((&0)*(Y0)):real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. log2((pi)*((B(i))/(N(i))))/log2(N(i)):real`; `&0:real`; `log2((pi)*(Y0)):real`; `\i:num. &1:real`; `&1:real`; `&0:real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)/((B(i))/(N(i))):real`; `(&1)*((&1)/(Y0)):real`; `((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))):real`; `\i:num. (log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1):real`; `(&0)+(&1):real`; `(log2((pi)*(Y0)))+(&0):real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`; `\i:num. ((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1)):real`; `((&1)*((&1)/(Y0)))*((&0)+(&1)):real`; `(((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1))):real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `twopie:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. twopie:real`; `twopie:real`; `&0:real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. ((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))):real`; `(&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))):real`; `((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))):real`; `\i:num. log2(twopie)/log2(N(i)):real`; `&0:real`; `log2(twopie):real`] asymp2_sub THEN specialize [`\i:num. N(i):real`; `\i:num. log2((B(i))/(N(i)))/log2(N(i)):real`; `&0:real`; `log2(Y0):real`; `\i:num. (((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))):real`; `((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0):real`; `(((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)):real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i)))):real`; `(&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)):real`; `(log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))):real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. (((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))):real`; `(((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))):real`; `((((&2)*(Y0))-(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((((&2)*(Y1))+((&0)*(Y0)))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))):real`; `\i:num. (&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))):real`; `(&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))):real`; `(&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))):real`] asymp2_mul THEN ASM_MESON_TAC []);; let asymp2_2B1D_simpler = prove(` !N:num->real B:num->real Y0:real Y1:real twopie:real. (!i. &1 < N(i)) /\ o1_seq (\i. &1 / N(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 /\ &0 < twopie ==> o1_seq (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - &1) * log2(N(i))) - (log2(Y0) - log2(twopie))) `, REPEAT STRIP_TAC THEN note `&0 < pi*Y0` [PI_POS; REAL_LT_MUL] THEN real_linear `&0 < Y0 ==> ~(Y0 = &0)` THEN real_linear `&0 < Y0 ==> ~(((&2)*(Y0))-((&2)*(&0)) = &0)` THEN real_linear `&0 < Y0 ==> &0 < ((&2)*(Y0))-((&2)*(&0))` THEN note `!i:num. &1 <= N(i)` [REAL_LT_IMP_LE] THEN note `!i:num. &0 < N(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < &2*(B(i) - &1)` [REAL_ARITH `&1 < b ==> &0 < &2 * (b - &1)`] THEN note `!i:num. &0 < (&2*(B(i) - &1))/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < (&2)*(B(i)/N(i))-(&2)*((&1)/N(i))` [REAL_FIELD `&1 < n ==> (&2*(b - &1))/n = (&2)*(b/n) - (&2)*(&1/n)`] THEN note `o1_seq (\i:num. log2(N(i))/N(i))` [o1_log2overlinear_1] THEN notetac `(\i:num. log2(N(i))/N(i)) = (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` (REWRITE_TAC [EQ_EXT; REAL_ARITH `x - &0 = x`; REAL_ARITH `(&1/x)*y = y/x`]) THEN note `o1_seq (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` [] THEN specialize [`N:num->real`; `B:num->real`; `Y0:real`; `Y1:real`; `twopie:real`] asymp2_2B1D_lemma THEN real_cancel `&0 < Y0 ==> log2(Y0) - log2(twopie) = ((((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))))))+((((((&2)*(Y0))-(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((((&2)*(Y1))+((&0)*(Y0)))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))))` THEN notetac `(\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))) * log2(N(i))) - (log2(Y0) - log2(twopie))) = (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))) * log2(N(i))) - ((((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))))))+((((((&2)*(Y0))-(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((((&2)*(Y1))+((&0)*(Y0)))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))))` (ASM_MESON_TAC [EQ_EXT]) THEN note `o1_seq (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))) * log2(N(i))) - (log2(Y0) - log2(twopie)))` [] THEN real_cancel `&0 < Y0 ==> &1 = (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))` THEN notetac `(\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - &1) * log2(N(i))) - (log2(Y0) - log2(twopie))) = (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))) - (((((&2)*(Y0))-(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)))))) * log2(N(i))) - (log2(Y0) - log2(twopie)))` (ASM_MESON_TAC [EQ_EXT]) THEN ASM_MESON_TAC []);; let asymp2_2B1D_lemma3 = prove(` !n:real x:real. &1 < n /\ &60 <= x ==> (&2 * x - &1) * log2(bkzdelta(x)) / log2(n) = (((((&2)*((x)/(n)))-((&1)/(n)))/(((&2)*((x)/(n)))-((&2)*((&1)/(n)))))*((&1)+((log2((x)/(n))/log2(n))+((((&1)/(n))*(((&1)/((x)/(n)))*((log2((pi)*((x)/(n)))/log2(n))+(&1))))-(log2(&2 * pi * exp(&1))/log2(n)))))) `, REPEAT STRIP_TAC THEN ASM_SIMP_TAC [log2ratio_lnratio] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> ((&2)*((x)/(n)))-((&1)/(n)) = (&2*x - &1)/n`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> &2 * x / n - &2 * &1 / n = (&2 * (x - &1)) / n`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> (a / n) / (b / n) = a / b`] THEN real_linear `&1 < n ==> &0 < n` THEN real_linear `&60 <= x ==> &0 < x` THEN ASM_SIMP_TAC [ln_div] THEN ASM_SIMP_TAC [ln_muldiv; PI_POS] THEN note `&0 < ln n` [ln_gt1] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln n ==> (ln pi + ln x - ln n) / ln n + &1 = (ln pi + ln x) / ln n`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < n ==> &1 / n * &1 / (x / n) * y = &1 / x * y`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln n ==> &1 + (ln x - ln n) / ln n + b * c / ln n - d / ln n = (ln x + b * c - d) / ln n`] THEN ASM_SIMP_TAC [REAL_ARITH `b / c * e / f = b * (e / c) / f`] THEN ASM_MESON_TAC [bkzdelta_ln4; LN_MUL; PI_POS]);; let asymp2_2B1D_lemma4 = prove(` !N:num->real B:num->real Y0:real. (!i. &1 < N(i)) /\ (!i. &60 <= B(i)) ==> (\i:num. (((&2 * B(i) - &1) * log2(bkzdelta(B(i))) / log2(N(i)) - &1) * log2(N(i))) - (log2(Y0) - log2(&2 * pi * exp(&1)))) = (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))) - &1) * log2(N(i))) - (log2(Y0) - log2(&2 * pi * exp(&1)))) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [asymp2_2B1D_lemma3]);; let asymp2_2B1D = prove(` !N:num->real B:num->real Y0:real Y1:real. (!i. &1 < N(i)) /\ o1_seq (\i. &1 / N(i)) /\ (!i. &60 <= B(i)) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 ==> o1_seq (\i:num. (((&2 * B(i) - &1) * log2(bkzdelta(B(i))) / log2(N(i)) - &1) * log2(N(i))) - (log2(Y0) - log2(&2 * pi * exp(&1)))) `, REPEAT STRIP_TAC THEN note `&0 < &2 * pi * exp(&1)` [twopie_pos] THEN note `!i:num. &1 < B(i)` [REAL_ARITH `&60 <= b ==> &1 < b`] THEN note `(\i:num. (((&2 * B(i) - &1) * log2(bkzdelta(B(i))) / log2(N(i)) - &1) * log2(N(i))) - (log2(Y0) - log2(&2 * pi * exp(&1)))) = (\i:num. (((((((&2)*((B(i))/(N(i))))-((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))) - &1) * log2(N(i))) - (log2(Y0) - log2(&2 * pi * exp(&1))))` [asymp2_2B1D_lemma4] THEN specialize [`N:num->real`; `B:num->real`; `Y0:real`; `Y1:real`; `&2 * pi * exp(&1)`] asymp2_2B1D_simpler THEN ASM_MESON_TAC []);; let asymp2_ndq_lemma = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real twopie:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. ((((&1)/(N(i))) - (&0)) * log2(N(i))) - (&0)) /\ o1_seq (\i:num. (((log2(Q(i))/log2(N(i))) - (Q0)) * log2(N(i))) - (Q1)) /\ o1_seq (\i:num. ((((B(i))/(N(i))) - (Y0)) * log2(N(i))) - (Y1)) /\ &0 < ((&2)*(Y0))-((&2)*(&0)) /\ (!i:num. &0 < ((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))) /\ ~(((&2)*(Y0))-((&2)*(&0)) = &0) /\ &0 < Y0 /\ (!i:num. &0 < (B(i))/(N(i))) /\ ~(Y0 = &0) /\ &0 < (pi)*(Y0) /\ &0 < twopie ==> o1_seq (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - ((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0)))) * log2(N(i))) - (((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(Q0))))+(((((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0))))) `, REPEAT STRIP_TAC THEN specialize [`\i:num. N(i):real`; `&1:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `&2:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (&2)*((B(i))/(N(i))):real`; `(&2)*(Y0):real`; `((&2)*(Y1))+((&0)*(Y0)):real`; `\i:num. (&2)*((&1)/(N(i))):real`; `(&2)*(&0):real`; `((&2)*(&0))+((&0)*(&0)):real`] asymp2_sub THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)+((&1)/(N(i))):real`; `(&1)+(&0):real`; `(&0)+(&0):real`; `\i:num. ((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i)))):real`; `((&2)*(Y0))-((&2)*(&0)):real`; `(((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0))):real`] asymp2_div THEN specialize [`\i:num. N(i):real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_div THEN specialize [`\i:num. N(i):real`; `pi:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. pi:real`; `pi:real`; `&0:real`; `\i:num. (B(i))/(N(i)):real`; `Y0:real`; `Y1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (pi)*((B(i))/(N(i))):real`; `(pi)*(Y0):real`; `((pi)*(Y1))+((&0)*(Y0)):real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. log2((pi)*((B(i))/(N(i))))/log2(N(i)):real`; `&0:real`; `log2((pi)*(Y0)):real`; `\i:num. &1:real`; `&1:real`; `&0:real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)/((B(i))/(N(i))):real`; `(&1)*((&1)/(Y0)):real`; `((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))):real`; `\i:num. (log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1):real`; `(&0)+(&1):real`; `(log2((pi)*(Y0)))+(&0):real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)/(N(i)):real`; `&0:real`; `&0:real`; `\i:num. ((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1)):real`; `((&1)*((&1)/(Y0)))*((&0)+(&1)):real`; `(((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1))):real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `twopie:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. twopie:real`; `twopie:real`; `&0:real`] asymp2_logn THEN specialize [`\i:num. N(i):real`; `\i:num. ((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))):real`; `(&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))):real`; `((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))):real`; `\i:num. log2(twopie)/log2(N(i)):real`; `&0:real`; `log2(twopie):real`] asymp2_sub THEN specialize [`\i:num. N(i):real`; `\i:num. log2((B(i))/(N(i)))/log2(N(i)):real`; `&0:real`; `log2(Y0):real`; `\i:num. (((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))):real`; `((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0):real`; `(((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)):real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i)))):real`; `(&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0)):real`; `(log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie))):real`] asymp2_add THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))):real`; `(&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))):real`; `(&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))):real`; `\i:num. log2(Q(i))/log2(N(i)):real`; `Q0:real`; `Q1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. ((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))):real`; `((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))):real`; `(((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))):real`; `\i:num. ((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(twopie)/log2(N(i))))))*(log2(Q(i))/log2(N(i))):real`; `((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0):real`; `(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(twopie)))))*(Q0)):real`] asymp2_mul THEN ASM_MESON_TAC []);; let asymp2_ndq_lemma2 = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 ==> o1_seq (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - ((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0)))) * log2(N(i))) - (((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(&2 * pi * exp(&1))))))*(Q0))))+(((((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0))))) `, REPEAT STRIP_TAC THEN note `&0 < pi*Y0` [PI_POS; REAL_LT_MUL] THEN note `&0 < &2 * pi * exp(&1)` [twopie_pos] THEN real_linear `&0 < Y0 ==> ~(Y0 = &0)` THEN real_linear `&0 < Y0 ==> ~(((&2)*(Y0))-((&2)*(&0)) = &0)` THEN real_linear `&0 < Y0 ==> &0 < ((&2)*(Y0))-((&2)*(&0))` THEN note `!i:num. &1 <= N(i)` [REAL_LT_IMP_LE] THEN note `o1_seq (\i:num. log2(N(i))/N(i))` [o1_log2overlinear_1] THEN notetac `(\i:num. log2(N(i))/N(i)) = (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` (REWRITE_TAC [EQ_EXT; REAL_ARITH `x - &0 = x`; REAL_ARITH `(&1/x)*y = y/x`]) THEN note `o1_seq (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` [] THEN note `!i:num. &0 < N(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < &2*(B(i) - &1)` [REAL_ARITH `&1 < b ==> &0 < &2 * (b - &1)`] THEN note `!i:num. &0 < (&2*(B(i) - &1))/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < (&2)*(B(i)/N(i))-(&2)*((&1)/N(i))` [REAL_FIELD `&1 < n ==> (&2*(b - &1))/n = (&2)*(b/n) - (&2)*(&1/n)`] THEN specialize [`N:num->real`; `Q:num->real`; `B:num->real`; `Q0:real`; `Q1:real`; `Y0:real`; `Y1:real`; `&2 * pi * exp(&1)`] asymp2_ndq_lemma THEN ASM_MESON_TAC []);; let asymp2_ndq_lemma3 = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 ==> o1_seq (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - ((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0)))) * log2(N(i))) - (((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(&2 * pi * exp(&1))))))*(Q0))))+(((((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0))))) `, REPEAT STRIP_TAC THEN note `&0 < pi*Y0` [PI_POS; REAL_LT_MUL] THEN note `&0 < &2 * pi * exp(&1)` [twopie_pos] THEN real_linear `&0 < Y0 ==> ~(Y0 = &0)` THEN real_linear `&0 < Y0 ==> ~(((&2)*(Y0))-((&2)*(&0)) = &0)` THEN real_linear `&0 < Y0 ==> &0 < ((&2)*(Y0))-((&2)*(&0))` THEN note `!i:num. &1 <= N(i)` [REAL_LT_IMP_LE] THEN note `o1_seq (\i:num. log2(N(i))/N(i))` [o1_log2overlinear_1] THEN notetac `(\i:num. log2(N(i))/N(i)) = (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` (REWRITE_TAC [EQ_EXT; REAL_ARITH `x - &0 = x`; REAL_ARITH `(&1/x)*y = y/x`]) THEN note `o1_seq (\i:num. (&1/N(i) - &0) * log2(N(i)) - &0)` [] THEN note `!i:num. &0 < N(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)` [REAL_ARITH `&1 < n ==> &0 < n`] THEN note `!i:num. &0 < B(i)/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < &2*(B(i) - &1)` [REAL_ARITH `&1 < b ==> &0 < &2 * (b - &1)`] THEN note `!i:num. &0 < (&2*(B(i) - &1))/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < (&2)*(B(i)/N(i))-(&2)*((&1)/N(i))` [REAL_FIELD `&1 < n ==> (&2*(b - &1))/n = (&2)*(b/n) - (&2)*(&1/n)`] THEN specialize [`N:num->real`; `Q:num->real`; `B:num->real`; `Q0:real`; `Q1:real`; `Y0:real`; `Y1:real`; `&2 * pi * exp(&1)`] asymp2_ndq_lemma THEN ASM_MESON_TAC []);; let asymp2_ndq_lemma4 = REAL_FIELD ` !Q0:real Y0:real. &0 < Y0 ==> ((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0))) = Q0 / (&2 * Y0) `;; let asymp2_ndq_lemma5 = REAL_FIELD ` !Q0 Q1 Y0 Y1. &0 < Y0 ==> (((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(&2 * pi * exp(&1))))))*(Q0))))+(((((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0)))) = ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2) `;; let asymp2_ndq_lemma6 = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. &0 < Y0 ==> (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - ((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0)))) * log2(N(i))) - (((((&1)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0)))))*((((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q1))+(((&0)+((log2(Y0))+((((&0)*((((&1)*((&1)/(Y0)))*((log2((pi)*(Y0)))+(&0)))+((((&1)*((--(Y1))/((Y0)*(Y0))))+((&0)*((&1)/(Y0))))*((&0)+(&1)))))+((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1)))))-(log2(&2 * pi * exp(&1))))))*(Q0))))+(((((&1)+(&0))*((--((((&2)*(Y1))+((&0)*(Y0)))-(((&2)*(&0))+((&0)*(&0)))))/((((&2)*(Y0))-((&2)*(&0)))*(((&2)*(Y0))-((&2)*(&0))))))+(((&0)+(&0))*((&1)/(((&2)*(Y0))-((&2)*(&0))))))*(((&1)+((&0)+(((&0)*(((&1)*((&1)/(Y0)))*((&0)+(&1))))-(&0))))*(Q0))))) = (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - Q0 / (&2 * Y0)) * log2(N(i))) - ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2)) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [asymp2_ndq_lemma4; asymp2_ndq_lemma5]);; let asymp2_ndq_lemma7 = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &1 < B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 ==> o1_seq (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - Q0 / (&2 * Y0)) * log2(N(i))) - ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2)) `, MESON_TAC [asymp2_ndq_lemma3; asymp2_ndq_lemma6]);; let asymp2_ndq_lemma8 = prove(` !n:real q:real x:real. &1 < n /\ &1 < q /\ &60 <= x ==> (n + &1) * log2(bkzdelta(x)) / log2(n) * log2(q) / log2(n) = ((((&1)+((&1)/(n)))/(((&2)*((x)/(n)))-((&2)*((&1)/(n)))))*(((&1)+((log2((x)/(n))/log2(n))+((((&1)/(n))*(((&1)/((x)/(n)))*((log2((pi)*((x)/(n)))/log2(n))+(&1))))-(log2(&2 * pi * exp(&1))/log2(n)))))*(log2(q)/log2(n)))) `, REPEAT STRIP_TAC THEN ASM_SIMP_TAC [log2ratio_lnratio] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> &1 + &1 / n = (n + &1) / n`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> &2 * x / n - &2 * &1 / n = (&2 * (x - &1)) / n`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> (a / n) / (b / n) = a / b`] THEN real_linear `&1 < n ==> &0 < n` THEN real_linear `&60 <= x ==> &0 < x` THEN ASM_SIMP_TAC [ln_div] THEN ASM_SIMP_TAC [ln_muldiv; PI_POS] THEN note `&0 < ln n` [ln_gt1] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln n ==> (ln pi + ln x - ln n) / ln n + &1 = (ln pi + ln x) / ln n`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < n ==> &1 / n * &1 / (x / n) * y = &1 / x * y`] THEN ASM_SIMP_TAC [REAL_FIELD `&0 < ln n ==> &1 + (ln x - ln n) / ln n + b * c / ln n - d / ln n = (ln x + b * c - d) / ln n`] THEN ASM_SIMP_TAC [REAL_ARITH `b / c * e / f * g / h = b * (e / c) / f * g / h`] THEN ASM_MESON_TAC [bkzdelta_ln4; LN_MUL; PI_POS]);; let asymp2_ndq_lemma9 = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &60 <= B(i)) ==> (\i:num. ((((((&1)+((&1)/(N(i))))/(((&2)*((B(i))/(N(i))))-((&2)*((&1)/(N(i))))))*(((&1)+((log2((B(i))/(N(i)))/log2(N(i)))+((((&1)/(N(i)))*(((&1)/((B(i))/(N(i))))*((log2((pi)*((B(i))/(N(i))))/log2(N(i)))+(&1))))-(log2(&2 * pi * exp(&1))/log2(N(i))))))*(log2(Q(i))/log2(N(i))))) - Q0 / (&2 * Y0)) * log2(N(i))) - ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2)) = (\i:num. (((N(i) + &1) * log2(bkzdelta(B(i))) / log2(N(i)) * log2(Q(i)) / log2(N(i)) - Q0 / (&2 * Y0)) * log2(N(i))) - ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2)) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [asymp2_ndq_lemma8]);; let asymp2_ndq = prove(` !N:num->real Q:num->real B:num->real Q0:real Q1:real Y0:real Y1:real. (!i. &1 < N(i)) /\ (!i. &1 < Q(i)) /\ (!i. &60 <= B(i)) /\ o1_seq (\i. &1 / N(i)) /\ o1_seq (\i:num. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ o1_seq (\i:num. (B(i)/N(i) - Y0) * log2(N(i)) - Y1) /\ &0 < Y0 ==> o1_seq (\i:num. (((N(i) + &1) * log2(bkzdelta(B(i))) / log2(N(i)) * log2(Q(i)) / log2(N(i)) - Q0 / (&2 * Y0)) * log2(N(i))) - ((Q1 + (Q0*log2(Y0) - Q0*log2(&2 * pi * exp(&1))))*Y0 - Q0*Y1)/(&2 * Y0 pow 2)) `, REPEAT STRIP_TAC THEN note `!i:num. &1 < B(i)` [REAL_ARITH `&60 <= b ==> &1 < b`] THEN ASM_MESON_TAC [asymp2_ndq_lemma7; asymp2_ndq_lemma9]);; let converse_X_gt = prove(` !c:real x:num->real X:num->real r:num->num r2:num->num. (!i. c < x(i)) /\ X = x o r o r2 ==> (!i. c < X(i)) `, MESON_TAC [o_THM]);; let converse_X_ge = prove(` !c:real x:num->real X:num->real r:num->num r2:num->num. (!i. c <= x(i)) /\ X = x o r o r2 ==> (!i. c <= X(i)) `, MESON_TAC [o_THM]);; let converse_rr2_subst = prove(` !x:num->real X:num->real r:num->num r2:num->num f:real->real. X = x o r o r2 ==> ((\i. f(x(i))) o r) o r2 = (\i. f(X(i))) `, MESON_TAC [o_THM; EQ_EXT]);; let converse_rr2_subst2 = prove(` !x:num->real X:num->real y:num->real Y:num->real r:num->num r2:num->num f:real->real->real. X = x o r o r2 /\ Y = y o r o r2 ==> ((\i. f (x(i)) (y(i))) o r) o r2 = (\i. f (X(i)) (Y(i))) `, MESON_TAC [o_THM; EQ_EXT]);; let converse_overN_o1_lemma = prove(` !n:num->real N:num->real r:num->num r2:num->num. N = n o r o r2 ==> ((\i. &1 / n(i)) o r) o r2 = (\i. &1 / N(i)) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `N:num->real`; `r:num->num`; `r2:num->num`; `\x. &1 / x`] converse_rr2_subst THEN ASM_MESON_TAC []);; let converse_overN_o1 = prove(` !n:num->real N:num->real r:num->num r2:num->num. o1_seq (\i. &1 / n(i)) /\ (!i j. i < j ==> r(i) < r(j)) /\ (!i j. i < j ==> r2(i) < r2(j)) /\ N = n o r o r2 ==> o1_seq (\i. &1 / N(i)) `, REPEAT STRIP_TAC THEN specialize [`\i:num. &1 / n(i)`; `r:num->num`] o1_seq_subseq THEN specialize [`(\i:num. &1 / n(i)) o (r:num->num)`; `r2:num->num`] o1_seq_subseq THEN ASM_MESON_TAC [converse_overN_o1_lemma]);; let converse_X_o1_lemma = prove(` !n:num->real N:num->real x:num->real X:num->real X0:real X1:real r:num->num r2:num->num. N = n o r o r2 /\ X = x o r o r2 ==> ((\i:num. (log2(x(i))/log2(n(i)) - X0) * log2(n(i)) - X1) o r) o r2 = (\i:num. (log2(X(i))/log2(N(i)) - X0) * log2(N(i)) - X1) `, REPEAT STRIP_TAC THEN specialize [`n:num->real`; `N:num->real`; `x:num->real`; `X:num->real`; `r:num->num`; `r2:num->num`; `\n x. (log2(x)/log2(n) - X0)*log2(n) - X1`] converse_rr2_subst2 THEN ASM_MESON_TAC []);; let converse_X_o1 = prove(` !n:num->real N:num->real x:num->real X:num->real X0:real X1:real r:num->num r2:num->num. o1_seq (\i:num. (log2(x(i))/log2(n(i)) - X0) * log2(n(i)) - X1) /\ (!i j. i < j ==> r(i) < r(j)) /\ (!i j. i < j ==> r2(i) < r2(j)) /\ X = x o r o r2 /\ N = n o r o r2 ==> o1_seq (\i:num. (log2(X(i))/log2(N(i)) - X0) * log2(N(i)) - X1) `, REPEAT STRIP_TAC THEN ASM_MESON_TAC [o1_seq_subseq; converse_X_o1_lemma]);; let converse_K_X0 = prove(` !n:num->real N:num->real k:num->real K:num->real X0:real r:num->num r2:num->num. o1_seq (\i. k(r(r2(i)))/n(r(r2(i))) - X0) /\ N = n o r o r2 /\ K = k o r o r2 ==> o1_seq (\i. K(i)/N(i) - X0) `, REPEAT STRIP_TAC THEN notetac `(\i. k(r(r2(i:num):num):num)/n(r(r2(i))) - X0) = (\i. K(i)/N(i) - X0)` (ASM_REWRITE_TAC [EQ_EXT; o_THM] THEN ASM_MESON_TAC []) THEN ASM_MESON_TAC []);; let converse_beta_le_B = prove(` !n:num->real N:num->real b:num->real beta:num->real B:num->real z0:real z1:real e:real r:num->num r2:num->num. (!i. &1 < n(i)) /\ &0 < e /\ (!i. (b(r(i))/n(r(i)) - z0)*log2(n(r(i))) - z1 < --e) /\ beta = b o r o r2 /\ N = n o r o r2 /\ B = (\i. (z0 + (z1 - e)/log2(N(i)))*N(i)) ==> !i. beta(i) <= B(i) `, REPEAT STRIP_TAC THEN ASM_REWRITE_TAC [o_THM] THEN def `j:num` `r(r2(i:num):num):num` THEN note `&1 < n(j:num)` [] THEN note `&0 < log2(n(j:num))` [log2_gt1] THEN note `(b(j:num)/n(j) - z0)*log2(n(j)) - z1 < --e` [] THEN real_linear `(b(j:num)/n(j) - z0)*log2(n(j)) - z1 < --e ==> (b(j:num)/n(j) - z0)*log2(n(j)) < z1 - e` THEN real_cancel `&0 < log2(n(j)) ==> ((b(j:num)/n(j) - z0)*log2(n(j)))/log2(n(j)) = b(j)/n(j) - z0` THEN note `b(j:num)/n(j) - z0 < (z1 - e)/log2(n(j))` [REAL_LT_DIV2_EQ] THEN real_linear `b(j:num)/n(j) - z0 < (z1 - e)/log2(n(j)) ==> b(j:num)/n(j) < z0 + (z1 - e)/log2(n(j))` THEN real_cancel `&1 < n(j:num) ==> b(j:num)/n(j)*n(j) = b(j:num)` THEN real_linear `&1 < n(j:num) ==> &0 < n(j)` THEN note `b(j:num) < (z0 + (z1 - e)/log2(n(j)))*n(j)` [REAL_LT_RMUL] THEN ASM_MESON_TAC [REAL_LT_IMP_LE]);; let converse_standardratio_rr2 = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real N:num->real Q:num->real S:num->real K:num->real beta:num->real r:num->num r2:num->num z0:real z1:real e:real m:num. (!i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) <= &1) /\ IMAGE r (:num) = {i | m <= i /\ (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e} /\ N = n o r o r2 /\ Q = q o r o r2 /\ S = s o r o r2 /\ K = k o r o r2 /\ beta = b o r o r2 ==> !i. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (beta(i)) <= &1 `, REPEAT STRIP_TAC THEN ASM_REWRITE_TAC [o_THM] THEN notetac `IMAGE r (:num) = {i:num | m <= i /\ (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e} ==> !i:num. m <= r(i)` (SET_TAC []) THEN note `!i:num. m <= r(i):num` [] THEN ASM_MESON_TAC []);; let converse_B_o1 = prove(` !N:num->real B:num->real z0:real z1:real e:real. (!i. &1 < N(i)) /\ B = (\i. (z0 + (z1 - e)/log2(N(i)))*N(i)) ==> o1_seq (\i. (B(i)/N(i) - z0)*log2(N(i)) - (z1 - e)) `, REPEAT STRIP_TAC THEN note `!i:num. &0 < log2(N(i))` [log2_gt1] THEN note `!i:num. &0 < N(i)` [REAL_ARITH `&1 < x ==> &0 < x`] THEN real_cancel `!i:num. &1 < N(i) ==> ((z0 + (z1 - e)/log2(N(i)))*N(i))/N(i) - z0 = (z1 - e)/log2(N(i))` THEN note `!i:num. B(i)/N(i) - z0 = (z1 - e)/log2(N(i))` [] THEN real_cancel `!i:num. &0 < log2(N(i)) ==> ((z1 - e)/log2(N(i)))*log2(N(i)) - (z1 - e) = &0` THEN note `!i:num. (B(i)/N(i) - z0)*log2(N(i)) - (z1 - e) = &0` [] THEN ASM_REWRITE_TAC [o1_seq_0]);; let converse_asymp1_lemma = prove(` !N:num->real Q:num->real S:num->real K:num->real B:num->real c:real. (!i. &1 < N(i)) /\ (!i. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)) <= &1) /\ o1_seq (\i:num. ln (standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i))) / ln (N(i)) - c) ==> c <= &0 `, REPEAT STRIP_TAC THEN note `!i:num. &0 < ln(N(i))` [ln_gt1] THEN note `!i:num. ln(standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i))) <= &0` [ln_le1; standardratio_positive] THEN note `!i:num. ln(standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)))/ln(N(i)) <= &0` [REAL_LE_DIV2_EQ; REAL_ARITH `&0/x = &0`] THEN ASM_CASES_TAC `&0 < c` THENL [choose_specializing `m:num` [`\i:num. ln(standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)))/ln(N(i))`; `c:real`] positive_limit_is_eventually_positive THEN ASM_MESON_TAC [LE_REFL; REAL_NOT_LT]; ASM_MESON_TAC [REAL_NOT_LT]]);; let converse_asymp1_lemma2 = prove(` !Q0 S0 z0 X0. &0 <= X0 /\ &0 < Q0 /\ -- &1 / &2 < Q0 - S0 /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ S0 - &1 / &2 + (&1 + X0) / (&2 * z0) - X0 / (&1 + X0) * Q0 <= &0 ==> X0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) `, REPEAT STRIP_TAC THEN note `&0 <= Q0` [REAL_LT_IMP_LE] THEN note `(S0 - &1 / &2 + (&1 + X0) / (&2 * z0) - X0 / (&1 + X0) * Q0)*Q0 <= &0` [REAL_LE_RMUL; REAL_ARITH `&0 * x = &0`] THEN real_linear `(S0 - &1 / &2 + (&1 + X0) / (&2 * z0) - X0 / (&1 + X0) * Q0)*Q0 <= &0 ==> (S0 - &1 / &2)*Q0 + (&1 + X0) * Q0 / (&2 * z0) - X0 / (&1 + X0) * Q0*Q0 <= &0` THEN real_cancel `&0 < Q0 /\ -- &1 / &2 < Q0 - S0 /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) ==> Q0 / (&2 * z0) = ((Q0 - S0 + &1 / &2) pow 2) / &4` THEN note `(S0 - &1 / &2)*Q0 + (&1 + X0) * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 / (&1 + X0) * Q0*Q0 <= &0` [] THEN real_linear `&0 <= X0 ==> &0 <= &1 + X0` THEN note `((S0 - &1 / &2)*Q0 + (&1 + X0) * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 / (&1 + X0) * Q0*Q0)*(&1 + X0) <= &0` [REAL_LE_RMUL; REAL_ARITH `&0 * x = &0`] THEN real_cancel `&0 <= X0 ==> ((S0 - &1 / &2)*Q0 + (&1 + X0) * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 / (&1 + X0) * Q0*Q0)*(&1 + X0) = (S0 - &1 / &2)*Q0*(&1 + X0) + (&1 + X0) pow 2 * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 * Q0*Q0` THEN note `(S0 - &1 / &2)*Q0*(&1 + X0) + (&1 + X0) pow 2 * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 * Q0*Q0 <= &0` [] THEN real_linear `(S0 - &1 / &2)*Q0*(&1 + X0) + (&1 + X0) pow 2 * (((Q0 - S0 + &1 / &2) pow 2) / &4) - X0 * Q0*Q0 <= &0 ==> ((Q0 - S0 + &1 / &2) * X0 - (Q0 + S0 - &1 / &2)) pow 2 <= &0` THEN note `(Q0 - S0 + &1 / &2) * X0 - (Q0 + S0 - &1 / &2) = &0` [REAL_LT_POW_2; REAL_NOT_LT] THEN real_linear `(Q0 - S0 + &1 / &2) * X0 - (Q0 + S0 - &1 / &2) = &0 ==> (Q0 - S0 + &1 / &2) * X0 = Q0 + S0 - &1 / &2` THEN real_linear `-- &1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2` THEN ASM_MESON_TAC [REAL_EQ_LDIV_EQ; REAL_MUL_SYM]);; let converse_asymp1 = prove(` !N:num->real Q:num->real S:num->real K:num->real B:num->real Q0:real Q1:real S0:real S1:real x0:real z0:real z1:real X0:real e:real. (!i. &1 < N(i)) /\ o1_seq (\i. &1 / N(i)) /\ (!i. &1 < Q(i)) /\ o1_seq (\i. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ (!i. &0 < S(i)) /\ o1_seq (\i. (log2(S(i))/log2(N(i)) - S0) * log2(N(i)) - S1) /\ (!i. &0 < K(i)) /\ &0 <= X0 /\ o1_seq (\i. K(i)/N(i) - X0) /\ (!i. &60 <= B(i)) /\ o1_seq (\i. (B(i)/N(i) - z0) * log2(N(i)) - (z1 - e)) /\ &0 < &1 + &2 * S0 /\ S0 <= &1 / &2 /\ -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2) * (log2(z0) - log2(&2 * pi * exp(&1))) - Q1 * (Q0 + S0 - &1 / &2)/Q0 ) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) /\ &0 < e /\ (!i. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)) <= &1) ==> x0 = X0 `, REPEAT STRIP_TAC THEN specialize [`N:num->real`; `\i:num. log2(Q(i))/log2(N(i))`; `Q0:real`; `Q1:real`] asymp2_asymp1 THEN specialize [`N:num->real`; `\i:num. log2(S(i))/log2(N(i))`; `S0:real`; `S1:real`] asymp2_asymp1 THEN specialize [`N:num->real`; `\i:num. B(i)/N(i):real`; `z0:real`; `z1-e:real`] asymp2_asymp1 THEN note `!i:num. &1 < B(i)` [REAL_ARITH `&60 <= x ==> &1 < x`] THEN real_linear `-- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < Q0` THEN note `&0 < z0` [main_z0_positive] THEN note `o1_seq (\i:num. ln (standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i))) / ln (N(i)) - (S0 - &1 / &2 + (&1 + X0) / (&2 * z0) - X0 / (&1 + X0) * Q0))` [asymp1_standardratio] THEN note `S0 - &1 / &2 + (&1 + X0) / (&2 * z0) - X0 / (&1 + X0) * Q0 <= &0` [converse_asymp1_lemma] THEN ASM_MESON_TAC [converse_asymp1_lemma2]);; let z1_lemma1 = prove(` !Q0 Q1 S0 S1 e z0 log2z0 log21x0 log2twopie. &0 < z0 /\ &0 < Q0 - S0 + &1 / &2 /\ &0 < Q0 /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2z0 - (S0 - Q0 + &3 / &2) * (log2z0 - log2twopie) - Q1 * (Q0 + S0 - &1 / &2)/Q0) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) ==> (Q0 - S0 + &1 / &2) * e / (&2 * z0) = &1 / &2 * (log21x0 + &0 + &2 * S1 + &0 * S0) - &1 / &2 * (log21x0 - log2z0) - ((log2z0 - log2twopie + Q1) - &2 * ((Q1 + Q0 * log2z0 - Q0 * log2twopie) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)) `, REPEAT STRIP_TAC THEN REWRITE_TAC [REAL_ARITH `&1 / &2 * (a + b) - &1 / &2 * (a - c) - d = &1 / &2 * b + &1 / &2 *c - d`] THEN REWRITE_TAC [REAL_ARITH `&0 * x = &0`; REAL_ARITH `&0 + x = x`; REAL_ARITH `x + &0 = x`; REAL_ARITH `&1 / &2 * &2 * s = s`] THEN ASM_REWRITE_TAC [] THEN real_cancel `&0 < Q0 /\ &0 < (Q0 - S0 + &1 / &2) ==> (Q0 - S0 + &1 / &2) * e / (&2 * &2 * Q0 / (Q0 - S0 + &1 / &2) pow 2) = S1 + &1 / &2 * log2z0 - ((log2z0 - log2twopie + Q1) - &2 * ((Q1 + Q0 * log2z0 - Q0 * log2twopie) * &2 * Q0 / (Q0 - S0 + &1 / &2) pow 2 - Q0 * ((&2 * S1 + log2z0 - (S0 - Q0 + &3 / &2) * (log2z0 - log2twopie) - Q1 * (Q0 + S0 - &1 / &2) / Q0) * (&2 * Q0) / (Q0 - S0 + &1 / &2) pow 3 - e)) / (&2 * (&2 * Q0 / (Q0 - S0 + &1 / &2) pow 2) pow 2) / (Q0 - S0 + &1 / &2))` THEN ASM_REWRITE_TAC []);; let z1_lemma2 = prove(` !Q0 Q1 S0 S1 e x0 z0. &0 < z0 /\ &0 < &1 + x0 /\ &0 < Q0 - S0 + &1 / &2 /\ &0 < Q0 /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2) * (log2(z0) - log2(&2 * pi * exp(&1))) - Q1 * (Q0 + S0 - &1 / &2)/Q0 ) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) ==> (Q0 - S0 + &1 / &2) * e / (&2 * z0) = &1 / &2 * (log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0) - &1 / &2 * log2 (((&1 + x0) + &0) * &1 / z0) - ((log2 z0 - log2 (&2 * pi * exp (&1)) + Q1) - &2 * ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)) `, REPEAT STRIP_TAC THEN note `&0 < &1 / z0` [pos_1over] THEN note `log2 (((&1 + x0) + &0) * &1 / z0) = log2(&1 + x0) - log2(z0)` [REAL_ARITH `(&1 + x0) + &0 = &1 + x0`; log2_mul; log2_1over; REAL_ARITH `a + --b = a - b`] THEN specialize [`Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `e:real`; `z0:real`; `log2(z0)`; `log2(&1 + x0)`; `log2(&2 * pi * exp(&1))`] z1_lemma1 THEN ASM_MESON_TAC []);; let sqrt_misc_lemma = prove(` &0 < L ==> sqrt(a * b / L * c / L) = sqrt(a * b * c) / L `, REWRITE_TAC [REAL_FIELD `a * b / L * c / L = (a*b*c)/(L*L)`] THEN MESON_TAC [REAL_LT_IMP_LE; SQRT_DIV; REAL_POW_2; POW_2_SQRT; REAL_LE_SQUARE]);; let converse_asymp2_lemma1 = REAL_FIELD ` !Q0:real S0:real z0:real. &0 < Q0 /\ -- &1 / &2 < Q0 - S0 /\ z0 = &2 * Q0 / (Q0 - S0 + &1 / &2) pow 2 ==> Q0 / (&2 * z0) = ((Q0 - S0 + &1 / &2) / &2) pow 2 `;; let converse_asymp2_lemma2 = prove(` !N:num->real Q:num->real S:num->real K:num->real B:num->real Q0:real S0:real z0:real e:real. (!i. &0 < log2(N(i))) ==> (\i:num. (&1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))) - &0) * log2 (N i) - (Q0 - S0 + &1 / &2) * e / (&2 * z0)) = (\i:num. (&1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) + log2 (Q i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) * log2 (Q i)))) - (Q0 - S0 + &1 / &2) * e / (&2 * z0)) `, REPEAT STRIP_TAC THEN MATCH_MP_TAC EQ_EXT THEN REWRITE_TAC [BETA_THM] THEN ASM_MESON_TAC [sqrt_misc_lemma; REAL_FIELD `&0 < L ==> ((&1 / &2 * log2x / L - &1 / &2 * log2y / L - (((&2 * bi - &1) * log2d / L + log2q / L) - &2 * s / L)) - &0) * L = &1 / &2 * log2x - &1 / &2 * log2y - (((&2 * bi - &1) * log2d + log2q ) - &2 * s)`]);; let converse_asymp2_lemma3 = prove(` !n q s k b. &1 < n /\ &0 < k /\ &1 < q /\ &0 < s /\ &60 <= b ==> &1 / &2 * log2 (&1 + (&1 + k / n) * n powreal (&1 + &2 * log2 (s) / log2 (n))) - &1 / &2 * log2 (((&1 + k / n) + &1 / n) / (b / n)) - (((&2 * b - &1) * log2 (bkzdelta (b)) + log2 (q)) - &2 * sqrt ((n + &1) * log2 (bkzdelta (b)) * log2 (q))) <= log2(standardratio n q s k b) `, REPEAT STRIP_TAC THEN ASM_SIMP_TAC [standardratio_log2] THEN REWRITE_TAC [powreal_sum] THEN real_linear `&1 < n ==> &0 < n` THEN ASM_SIMP_TAC [powreal_1] THEN ASM_REWRITE_TAC [GSYM powreal_pow] THEN ASM_SIMP_TAC [GSYM powreal_log2ratio] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> &1 + (&1 + k / n) * (n * x) = (n + k)*x + &1`] THEN ASM_SIMP_TAC [REAL_FIELD `&1 < n ==> ((&1 + k / n) + &1 / n) / (b / n) = (n + k + &1)/b`] THEN def `d:real` `bkzdelta(b)` THEN note `&1 < d` [deltabound5] THEN real_linear `&1 < d ==> &1 <= d` THEN note `(&2 * b - n - k - &2) * log2 d + k / (n + k + &1) * log2 q <= (&2 * b - &1) * log2 d + log2 q - &2 * sqrt ((n + &1) * log2 d * log2 q)` [kappa_main] THEN real_linear `(&2 * b - n - k - &2) * log2 d + k / (n + k + &1) * log2 q <= (&2 * b - &1) * log2 d + log2 q - &2 * sqrt ((n + &1) * log2 d * log2 q) ==> &1 / &2 * log2 ((n + k) * s pow 2 + &1) - &1 / &2 * log2 ((n + k + &1) / b) - (((&2 * b - &1) * log2 d + log2 q) - &2 * sqrt ((n + &1) * log2 d * log2 q)) <= &1 / &2 * log2 ((n + k) * s pow 2 + &1) - (&1 / &2 * log2 ((n + k + &1) / b) + ( (&2 * b - n - k - &2) * log2 d + k / (n + k + &1) * log2 q))` THEN note `log2 (bkzdelta b) = (log2 b + &1 / b * log2 (pi * b) - log2 (&2 * pi * exp (&1))) / (&2 * (b - &1))` [bkzdelta_log2] THEN note `(&2 * b - n - k - &2) * log2 d = (log2 b + &1 / b * log2 (pi * b) - log2 (&2 * pi * exp (&1))) * (&2 * b - (n + k + &1) - &1) / (&2 * (b - &1))` [REAL_ARITH `c * (L / x) = L * (c / x)`; REAL_ARITH `&2 * b - n - k - &2 = &2 * b - (n + k + &1) - &1`] THEN ASM_MESON_TAC []);; let converse_asymp2_lemma4 = prove(` !n q s k b. &1 < n /\ &0 < k /\ &1 < q /\ &0 < s /\ &60 <= b /\ &0 < &1 / &2 * log2 (&1 + (&1 + k / n) * n powreal (&1 + &2 * log2 (s) / log2 (n))) - &1 / &2 * log2 (((&1 + k / n) + &1 / n) / (b / n)) - (((&2 * b - &1) * log2 (bkzdelta (b)) + log2 (q)) - &2 * sqrt ((n + &1) * log2 (bkzdelta (b)) * log2 (q))) ==> &1 < standardratio n q s k b `, REPEAT STRIP_TAC THEN specialize [`n:real`; `q:real`; `s:real`; `k:real`; `b:real`] converse_asymp2_lemma3 THEN note `&0 < log2(standardratio n q s k b)` [REAL_LTE_TRANS] THEN ASM_MESON_TAC [REAL_NOT_LT; standardratio_positive; log2_le1]);; let converse_asymp2 = prove(` !N:num->real Q:num->real S:num->real K:num->real B:num->real Q0:real Q1:real S0:real S1:real x0:real z0:real z1:real e:real. (!i. &1 < N(i)) /\ o1_seq (\i. &1 / N(i)) /\ (!i. &1 < Q(i)) /\ o1_seq (\i. (log2(Q(i))/log2(N(i)) - Q0) * log2(N(i)) - Q1) /\ (!i. &0 < S(i)) /\ o1_seq (\i. (log2(S(i))/log2(N(i)) - S0) * log2(N(i)) - S1) /\ (!i. &0 < K(i)) /\ o1_seq (\i. K(i)/N(i) - x0) /\ (!i. &60 <= B(i)) /\ o1_seq (\i. (B(i)/N(i) - z0) * log2(N(i)) - (z1 - e)) /\ -- &1 / &2 < S0 /\ S0 <= &1 / &2 /\ -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2) * (log2(z0) - log2(&2 * pi * exp(&1))) - Q1 * (Q0 + S0 - &1 / &2)/Q0 ) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) /\ &0 < e ==> ?m. !i. m <= i ==> &1 < standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)) `, REPEAT STRIP_TAC THEN real_linear `-- &1 / &2 < S0 ==> &0 < &1 + &2 * S0` THEN note `&0 < x0` [main_x0_positive] THEN note `&0 < z0` [main_z0_positive] THEN specialize [`N:num->real`; `B:num->real`; `z0:real`; `z1 - e:real`] asymp2_2B1D THEN specialize [`N:num->real`; `Q:num->real`; `B:num->real`; `Q0:real`; `Q1:real`; `z0:real`; `z1 - e:real`] asymp2_ndq THEN real_linear `-- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 ==> &0 < Q0` THEN note `Q0 / (&2 * z0) = ((Q0 - S0 + &1 / &2) / &2) pow 2` [converse_asymp2_lemma1] THEN note_eqlambda `(\i:num. ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i) - Q0 / (&2 * z0)) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2)) = (\i:num. ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i) - ((Q0 - S0 + &1 / &2) / &2) pow 2) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2))` [] THEN note `o1_seq (\i:num. ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i) - ((Q0 - S0 + &1 / &2) / &2) pow 2) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2))` [] THEN real_linear `-- &1 / &2 < Q0 - S0 ==> &0 < Q0 - S0 + &1 / &2` THEN real_linear `-- &1 / &2 < Q0 - S0 ==> &0 < (Q0 - S0 + &1 / &2) / &2` THEN note `&0 < ((Q0 - S0 + &1 / &2) / &2) pow 2` [REAL_LT_IMP_NZ; REAL_LT_POW_2] THEN specialize [`N:num->real`; `\i:num. (N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i)`; `((Q0 - S0 + &1 / &2) / &2) pow 2`; `((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2)`] asymp2_sqrt THEN note `sqrt (((Q0 - S0 + &1 / &2) / &2) pow 2) = (Q0 - S0 + &1 / &2) / &2` [REAL_LT_IMP_LE; POW_2_SQRT] THEN note `&2 * sqrt (((Q0 - S0 + &1 / &2) / &2) pow 2) = Q0 - S0 + &1 / &2` [REAL_ARITH `&2 * (a / &2) = a`] THEN note_eqlambda `(\i:num. (sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i)) - sqrt (((Q0 - S0 + &1 / &2) / &2) pow 2)) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (&2 * sqrt (((Q0 - S0 + &1 / &2) / &2) pow 2))) = (\i. (sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i)) - (Q0 - S0 + &1 / &2) / &2) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2))` [] THEN note `o1_seq (\i:num. (sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i)) - (Q0 - S0 + &1 / &2) / &2) * log2 (N i) - ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2))` [] THEN specialize [`N:num->real`; `\i:num. sqrt((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))`; `(Q0 - S0 + &1 / &2) / &2`; `((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)`; `&2`] asymp2_mulconst THEN specialize [`N:num->real`; `\i:num. (&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i)`; `&1`; `log2 z0 - log2 (&2 * pi * exp (&1))`; `\i:num. log2(Q(i))/log2(N(i))`; `Q0:real`; `Q1:real`] asymp2_add THEN specialize [`N:num->real`; `\i:num. (&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)`; `&1 + Q0`; `log2 z0 - log2 (&2 * pi * exp (&1)) + Q1`; `\i:num. &2 * sqrt((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))`; `&2 * ((Q0 - S0 + &1 / &2) / &2)`; `&2 * ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)`] asymp2_sub THEN specialize [`N:num->real`] asymp2_simple_lemma2 THEN specialize [`\i:num. N(i):real`; `&1:real`] asymp1_const THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `\i:num. (K(i))/(N(i)):real`; `x0:real`] asymp1_add THEN specialize [`\i:num. N(i):real`; `&1:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `&2:real`] asymp2_const THEN specialize [`\i:num. N(i):real`; `\i:num. &2:real`; `&2:real`; `&0:real`; `\i:num. log2(S(i))/log2(N(i)):real`; `S0:real`; `S1:real`] asymp2_mul THEN specialize [`\i:num. N(i):real`; `\i:num. &1:real`; `&1:real`; `&0:real`; `\i:num. (&2)*(log2(S(i))/log2(N(i))):real`; `(&2)*(S0):real`; `((&2)*(S1))+((&0)*(S0)):real`] asymp2_add THEN note `!i:num. &0 < N(i)` [REAL_ARITH `&1 < x ==> &0 < x`] THEN note `!i:num. &0 < K(i)/N(i)` [REAL_LT_DIV] THEN note `!i:num. &0 < &1 + K(i)/N(i)` [REAL_ARITH `&0 < x ==> &0 < &1 + x`] THEN real_linear `&0 < x0 ==> &0 < &1 + x0` THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)+((K(i))/(N(i))):real`; `(&1)+(x0):real`; `\i:num. (&1)+((&2)*(log2(S(i))/log2(N(i)))):real`; `(&1)+((&2)*(S0)):real`; `(&0)+(((&2)*(S1))+((&0)*(S0))):real`] asymp2_logn1plusAtimesntotheB_mini THEN specialize [`N:num->real`; `\i:num. log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i)`; `&1 + &2 * S0`; `(log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0)`; `&1 / &2`] asymp2_mulconst THEN note_eqlambda `(\i:num. &1 / N(i)) = (\i:num. &1 / N(i) - &0)` [REAL_ARITH `x - &0 = x`] THEN note `o1_seq (\i:num. &1 / N(i) - &0)` [] THEN specialize [`\i:num. N(i):real`; `\i:num. (&1)+((K(i))/(N(i))):real`; `(&1)+(x0):real`; `\i:num. (&1)/(N(i)):real`; `&0:real`] asymp1_add THEN specialize [`N:num->real`; `\i:num. B(i)/N(i)`; `z0:real`; `z1-e:real`] asymp2_asymp1 THEN real_linear `&0 < z0 ==> ~(z0 = &0)` THEN specialize [`\i:num. N(i):real`; `\i:num. ((&1)+((K(i))/(N(i))))+((&1)/(N(i))):real`; `((&1)+(x0))+(&0):real`; `\i:num. (B(i))/(N(i)):real`; `z0:real`] asymp1_div THEN note `&0 < ((&1 + x0) + &0) * &1 / z0` [pos_1over; REAL_ARITH `x + &0 = x`; REAL_LT_MUL] THEN specialize [`N:num->real`; `\i:num. ((&1 + K i / N i) + &1 / N i) / (B i / N i)`; `((&1 + x0) + &0) * &1 / z0`] asymp2_logn_mini THEN specialize [`N:num->real`; `\i:num. log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i)`; `&0`; `log2 (((&1 + x0) + &0) * &1 / z0)`; `&1 / &2`] asymp2_mulconst THEN specialize [`N:num->real`; `\i:num. &1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i)`; `&1 / &2 * (&1 + &2 * S0)`; `&1 / &2 * (log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0)`; `\i:num. &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i)`; `&1 / &2 * &0`; `&1 / &2 * log2 (((&1 + x0) + &0) * &1 / z0)`] asymp2_sub THEN specialize [`N:num->real`; `\i:num. &1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i)`; `&1 / &2 * (&1 + &2 * S0) - &1 / &2 * &0`; `&1 / &2 * (log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0) - &1 / &2 * log2 (((&1 + x0) + &0) * &1 / z0)`; `\i:num. ((&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))`; `(&1 + Q0) - &2 * (Q0 - S0 + &1 / &2) / &2`; `(log2 z0 - log2 (&2 * pi * exp (&1)) + Q1) - &2 * ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)`] asymp2_sub THEN real_linear `&0 = (&1 / &2 * (&1 + &2 * S0) - &1 / &2 * &0 - ((&1 + Q0) - &2 * (Q0 - S0 + &1 / &2) / &2))` THEN note `(Q0 - S0 + &1 / &2) * e / (&2 * z0) = &1 / &2 * (log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0) - &1 / &2 * log2 (((&1 + x0) + &0) * &1 / z0) - ((log2 z0 - log2 (&2 * pi * exp (&1)) + Q1) - &2 * ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2))` [z1_lemma2] THEN note_eqlambda `(\i:num. (&1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))) - (&1 / &2 * (&1 + &2 * S0) - &1 / &2 * &0 - ((&1 + Q0) - &2 * (Q0 - S0 + &1 / &2) / &2))) * log2 (N i) - (&1 / &2 * (log2 (&1 + x0) + &0 + &2 * S1 + &0 * S0) - &1 / &2 * log2 (((&1 + x0) + &0) * &1 / z0) - ((log2 z0 - log2 (&2 * pi * exp (&1)) + Q1) - &2 * ((Q1 + Q0 * log2 z0 - Q0 * log2 (&2 * pi * exp (&1))) * z0 - Q0 * (z1 - e)) / (&2 * z0 pow 2) / (Q0 - S0 + &1 / &2)))) = (\i:num. (&1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))) - &0) * log2 (N i) - (Q0 - S0 + &1 / &2) * e / (&2 * z0))` [] THEN note `o1_seq (\i:num. (&1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) / log2 (N i) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) / log2 (N i) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) / log2 (N i) + log2 (Q i) / log2 (N i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) / log2 (N i) * log2 (Q i) / log2 (N i))) - &0) * log2 (N i) - (Q0 - S0 + &1 / &2) * e / (&2 * z0))` [] THEN note `!i:num. &0 < log2(N(i))` [log2_gt1] THEN specialize [`N:num->real`; `Q:num->real`; `S:num->real`; `K:num->real`; `B:num->real`; `Q0:real`; `S0:real`; `z0:real`; `e:real`] converse_asymp2_lemma2 THEN note `o1_seq (\i:num. ( &1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) + log2 (Q i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) * log2 (Q i)))) - (Q0 - S0 + &1 / &2) * e / (&2 * z0))` [] THEN note `&0 < (Q0 - S0 + &1 / &2) * e / (&2 * z0)` [REAL_LT_MUL; REAL_LT_DIV; REAL_ARITH `&0 < &2`] THEN choose_specializing `M:num` [`\i:num. &1 / &2 * log2 (&1 + (&1 + K i / N i) * N i powreal (&1 + &2 * log2 (S i) / log2 (N i))) - &1 / &2 * log2 (((&1 + K i / N i) + &1 / N i) / (B i / N i)) - (((&2 * B i - &1) * log2 (bkzdelta (B i)) + log2 (Q i)) - &2 * sqrt ((N i + &1) * log2 (bkzdelta (B i)) * log2 (Q i)))`; `(Q0 - S0 + &1 / &2) * e / (&2 * z0)`] positive_limit_is_eventually_positive THEN EXISTS_TAC `M:num` THEN ASM_MESON_TAC [converse_asymp2_lemma4]);; let converse_denouement = prove(` !n:num->real k:num->real b:num->real z0:real z1:real g:num->real L:num->real. (!i. &1 < n(i)) /\ (!i. g(i) <= (b(i)/n(i) - z0)*log2(n(i)) - z1) /\ o1_seq g /\ L = (\i. (z0 + (z1 + g(i))/log2(n(i)))*n(i)) ==> (!i. L(i) <= b(i)) /\ o1_seq (\i. (L(i)/n(i) - z0)*log2(n(i)) - z1) `, REPEAT STRIP_TAC THENL [note `g(i:num) <= (b(i)/n(i) - z0)*log2(n(i)) - z1` [] THEN real_linear `g(i:num) <= (b(i)/n(i) - z0)*log2(n(i)) - z1 ==> z1 + g(i) <= (b(i)/n(i) - z0)*log2(n(i))` THEN note `&0 < log2(n(i:num))` [log2_gt1] THEN note `(z1 + g(i))/log2(n(i:num)) <= ((b(i)/n(i) - z0)*log2(n(i)))/log2(n(i))` [REAL_LE_DIV2_EQ] THEN real_cancel `&0 < log2(n(i:num)) ==> ((b i / n i - z0) * log2 (n i)) / log2 (n i) = b(i)/n(i) - z0` THEN note `(z1 + g(i))/log2(n(i:num)) <= b(i)/n(i) - z0` [] THEN real_linear `(z1 + g(i:num))/log2(n(i:num)) <= b(i)/n(i) - z0 ==> z0 + (z1 + g(i))/log2(n(i:num)) <= b(i)/n(i)` THEN note `&1 < n(i:num)` [] THEN real_linear `&1 < n(i:num) ==> &0 <= n(i)` THEN note `(z0 + (z1 + g(i))/log2(n(i:num)))*n(i) <= (b(i)/n(i))*n(i)` [REAL_LE_RMUL] THEN real_cancel `&1 < n(i:num) ==> (b(i)/n(i))*n(i) = b(i)` THEN ASM_MESON_TAC []; SUBGOAL_THEN `!i:num. g(i) = (L(i) / n(i) - z0) * log2(n(i)) - z1` MP_TAC THENL [STRIP_TAC THEN note `&1 < n(i:num)` [] THEN note `L(i:num) = (z0 + (z1 + g(i))/log2(n(i)))*n(i)` [] THEN real_cancel `&1 < n(i) /\ L(i:num) = (z0 + (z1 + g(i))/log2(n(i)))*n(i) ==> L(i)/n(i) - z0 = (z1 + g(i))/log2(n(i))` THEN note `&0 < log2(n(i:num))` [log2_gt1] THEN real_cancel `&0 < log2(n(i:num)) /\ L(i)/n(i) - z0 = (z1 + g(i))/log2(n(i)) ==> (L(i)/n(i) - z0) * log2(n(i)) - z1 = g(i)` THEN ASM_MESON_TAC []; ASM_MESON_TAC [EQ_EXT]]]);; let converse_main = prove(` !n:num->real q:num->real s:num->real k:num->real b:num->real Q0:real Q1:real S0:real S1:real x0:real z0:real z1:real. (!i. &1 < n(i)) /\ (!i. &1 < q(i)) /\ (!i. &0 < s(i)) /\ o1_seq (\i. &1 / n(i)) /\ o1_seq (\i. (log2(q(i))/log2(n(i)) - Q0) * log2(n(i)) - Q1) /\ o1_seq (\i. (log2(s(i))/log2(n(i)) - S0) * log2(n(i)) - S1) /\ -- &1 / &2 < S0 /\ S0 <= &1 / &2 /\ -- &1 / &2 < Q0 - S0 /\ &1 / &2 < Q0 + S0 /\ x0 = (Q0 + S0 - &1 / &2)/(Q0 - S0 + &1 / &2) /\ z0 = &2 * Q0/((Q0 - S0 + &1 / &2) pow 2) /\ z1 = (&2 * S1 + log2(z0) - (S0 - Q0 + &3 / &2) * (log2(z0) - log2(&2 * pi * exp(&1))) - Q1 * (Q0 + S0 - &1 / &2)/Q0 ) * (&2 * Q0) / ((Q0 - S0 + &1 / &2) pow 3) /\ (!i. &0 < k(i)) /\ (!i. k(i) <= &100 * n(i)) /\ (!i. &60 <= b(i)) /\ (!i. b(i) <= ceil(n(i) + k(i) + &1)) /\ (?m. !i. m <= i ==> standardratio (n(i)) (q(i)) (s(i)) (k(i)) (b(i)) <= &1) ==> ?L. (!i. L(i) <= b(i)) /\ o1_seq (\i. (L(i)/n(i) - z0) * log2(n(i)) - z1) `, REPEAT STRIP_TAC THEN ASM_CASES_TAC `!e:real. &0 < e ==> FINITE {i:num | (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e}` THENL [choose_specializing `g:num->real` [`\i:num. (b(i)/n(i) - z0)*log2(n(i)) - z1`] o1_lower_main THEN def `L:num->real` `\i:num. (z0 + (z1 + g(i))/log2(n(i)))*n(i)` THEN ASM_MESON_TAC [converse_denouement]; ALL_TAC] THEN choose `e:real` `&0 < e /\ INFINITE {i:num | (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e}` [INFINITE] THEN note `INFINITE {i:num | (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e}` [] THEN specialize [`\i:num. (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e`; `m:num`] num_chop_infinite THEN choose `r:num->num` `(!m n:num. m < n ==> r(m) < r(n)) /\ IMAGE r (:num) = {i:num | m <= i /\ (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e}` [INFINITE_ENUMERATE] THEN notetac `IMAGE r (:num) = {i:num | m <= i /\ (b(i)/n(i) - z0)*log2(n(i)) - z1 < --e} ==> !i. m <= r(i) /\ (b(r(i))/n(r(i)) - z0)*log2(n(r(i))) - z1 < --e` (SET_TAC []) THEN note `!i:num. m <= r(i) /\ (b(r(i):num)/n(r(i)) - z0)*log2(n(r(i))) - z1 < --e` [] THEN note `!i:num. &0 <= k(r(i):num)/n(r(i))` [REAL_ARITH `&1 < x ==> &0 < x`; REAL_LT_DIV; REAL_LT_IMP_LE] THEN note `!i:num. k(r(i):num)/n(r(i)) <= &100` [REAL_LE_DIV2_EQ; REAL_ARITH `&1 < x ==> &0 < x`; REAL_FIELD `&0 < x ==> (&100 * x) / x = &100`] THEN specialize [`\i:num. k(r(i):num):real / n(r(i))`; `&0`; `&100`] seq_bolzano2 THEN choose `r2:num->num` `?X0:real. (!i j. i < j ==> r2(i) < r2(j)) /\ o1_seq (\i. k(r(r2(i:num):num):num)/n(r(r2(i))) - X0) /\ &0 <= X0` [] THEN choose `X0:real` `(!i j. i < j ==> r2(i) < r2(j)) /\ o1_seq (\i. k(r(r2(i:num):num):num)/n(r(r2(i))) - X0) /\ &0 <= X0` [] THEN def `N:num->real` `(n:num->real) o (r:num->num) o (r2:num->num)` THEN def `K:num->real` `(k:num->real) o (r:num->num) o (r2:num->num)` THEN def `Q:num->real` `(q:num->real) o (r:num->num) o (r2:num->num)` THEN def `S:num->real` `(s:num->real) o (r:num->num) o (r2:num->num)` THEN def `beta:num->real` `(b:num->real) o (r:num->num) o (r2:num->num)` THEN def `B:num->real` `\i:num. (z0 + (z1 - e)/log2(N(i)))*N(i)` THEN note `!i j. i < j:num ==> r(i) < r(j):num` [] THEN note `!i j. i < j:num ==> r2(i) < r2(j):num` [] THEN specialize [`&1`; `n:num->real`; `N:num->real`; `r:num->num`; `r2:num->num`] converse_X_gt THEN specialize [`&1`; `q:num->real`; `Q:num->real`; `r:num->num`; `r2:num->num`] converse_X_gt THEN specialize [`&0`; `s:num->real`; `S:num->real`; `r:num->num`; `r2:num->num`] converse_X_gt THEN specialize [`&0`; `k:num->real`; `K:num->real`; `r:num->num`; `r2:num->num`] converse_X_gt THEN specialize [`&60`; `b:num->real`; `beta:num->real`; `r:num->num`; `r2:num->num`] converse_X_ge THEN specialize [`n:num->real`; `N:num->real`; `r:num->num`; `r2:num->num`] converse_overN_o1 THEN note `!i:num. beta(i) <= B(i)` [converse_beta_le_B] THEN note `!i:num. &60 <= B(i)` [REAL_LE_TRANS] THEN note `!i:num. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)) <= standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (beta(i))` [rho_decreasing4] THEN note `!i:num. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (beta(i)) <= &1` [converse_standardratio_rr2] THEN note `!i:num. standardratio (N(i)) (Q(i)) (S(i)) (K(i)) (B(i)) <= &1` [REAL_LE_TRANS] THEN specialize [`n:num->real`; `N:num->real`; `q:num->real`; `Q:num->real`; `Q0:real`; `Q1:real`; `r:num->num`; `r2:num->num`] converse_X_o1 THEN specialize [`n:num->real`; `N:num->real`; `s:num->real`; `S:num->real`; `S0:real`; `S1:real`; `r:num->num`; `r2:num->num`] converse_X_o1 THEN note `o1_seq (\i:num. K(i)/N(i) - X0:real)` [converse_K_X0] THEN note `o1_seq (\i:num. (B(i)/N(i) - z0)*log2(N(i)) - (z1 - e))` [converse_B_o1] THEN real_linear `-- &1 / &2 < S0 ==> &0 < &1 + &2 * S0` THEN note `&0 <= X0` [] THEN note `&0 < e` [] THEN specialize [`N:num->real`; `Q:num->real`; `S:num->real`; `K:num->real`; `B:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `x0:real`; `z0:real`; `z1:real`; `X0:real`; `e:real`] converse_asymp1 THEN note `o1_seq (\i. K(i)/N(i) - x0)` [] THEN choose_specializing `M:num` [`N:num->real`; `Q:num->real`; `S:num->real`; `K:num->real`; `B:num->real`; `Q0:real`; `Q1:real`; `S0:real`; `S1:real`; `x0:real`; `z0:real`; `z1:real`; `e:real`] converse_asymp2 THEN def `U:num` `MAX m M` THEN note `m <= U:num` [max_le; LE_REFL] THEN note `M <= U:num` [max_le; LE_REFL] THEN note `!i:num. m <= i ==> standardratio (N i) (Q i) (S i) (K i) (B i) <= &1` [o_THM] THEN note `&1 < standardratio (N (U:num)) (Q U) (S U) (K U) (B U)` [] THEN note `standardratio (N (U:num)) (Q U) (S U) (K U) (B U) <= &1` [] THEN ASM_MESON_TAC [REAL_NOT_LT]);; (* ----- review external theorems *) let forward_main = forward_main;; let converse_main = converse_main;;