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').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').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').

(* Specifications: *)
Lemma stack_approx_rel_refl : forall n stk, stack_approx_rel n stk stk.
Lemma stack_approx_downward : forall n m s1 s2, n <= m -> stack_approx_rel m s1 s2 -> stack_approx_rel n s1 s2.
Lemma nec_prog_lookup : forall p p' l i, necR p p' -> prog_lookup p l = Some i -> prog_lookup p' l = Some (fmap_instr (K.approx (level p')) i).
Lemma step_prog: forall p1 p2 r1 s1 r2 s2, step p1 p2 r1 s1 r2 s2 -> p1 = p2 \/ age p1 p2.
Lemma step_prog_levels : forall p p' r s r' s', step p p' r s r' s' -> level p' <= level p.
Lemma step_approxprog: forall n p1 p2 p1' p2' r1 s1 s1' r2 s2, step p1 p2 r1 s1 r2 s2 -> ageN n p1 p1' -> ageN n p2 p2' -> stack_approx_rel (S (level p1')) s1 s1' -> exists s2', step p1' p2' r1 s1' r2 s2' /\ stack_approx_rel (S (level p2')) s2 s2'.
Lemma stepstar_prog_levels : forall p p' r s r' s', stepstar p p' r s r' s' -> level p' <= level p.
Lemma stepstar_approxprog: forall n p1 p2 p1' p2' r1 s1 s1' r2 s2, stepstar p1 p2 r1 s1 r2 s2 -> ageN n p1 p1' -> ageN n p2 p2' -> stack_approx_rel (S (level p1')) s1 s1' -> exists s2', stepstar p1' p2' r1 s1' r2 s2' /\ stack_approx_rel (S (level p2')) s2 s2'.
Lemma stack_approx_rel_refl : forall n stk, stack_approx_rel n stk stk.
Lemma stack_approx_downward : forall n m s1 s2, n <= m -> stack_approx_rel m s1 s2 -> stack_approx_rel n s1 s2.
Lemma nec_prog_lookup : forall p p' l i, necR p p' -> prog_lookup p l = Some i -> prog_lookup p' l = Some (fmap_instr (K.approx (level p')) i).
Lemma step_prog: forall p1 p2 r1 s1 r2 s2, step p1 p2 r1 s1 r2 s2 -> p1 = p2 \/ age p1 p2.
Lemma step_prog_levels : forall p p' r s r' s', step p p' r s r' s' -> level p' <= level p.
Lemma step_approxprog: forall n p1 p2 p1' p2' r1 s1 s1' r2 s2, step p1 p2 r1 s1 r2 s2 -> ageN n p1 p1' -> ageN n p2 p2' -> stack_approx_rel (S (level p1')) s1 s1' -> exists s2', step p1' p2' r1 s1' r2 s2' /\ stack_approx_rel (S (level p2')) s2 s2'.
Lemma stepstar_prog_levels : forall p p' r s r' s', stepstar p p' r s r' s' -> level p' <= level p.
Lemma stepstar_approxprog: forall n p1 p2 p1' p2' r1 s1 s1' r2 s2, stepstar p1 p2 r1 s1 r2 s2 -> ageN n p1 p1' -> ageN n p2 p2' -> stack_approx_rel (S (level p1')) s1 s1' -> exists s2', stepstar p1' p2' r1 s1' r2 s2' /\ stack_approx_rel (S (level p2')) s2 s2'.