(** ** Correctness proofs for the square root function *)

Inductive SqrtSpec : positive*mask -> positive -> Prop :=
 | SqrtExact s x : x=s*s -> SqrtSpec (s,IsNul) x
 | SqrtApprox s r x : x=s*s+r -> r <= s~0 -> SqrtSpec (s,IsPos r) x.(** ** Correctness proofs for the square root function *)

Inductive SqrtSpec : positive*mask -> positive -> Prop :=
 | SqrtExact s x : x=s*s -> SqrtSpec (s,IsNul) x
 | SqrtApprox s r x : x=s*s+r -> r <= s~0 -> SqrtSpec (s,IsPos r) x.(** ** Correctness proofs for the square root function *)

Inductive SqrtSpec : positive*mask -> positive -> Prop :=
 | SqrtExact s x : x=s*s -> SqrtSpec (s,IsNul) x
 | SqrtApprox s r x : x=s*s+r -> r <= s~0 -> SqrtSpec (s,IsPos r) x.

(* Specifications: *)
Lemma sqrtrem_step_spec f g p x : (f=xO \/ f=xI) -> (g=xO \/ g=xI) -> SqrtSpec p x -> SqrtSpec (sqrtrem_step f g p) (g (f x)).
Lemma sqrtrem_spec p : SqrtSpec (sqrtrem p) p.
Lemma sqrt_spec p : let s := sqrt p in s*s <= p < (succ s)*(succ s).
Lemma divide_add_cancel_l p q r : (p | r) -> (p | q + r) -> (p | q).
Lemma divide_xO_xI p q r : (p | q~0) -> (p | r~1) -> (p | q).
Lemma divide_xO_xO p q : (p~0|q~0) <-> (p|q).
Lemma divide_mul_l p q r : (p|q) -> (p|q*r).
Lemma divide_mul_r p q r : (p|r) -> (p|q*r).
Lemma ggcdn_gcdn : forall n a b, fst (ggcdn n a b) = gcdn n a b.
Lemma ggcd_gcd : forall a b, fst (ggcd a b) = gcd a b.