Section ALLOC.
Variable m1: mem.
Variables lo hi: Z.
Variable m2: mem.
Variable b: Values.block.
Hypothesis ALLOC: Mem.alloc m1 lo hi = (m2, b).
Transparent Mem.alloc.
Opaque Mem.alloc.
End ALLOC.
Definition gvar_info_eq {V1 V2} (v1: option (globvar V1)) (v2: option (globvar V2)) :=
match v1, v2 with
None, None => True
| Some i1, Some i2 => gvar_init i1 = gvar_init i2 /\
gvar_readonly i1 = gvar_readonly i2 /\ gvar_volatile i1 = gvar_volatile i2
| _, _ => False
end.
Definition gvar_infos_eq {F1 V1 F2 V2}
(g1 : Genv.t F1 V1) (g2 : Genv.t F2 V2) :=
forall b, gvar_info_eq (Genv.find_var_info g1 b) (Genv.find_var_info g2 b).
destruct v; simpl; intuition. Qed.
(*****************The following variant is used in the linker***********)
Definition gvars_included {V1 V2} (gv1:option (globvar V1)) (gv2: option (globvar V2)): Prop :=
match gv1, gv2 with
None, None => True
| None, Some x2 => True
| Some x1, None => False
| Some x1, Some x2 => gvar_init x1 = gvar_init x2 /\
gvar_readonly x1 = gvar_readonly x2 /\
gvar_volatile x1 = gvar_volatile x2
end.

Lemma gvars_cohereD {F1 V1 F2 V2} (ge1:Genv.t F1 V1) (ge2:Genv.t F2 V2)
(HG: forall b, gvars_included (Genv.find_var_info ge1 b)
(Genv.find_var_info ge2 b))
b gv1 (GV: Genv.find_var_info ge1 b = Some gv1):
exists gv2, Genv.find_var_info ge2 b = Some gv2 /\
gvar_init gv1 = gvar_init gv2 /\
gvar_readonly gv1 = gvar_readonly gv2 /\
gvar_volatile gv1 = gvar_volatile gv2.