(* ========================================================================= *) (* Fundamental theorem of algebra. *) (* ========================================================================= *) needs "Complex/complex_transc.ml";; needs "Complex/cpoly.ml";; prioritize_complex();; (* ------------------------------------------------------------------------- *) (* A cute trick to reduce magnitude of unimodular number. *) (* ------------------------------------------------------------------------- *)let SQRT_SOS_LT_1 =prove (`!x y. sqrt(x pow 2 + y pow 2) < &1 <=> x pow 2 + y pow 2 < &1`,let SQRT_SOS_EQ_1 =prove (`!x y. (sqrt(x pow 2 + y pow 2) = &1) <=> (x pow 2 + y pow 2 = &1)`,(* ------------------------------------------------------------------------- *) (* Hence we can always reduce modulus of 1 + b z^n if nonzero *) (* ------------------------------------------------------------------------- *)let UNIMODULAR_REDUCE_NORM =prove (`!z. (norm(z) = &1) ==> norm(z + Cx(&1)) < &1 \/ norm(z - Cx(&1)) < &1 \/ norm(z + ii) < &1 \/ norm(z - ii) < &1`,(* ------------------------------------------------------------------------- *) (* Basic lemmas about polynomials. *) (* ------------------------------------------------------------------------- *)let REDUCE_POLY_SIMPLE =prove (`!b n. ~(b = Cx(&0)) /\ ~(n = 0) ==> ?z. norm(Cx(&1) + b * z pow n) < &1`,(* ------------------------------------------------------------------------- *) (* Offsetting the variable in a polynomial gives another of same degree. *) (* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *) (* Bolzano-Weierstrass type property for closed disc in complex plane. *) (* ------------------------------------------------------------------------- *)let POLY_BOUND_EXISTS =prove (`!p r. ?m. &0 < m /\ !z. norm(z) <= r ==> norm(poly p z) <= m`,let METRIC_BOUND_LEMMA =prove (`!x y. norm(x - y) <= abs(Re(x) - Re(y)) + abs(Im(x) - Im(y))`,(* ------------------------------------------------------------------------- *) (* Polynomial is continuous. *) (* ------------------------------------------------------------------------- *)let BOLZANO_WEIERSTRASS_COMPLEX_DISC =prove (`!s r. (!n. norm(s n) <= r) ==> ?f z. subseq f /\ !e. &0 < e ==> ?N. !n. n >= N ==> norm(s(f n) - z) < e`,(* ------------------------------------------------------------------------- *) (* Hence a polynomial attains minimum on a closed disc in the complex plane. *) (* ------------------------------------------------------------------------- *)let POLY_CONT =prove (`!p z e. &0 < e ==> ?d. &0 < d /\ !w. &0 < norm(w - z) /\ norm(w - z) < d ==> norm(poly p w - poly p z) < e`,(* ------------------------------------------------------------------------- *) (* Nonzero polynomial in z goes to infinity as z does. *) (* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *) (* Hence polynomial's modulus attains its minimum somewhere. *) (* ------------------------------------------------------------------------- *)let POLY_MINIMUM_MODULUS_DISC =prove (`!p r. ?z. !w. norm(w) <= r ==> norm(poly p z) <= norm(poly p w)`,(* ------------------------------------------------------------------------- *) (* Constant function (non-syntactic characterization). *) (* ------------------------------------------------------------------------- *)let POLY_MINIMUM_MODULUS =prove (`!p. ?z. !w. norm(poly p z) <= norm(poly p w)`,(* ------------------------------------------------------------------------- *) (* Decomposition of polynomial, skipping zero coefficients after the first. *) (* ------------------------------------------------------------------------- *) (* ------------------------------------------------------------------------- *) (* Fundamental theorem. *) (* ------------------------------------------------------------------------- *)let constant = new_definition `constant f = !w z. f(w) = f(z)`;;(* ------------------------------------------------------------------------- *) (* Alternative version with a syntactic notion of constant polynomial. *) (* ------------------------------------------------------------------------- *)let FUNDAMENTAL_THEOREM_OF_ALGEBRA =prove (`!p. ~constant(poly p) ==> ?z. poly p z = Cx(&0)`,