Lemma
spec_Qquadratic_Qpositive_to_Q_spec_Qquadratic_Qpositive_to_Qpositive2_pos :
forall (a b c d e f g h : Z) (p1 p2 : Qpositive),
Qsgn (spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2) = 1%Z ->
spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2 =
Qpos (spec_Qquadratic_Qpositive_to_Qpositive2 a b c d e f g h p1 p2).
(** We use this when (Z.sgn a+b+c+d)<0 *)
Lemma
spec_Qquadratic_Qpositive_to_Q_spec_Qquadratic_Qpositive_to_Qpositive2_neg_1
:
forall (a b c d e f g h : Z) (p1 p2 : Qpositive),
Qsgn (spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2) = (-1)%Z ->
spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2 =
Qneg
(spec_Qquadratic_Qpositive_to_Qpositive2 (- a) (- b)
(- c) (- d) e f g h p1 p2).
(** We use this when 0<=(Z.sgn a+b+c+d) *)
Lemma
spec_Qquadratic_Qpositive_to_Q_spec_Qquadratic_Qpositive_to_Qpositive2_neg_2
:
forall (a b c d e f g h : Z) (p1 p2 : Qpositive),
Qsgn (spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2) = (-1)%Z ->
spec_Qquadratic_Qpositive_to_Q a b c d e f g h p1 p2 =
Qneg
(spec_Qquadratic_Qpositive_to_Qpositive2 a b c d
(- e) (- f) (- g) (- h) p1 p2).

Lemma Qquadratic_sign_pres_fraction :
forall (a b c d e f g h : Z) (p1 p2 : Qpositive)
(H_Qquadratic_sg_denom_nonzero : Qquadratic_sg_denom_nonzero e f g h p1 p2),
Qmult
(Qplus
(Qplus
(Qplus
(Qmult
(Qmult
(qnew_a a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p1 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))
(Qpos
(qnew_p2 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))
(Qmult
(qnew_b a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p1 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))))
(Qmult (qnew_c a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p2 a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero))))
(qnew_d a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero))
(Qinv
(Qplus
(Qplus
(Qplus
(Qmult
(Qmult
(qnew_e a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p1 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))
(Qpos
(qnew_p2 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))
(Qmult
(qnew_f a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p1 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))))
(Qmult
(qnew_g a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(Qpos
(qnew_p2 a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))))
(qnew_h a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero))) =
Qmult
(Qplus
(Qplus
(Qplus (Qmult (Qmult a (Qpos p1)) (Qpos p2)) (Qmult b (Qpos p1)))
(Qmult c (Qpos p2))) d)
(Qinv
(Qplus
(Qplus
(Qplus (Qmult (Qmult e (Qpos p1)) (Qpos p2)) (Qmult f (Qpos p1)))
(Qmult g (Qpos p2))) h)).