(************************************************************************)
(*         *   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)         *)
(************************************************************************)
Local Open Scope R_scope.
(** * Continuous extension of Rsqrt on R *)
Definition sqrt (x:R) : R :=
match Rcase_abs x with
| left _ => 0
| right a => Rsqrt (mknonnegreal x (Rge_le _ _ a))
end.
intros; simpl; rewrite Rmult_1_r, sqrt_square; auto.
Qed.
intros x y H H0; try assumption.
replace 0 with (x * 0).
apply Rmult_lt_compat_l; auto with real.
ring.
Qed.
intros x y H H0; try assumption.
case H; intros.
red; left.
apply Rlt_mult_inv_pos; auto with real.
rewrite <- H1.
red; right; ring.
Qed.
(************************************************************)
(** * Resolution of [a*X^2+b*X+c=0]                         *)
(************************************************************)
Definition Delta (a:nonzeroreal) (b c:R) : R := Rsqr b - 4 * a * c.
Definition Delta_is_pos (a:nonzeroreal) (b c:R) : Prop := 0 <= Delta a b c.
Definition sol_x1 (a:nonzeroreal) (b c:R) : R :=
(- b + sqrt (Delta a b c)) / (2 * a).
Definition sol_x2 (a:nonzeroreal) (b c:R) : R :=
(- b - sqrt (Delta a b c)) / (2 * a).

Lemma Rsqr_sol_eq_0_0 :
forall (a:nonzeroreal) (b c x:R),
Delta_is_pos a b c ->
a * Rsqr x + b * x + c = 0 -> x = sol_x1 a b c \/ x = sol_x2 a b c.