Global environments are a component of the dynamic semantics of
all languages involved in the compiler. A global environment
maps symbol names (names of functions and of global variables)
to the corresponding memory addresses. It also maps memory addresses
of functions to the corresponding function descriptions.
Global environments, along with the initial memory state at the beginning
of program execution, are built from the program of interest, as follows:
-
A distinct memory address is assigned to each function of the program.
These function addresses use negative numbers to distinguish them from
addresses of memory blocks. The associations of function name to function
address and function address to function description are recorded in
the global environment.
-
For each global variable, a memory block is allocated and associated to
the name of the variable.
These operations reflect (at a high level of abstraction) what takes
place during program linking and program loading in a real operating
system.
Require Recdef.
Require Import Zwf.
Require Import Coqlib.
Require Import Errors.
Require Import Maps.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Memory.
Notation "
s #1" := (
fst s) (
at level 9,
format "
s '#1'") :
pair_scope.
Notation "
s #2" := (
snd s) (
at level 9,
format "
s '#2'") :
pair_scope.
Local Open Scope pair_scope.
Local Open Scope error_monad_scope.
Set Implicit Arguments.
Auxiliary function for initialization of global variables.
Function store_zeros (
m:
mem) (
b:
block) (
p:
Z) (
n:
Z) {
wf (
Zwf 0)
n}:
option mem :=
if zle n 0
then Some m else
match Mem.store Mint8unsigned m b p Vzero with
|
Some m' =>
store_zeros m'
b (
p + 1) (
n - 1)
|
None =>
None
end.
Proof.
Local Unset Elimination Schemes.
Local Unset Case Analysis Schemes.
Symbol environments
Symbol environments are a restricted view of global environments,
focusing on symbol names and their associated blocks. They do not
contain mappings from blocks to function or variable definitions.
Module Senv.
Record t:
Type :=
mksenv {
Operations
find_symbol:
ident ->
option block;
public_symbol:
ident ->
bool;
invert_symbol:
block ->
option ident;
block_is_volatile:
block ->
bool;
nextblock:
block;
Properties
find_symbol_injective:
forall id1 id2 b,
find_symbol id1 =
Some b ->
find_symbol id2 =
Some b ->
id1 =
id2;
invert_find_symbol:
forall id b,
invert_symbol b =
Some id ->
find_symbol id =
Some b;
find_invert_symbol:
forall id b,
find_symbol id =
Some b ->
invert_symbol b =
Some id;
public_symbol_exists:
forall id,
public_symbol id =
true ->
exists b,
find_symbol id =
Some b;
find_symbol_below:
forall id b,
find_symbol id =
Some b ->
Plt b nextblock;
block_is_volatile_below:
forall b,
block_is_volatile b =
true ->
Plt b nextblock
}.
Definition symbol_address (
ge:
t) (
id:
ident) (
ofs:
int) :
val :=
match find_symbol ge id with
|
Some b =>
Vptr b ofs
|
None =>
Vundef
end.
Theorem shift_symbol_address:
forall ge id ofs n,
symbol_address ge id (
Int.add ofs n) =
Val.add (
symbol_address ge id ofs) (
Vint n).
Proof.
End Senv.
Module Genv.
Global environments
Section GENV.
Variable F:
Type.
(* The type of function descriptions *)
Variable V:
Type.
(* The type of information attached to variables *)
The type of global environments.
Record t:
Type :=
mkgenv {
genv_public:
list ident;
(* which symbol names are public *)
genv_symb:
PTree.t block;
(* mapping symbol -> block *)
genv_funs:
PTree.t F;
(* mapping function pointer -> definition *)
genv_vars:
PTree.t (
globvar V);
(* mapping variable pointer -> info *)
genv_next:
block;
(* next symbol pointer *)
genv_symb_range:
forall id b,
PTree.get id genv_symb =
Some b ->
Plt b genv_next;
genv_funs_range:
forall b f,
PTree.get b genv_funs =
Some f ->
Plt b genv_next;
genv_vars_range:
forall b v,
PTree.get b genv_vars =
Some v ->
Plt b genv_next;
genv_funs_vars:
forall b1 b2 f v,
PTree.get b1 genv_funs =
Some f ->
PTree.get b2 genv_vars =
Some v ->
b1 <>
b2;
genv_vars_inj:
forall id1 id2 b,
PTree.get id1 genv_symb =
Some b ->
PTree.get id2 genv_symb =
Some b ->
id1 =
id2
}.
Lookup functions
find_symbol ge id returns the block associated with the given name, if any
Definition find_symbol (
ge:
t) (
id:
ident) :
option block :=
PTree.get id ge.(
genv_symb).
symbol_address ge id ofs returns a pointer into the block associated
with id, at byte offset ofs. Vundef is returned if no block is associated
to id.
Definition symbol_address (
ge:
t) (
id:
ident) (
ofs:
int) :
val :=
match find_symbol ge id with
|
Some b =>
Vptr b ofs
|
None =>
Vundef
end.
public_symbol ge id says whether the name id is public and defined.
Definition public_symbol (
ge:
t) (
id:
ident) :
bool :=
match find_symbol ge id with
|
None =>
false
|
Some _ =>
In_dec ident_eq id ge.(
genv_public)
end.
find_funct_ptr ge b returns the function description associated with
the given address.
Definition find_funct_ptr (
ge:
t) (
b:
block) :
option F :=
PTree.get b ge.(
genv_funs).
find_funct is similar to find_funct_ptr, but the function address
is given as a value, which must be a pointer with offset 0.
Definition find_funct (
ge:
t) (
v:
val) :
option F :=
match v with
|
Vptr b ofs =>
if Int.eq_dec ofs Int.zero then find_funct_ptr ge b else None
|
_ =>
None
end.
invert_symbol ge b returns the name associated with the given block, if any
Definition invert_symbol (
ge:
t) (
b:
block) :
option ident :=
PTree.fold
(
fun res id b' =>
if eq_block b b'
then Some id else res)
ge.(
genv_symb)
None.
find_var_info ge b returns the information attached to the variable
at address b.
Definition find_var_info (
ge:
t) (
b:
block) :
option (
globvar V) :=
PTree.get b ge.(
genv_vars).
block_is_volatile ge b returns true if b points to a global variable
of volatile type, false otherwise.
Definition block_is_volatile (
ge:
t) (
b:
block) :
bool :=
match find_var_info ge b with
|
None =>
false
|
Some gv =>
gv.(
gvar_volatile)
end.
Constructing the global environment
Program Definition add_global (
ge:
t) (
idg:
ident *
globdef F V) :
t :=
@
mkgenv
ge.(
genv_public)
(
PTree.set idg#1
ge.(
genv_next)
ge.(
genv_symb))
(
match idg#2
with
|
Gfun f =>
PTree.set ge.(
genv_next)
f ge.(
genv_funs)
|
Gvar v =>
ge.(
genv_funs)
end)
(
match idg#2
with
|
Gfun f =>
ge.(
genv_vars)
|
Gvar v =>
PTree.set ge.(
genv_next)
v ge.(
genv_vars)
end)
(
Psucc ge.(
genv_next))
_ _ _ _ _.
Next Obligation.
Next Obligation.
Next Obligation.
Next Obligation.
Next Obligation.
destruct ge;
simpl in *.
rewrite PTree.gsspec in H.
rewrite PTree.gsspec in H0.
destruct (
peq id1 i);
destruct (
peq id2 i).
congruence.
inv H.
eelim Plt_strict.
eapply genv_symb_range0;
eauto.
inv H0.
eelim Plt_strict.
eapply genv_symb_range0;
eauto.
eauto.
Qed.
Definition add_globals (
ge:
t) (
gl:
list (
ident *
globdef F V)) :
t :=
List.fold_left add_global gl ge.
Lemma add_globals_app:
forall gl2 gl1 ge,
add_globals ge (
gl1 ++
gl2) =
add_globals (
add_globals ge gl1)
gl2.
Proof.
induction gl1; simpl; intros. auto. rewrite IHgl1; auto.
Qed.
Program Definition empty_genv (
pub:
list ident):
t :=
@
mkgenv pub (
PTree.empty _) (
PTree.empty _) (
PTree.empty _) 1%
positive _ _ _ _ _.
Next Obligation.
Next Obligation.
Next Obligation.
Next Obligation.
Next Obligation.
Definition globalenv (
p:
program F V) :=
add_globals (
empty_genv p.(
prog_public))
p.(
prog_defs).
Proof principles
Section GLOBALENV_PRINCIPLES.
Variable P:
t ->
Prop.
Lemma add_globals_preserves:
forall gl ge,
(
forall ge id g,
P ge ->
In (
id,
g)
gl ->
P (
add_global ge (
id,
g))) ->
P ge ->
P (
add_globals ge gl).
Proof.
induction gl; simpl; intros.
auto.
destruct a. apply IHgl; auto.
Qed.
Lemma add_globals_ensures:
forall id g gl ge,
(
forall ge id g,
P ge ->
In (
id,
g)
gl ->
P (
add_global ge (
id,
g))) ->
(
forall ge,
P (
add_global ge (
id,
g))) ->
In (
id,
g)
gl ->
P (
add_globals ge gl).
Proof.
induction gl;
simpl;
intros.
contradiction.
destruct H1.
subst a.
apply add_globals_preserves;
auto.
apply IHgl;
auto.
Qed.
Lemma add_globals_unique_preserves:
forall id gl ge,
(
forall ge id1 g,
P ge ->
In (
id1,
g)
gl ->
id1 <>
id ->
P (
add_global ge (
id1,
g))) ->
~
In id (
map fst gl) ->
P ge ->
P (
add_globals ge gl).
Proof.
induction gl; simpl; intros.
auto.
destruct a. apply IHgl; auto.
Qed.
Lemma add_globals_unique_ensures:
forall gl1 id g gl2 ge,
(
forall ge id1 g1,
P ge ->
In (
id1,
g1)
gl2 ->
id1 <>
id ->
P (
add_global ge (
id1,
g1))) ->
(
forall ge,
P (
add_global ge (
id,
g))) ->
~
In id (
map fst gl2) ->
P (
add_globals ge (
gl1 ++ (
id,
g) ::
gl2)).
Proof.
Remark in_norepet_unique:
forall id g (
gl:
list (
ident *
globdef F V)),
In (
id,
g)
gl ->
list_norepet (
map fst gl) ->
exists gl1 gl2,
gl =
gl1 ++ (
id,
g) ::
gl2 /\ ~
In id (
map fst gl2).
Proof.
induction gl as [|[
id1 g1]
gl];
simpl;
intros.
contradiction.
inv H0.
destruct H.
inv H.
exists nil,
gl.
auto.
exploit IHgl;
eauto.
intros (
gl1 &
gl2 &
X &
Y).
exists ((
id1,
g1) ::
gl1),
gl2;
split;
auto.
rewrite X;
auto.
Qed.
Lemma add_globals_norepet_ensures:
forall id g gl ge,
(
forall ge id1 g1,
P ge ->
In (
id1,
g1)
gl ->
id1 <>
id ->
P (
add_global ge (
id1,
g1))) ->
(
forall ge,
P (
add_global ge (
id,
g))) ->
In (
id,
g)
gl ->
list_norepet (
map fst gl) ->
P (
add_globals ge gl).
Proof.
End GLOBALENV_PRINCIPLES.
Properties of the operations over global environments
Theorem public_symbol_exists:
forall ge id,
public_symbol ge id =
true ->
exists b,
find_symbol ge id =
Some b.
Proof.
Theorem shift_symbol_address:
forall ge id ofs n,
symbol_address ge id (
Int.add ofs n) =
Val.add (
symbol_address ge id ofs) (
Vint n).
Proof.
Theorem find_funct_inv:
forall ge v f,
find_funct ge v =
Some f ->
exists b,
v =
Vptr b Int.zero.
Proof.
intros until f;
unfold find_funct.
destruct v;
try congruence.
destruct (
Int.eq_dec i Int.zero);
try congruence.
intros.
exists b;
congruence.
Qed.
Theorem find_funct_find_funct_ptr:
forall ge b,
find_funct ge (
Vptr b Int.zero) =
find_funct_ptr ge b.
Proof.
Theorem find_symbol_exists:
forall p id g,
In (
id,
g) (
prog_defs p) ->
exists b,
find_symbol (
globalenv p)
id =
Some b.
Proof.
Theorem find_funct_ptr_exists_2:
forall p gl1 id f gl2,
prog_defs p =
gl1 ++ (
id,
Gfun f) ::
gl2 -> ~
In id (
map fst gl2) ->
exists b,
find_symbol (
globalenv p)
id =
Some b
/\
find_funct_ptr (
globalenv p)
b =
Some f.
Proof.
Corollary find_funct_ptr_exists:
forall p id f,
list_norepet (
prog_defs_names p) ->
In (
id,
Gfun f) (
prog_defs p) ->
exists b,
find_symbol (
globalenv p)
id =
Some b
/\
find_funct_ptr (
globalenv p)
b =
Some f.
Proof.
Theorem find_var_exists_2:
forall p gl1 id v gl2,
prog_defs p =
gl1 ++ (
id,
Gvar v) ::
gl2 -> ~
In id (
map fst gl2) ->
exists b,
find_symbol (
globalenv p)
id =
Some b
/\
find_var_info (
globalenv p)
b =
Some v.
Proof.
Corollary find_var_exists:
forall p id v,
list_norepet (
prog_defs_names p) ->
In (
id,
Gvar v) (
prog_defs p) ->
exists b,
find_symbol (
globalenv p)
id =
Some b
/\
find_var_info (
globalenv p)
b =
Some v.
Proof.
Lemma find_symbol_inversion :
forall p x b,
find_symbol (
globalenv p)
x =
Some b ->
In x (
prog_defs_names p).
Proof.
Theorem find_funct_ptr_inversion:
forall p b f,
find_funct_ptr (
globalenv p)
b =
Some f ->
exists id,
In (
id,
Gfun f) (
prog_defs p).
Proof.
Theorem find_funct_inversion:
forall p v f,
find_funct (
globalenv p)
v =
Some f ->
exists id,
In (
id,
Gfun f) (
prog_defs p).
Proof.
Theorem find_funct_ptr_prop:
forall (
P:
F ->
Prop)
p b f,
(
forall id f,
In (
id,
Gfun f) (
prog_defs p) ->
P f) ->
find_funct_ptr (
globalenv p)
b =
Some f ->
P f.
Proof.
Theorem find_funct_prop:
forall (
P:
F ->
Prop)
p v f,
(
forall id f,
In (
id,
Gfun f) (
prog_defs p) ->
P f) ->
find_funct (
globalenv p)
v =
Some f ->
P f.
Proof.
Theorem find_funct_ptr_symbol_inversion:
forall p id b f,
find_symbol (
globalenv p)
id =
Some b ->
find_funct_ptr (
globalenv p)
b =
Some f ->
In (
id,
Gfun f)
p.(
prog_defs).
Proof.
Theorem global_addresses_distinct:
forall ge id1 id2 b1 b2,
id1 <>
id2 ->
find_symbol ge id1 =
Some b1 ->
find_symbol ge id2 =
Some b2 ->
b1 <>
b2.
Proof.
intros. red; intros; subst. elim H. destruct ge. eauto.
Qed.
Theorem invert_find_symbol:
forall ge id b,
invert_symbol ge b =
Some id ->
find_symbol ge id =
Some b.
Proof.
Theorem find_invert_symbol:
forall ge id b,
find_symbol ge id =
Some b ->
invert_symbol ge b =
Some id.
Proof.
Definition advance_next (
gl:
list (
ident *
globdef F V)) (
x:
positive) :=
List.fold_left (
fun n g =>
Psucc n)
gl x.
Remark genv_next_add_globals:
forall gl ge,
genv_next (
add_globals ge gl) =
advance_next gl (
genv_next ge).
Proof.
induction gl; simpl; intros.
auto.
rewrite IHgl. auto.
Qed.
Remark genv_public_add_globals:
forall gl ge,
genv_public (
add_globals ge gl) =
genv_public ge.
Proof.
induction gl; simpl; intros.
auto.
rewrite IHgl; auto.
Qed.
Theorem globalenv_public:
forall p,
genv_public (
globalenv p) =
prog_public p.
Proof.
Theorem block_is_volatile_below:
forall ge b,
block_is_volatile ge b =
true ->
Plt b ge.(
genv_next).
Proof.
Coercing a global environment into a symbol environment
Definition to_senv (
ge:
t) :
Senv.t :=
@
Senv.mksenv
(
find_symbol ge)
(
public_symbol ge)
(
invert_symbol ge)
(
block_is_volatile ge)
ge.(
genv_next)
ge.(
genv_vars_inj)
(
invert_find_symbol ge)
(
find_invert_symbol ge)
(
public_symbol_exists ge)
ge.(
genv_symb_range)
(
block_is_volatile_below ge).
Construction of the initial memory state
Section INITMEM.
Variable ge:
t.
Definition init_data_size (
i:
init_data) :
Z :=
match i with
|
Init_int8 _ => 1
|
Init_int16 _ => 2
|
Init_int32 _ => 4
|
Init_int64 _ => 8
|
Init_float32 _ => 4
|
Init_float64 _ => 8
|
Init_addrof _ _ => 4
|
Init_space n =>
Zmax n 0
end.
Lemma init_data_size_pos:
forall i,
init_data_size i >= 0.
Proof.
destruct i;
simpl;
try omega.
generalize (
Zle_max_r z 0).
omega.
Qed.
Definition store_init_data (
m:
mem) (
b:
block) (
p:
Z) (
id:
init_data) :
option mem :=
match id with
|
Init_int8 n =>
Mem.store Mint8unsigned m b p (
Vint n)
|
Init_int16 n =>
Mem.store Mint16unsigned m b p (
Vint n)
|
Init_int32 n =>
Mem.store Mint32 m b p (
Vint n)
|
Init_int64 n =>
Mem.store Mint64 m b p (
Vlong n)
|
Init_float32 n =>
Mem.store Mfloat32 m b p (
Vsingle n)
|
Init_float64 n =>
Mem.store Mfloat64 m b p (
Vfloat n)
|
Init_addrof symb ofs =>
match find_symbol ge symb with
|
None =>
None
|
Some b' =>
Mem.store Mint32 m b p (
Vptr b'
ofs)
end
|
Init_space n =>
Some m
end.
Fixpoint store_init_data_list (
m:
mem) (
b:
block) (
p:
Z) (
idl:
list init_data)
{
struct idl}:
option mem :=
match idl with
|
nil =>
Some m
|
id ::
idl' =>
match store_init_data m b p id with
|
None =>
None
|
Some m' =>
store_init_data_list m'
b (
p +
init_data_size id)
idl'
end
end.
Fixpoint init_data_list_size (
il:
list init_data) {
struct il} :
Z :=
match il with
|
nil => 0
|
i ::
il' =>
init_data_size i +
init_data_list_size il'
end.
Definition perm_globvar (
gv:
globvar V) :
permission :=
if gv.(
gvar_volatile)
then Nonempty
else if gv.(
gvar_readonly)
then Readable
else Writable.
Definition alloc_global (
m:
mem) (
idg:
ident *
globdef F V):
option mem :=
match idg with
| (
id,
Gfun f) =>
let (
m1,
b) :=
Mem.alloc m 0 1
in
Mem.drop_perm m1 b 0 1
Nonempty
| (
id,
Gvar v) =>
let init :=
v.(
gvar_init)
in
let sz :=
init_data_list_size init in
let (
m1,
b) :=
Mem.alloc m 0
sz in
match store_zeros m1 b 0
sz with
|
None =>
None
|
Some m2 =>
match store_init_data_list m2 b 0
init with
|
None =>
None
|
Some m3 =>
Mem.drop_perm m3 b 0
sz (
perm_globvar v)
end
end
end.
Fixpoint alloc_globals (
m:
mem) (
gl:
list (
ident *
globdef F V))
{
struct gl} :
option mem :=
match gl with
|
nil =>
Some m
|
g ::
gl' =>
match alloc_global m g with
|
None =>
None
|
Some m' =>
alloc_globals m'
gl'
end
end.
Lemma alloc_globals_app :
forall gl1 gl2 m m1,
alloc_globals m gl1 =
Some m1 ->
alloc_globals m1 gl2 =
alloc_globals m (
gl1 ++
gl2).
Proof.
induction gl1.
simpl.
intros.
inversion H;
subst.
auto.
simpl.
intros.
destruct (
alloc_global m a);
eauto.
inversion H.
Qed.
Next-block properties
Remark store_zeros_nextblock:
forall m b p n m',
store_zeros m b p n =
Some m' ->
Mem.nextblock m' =
Mem.nextblock m.
Proof.
intros until n.
functional induction (
store_zeros m b p n);
intros.
inv H;
auto.
rewrite IHo;
eauto with mem.
congruence.
Qed.
Remark store_init_data_list_nextblock:
forall idl b m p m',
store_init_data_list m b p idl =
Some m' ->
Mem.nextblock m' =
Mem.nextblock m.
Proof.
Remark alloc_global_nextblock:
forall g m m',
alloc_global m g =
Some m' ->
Mem.nextblock m' =
Psucc(
Mem.nextblock m).
Proof.
Remark alloc_globals_nextblock:
forall gl m m',
alloc_globals m gl =
Some m' ->
Mem.nextblock m' =
advance_next gl (
Mem.nextblock m).
Proof.
Permissions
Remark store_zeros_perm:
forall k prm b'
q m b p n m',
store_zeros m b p n =
Some m' ->
(
Mem.perm m b'
q k prm <->
Mem.perm m'
b'
q k prm).
Proof.
intros until n.
functional induction (
store_zeros m b p n);
intros.
inv H;
tauto.
destruct (
IHo _ H);
intros.
split;
eauto with mem.
congruence.
Qed.
Remark store_init_data_list_perm:
forall k prm b'
q idl b m p m',
store_init_data_list m b p idl =
Some m' ->
(
Mem.perm m b'
q k prm <->
Mem.perm m'
b'
q k prm).
Proof.
induction idl;
simpl;
intros until m'.
intros.
inv H.
tauto.
caseEq (
store_init_data m b p a);
try congruence.
intros.
rewrite <- (
IHidl _ _ _ _ H0).
assert (
forall chunk v,
Mem.store chunk m b p v =
Some m0 ->
(
Mem.perm m b'
q k prm <->
Mem.perm m0 b'
q k prm)).
intros;
split;
eauto with mem.
destruct a;
simpl in H;
eauto.
inv H;
tauto.
destruct (
find_symbol ge i).
eauto.
discriminate.
Qed.
Remark alloc_global_perm:
forall k prm b'
q idg m m',
alloc_global m idg =
Some m' ->
Mem.valid_block m b' ->
(
Mem.perm m b'
q k prm <->
Mem.perm m'
b'
q k prm).
Proof.
Remark alloc_globals_perm:
forall k prm b'
q gl m m',
alloc_globals m gl =
Some m' ->
Mem.valid_block m b' ->
(
Mem.perm m b'
q k prm <->
Mem.perm m'
b'
q k prm).
Proof.
Data preservation properties
Remark store_zeros_load_outside:
forall m b p n m',
store_zeros m b p n =
Some m' ->
forall chunk b'
p',
b' <>
b \/
p' +
size_chunk chunk <=
p \/
p +
n <=
p' ->
Mem.load chunk m'
b'
p' =
Mem.load chunk m b'
p'.
Proof.
intros until n.
functional induction (
store_zeros m b p n);
intros.
inv H;
auto.
transitivity (
Mem.load chunk m'
b'
p').
apply IHo.
auto.
intuition omega.
eapply Mem.load_store_other;
eauto.
simpl.
intuition omega.
discriminate.
Qed.
Remark store_zeros_loadbytes_outside:
forall m b p n m',
store_zeros m b p n =
Some m' ->
forall b'
p'
n',
b' <>
b \/
p' +
n' <=
p \/
p +
n <=
p' ->
Mem.loadbytes m'
b'
p'
n' =
Mem.loadbytes m b'
p'
n'.
Proof.
Definition read_as_zero (
m:
mem) (
b:
block) (
ofs len:
Z) :
Prop :=
forall chunk p,
ofs <=
p ->
p +
size_chunk chunk <=
ofs +
len ->
(
align_chunk chunk |
p) ->
Mem.load chunk m b p =
Some (
match chunk with
|
Mint8unsigned |
Mint8signed |
Mint16unsigned |
Mint16signed |
Mint32 =>
Vint Int.zero
|
Mint64 =>
Vlong Int64.zero
|
Mfloat32 =>
Vsingle Float32.zero
|
Mfloat64 =>
Vfloat Float.zero
|
Many32 |
Many64 =>
Vundef
end).
Remark store_zeros_loadbytes:
forall m b p n m',
store_zeros m b p n =
Some m' ->
forall p'
n',
p <=
p' ->
p' +
Z.of_nat n' <=
p +
n ->
Mem.loadbytes m'
b p' (
Z.of_nat n') =
Some (
list_repeat n' (
Byte Byte.zero)).
Proof.
Lemma store_zeros_read_as_zero:
forall m b p n m',
store_zeros m b p n =
Some m' ->
read_as_zero m'
b p n.
Proof.
Remark store_init_data_outside:
forall b i m p m',
store_init_data m b p i =
Some m' ->
forall chunk b'
q,
b' <>
b \/
q +
size_chunk chunk <=
p \/
p +
init_data_size i <=
q ->
Mem.load chunk m'
b'
q =
Mem.load chunk m b'
q.
Proof.
Remark store_init_data_list_outside:
forall b il m p m',
store_init_data_list m b p il =
Some m' ->
forall chunk b'
q,
b' <>
b \/
q +
size_chunk chunk <=
p ->
Mem.load chunk m'
b'
q =
Mem.load chunk m b'
q.
Proof.
Fixpoint load_store_init_data (
m:
mem) (
b:
block) (
p:
Z) (
il:
list init_data) {
struct il} :
Prop :=
match il with
|
nil =>
True
|
Init_int8 n ::
il' =>
Mem.load Mint8unsigned m b p =
Some(
Vint(
Int.zero_ext 8
n))
/\
load_store_init_data m b (
p + 1)
il'
|
Init_int16 n ::
il' =>
Mem.load Mint16unsigned m b p =
Some(
Vint(
Int.zero_ext 16
n))
/\
load_store_init_data m b (
p + 2)
il'
|
Init_int32 n ::
il' =>
Mem.load Mint32 m b p =
Some(
Vint n)
/\
load_store_init_data m b (
p + 4)
il'
|
Init_int64 n ::
il' =>
Mem.load Mint64 m b p =
Some(
Vlong n)
/\
load_store_init_data m b (
p + 8)
il'
|
Init_float32 n ::
il' =>
Mem.load Mfloat32 m b p =
Some(
Vsingle n)
/\
load_store_init_data m b (
p + 4)
il'
|
Init_float64 n ::
il' =>
Mem.load Mfloat64 m b p =
Some(
Vfloat n)
/\
load_store_init_data m b (
p + 8)
il'
|
Init_addrof symb ofs ::
il' =>
(
exists b',
find_symbol ge symb =
Some b' /\
Mem.load Mint32 m b p =
Some(
Vptr b'
ofs))
/\
load_store_init_data m b (
p + 4)
il'
|
Init_space n ::
il' =>
read_as_zero m b p n
/\
load_store_init_data m b (
p +
Zmax n 0)
il'
end.
Remark init_data_list_size_pos:
forall il,
init_data_list_size il >= 0.
Proof.
Lemma store_init_data_list_charact:
forall b il m p m',
store_init_data_list m b p il =
Some m' ->
read_as_zero m b p (
init_data_list_size il) ->
load_store_init_data m'
b p il.
Proof.
Remark load_alloc_global:
forall chunk b p id g m m',
alloc_global m (
id,
g) =
Some m' ->
Mem.valid_block m b ->
Mem.load chunk m'
b p =
Mem.load chunk m b p.
Proof.
Remark load_alloc_globals:
forall chunk b p gl m m',
alloc_globals m gl =
Some m' ->
Mem.valid_block m b ->
Mem.load chunk m'
b p =
Mem.load chunk m b p.
Proof.
Remark load_store_init_data_invariant:
forall m m'
b,
(
forall chunk ofs,
Mem.load chunk m'
b ofs =
Mem.load chunk m b ofs) ->
forall il p,
load_store_init_data m b p il ->
load_store_init_data m'
b p il.
Proof.
induction il; intro p; simpl.
auto.
repeat rewrite H. destruct a; intuition. red; intros; rewrite H; auto.
Qed.
Definition variables_initialized (
g:
t) (
m:
mem) :=
forall b gv,
find_var_info g b =
Some gv ->
Mem.range_perm m b 0 (
init_data_list_size gv.(
gvar_init))
Cur (
perm_globvar gv)
/\ (
forall ofs k p,
Mem.perm m b ofs k p ->
0 <=
ofs <
init_data_list_size gv.(
gvar_init) /\
perm_order (
perm_globvar gv)
p)
/\ (
gv.(
gvar_volatile) =
false ->
load_store_init_data m b 0
gv.(
gvar_init)).
Definition functions_initialized (
g:
t) (
m:
mem) :=
forall b fd,
find_funct_ptr g b =
Some fd ->
Mem.perm m b 0
Cur Nonempty
/\ (
forall ofs k p,
Mem.perm m b ofs k p ->
ofs = 0 /\
perm_order Nonempty p).
Lemma alloc_global_initialized:
forall ge m id g m',
genv_next ge =
Mem.nextblock m ->
alloc_global m (
id,
g) =
Some m' ->
variables_initialized ge m ->
functions_initialized ge m ->
variables_initialized (
add_global ge (
id,
g))
m'
/\
functions_initialized (
add_global ge (
id,
g))
m'
/\
genv_next (
add_global ge (
id,
g)) =
Mem.nextblock m'.
Proof.
Lemma alloc_globals_initialized:
forall gl ge m m',
genv_next ge =
Mem.nextblock m ->
alloc_globals m gl =
Some m' ->
variables_initialized ge m ->
functions_initialized ge m ->
variables_initialized (
add_globals ge gl)
m' /\
functions_initialized (
add_globals ge gl)
m'.
Proof.
induction gl;
simpl;
intros.
inv H0;
auto.
destruct a as [
id g].
destruct (
alloc_global m (
id,
g))
as [
m1|]
eqn:?;
try discriminate.
exploit alloc_global_initialized;
eauto.
intros [
P [
Q R]].
eapply IHgl;
eauto.
Qed.
End INITMEM.
Definition init_mem (
p:
program F V) :=
alloc_globals (
globalenv p)
Mem.empty p.(
prog_defs).
Lemma init_mem_genv_next:
forall p m,
init_mem p =
Some m ->
genv_next (
globalenv p) =
Mem.nextblock m.
Proof.
Theorem find_symbol_not_fresh:
forall p id b m,
init_mem p =
Some m ->
find_symbol (
globalenv p)
id =
Some b ->
Mem.valid_block m b.
Proof.
Theorem find_funct_ptr_not_fresh:
forall p b f m,
init_mem p =
Some m ->
find_funct_ptr (
globalenv p)
b =
Some f ->
Mem.valid_block m b.
Proof.
Theorem find_var_info_not_fresh:
forall p b gv m,
init_mem p =
Some m ->
find_var_info (
globalenv p)
b =
Some gv ->
Mem.valid_block m b.
Proof.
Theorem init_mem_characterization:
forall p b gv m,
find_var_info (
globalenv p)
b =
Some gv ->
init_mem p =
Some m ->
Mem.range_perm m b 0 (
init_data_list_size gv.(
gvar_init))
Cur (
perm_globvar gv)
/\ (
forall ofs k p,
Mem.perm m b ofs k p ->
0 <=
ofs <
init_data_list_size gv.(
gvar_init) /\
perm_order (
perm_globvar gv)
p)
/\ (
gv.(
gvar_volatile) =
false ->
load_store_init_data (
globalenv p)
m b 0
gv.(
gvar_init)).
Proof.
Theorem init_mem_characterization_2:
forall p b fd m,
find_funct_ptr (
globalenv p)
b =
Some fd ->
init_mem p =
Some m ->
Mem.perm m b 0
Cur Nonempty
/\ (
forall ofs k p,
Mem.perm m b ofs k p ->
ofs = 0 /\
perm_order Nonempty p).
Proof.
Compatibility with memory injections
Section INITMEM_INJ.
Variable ge:
t.
Variable thr:
block.
Hypothesis symb_inject:
forall id b,
find_symbol ge id =
Some b ->
Plt b thr.
Lemma store_zeros_neutral:
forall m b p n m',
Mem.inject_neutral thr m ->
Plt b thr ->
store_zeros m b p n =
Some m' ->
Mem.inject_neutral thr m'.
Proof.
Lemma store_init_data_neutral:
forall m b p id m',
Mem.inject_neutral thr m ->
Plt b thr ->
store_init_data ge m b p id =
Some m' ->
Mem.inject_neutral thr m'.
Proof.
Lemma store_init_data_list_neutral:
forall b idl m p m',
Mem.inject_neutral thr m ->
Plt b thr ->
store_init_data_list ge m b p idl =
Some m' ->
Mem.inject_neutral thr m'.
Proof.
Lemma alloc_global_neutral:
forall idg m m',
alloc_global ge m idg =
Some m' ->
Mem.inject_neutral thr m ->
Plt (
Mem.nextblock m)
thr ->
Mem.inject_neutral thr m'.
Proof.
Remark advance_next_le:
forall gl x,
Ple x (
advance_next gl x).
Proof.
Lemma alloc_globals_neutral:
forall gl m m',
alloc_globals ge m gl =
Some m' ->
Mem.inject_neutral thr m ->
Ple (
Mem.nextblock m')
thr ->
Mem.inject_neutral thr m'.
Proof.
End INITMEM_INJ.
Theorem initmem_inject:
forall p m,
init_mem p =
Some m ->
Mem.inject (
Mem.flat_inj (
Mem.nextblock m))
m m.
Proof.
Section INITMEM_AUGMENT_INJ.
Variable ge:
t.
Variable thr:
block.
Lemma store_zeros_augment:
forall m1 m2 b p n m2',
Mem.inject (
Mem.flat_inj thr)
m1 m2 ->
Ple thr b ->
store_zeros m2 b p n =
Some m2' ->
Mem.inject (
Mem.flat_inj thr)
m1 m2'.
Proof.
Lemma store_init_data_augment:
forall m1 m2 b p id m2',
Mem.inject (
Mem.flat_inj thr)
m1 m2 ->
Ple thr b ->
store_init_data ge m2 b p id =
Some m2' ->
Mem.inject (
Mem.flat_inj thr)
m1 m2'.
Proof.
Lemma store_init_data_list_augment:
forall b idl m1 m2 p m2',
Mem.inject (
Mem.flat_inj thr)
m1 m2 ->
Ple thr b ->
store_init_data_list ge m2 b p idl =
Some m2' ->
Mem.inject (
Mem.flat_inj thr)
m1 m2'.
Proof.
induction idl;
simpl.
intros;
congruence.
intros until m2';
intros INJ FB.
caseEq (
store_init_data ge m2 b p a);
try congruence.
intros.
eapply IHidl.
eapply store_init_data_augment;
eauto.
auto.
eauto.
Qed.
Lemma alloc_global_augment:
forall idg m1 m2 m2',
alloc_global ge m2 idg =
Some m2' ->
Mem.inject (
Mem.flat_inj thr)
m1 m2 ->
Ple thr (
Mem.nextblock m2) ->
Mem.inject (
Mem.flat_inj thr)
m1 m2'.
Proof.
Lemma alloc_globals_augment:
forall gl m1 m2 m2',
alloc_globals ge m2 gl =
Some m2' ->
Mem.inject (
Mem.flat_inj thr)
m1 m2 ->
Ple thr (
Mem.nextblock m2) ->
Mem.inject (
Mem.flat_inj thr)
m1 m2'.
Proof.
End INITMEM_AUGMENT_INJ.
End GENV.
Commutation with program transformations
Commutation with matching between programs.
Section MATCH_PROGRAMS.
Variables A B V W:
Type.
Variable match_fun:
A ->
B ->
Prop.
Variable match_varinfo:
V ->
W ->
Prop.
Inductive match_globvar:
globvar V ->
globvar W ->
Prop :=
|
match_globvar_intro:
forall info1 info2 init ro vo,
match_varinfo info1 info2 ->
match_globvar (
mkglobvar info1 init ro vo) (
mkglobvar info2 init ro vo).
Record match_genvs (
new_globs :
list (
ident *
globdef B W))
(
ge1:
t A V) (
ge2:
t B W):
Prop := {
mge_next:
genv_next ge2 =
advance_next new_globs (
genv_next ge1);
mge_symb:
forall id, ~
In id (
map fst new_globs) ->
PTree.get id (
genv_symb ge2) =
PTree.get id (
genv_symb ge1);
mge_funs:
forall b f,
PTree.get b (
genv_funs ge1) =
Some f ->
exists tf,
PTree.get b (
genv_funs ge2) =
Some tf /\
match_fun f tf;
mge_rev_funs:
forall b tf,
PTree.get b (
genv_funs ge2) =
Some tf ->
if plt b (
genv_next ge1)
then
exists f,
PTree.get b (
genv_funs ge1) =
Some f /\
match_fun f tf
else
In (
Gfun tf) (
map snd new_globs);
mge_vars:
forall b v,
PTree.get b (
genv_vars ge1) =
Some v ->
exists tv,
PTree.get b (
genv_vars ge2) =
Some tv /\
match_globvar v tv;
mge_rev_vars:
forall b tv,
PTree.get b (
genv_vars ge2) =
Some tv ->
if plt b (
genv_next ge1)
then
exists v,
PTree.get b (
genv_vars ge1) =
Some v /\
match_globvar v tv
else
In (
Gvar tv) (
map snd new_globs)
}.
Lemma add_global_match:
forall ge1 ge2 idg1 idg2,
match_genvs nil ge1 ge2 ->
match_globdef match_fun match_varinfo idg1 idg2 ->
match_genvs nil (
add_global ge1 idg1) (
add_global ge2 idg2).
Proof.
Lemma add_globals_match:
forall gl1 gl2,
list_forall2 (
match_globdef match_fun match_varinfo)
gl1 gl2 ->
forall ge1 ge2,
match_genvs nil ge1 ge2 ->
match_genvs nil (
add_globals ge1 gl1) (
add_globals ge2 gl2).
Proof.
induction 1;
intros;
simpl.
auto.
apply IHlist_forall2.
apply add_global_match;
auto.
Qed.
Lemma add_global_augment_match:
forall new_globs ge1 ge2 idg,
match_genvs new_globs ge1 ge2 ->
match_genvs (
new_globs ++ (
idg ::
nil))
ge1 (
add_global ge2 idg).
Proof.
Lemma add_globals_augment_match:
forall gl new_globs ge1 ge2,
match_genvs new_globs ge1 ge2 ->
match_genvs (
new_globs ++
gl)
ge1 (
add_globals ge2 gl).
Proof.
Variable new_globs :
list (
ident *
globdef B W).
Variable new_main :
ident.
Variable p:
program A V.
Variable p':
program B W.
Hypothesis progmatch:
match_program match_fun match_varinfo new_globs new_main p p'.
Lemma globalenvs_match:
match_genvs new_globs (
globalenv p) (
globalenv p').
Proof.
Theorem find_funct_ptr_match:
forall (
b :
block) (
f :
A),
find_funct_ptr (
globalenv p)
b =
Some f ->
exists tf :
B,
find_funct_ptr (
globalenv p')
b =
Some tf /\
match_fun f tf.
Proof (
mge_funs globalenvs_match).
Theorem find_funct_ptr_rev_match:
forall (
b :
block) (
tf :
B),
find_funct_ptr (
globalenv p')
b =
Some tf ->
if plt b (
genv_next (
globalenv p))
then
exists f,
find_funct_ptr (
globalenv p)
b =
Some f /\
match_fun f tf
else
In (
Gfun tf) (
map snd new_globs).
Proof (
mge_rev_funs globalenvs_match).
Theorem find_funct_match:
forall (
v :
val) (
f :
A),
find_funct (
globalenv p)
v =
Some f ->
exists tf :
B,
find_funct (
globalenv p')
v =
Some tf /\
match_fun f tf.
Proof.
Theorem find_funct_rev_match:
forall (
v :
val) (
tf :
B),
find_funct (
globalenv p')
v =
Some tf ->
(
exists f,
find_funct (
globalenv p)
v =
Some f /\
match_fun f tf)
\/ (
In (
Gfun tf) (
map snd new_globs)).
Proof.
Theorem find_var_info_match:
forall (
b :
block) (
v :
globvar V),
find_var_info (
globalenv p)
b =
Some v ->
exists tv,
find_var_info (
globalenv p')
b =
Some tv /\
match_globvar v tv.
Proof (
mge_vars globalenvs_match).
Theorem find_var_info_rev_match:
forall (
b :
block) (
tv :
globvar W),
find_var_info (
globalenv p')
b =
Some tv ->
if plt b (
genv_next (
globalenv p))
then
exists v,
find_var_info (
globalenv p)
b =
Some v /\
match_globvar v tv
else
In (
Gvar tv) (
map snd new_globs).
Proof (
mge_rev_vars globalenvs_match).
Theorem find_symbol_match:
forall (
s :
ident),
~
In s (
map fst new_globs) ->
find_symbol (
globalenv p')
s =
find_symbol (
globalenv p)
s.
Proof.
Theorem public_symbol_match:
forall (
s :
ident),
~
In s (
map fst new_globs) ->
public_symbol (
globalenv p')
s =
public_symbol (
globalenv p)
s.
Proof.
Hypothesis new_ids_fresh:
forall s,
In s (
prog_defs_names p) ->
In s (
map fst new_globs) ->
False.
Hypothesis new_ids_unique:
list_norepet (
map fst new_globs).
Lemma store_init_data_list_match:
forall idl m b ofs m',
store_init_data_list (
globalenv p)
m b ofs idl =
Some m' ->
store_init_data_list (
globalenv p')
m b ofs idl =
Some m'.
Proof.
Lemma alloc_globals_match:
forall gl1 gl2,
list_forall2 (
match_globdef match_fun match_varinfo)
gl1 gl2 ->
forall m m',
alloc_globals (
globalenv p)
m gl1 =
Some m' ->
alloc_globals (
globalenv p')
m gl2 =
Some m'.
Proof.
Theorem init_mem_match:
forall m,
init_mem p =
Some m ->
init_mem p' =
alloc_globals (
globalenv p')
m new_globs.
Proof.
Theorem find_new_funct_ptr_match:
forall id f,
In (
id,
Gfun f)
new_globs ->
exists b,
find_symbol (
globalenv p')
id =
Some b
/\
find_funct_ptr (
globalenv p')
b =
Some f.
Proof.
Theorem find_new_var_match:
forall id v,
In (
id,
Gvar v)
new_globs ->
exists b,
find_symbol (
globalenv p')
id =
Some b
/\
find_var_info (
globalenv p')
b =
Some v.
Proof.
End MATCH_PROGRAMS.
Section TRANSF_PROGRAM_AUGMENT.
Variable A B V W:
Type.
Variable transf_fun:
A ->
res B.
Variable transf_var:
V ->
res W.
Variable new_globs :
list (
ident *
globdef B W).
Variable new_main :
ident.
Variable p:
program A V.
Variable p':
program B W.
Hypothesis transf_OK:
transform_partial_augment_program transf_fun transf_var new_globs new_main p =
OK p'.
Let prog_match:
match_program
(
fun fd tfd =>
transf_fun fd =
OK tfd)
(
fun info tinfo =>
transf_var info =
OK tinfo)
new_globs new_main
p p'.
Proof.
Theorem find_funct_ptr_transf_augment:
forall (
b:
block) (
f:
A),
find_funct_ptr (
globalenv p)
b =
Some f ->
exists f',
find_funct_ptr (
globalenv p')
b =
Some f' /\
transf_fun f =
OK f'.
Proof.
Theorem find_funct_ptr_rev_transf_augment:
forall (
b:
block) (
tf:
B),
find_funct_ptr (
globalenv p')
b =
Some tf ->
if plt b (
genv_next (
globalenv p))
then
(
exists f,
find_funct_ptr (
globalenv p)
b =
Some f /\
transf_fun f =
OK tf)
else
In (
Gfun tf) (
map snd new_globs).
Proof.
Theorem find_funct_transf_augment:
forall (
v:
val) (
f:
A),
find_funct (
globalenv p)
v =
Some f ->
exists f',
find_funct (
globalenv p')
v =
Some f' /\
transf_fun f =
OK f'.
Proof.
Theorem find_funct_rev_transf_augment:
forall (
v:
val) (
tf:
B),
find_funct (
globalenv p')
v =
Some tf ->
(
exists f,
find_funct (
globalenv p)
v =
Some f /\
transf_fun f =
OK tf) \/
In (
Gfun tf) (
map snd new_globs).
Proof.
Theorem find_var_info_transf_augment:
forall (
b:
block) (
v:
globvar V),
find_var_info (
globalenv p)
b =
Some v ->
exists v',
find_var_info (
globalenv p')
b =
Some v' /\
transf_globvar transf_var v =
OK v'.
Proof.
Theorem find_var_info_rev_transf_augment:
forall (
b:
block) (
v':
globvar W),
find_var_info (
globalenv p')
b =
Some v' ->
if plt b (
genv_next (
globalenv p))
then
(
exists v,
find_var_info (
globalenv p)
b =
Some v /\
transf_globvar transf_var v =
OK v')
else
(
In (
Gvar v') (
map snd new_globs)).
Proof.
Theorem find_symbol_transf_augment:
forall (
s:
ident),
~
In s (
map fst new_globs) ->
find_symbol (
globalenv p')
s =
find_symbol (
globalenv p)
s.
Proof.
Theorem public_symbol_transf_augment:
forall (
s:
ident),
~
In s (
map fst new_globs) ->
public_symbol (
globalenv p')
s =
public_symbol (
globalenv p)
s.
Proof.
Hypothesis new_ids_fresh:
forall s,
In s (
prog_defs_names p) ->
In s (
map fst new_globs) ->
False.
Hypothesis new_ids_unique:
list_norepet (
map fst new_globs).
Theorem init_mem_transf_augment:
forall m,
init_mem p =
Some m ->
init_mem p' =
alloc_globals (
globalenv p')
m new_globs.
Proof.
Theorem init_mem_inject_transf_augment:
forall m,
init_mem p =
Some m ->
forall m',
init_mem p' =
Some m' ->
Mem.inject (
Mem.flat_inj (
Mem.nextblock m))
m m'.
Proof.
Theorem find_new_funct_ptr_exists:
forall id f,
In (
id,
Gfun f)
new_globs ->
exists b,
find_symbol (
globalenv p')
id =
Some b
/\
find_funct_ptr (
globalenv p')
b =
Some f.
Proof.
Theorem find_new_var_exists:
forall id gv,
In (
id,
Gvar gv)
new_globs ->
exists b,
find_symbol (
globalenv p')
id =
Some b
/\
find_var_info (
globalenv p')
b =
Some gv.
Proof.
End TRANSF_PROGRAM_AUGMENT.
Section TRANSF_PROGRAM_PARTIAL2.
Variable A B V W:
Type.
Variable transf_fun:
A ->
res B.
Variable transf_var:
V ->
res W.
Variable p:
program A V.
Variable p':
program B W.
Hypothesis transf_OK:
transform_partial_program2 transf_fun transf_var p =
OK p'.
Remark transf_augment_OK:
transform_partial_augment_program transf_fun transf_var nil p.(
prog_main)
p =
OK p'.
Proof.
Theorem find_funct_ptr_transf_partial2:
forall (
b:
block) (
f:
A),
find_funct_ptr (
globalenv p)
b =
Some f ->
exists f',
find_funct_ptr (
globalenv p')
b =
Some f' /\
transf_fun f =
OK f'.
Proof.
Theorem find_funct_ptr_rev_transf_partial2:
forall (
b:
block) (
tf:
B),
find_funct_ptr (
globalenv p')
b =
Some tf ->
exists f,
find_funct_ptr (
globalenv p)
b =
Some f /\
transf_fun f =
OK tf.
Proof.
Theorem find_funct_transf_partial2:
forall (
v:
val) (
f:
A),
find_funct (
globalenv p)
v =
Some f ->
exists f',
find_funct (
globalenv p')
v =
Some f' /\
transf_fun f =
OK f'.
Proof.
Theorem find_funct_rev_transf_partial2:
forall (
v:
val) (
tf:
B),
find_funct (
globalenv p')
v =
Some tf ->
exists f,
find_funct (
globalenv p)
v =
Some f /\
transf_fun f =
OK tf.
Proof.
Theorem find_var_info_transf_partial2:
forall (
b:
block) (
v:
globvar V),
find_var_info (
globalenv p)
b =
Some v ->
exists v',
find_var_info (
globalenv p')
b =
Some v' /\
transf_globvar transf_var v =
OK v'.
Proof.
Theorem find_var_info_rev_transf_partial2:
forall (
b:
block) (
v':
globvar W),
find_var_info (
globalenv p')
b =
Some v' ->
exists v,
find_var_info (
globalenv p)
b =
Some v /\
transf_globvar transf_var v =
OK v'.
Proof.
Theorem find_symbol_transf_partial2:
forall (
s:
ident),
find_symbol (
globalenv p')
s =
find_symbol (
globalenv p)
s.
Proof.
Theorem public_symbol_transf_partial2:
forall (
s:
ident),
public_symbol (
globalenv p')
s =
public_symbol (
globalenv p)
s.
Proof.
Theorem block_is_volatile_transf_partial2:
forall (
b:
block),
block_is_volatile (
globalenv p')
b =
block_is_volatile (
globalenv p)
b.
Proof.
Theorem init_mem_transf_partial2:
forall m,
init_mem p =
Some m ->
init_mem p' =
Some m.
Proof.
End TRANSF_PROGRAM_PARTIAL2.
Section TRANSF_PROGRAM_PARTIAL.
Variable A B V:
Type.
Variable transf:
A ->
res B.
Variable p:
program A V.
Variable p':
program B V.
Hypothesis transf_OK:
transform_partial_program transf p =
OK p'.
Theorem find_funct_ptr_transf_partial:
forall (
b:
block) (
f:
A),
find_funct_ptr (
globalenv p)
b =
Some f ->
exists f',
find_funct_ptr (
globalenv p')
b =
Some f' /\
transf f =
OK f'.
Proof.
Theorem find_funct_ptr_rev_transf_partial:
forall (
b:
block) (
tf:
B),
find_funct_ptr (
globalenv p')
b =
Some tf ->
exists f,
find_funct_ptr (
globalenv p)
b =
Some f /\
transf f =
OK tf.
Proof.
Theorem find_funct_transf_partial:
forall (
v:
val) (
f:
A),
find_funct (
globalenv p)
v =
Some f ->
exists f',
find_funct (
globalenv p')
v =
Some f' /\
transf f =
OK f'.
Proof.
Theorem find_funct_rev_transf_partial:
forall (
v:
val) (
tf:
B),
find_funct (
globalenv p')
v =
Some tf ->
exists f,
find_funct (
globalenv p)
v =
Some f /\
transf f =
OK tf.
Proof.
Theorem find_symbol_transf_partial:
forall (
s:
ident),
find_symbol (
globalenv p')
s =
find_symbol (
globalenv p)
s.
Proof.
Theorem public_symbol_transf_partial:
forall (
s:
ident),
public_symbol (
globalenv p')
s =
public_symbol (
globalenv p)
s.
Proof.
Theorem find_var_info_transf_partial:
forall (
b:
block),
find_var_info (
globalenv p')
b =
find_var_info (
globalenv p)
b.
Proof.
Theorem block_is_volatile_transf_partial:
forall (
b:
block),
block_is_volatile (
globalenv p')
b =
block_is_volatile (
globalenv p)
b.
Proof.
Theorem init_mem_transf_partial:
forall m,
init_mem p =
Some m ->
init_mem p' =
Some m.
Proof.
End TRANSF_PROGRAM_PARTIAL.
Section TRANSF_PROGRAM.
Variable A B V:
Type.
Variable transf:
A ->
B.
Variable p:
program A V.
Let tp :=
transform_program transf p.
Remark transf_OK:
transform_partial_program (
fun x =>
OK (
transf x))
p =
OK tp.
Proof.
Theorem find_funct_ptr_transf:
forall (
b:
block) (
f:
A),
find_funct_ptr (
globalenv p)
b =
Some f ->
find_funct_ptr (
globalenv tp)
b =
Some (
transf f).
Proof.
Theorem find_funct_ptr_rev_transf:
forall (
b:
block) (
tf:
B),
find_funct_ptr (
globalenv tp)
b =
Some tf ->
exists f,
find_funct_ptr (
globalenv p)
b =
Some f /\
transf f =
tf.
Proof.
Theorem find_funct_transf:
forall (
v:
val) (
f:
A),
find_funct (
globalenv p)
v =
Some f ->
find_funct (
globalenv tp)
v =
Some (
transf f).
Proof.
Theorem find_funct_rev_transf:
forall (
v:
val) (
tf:
B),
find_funct (
globalenv tp)
v =
Some tf ->
exists f,
find_funct (
globalenv p)
v =
Some f /\
transf f =
tf.
Proof.
Theorem find_symbol_transf:
forall (
s:
ident),
find_symbol (
globalenv tp)
s =
find_symbol (
globalenv p)
s.
Proof.
Theorem public_symbol_transf:
forall (
s:
ident),
public_symbol (
globalenv tp)
s =
public_symbol (
globalenv p)
s.
Proof.
Theorem find_var_info_transf:
forall (
b:
block),
find_var_info (
globalenv tp)
b =
find_var_info (
globalenv p)
b.
Proof.
Theorem block_is_volatile_transf:
forall (
b:
block),
block_is_volatile (
globalenv tp)
b =
block_is_volatile (
globalenv p)
b.
Proof.
Theorem init_mem_transf:
forall m,
init_mem p =
Some m ->
init_mem tp =
Some m.
Proof.
End TRANSF_PROGRAM.
End Genv.
Coercion Genv.to_senv:
Genv.t >->
Senv.t.