Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Stacked Borrows Coq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
FP
Stacked Borrows Coq
Commits
973be934
Commit
973be934
authored
Jul 09, 2019
by
Ralf Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of stubs for ex1
parent
e1bfea41
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
260 additions
and
50 deletions
+260
-50
theories/lang/notation.v
theories/lang/notation.v
+1
-1
theories/lang/steps_retag.v
theories/lang/steps_retag.v
+2
-0
theories/opt/ex1.v
theories/opt/ex1.v
+43
-6
theories/sim/body.v
theories/sim/body.v
+24
-3
theories/sim/cmra.v
theories/sim/cmra.v
+2
-1
theories/sim/left_step.v
theories/sim/left_step.v
+39
-0
theories/sim/refl.v
theories/sim/refl.v
+1
-1
theories/sim/refl_mem_step.v
theories/sim/refl_mem_step.v
+26
-5
theories/sim/refl_pure_step.v
theories/sim/refl_pure_step.v
+10
-4
theories/sim/right_step.v
theories/sim/right_step.v
+38
-9
theories/sim/simple.v
theories/sim/simple.v
+28
-10
theories/sim/tactics.v
theories/sim/tactics.v
+46
-10
No files found.
theories/lang/notation.v
View file @
973be934
...
...
@@ -53,7 +53,7 @@ Notation "'Box<' T '>'" := (Reference RawPtr T%T)
(
**
Pointer
operations
*
)
Notation
"& e"
:=
(
Ref
e
%
E
)
(
at
level
8
,
format
"& e"
)
:
expr_scope
.
Notation
"*{ T } e"
:=
(
Deref
(
Proj
(
Copy
e
%
E
)
#[
0
]
)
T
%
T
)
Notation
"*{ T } e"
:=
(
Deref
(
Copy
e
%
E
)
T
%
T
)
(
at
level
9
,
format
"*{ T } e"
)
:
expr_scope
.
(
**
Syntax
inspired
by
Coq
/
Ocaml
.
Constructions
with
higher
precedence
come
...
...
theories/lang/steps_retag.v
View file @
973be934
...
...
@@ -6,6 +6,8 @@ Definition tag_in t (stk: stack) :=
∃
pm
opro
,
pm
≠
Disabled
∧
mkItem
pm
(
Tagged
t
)
opro
∈
stk
.
Definition
tag_in_stack
σ
l
t
:=
∃
stk
,
σ
.(
sst
)
!!
l
=
Some
stk
∧
tag_in
t
stk
.
Definition
tag_on_top
σ
t
l
tag
:
Prop
:=
tg
<
$
>
(
σ
t
.(
sst
)
!!
l
)
≫
=
head
=
Some
(
Tagged
tag
).
(
**
Active
protector
preserving
*
)
Definition
active_preserving
(
cids
:
call_id_stack
)
(
stk
stk
'
:
stack
)
:=
...
...
theories/opt/ex1.v
View file @
973be934
From
stbor
.
sim
Require
Import
local
invariant
refl
tactics
simple
program
.
From
stbor
.
sim
Require
Import
local
invariant
refl
tactics
simple
program
refl_step
right_step
left_step
.
Set
Default
Proof
Using
"Type"
.
...
...
@@ -33,16 +33,16 @@ Proof.
simplify_eq
/=
.
(
*
InitCall
*
)
apply
sim_simple_init_call
=>
c
/=
{
css
}
.
(
*
Alloc
*
)
(
*
Alloc
local
*
)
sim_apply
sim_simple_alloc_local
=>
l
t
/=
.
sim_apply
sim_simple_let
=>/=
.
(
*
Write
*
)
(
*
Write
local
*
)
rewrite
(
vrel_eq
_
_
_
AREL
).
sim_apply
sim_simple_write_local
;
[
solve_sim
..
|
].
intros
arg
->
.
simpl
.
sim_apply
sim_simple_let
=>/=
.
apply:
sim_simple_result
.
(
*
Retag
.
*
)
(
*
Retag
local
*
)
sim_apply
sim_simple_let
=>/=
.
destruct
args
as
[
|
args
args
'
];
first
by
inversion
AREL
.
apply
Forall2_cons_inv
in
AREL
as
[
AREL
ATAIL
].
...
...
@@ -55,8 +55,45 @@ Proof.
intros
rf
frs
frt
???
?
_
_
FREL
.
simplify_eq
/=
.
apply:
sim_simple_result
.
simpl
.
sim_apply
sim_simple_let
=>/=
.
(
*
Deref
*
)
(
*
Copy
local
*
)
sim_apply
sim_simple_copy_local
;
[
solve_sim
..
|
].
apply:
sim_simple_result
.
simpl
.
sim_apply
sim_simple_deref
=>
l
'
t
'
?
.
simplify_eq
/=
.
(
*
Write
unique
.
We
need
to
drop
to
complex
mode
,
to
preserve
some
local
state
info
.
*
)
intros
σ
s
σ
t
H
σ
s
H
σ
t
.
sim_apply
sim_body_write_owned
;
[
solve_sim
..
|
].
intros
????
Htop
.
simplify_eq
/=
.
sim_apply
sim_body_let
.
simplify_eq
/=
.
(
*
Copy
local
(
right
)
*
)
sim_apply_r
sim_body_copy_local_r
;
[
solve_sim
..
|
].
apply:
sim_body_result
=>
_.
simpl
.
(
*
Copy
unique
(
right
)
*
)
sim_apply_r
sim_body_deref_r
.
simpl
.
sim_apply_r
sim_body_copy_unique_r
;
[
try
solve_sim
..
|
].
{
subst
σ
t
'
.
admit
.
(
*
show
that
tag_op_top
is
preserved
.
*
)
}
{
rewrite
lookup_insert
.
done
.
}
apply:
sim_body_result
=>
_.
simpl
.
apply:
sim_body_let_r
.
simpl
.
(
*
FIXME
:
figure
out
why
[
sim_apply_r
]
does
the
wrong
thing
here
*
)
(
*
We
can
go
back
to
simple
mode
!
*
)
eapply
sim_simplify
.
{
intros
??????
HH
.
exact
HH
.
}
simplify_eq
/=
.
rewrite
H
σ
s
H
σ
t
.
clear
-
AREL
FREL
LOOK
.
(
*
Call
*
)
sim_apply
(
sim_simple_call
10
[]
[]
ε
);
[
solve_sim
..
|
].
intros
rf
'
frs
'
frt
'
???
?
_
_
FREL
'
.
simplify_eq
/=
.
apply:
sim_simple_result
.
simpl
.
sim_apply
sim_simple_let
=>/=
.
(
*
Copy
local
(
left
).
We
drop
to
complex
just
because
simple
does
not
support
this
yet
.
*
)
intros
σ
s
σ
t
H
σ
s
H
σ
t
.
sim_apply_l
sim_body_copy_local_l
;
[
solve_sim
..
|
].
apply:
sim_body_result
=>
_.
simpl
.
(
*
Copy
unique
(
left
)
*
)
sim_apply_l
sim_body_deref_l
.
simpl
.
sim_apply_l
sim_body_copy_unique_l
;
[
try
solve_sim
..
|
].
{
rewrite
lookup_insert
.
done
.
}
apply:
sim_body_result
=>
_.
simpl
.
apply:
sim_body_result
=>
Hval
.
split
.
-
eexists
.
split
;
first
done
.
admit
.
(
*
end_call_sat
*
)
-
constructor
;
simpl
;
auto
.
Admitted
.
(
**
Top
-
level
theorem
:
Two
programs
that
only
differ
in
the
...
...
theories/sim/body.v
View file @
973be934
...
...
@@ -44,9 +44,10 @@ Proof.
intros
.
eapply
H
Φ
;
done
.
Qed
.
Lemma
sim_body_bind
fs
ft
r
n
(
Ks
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
fs
)))
(
Kt
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
es
et
σ
s
σ
t
Φ
:
Lemma
sim_body_bind
fs
ft
(
Ks
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
fs
)))
es
(
Kt
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
et
r
n
σ
s
σ
t
Φ
:
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
et
,
σ
t
)
:
(
λ
r
'
n
'
es
'
σ
s
'
et
'
σ
t
'
,
r
'
⊨
{
n
'
,
fs
,
ft
}
(
fill
Ks
es
'
,
σ
s
'
)
≥
(
fill
Kt
et
'
,
σ
t
'
)
:
Φ
)
→
...
...
@@ -132,6 +133,26 @@ Proof.
pclearbot
.
right
.
by
apply
CIH
.
}
Qed
.
Lemma
sim_body_bind_r
fs
ft
(
Kt
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
et
r
n
es
σ
s
σ
t
Φ
:
r
⊨
{
n
,
fs
,
ft
}
(#[],
σ
s
)
≥
(
et
,
σ
t
)
:
(
λ
r
'
n
'
_
_
et
'
σ
t
'
,
r
'
⊨
{
n
'
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
fill
Kt
et
'
,
σ
t
'
)
:
Φ
)
→
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
fill
Kt
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_bind_l
fs
ft
(
Ks
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
es
r
n
et
σ
s
σ
t
Φ
:
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(#[],
σ
t
)
:
(
λ
r
'
n
'
es
'
σ
s
'
_
_
,
r
'
⊨
{
n
'
,
fs
,
ft
}
(
fill
Ks
es
'
,
σ
s
'
)
≥
(
et
,
σ
t
)
:
Φ
)
→
r
⊨
{
n
,
fs
,
ft
}
(
fill
Ks
es
,
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_bind_call
r
n
fs
ft
es
σ
s
et
σ
t
(
fns
fnt
:
result
)
(
pres
pret
:
list
result
)
posts
postt
Φ
:
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
et
,
σ
t
)
:
(
λ
r
'
n
'
rs
'
σ
s
'
rt
'
σ
t
'
,
...
...
theories/sim/cmra.v
View file @
973be934
...
...
@@ -26,6 +26,7 @@ Definition cmapUR := gmapUR call_id callStateR.
Definition
to_cmapUR
(
cm
:
cmap
)
:
cmapUR
:=
fmap
to_callStateR
cm
.
Definition
tmap
:=
gmap
ptr_id
(
tag_kind
*
mem
).
Definition
heaplet
:=
gmap
loc
scalar
.
Definition
heapletR
:=
gmapR
loc
(
agreeR
scalarC
).
(
*
ptr_id
⇀
TagKid
x
(
loc
⇀
Ag
(
Scalar
))
*
)
Definition
tmapUR
:=
gmapUR
ptr_id
(
prodR
tagKindR
heapletR
).
...
...
@@ -352,7 +353,7 @@ Proof. intros Eq. rewrite lookup_core Eq /core /= core_id //. Qed.
(
**
Resources
that
we
own
.
*
)
Definition
res_tag
tg
tk
h
:
resUR
:=
Definition
res_tag
tg
tk
(
h
:
heaplet
)
:
resUR
:=
(
{
[
tg
:=
(
to_tagKindR
tk
,
to_agree
<
$
>
h
)]
}
,
ε
,
ε
).
Definition
res_callState
(
c
:
call_id
)
(
cs
:
call_state
)
:
resUR
:=
...
...
theories/sim/left_step.v
View file @
973be934
...
...
@@ -5,6 +5,43 @@ From stbor.sim Require Export instance.
Set
Default
Proof
Using
"Type"
.
Section
left
.
Implicit
Types
Φ
:
resUR
→
nat
→
result
→
state
→
result
→
state
→
Prop
.
Lemma
sim_body_let_l
fs
ft
r
n
x
et
es1
es2
vs1
σ
s
σ
t
Φ
:
IntoResult
es1
vs1
→
r
⊨
{
n
,
fs
,
ft
}
(
subst
'
x
es1
es2
,
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
→
r
⊨
{
n
,
fs
,
ft
}
(
let
:
x
:=
es1
in
es2
,
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_deref_l
fs
ft
r
n
et
(
rt
:
result
)
l
t
T
σ
s
σ
t
Φ
:
IntoResult
et
rt
→
(
Φ
r
n
(
PlaceR
l
t
T
)
σ
s
rt
σ
t
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Deref
#[
ScPtr
l
t
]
T
,
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_copy_local_l
fs
ft
r
r
'
n
l
tg
ty
s
et
σ
s
σ
t
Φ
:
tsize
ty
=
1
%
nat
→
r
≡
r
'
⋅
res_mapsto
l
1
s
tg
→
(
r
⊨
{
n
,
fs
,
ft
}
(#[
s
],
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_copy_unique_l
fs
ft
(
r
r
'
:
resUR
)
(
h
:
heaplet
)
n
(
l
:
loc
)
tg
T
(
s
:
scalar
)
et
σ
s
σ
t
Φ
:
tsize
T
=
1
%
nat
→
r
≡
r
'
⋅
res_tag
tg
tkUnique
h
→
h
!!
l
=
Some
s
→
(
r
⊨
{
n
,
fs
,
ft
}
(#[
s
],
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Copy
(
Place
l
(
Tagged
tg
)
T
),
σ
s
)
≥
(
et
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_copy_left_1
fs
ft
(
r
:
resUR
)
k
(
h
:
heapletR
)
n
l
t
et
σ
s
σ
t
Φ
(
UNIQUE
:
r
.(
rtm
)
!!
t
≡
Some
(
k
,
h
))
...
...
@@ -33,3 +70,5 @@ Proof.
{
(
*
follows
COND
*
)
admit
.
}
{
(
*
follows
COND
*
)
admit
.
}
Abort
.
End
left
.
theories/sim/refl.v
View file @
973be934
...
...
@@ -255,7 +255,7 @@ Proof using Type*.
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
?
]
%
rrel_with_eq
).
simplify_eq
/=
.
eapply
sim_simple_deref
=>
l
t
?
.
simplify_eq
/=
.
simplify_eq
/=
.
apply
:
sim_simple_deref
=>
l
t
?
.
simplify_eq
/=
.
do
3
(
split
;
first
done
).
done
.
-
(
*
Ref
*
)
move
=>
Hwf
xs
Hxswf
/=
.
sim_bind
(
subst_map
_
e
)
(
subst_map
_
e
).
...
...
theories/sim/refl_mem_step.v
View file @
973be934
...
...
@@ -5,6 +5,8 @@ From stbor.sim Require Export instance body.
Set
Default
Proof
Using
"Type"
.
Section
mem
.
Implicit
Types
Φ
:
resUR
→
nat
→
result
→
state
→
result
→
state
→
Prop
.
(
**
MEM
STEP
-----------------------------------------------------------------*
)
...
...
@@ -30,7 +32,7 @@ Lemma sim_body_alloc_local fs ft r n T σs σt Φ :
(
S
σ
t
.(
snp
))
σ
t
.(
snc
)
in
let
rt
:
resUR
:=
res_tag
σ
t
.(
snp
)
tkUnique
∅
in
let
r
'
:
resUR
:=
res_mapsto
l
(
tsize
T
)
☠
σ
t
.(
snp
)
in
Φ
(
r
⋅
rt
⋅
r
'
)
n
(
PlaceR
l
t
T
)
σ
s
'
(
PlaceR
l
t
T
)
σ
t
'
:
Prop
→
Φ
(
r
⋅
rt
⋅
r
'
)
n
(
PlaceR
l
t
T
)
σ
s
'
(
PlaceR
l
t
T
)
σ
t
'
→
r
⊨
{
n
,
fs
,
ft
}
(
Alloc
T
,
σ
s
)
≥
(
Alloc
T
,
σ
t
)
:
Φ
.
Proof
.
intros
l
t
σ
s
'
σ
t
'
rt
r
'
POST
.
...
...
@@ -351,7 +353,7 @@ Lemma sim_body_copy_public fs ft r n l t Ts Tt σs σt Φ
∀
α'
,
memory_read
σ
t
.(
sst
)
σ
t
.(
scs
)
l
(
Tagged
t
)
(
tsize
Tt
)
=
Some
α'
→
let
σ
s
'
:=
mkState
σ
s
.(
shp
)
α'
σ
s
.(
scs
)
σ
s
.(
snp
)
σ
s
.(
snc
)
in
let
σ
t
'
:=
mkState
σ
t
.(
shp
)
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)
in
vrel
(
r
⋅
r
'
)
vs
vt
→
Φ
(
r
⋅
r
'
)
n
(
ValR
vs
)
σ
s
'
(
ValR
vt
)
σ
t
'
:
Prop
)
→
vrel
(
r
⋅
r
'
)
vs
vt
→
Φ
(
r
⋅
r
'
)
n
(
ValR
vs
)
σ
s
'
(
ValR
vt
)
σ
t
'
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Copy
(
Place
l
(
Tagged
t
)
Ts
),
σ
s
)
≥
(
Copy
(
Place
l
(
Tagged
t
)
Tt
),
σ
t
)
:
Φ
.
Proof
.
intros
POST
.
pfold
.
...
...
@@ -580,7 +582,7 @@ Lemma sim_body_write_local_1 fs ft r r' n l tg T v v' σs σt Φ :
let
σ
s
'
:=
mkState
(
<
[
l
:=
s
]
>
σ
s
.(
shp
))
σ
s
.(
sst
)
σ
s
.(
scs
)
σ
s
.(
snp
)
σ
s
.(
snc
)
in
let
σ
t
'
:=
mkState
(
<
[
l
:=
s
]
>
σ
t
.(
shp
))
σ
t
.(
sst
)
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)
in
Φ
(
r
'
⋅
res_mapsto
l
1
s
tg
)
n
(
ValR
[
☠
%
S
])
σ
s
'
(
ValR
[
☠
%
S
])
σ
t
'
:
Prop
)
→
(
ValR
[
☠
%
S
])
σ
s
'
(
ValR
[
☠
%
S
])
σ
t
'
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Place
l
(
Tagged
tg
)
T
<-
#
v
,
σ
s
)
≥
(
Place
l
(
Tagged
tg
)
T
<-
#
v
,
σ
t
)
:
Φ
.
Proof
.
...
...
@@ -739,7 +741,7 @@ Lemma sim_body_write_related_values
(
∀
α'
,
memory_written
σ
t
.(
sst
)
σ
t
.(
scs
)
l
(
Tagged
tg
)
(
tsize
Tt
)
=
Some
α'
→
let
σ
s
'
:=
mkState
(
write_mem
l
v
σ
s
.(
shp
))
α'
σ
s
.(
scs
)
σ
s
.(
snp
)
σ
s
.(
snc
)
in
let
σ
t
'
:=
mkState
(
write_mem
l
v
σ
t
.(
shp
))
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)
in
Φ
r
'
n
(
(#[
☠
])
%
V
)
σ
s
'
((#[
☠
]
%
V
)
)
σ
t
'
:
Prop
)
→
Φ
r
'
n
(
ValR
[
☠
]
%
S
)
σ
s
'
(
ValR
[
☠
]
%
S
)
σ
t
'
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Place
l
(
Tagged
tg
)
Ts
<-
#
v
,
σ
s
)
≥
(
Place
l
(
Tagged
tg
)
Tt
<-
#
v
,
σ
t
)
:
Φ
.
Proof
.
...
...
@@ -1032,6 +1034,23 @@ Proof.
intros
.
simpl
.
by
apply
POST
.
Qed
.
(
**
can
probably
be
derived
from
[
write_related_values
]
?
*
)
Lemma
sim_body_write_owned
fs
ft
(
r
r
'
r
''
rs
:
resUR
)
h
n
l
tg
T
s
σ
s
σ
t
Φ
:
tsize
T
=
1
%
nat
→
r
≡
r
'
⋅
res_tag
tg
tkUnique
h
→
arel
rs
s
s
→
(
*
assuming
to
-
write
values
are
related
*
)
r
'
≡
r
''
⋅
rs
→
(
∀
α'
,
memory_written
σ
t
.(
sst
)
σ
t
.(
scs
)
l
(
Tagged
tg
)
(
tsize
T
)
=
Some
α'
→
let
σ
s
'
:=
mkState
(
write_mem
l
[
s
]
σ
s
.(
shp
))
α'
σ
s
.(
scs
)
σ
s
.(
snp
)
σ
s
.(
snc
)
in
let
σ
t
'
:=
mkState
(
write_mem
l
[
s
]
σ
t
.(
shp
))
α'
σ
t
.(
scs
)
σ
t
.(
snp
)
σ
t
.(
snc
)
in
tag_on_top
σ
t
l
tg
→
Φ
(
r
'
⋅
res_tag
tg
tkUnique
(
<
[
l
:=
s
]
>
h
))
n
(
ValR
[
☠
]
%
S
)
σ
s
'
(
ValR
[
☠
]
%
S
)
σ
t
'
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Place
l
(
Tagged
tg
)
T
<-
#[
s
],
σ
s
)
≥
(
Place
l
(
Tagged
tg
)
T
<-
#[
s
],
σ
t
)
:
Φ
.
Proof
.
Admitted
.
(
**
Retag
*
)
Lemma
retag_ref_change_1
h
α
cids
c
nxtp
x
rk
mut
T
h
'
α'
nxtp
'
...
...
@@ -1108,7 +1127,7 @@ Lemma sim_body_retag_default fs ft r n x xtag mut T σs σt Φ
=
Some
(
hs
'
,
α
s
'
,
nps
'
)
→
let
σ
s
'
:=
mkState
hs
'
α
s
'
σ
s
.(
scs
)
nps
'
σ
s
.(
snc
)
in
let
σ
t
'
:=
mkState
ht
'
α
t
'
σ
t
.(
scs
)
npt
'
σ
t
.(
snc
)
in
Φ
r
n
(
(#[
☠
])
%
V
)
σ
s
'
((#[
☠
]
%
V
)
)
σ
t
'
:
Prop
)
→
Φ
r
n
(
ValR
[
☠
]
%
S
)
σ
s
'
(
ValR
[
☠
]
%
S
)
σ
t
'
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Retag
(
Place
x
xtag
Tr
)
Default
,
σ
s
)
≥
(
Retag
(
Place
x
xtag
Tr
)
Default
,
σ
t
)
:
Φ
.
...
...
@@ -1353,3 +1372,5 @@ Proof.
simplify_eq
.
split
;
[
done
|
].
eexists
.
split
;
[
|
done
].
by
apply
tc_once
.
}
subst
.
simpl
.
by
exists
vs
,
vt
.
Qed
.
End
mem
.
theories/sim/refl_pure_step.v
View file @
973be934
...
...
@@ -5,6 +5,10 @@ From stbor.sim Require Export instance body.
Set
Default
Proof
Using
"Type"
.
Section
pure
.
Implicit
Types
Φ
:
resUR
→
nat
→
result
→
state
→
result
→
state
→
Prop
.
(
**
PURE
STEP
----------------------------------------------------------------*
)
(
**
Call
-
step
over
*
)
...
...
@@ -88,7 +92,7 @@ Qed.
(
**
Conc
*
)
Lemma
sim_body_conc
fs
ft
r
n
(
r1
r2
:
result
)
σ
s
σ
t
Φ
:
(
∀
v1
v2
,
r1
=
ValR
v1
→
r2
=
ValR
v2
→
Φ
r
n
(
ValR
(
v1
++
v2
))
σ
s
(
ValR
(
v1
++
v2
))
σ
t
:
Prop
)
→
Φ
r
n
(
ValR
(
v1
++
v2
))
σ
s
(
ValR
(
v1
++
v2
))
σ
t
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Conc
r1
r2
,
σ
s
)
≥
(
Conc
r1
r2
,
σ
t
)
:
Φ
.
Proof
.
intros
POST
.
pfold
.
intros
NT
r_f
WSAT
.
split
;
[
|
done
|
].
...
...
@@ -110,7 +114,7 @@ Qed.
Lemma
sim_body_bin_op
fs
ft
r
n
op
(
r1
r2
:
result
)
σ
s
σ
t
Φ
:
(
∀
s1
s2
s
,
r1
=
ValR
[
s1
]
→
r2
=
ValR
[
s2
]
→
bin_op_eval
σ
t
.(
shp
)
op
s1
s2
s
→
Φ
r
n
(
ValR
[
s
])
σ
s
(
ValR
[
s
])
σ
t
:
Prop
)
→
Φ
r
n
(
ValR
[
s
])
σ
s
(
ValR
[
s
])
σ
t
)
→
r
⊨
{
n
,
fs
,
ft
}
(
BinOp
op
r1
r2
,
σ
s
)
≥
(
BinOp
op
r1
r2
,
σ
t
)
:
Φ
.
Proof
.
intros
POST
.
pfold
.
intros
NT
r_f
WSAT
.
split
;
[
|
done
|
].
...
...
@@ -180,7 +184,7 @@ Qed.
(
**
Ref
*
)
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
(
ValR
[
ScPtr
l
t
])
σ
s
(
ValR
[
ScPtr
l
t
])
σ
t
)
→
r
⊨
{
n
,
fs
,
ft
}
((
&
pl
)
%
E
,
σ
s
)
≥
((
&
pl
)
%
E
,
σ
t
)
:
Φ
.
Proof
.
intros
POST
.
pfold
.
...
...
@@ -211,7 +215,7 @@ Qed.
(
**
Deref
*
)
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
(
PlaceR
l
t
T
)
σ
s
(
PlaceR
l
t
T
)
σ
t
)
→
r
⊨
{
n
,
fs
,
ft
}
(
Deref
rf
T
,
σ
s
)
≥
(
Deref
rf
T
,
σ
t
)
:
Φ
.
Proof
.
intros
POST
.
pfold
.
...
...
@@ -236,3 +240,5 @@ Proof.
left
.
apply
:
sim_body_result
.
intros
.
by
eapply
POST
.
Qed
.
End
pure
.
theories/sim/right_step.v
View file @
973be934
...
...
@@ -5,13 +5,42 @@ From stbor.sim Require Export instance.
Set
Default
Proof
Using
"Type"
.
Lemma
sim_body_copy_right_1
fs
ft
(
r
:
resUR
)
k
(
h
:
heapletR
)
n
l
t
s
es
σ
s
σ
t
Φ
(
*
we
know
we
'
re
going
to
read
s
*
)
(
UNIQUE
:
r
.(
rtm
)
!!
t
≡
Some
(
k
,
h
))
(
InD
:
h
!!
l
≡
Some
(
to_agree
s
))
(
IN
:
tag_in_stack
σ
t
l
t
)
:
(
σ
t
.(
shp
)
!!
l
=
Some
s
→
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(#[
s
%
S
],
σ
t
)
:
Φ
:
Prop
)
→
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
Copy
(
Place
l
(
Tagged
t
)
int
),
σ
t
)
:
Φ
.
Section
right
.
Implicit
Types
Φ
:
resUR
→
nat
→
result
→
state
→
result
→
state
→
Prop
.
Lemma
sim_body_let_r
fs
ft
r
n
x
es
et1
et2
vt1
σ
s
σ
t
Φ
:
IntoResult
et1
vt1
→
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
subst
'
x
et1
et2
,
σ
t
)
:
Φ
→
r
⊨
{
S
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
let
:
x
:=
et1
in
et2
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_deref_r
fs
ft
r
n
es
(
rs
:
result
)
l
t
T
σ
s
σ
t
Φ
:
IntoResult
es
rs
→
(
Φ
r
n
rs
σ
s
(
PlaceR
l
t
T
)
σ
t
)
→
r
⊨
{
S
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
Deref
#[
ScPtr
l
t
]
T
,
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_copy_local_r
fs
ft
r
r
'
n
l
tg
ty
s
es
σ
s
σ
t
Φ
:
tsize
ty
=
1
%
nat
→
r
≡
r
'
⋅
res_mapsto
l
1
s
tg
→
(
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(#[
s
],
σ
t
)
:
Φ
)
→
r
⊨
{
S
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
σ
t
)
:
Φ
.
Proof
.
Admitted
.
Lemma
sim_body_copy_unique_r
fs
ft
(
r
r
'
:
resUR
)
(
h
:
heaplet
)
n
(
l
:
loc
)
tg
T
(
s
:
scalar
)
es
σ
s
σ
t
Φ
:
tsize
T
=
1
%
nat
→
tag_on_top
σ
t
l
tg
→
r
≡
r
'
⋅
res_tag
tg
tkUnique
h
→
h
!!
l
=
Some
s
→
(
r
⊨
{
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(#[
s
],
σ
t
)
:
Φ
:
Prop
)
→
r
⊨
{
S
n
,
fs
,
ft
}
(
es
,
σ
s
)
≥
(
Copy
(
Place
l
(
Tagged
tg
)
T
),
σ
t
)
:
Φ
.
Proof
.
Abort
.
Admitted
.
End
right
.
theories/sim/simple.v
View file @
973be934
...
...
@@ -8,7 +8,7 @@ want to clean some stuff from your context.
*
)
From
stbor
.
sim
Require
Export
body
instance
.
From
stbor
.
sim
Require
Import
refl_step
.
From
stbor
.
sim
Require
Import
refl_step
right_step
left_step
.
Definition
fun_post_simple
initial_call_id_stack
(
r
:
resUR
)
(
n
:
nat
)
vs
(
css
:
call_id_stack
)
vt
cst
:=
...
...
@@ -167,9 +167,9 @@ Proof.
Qed
.
Lemma
sim_simple_bind
fs
ft
(
Ks
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
fs
)))
(
Kt
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
es
et
r
n
css
cst
Φ
:
(
Ks
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
fs
)))
es
(
Kt
:
list
(
ectxi_language
.
ectx_item
(
bor_ectxi_lang
ft
)))
et
r
n
css
cst
Φ
:
r
⊨ˢ
{
n
,
fs
,
ft
}
(
es
,
css
)
≥
(
et
,
cst
)
:
(
λ
r
'
n
'
es
'
css
'
et
'
cst
'
,
r
'
⊨ˢ
{
n
'
,
fs
,
ft
}
(
fill
Ks
es
'
,
css
'
)
≥
(
fill
Kt
et
'
,
cst
'
)
:
Φ
)
→
...
...
@@ -268,17 +268,34 @@ Lemma sim_simple_copy_local_l fs ft r r' n l tg ty s et css cst Φ :
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
css
)
≥
(
et
,
cst
)
:
Φ
.
Proof
.
Admitted
.
intros
??
Hold
σ
s
σ
t
<-
<-
.
eapply
sim_body_copy_local_l
;
eauto
.
Qed
.
Lemma
sim_simple_copy_local_r
fs
ft
r
r
'
n
l
tg
ty
s
es
css
cst
Φ
:
tsize
ty
=
1
%
nat
→
r
≡
r
'
⋅
res_mapsto
l
1
s
tg
→
(
r
⊨ˢ
{
n
,
fs
,
ft
}
(
es
,
css
)
≥
(#[
s
],
cst
)
:
Φ
)
→
r
⊨ˢ
{
n
,
fs
,
ft
}
r
⊨ˢ
{
S
n
,
fs
,
ft
}
(
es
,
css
)
≥
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
cst
)
:
Φ
.
Proof
.
Admitted
.
intros
??
Hold
σ
s
σ
t
<-
<-
.
eapply
sim_body_copy_local_r
;
eauto
.
Qed
.
Lemma
sim_simple_copy_local
fs
ft
r
r
'
n
l
tg
ty
s
css
cst
Φ
:
tsize
ty
=
1
%
nat
→
r
≡
r
'
⋅
res_mapsto
l
1
s
tg
→
(
r
⊨ˢ
{
n
,
fs
,
ft
}
(#[
s
],
css
)
≥
(#[
s
],
cst
)
:
Φ
)
→
r
⊨ˢ
{
S
n
,
fs
,
ft
}
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
css
)
≥
(
Copy
(
Place
l
(
Tagged
tg
)
ty
),
cst
)
:
Φ
.
Proof
.
intros
??
Hcont
.
eapply
sim_simple_copy_local_l
;
[
done
..
|
].
eapply
sim_simple_copy_local_r
;
done
.
Qed
.
Lemma
sim_simple_retag_local
fs
ft
r
r
'
r
''
rs
n
l
s
'
s
tg
ty
css
cst
Φ
:
r
≡
r
'
⋅
res_mapsto
l
1
s
tg
→
...
...
@@ -351,11 +368,12 @@ Lemma sim_simple_ref fs ft r n (pl: result) css 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
(
rf
:
result
)
T
css
cst
Φ
:
Lemma
sim_simple_deref
fs
ft
r
n
ef
(
rf
:
result
)
T
css
cst
Φ
:
IntoResult
ef
rf
→
(
∀
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
r
f
T
,
cst
)
:
Φ
.
Proof
.
intros
HH
σ
s
σ
t
<-<-
.
apply
sim_body_deref
;
eauto
.
Qed
.
r
⊨ˢ
{
n
,
fs
,
ft
}
(
Deref
ef
T
,
css
)
≥
(
Deref
e
f
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
)
:
Φ
.
...
...
theories/sim/tactics.v
View file @
973be934
...
...
@@ -41,23 +41,23 @@ Ltac reshape_expr e tac :=
(
**
bind
if
K
is
not
empty
.
Otherwise
do
nothing
.
Binds
cost
us
steps
,
so
don
'
t
waste
them
!
*
)
Ltac
sim_body_bind_core
Ks
Kt
es
et
:=
Ltac
sim_body_bind_core
Ks
es
Kt
et
:=
(
*
Ltac
is
SUCH
a
bad
language
...
*
)
match
Ks
with
|
[]
=>
match
Kt
with
|
[]
=>
idtac
|
_
=>
eapply
(
sim_body_bind
_
_
_
_
Ks
Kt
es
et
)
|
_
=>
eapply
(
sim_body_bind
_
_
Ks
es
Kt
et
)
end
|
_
=>
eapply
(
sim_body_bind
_
_
_
_
Ks
Kt
es
et
)
|
_
=>
eapply
(
sim_body_bind
_
_
Ks
es
Kt
et
)
end
.
Ltac
sim_simple_bind_core
Ks
Kt
es
et
:=
Ltac
sim_simple_bind_core
Ks
es
Kt
et
:=
(
*
Ltac
is
SUCH
a
bad
language
...
*
)
match
Ks
with
|
[]
=>
match
Kt
with
|
[]
=>
idtac
|
_
=>
eapply
(
sim_simple_bind
_
_
Ks
Kt
es
et
)
|
_
=>
eapply
(
sim_simple_bind
_
_
Ks
es
Kt
et
)
end
|
_
=>
eapply
(
sim_simple_bind
_
_
Ks
Kt
es
et
)
|
_
=>
eapply
(
sim_simple_bind
_
_
Ks
es
Kt
et
)
end
.
Tactic
Notation
"sim_bind"
open_constr
(
efocs
)
open_constr
(
efoct
)
:=
...
...
@@ -67,7 +67,7 @@ Tactic Notation "sim_bind" open_constr(efocs) open_constr(efoct) :=
unify
es
efocs
;
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
unify
et
efoct
;
sim_body_bind_core
Ks
Kt
es
et
sim_body_bind_core
Ks
es
Kt
et
)
)
|
|-
_
⊨ˢ
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
?
et
,
_
)
:
_
=>
...
...
@@ -75,7 +75,7 @@ Tactic Notation "sim_bind" open_constr(efocs) open_constr(efoct) :=
unify
es
efocs
;
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
unify
et
efoct
;
sim_simple_bind_core
Ks
Kt
es
et
sim_simple_bind_core
Ks
es
Kt
et
)
)
end
.
...
...
@@ -85,19 +85,55 @@ Tactic Notation "sim_apply" open_constr(lem) :=
|
|-
_
⊨
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
?
et
,
_
)
:
_
=>
reshape_expr
es
ltac
:
(
fun
Ks
es
=>
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
sim_body_bind_core
Ks
Kt
es
et
;
sim_body_bind_core
Ks
es
Kt
et
;
apply:
lem
)
)
|
|-
_
⊨ˢ
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
?
et
,
_
)
:
_
=>
reshape_expr
es
ltac
:
(
fun
Ks
es
=>
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
sim_simple_bind_core
Ks
Kt
es
et
;
sim_simple_bind_core
Ks
es
Kt
et
;
apply:
lem
)
)
end
.
Tactic
Notation
"sim_bind_r"
open_constr
(
efoc
)
:=
match
goal
with
|
|-
_
⊨
{
_
,
_
,
_
}
(
_
,
_
)
≥
(
?
et
,
_
)
:
_
=>
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
unify
et
efoc
;
eapply
(
sim_body_bind_r
_
_
Kt
et
)
)
end
.
Tactic
Notation
"sim_apply_r"
open_constr
(
lem
)
:=
match
goal
with
|
|-
_
⊨
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
?
et
,
_
)
:
_
=>
reshape_expr
et
ltac
:
(
fun
Kt
et
=>
eapply
(
sim_body_bind_r
_
_
Kt
et
);
apply:
lem
)
end
.
Tactic
Notation
"sim_bind_l"
open_constr
(
efoc
)
:=
match
goal
with
|
|-
_
⊨
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
_
,
_
)
:
_
=>
reshape_expr
es
ltac
:
(
fun
Ks
es
=>
unify
es
efoc
;
eapply
(
sim_body_bind_l
_
_
Ks
es
)
)
end
.
Tactic
Notation
"sim_apply_l"
open_constr
(
lem
)
:=
match
goal
with
|
|-
_
⊨
{
_
,
_
,
_
}
(
?
es
,
_
)
≥
(
_
,
_
)
:
_
=>
reshape_expr
es
ltac
:
(
fun
Ks
es
=>
eapply
(
sim_body_bind_l
_
_
Ks
es
);
apply:
lem
)
end
.
(
**
The
expectation
is
that
lemmas
state
their
resource
requirements
as
[
r
≡
frame
⋅
what_lemma_needs
].
Users
eapply
the
lemma
,
and
[
frame
]
...
...
Write
Preview
Markdown
is supported
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