(** * Neededness for register environments *)
Module NVal <: SEMILATTICE.
Definition t := nval.
Definition eq (x y: t) := (x = y).
Definition eq_refl: forall x, eq x x := (@eq_refl t).
Definition eq_sym: forall x y, eq x y -> eq y x := (@eq_sym t).
Definition eq_trans: forall x y z, eq x y -> eq y z -> eq x z := (@eq_trans t).
Definition beq (x y: t) : bool := proj_sumbool (eq_nval x y).

(* Specifications: *)
Lemma beq_correct: forall x y, beq x y = true -> eq x y.
Hint Resolve nreg_agree: na.
Lemma eagree_ge:
forall e1 e2 ne ne',
eagree e1 e2 ne -> NE.ge ne ne' -> eagree e1 e2 ne'.
Lemma eagree_bot:
forall e1 e2, eagree e1 e2 NE.bot.
Lemma eagree_same:
forall e ne, eagree e e ne.
Lemma eagree_update_1:
forall e1 e2 ne v1 v2 nv r,
eagree e1 e2 ne -> vagree v1 v2 nv -> eagree (e1#r <- v1) (e2#r <- v2) (NE.set r nv ne).
Lemma eagree_update:
forall e1 e2 ne v1 v2 r,
vagree v1 v2 (nreg ne r) ->
eagree e1 e2 (NE.set r Nothing ne) ->
eagree (e1#r <- v1) (e2#r <- v2) ne.
Lemma eagree_update_dead:
forall e1 e2 ne v1 r,
nreg ne r = Nothing ->
eagree e1 e2 ne -> eagree (e1#r <- v1) e2 ne.