(* ========================================================================= *)
(* Liouville approximation theorem. *)
(* ========================================================================= *)
needs "Library/poly.ml";;
needs "Library/floor.ml";;
(* ------------------------------------------------------------------------- *)
(* Definition of algebraic and transcendental. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Some trivialities. *)
(* ------------------------------------------------------------------------- *)
let EXP_LE_REFL = prove
(`!a. 1 < a ==> !n. n <= a
EXP n`,
GEN_TAC THEN DISCH_TAC THEN INDUCT_TAC THEN REWRITE_TAC[
EXP; ARITH] THEN
FIRST_X_ASSUM(MATCH_MP_TAC o MATCH_MP (ARITH_RULE
`n <= x ==> 1 * x < y ==> SUC n <= y`)) THEN
REWRITE_TAC[
LT_MULT_RCANCEL;
EXP_EQ_0] THEN
POP_ASSUM MP_TAC THEN ARITH_TAC);;
(* ------------------------------------------------------------------------- *)
(* Archimedian properties taken from Multivariate/misc.ml *)
(* ------------------------------------------------------------------------- *)
let REAL_ARCH_POW = prove
(`!x y. &1 < x ==> ?n. y < x pow n`,
REPEAT STRIP_TAC THEN
MP_TAC(SPEC `x - &1`
REAL_ARCH) THEN ASM_REWRITE_TAC[
REAL_SUB_LT] THEN
DISCH_THEN(MP_TAC o SPEC `y:real`) THEN MATCH_MP_TAC
MONO_EXISTS THEN
X_GEN_TAC `n:num` THEN DISCH_TAC THEN MATCH_MP_TAC
REAL_LTE_TRANS THEN
EXISTS_TAC `&1 + &n * (x - &1)` THEN
ASM_SIMP_TAC[REAL_ARITH `x < y ==> x < &1 + y`] THEN
ASM_MESON_TAC[
REAL_POW_LBOUND;
REAL_SUB_ADD2; REAL_ARITH
`&1 < x ==> &0 <= x - &1`]);;
(* ------------------------------------------------------------------------- *)
(* Inequality variant of mean value theorem. *)
(* ------------------------------------------------------------------------- *)
let MVT_INEQ = prove
(`!f f' a d M.
&0 < M /\ &0 < d /\
(!x. abs(x - a) <= d ==> (f diffl f'(x)) x /\ abs(f' x) < M)
==> !x. abs(x - a) <= d ==> abs(f x - f a) < M * d`,
REWRITE_TAC[TAUT `a ==> b /\ c <=> (a ==> b) /\ (a ==> c)`] THEN
REWRITE_TAC[
FORALL_AND_THM] THEN
REPEAT STRIP_TAC THEN REPEAT_TCL DISJ_CASES_THEN ASSUME_TAC
(REAL_ARITH `x = a \/ x < a \/ a < x`)
THENL
[ASM_SIMP_TAC[
REAL_SUB_REFL;
REAL_ABS_NUM;
REAL_LT_MUL];
MP_TAC(SPECL [`f:real->real`; `f':real->real`; `x:real`; `a:real`]
MVT_ALT);
MP_TAC(SPECL [`f:real->real`; `f':real->real`; `a:real`; `x:real`]
MVT_ALT)] THEN
(ANTS_TAC THENL
[ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN
FIRST_X_ASSUM MATCH_MP_TAC THEN
POP_ASSUM_LIST(MP_TAC o end_itlist CONJ) THEN REAL_ARITH_TAC;
ALL_TAC]) THEN
STRIP_TAC THENL
[ONCE_REWRITE_TAC[
REAL_ABS_SUB]; ALL_TAC] THEN
ONCE_REWRITE_TAC[REAL_MUL_SYM] THEN ASM_REWRITE_TAC[
REAL_ABS_MUL] THEN
MATCH_MP_TAC
REAL_LET_TRANS THEN EXISTS_TAC `d * abs(f'(z:real))` THEN
(CONJ_TAC THENL
[MATCH_MP_TAC
REAL_LE_RMUL;
MATCH_MP_TAC
REAL_LT_LMUL THEN
ASM_REWRITE_TAC[] THEN FIRST_X_ASSUM MATCH_MP_TAC]) THEN
POP_ASSUM_LIST(MP_TAC o end_itlist CONJ) THEN REAL_ARITH_TAC);;
(* ------------------------------------------------------------------------- *)
(* Appropriate multiple of poly on rational is an integer. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* First show any root is surrounded by an other-root-free zone. *)
(* ------------------------------------------------------------------------- *)
let POLY_ROOT_SEPARATE_LE = prove
(`!p x. poly p x = &0 /\ ~(poly p = poly [])
==> ?d. &0 < d /\
!x'. &0 < abs(x' - x) /\ abs(x' - x) < d
==> ~(poly p x' = &0)`,
let POLY_ROOT_SEPARATE_LT = prove
(`!p x. poly p x = &0 /\ ~(poly p = poly [])
==> ?d. &0 < d /\
!x'. &0 < abs(x' - x) /\ abs(x' - x) <= d
==> ~(poly p x' = &0)`,
REPEAT GEN_TAC THEN DISCH_THEN(MP_TAC o MATCH_MP
POLY_ROOT_SEPARATE_LE) THEN
DISCH_THEN(X_CHOOSE_THEN `d:real` STRIP_ASSUME_TAC) THEN
EXISTS_TAC `d / &2` THEN ASM_MESON_TAC[REAL_ARITH
`&0 < d ==> &0 < d / &2 /\ (x <= d / &2 ==> x < d)`]);;
(* ------------------------------------------------------------------------- *)
(* And also there is a positive bound on a polynomial in an interval. *)
(* ------------------------------------------------------------------------- *)
let POLY_BOUND_INTERVAL = prove
(`!p d x. ?M. &0 < M /\ !x'. abs(x' - x) <= d ==> abs(poly p x') < M`,
REPEAT STRIP_TAC THEN
MP_TAC(SPECL [`poly p`; `x - d`; `x + d`]
CONT_BOUNDED_ABS) THEN
REWRITE_TAC[REWRITE_RULE[ETA_AX] (SPEC_ALL
POLY_CONT)] THEN
DISCH_THEN(X_CHOOSE_TAC `M:real`) THEN EXISTS_TAC `&1 + abs M` THEN
CONJ_TAC THENL [REAL_ARITH_TAC; ALL_TAC] THEN REPEAT STRIP_TAC THEN
MATCH_MP_TAC
REAL_LET_TRANS THEN EXISTS_TAC `M:real` THEN CONJ_TAC THENL
[FIRST_X_ASSUM MATCH_MP_TAC THEN POP_ASSUM MP_TAC; ALL_TAC] THEN
REAL_ARITH_TAC);;
(* ------------------------------------------------------------------------- *)
(* Now put these together to get the interval we need. *)
(* ------------------------------------------------------------------------- *)
let LIOUVILLE_INTERVAL = prove
(`!p x. poly p x = &0 /\ ~(poly p = poly [])
==> ?c. &0 < c /\
(!x'. abs(x' - x) <= c
==> abs(poly(
poly_diff p) x') < &1 / c) /\
(!x'. &0 < abs(x' - x) /\ abs(x' - x) <= c
==> ~(poly p x' = &0))`,
(* ------------------------------------------------------------------------- *)
(* Liouville's approximation theorem. *)
(* ------------------------------------------------------------------------- *)
let LIOUVILLE = prove
(`!x. algebraic x
==> ?n c. c > &0 /\
!p q. ~(q = 0) ==> &p / &q = x \/
abs(x - &p / &q) > c / &q pow n`,
(* ------------------------------------------------------------------------- *)
(* Corollary for algebraic irrationals. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Liouville's constant. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Some bounds on the partial sums and hence convergence. *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* Main proof. *)
(* ------------------------------------------------------------------------- *)