Definition defined_by_instr (r': mreg) (i: instruction) :=
  match i with
  | Lgetstack sl ofs ty r => r' = r
  | Lop op args res => r' = res
  | Lload chunk addr args dst => r' = dst
  | Lbuiltin ef args res => In r' (params_of_builtin_res res) \/ In r' (destroyed_by_builtin ef)
  | _ => False
  end.

(* Specifications: *)
Lemma record_regs_of_instr_ok: forall r' u i, defined_by_instr r' i -> is_callee_save r' = true -> RegSet.In r' (record_regs_of_instr u i).
Lemma record_regs_of_function_ok: forall r i, In i f.(fn_code) -> defined_by_instr r i -> is_callee_save r = true -> RegSet.In r record_regs_of_function.
Lemma max_over_list_bound: forall (A: Type) (valu: A -> Z) (l: list A) (x: A), In x l -> valu x <= max_over_list valu l.
Lemma max_over_instrs_bound: forall (valu: instruction -> Z) i, In i f.(fn_code) -> valu i <= max_over_instrs valu.
Lemma max_over_slots_of_funct_bound: forall (valu: slot * Z * typ -> Z) i s, In i f.(fn_code) -> In s (slots_of_instr i) -> valu s <= max_over_slots_of_funct valu.
Lemma local_slot_bound: forall i ofs ty, In i f.(fn_code) -> In (Local, ofs, ty) (slots_of_instr i) -> ofs + typesize ty <= bound_local function_bounds.
Lemma outgoing_slot_bound: forall i ofs ty, In i f.(fn_code) -> In (Outgoing, ofs, ty) (slots_of_instr i) -> ofs + typesize ty <= bound_outgoing function_bounds.
Lemma size_arguments_bound: forall sig ros, In (Lcall sig ros) f.(fn_code) -> size_arguments sig <= bound_outgoing function_bounds.
Lemma mreg_is_within_bounds: forall i, In i f.(fn_code) -> forall r, defined_by_instr r i -> mreg_within_bounds function_bounds r.
Lemma slot_is_within_bounds: forall i, In i f.(fn_code) -> forall sl ty ofs, In (sl, ofs, ty) (slots_of_instr i) -> slot_within_bounds function_bounds sl ofs ty.
Lemma slots_of_locs_charact: forall sl ofs ty l, In (sl, ofs, ty) (slots_of_locs l) <-> In (S sl ofs ty) l.
Lemma instr_is_within_bounds: forall i, In i f.(fn_code) -> instr_within_bounds function_bounds i.
Lemma function_is_within_bounds: function_within_bounds f function_bounds.