(** The divisibility results are no so complicated when we do not need to show that encode_state is injective ... *)
Local Fact divides_from_eq x y t : x*y = t -> divides x t.
Local Fact prime_div_mult4 p w x y z : prime p -> divides p (w*x*y*z) -> divides p w \/ divides p x \/ divides p y \/ divides p z.
Local Hint Resolve encode_mm_instr_regular'.

Lemma steps_backward m i P i1 v1 k st :
@mm_no_self_loops m (i, P)
->               encode_mm_instr i P /F/ encode_state (i1,v1) -[k]-> st
-> exists i2 v2, (i, P) /MM/ (i1, v1) -[k]-> (i2,v2)
/\ st = encode_state (i2,v2).