(** Simplification of fractions using [Zgcd].
  This version can compute within Coq. *)

Definition Qred (q:Q) := 
  let (q1,q2) := Qfactor_twos q in 
  let (r1,r2) := snd (Zggcd q1 (Zpos q2)) in r1#(Z2P r2).

Lemma Qred_correct : forall q, (Qred q) == q.