Ltac Rewrite_eq_ :=
  repeat
   match goal with
   | id1:(_ = left _ _) |- _ => rewrite id1; clear id1
   | id1:(_ = right _ _) |- _ => rewrite id1; clear id1
   | id1:(_ = inleft _ _) |- _ =>
       rewrite id1; clear id1
   | id1:(_ = inright _ _) |- _ => rewrite id1; clear id1
   end.Ltac Clear_eq_ :=
  repeat
   match goal with
   | id1:(_ = left _ _) |- _ => clear id1
   | id1:(_ = right _ _) |- _ => clear id1
   | id1:(_ = inleft _ _) |- _ => clear id1
   | id1:(_ = inright _ _) |- _ => clear id1
   end.Ltac Sign_mismatch :=
  Clear_eq_;
   match goal with
   | id1:(?X1 = 1%Z),id2:(?X1 = 0%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   | id1:(?X1 = 0%Z),id2:(?X1 = 1%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   | id1:(?X1 = (-1)%Z),id2:(?X1 = 0%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   | id1:(?X1 = 0%Z),id2:(?X1 = (-1)%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   | id1:(?X1 = 1%Z),id2:(?X1 = (-1)%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   | id1:(?X1 = (-1)%Z),id2:(?X1 = 1%Z) |- _ =>
       rewrite id2 in id1; discriminate id1
   end.

(* Specifications: *)
Lemma Qhomographic_Qpositive_to_Q_0 : forall (a b c d : Z) (p : Qpositive) (H_Qhomographic_sg_denom_nonzero : Qhomographic_sg_denom_nonzero c d p) (Hc : c <> 0%Z), (a * d)%Z = (b * c)%Z -> d = 0%Z -> Qhomographic_Qpositive_to_Q a b c d p H_Qhomographic_sg_denom_nonzero = fraction_encoding a c Hc.
Lemma Qhomographic_Qpositive_to_Q_1 : forall (a b c d : Z) (p : Qpositive) (H_Qhomographic_sg_denom_nonzero : Qhomographic_sg_denom_nonzero c d p) (Hd : d <> 0%Z), (a * d)%Z = (b * c)%Z -> Qhomographic_Qpositive_to_Q a b c d p H_Qhomographic_sg_denom_nonzero = fraction_encoding b d Hd.
Lemma Qhomographic_Qpositive_to_Q_2 : forall (a b c d : Z) (p : Qpositive) (H_Qhomographic_sg_denom_nonzero : Qhomographic_sg_denom_nonzero c d p), (a * d)%Z <> (b * c)%Z -> h_sign a b c d p H_Qhomographic_sg_denom_nonzero = 0%Z -> Qhomographic_Qpositive_to_Q a b c d p H_Qhomographic_sg_denom_nonzero = Zero.