(** Sqrt is exact on squares *)

(* Specifications: *)
Lemma sqrt_square : forall a, 0<=a -> √(a²) == a.
(** Sqrt and predecessors of squares *)
Lemma sqrt_pred_square : forall a, 0<a -> √(P a²) == P a.
(** Sqrt is a monotone function (but not a strict one) *)
Lemma sqrt_le_mono : forall a b, a <= b -> √a <= √b.
(** No reverse result for <=, consider for instance √2 <= √1 *)
Lemma sqrt_lt_cancel : forall a b, √a < √b -> a < b.
(** When left side is a square, we have an equivalence for <= *)
Lemma sqrt_le_square : forall a b, 0<=a -> 0<=b -> (b²<=a <-> b <= √a).
(** When right side is a square, we have an equivalence for < *)
Lemma sqrt_lt_square : forall a b, 0<=a -> 0<=b -> (a<b² <-> √a < b).
(** Sqrt and basic constants *)
Lemma sqrt_0 : √0 == 0.
Lemma sqrt_1 : √1 == 1.
Lemma sqrt_2 : √2 == 1.
Lemma sqrt_pos : forall a, 0 < √a <-> 0 < a.
Lemma sqrt_lt_lin : forall a, 1<a -> √a<a.
Lemma sqrt_le_lin : forall a, 0<=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. *)
Lemma sqrt_mul_below : forall a b, √a * √b <= √(a*b).
Lemma sqrt_mul_above : forall a b, 0<=a -> 0<=b -> √(a*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 *)
Lemma sqrt_succ_le : forall a, 0<=a -> √(S a) <= S (√a).
Lemma sqrt_succ_or : forall a, 0<=a -> √(S a) == S (√a) \/ √(S a) == √a.
Lemma sqrt_eq_succ_iff_square : forall a, 0<=a ->
(√(S a) == S (√a) <-> exists b, 0<b /\ S a == b²).