Program Definition haltsn (n : nat) (stk : stack) : pred world :=
  fun pr => let (p,r) := pr in
    (level p >= n -> eventually_halts_n n p r stk).Definition termMeas :=
  { R : store -> nat -> Prop |
    forall x y y', R x y -> R x y' -> y = y' }.Program Definition code (l : label) (c : instruction) : pred prog :=
  fun p =>
    exists i, prog_lookup p l = Some i /\ instr_approx_rel (level p) c i.Program Definition evalTM (t : termMeas) (n : nat) : pred world :=
  fun w => let (_, r) := w in
    proj1_sig t r n.Program Definition embedWP (P : pred world) : pred prog :=
  fun p => forall r, P (p,r).

(* Specifications: *)
Lemma hoare_weaken_time : forall x x' G R P i Q, x <= x' -> hoare x G R P i Q -> hoare x' G R P i Q.
Lemma hoare_ex_pre : forall x G R T P i Q, (forall z:T, hoare x G R (P z) i Q) -> hoare x G R (exp P) i Q.
Lemma hoare_ex_pre' : forall x G R T P i Q, hoare x G R (exp P) i Q -> (forall z:T, hoare x G R (P z) i Q).
Lemma hoare_return : forall G R, hoare 0 G R R instr_return FF.
Lemma hoare_getlabel : forall l v G R P, hoare 0 G R (box (setM v (value_label l)) P) (instr_getlabel l v) P.
Lemma verify_complete : forall G psi, verify_prog psi G -> forall n, G (K.squash (n,psi)).