(* Title : NthRoot.thy Author : Jacques D. Fleuriot Copyright : 1998 University of Cambridge Conversion to Isar and new proofs by Lawrence C Paulson, 2004 *) header {* Nth Roots of Real Numbers *} theory NthRoot imports SEQ Parity Deriv begin subsection {* Existence of Nth Root *} text {* Existence follows from the Intermediate Value Theorem *} lemma realpow_pos_nth: assumes n: "0 < n" assumes a: "0 < a" shows "∃r>0. r ^ n = (a::real)" proof - have "∃r≥0. r ≤ (max 1 a) ∧ r ^ n = a" proof (rule IVT) show "0 ^ n ≤ a" using n a by (simp add: power_0_left) show "0 ≤ max 1 a" by simp from n have n1: "1 ≤ n" by simp have "a ≤ max 1 a ^ 1" by simp also have "max 1 a ^ 1 ≤ max 1 a ^ n" using n1 by (rule power_increasing, simp) finally show "a ≤ max 1 a ^ n" . show "∀r. 0 ≤ r ∧ r ≤ max 1 a --> isCont (λx. x ^ n) r" by (simp add: isCont_power) qed then obtain r where r: "0 ≤ r ∧ r ^ n = a" by fast with n a have "r ≠ 0" by (auto simp add: power_0_left) with r have "0 < r ∧ r ^ n = a" by simp thus ?thesis .. qed (* Used by Integration/RealRandVar.thy in AFP *) lemma realpow_pos_nth2: "(0::real) < a ==> ∃r>0. r ^ Suc n = a" by (blast intro: realpow_pos_nth) text {* Uniqueness of nth positive root *} lemma realpow_pos_nth_unique: "[|0 < n; 0 < a|] ==> ∃!r. 0 < r ∧ r ^ n = (a::real)" apply (auto intro!: realpow_pos_nth) apply (rule_tac n=n in power_eq_imp_eq_base, simp_all) done subsection {* Nth Root *} text {* We define roots of negative reals such that @{term "root n (- x) = - root n x"}. This allows us to omit side conditions from many theorems. *} definition root :: "[nat, real] => real" where "root n x = (if 0 < x then (THE u. 0 < u ∧ u ^ n = x) else if x < 0 then - (THE u. 0 < u ∧ u ^ n = - x) else 0)" lemma real_root_zero [simp]: "root n 0 = 0" unfolding root_def by simp lemma real_root_minus: "0 < n ==> root n (- x) = - root n x" unfolding root_def by simp lemma real_root_gt_zero: "[|0 < n; 0 < x|] ==> 0 < root n x" apply (simp add: root_def) apply (drule (1) realpow_pos_nth_unique) apply (erule theI' [THEN conjunct1]) done lemma real_root_pow_pos: (* TODO: rename *) "[|0 < n; 0 < x|] ==> root n x ^ n = x" apply (simp add: root_def) apply (drule (1) realpow_pos_nth_unique) apply (erule theI' [THEN conjunct2]) done lemma real_root_pow_pos2 [simp]: (* TODO: rename *) "[|0 < n; 0 ≤ x|] ==> root n x ^ n = x" by (auto simp add: order_le_less real_root_pow_pos) lemma odd_pos: "odd (n::nat) ==> 0 < n" by (cases n, simp_all) lemma odd_real_root_pow: "odd n ==> root n x ^ n = x" apply (rule_tac x=0 and y=x in linorder_le_cases) apply (erule (1) real_root_pow_pos2 [OF odd_pos]) apply (subgoal_tac "root n (- x) ^ n = - x") apply (simp add: real_root_minus odd_pos) apply (simp add: odd_pos) done lemma real_root_ge_zero: "[|0 < n; 0 ≤ x|] ==> 0 ≤ root n x" by (auto simp add: order_le_less real_root_gt_zero) lemma real_root_power_cancel: "[|0 < n; 0 ≤ x|] ==> root n (x ^ n) = x" apply (subgoal_tac "0 ≤ x ^ n") apply (subgoal_tac "0 ≤ root n (x ^ n)") apply (subgoal_tac "root n (x ^ n) ^ n = x ^ n") apply (erule (3) power_eq_imp_eq_base) apply (erule (1) real_root_pow_pos2) apply (erule (1) real_root_ge_zero) apply (erule zero_le_power) done lemma odd_real_root_power_cancel: "odd n ==> root n (x ^ n) = x" apply (rule_tac x=0 and y=x in linorder_le_cases) apply (erule (1) real_root_power_cancel [OF odd_pos]) apply (subgoal_tac "root n ((- x) ^ n) = - x") apply (simp add: real_root_minus odd_pos) apply (erule real_root_power_cancel [OF odd_pos], simp) done lemma real_root_pos_unique: "[|0 < n; 0 ≤ y; y ^ n = x|] ==> root n x = y" by (erule subst, rule real_root_power_cancel) lemma odd_real_root_unique: "[|odd n; y ^ n = x|] ==> root n x = y" by (erule subst, rule odd_real_root_power_cancel) lemma real_root_one [simp]: "0 < n ==> root n 1 = 1" by (simp add: real_root_pos_unique) text {* Root function is strictly monotonic, hence injective *} lemma real_root_less_mono_lemma: "[|0 < n; 0 ≤ x; x < y|] ==> root n x < root n y" apply (subgoal_tac "0 ≤ y") apply (subgoal_tac "root n x ^ n < root n y ^ n") apply (erule power_less_imp_less_base) apply (erule (1) real_root_ge_zero) apply simp apply simp done lemma real_root_less_mono: "[|0 < n; x < y|] ==> root n x < root n y" apply (cases "0 ≤ x") apply (erule (2) real_root_less_mono_lemma) apply (cases "0 ≤ y") apply (rule_tac y=0 in order_less_le_trans) apply (subgoal_tac "0 < root n (- x)") apply (simp add: real_root_minus) apply (simp add: real_root_gt_zero) apply (simp add: real_root_ge_zero) apply (subgoal_tac "root n (- y) < root n (- x)") apply (simp add: real_root_minus) apply (simp add: real_root_less_mono_lemma) done lemma real_root_le_mono: "[|0 < n; x ≤ y|] ==> root n x ≤ root n y" by (auto simp add: order_le_less real_root_less_mono) lemma real_root_less_iff [simp]: "0 < n ==> (root n x < root n y) = (x < y)" apply (cases "x < y") apply (simp add: real_root_less_mono) apply (simp add: linorder_not_less real_root_le_mono) done lemma real_root_le_iff [simp]: "0 < n ==> (root n x ≤ root n y) = (x ≤ y)" apply (cases "x ≤ y") apply (simp add: real_root_le_mono) apply (simp add: linorder_not_le real_root_less_mono) done lemma real_root_eq_iff [simp]: "0 < n ==> (root n x = root n y) = (x = y)" by (simp add: order_eq_iff) lemmas real_root_gt_0_iff [simp] = real_root_less_iff [where x=0, simplified] lemmas real_root_lt_0_iff [simp] = real_root_less_iff [where y=0, simplified] lemmas real_root_ge_0_iff [simp] = real_root_le_iff [where x=0, simplified] lemmas real_root_le_0_iff [simp] = real_root_le_iff [where y=0, simplified] lemmas real_root_eq_0_iff [simp] = real_root_eq_iff [where y=0, simplified] lemma real_root_gt_1_iff [simp]: "0 < n ==> (1 < root n y) = (1 < y)" by (insert real_root_less_iff [where x=1], simp) lemma real_root_lt_1_iff [simp]: "0 < n ==> (root n x < 1) = (x < 1)" by (insert real_root_less_iff [where y=1], simp) lemma real_root_ge_1_iff [simp]: "0 < n ==> (1 ≤ root n y) = (1 ≤ y)" by (insert real_root_le_iff [where x=1], simp) lemma real_root_le_1_iff [simp]: "0 < n ==> (root n x ≤ 1) = (x ≤ 1)" by (insert real_root_le_iff [where y=1], simp) lemma real_root_eq_1_iff [simp]: "0 < n ==> (root n x = 1) = (x = 1)" by (insert real_root_eq_iff [where y=1], simp) text {* Roots of roots *} lemma real_root_Suc_0 [simp]: "root (Suc 0) x = x" by (simp add: odd_real_root_unique) lemma real_root_pos_mult_exp: "[|0 < m; 0 < n; 0 < x|] ==> root (m * n) x = root m (root n x)" by (rule real_root_pos_unique, simp_all add: power_mult) lemma real_root_mult_exp: "[|0 < m; 0 < n|] ==> root (m * n) x = root m (root n x)" apply (rule linorder_cases [where x=x and y=0]) apply (subgoal_tac "root (m * n) (- x) = root m (root n (- x))") apply (simp add: real_root_minus) apply (simp_all add: real_root_pos_mult_exp) done lemma real_root_commute: "[|0 < m; 0 < n|] ==> root m (root n x) = root n (root m x)" by (simp add: real_root_mult_exp [symmetric] mult_commute) text {* Monotonicity in first argument *} lemma real_root_strict_decreasing: "[|0 < n; n < N; 1 < x|] ==> root N x < root n x" apply (subgoal_tac "root n (root N x) ^ n < root N (root n x) ^ N", simp) apply (simp add: real_root_commute power_strict_increasing del: real_root_pow_pos2) done lemma real_root_strict_increasing: "[|0 < n; n < N; 0 < x; x < 1|] ==> root n x < root N x" apply (subgoal_tac "root N (root n x) ^ N < root n (root N x) ^ n", simp) apply (simp add: real_root_commute power_strict_decreasing del: real_root_pow_pos2) done lemma real_root_decreasing: "[|0 < n; n < N; 1 ≤ x|] ==> root N x ≤ root n x" by (auto simp add: order_le_less real_root_strict_decreasing) lemma real_root_increasing: "[|0 < n; n < N; 0 ≤ x; x ≤ 1|] ==> root n x ≤ root N x" by (auto simp add: order_le_less real_root_strict_increasing) text {* Roots of multiplication and division *} lemma real_root_mult_lemma: "[|0 < n; 0 ≤ x; 0 ≤ y|] ==> root n (x * y) = root n x * root n y" by (simp add: real_root_pos_unique mult_nonneg_nonneg power_mult_distrib) lemma real_root_inverse_lemma: "[|0 < n; 0 ≤ x|] ==> root n (inverse x) = inverse (root n x)" by (simp add: real_root_pos_unique power_inverse [symmetric]) lemma real_root_mult: assumes n: "0 < n" shows "root n (x * y) = root n x * root n y" proof (rule linorder_le_cases, rule_tac [!] linorder_le_cases) assume "0 ≤ x" and "0 ≤ y" thus ?thesis by (rule real_root_mult_lemma [OF n]) next assume "0 ≤ x" and "y ≤ 0" hence "0 ≤ x" and "0 ≤ - y" by simp_all hence "root n (x * - y) = root n x * root n (- y)" by (rule real_root_mult_lemma [OF n]) thus ?thesis by (simp add: real_root_minus [OF n]) next assume "x ≤ 0" and "0 ≤ y" hence "0 ≤ - x" and "0 ≤ y" by simp_all hence "root n (- x * y) = root n (- x) * root n y" by (rule real_root_mult_lemma [OF n]) thus ?thesis by (simp add: real_root_minus [OF n]) next assume "x ≤ 0" and "y ≤ 0" hence "0 ≤ - x" and "0 ≤ - y" by simp_all hence "root n (- x * - y) = root n (- x) * root n (- y)" by (rule real_root_mult_lemma [OF n]) thus ?thesis by (simp add: real_root_minus [OF n]) qed lemma real_root_inverse: assumes n: "0 < n" shows "root n (inverse x) = inverse (root n x)" proof (rule linorder_le_cases) assume "0 ≤ x" thus ?thesis by (rule real_root_inverse_lemma [OF n]) next assume "x ≤ 0" hence "0 ≤ - x" by simp hence "root n (inverse (- x)) = inverse (root n (- x))" by (rule real_root_inverse_lemma [OF n]) thus ?thesis by (simp add: real_root_minus [OF n]) qed lemma real_root_divide: "0 < n ==> root n (x / y) = root n x / root n y" by (simp add: divide_inverse real_root_mult real_root_inverse) lemma real_root_power: "0 < n ==> root n (x ^ k) = root n x ^ k" by (induct k, simp_all add: real_root_mult) lemma real_root_abs: "0 < n ==> root n ¦x¦ = ¦root n x¦" by (simp add: abs_if real_root_minus) text {* Continuity and derivatives *} lemma isCont_root_pos: assumes n: "0 < n" assumes x: "0 < x" shows "isCont (root n) x" proof - have "isCont (root n) (root n x ^ n)" proof (rule isCont_inverse_function [where f="λa. a ^ n"]) show "0 < root n x" using n x by simp show "∀z. ¦z - root n x¦ ≤ root n x --> root n (z ^ n) = z" by (simp add: abs_le_iff real_root_power_cancel n) show "∀z. ¦z - root n x¦ ≤ root n x --> isCont (λa. a ^ n) z" by (simp add: isCont_power) qed thus ?thesis using n x by simp qed lemma isCont_root_neg: "[|0 < n; x < 0|] ==> isCont (root n) x" apply (subgoal_tac "isCont (λx. - root n (- x)) x") apply (simp add: real_root_minus) apply (rule isCont_o2 [OF isCont_minus [OF isCont_ident]]) apply (simp add: isCont_minus isCont_root_pos) done lemma isCont_root_zero: "0 < n ==> isCont (root n) 0" unfolding isCont_def apply (rule LIM_I) apply (rule_tac x="r ^ n" in exI, safe) apply (simp add: zero_less_power) apply (simp add: real_root_abs [symmetric]) apply (rule_tac n="n" in power_less_imp_less_base, simp_all) done lemma isCont_real_root: "0 < n ==> isCont (root n) x" apply (rule_tac x=x and y=0 in linorder_cases) apply (simp_all add: isCont_root_pos isCont_root_neg isCont_root_zero) done lemma DERIV_real_root: assumes n: "0 < n" assumes x: "0 < x" shows "DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))" proof (rule DERIV_inverse_function) show "0 < x" using x . show "x < x + 1" by simp show "∀y. 0 < y ∧ y < x + 1 --> root n y ^ n = y" using n by simp show "DERIV (λx. x ^ n) (root n x) :> real n * root n x ^ (n - Suc 0)" by (rule DERIV_pow) show "real n * root n x ^ (n - Suc 0) ≠ 0" using n x by simp show "isCont (root n) x" using n by (rule isCont_real_root) qed lemma DERIV_odd_real_root: assumes n: "odd n" assumes x: "x ≠ 0" shows "DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))" proof (rule DERIV_inverse_function) show "x - 1 < x" by simp show "x < x + 1" by simp show "∀y. x - 1 < y ∧ y < x + 1 --> root n y ^ n = y" using n by (simp add: odd_real_root_pow) show "DERIV (λx. x ^ n) (root n x) :> real n * root n x ^ (n - Suc 0)" by (rule DERIV_pow) show "real n * root n x ^ (n - Suc 0) ≠ 0" using odd_pos [OF n] x by simp show "isCont (root n) x" using odd_pos [OF n] by (rule isCont_real_root) qed subsection {* Square Root *} definition sqrt :: "real => real" where "sqrt = root 2" lemma pos2: "0 < (2::nat)" by simp lemma real_sqrt_unique: "[|y² = x; 0 ≤ y|] ==> sqrt x = y" unfolding sqrt_def by (rule real_root_pos_unique [OF pos2]) lemma real_sqrt_abs [simp]: "sqrt (x²) = ¦x¦" apply (rule real_sqrt_unique) apply (rule power2_abs) apply (rule abs_ge_zero) done lemma real_sqrt_pow2 [simp]: "0 ≤ x ==> (sqrt x)² = x" unfolding sqrt_def by (rule real_root_pow_pos2 [OF pos2]) lemma real_sqrt_pow2_iff [simp]: "((sqrt x)² = x) = (0 ≤ x)" apply (rule iffI) apply (erule subst) apply (rule zero_le_power2) apply (erule real_sqrt_pow2) done lemma real_sqrt_zero [simp]: "sqrt 0 = 0" unfolding sqrt_def by (rule real_root_zero) lemma real_sqrt_one [simp]: "sqrt 1 = 1" unfolding sqrt_def by (rule real_root_one [OF pos2]) lemma real_sqrt_minus: "sqrt (- x) = - sqrt x" unfolding sqrt_def by (rule real_root_minus [OF pos2]) lemma real_sqrt_mult: "sqrt (x * y) = sqrt x * sqrt y" unfolding sqrt_def by (rule real_root_mult [OF pos2]) lemma real_sqrt_inverse: "sqrt (inverse x) = inverse (sqrt x)" unfolding sqrt_def by (rule real_root_inverse [OF pos2]) lemma real_sqrt_divide: "sqrt (x / y) = sqrt x / sqrt y" unfolding sqrt_def by (rule real_root_divide [OF pos2]) lemma real_sqrt_power: "sqrt (x ^ k) = sqrt x ^ k" unfolding sqrt_def by (rule real_root_power [OF pos2]) lemma real_sqrt_gt_zero: "0 < x ==> 0 < sqrt x" unfolding sqrt_def by (rule real_root_gt_zero [OF pos2]) lemma real_sqrt_ge_zero: "0 ≤ x ==> 0 ≤ sqrt x" unfolding sqrt_def by (rule real_root_ge_zero [OF pos2]) lemma real_sqrt_less_mono: "x < y ==> sqrt x < sqrt y" unfolding sqrt_def by (rule real_root_less_mono [OF pos2]) lemma real_sqrt_le_mono: "x ≤ y ==> sqrt x ≤ sqrt y" unfolding sqrt_def by (rule real_root_le_mono [OF pos2]) lemma real_sqrt_less_iff [simp]: "(sqrt x < sqrt y) = (x < y)" unfolding sqrt_def by (rule real_root_less_iff [OF pos2]) lemma real_sqrt_le_iff [simp]: "(sqrt x ≤ sqrt y) = (x ≤ y)" unfolding sqrt_def by (rule real_root_le_iff [OF pos2]) lemma real_sqrt_eq_iff [simp]: "(sqrt x = sqrt y) = (x = y)" unfolding sqrt_def by (rule real_root_eq_iff [OF pos2]) lemmas real_sqrt_gt_0_iff [simp] = real_sqrt_less_iff [where x=0, simplified] lemmas real_sqrt_lt_0_iff [simp] = real_sqrt_less_iff [where y=0, simplified] lemmas real_sqrt_ge_0_iff [simp] = real_sqrt_le_iff [where x=0, simplified] lemmas real_sqrt_le_0_iff [simp] = real_sqrt_le_iff [where y=0, simplified] lemmas real_sqrt_eq_0_iff [simp] = real_sqrt_eq_iff [where y=0, simplified] lemmas real_sqrt_gt_1_iff [simp] = real_sqrt_less_iff [where x=1, simplified] lemmas real_sqrt_lt_1_iff [simp] = real_sqrt_less_iff [where y=1, simplified] lemmas real_sqrt_ge_1_iff [simp] = real_sqrt_le_iff [where x=1, simplified] lemmas real_sqrt_le_1_iff [simp] = real_sqrt_le_iff [where y=1, simplified] lemmas real_sqrt_eq_1_iff [simp] = real_sqrt_eq_iff [where y=1, simplified] lemma isCont_real_sqrt: "isCont sqrt x" unfolding sqrt_def by (rule isCont_real_root [OF pos2]) lemma DERIV_real_sqrt: "0 < x ==> DERIV sqrt x :> inverse (sqrt x) / 2" unfolding sqrt_def by (rule DERIV_real_root [OF pos2, simplified]) lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" apply auto apply (cut_tac x = x and y = 0 in linorder_less_linear) apply (simp add: zero_less_mult_iff) done lemma real_sqrt_abs2 [simp]: "sqrt(x*x) = ¦x¦" apply (subst power2_eq_square [symmetric]) apply (rule real_sqrt_abs) done lemma real_sqrt_pow2_gt_zero: "0 < x ==> 0 < (sqrt x)²" by simp (* TODO: delete *) lemma real_sqrt_not_eq_zero: "0 < x ==> sqrt x ≠ 0" by simp (* TODO: delete *) lemma real_inv_sqrt_pow2: "0 < x ==> inverse (sqrt(x)) ^ 2 = inverse x" by (simp add: power_inverse [symmetric]) lemma real_sqrt_eq_zero_cancel: "[| 0 ≤ x; sqrt(x) = 0|] ==> x = 0" by simp lemma real_sqrt_ge_one: "1 ≤ x ==> 1 ≤ sqrt x" by simp lemma real_sqrt_two_gt_zero [simp]: "0 < sqrt 2" by simp lemma real_sqrt_two_ge_zero [simp]: "0 ≤ sqrt 2" by simp lemma real_sqrt_two_gt_one [simp]: "1 < sqrt 2" by simp lemma sqrt_divide_self_eq: assumes nneg: "0 ≤ x" shows "sqrt x / x = inverse (sqrt x)" proof cases assume "x=0" thus ?thesis by simp next assume nz: "x≠0" hence pos: "0<x" using nneg by arith show ?thesis proof (rule right_inverse_eq [THEN iffD1, THEN sym]) show "sqrt x / x ≠ 0" by (simp add: divide_inverse nneg nz) show "inverse (sqrt x) / (sqrt x / x) = 1" by (simp add: divide_inverse mult_assoc [symmetric] power2_eq_square [symmetric] real_inv_sqrt_pow2 pos nz) qed qed lemma real_divide_square_eq [simp]: "(((r::real) * a) / (r * r)) = a / r" apply (simp add: divide_inverse) apply (case_tac "r=0") apply (auto simp add: mult_ac) done lemma lemma_real_divide_sqrt_less: "0 < u ==> u / sqrt 2 < u" by (simp add: divide_less_eq mult_compare_simps) lemma four_x_squared: fixes x::real shows "4 * x² = (2 * x)²" by (simp add: power2_eq_square) subsection {* Square Root of Sum of Squares *} lemma real_sqrt_mult_self_sum_ge_zero [simp]: "0 ≤ sqrt(x*x + y*y)" by (rule real_sqrt_ge_zero [OF sum_squares_ge_zero]) lemma real_sqrt_sum_squares_ge_zero [simp]: "0 ≤ sqrt (x² + y²)" by simp declare real_sqrt_sum_squares_ge_zero [THEN abs_of_nonneg, simp] lemma real_sqrt_sum_squares_mult_ge_zero [simp]: "0 ≤ sqrt ((x² + y²)*(xa² + ya²))" by (auto intro!: real_sqrt_ge_zero simp add: zero_le_mult_iff) lemma real_sqrt_sum_squares_mult_squared_eq [simp]: "sqrt ((x² + y²) * (xa² + ya²)) ^ 2 = (x² + y²) * (xa² + ya²)" by (auto simp add: zero_le_mult_iff) lemma real_sqrt_sum_squares_eq_cancel: "sqrt (x² + y²) = x ==> y = 0" by (drule_tac f = "%x. x²" in arg_cong, simp) lemma real_sqrt_sum_squares_eq_cancel2: "sqrt (x² + y²) = y ==> x = 0" by (drule_tac f = "%x. x²" in arg_cong, simp) lemma real_sqrt_sum_squares_ge1 [simp]: "x ≤ sqrt (x² + y²)" by (rule power2_le_imp_le, simp_all) lemma real_sqrt_sum_squares_ge2 [simp]: "y ≤ sqrt (x² + y²)" by (rule power2_le_imp_le, simp_all) lemma real_sqrt_ge_abs1 [simp]: "¦x¦ ≤ sqrt (x² + y²)" by (rule power2_le_imp_le, simp_all) lemma real_sqrt_ge_abs2 [simp]: "¦y¦ ≤ sqrt (x² + y²)" by (rule power2_le_imp_le, simp_all) lemma le_real_sqrt_sumsq [simp]: "x ≤ sqrt (x * x + y * y)" by (simp add: power2_eq_square [symmetric]) lemma power2_sum: fixes x y :: "'a::{number_ring,recpower}" shows "(x + y)² = x² + y² + 2 * x * y" by (simp add: ring_distribs power2_eq_square) lemma power2_diff: fixes x y :: "'a::{number_ring,recpower}" shows "(x - y)² = x² + y² - 2 * x * y" by (simp add: ring_distribs power2_eq_square) lemma real_sqrt_sum_squares_triangle_ineq: "sqrt ((a + c)² + (b + d)²) ≤ sqrt (a² + b²) + sqrt (c² + d²)" apply (rule power2_le_imp_le, simp) apply (simp add: power2_sum) apply (simp only: mult_assoc right_distrib [symmetric]) apply (rule mult_left_mono) apply (rule power2_le_imp_le) apply (simp add: power2_sum power_mult_distrib) apply (simp add: ring_distribs) apply (subgoal_tac "0 ≤ b² * c² + a² * d² - 2 * (a * c) * (b * d)", simp) apply (rule_tac b="(a * d - b * c)²" in ord_le_eq_trans) apply (rule zero_le_power2) apply (simp add: power2_diff power_mult_distrib) apply (simp add: mult_nonneg_nonneg) apply simp apply (simp add: add_increasing) done lemma real_sqrt_sum_squares_less: "[|¦x¦ < u / sqrt 2; ¦y¦ < u / sqrt 2|] ==> sqrt (x² + y²) < u" apply (rule power2_less_imp_less, simp) apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) apply (drule power_strict_mono [OF _ abs_ge_zero pos2]) apply (simp add: power_divide) apply (drule order_le_less_trans [OF abs_ge_zero]) apply (simp add: zero_less_divide_iff) done text{*Needed for the infinitely close relation over the nonstandard complex numbers*} lemma lemma_sqrt_hcomplex_capprox: "[| 0 < u; x < u/2; y < u/2; 0 ≤ x; 0 ≤ y |] ==> sqrt (x² + y²) < u" apply (rule_tac y = "u/sqrt 2" in order_le_less_trans) apply (erule_tac [2] lemma_real_divide_sqrt_less) apply (rule power2_le_imp_le) apply (auto simp add: real_0_le_divide_iff power_divide) apply (rule_tac t = "u²" in real_sum_of_halves [THEN subst]) apply (rule add_mono) apply (auto simp add: four_x_squared simp del: realpow_Suc intro: power_mono) done text "Legacy theorem names:" lemmas real_root_pos2 = real_root_power_cancel lemmas real_root_pos_pos = real_root_gt_zero [THEN order_less_imp_le] lemmas real_root_pos_pos_le = real_root_ge_zero lemmas real_sqrt_mult_distrib = real_sqrt_mult lemmas real_sqrt_mult_distrib2 = real_sqrt_mult lemmas real_sqrt_eq_zero_cancel_iff = real_sqrt_eq_0_iff (* needed for CauchysMeanTheorem.het_base from AFP *) lemma real_root_pos: "0 < x ==> root (Suc n) (x ^ (Suc n)) = x" by (rule real_root_power_cancel [OF zero_less_Suc order_less_imp_le]) end
lemma realpow_pos_nth:
[| 0 < n; 0 < a |] ==> ∃r>0. r ^ n = a
lemma realpow_pos_nth2:
0 < a ==> ∃r>0. r ^ Suc n = a
lemma realpow_pos_nth_unique:
[| 0 < n; 0 < a |] ==> ∃!r. 0 < r ∧ r ^ n = a
lemma real_root_zero:
root n 0 = 0
lemma real_root_minus:
0 < n ==> root n (- x) = - root n x
lemma real_root_gt_zero:
[| 0 < n; 0 < x |] ==> 0 < root n x
lemma real_root_pow_pos:
[| 0 < n; 0 < x |] ==> root n x ^ n = x
lemma real_root_pow_pos2:
[| 0 < n; 0 ≤ x |] ==> root n x ^ n = x
lemma odd_pos:
odd n ==> 0 < n
lemma odd_real_root_pow:
odd n ==> root n x ^ n = x
lemma real_root_ge_zero:
[| 0 < n; 0 ≤ x |] ==> 0 ≤ root n x
lemma real_root_power_cancel:
[| 0 < n; 0 ≤ x |] ==> root n (x ^ n) = x
lemma odd_real_root_power_cancel:
odd n ==> root n (x ^ n) = x
lemma real_root_pos_unique:
[| 0 < n; 0 ≤ y; y ^ n = x |] ==> root n x = y
lemma odd_real_root_unique:
[| odd n; y ^ n = x |] ==> root n x = y
lemma real_root_one:
0 < n ==> root n 1 = 1
lemma real_root_less_mono_lemma:
[| 0 < n; 0 ≤ x; x < y |] ==> root n x < root n y
lemma real_root_less_mono:
[| 0 < n; x < y |] ==> root n x < root n y
lemma real_root_le_mono:
[| 0 < n; x ≤ y |] ==> root n x ≤ root n y
lemma real_root_less_iff:
0 < n ==> (root n x < root n y) = (x < y)
lemma real_root_le_iff:
0 < n ==> (root n x ≤ root n y) = (x ≤ y)
lemma real_root_eq_iff:
0 < n ==> (root n x = root n y) = (x = y)
lemma real_root_gt_0_iff:
0 < n ==> (0 < root n y) = (0 < y)
lemma real_root_lt_0_iff:
0 < n ==> (root n x < 0) = (x < 0)
lemma real_root_ge_0_iff:
0 < n ==> (0 ≤ root n y) = (0 ≤ y)
lemma real_root_le_0_iff:
0 < n ==> (root n x ≤ 0) = (x ≤ 0)
lemma real_root_eq_0_iff:
0 < n ==> (root n x = 0) = (x = 0)
lemma real_root_gt_1_iff:
0 < n ==> (1 < root n y) = (1 < y)
lemma real_root_lt_1_iff:
0 < n ==> (root n x < 1) = (x < 1)
lemma real_root_ge_1_iff:
0 < n ==> (1 ≤ root n y) = (1 ≤ y)
lemma real_root_le_1_iff:
0 < n ==> (root n x ≤ 1) = (x ≤ 1)
lemma real_root_eq_1_iff:
0 < n ==> (root n x = 1) = (x = 1)
lemma real_root_Suc_0:
root (Suc 0) x = x
lemma real_root_pos_mult_exp:
[| 0 < m; 0 < n; 0 < x |] ==> root (m * n) x = root m (root n x)
lemma real_root_mult_exp:
[| 0 < m; 0 < n |] ==> root (m * n) x = root m (root n x)
lemma real_root_commute:
[| 0 < m; 0 < n |] ==> root m (root n x) = root n (root m x)
lemma real_root_strict_decreasing:
[| 0 < n; n < N; 1 < x |] ==> root N x < root n x
lemma real_root_strict_increasing:
[| 0 < n; n < N; 0 < x; x < 1 |] ==> root n x < root N x
lemma real_root_decreasing:
[| 0 < n; n < N; 1 ≤ x |] ==> root N x ≤ root n x
lemma real_root_increasing:
[| 0 < n; n < N; 0 ≤ x; x ≤ 1 |] ==> root n x ≤ root N x
lemma real_root_mult_lemma:
[| 0 < n; 0 ≤ x; 0 ≤ y |] ==> root n (x * y) = root n x * root n y
lemma real_root_inverse_lemma:
[| 0 < n; 0 ≤ x |] ==> root n (inverse x) = inverse (root n x)
lemma real_root_mult:
0 < n ==> root n (x * y) = root n x * root n y
lemma real_root_inverse:
0 < n ==> root n (inverse x) = inverse (root n x)
lemma real_root_divide:
0 < n ==> root n (x / y) = root n x / root n y
lemma real_root_power:
0 < n ==> root n (x ^ k) = root n x ^ k
lemma real_root_abs:
0 < n ==> root n ¦x¦ = ¦root n x¦
lemma isCont_root_pos:
[| 0 < n; 0 < x |] ==> isCont (root n) x
lemma isCont_root_neg:
[| 0 < n; x < 0 |] ==> isCont (root n) x
lemma isCont_root_zero:
0 < n ==> isCont (root n) 0
lemma isCont_real_root:
0 < n ==> isCont (root n) x
lemma DERIV_real_root:
[| 0 < n; 0 < x |]
==> DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))
lemma DERIV_odd_real_root:
[| odd n; x ≠ 0 |]
==> DERIV (root n) x :> inverse (real n * root n x ^ (n - Suc 0))
lemma pos2:
0 < 2
lemma real_sqrt_unique:
[| y ^ 2 = x; 0 ≤ y |] ==> sqrt x = y
lemma real_sqrt_abs:
sqrt (x ^ 2) = ¦x¦
lemma real_sqrt_pow2:
0 ≤ x ==> sqrt x ^ 2 = x
lemma real_sqrt_pow2_iff:
(sqrt x ^ 2 = x) = (0 ≤ x)
lemma real_sqrt_zero:
sqrt 0 = 0
lemma real_sqrt_one:
sqrt 1 = 1
lemma real_sqrt_minus:
sqrt (- x) = - sqrt x
lemma real_sqrt_mult:
sqrt (x * y) = sqrt x * sqrt y
lemma real_sqrt_inverse:
sqrt (inverse x) = inverse (sqrt x)
lemma real_sqrt_divide:
sqrt (x / y) = sqrt x / sqrt y
lemma real_sqrt_power:
sqrt (x ^ k) = sqrt x ^ k
lemma real_sqrt_gt_zero:
0 < x ==> 0 < sqrt x
lemma real_sqrt_ge_zero:
0 ≤ x ==> 0 ≤ sqrt x
lemma real_sqrt_less_mono:
x < y ==> sqrt x < sqrt y
lemma real_sqrt_le_mono:
x ≤ y ==> sqrt x ≤ sqrt y
lemma real_sqrt_less_iff:
(sqrt x < sqrt y) = (x < y)
lemma real_sqrt_le_iff:
(sqrt x ≤ sqrt y) = (x ≤ y)
lemma real_sqrt_eq_iff:
(sqrt x = sqrt y) = (x = y)
lemma real_sqrt_gt_0_iff:
(0 < sqrt y) = (0 < y)
lemma real_sqrt_lt_0_iff:
(sqrt x < 0) = (x < 0)
lemma real_sqrt_ge_0_iff:
(0 ≤ sqrt y) = (0 ≤ y)
lemma real_sqrt_le_0_iff:
(sqrt x ≤ 0) = (x ≤ 0)
lemma real_sqrt_eq_0_iff:
(sqrt x = 0) = (x = 0)
lemma real_sqrt_gt_1_iff:
(1 < sqrt y) = (1 < y)
lemma real_sqrt_lt_1_iff:
(sqrt x < 1) = (x < 1)
lemma real_sqrt_ge_1_iff:
(1 ≤ sqrt y) = (1 ≤ y)
lemma real_sqrt_le_1_iff:
(sqrt x ≤ 1) = (x ≤ 1)
lemma real_sqrt_eq_1_iff:
(sqrt x = 1) = (x = 1)
lemma isCont_real_sqrt:
isCont sqrt x
lemma DERIV_real_sqrt:
0 < x ==> DERIV sqrt x :> inverse (sqrt x) / 2
lemma not_real_square_gt_zero:
(¬ 0 < x * x) = (x = 0)
lemma real_sqrt_abs2:
sqrt (x * x) = ¦x¦
lemma real_sqrt_pow2_gt_zero:
0 < x ==> 0 < sqrt x ^ 2
lemma real_sqrt_not_eq_zero:
0 < x ==> sqrt x ≠ 0
lemma real_inv_sqrt_pow2:
0 < x ==> inverse (sqrt x) ^ 2 = inverse x
lemma real_sqrt_eq_zero_cancel:
[| 0 ≤ x; sqrt x = 0 |] ==> x = 0
lemma real_sqrt_ge_one:
1 ≤ x ==> 1 ≤ sqrt x
lemma real_sqrt_two_gt_zero:
0 < sqrt 2
lemma real_sqrt_two_ge_zero:
0 ≤ sqrt 2
lemma real_sqrt_two_gt_one:
1 < sqrt 2
lemma sqrt_divide_self_eq:
0 ≤ x ==> sqrt x / x = inverse (sqrt x)
lemma real_divide_square_eq:
r * a / (r * r) = a / r
lemma lemma_real_divide_sqrt_less:
0 < u ==> u / sqrt 2 < u
lemma four_x_squared:
4 * x ^ 2 = (2 * x) ^ 2
lemma real_sqrt_mult_self_sum_ge_zero:
0 ≤ sqrt (x * x + y * y)
lemma real_sqrt_sum_squares_ge_zero:
0 ≤ sqrt (x ^ 2 + y ^ 2)
lemma real_sqrt_sum_squares_mult_ge_zero:
0 ≤ sqrt ((x ^ 2 + y ^ 2) * (xa ^ 2 + ya ^ 2))
lemma real_sqrt_sum_squares_mult_squared_eq:
sqrt ((x ^ 2 + y ^ 2) * (xa ^ 2 + ya ^ 2)) ^ 2 =
(x ^ 2 + y ^ 2) * (xa ^ 2 + ya ^ 2)
lemma real_sqrt_sum_squares_eq_cancel:
sqrt (x ^ 2 + y ^ 2) = x ==> y = 0
lemma real_sqrt_sum_squares_eq_cancel2:
sqrt (x ^ 2 + y ^ 2) = y ==> x = 0
lemma real_sqrt_sum_squares_ge1:
x ≤ sqrt (x ^ 2 + y ^ 2)
lemma real_sqrt_sum_squares_ge2:
y ≤ sqrt (x ^ 2 + y ^ 2)
lemma real_sqrt_ge_abs1:
¦x¦ ≤ sqrt (x ^ 2 + y ^ 2)
lemma real_sqrt_ge_abs2:
¦y¦ ≤ sqrt (x ^ 2 + y ^ 2)
lemma le_real_sqrt_sumsq:
x ≤ sqrt (x * x + y * y)
lemma power2_sum:
(x + y) ^ 2 = x ^ 2 + y ^ 2 + (2::'a) * x * y
lemma power2_diff:
(x - y) ^ 2 = x ^ 2 + y ^ 2 - (2::'a) * x * y
lemma real_sqrt_sum_squares_triangle_ineq:
sqrt ((a + c) ^ 2 + (b + d) ^ 2) ≤ sqrt (a ^ 2 + b ^ 2) + sqrt (c ^ 2 + d ^ 2)
lemma real_sqrt_sum_squares_less:
[| ¦x¦ < u / sqrt 2; ¦y¦ < u / sqrt 2 |] ==> sqrt (x ^ 2 + y ^ 2) < u
lemma lemma_sqrt_hcomplex_capprox:
[| 0 < u; x < u / 2; y < u / 2; 0 ≤ x; 0 ≤ y |] ==> sqrt (x ^ 2 + y ^ 2) < u
lemma real_root_pos2:
[| 0 < n; 0 ≤ x |] ==> root n (x ^ n) = x
lemma real_root_pos_pos:
[| 0 < n1; 0 < x1 |] ==> 0 ≤ root n1 x1
lemma real_root_pos_pos_le:
[| 0 < n; 0 ≤ x |] ==> 0 ≤ root n x
lemma real_sqrt_mult_distrib:
sqrt (x * y) = sqrt x * sqrt y
lemma real_sqrt_mult_distrib2:
sqrt (x * y) = sqrt x * sqrt y
lemma real_sqrt_eq_zero_cancel_iff:
(sqrt x = 0) = (x = 0)
lemma real_root_pos:
0 < x ==> root (Suc n) (x ^ Suc n) = x