Built with Alectryon, running Coq+SerAPI v8.10.0+0.7.0. Coq sources are in this panel; goals and messages will appear in the other. Bubbles () indicate interactive fragments: hover for details, tap to reveal contents. Use Ctrl+↑ Ctrl+↓ to navigate, Ctrl+🖱️ to focus.
(************************************************************************)
(* * The Coq Proof Assistant / The Coq Development Team *)
(* v * INRIA, CNRS and contributors - Copyright 1999-2018 *)
(* <O___,, * (see CREDITS file for the list of authors) *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)
Square Root Function
Require Import NZAxioms NZMulOrder.
Interface of a sqrt function, then its specification on naturals
Module Type Sqrt (Import A : Typ). Parameter Inline sqrt : t -> t. End Sqrt. Module Type SqrtNotation (A : Typ)(Import B : Sqrt A). Notation "√ x" := (sqrt x) (at level 6). End SqrtNotation. Module Type Sqrt' (A : Typ) := Sqrt A <+ SqrtNotation A. Module Type NZSqrtSpec (Import A : NZOrdAxiomsSig')(Import B : Sqrt' A). Axiom sqrt_spec : forall a, 0<=a -> √a * √a <= a < S (√a) * S (√a). Axiom sqrt_neg : forall a, a<0 -> √a == 0. End NZSqrtSpec. Module Type NZSqrt (A : NZOrdAxiomsSig) := Sqrt A <+ NZSqrtSpec A. Module Type NZSqrt' (A : NZOrdAxiomsSig) := Sqrt' A <+ NZSqrtSpec A.
Derived properties of power
Module Type NZSqrtProp (Import A : NZOrdAxiomsSig') (Import B : NZSqrt' A) (Import C : NZMulOrderProp A). Local Notation "a ²" := (a*a) (at level 5, no associativity, format "a ²").
First, sqrt is non-negative
forall b : t, b² < (S b)² -> 0 <= bforall b : t, b² < (S b)² -> 0 <= bb:tLT:b² < (S b)²0 <= bb:tLT:b² < (S b)²Hb:b < 00 <= bb:tLT:b² < (S b)²Hb:b < 0Falseb:tLT:b² < (S b)²Hb:b < 0(S b)² < b²b:tLT:b² < (S b)²Hb:b < 0H:(S b)² < b²Falseb:tLT:b² < (S b)²Hb:b < 0(S b)² < b²b:tLT:b² < (S b)²Hb:b < 0b * S b + S b < b² + 0b:tLT:b² < (S b)²Hb:b < 0b * S b < b²b:tLT:b² < (S b)²Hb:b < 0S b <= 0b:tLT:b² < (S b)²Hb:b < 0b * S b < b²apply lt_succ_diag_r.b:tLT:b² < (S b)²Hb:b < 0b < S bnow apply le_succ_l.b:tLT:b² < (S b)²Hb:b < 0S b <= 0order. Qed.b:tLT:b² < (S b)²Hb:b < 0H:(S b)² < b²Falseforall a : t, 0 <= √ aforall a : t, 0 <= √ aa:t0 <= √ aa:tHa:a < 00 <= √ aa:tHa:0 <= a0 <= √ anow rewrite (sqrt_neg _ Ha).a:tHa:a < 00 <= √ aa:tHa:0 <= a0 <= √ aa:tHa:0 <= a(√ a)² < (S √ a)²order. Qed.a:tHa:0 <= aH:(√ a)² <= aH0:a < (S √ a)²(√ a)² < (S √ a)²
The spec of sqrt indeed determines it
forall a b : t, b² <= a < (S b)² -> √ a == bforall a b : t, b² <= a < (S b)² -> √ a == ba, b:tLEb:b² <= aLTb:a < (S b)²√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= a√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= b√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ a√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²b <= √ aa, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ a√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²b <= √ anow apply lt_le_incl, lt_succ_r.a, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²0 <= S √ aa, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ a√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ a√ a <= ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ aH0:√ a <= b√ a == ba, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ a√ a <= bnow apply lt_le_incl, lt_succ_r.a, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ a0 <= S border. Qed.a, b:tLEb:b² <= aLTb:a < (S b)²Ha:0 <= aHb:0 <= bHa':0 <= √ aLEa:(√ a)² <= aLTa:a < (S √ a)²H:b <= √ aH0:√ a <= b√ a == b
Hence sqrt is a morphism
Proper (eq ==> eq) sqrtProper (eq ==> eq) sqrtx, x':tHx:x == x'√ x == √ x'x, x':tHx:x == x'H:x < 0√ x == √ x'x, x':tHx:x == x'H:0 <= x√ x == √ x'x, x':tHx:x == x'H:x < 0√ x == √ x'x, x':tHx:x == x'H:x < 00 == 0x, x':tHx:x == x'H:x < 0x' < 0reflexivity.x, x':tHx:x == x'H:x < 00 == 0now rewrite <- Hx.x, x':tHx:x == x'H:x < 0x' < 0x, x':tHx:x == x'H:0 <= x√ x == √ x'x, x':tHx:x == x'H:0 <= x(√ x')² <= x < (S √ x')²now apply sqrt_spec. Qed.x, x':tHx:x == x'H:0 <= x'(√ x')² <= x' < (S √ x')²
An alternate specification
forall a : t, 0 <= a -> exists r : t, a == (√ a)² + r /\ 0 <= r <= 2 * √ aforall a : t, 0 <= a -> exists r : t, a == (√ a)² + r /\ 0 <= r <= 2 * √ aa:tHa:0 <= aexists r : t, a == (√ a)² + r /\ 0 <= r <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²exists r : t, a == (√ a)² + r /\ 0 <= r <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= rexists r0 : t, a == (√ a)² + r0 /\ 0 <= r0 <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra == (√ a)² + r /\ 0 <= r <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra == (√ a)² + ra:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= r0 <= r <= 2 * √ anow rewrite add_comm.a:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra == (√ a)² + ra:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= r0 <= r <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= r0 <= ra:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= rr <= 2 * √ atrivial.a:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= r0 <= ra:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= rr <= 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= rr + (√ a)² <= 2 * √ a + (√ a)²a:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra <= (√ a)² + 2 * √ aa:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra < (S √ a)² -> a <= (√ a)² + 2 * √ anow rewrite lt_succ_r, add_assoc. Qed.a:tHa:0 <= aLE:(√ a)² <= aLT:a < (S √ a)²r:tHr:a == r + (√ a)²Hr':0 <= ra < S ((√ a)² + √ a + √ a) -> a <= (√ a)² + (√ a + √ a)forall a b c : t, 0 <= c <= 2 * b -> a == b² + c -> √ a == bforall a b c : t, 0 <= c <= 2 * b -> a == b² + c -> √ a == ba, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + c√ a == ba, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² <= a < (S b)²a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² <= b² + c < (S b)²a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² <= b² + ca, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + c < (S b)²a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² <= b² + cnow apply add_le_mono_l.a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + 0 <= b² + ca, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + c < (S b)²a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + c < S (b² + b + b)a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + c <= b² + b + ba, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cb² + c <= b² + (b + b)generalize H; now nzsimpl'. Qed.a, b, c:tHc:0 <= cH:c <= 2 * bEQ:a == b² + cc <= b + b
Sqrt is exact on squares
forall a : t, 0 <= a -> √ a² == aforall a : t, 0 <= a -> √ a² == aa:tHa:0 <= a√ a² == aa:tHa:0 <= a0 <= 0 <= 2 * aa:tHa:0 <= aa² == a² + 0a:tHa:0 <= a0 <= 0 <= 2 * aa:tHa:0 <= a0 <= 0a:tHa:0 <= a0 <= 2 * aorder.a:tHa:0 <= a0 <= 0apply mul_nonneg_nonneg; order'.a:tHa:0 <= a0 <= 2 * anow nzsimpl. Qed.a:tHa:0 <= aa² == a² + 0
Sqrt and predecessors of squares
forall a : t, 0 < a -> √ (P a²) == P aforall a : t, 0 < a -> √ (P a²) == P aa:tHa:0 < a√ (P a²) == P aa:tHa:0 < a(P a)² <= P a² < (S (P a))²a:tHa:0 < aEQ:S (P a) == a(P a)² <= P a² < (S (P a))²a:tHa:0 < aEQ:S (P a) == a(P a)² <= P a² < a²a:tHa:0 < aEQ:S (P a) == a(P a)² <= P a²a:tHa:0 < aEQ:S (P a) == aP a² < a²a:tHa:0 < aEQ:S (P a) == a(P a)² <= P a²a:tHa:0 < aEQ:S (P a) == a(P a)² < S (P a²)a:tHa:0 < aEQ:S (P a) == a(P a)² < a²a:tHa:0 < aEQ:S (P a) == a0 < a²a:tHa:0 < aEQ:S (P a) == a(P a)² < a²a:tHa:0 < aEQ:S (P a) == aH:0 <= P a(P a)² < a²apply mul_lt_mono_nonneg; trivial.a:tHa:0 < aEQ:S (P a) == aH:0 <= P aH0:P a < a(P a)² < a²now apply mul_pos_pos.a:tHa:0 < aEQ:S (P a) == a0 < a²a:tHa:0 < aEQ:S (P a) == aP a² < a²a:tHa:0 < aEQ:S (P a) == aS (P a²) <= a²a:tHa:0 < aEQ:S (P a) == aa² <= a²a:tHa:0 < aEQ:S (P a) == a0 < a²reflexivity.a:tHa:0 < aEQ:S (P a) == aa² <= a²now apply mul_pos_pos. Qed.a:tHa:0 < aEQ:S (P a) == a0 < a²
Sqrt is a monotone function (but not a strict one)
forall a b : t, a <= b -> √ a <= √ bforall a b : t, a <= b -> √ a <= √ ba, b:tHab:a <= b√ a <= √ ba, b:tHab:a <= bHa:a < 0√ a <= √ ba, b:tHab:a <= bHa:0 <= a√ a <= √ ba, b:tHab:a <= bHa:a < 0√ a <= √ bapply sqrt_nonneg.a, b:tHab:a <= bHa:a < 00 <= √ ba, b:tHab:a <= bHa:0 <= a√ a <= √ ba, b:tHab:a <= bHa:0 <= aHb:0 <= b√ a <= √ ba, b:tHab:a <= bHa:0 <= aHb:0 <= bLE:(√ a)² <= a√ a <= √ ba, b:tHab:a <= bHa:0 <= aHb:0 <= bLE:(√ a)² <= aLT:b < (S √ b)²√ a <= √ ba, b:tHab:a <= bHa:0 <= aHb:0 <= bLE:(√ a)² <= aLT:b < (S √ b)²√ a < S √ bnow apply lt_le_incl, lt_succ_r, sqrt_nonneg. Qed.a, b:tHab:a <= bHa:0 <= aHb:0 <= bLE:(√ a)² <= aLT:b < (S √ b)²0 <= S √ b
No reverse result for <=, consider for instance √2 <= √1
forall a b : t, √ a < √ b -> a < bforall a b : t, √ a < √ b -> a < ba, b:tH:√ a < √ ba < ba, b:tH:√ a < √ bHb:b < 0a < ba, b:tH:√ a < √ bHb:0 <= ba < brewrite (sqrt_neg b Hb) in H; generalize (sqrt_nonneg a); order.a, b:tH:√ a < √ bHb:b < 0a < ba, b:tH:√ a < √ bHb:0 <= ba < ba, b:tH:√ a < √ bHb:0 <= bHa:0 <= aa < ba, b:tH:√ a < √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²a < ba, b:tH:√ a < √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= ba < ba, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= ba < ba, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b(S √ a)² <= (√ b)²a, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= bH0:(S √ a)² <= (√ b)²a < ba, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b(S √ a)² <= (√ b)²a, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b0 <= S √ aa, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b0 <= S √ anow apply lt_le_incl, lt_succ_r, sqrt_nonneg.a, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b0 <= S √ anow apply lt_le_incl, lt_succ_r, sqrt_nonneg.a, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= b0 <= S √ aorder. Qed.a, b:tH:S √ a <= √ bHb:0 <= bHa:0 <= aLT:a < (S √ a)²LE:(√ b)² <= bH0:(S √ a)² <= (√ b)²a < b
When left side is a square, we have an equivalence for <=
forall a b : t, 0 <= a -> 0 <= b -> b² <= a <-> b <= √ aforall a b : t, 0 <= a -> 0 <= b -> b² <= a <-> b <= √ aa, b:tHa:0 <= aHb:0 <= bb² <= a <-> b <= √ aa, b:tHa:0 <= aHb:0 <= bH:b² <= ab <= √ aa, b:tHa:0 <= aHb:0 <= bH:b <= √ ab² <= aa, b:tHa:0 <= aHb:0 <= bH:b² <= ab <= √ anow apply sqrt_le_mono.a, b:tHa:0 <= aHb:0 <= bH:b² <= a√ b² <= √ aa, b:tHa:0 <= aHb:0 <= bH:b <= √ ab² <= aa, b:tHa:0 <= aHb:0 <= bH:b <= √ aLE:(√ a)² <= aLT:a < (S √ a)²b² <= anow apply mul_le_mono_nonneg. Qed.a, b:tHa:0 <= aHb:0 <= bH:b <= √ aLE:(√ a)² <= aLT:a < (S √ a)²b² <= (√ a)²
When right side is a square, we have an equivalence for <
forall a b : t, 0 <= a -> 0 <= b -> a < b² <-> √ a < bforall a b : t, 0 <= a -> 0 <= b -> a < b² <-> √ a < ba, b:tHa:0 <= aHb:0 <= ba < b² <-> √ a < ba, b:tHa:0 <= aHb:0 <= bH:a < b²√ a < ba, b:tHa:0 <= aHb:0 <= bH:√ a < ba < b²a, b:tHa:0 <= aHb:0 <= bH:a < b²√ a < bapply square_lt_simpl_nonneg; try order.a, b:tHa:0 <= aHb:0 <= bH:a < b²LE:(√ a)² <= a√ a < ba, b:tHa:0 <= aHb:0 <= bH:√ a < ba < b²now apply sqrt_lt_cancel. Qed.a, b:tHa:0 <= aHb:0 <= bH:√ a < √ b²a < b²
Sqrt and basic constants
√ 0 == 0√ 0 == 0now apply sqrt_square. Qed.√ 0² == 0√ 1 == 1√ 1 == 1√ 1² == 1order'. Qed.0 <= 1√ 2 == 1√ 2 == 10 <= 1 <= 2 * 12 == 1² + 1nzsimpl; split; order'.0 <= 1 <= 2 * 1now nzsimpl'. Qed.2 == 1² + 1forall a : t, 0 < √ a <-> 0 < aforall a : t, 0 < √ a <-> 0 < aa:t0 < √ a <-> 0 < aa:tHa:0 < √ a0 < aa:tHa:0 < a0 < √ aa:tHa:0 < √ a0 < anow rewrite sqrt_0.a:tHa:0 < √ a√ 0 < √ aa:tHa:0 < a0 < √ aa:tHa:0 < a√ 1 <= √ anow rewrite one_succ, le_succ_l. Qed.a:tHa:0 < a1 <= aforall a : t, 1 < a -> √ a < aforall a : t, 1 < a -> √ a < aa:tHa:1 < a√ a < aa:tHa:1 < aa < a²rewrite <- mul_lt_mono_pos_l; order'. Qed.a:tHa:1 < aa * 1 < a²forall a : t, 0 <= a -> √ a <= aforall a : t, 0 <= a -> √ a <= aa:tHa:0 <= a√ a <= aa:tHa:0 <= aH:a <= 0√ a <= aa:tHa:0 <= aH:0 < a√ a <= aa:tHa:0 <= aH:a <= 0√ a <= anow rewrite sqrt_0.a:tHa:0 <= aH:a <= 0√ 0 <= 0a:tHa:0 <= aH:0 < a√ a <= aa:tHa:0 <= aH:0 < aH':a <= 1√ a <= aa:tHa:0 <= aH:0 < aH':1 < a√ a <= aa:tHa:0 <= aH:0 < aH':a <= 1√ a <= aa:tHa:0 <= aH:1 <= aH':a <= 1√ a <= anow rewrite sqrt_1.a:tHa:0 <= aH:1 <= aH':a <= 1√ 1 <= 1now apply lt_le_incl, sqrt_lt_lin. Qed.a:tHa:0 <= aH:0 < aH':1 < a√ a <= a
Sqrt and multiplication.
Due to rounding error, we don't have the usual √(a*b) = √a*√b
but only lower and upper bounds.
forall a b : t, √ a * √ b <= √ (a * b)forall a b : t, √ a * √ b <= √ (a * b)a, b:t√ a * √ b <= √ (a * b)a, b:tHa:a < 0√ a * √ b <= √ (a * b)a, b:tHa:0 <= a√ a * √ b <= √ (a * b)a, b:tHa:a < 0√ a * √ b <= √ (a * b)a, b:tHa:a < 00 * √ b <= √ (a * b)apply sqrt_nonneg.a, b:tHa:a < 00 <= √ (a * b)a, b:tHa:0 <= a√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:b < 0√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:0 <= b√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:b < 0√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:b < 0√ a * 0 <= √ (a * b)apply sqrt_nonneg.a, b:tHa:0 <= aHb:b < 00 <= √ (a * b)a, b:tHa:0 <= aHb:0 <= b√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ a√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b√ a * √ b <= √ (a * b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a * √ b)² <= a * ba, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² * (√ b)² <= a * ba, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² <= aa, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ b)² <= bnow apply sqrt_spec.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² <= anow apply sqrt_spec. Qed.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ b)² <= bforall a b : t, 0 <= a -> 0 <= b -> √ (a * b) < S √ a * S √ bforall a b : t, 0 <= a -> 0 <= b -> √ (a * b) < S √ a * S √ ba, b:tHa:0 <= aHb:0 <= b√ (a * b) < S √ a * S √ ba, b:tHa:0 <= aHb:0 <= b0 <= a * ba, b:tHa:0 <= aHb:0 <= b0 <= S √ a * S √ ba, b:tHa:0 <= aHb:0 <= ba * b < (S √ a * S √ b)²now apply mul_nonneg_nonneg.a, b:tHa:0 <= aHb:0 <= b0 <= a * ba, b:tHa:0 <= aHb:0 <= b0 <= S √ a * S √ ba, b:tHa:0 <= aHb:0 <= b0 <= S √ aa, b:tHa:0 <= aHb:0 <= b0 <= S √ bnow apply lt_le_incl, lt_succ_r, sqrt_nonneg.a, b:tHa:0 <= aHb:0 <= b0 <= S √ anow apply lt_le_incl, lt_succ_r, sqrt_nonneg.a, b:tHa:0 <= aHb:0 <= b0 <= S √ ba, b:tHa:0 <= aHb:0 <= ba * b < (S √ a * S √ b)²apply mul_lt_mono_nonneg; trivial; now apply sqrt_spec. Qed.a, b:tHa:0 <= aHb:0 <= ba * b < (S √ a)² * (S √ b)²
And we can't find better approximations in general.
- The lower bound is exact for squares
- Concerning the upper bound, for any c>0, take a=b=c²-1, then √(a*b) = c² -1 while S √a = S √b = c
Sqrt and successor :
- the sqrt function climbs by at most 1 at a time
- otherwise it stays at the same value
- the +1 steps occur for squares
forall a : t, 0 <= a -> √ (S a) <= S √ aforall a : t, 0 <= a -> √ (S a) <= S √ aa:tHa:0 <= a√ (S a) <= S √ aa:tHa:0 <= a√ (S a) < S (S √ a)a:tHa:0 <= a0 <= S aa:tHa:0 <= a0 <= S (S √ a)a:tHa:0 <= aS a < (S (S √ a))²now apply le_le_succ_r.a:tHa:0 <= a0 <= S aapply le_le_succ_r, le_le_succ_r, sqrt_nonneg.a:tHa:0 <= a0 <= S (S √ a)a:tHa:0 <= aS a < (S (S √ a))²a:tHa:0 <= aS a < (1 + S √ a)²a:tHa:0 <= aS a < 1² + (S √ a)²a:tHa:0 <= a1² + (S √ a)² <= (1 + S √ a)²a:tHa:0 <= aS a < 1² + (S √ a)²now apply sqrt_spec.a:tHa:0 <= aa < (S √ a)²a:tHa:0 <= a1² + (S √ a)² <= (1 + S √ a)²a:tHa:0 <= a0 <= 1a:tHa:0 <= a0 <= S √ aorder'.a:tHa:0 <= a0 <= 1apply le_le_succ_r, sqrt_nonneg. Qed.a:tHa:0 <= a0 <= S √ aforall a : t, 0 <= a -> √ (S a) == S √ a \/ √ (S a) == √ aforall a : t, 0 <= a -> √ (S a) == S √ a \/ √ (S a) == √ aa:tHa:0 <= a√ (S a) == S √ a \/ √ (S a) == √ aa:tHa:0 <= aH:√ (S a) <= √ a√ (S a) == S √ a \/ √ (S a) == √ aa:tHa:0 <= aH:√ a < √ (S a)√ (S a) == S √ a \/ √ (S a) == √ aa:tHa:0 <= aH:√ (S a) <= √ a√ (S a) == S √ a \/ √ (S a) == √ ageneralize (sqrt_le_mono _ _ (le_succ_diag_r a)); order.a:tHa:0 <= aH:√ (S a) <= √ a√ (S a) == √ aa:tHa:0 <= aH:√ a < √ (S a)√ (S a) == S √ a \/ √ (S a) == √ aa:tHa:0 <= aH:√ a < √ (S a)√ (S a) == S √ ageneralize (sqrt_succ_le a Ha); order. Qed.a:tHa:0 <= aH:S √ a <= √ (S a)√ (S a) == S √ aforall a : t, 0 <= a -> √ (S a) == S √ a <-> (exists b : t, 0 < b /\ S a == b²)forall a : t, 0 <= a -> √ (S a) == S √ a <-> (exists b : t, 0 < b /\ S a == b²)a:tHa:0 <= a√ (S a) == S √ a <-> (exists b : t, 0 < b /\ S a == b²)a:tHa:0 <= a√ (S a) == S √ a -> exists b : t, 0 < b /\ S a == b²a:tHa:0 <= a(exists b : t, 0 < b /\ S a == b²) -> √ (S a) == S √ aa:tHa:0 <= a√ (S a) == S √ a -> exists b : t, 0 < b /\ S a == b²a:tHa:0 <= aEQ:√ (S a) == S √ aexists b : t, 0 < b /\ S a == b²a:tHa:0 <= aEQ:√ (S a) == S √ a0 < S √ a /\ S a == (S √ a)²a:tHa:0 <= aEQ:√ (S a) == S √ a0 < S √ aa:tHa:0 <= aEQ:√ (S a) == S √ aS a == (S √ a)²apply lt_succ_r, sqrt_nonneg.a:tHa:0 <= aEQ:√ (S a) == S √ a0 < S √ aa:tHa:0 <= aEQ:√ (S a) == S √ aS a == (S √ a)²a:tHa:0 <= aEQ:√ (S a) == S √ aa < (S √ a)² -> S a == (S √ a)²a:tHa:0 <= aEQ:√ (S a) == S √ aS a <= (S √ a)² -> S a == (S √ a)²a:tHa:0 <= aEQ:√ (S a) == S √ aHa':0 <= S aS a <= (S √ a)² -> S a == (S √ a)²rewrite EQ; order.a:tHa:0 <= aEQ:√ (S a) == S √ aHa':0 <= S a(√ (S a))² <= S a -> S a <= (S √ a)² -> S a == (S √ a)²a:tHa:0 <= a(exists b : t, 0 < b /\ S a == b²) -> √ (S a) == S √ aa:tHa:0 <= ab:tHb:0 < bH:S a == b²√ (S a) == S √ aa:tHa:0 <= ab:tHb:0 < bH:S a == b²√ b² == S √ aa:tHa:0 <= ab:tHb:0 < bH:S a == b²b == S √ aa:tHa:0 <= ab:tHb:0 < bH:S a == b²S √ a == ba:tHa:0 <= ab:tHb:0 < bH:S a == b²S √ a == S (P b)a:tHa:0 <= ab:tHb:0 < bH:S a == b²√ a == P ba:tHa:0 <= ab:tHb:0 < bH:S a == S (P b²)√ a == P ba:tHa:0 <= ab:tHb:0 < bH:S a == b²0 < b²a:tHa:0 <= ab:tHb:0 < bH:S a == S (P b²)√ a == P bnow rewrite H, sqrt_pred_square.a:tHa:0 <= ab:tHb:0 < bH:a == P b²√ a == P bnow apply mul_pos_pos. Qed.a:tHa:0 <= ab:tHb:0 < bH:S a == b²0 < b²
Sqrt and addition
forall a b : t, √ (a + b) <= √ a + √ bforall a b : t, √ (a + b) <= √ a + √ bforall a b : t, a < 0 -> √ (a + b) <= √ a + √ bAUX:forall a b : t, a < 0 -> √ (a + b) <= √ a + √ bforall a b : t, √ (a + b) <= √ a + √ bforall a b : t, a < 0 -> √ (a + b) <= √ a + √ ba, b:tHa:a < 0√ (a + b) <= √ a + √ ba, b:tHa:a < 0√ (a + b) <= 0 + √ ba, b:tHa:a < 0√ (a + b) <= √ ba, b:tHa:a < 0a + b <= bapply add_le_mono_r; order.a, b:tHa:a < 0a + b <= 0 + bAUX:forall a b : t, a < 0 -> √ (a + b) <= √ a + √ bforall a b : t, √ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:t√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:a < 0√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= a√ (a + b) <= √ a + √ bnow apply AUX.AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:a < 0√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= a√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:b < 0√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= b√ (a + b) <= √ a + √ brewrite (add_comm a), (add_comm (√a)); now apply AUX.AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:b < 0√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= b√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ a√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b√ (a + b) <= √ a + √ bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b√ (a + b) < S (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= a + bAUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= S (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ ba + b < (S (√ a + √ b))²now apply add_nonneg_nonneg.AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= a + bnow apply lt_le_incl, lt_succ_r, add_nonneg_nonneg.AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= S (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ ba + b < (S (√ a + √ b))²AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ bLTa:a < (S √ a)²a + b < (S (√ a + √ b))²AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ bLTa:a < (S √ a)²LTb:b < (S √ b)²a + b < (S (√ a + √ b))²AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ ba < (S √ a)² -> b < (S √ b)² -> a + b < (S (√ a + √ b))²AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ ba < S ((√ a)² + √ a + √ a) -> b < S ((√ b)² + √ b + √ b) -> a + b < S ((√ a + √ b)² + (√ a + √ b) + (√ a + √ b))AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ ba <= (√ a)² + √ a + √ a -> b <= (√ b)² + √ b + √ b -> a + b <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ bLTa:a <= (√ a)² + √ a + √ aLTb:b <= (√ b)² + √ b + √ ba + b <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ bLTa:a <= (√ a)² + √ a + √ aLTb:b <= (√ b)² + √ b + √ bH:a + b <= (√ a)² + √ a + √ a + ((√ b)² + √ b + √ b)a + b <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ bLTa:a <= (√ a)² + √ a + √ aLTb:b <= (√ b)² + √ b + √ bH:a + b <= (√ a)² + √ a + √ a + ((√ b)² + √ b + √ b)(√ a)² + √ a + √ a + ((√ b)² + √ b + √ b) <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + √ a + √ a + ((√ b)² + √ b + √ b) <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ a + √ a) + ((√ b)² + √ b + √ b) <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ a + √ a) + ((√ b)² + (√ b + √ b)) <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² + (√ a + √ a + (√ b + √ b)) <= (√ a + √ b)² + (√ a + √ b) + (√ a + √ b)AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² + (√ a + √ a + (√ b + √ b)) <= (√ a + √ b)² + (√ a + √ b + (√ a + √ b))AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² + (√ a + √ a + (√ b + √ b)) <= (√ a + √ b)² + (√ a + √ a + (√ b + √ b))now apply add_square_le. Qed.AUX:forall a0 b0 : t, a0 < 0 -> √ (a0 + b0) <= √ a0 + √ b0a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² <= (√ a + √ b)²
convexity inequality for sqrt: sqrt of middle is above middle
of square roots.
forall a b : t, 0 <= a -> 0 <= b -> √ a + √ b <= √ (2 * (a + b))forall a b : t, 0 <= a -> 0 <= b -> √ a + √ b <= √ (2 * (a + b))a, b:tHa:0 <= aHb:0 <= b√ a + √ b <= √ (2 * (a + b))a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ a√ a + √ b <= √ (2 * (a + b))a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b√ a + √ b <= √ (2 * (a + b))a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2 * (a + b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= √ a + √ ba, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a + √ b)² <= 2 * (a + b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2 * (a + b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= a + border'.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2now apply add_nonneg_nonneg.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= a + bnow apply add_nonneg_nonneg.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= √ a + √ ba, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a + √ b)² <= 2 * (a + b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a + √ b)² <= 2 * ((√ a)² + (√ b)²)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b2 * ((√ a)² + (√ b)²) <= 2 * (a + b)now apply square_add_le.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a + √ b)² <= 2 * ((√ a)² + (√ b)²)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b2 * ((√ a)² + (√ b)²) <= 2 * (a + b)a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² <= a + border'.a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b0 <= 2apply add_le_mono; now apply sqrt_spec. Qed. End NZSqrtProp. Module Type NZSqrtUpProp (Import A : NZDecOrdAxiomsSig') (Import B : NZSqrt' A) (Import C : NZMulOrderProp A) (Import D : NZSqrtProp A B C).a, b:tHa:0 <= aHb:0 <= bHa':0 <= √ aHb':0 <= √ b(√ a)² + (√ b)² <= a + b
Local Notation "a ²" := (a*a) (at level 5, no associativity, format "a ²").
For once, we define instead of axiomatizing, thanks to sqrt
Definition sqrt_up a := match compare 0 a with | Lt => S √(P a) | _ => 0 end. Local Notation "√° a" := (sqrt_up a) (at level 6, no associativity).forall a : t, a <= 0 -> √° a == 0forall a : t, a <= 0 -> √° a == 0a:tHa:a <= 0√° a == 0case compare_spec; try order. Qed.a:tHa:a <= 0match compare 0 a with | Lt => S √ (P a) | _ => 0 end == 0forall a : t, 0 < a -> √° a == S √ (P a)forall a : t, 0 < a -> √° a == S √ (P a)a:tHa:0 < a√° a == S √ (P a)case compare_spec; try order. Qed.a:tHa:0 < amatch compare 0 a with | Lt => S √ (P a) | _ => 0 end == S √ (P a)forall a : t, 0 < a -> (P √° a)² < a <= (√° a)²forall a : t, 0 < a -> (P √° a)² < a <= (√° a)²a:tHa:0 < a(P √° a)² < a <= (√° a)²a:tHa:0 < a(√ (P a))² < a <= (S √ (P a))²a:tHa:0 < aHa':S (P a) == a(√ (P a))² < a <= (S √ (P a))²a:tHa:0 < aHa':S (P a) == a(√ (P a))² < S (P a) <= (S √ (P a))²a:tHa:0 < aHa':S (P a) == a(√ (P a))² <= P a < (S √ (P a))²now rewrite <- lt_succ_r, Ha'. Qed.a:tHa:0 < aHa':S (P a) == a0 <= P a
First, sqrt_up is non-negative
forall a : t, 0 <= √° aforall a : t, 0 <= √° aa:t0 <= √° aa:tHa:a <= 00 <= √° aa:tHa:0 < a0 <= √° anow rewrite sqrt_up_eqn0.a:tHa:a <= 00 <= √° aa:tHa:0 < a0 <= √° aapply le_le_succ_r, sqrt_nonneg. Qed.a:tHa:0 < a0 <= S √ (P a)
sqrt_up is a morphism
Proper (eq ==> eq) sqrt_upProper (eq ==> eq) sqrt_upProper (eq ==> eq ==> Logic.eq) compareH:Proper (eq ==> eq ==> Logic.eq) compareProper (eq ==> eq) sqrt_upProper (eq ==> eq ==> Logic.eq) comparedo 2 case compare_spec; trivial; order.x, x':tHx:x == x'y, y':tHy:y == y'compare x y = compare x' y'intros x x' Hx; unfold sqrt_up; rewrite Hx; case compare; now rewrite ?Hx. Qed.H:Proper (eq ==> eq ==> Logic.eq) compareProper (eq ==> eq) sqrt_up
The spec of sqrt_up indeed determines it
forall a b : t, 0 < b -> (P b)² < a <= b² -> √° a == bforall a b : t, 0 < b -> (P b)² < a <= b² -> √° a == ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²√° a == ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < a√° a == ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aS √ (P a) == ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == bS √ (P a) == ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == bS √ (P a) == S (P b)a, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == b√ (P a) == P ba, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == b(P b)² <= P a < (S (P b))²a, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == b(P b)² < S (P a) <= b²now split. Qed.a, b:tHb:0 < bLEb:(P b)² < aLTb:a <= b²Ha:0 < aHb':S (P b) == b(P b)² < a <= b²
sqrt_up is exact on squares
forall a : t, 0 <= a -> √° a² == aforall a : t, 0 <= a -> √° a² == aa:tHa:0 <= a√° a² == aa:tHa:0 < a√° a² == aa:tHa:0 == a√° a² == aa:tHa:0 < a√° a² == aa:tHa:0 < aS √ (P a²) == aapply (lt_succ_pred 0); trivial.a:tHa:0 < aS (P a) == aa:tHa:0 == a√° a² == aa:tHa:0 == aa² <= 0now nzsimpl. Qed.a:tHa:0 == a0² <= 0
sqrt_up and successors of squares
forall a : t, 0 <= a -> √° (S a²) == S aforall a : t, 0 <= a -> √° (S a²) == S aa:tHa:0 <= a√° (S a²) == S anow rewrite pred_succ, sqrt_square. Qed.a:tHa:0 <= aS √ (P (S a²)) == S a
Basic constants
√° 0 == 0√° 0 == 0now apply sqrt_up_square. Qed.√° 0² == 0√° 1 == 1√° 1 == 1√° 1² == 1order'. Qed.0 <= 1√° 2 == 2√° 2 == 2now rewrite two_succ, pred_succ, sqrt_1. Qed.S √ (P 2) == 2
Links between sqrt and sqrt_up
forall a : t, √ a <= √° aforall a : t, √ a <= √° aa:t√ a <= √° aa:t√ a <= match compare 0 a with | Lt => S √ (P a) | _ => 0 enda:tH:0 == a√ a <= 0a:tH:0 < a√ a <= S √ (P a)a:tH:a < 0√ a <= 0a:tH:0 == a√ a <= 0order.a:tH:0 == a0 <= 0a:tH:0 < a√ a <= S √ (P a)a:tH:0 < a√ (S (P a)) <= S √ (P a)a:tH:0 < a0 <= P anow rewrite (lt_succ_pred 0 a H).a:tH:0 < a0 < S (P a)now rewrite sqrt_neg. Qed.a:tH:a < 0√ a <= 0forall a : t, √° a <= S √ aforall a : t, √° a <= S √ aa:t√° a <= S √ aa:tmatch compare 0 a with | Lt => S √ (P a) | _ => 0 end <= S √ aa:tH:0 < aS √ (P a) <= S √ aa:tH:0 < a√ (P a) <= √ aa:tH:0 < aP a <= aapply le_succ_diag_r. Qed.a:tH:0 < aP a <= S (P a)forall a : t, 0 <= a -> (√ a)² <= a <= (√° a)²forall a : t, 0 <= a -> (√ a)² <= a <= (√° a)²a:tH:0 <= a(√ a)² <= a <= (√° a)²a:tH:0 <= a(√ a)² <= aa:tH:0 <= aa <= (√° a)²now apply sqrt_spec.a:tH:0 <= a(√ a)² <= aa:tH:0 <= aa <= (√° a)²a:tH:0 < aa <= (√° a)²a:tH:0 == aa <= (√° a)²now apply sqrt_up_spec.a:tH:0 < aa <= (√° a)²now rewrite <-H, sqrt_up_0, mul_0_l. Qed.a:tH:0 == aa <= (√° a)²forall a : t, 0 <= a -> √ a == √° a <-> (exists b : t, 0 <= b /\ a == b²)forall a : t, 0 <= a -> √ a == √° a <-> (exists b : t, 0 <= b /\ a == b²)a:tHa:0 <= a√ a == √° a <-> (exists b : t, 0 <= b /\ a == b²)a:tHa:0 <= a√ a == √° a -> exists b : t, 0 <= b /\ a == b²a:tHa:0 <= a(exists b : t, 0 <= b /\ a == b²) -> √ a == √° aa:tHa:0 <= a√ a == √° a -> exists b : t, 0 <= b /\ a == b²a:tHa:0 <= aH:√ a == √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 <= aH:√ a == √° a0 <= √ a /\ a == (√ a)²a:tHa:0 <= aH:√ a == √° a0 <= √ aa:tHa:0 <= aH:√ a == √° aa == (√ a)²apply sqrt_nonneg.a:tHa:0 <= aH:√ a == √° a0 <= √ aa:tHa:0 <= aH:√ a == √° aa == (√ a)²a:tHa:0 <= aH:√ a == √° a(√ a)² <= a <= (√° a)² -> a == (√ a)²destruct 1; order.a:tHa:0 <= aH:√ a == √° a(√ a)² <= a <= (√ a)² -> a == (√ a)²a:tHa:0 <= a(exists b : t, 0 <= b /\ a == b²) -> √ a == √° aa:tHa:0 <= ab:tHb:0 <= bHb':a == b²√ a == √° anow rewrite sqrt_square, sqrt_up_square. Qed.a:tHa:0 <= ab:tHb:0 <= bHb':a == b²√ b² == √° b²
sqrt_up is a monotone function (but not a strict one)
forall a b : t, a <= b -> √° a <= √° bforall a b : t, a <= b -> √° a <= √° ba, b:tH:a <= b√° a <= √° ba, b:tH:a <= bHa:a <= 0√° a <= √° ba, b:tH:a <= bHa:0 < a√° a <= √° ba, b:tH:a <= bHa:a <= 0√° a <= √° bapply sqrt_up_nonneg.a, b:tH:a <= bHa:a <= 00 <= √° ba, b:tH:a <= bHa:0 < a√° a <= √° ba, b:tH:a <= bHa:0 < aS √ (P a) <= S √ (P b)a, b:tH:a <= bHa:0 < a√ (P a) <= √ (P b)rewrite 2 (lt_succ_pred 0); order. Qed.a, b:tH:a <= bHa:0 < aS (P a) <= S (P b)
No reverse result for <=, consider for instance √°3 <= √°2
forall a b : t, √° a < √° b -> a < bforall a b : t, √° a < √° b -> a < ba, b:tH:√° a < √° ba < ba, b:tH:√° a < √° bHb:b <= 0a < ba, b:tH:√° a < √° bHb:0 < ba < brewrite (sqrt_up_eqn0 _ Hb) in H; generalize (sqrt_up_nonneg a); order.a, b:tH:√° a < √° bHb:b <= 0a < ba, b:tH:√° a < √° bHb:0 < ba < ba, b:tH:√° a < √° bHb:0 < bHa:0 < aa < ba, b:tH:√° a < √° bHb:0 < bHa:0 < aP a < P bnow rewrite <- 2 sqrt_up_eqn. Qed.a, b:tH:√° a < √° bHb:0 < bHa:0 < aS √ (P a) < S √ (P b)
When left side is a square, we have an equivalence for <
forall a b : t, 0 <= a -> 0 <= b -> b² < a <-> b < √° aforall a b : t, 0 <= a -> 0 <= b -> b² < a <-> b < √° aa, b:tHa:0 <= aHb:0 <= bb² < a <-> b < √° aa, b:tHa:0 <= aHb:0 <= bH:b² < ab < √° aa, b:tHa:0 <= aHb:0 <= bH:b < √° ab² < aa, b:tHa:0 <= aHb:0 <= bH:b² < ab < √° aa, b:tHa:0 <= aHb:0 <= bH:b² < a0 < aa, b:tHa:0 <= aHb:0 <= bH:b² < aLE:(P √° a)² < aLT:a <= (√° a)²b < √° aapply le_lt_trans with b²; trivial using square_nonneg.a, b:tHa:0 <= aHb:0 <= bH:b² < a0 < aa, b:tHa:0 <= aHb:0 <= bH:b² < aLE:(P √° a)² < aLT:a <= (√° a)²b < √° aapply sqrt_up_nonneg.a, b:tHa:0 <= aHb:0 <= bH:b² < aLE:(P √° a)² < aLT:a <= (√° a)²0 <= √° aa, b:tHa:0 <= aHb:0 <= bH:b < √° ab² < anow rewrite sqrt_up_square. Qed.a, b:tHa:0 <= aHb:0 <= bH:b < √° a√° b² < √° a
When right side is a square, we have an equivalence for <=
forall a b : t, 0 <= a -> 0 <= b -> a <= b² <-> √° a <= bforall a b : t, 0 <= a -> 0 <= b -> a <= b² <-> √° a <= ba, b:tHa:0 <= aHb:0 <= ba <= b² <-> √° a <= ba, b:tHa:0 <= aHb:0 <= bH:a <= b²√° a <= ba, b:tHa:0 <= aHb:0 <= bH:√° a <= ba <= b²a, b:tHa:0 <= aHb:0 <= bH:a <= b²√° a <= bnow apply sqrt_up_le_mono.a, b:tHa:0 <= aHb:0 <= bH:a <= b²√° a <= √° b²a, b:tHa:0 <= aHb:0 <= bH:√° a <= ba <= b²a, b:tHa:0 <= aHb:0 <= bH:(√° a)² <= b²a <= b²now apply sqrt_sqrt_up_spec. Qed.a, b:tHa:0 <= aHb:0 <= bH:(√° a)² <= b²a <= (√° a)²forall a : t, 0 < √° a <-> 0 < aforall a : t, 0 < √° a <-> 0 < aa:t0 < √° a <-> 0 < aa:tHa:0 < √° a0 < aa:tHa:0 < a0 < √° aa:tHa:0 < √° a0 < anow rewrite sqrt_up_0.a:tHa:0 < √° a√° 0 < √° aa:tHa:0 < a0 < √° aa:tHa:0 < a√° 1 <= √° anow rewrite one_succ, le_succ_l. Qed.a:tHa:0 < a1 <= aforall a : t, 2 < a -> √° a < aforall a : t, 2 < a -> √° a < aa:tHa:2 < a√° a < aa:tHa:2 < aS √ (P a) < aa:tHa:2 < aHa':S (P a) == aS √ (P a) < aa:tHa:2 < aHa':S (P a) == aS √ (P a) < S (P a)a:tHa:2 < aHa':S (P a) == a√ (P a) < P aa:tHa:2 < aHa':S (P a) == a1 < P anow rewrite Ha', <- two_succ. Qed.a:tHa:2 < aHa':S (P a) == aS 1 < S (P a)forall a : t, 0 <= a -> √° a <= aforall a : t, 0 <= a -> √° a <= aa:tHa:0 <= a√° a <= aa:tHa:0 < a√° a <= aa:tHa:0 == a√° a <= aa:tHa:0 < a√° a <= aa:tHa:0 < aS √ (P a) <= aa:tHa:0 < a√ (P a) < aa:tHa:0 < a√ (P a) <= P aa:tHa:0 < aP a < aa:tHa:0 < a√ (P a) <= P anow rewrite <- lt_succ_r, (lt_succ_pred 0).a:tHa:0 < a0 <= P aa:tHa:0 < aP a < aapply lt_succ_diag_r.a:tHa:0 < aP a < S (P a)now rewrite <- Ha, sqrt_up_0. Qed.a:tHa:0 == a√° a <= a
sqrt_up and multiplication.
Due to rounding error, we don't have the usual √(a×b) = √a*√b
but only lower and upper bounds.
forall a b : t, 0 <= a -> 0 <= b -> √° (a * b) <= √° a * √° bforall a b : t, 0 <= a -> 0 <= b -> √° (a * b) <= √° a * √° ba, b:tHa:0 <= aHb:0 <= b√° (a * b) <= √° a * √° ba, b:tHa:0 <= aHb:0 <= b0 <= a * ba, b:tHa:0 <= aHb:0 <= b0 <= √° a * √° ba, b:tHa:0 <= aHb:0 <= ba * b <= (√° a * √° b)²now apply mul_nonneg_nonneg.a, b:tHa:0 <= aHb:0 <= b0 <= a * bapply mul_nonneg_nonneg; apply sqrt_up_nonneg.a, b:tHa:0 <= aHb:0 <= b0 <= √° a * √° ba, b:tHa:0 <= aHb:0 <= ba * b <= (√° a * √° b)²apply mul_le_mono_nonneg; trivial; now apply sqrt_sqrt_up_spec. Qed.a, b:tHa:0 <= aHb:0 <= ba * b <= (√° a)² * (√° b)²forall a b : t, 0 < a -> 0 < b -> P √° a * P √° b < √° (a * b)forall a b : t, 0 < a -> 0 < b -> P √° a * P √° b < √° (a * b)a, b:tHa:0 < aHb:0 < bP √° a * P √° b < √° (a * b)a, b:tHa:0 < aHb:0 < b0 <= a * ba, b:tHa:0 < aHb:0 < b0 <= P √° a * P √° ba, b:tHa:0 < aHb:0 < b(P √° a * P √° b)² < a * bapply mul_nonneg_nonneg; order.a, b:tHa:0 < aHb:0 < b0 <= a * ba, b:tHa:0 < aHb:0 < b0 <= P √° a * P √° ba, b:tHa:0 < aHb:0 < b0 < S (P √° a)a, b:tHa:0 < aHb:0 < b0 < S (P √° b)rewrite (lt_succ_pred 0); now rewrite sqrt_up_pos.a, b:tHa:0 < aHb:0 < b0 < S (P √° a)rewrite (lt_succ_pred 0); now rewrite sqrt_up_pos.a, b:tHa:0 < aHb:0 < b0 < S (P √° b)a, b:tHa:0 < aHb:0 < b(P √° a * P √° b)² < a * bapply mul_lt_mono_nonneg; trivial using square_nonneg; now apply sqrt_up_spec. Qed.a, b:tHa:0 < aHb:0 < b(P √° a)² * (P √° b)² < a * b
And we can't find better approximations in general.
- The upper bound is exact for squares
- Concerning the lower bound, for any c>0, take a=b=c²+1, then √°(a×b) = c²+1 while P √°a = P √°b = c
sqrt_up and successor :
- the sqrt_up function climbs by at most 1 at a time
- otherwise it stays at the same value
- the +1 steps occur after squares
forall a : t, 0 <= a -> √° (S a) <= S √° aforall a : t, 0 <= a -> √° (S a) <= S √° aa:tHa:0 <= a√° (S a) <= S √° aa:tHa:0 <= a0 <= S aa:tHa:0 <= a0 <= S √° aa:tHa:0 <= aS a <= (S √° a)²now apply le_le_succ_r.a:tHa:0 <= a0 <= S aapply le_le_succ_r, sqrt_up_nonneg.a:tHa:0 <= a0 <= S √° aa:tHa:0 <= aS a <= (S √° a)²a:tHa:0 <= aS a <= (1 + √° a)²a:tHa:0 <= aS a <= 1² + (√° a)²a:tHa:0 <= a1² + (√° a)² <= (1 + √° a)²a:tHa:0 <= aS a <= 1² + (√° a)²now apply sqrt_sqrt_up_spec.a:tHa:0 <= aa <= (√° a)²a:tHa:0 <= a1² + (√° a)² <= (1 + √° a)²a:tHa:0 <= a0 <= 1a:tHa:0 <= a0 <= √° aorder'.a:tHa:0 <= a0 <= 1apply sqrt_up_nonneg. Qed.a:tHa:0 <= a0 <= √° aforall a : t, 0 <= a -> √° (S a) == S √° a \/ √° (S a) == √° aforall a : t, 0 <= a -> √° (S a) == S √° a \/ √° (S a) == √° aa:tHa:0 <= a√° (S a) == S √° a \/ √° (S a) == √° aa:tHa:0 <= aH:√° (S a) <= √° a√° (S a) == S √° a \/ √° (S a) == √° aa:tHa:0 <= aH:√° a < √° (S a)√° (S a) == S √° a \/ √° (S a) == √° aa:tHa:0 <= aH:√° (S a) <= √° a√° (S a) == S √° a \/ √° (S a) == √° ageneralize (sqrt_up_le_mono _ _ (le_succ_diag_r a)); order.a:tHa:0 <= aH:√° (S a) <= √° a√° (S a) == √° aa:tHa:0 <= aH:√° a < √° (S a)√° (S a) == S √° a \/ √° (S a) == √° aa:tHa:0 <= aH:√° a < √° (S a)√° (S a) == S √° ageneralize (sqrt_up_succ_le a Ha); order. Qed.a:tHa:0 <= aH:S √° a <= √° (S a)√° (S a) == S √° aforall a : t, 0 <= a -> √° (S a) == S √° a <-> (exists b : t, 0 <= b /\ a == b²)forall a : t, 0 <= a -> √° (S a) == S √° a <-> (exists b : t, 0 <= b /\ a == b²)a:tHa:0 <= a√° (S a) == S √° a <-> (exists b : t, 0 <= b /\ a == b²)a:tHa:0 <= a√° (S a) == S √° a -> exists b : t, 0 <= b /\ a == b²a:tHa:0 <= a(exists b : t, 0 <= b /\ a == b²) -> √° (S a) == S √° aa:tHa:0 <= a√° (S a) == S √° a -> exists b : t, 0 <= b /\ a == b²a:tHa:0 <= aEQ:√° (S a) == S √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 < aEQ:√° (S a) == S √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 == aEQ:√° (S a) == S √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 < aEQ:√° (S a) == S √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 < aEQ:√° (S a) == S √° a0 <= √° a /\ a == (√° a)²a:tHa:0 < aEQ:√° (S a) == S √° a0 <= √° aa:tHa:0 < aEQ:√° (S a) == S √° aa == (√° a)²apply sqrt_up_nonneg.a:tHa:0 < aEQ:√° (S a) == S √° a0 <= √° aa:tHa:0 < aEQ:√° (S a) == S √° aa == (√° a)²a:tHa:0 < aEQ:√° (S a) == S √° aa <= (√° a)² -> a == (√° a)²a:tHa:0 < aEQ:√° (S a) == S √° aHa':0 < S aa <= (√° a)² -> a == (√° a)²a:tHa:0 < aEQ:√° (S a) == S √° aHa':0 < S a(P √° (S a))² < S a -> a <= (√° a)² -> a == (√° a)²order.a:tHa:0 < aEQ:√° (S a) == S √° aHa':0 < S a(√° a)² <= a -> a <= (√° a)² -> a == (√° a)²a:tHa:0 == aEQ:√° (S a) == S √° aexists b : t, 0 <= b /\ a == b²a:tHa:0 == aEQ:√° (S a) == S √° a0 <= 0 /\ a == 0²now split.a:tHa:0 == aEQ:√° (S a) == S √° a0 <= 0 /\ a == 0a:tHa:0 <= a(exists b : t, 0 <= b /\ a == b²) -> √° (S a) == S √° anow rewrite H, sqrt_up_succ_square, sqrt_up_square. Qed.a:tHa:0 <= ab:tHb:0 <= bH:a == b²√° (S a) == S √° a
sqrt_up and addition
forall a b : t, √° (a + b) <= √° a + √° bforall a b : t, √° (a + b) <= √° a + √° bforall a b : t, a <= 0 -> √° (a + b) <= √° a + √° bAUX:forall a b : t, a <= 0 -> √° (a + b) <= √° a + √° bforall a b : t, √° (a + b) <= √° a + √° bforall a b : t, a <= 0 -> √° (a + b) <= √° a + √° ba, b:tHa:a <= 0√° (a + b) <= √° a + √° ba, b:tHa:a <= 0√° (a + b) <= 0 + √° ba, b:tHa:a <= 0√° (a + b) <= √° ba, b:tHa:a <= 0a + b <= bapply add_le_mono_r; order.a, b:tHa:a <= 0a + b <= 0 + bAUX:forall a b : t, a <= 0 -> √° (a + b) <= √° a + √° bforall a b : t, √° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:t√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:a <= 0√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < a√° (a + b) <= √° a + √° bnow apply AUX.AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:a <= 0√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < a√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:b <= 0√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√° (a + b) <= √° a + √° brewrite (add_comm a), (add_comm (√°a)); now apply AUX.AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:b <= 0√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√° (a + b) <= √° a + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < bS √ (P (a + b)) <= S √ (P a) + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b0 < a + bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < bS √ (P (a + b)) <= S √ (P a) + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < bS √ (P (a + b)) <= S (√ (P a) + √° b)AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P (a + b)) <= √ (P a) + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P (a + b)) <= √ (P a) + √ bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P a) + √ b <= √ (P a) + √° bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P (a + b)) <= √ (P a) + √ bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P (S (P a) + b)) <= √ (P a) + √ bapply sqrt_add_le.AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P a + b) <= √ (P a) + √ bAUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ (P a) + √ b <= √ (P a) + √° bapply le_sqrt_sqrt_up.AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b√ b <= √° bnow apply add_pos_pos. Qed.AUX:forall a0 b0 : t, a0 <= 0 -> √° (a0 + b0) <= √° a0 + √° b0a, b:tHa:0 < aHb:0 < b0 < a + b
Convexity-like inequality for sqrt_up: sqrt_up of middle is above middle
of square roots. We cannot say more, for instance take a=b=2, then
2+2 <= S 3
forall a b : t, 0 <= a -> 0 <= b -> √° a + √° b <= S √° (2 * (a + b))forall a b : t, 0 <= a -> 0 <= b -> √° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 <= aHb:0 <= b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 < aHb:0 < b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 < aHb:0 == b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 == aHb:0 <= b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 < aHb:0 < b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 < aHb:0 < bS √ (P a) + S √ (P b) <= S (S √ (P (2 * (a + b))))a, b:tHa:0 < aHb:0 < b0 < 2 * (a + b)a, b:tHa:0 < aHb:0 < bS √ (P a) + S √ (P b) <= S (S √ (P (2 * (a + b))))a, b:tHa:0 < aHb:0 < bS (S (√ (P a) + √ (P b))) <= S (S √ (P (2 * (a + b))))a, b:tHa:0 < aHb:0 < b√ (P a) + √ (P b) <= √ (P (2 * (a + b)))a, b:tHa:0 < aHb:0 < b0 <= P aa, b:tHa:0 < aHb:0 < b0 <= P ba, b:tHa:0 < aHb:0 < b√ (2 * (P a + P b)) <= √ (P (2 * (a + b)))a, b:tHa:0 < aHb:0 < b0 <= P anow rewrite (lt_succ_pred 0 a Ha).a, b:tHa:0 < aHb:0 < b0 < S (P a)a, b:tHa:0 < aHb:0 < b0 <= P bnow rewrite (lt_succ_pred 0 b Hb).a, b:tHa:0 < aHb:0 < b0 < S (P b)a, b:tHa:0 < aHb:0 < b√ (2 * (P a + P b)) <= √ (P (2 * (a + b)))a, b:tHa:0 < aHb:0 < b2 * (P a + P b) <= P (2 * (a + b))a, b:tHa:0 < aHb:0 < b2 * (P a + P b) < S (P (2 * (a + b)))a, b:tHa:0 < aHb:0 < b2 * (P a + P b) < 2 * (a + b)a, b:tHa:0 < aHb:0 < b0 < 2 * (a + b)a, b:tHa:0 < aHb:0 < b2 * (P a + P b) < 2 * (a + b)a, b:tHa:0 < aHb:0 < b0 < 2a, b:tHa:0 < aHb:0 < bP a + P b < a + border'.a, b:tHa:0 < aHb:0 < b0 < 2a, b:tHa:0 < aHb:0 < bP a + P b < a + ba, b:tHa:0 < aHb:0 < bP a < aa, b:tHa:0 < aHb:0 < bP b < ba, b:tHa:0 < aHb:0 < bP a < anow rewrite (lt_succ_pred 0).a, b:tHa:0 < aHb:0 < bS (P a) <= aa, b:tHa:0 < aHb:0 < bP b < bnow rewrite (lt_succ_pred 0).a, b:tHa:0 < aHb:0 < bS (P b) <= ba, b:tHa:0 < aHb:0 < b0 < 2 * (a + b)a, b:tHa:0 < aHb:0 < b0 < 2a, b:tHa:0 < aHb:0 < b0 < a + border'.a, b:tHa:0 < aHb:0 < b0 < 2now apply add_pos_pos.a, b:tHa:0 < aHb:0 < b0 < a + ba, b:tHa:0 < aHb:0 < b0 < 2 * (a + b)a, b:tHa:0 < aHb:0 < b0 < 2a, b:tHa:0 < aHb:0 < b0 < a + border'.a, b:tHa:0 < aHb:0 < b0 < 2now apply add_pos_pos.a, b:tHa:0 < aHb:0 < b0 < a + ba, b:tHa:0 < aHb:0 == b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 < aHb:0 == b√° a + 0 <= S √° (2 * (a + 0))a, b:tHa:0 < aHb:0 == b√° a <= S √° (2 * a)a, b:tHa:0 < aHb:0 == ba <= 2 * aapply mul_le_mono_nonneg_r; order'.a, b:tHa:0 < aHb:0 == b1 * a <= 2 * aa, b:tHa:0 == aHb:0 <= b√° a + √° b <= S √° (2 * (a + b))a, b:tHa:0 == aHb:0 <= b0 + √° b <= S √° (2 * (0 + b))a, b:tHa:0 == aHb:0 <= b√° b <= S √° (2 * b)a, b:tHa:0 == aHb:0 <= bb <= 2 * bapply mul_le_mono_nonneg_r; order'. Qed. End NZSqrtUpProp.a, b:tHa:0 == aHb:0 <= b1 * b <= 2 * b