Section div2.
Variables (src quo rem : pos n)
(Hsq : src <> quo) (Hsr : src <> rem) (Hqr : quo <> rem)
(i : nat).
Definition mm_div2 :=
DEC src (6+i) ::
INC rem ::
DEC src (i+6) ::
DEC rem (4+i) ::
INC quo ::
DEC rem i ::
nil.
Fact mm_div2_length : length mm_div2 = 6.
Let mm_div2_spec_1 k v w :
v#>src = 1+2*k -> v#>rem = 0 -> w = v[0/src][(k+(v#>quo))/quo][1/rem] -> (i,mm_div2) // (i,v) -+> (6+i,w).
Fact mm_div2_progress v :
v#>quo = 0
-> v#>rem = 0
-> let (k,b) := div2 (v#>src)
in  (i,mm_div2) // (i,v) -+> (6+i,v[0/src][k/quo][(if b then 1 else 0)/rem]).

Corollary mm_div2_progress_1 v k st :
v#>quo = 0
-> v#>rem = 0
-> div2 (v#>src) = (k,true)
-> st = (6+i,v[0/src][k/quo][1/rem])
-> (i,mm_div2) // (i,v) -+> st.