Open Scope pred.
(* Various utility lemmas *)
Definition instr_approx_rel (n:nat) (i1 i2:instruction) : Prop :=
fmap_instr (K.approx n) i1 = fmap_instr (K.approx n) i2.
Inductive stack_approx_rel (n:nat) : stack -> stack -> Prop :=
| stack_approx_nil : stack_approx_rel n nil nil
| stack_approx_cons : forall i i' stk stk',
instr_approx_rel n i i' ->
stack_approx_rel n stk stk' ->
stack_approx_rel n (i::stk) (i'::stk').
Program Definition agedfrom {A} `{ageable A} (x:A) : pred A := necR x.
Next Obligation.
unfold hereditary; intros.
apply rt_trans with a; auto.
apply rt_step; auto.
Qed.

Lemma ev_halts_approx : forall t t' p n r r' s s',
level p < n ->
termMeasure_incr t t' ->
store_incr r r' ->
stack_approx_rel n s s' ->
eventually_halts t  p r  s ->
eventually_halts t' p r' s'.