(** A compilation environment (mapping) is valid in a given state if
  the registers associated with Cminor local variables and let-bound variables
  are valid in the state. *)

Definition map_valid (m: mapping) (s: state) : Prop :=
  forall r, reg_in_map m r -> reg_valid r s.

Lemma alloc_optreg_fresh_or_in_map: forall map dest s r s' i, map_valid map s -> alloc_optreg map dest s = OK r s' i -> reg_in_map map r \/ reg_fresh r s.