Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
FP
Stacked Borrows Coq
Commits
246061ef
Commit
246061ef
authored
Jul 08, 2019
by
Hai Dang
Browse files
deref/ref take results
parent
2f224774
Changes
6
Hide whitespace changes
Inline
Side-by-side
theories/lang/steps_inversion.v
View file @
246061ef
...
...
@@ -474,16 +474,18 @@ Proof.
-
by
exists
(
Ki
::
K
'
).
Qed
.
Lemma
tstep_ref_inv
l
tg
T
e
'
σ
σ'
(
STEP
:
((
&
(
Place
l
tg
T
)
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
e
'
=
#[
ScPtr
l
tg
]
%
E
∧
σ'
=
σ
∧
is_Some
(
σ
.(
shp
)
!!
l
).
Lemma
tstep_ref_inv
(
pl
:
result
)
e
'
σ
σ'
(
STEP
:
((
&
pl
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
l
tg
T
,
pl
=
PlaceR
l
tg
T
∧
e
'
=
#[
ScPtr
l
tg
]
%
E
∧
σ'
=
σ
∧
is_Some
(
σ
.(
shp
)
!!
l
).
Proof
.
inv_tstep
.
symmetry
in
Eq
.
destruct
(
fill_ref_decompose
_
_
_
Eq
)
as
[[]
|
[
K
'
[
?
Eq
'
]]];
subst
.
-
clear
Eq
.
simpl
in
HS
.
by
inv_head_step
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
have
Eq1
:=
to_of_result
pl
.
rewrite
-
H
/
to_result
in
Eq1
.
simplify_eq
.
naive_solver
.
-
apply
result_head_stuck
,
(
fill_not_result
_
K
'
)
in
HS
.
by
rewrite
Eq
'
in
HS
.
by
rewrite
Eq
'
to_of_result
in
HS
.
Qed
.
(
**
Deref
*
)
...
...
@@ -498,17 +500,19 @@ Proof.
-
by
exists
(
Ki
::
K
'
).
Qed
.
Lemma
tstep_deref_inv
l
tg
T
e
'
σ
σ'
(
STEP
:
((
Deref
#[
ScPtr
l
tg
]
T
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
e
'
=
Place
l
tg
T
∧
σ'
=
σ
∧
Lemma
tstep_deref_inv
(
rf
:
result
)
T
e
'
σ
σ'
(
STEP
:
((
Deref
rf
T
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
l
tg
,
rf
=
(
ValR
[
ScPtr
l
tg
])
%
R
∧
e
'
=
Place
l
tg
T
∧
σ'
=
σ
∧
(
∀
(
i
:
nat
),
(
i
<
tsize
T
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
.(
shp
)).
Proof
.
inv_tstep
.
symmetry
in
Eq
.
destruct
(
fill_deref_decompose
_
_
_
_
Eq
)
as
[[]
|
[
K
'
[
?
Eq
'
]]];
subst
.
-
clear
Eq
.
simpl
in
HS
.
by
inv_head_step
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
have
Eq1
:=
to_of_result
rf
.
rewrite
-
H0
/
to_result
in
Eq1
.
simplify_eq
.
naive_solver
.
-
apply
result_head_stuck
,
(
fill_not_result
_
K
'
)
in
HS
.
by
rewrite
Eq
'
in
HS
.
by
rewrite
Eq
'
to_of_result
in
HS
.
Qed
.
(
**
Call
*
)
...
...
@@ -728,17 +732,21 @@ Proof.
-
subst
K
.
by
exists
(
Ki
::
K0
).
Qed
.
Lemma
tstep_copy_inv
l
tg
T
e
'
σ
σ'
(
STEP
:
(
Copy
(
Place
l
tg
T
),
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
v
α'
,
e
'
=
Val
v
∧
read_mem
l
(
tsize
T
)
σ
.(
shp
)
=
Some
v
∧
Lemma
tstep_copy_inv
(
pl
:
result
)
e
'
σ
σ'
(
STEP
:
(
Copy
pl
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
l
tg
T
v
α'
,
pl
=
PlaceR
l
tg
T
∧
e
'
=
Val
v
∧
read_mem
l
(
tsize
T
)
σ
.(
shp
)
=
Some
v
∧
memory_read
σ
.(
sst
)
σ
.(
scs
)
l
tg
(
tsize
T
)
=
Some
α'
∧
σ'
=
mkState
σ
.(
shp
)
α'
σ
.(
scs
)
σ
.(
snp
)
σ
.(
snc
).
Proof
.
inv_tstep
.
symmetry
in
Eq
.
destruct
(
fill_copy_decompose
_
_
_
Eq
)
as
[[]
|
[
K
'
[
?
Eq
'
]]];
subst
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
naive_solver
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
have
Eq1
:=
to_of_result
pl
.
rewrite
-
H0
/
to_result
in
Eq1
.
simplify_eq
.
naive_solver
.
-
exfalso
.
apply
val_head_stuck
in
HS
.
destruct
(
fill_val
K
'
e1
'
)
as
[
?
Eq1
'
].
+
rewrite
/=
Eq
'
.
by
eexists
.
+
rewrite
/=
Eq
'
to_of_result
.
by
eexists
.
+
by
rewrite
Eq1
'
in
HS
.
Qed
.
...
...
@@ -776,9 +784,12 @@ Proof.
-
subst
K
.
right
.
by
exists
r1
,
(
Ki
::
K
'
).
Qed
.
Lemma
tstep_write_inv
l
tg
T
v
e
'
σ
σ'
(
STEP
:
((
Place
l
tg
T
<-
#
v
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
α'
,
e
'
=
(#[
☠
]
%
V
)
∧
Lemma
tstep_write_inv
(
pl
r
:
result
)
e
'
σ
σ'
(
STEP
:
((
pl
<-
r
)
%
E
,
σ
)
~{
fns
}~>
(
e
'
,
σ'
))
:
∃
l
tg
T
v
α'
,
pl
=
PlaceR
l
tg
T
∧
r
=
ValR
v
∧
e
'
=
(#[
☠
]
%
V
)
∧
memory_written
σ
.(
sst
)
σ
.(
scs
)
l
tg
(
tsize
T
)
=
Some
α'
∧
(
∀
(
i
:
nat
),
(
i
<
length
v
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
.(
shp
))
∧
(
v
<<
t
σ
.(
snp
))
∧
(
length
v
=
tsize
T
)
∧
...
...
@@ -787,12 +798,15 @@ Proof.
inv_tstep
.
symmetry
in
Eq
.
destruct
(
fill_write_decompose
_
_
_
_
Eq
)
as
[[]
|
[[
K
'
[
?
Eq
'
]]
|
[
?
[
K
'
[
?
[
Eq
'
?
]]]]]];
subst
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
naive_solver
.
-
clear
Eq
.
simpl
in
HS
.
inv_head_step
.
have
Eq1
:=
to_of_result
pl
.
rewrite
-
H0
/
to_result
in
Eq1
.
have
Eq2
:=
to_of_result
r
.
rewrite
-
H1
/
to_result
in
Eq2
.
simplify_eq
.
naive_solver
.
-
exfalso
.
apply
val_head_stuck
in
HS
.
destruct
(
fill_val
K
'
e1
'
)
as
[
?
Eq1
'
].
+
rewrite
/=
Eq
'
.
by
eexists
.
+
rewrite
/=
Eq
'
to_of_result
.
by
eexists
.
+
by
rewrite
Eq1
'
in
HS
.
-
exfalso
.
apply
val_head_stuck
in
HS
.
destruct
(
fill_val
K
'
e1
'
)
as
[
?
Eq1
'
].
+
rewrite
/=
Eq
'
.
by
eexists
.
+
rewrite
/=
Eq
'
to_of_result
.
by
eexists
.
+
by
rewrite
Eq1
'
in
HS
.
Qed
.
...
...
theories/sim/left_step.v
View file @
246061ef
...
...
@@ -14,8 +14,10 @@ Lemma sim_body_copy_left_1
Proof
.
intros
COND
.
pfold
.
intros
NT
r_f
WSAT
.
edestruct
NT
as
[[]
|
[
es1
[
σ
s1
STEP1
]]];
[
constructor
1
|
done
|
].
destruct
(
tstep_copy_inv
_
_
_
_
_
_
_
STEP1
)
as
(
vs
&
α'
&
?
&
Eqvs
&
READ
&
?
).
subst
es1
σ
s1
.
rewrite
/=
read_mem_equation_1
/=
in
Eqvs
.
destruct
(
tstep_copy_inv
_
(
PlaceR
l
(
Tagged
t
)
int
)
_
_
_
STEP1
)
as
(
l
'
&
t
'
&
T
'
&
vs
&
α'
&
EqH
&
?
&
Eqvs
&
READ
&
?
).
symmetry
in
EqH
.
simplify_eq
.
rewrite
/=
read_mem_equation_1
/=
in
Eqvs
.
destruct
(
σ
s
.(
shp
)
!!
l
)
as
[
s
|
]
eqn
:
Eqs
;
[
|
done
].
simpl
in
Eqvs
.
simplify_eq
.
specialize
(
COND
_
eq_refl
).
...
...
theories/sim/refl.v
View file @
246061ef
...
...
@@ -102,13 +102,14 @@ Proof.
move
=>
Hwf
xs
Hxswf
/=
.
sim_bind
(
subst_map
_
e
)
(
subst_map
_
e
).
eapply
sim_simple_post_mono
,
IHe
;
[
|
by
auto
..].
intros
r
'
n
'
rs
css
'
rt
cst
'
(
->
&
->
&
->
&
Hrel
).
simpl
.
Fail
eapply
sim_simple_deref
.
admi
t
.
have
?:=
(
rrel_eq
_
_
_
Hrel
).
subst
rt
.
eapply
sim_simple_deref
.
intros
.
by
subs
t
.
-
(
*
Ref
*
)
move
=>
Hwf
xs
Hxswf
/=
.
sim_bind
(
subst_map
_
e
)
(
subst_map
_
e
).
eapply
sim_simple_post_mono
,
IHe
;
[
|
by
auto
..].
intros
r
'
n
'
rs
css
'
rt
cst
'
(
->
&
->
&
->
&
Hrel
).
simpl
.
Fail
eapply
sim_simple_ref
.
have
?:=
(
rrel_eq
_
_
_
Hrel
).
subst
rt
.
eapply
sim_simple_ref
.
intros
.
subst
.
admit
.
-
(
*
Copy
*
)
admit
.
-
(
*
Write
*
)
admit
.
...
...
theories/sim/refl_mem_step.v
View file @
246061ef
...
...
@@ -296,8 +296,8 @@ Proof.
{
right
.
destruct
(
NT
(
Copy
(
Place
l
(
Tagged
t
)
Ts
))
σ
s
)
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
done
..
|
].
destruct
(
tstep_copy_inv
_
_
_
_
_
_
_
STEPS
)
as
(
vs
&
α'
&
?
&
Eqvs
&
Eq
α'
&
?
).
s
ubst
es
'
.
destruct
(
tstep_copy_inv
_
(
PlaceR
l
(
Tagged
t
)
Ts
)
_
_
_
STEPS
)
as
(
?&?&?&
vs
&
α'
&
EqH
&
?
&
Eqvs
&
Eq
α'
&
?
).
s
ymmetry
in
EqH
.
simplify_eq
.
destruct
(
read_mem_is_Some
l
(
tsize
Tt
)
σ
t
.(
shp
))
as
[
vt
Eqvt
].
{
intros
m
.
rewrite
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
-
EQS
.
apply
(
read_mem_is_Some
'
l
(
tsize
Ts
)
σ
s
.(
shp
)).
by
eexists
.
}
...
...
@@ -306,8 +306,8 @@ Proof.
exists
(#
vt
)
%
E
,
(
mkState
σ
t
.(
shp
)
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)).
by
eapply
(
head_step_fill_tstep
_
[]),
copy_head_step
'
.
}
constructor
1.
intros
.
destruct
(
tstep_copy_inv
_
_
_
_
_
_
_
STEPT
)
as
(
vt
&
α'
&
?
&
Eqvt
&
Eq
α'
&
?
).
subst
et
'
.
destruct
(
tstep_copy_inv
_
(
PlaceR
l
(
Tagged
t
)
Tt
)
_
_
_
STEPT
)
as
(
?&?&?&
vt
&
α'
&
EqH
&
?
&
Eqvt
&
Eq
α'
&
?
).
symmetry
in
EqH
.
simplify_eq
.
destruct
(
read_mem_is_Some
l
(
tsize
Ts
)
σ
s
.(
shp
))
as
[
vs
Eqvs
].
{
intros
m
.
rewrite
-
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
EQS
.
apply
(
read_mem_is_Some
'
l
(
tsize
Tt
)
σ
t
.(
shp
)).
by
eexists
.
}
...
...
@@ -374,7 +374,7 @@ Proof.
-
by
apply
(
tstep_wf
_
_
_
STEPS
WFS
).
-
by
apply
(
tstep_wf
_
_
_
STEPT
WFT
).
-
done
.
-
intros
t1
k
h
Eqt
.
specialize
(
PINV
t1
k
h
Eqt
)
as
[
Lt
PI
].
subst
σ
t
'
.
simpl
.
-
intros
t1
k
h
Eqt
.
specialize
(
PINV
t1
k
h
Eqt
)
as
[
Lt
PI
].
simpl
.
split
;
[
done
|
].
intros
l
'
s
'
Eqk
'
.
specialize
(
PI
_
_
Eqk
'
)
as
[
?
PI
].
split
;
[
done
|
].
intros
stk
'
Eqstk
'
.
...
...
@@ -394,7 +394,7 @@ Proof.
destruct
k
.
+
eapply
access1_head_preserving
;
eauto
.
+
eapply
access1_active_SRO_preserving
;
eauto
.
-
intros
c
cs
Eqc
.
specialize
(
CINV
_
_
Eqc
).
subst
σ
t
'
.
simpl
.
-
intros
c
cs
Eqc
.
specialize
(
CINV
_
_
Eqc
).
simpl
.
clear
-
Eq
α'
CINV
.
destruct
cs
as
[[
T
|
]
|
|
];
[
|
done
..].
destruct
CINV
as
[
IN
CINV
].
split
;
[
done
|
].
intros
t1
InT
.
specialize
(
CINV
_
InT
)
as
[
?
CINV
].
split
;
[
done
|
].
...
...
@@ -403,8 +403,8 @@ Proof.
destruct
(
for_each_access1_active_preserving
_
_
_
_
_
_
_
Eq
α'
_
_
Eqstk
'
)
as
[
stk
[
Eqstk
AS
]].
exists
stk
,
pm
'
.
split
;
last
split
;
[
done
|
|
done
].
by
apply
AS
.
-
subst
σ
t
'
.
rewrite
/
srel
/=
.
by
destruct
SREL
as
(
?&?&?&?&?
).
-
subst
σ
s
'
σ
t
'
.
intros
l1
.
simpl
.
intros
Inl1
.
-
rewrite
/
srel
/=
.
by
destruct
SREL
as
(
?&?&?&?&?
).
-
intros
l1
.
simpl
.
intros
Inl1
.
specialize
(
LINV
_
Inl1
)
as
[
InD1
LINV
].
split
;
[
done
|
].
intros
s
stk
Eqs
.
have
HLF
:
∀
i
,
(
i
<
tsize
Tt
)
%
nat
→
l1
≠
(
l
+
ₗ
i
).
...
...
@@ -417,7 +417,7 @@ Proof.
apply
(
sim_body_result
_
_
_
_
(
ValR
vs
)
(
ValR
vt
)).
intros
.
have
VREL2
:
vrel
(
r
⋅
(
core
(
r_f
⋅
r
)))
vs
vt
.
{
eapply
vrel_mono
;
[
done
|
|
exact
VREL
'
].
apply
cmra_included_r
.
}
subst
σ
t
'
.
apply
POST
;
eauto
.
apply
POST
;
eauto
.
Admitted
.
(
**
Write
*
)
...
...
@@ -510,17 +510,19 @@ Proof.
split
;
[
|
done
|
].
{
right
.
edestruct
NT
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
constructor
1
|
done
|
].
destruct
(
tstep_write_inv
_
_
_
_
_
_
_
_
STEPS
)
as
(
α'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
subst
es
'
.
setoid_rewrite
<-
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
in
EqD
.
destruct
(
tstep_write_inv
_
(
PlaceR
_
_
_
)
(
ValR
_
)
_
_
_
STEPS
)
as
(
?&?&?&?&
α'
&
EqH
&
EqH
'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
symmetry
in
EqH
,
EqH
'
.
simplify_eq
.
setoid_rewrite
<-
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
in
EqD
.
destruct
SREL
as
(
Eqst
&
Eqnp
&
Eqcs
&
Eqnc
&
AREL
).
rewrite
Eqst
Eqcs
in
Eq
α'
.
rewrite
Eqnp
in
IN
.
rewrite
EQL
in
EqD
.
exists
(#[
☠
])
%
V
,
(
mkState
(
write_mem
l
v
σ
t
.(
shp
))
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)).
eapply
(
head_step_fill_tstep
_
[]),
write_head_step
'
;
eauto
.
}
constructor
1.
intros
.
destruct
(
tstep_write_inv
_
_
_
_
_
_
_
_
STEPT
)
as
(
α'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
subst
et
'
.
destruct
(
tstep_write_inv
_
(
PlaceR
_
_
_
)
(
ValR
_
)
_
_
_
STEPT
)
as
(
?&?&?&?&
α'
&
EqH
&
EqH
'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
symmetry
in
EqH
,
EqH
'
.
simplify_eq
.
assert
(
∃
s
,
v
=
[
s
])
as
[
s
?
].
{
rewrite
LenT
in
EQL
.
destruct
v
as
[
|
s
v
];
[
simpl
in
EQL
;
done
|
].
exists
s
.
destruct
v
;
[
done
|
simpl
in
EQL
;
lia
].
}
subst
v
.
...
...
@@ -584,7 +586,7 @@ Proof.
(
<
[
l
:=
Cinl
(
Excl
(
v
'
,
init_stack
(
Tagged
tg
)))]
>
(
r_f
.2
⋅
r
'
.2
))).
{
by
rewrite
lookup_insert
.
}
by
apply
exclusive_local_update
.
-
subst
σ
t
'
.
intros
t
k
h
HL
.
destruct
(
PINV
t
k
h
)
as
[
?
PI
].
-
intros
t
k
h
HL
.
destruct
(
PINV
t
k
h
)
as
[
?
PI
].
{
rewrite
Eqr
.
move
:
HL
.
by
rewrite
4
!
lookup_op
/=
2
!
right_id
.
}
split
;
[
done
|
].
simpl
.
intros
l1
s1
Eqs1
.
specialize
(
PI
l1
s1
Eqs1
)
as
[
HLs1
PI
].
...
...
@@ -595,11 +597,11 @@ Proof.
rewrite
lookup_op
(
lookup_op
(
r_f
.2
⋅
r
'
.2
))
/
init_local_res
/=
2
!
lookup_fmap
.
do
2
rewrite
lookup_insert_ne
//. }
by
setoid_rewrite
lookup_insert_ne
.
-
subst
σ
t
'
.
intros
c
cs
.
simpl
.
rewrite
-
HCEq
.
intros
Eqcm
.
-
intros
c
cs
.
simpl
.
rewrite
-
HCEq
.
intros
Eqcm
.
move
:
CINV
.
rewrite
Eqr
cmra_assoc
=>
CINV
.
specialize
(
CINV
_
_
Eqcm
).
destruct
cs
as
[[]
|
|
];
[
|
done
..].
destruct
CINV
as
[
?
CINV
].
split
;
[
done
|
].
by
setoid_rewrite
<-
HTEq
.
-
subst
σ
t
'
.
destruct
SREL
as
(
?&?&?&?&
REL
).
do
4
(
split
;
[
done
|
]).
-
destruct
SREL
as
(
?&?&?&?&
REL
).
do
4
(
split
;
[
done
|
]).
simpl
.
intros
l1
Inl1
Eq1
.
have
NEql1
:
l1
≠
l
.
{
intros
?
.
subst
l1
.
move
:
Eq1
.
rewrite
lookup_op
HLN
left_id
.
...
...
@@ -619,7 +621,7 @@ Proof.
setoid_rewrite
Eqr
.
setoid_rewrite
cmra_assoc
.
by
setoid_rewrite
<-
HTEq
.
+
right
.
move
:
REL
.
setoid_rewrite
Eqr
.
setoid_rewrite
cmra_assoc
.
rewrite
/
priv_loc
.
by
setoid_rewrite
<-
HTEq
.
-
subst
σ
t
'
.
move
:
LINV
.
rewrite
Eqr
cmra_assoc
.
-
move
:
LINV
.
rewrite
Eqr
cmra_assoc
.
(
*
TODO
:
general
property
of
lmap_inv
w
.
r
.
t
to
separable
resource
*
)
intros
LINV
l1
Inl1
.
have
EqD
'
:
dom
(
gset
loc
)
(
r_f
⋅
r
'
⋅
res_mapsto
l
1
s
(
init_stack
(
Tagged
tg
))).(
rlm
)
...
...
@@ -648,7 +650,7 @@ Proof.
by
inversion
1.
}
left
.
eapply
(
sim_body_result
_
_
_
_
(
ValR
[
☠
%
S
])
(
ValR
[
☠
%
S
])).
intros
.
simpl
.
subst
σ
t
'
.
by
apply
POST
.
intros
.
simpl
.
by
apply
POST
.
Qed
.
Lemma
sim_body_write_related_values
...
...
@@ -675,9 +677,10 @@ Proof.
split
;
[
|
done
|
].
{
right
.
edestruct
NT
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
constructor
1
|
done
|
].
destruct
(
tstep_write_inv
_
_
_
_
_
_
_
_
STEPS
)
as
(
α'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
subst
es
'
.
setoid_rewrite
<-
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
in
EqD
.
destruct
(
tstep_write_inv
_
(
PlaceR
_
_
_
)
(
ValR
_
)
_
_
_
STEPS
)
as
(
?&?&?&?&
α'
&
EqH
&
EqH
'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
symmetry
in
EqH
,
EqH
'
.
simplify_eq
.
setoid_rewrite
<-
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
in
EqD
.
destruct
SREL
as
(
Eqst
&
Eqnp
&
Eqcs
&
Eqnc
&
AREL
).
rewrite
Eqst
Eqcs
EQS
in
Eq
α'
.
rewrite
-
EQL
in
EQS
.
rewrite
EQS
in
EqD
.
rewrite
Eqnp
in
IN
.
...
...
@@ -685,8 +688,9 @@ Proof.
(
mkState
(
write_mem
l
v
σ
t
.(
shp
))
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)).
by
eapply
(
head_step_fill_tstep
_
[]),
write_head_step
'
.
}
constructor
1.
intros
.
destruct
(
tstep_write_inv
_
_
_
_
_
_
_
_
STEPT
)
as
(
α'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
subst
et
'
.
destruct
(
tstep_write_inv
_
(
PlaceR
_
_
_
)
(
ValR
_
)
_
_
_
STEPT
)
as
(
?&?&?&?&
α'
&
EqH
&
EqH
'
&
?
&
Eq
α'
&
EqD
&
IN
&
EQL
&
?
).
symmetry
in
EqH
,
EqH
'
.
simplify_eq
.
set
σ
s
'
:=
mkState
(
write_mem
l
v
σ
s
.(
shp
))
α'
σ
s
.(
scs
)
σ
s
.(
snp
)
σ
s
.(
snc
).
have
STEPS
:
((
Place
l
(
Tagged
tg
)
Ts
<-
v
)
%
E
,
σ
s
)
~{
fs
}~>
((#[
☠
])
%
V
,
σ
s
'
).
{
setoid_rewrite
(
srel_heap_dom
_
_
_
WFS
WFT
SREL
)
in
EqD
.
...
...
@@ -734,7 +738,7 @@ Proof.
move
:
Eqt
.
rewrite
lookup_op
Eqtg
.
by
move
=>
/
tagKindR_exclusive_2
.
+
right
.
naive_solver
.
}
split
.
{
subst
σ
t
'
.
simpl
.
destruct
CASEt
as
[(
?&?&?&?
Eqh
)
|
[
Eqh
NEQ
]].
{
simpl
.
destruct
CASEt
as
[(
?&?&?&?
Eqh
)
|
[
Eqh
NEQ
]].
-
subst
t
k
k0
.
apply
(
PINV
tg
tkUnique
h0
).
by
rewrite
HL2
.
-
move
:
Eqh
.
apply
PINV
.
}
intros
l
'
s
'
Eqk
'
.
split
.
...
...
@@ -752,7 +756,7 @@ Proof.
destruct
(
PI
l
'
ss0
)
as
[
?
_
];
[
|
done
].
by
rewrite
Eqs0
Eqss0
.
-
specialize
(
PINV
_
_
_
Eqh
)
as
[
?
PINV
].
specialize
(
PINV
_
_
Eqk
'
)
as
[
EQ
_
].
rewrite
/
r
'
/=
.
by
destruct
k0
.
}
intros
stk
'
.
subst
σ
t
'
.
simpl
.
intros
stk
'
.
simpl
.
destruct
(
write_mem_lookup_case
l
v
σ
t
.(
shp
)
l
'
)
as
[[
i
[
Lti
[
Eqi
Eqmi
]]]
|
[
NEql
Eql
]];
last
first
.
{
(
*
l
'
is
NOT
written
to
*
)
...
...
@@ -829,7 +833,7 @@ Proof.
intros
c
cs
Eqc
'
.
have
Eqc
:
(
r_f
⋅
r
).(
rcm
)
!!
c
≡
Some
cs
.
{
move
:
Eqc
'
.
rewrite
/
r
'
.
by
destruct
k0
.
}
specialize
(
CINV
_
_
Eqc
).
subst
σ
t
'
.
simpl
.
specialize
(
CINV
_
_
Eqc
).
simpl
.
clear
-
Eq
α'
CINV
Eqtg
VALID
HL
HL2
.
destruct
cs
as
[[
T
|
]
|
|
];
[
|
done
..].
destruct
CINV
as
[
IN
CINV
].
split
;
[
done
|
].
intros
t
InT
.
specialize
(
CINV
_
InT
)
as
[
?
CINV
].
split
;
[
done
|
].
...
...
@@ -860,7 +864,7 @@ Proof.
as
[
stk
[
Eqstk
AS
]].
exists
stk
,
pm
'
.
split
;
last
split
;
[
done
|
by
apply
AS
|
done
].
-
(
*
srel
*
)
subst
σ
t
'
.
rewrite
/
srel
/=
.
destruct
SREL
as
(
?&?&?&?&
Eq
).
rewrite
/
srel
/=
.
destruct
SREL
as
(
?&?&?&?&
Eq
).
repeat
split
;
[
done
..
|
].
intros
l1
InD1
Eq1
.
destruct
(
write_mem_lookup
l
v
σ
s
.(
shp
))
as
[
EqN
EqO
].
rewrite
/
r
'
.
...
...
@@ -934,8 +938,8 @@ Proof.
{
exists
h
.
rewrite
/
rtm
/=
HL
lookup_insert_ne
//. }
-
intros
l
'
.
rewrite
->
Eqrlm
.
setoid_rewrite
Eqrlm
.
intros
InD
.
specialize
(
LINV
_
InD
)
as
[
?
LINV
].
split
.
{
subst
σ
t
'
.
rewrite
/=
write_mem_dom
//. }
intros
s
stk
Eq
.
subst
σ
t
'
.
rewrite
/=
.
split
.
{
rewrite
/=
write_mem_dom
//. }
intros
s
stk
Eq
.
rewrite
/=
.
specialize
(
LINV
_
_
Eq
)
as
(
?&?&?&?
).
destruct
(
write_mem_lookup
l
v
σ
s
.(
shp
))
as
[
_
HLs
].
destruct
(
write_mem_lookup
l
v
σ
t
.(
shp
))
as
[
_
HLt
].
...
...
@@ -948,7 +952,7 @@ Proof.
}
left
.
eapply
(
sim_body_result
fs
ft
r
'
n
(
ValR
[
☠
%
S
])
(
ValR
[
☠
%
S
])).
intros
.
simpl
.
subst
σ
t
'
.
by
apply
POST
.
intros
.
simpl
.
by
apply
POST
.
Qed
.
(
**
Retag
*
)
...
...
theories/sim/refl_pure_step.v
View file @
246061ef
...
...
@@ -186,54 +186,61 @@ Lemma sim_body_let_place fs ft r n x ls lt ts tt tys tyt es2 et2 σs σt Φ :
Proof
.
apply
sim_body_let
;
eauto
.
Qed
.
(
**
Ref
*
)
Lemma
sim_body_ref
fs
ft
r
n
l
tgs
tgt
Ts
Tt
σ
s
σ
t
Φ
:
Φ
r
n
(
ValR
[
ScPtr
l
tgs
])
σ
s
(
ValR
[
ScPtr
l
tgt
])
σ
t
:
Prop
→
r
⊨
{
n
,
fs
,
ft
}
((
&
(
Place
l
tgs
Ts
))
%
E
,
σ
s
)
≥
((
&
(
Place
l
tgt
Tt
))
%
E
,
σ
t
)
:
Φ
.
Lemma
sim_body_ref
fs
ft
r
n
(
pl
:
result
)
σ
s
σ
t
Φ
:
(
∀
l
t
T
,
pl
=
PlaceR
l
t
T
→
Φ
r
n
(
ValR
[
ScPtr
l
t
])
σ
s
(
ValR
[
ScPtr
l
t
])
σ
t
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
((
&
pl
)
%
E
,
σ
s
)
≥
((
&
pl
)
%
E
,
σ
t
)
:
Φ
.
Proof
.
intros
SIM
.
pfold
.
intros
POST
.
pfold
.
intros
NT
r_f
WSAT
.
split
;
[
|
done
|
].
{
right
.
destruct
(
NT
(
&
(
Place
l
tgs
Ts
))
%
E
σ
s
)
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
done
..
|
].
destruct
(
tstep_ref_inv
_
_
_
_
_
_
_
STEPS
)
as
[
?
[
?
IS
]].
subst
es
'
σ
s
'
.
destruct
(
NT
(
&
pl
)
%
E
σ
s
)
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
done
..
|
].
destruct
(
tstep_ref_inv
_
_
_
_
_
STEPS
)
as
(
l
&
tg
&
T
&
?
&
?
&
?
&
IS
).
simplify_eq
.
have
?:
is_Some
(
σ
t
.(
shp
)
!!
l
).
{
clear
-
WSAT
IS
.
move
:
IS
.
by
rewrite
-
2
!
(
elem_of_dom
(
D
:=
gset
loc
))
-
wsat_heap_dom
.
}
exists
#[
ScPtr
l
tg
t
]
%
E
,
σ
t
.
exists
#[
ScPtr
l
tg
]
%
E
,
σ
t
.
eapply
(
head_step_fill_tstep
_
[]).
by
econstructor
;
econstructor
.
}
constructor
1.
intros
.
destruct
(
tstep_ref_inv
_
_
_
_
_
_
_
STEPT
)
as
[
?
[
?
IS
]].
subst
et
'
σ
t
'
.
destruct
(
tstep_ref_inv
_
_
_
_
_
STEPT
)
as
(
l
&
tg
&
T
&
?
&
?
&
?
&
IS
).
simplify_eq
.
have
?:
is_Some
(
σ
s
.(
shp
)
!!
l
).
{
clear
-
WSAT
IS
.
move
:
IS
.
by
rewrite
-
2
!
(
elem_of_dom
(
D
:=
gset
loc
))
wsat_heap_dom
.
}
exists
#[
ScPtr
l
tg
s
]
%
E
,
σ
s
,
r
,
n
.
split
.
exists
#[
ScPtr
l
tg
]
%
E
,
σ
s
,
r
,
n
.
split
.
{
left
.
constructor
1.
eapply
(
head_step_fill_tstep
_
[]).
by
econstructor
;
econstructor
.
}
split
;
[
done
|
].
left
.
by
apply
(
sim_body_result
_
_
_
_
(
ValR
_
)
(
ValR
_
)).
apply
(
sim_body_result
_
_
_
_
(
ValR
_
)
(
ValR
_
)).
intros
.
by
eapply
POST
.
Qed
.
(
**
Deref
*
)
Lemma
sim_body_deref
fs
ft
r
n
l
tgs
tgt
Ts
T
t
σ
s
σ
t
Φ
(
EQS
:
tsize
Ts
=
tsize
Tt
)
:
Φ
r
n
(
PlaceR
l
t
gs
T
s
)
σ
s
(
PlaceR
l
t
gt
T
t
)
σ
t
:
Prop
→
r
⊨
{
n
,
fs
,
ft
}
(
Deref
#[
ScPtr
l
tgs
]
T
s
,
σ
s
)
≥
(
Deref
#[
ScPtr
l
tgt
]
T
t
,
σ
t
)
:
Φ
.
Lemma
sim_body_deref
fs
ft
r
n
(
rf
:
result
)
T
σ
s
σ
t
Φ
:
(
∀
l
t
,
rf
=
ValR
[
ScPtr
l
t
]
→
Φ
r
n
(
PlaceR
l
t
T
)
σ
s
(
PlaceR
l
t
T
)
σ
t
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Deref
rf
T
,
σ
s
)
≥
(
Deref
rf
T
,
σ
t
)
:
Φ
.
Proof
.
intros
SIM
.
pfold
.
intros
POST
.
pfold
.
intros
NT
r_f
WSAT
.
split
;
[
|
done
|
].
{
right
.
destruct
(
NT
(
Deref
#[
ScPtr
l
tgs
]
Ts
)
σ
s
)
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
done
..
|
].
destruct
(
tstep_deref_inv
_
_
_
_
_
_
_
STEPS
)
as
[
?
[
?
IS
]].
subst
es
'
σ
s
'
.
have
?:
(
∀
(
i
:
nat
),
(
i
<
tsize
Tt
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
t
.(
shp
)).
{
clear
-
WSAT
IS
EQS
.
rewrite
-
EQS
.
move
=>
i
/
IS
.
by
rewrite
-
wsat_heap_dom
.
}
exists
(
Place
l
tgt
Tt
),
σ
t
.
destruct
(
NT
(
Deref
rf
T
)
σ
s
)
as
[[]
|
[
es
'
[
σ
s
'
STEPS
]]];
[
done
..
|
].
destruct
(
tstep_deref_inv
_
_
_
_
_
_
STEPS
)
as
(
l
&
t
&
?
&
?
&
?
&
IS
).
subst
.
have
?:
(
∀
(
i
:
nat
),
(
i
<
tsize
T
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
t
.(
shp
)).
{
clear
-
WSAT
IS
.
by
setoid_rewrite
wsat_heap_dom
.
}
exists
(
Place
l
t
T
),
σ
t
.
eapply
(
head_step_fill_tstep
_
[]).
by
econstructor
;
econstructor
.
}
constructor
1.
intros
.
destruct
(
tstep_deref_inv
_
_
_
_
_
_
_
STEPT
)
as
[
?
[
?
IS
]].
subst
et
'
σ
t
'
.
have
?:
(
∀
(
i
:
nat
),
(
i
<
tsize
Ts
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
s
.(
shp
)).
{
clear
-
WSAT
IS
EQS
.
rewrite
EQS
.
move
=>
i
/
IS
.
by
rewrite
wsat_heap_dom
.
}
exists
(
Place
l
tgs
Ts
),
σ
s
,
r
,
n
.
split
.
destruct
(
tstep_deref_inv
_
_
_
_
_
_
STEPT
)
as
(
l
&
t
&
?
&
?
&
?
&
IS
).
subst
.
have
?:
(
∀
(
i
:
nat
),
(
i
<
tsize
T
)
%
nat
→
l
+
ₗ
i
∈
dom
(
gset
loc
)
σ
s
.(
shp
)).
{
clear
-
WSAT
IS
.
by
setoid_rewrite
<-
wsat_heap_dom
.
}
exists
(
Place
l
t
T
),
σ
s
,
r
,
n
.
split
.
{
left
.
constructor
1.
eapply
(
head_step_fill_tstep
_
[]).
by
econstructor
;
econstructor
.
}
split
;
[
done
|
].
left
.
by
apply
(
sim_body_result
_
_
_
_
(
PlaceR
_
_
_
)
(
PlaceR
_
_
_
)).
left
.
apply
(
sim_body_result
_
_
_
_
(
PlaceR
_
_
_
)
(
PlaceR
_
_
_
)).
intros
.
by
eapply
POST
.
Qed
.
theories/sim/simple.v
View file @
246061ef
...
...
@@ -210,16 +210,17 @@ Lemma sim_simple_let_place fs ft r n x ls lt ts tt tys tyt es2 et2 css cst Φ :
r
⊨ˢ
{
n
,
fs
,
ft
}
(
let
:
x
:=
Place
ls
ts
tys
in
es2
,
css
)
≥
((
let
:
x
:=
Place
lt
tt
tyt
in
et2
),
cst
)
:
Φ
.
Proof
.
intros
HH
σ
s
σ
t
<-<-
.
apply
sim_body_let
;
eauto
.
Qed
.
Lemma
sim_simple_ref
fs
ft
r
n
l
tgs
tgt
Ts
Tt
css
cst
Φ
:
Φ
r
n
(
ValR
[
ScPtr
l
tgs
])
css
(
ValR
[
ScPtr
l
tgt
])
cst
→
r
⊨ˢ
{
n
,
fs
,
ft
}
((
&
(
Place
l
tgs
Ts
))
%
E
,
css
)
≥
((
&
(
Place
l
tgt
Tt
))
%
E
,
cst
)
:
Φ
.
Lemma
sim_simple_ref
fs
ft
r
n
(
pl
:
result
)
css
cst
Φ
:
(
∀
l
t
T
,
pl
=
PlaceR
l
t
T
→
Φ
r
n
(
ValR
[
ScPtr
l
t
])
css
(
ValR
[
ScPtr
l
t
])
cst
)
→
r
⊨ˢ
{
n
,
fs
,
ft
}
((
&
pl
)
%
E
,
css
)
≥
((
&
pl
)
%
E
,
cst
)
:
Φ
.
Proof
.
intros
HH
σ
s
σ
t
<-<-
.
apply
sim_body_ref
;
eauto
.
Qed
.
Lemma
sim_simple_deref
fs
ft
r
n
l
tgs
tgt
Ts
Tt
css
cst
Φ
:
tsize
Ts
=
tsize
Tt
→
Φ
r
n
(
PlaceR
l
t
gs
T
s
)
css
(
PlaceR
l
t
gt
T
t
)
cst
→
r
⊨ˢ
{
n
,
fs
,
ft
}
(
Deref
#[
ScPtr
l
tgs
]
T
s
,
css
)
≥
(
Deref
#[
ScPtr
l
tgt
]
T
t
,
cst
)
:
Φ
.
Proof
.
intros
?
HH
σ
s
σ
t
<-<-
.
apply
sim_body_deref
;
eauto
.
Qed
.
Lemma
sim_simple_deref
fs
ft
r
n
(
rf
:
result
)
T
css
cst
Φ
:
(
∀
l
t
,
rf
=
ValR
[
ScPtr
l
t
]
→
Φ
r
n
(
PlaceR
l
t
T
)
css
(
PlaceR
l
t
T
)
cst
)
→
r
⊨ˢ
{
n
,
fs
,
ft
}
(
Deref
rf
T
,
css
)
≥
(
Deref
rf
T
,
cst
)
:
Φ
.
Proof
.
intros
HH
σ
s
σ
t
<-<-
.
apply
sim_body_deref
;
eauto
.
Qed
.
Lemma
sim_simple_var
fs
ft
r
n
css
cst
var
Φ
:
r
⊨ˢ
{
n
,
fs
,
ft
}
(
Var
var
,
css
)
≥
(
Var
var
,
cst
)
:
Φ
.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment