Let bsm_end := mm_nullify tmp1 err (map (fun p => pos_nxt (pos_nxt p)) (pos_list m)) ++ DEC tmp1 0 :: nil.
Let length_nullify : length (mm_nullify tmp1 err (map (fun p => pos_nxt (pos_nxt p)) (pos_list m))) = 2*m.
Let bsm_end_spec w : w#>tmp1 = 0 -> w#>tmp2 = 0 -> (err,bsm_end) // (err,w) -+> (0,vec_zero).
Definition bsm_simulator := bsm_compiler ++ bsm_end.
Let bsm_comp_sim : Q <sc (1,bsm_simulator).
Let bsm_end_sim : (err,bsm_end) <sc (1,bsm_simulator).

Theorem bsm_simulator_correct v : (exists q w, P /BSM/ (fst P,v) ->> (q,w) /\ out_code q P)
<-> (1,bsm_simulator) // (1,0##0##vec_map stack_enc v) ->> (0,vec_zero).