fact: Fixpoint div_bin (n m:positive){struct n} : Z*Z := match n with | 1%positive => match m with 1%positive =>(1,0) | _ =>(0,1) end | xO n' => let (q',r'):=div_bin n' m in match Z_lt_ge_dec (2*r')(Zpos m) with | left Hlt => (2*q', 2*r') | right Hge => (2*q' + 1, 2*r' - (Zpos m)) end | xI n' => let (q',r'):=div_bin n' m in match Z_lt_ge_dec (2*r' + 1)(Zpos m) with | left Hlt => (2*q', 2*r' + 1) | right Hge => (2*q' + 1, (2*r' + 1)-(Zpos m)) end end.
imports: ZArith List Arith Lia Zwf Program