(** A simple cancelation by powers of two *)
Definition Qfactor_twos (q:Q) :=
let (p,q) := q in
match p with
| Z0 => 0
| Zpos p => let (p,q) := Pfactor_twos p q in (Zpos p)#q
| Zneg p => let (p,q) := Pfactor_twos p q in (Zneg p)#q
end.

Lemma Qfactor_twos_correct : forall q, Qfactor_twos q == q.
Hint Resolve Qfactor_twos_correct.