(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Require Export Qquadratic_sign_properties.
Require Export Qquadratic_Qpositive_to_Qpositive.
Require Export homographicAcc_Qhomographic_sign.
Definition qnew_a (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) :=
fst
(fst
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))).
Definition qnew_b (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) :=
fst
(snd
(fst
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))))).
Definition qnew_c (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) :=
fst
(snd
(snd
(fst
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))))).
Definition qnew_d (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) :=
snd
(snd
(snd
(fst
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))))).
Definition qnew_e (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) :=
fst
(snd
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))).
Definition qnew_f (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) :=
fst
(snd
(snd
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))))).
Definition qnew_g (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) :=
fst
(snd
(snd
(snd
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))))).
Definition qnew_h (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) :=
snd
(snd
(snd
(snd
(fst
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero)))))).
Definition qnew_p1 (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) :=
fst
(snd
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))).
Definition qnew_p2 (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) :=
snd
(snd
(snd
(Qquadratic_sign a b c d e f g h p1 p2
H_Qquadratic_sg_denom_nonzero))).

Lemma Qquadratic_Qpositive_to_Q_quadraticAcc_neg_1 :
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),
~ same_ratio a b c d e f g h ->
q_sign a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero = (-1)%Z ->
Z.sgn
(qnew_a a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero +
qnew_b a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero +
qnew_c 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) = 1%Z ->
quadraticAcc (qnew_a a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(qnew_b a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(qnew_c 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)
(- qnew_e a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(- qnew_f a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(- qnew_g 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)
(qnew_p1 a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero)
(qnew_p2 a b c d e f g h p1 p2 H_Qquadratic_sg_denom_nonzero).