Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iris-atomic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FP
iris-atomic
Commits
889d57f1
Commit
889d57f1
authored
8 years ago
by
Zhen Zhang
Browse files
Options
Downloads
Patches
Plain Diff
change invariant
parent
d5272bc5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
srv.v
+30
-56
30 additions, 56 deletions
srv.v
with
30 additions
and
56 deletions
srv.v
+
30
−
56
View file @
889d57f1
...
...
@@ -3,7 +3,7 @@ From iris.proofmode Require Import invariants ghost_ownership.
From
iris
.
heap_lang
Require
Export
lang
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
iris
.
heap_lang
.
lib
Require
Import
spin_lock
.
From
iris
.
algebra
Require
Import
frac
excl
dec_agree
upred_big_op
gset
gmap
.
From
iris
.
algebra
Require
Import
upred
frac
excl
dec_agree
upred_big_op
gset
gmap
.
From
iris
.
tests
Require
Import
atomic
treiber_stack
.
From
flatcomb
Require
Import
misc
.
...
...
@@ -41,69 +41,39 @@ Definition flat : val :=
Global
Opaque
doOp
install
loop
flat
.
Definition
hdset
:=
gset
loc
.
Definition
gnmap
:=
gmap
loc
(
dec_agree
(
gname
*
gname
*
gname
*
gname
)).
Definition
srvR
:=
prodR
fracR
(
dec_agreeR
val
).
Definition
hdsetR
:=
gset_disjUR
loc
.
Definition
gnmapR
:=
gmapUR
loc
(
dec_agreeR
(
gname
*
gname
*
gname
*
gname
)).
Class
srvG
Σ
:=
SrvG
{
srv_tokG
:>
inG
Σ
srvR
;
hd_G
:>
inG
Σ
(
authR
hdsetR
);
gn_G
:>
inG
Σ
(
authR
gnmapR
)
}
.
Definition
srv
Σ
:
gFunctors
:=
#[
GFunctor
(
constRF
srvR
);
GFunctor
(
constRF
(
authR
hdsetR
));
GFunctor
(
constRF
(
authR
gnmapR
))
].
Class
srvG
Σ
:=
SrvG
{
srv_G
:>
inG
Σ
srvR
}
.
Definition
srv
Σ
:
gFunctors
:=
#[
GFunctor
(
constRF
srvR
)].
Instance
subG_srv
Σ
{
Σ
}
:
subG
srv
Σ
Σ
→
srvG
Σ
.
Proof
.
intros
[
?%
subG_inG
[
?
subG_inG
[
?
subG_inG
_
]
%
subG_inv
]
%
subG_inv
]
%
subG_inv
.
split
;
apply
_.
Qed
.
Proof
.
intros
[
?%
subG_inG
_
]
%
subG_inv
.
split
;
apply
_.
Qed
.
Section
proof
.
Context
`
{!
heapG
Σ
,
!
lockG
Σ
,
!
srvG
Σ
}
(
N
:
namespace
).
Context
`
{!
heapG
Σ
,
!
lockG
Σ
,
!
evidenceG
loc
val
Σ
,
!
srvG
Σ
}
(
N
:
namespace
).
Definition
p_inv
(
γ
x
γ
1
γ
2
γ
3
γ
4
:
gname
)
(
p
:
loc
)
(
Q
:
val
→
val
→
Prop
)
:
iProp
Σ
:=
((
∃
(
y
:
val
),
p
↦
InjRV
y
★
own
γ
1
(
Excl
())
★
own
γ
3
(
Excl
()))
∨
(
∃
(
x
:
val
),
p
↦
InjLV
x
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
1
(
Excl
())
★
own
γ
4
(
Excl
()))
∨
(
∃
(
x
:
val
),
p
↦
InjLV
x
★
own
γ
x
((
1
/
4
)
%
Qp
,
DecAgree
x
)
★
own
γ
2
(
Excl
())
★
own
γ
4
(
Excl
()))
∨
(
∃
(
x
y
:
val
),
p
↦
InjRV
y
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
■
Q
x
y
★
own
γ
1
(
Excl
())
★
own
γ
4
(
Excl
())))
%
I
.
(
γ
x
γ
1
γ
2
γ
3
γ
4
:
gname
)
(
Q
:
val
→
val
→
Prop
)
(
v
:
val
)
:
iProp
Σ
:=
((
∃
(
y
:
val
),
v
=
InjRV
y
★
own
γ
1
(
Excl
())
★
own
γ
3
(
Excl
()))
∨
(
∃
(
x
:
val
),
v
=
InjLV
x
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
1
(
Excl
())
★
own
γ
4
(
Excl
()))
∨
(
∃
(
x
:
val
),
v
=
InjLV
x
★
own
γ
x
((
1
/
4
)
%
Qp
,
DecAgree
x
)
★
own
γ
2
(
Excl
())
★
own
γ
4
(
Excl
()))
∨
(
∃
(
x
y
:
val
),
v
=
InjRV
y
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
■
Q
x
y
★
own
γ
1
(
Excl
())
★
own
γ
4
(
Excl
())))
%
I
.
Definition
p_inv
'
γ
2
(
γ
s
:
dec_agree
(
gname
*
gname
*
gname
*
gname
))
p
Q
:=
match
γ
s
with
|
DecAgreeBot
=>
False
%
I
|
DecAgree
(
γ
x
,
γ
1
,
γ
3
,
γ
4
)
=>
p_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
end
.
Definition
p_inv_R
γ
2
Q
v
:
iProp
Σ
:=
(
∃
γ
x
γ
1
γ
3
γ
4
:
gname
,
p_inv
γ
x
γ
1
γ
2
γ
3
γ
4
Q
v
)
%
I
.
Definition
srv_inv
(
γ
hd
γ
gn
γ
2
:
gname
)
(
s
:
loc
)
(
Q
:
val
→
val
→
Prop
)
:
iProp
Σ
:=
(
∃
(
hds
:
hdset
)
(
gnm
:
gnmap
),
own
γ
hd
(
●
GSet
hds
)
★
own
γ
gn
(
●
gnm
)
★
(
∃
xs
:
list
loc
,
is_stack
s
(
map
(
fun
x
=>
#
(
LitLoc
x
))
xs
)
★
[
★
list
]
k
↦
x
∈
xs
,
■
(
x
∈
dom
(
gset
loc
)
gnm
))
★
([
★
set
]
hd
∈
hds
,
∃
xs
,
is_list
hd
(
map
(
fun
x
=>
#
(
LitLoc
x
))
xs
)
★
[
★
list
]
k
↦
x
∈
xs
,
■
(
x
∈
dom
(
gset
loc
)
gnm
))
★
([
★
map
]
p
↦
γ
s
∈
gnm
,
p_inv
'
γ
2
γ
s
p
Q
)
)
%
I
.
Definition
srv_inv
(
γ
γ
2
:
gname
)
(
s
:
loc
)
(
Q
:
val
→
val
→
Prop
)
:
iProp
Σ
:=
(
∃
xs
,
is_stack
'
(
p_inv_R
γ
2
Q
)
xs
s
γ
)
%
I
.
Instance
p_inv_timeless
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
:
TimelessP
(
p_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
).
Proof
.
apply
_.
Qed
.
Instance
p
_inv
'
_
timeless
γ
2
γ
s
p
Q
:
TimelessP
(
p
_inv
'
γ
2
γ
s
p
Q
).
Instance
srv
_inv_timeless
γ
γ
2
s
Q
:
TimelessP
(
srv
_inv
γ
γ
2
s
Q
).
Proof
.
rewrite
/
p_inv
'
.
destruct
γ
s
as
[
γ
s
|
]
.
-
repeat
(
destruct
γ
s
as
[
γ
s
?
]).
apply
_
.
-
apply
_.
apply
uPred
.
exist_timeless
.
move
=>
x
.
apply
is_stack
'_
timeless
.
move
=>
v
.
apply
_.
Qed
.
Instance
srv_inv_timeless
γ
hd
γ
gn
γ
2
s
Q
:
TimelessP
(
srv_inv
γ
hd
γ
gn
γ
2
s
Q
).
Proof
.
apply
_.
Qed
.
(
*
Lemma
push_spec
*
)
(
*
(
Φ
:
val
→
iProp
Σ
)
(
Q
:
val
→
val
→
Prop
)
*
)
(
*
(
p
:
loc
)
(
γ
x
γ
1
γ
2
γ
3
γ
4
:
gname
)
*
)
...
...
@@ -237,7 +207,7 @@ Section proof.
Lemma
loop_iter_list_spec
Φ
(
f
:
val
)
(
s
hd
:
loc
)
Q
(
γ
hd
γ
gn
γ
2
:
gname
)
xs
:
heapN
⊥
N
→
heap_ctx
★
inv
N
(
srv_inv
γ
hd
γ
gn
γ
2
s
Q
)
★
□
(
∀
x
:
val
,
WP
f
x
{{
v
,
■
Q
x
v
}}
)
%
I
★
own
γ
2
(
Excl
())
★
is_list
hd
xs
★
own
γ
hd
(
◯
GSet
{
[
hd
]
}
)
★
(
own
γ
2
(
Excl
())
-
★
Φ
#())
is_list
hd
xs
★
own
γ
hd
(
◯
(
{
[
hd
]
}
:
hdsetR
)
)
★
(
own
γ
2
(
Excl
())
-
★
Φ
#())
⊢
WP
doOp
f
{{
f
'
,
WP
iter
'
#
hd
f
'
{{
Φ
}}
}}
.
Proof
.
iIntros
(
HN
)
"(#Hh & #? & #Hf & Hxs & Hhd & Ho2 & HΦ)"
.
...
...
@@ -287,7 +257,7 @@ Section proof.
iAssert
(
∃
(
hd
'0
:
loc
)
(
q0
:
Qp
),
hd
↦
{
q0
}
SOMEV
(#
p
,
#
hd
'0
)
★
is_list
hd
'0
xs
'
)
%
I
with
"[Hhd2 Hl]"
as
"He"
.
{
iExists
hd
'
,
(
q
/
2
)
%
Qp
.
by
iFrame
.
}
iAssert
(
own
γ
hd
(
◯
GSet
{
[
hd
]
}
))
as
"Hfrag"
.
iAssert
(
own
γ
hd
(
◯
{
[
hd
]
}
))
as
"Hfrag"
.
{
admit
.
}
iSpecialize
(
"IH"
with
"Ho2 He Hfrag HΦ"
).
admit
.
...
...
@@ -304,7 +274,7 @@ Section proof.
⊢
WP
iter
(
doOp
f
)
#
s
{{
Φ
}}
.
Proof
.
iIntros
(
HN
)
"(#Hh & #? & #? & ? & ?)"
.
iAssert
(
∃
(
hd
:
loc
)
xs
,
is_list
hd
xs
★
own
γ
hd
(
◯
GSet
{
[
hd
]
}
)
★
s
↦
#
hd
)
%
I
as
"H"
.
iAssert
(
∃
(
hd
:
loc
)
xs
,
is_list
hd
xs
★
own
γ
hd
(
◯
{
[
hd
]
}
)
★
s
↦
#
hd
)
%
I
as
"H"
.
{
admit
.
}
iDestruct
"H"
as
(
hd
xs
)
"(? & ? & ?)"
.
wp_bind
(
doOp
_
).
...
...
@@ -343,19 +313,23 @@ Section proof.
Lemma
flat_spec
(
f
:
val
)
Q
:
heapN
⊥
N
→
heap_ctx
★
□
(
∀
x
:
val
,
WP
f
x
{{
v
,
■
Q
x
v
}}
)
%
I
⊢
WP
flat
f
{{
f
'
,
True
%
I
}}
.
heap_ctx
★
□
(
∀
x
:
val
,
WP
f
x
{{
v
,
■
Q
x
v
}}
)
%
I
⊢
WP
flat
f
{{
f
'
,
□
(
∀
x
:
val
,
WP
f
'
x
{{
v
,
■
Q
x
v
}}
)
}}
.
Proof
.
iIntros
(
HN
)
"(#Hh & #?)"
.
wp_seq
.
wp_alloc
lk
as
"Hl"
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
2
)
"Ho2"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
lk
)
"Hγlk"
;
first
done
.
iVs
(
own_alloc
(
●
(
∅
:
hdsetR
)
⋅
◯
∅
))
as
(
γ
hd
)
"[Hgs Hgs']"
;
first
admit
.
iVs
(
own_alloc
(
●
∅
⋅
◯
∅
))
as
(
γ
gn
)
"[Hgs Hgs']"
;
first
admit
.
iVs
(
own_alloc
())
as
(
γ
lk
)
"Hγlk"
;
first
done
.
iVs
(
inv_alloc
N
_
(
lock_inv
γ
lk
lk
(
own
γ
2
(
Excl
())))
with
"[-]"
)
as
"#?"
.
{
iIntros
"!>"
.
iExists
false
.
by
iFrame
.
}
wp_let
.
wp_bind
(
new_stack
_
).
iApply
new_stack_spec
=>
//.
iFrame
"Hh"
.
iIntros
(
s
)
"Hs"
.
iVs
(
inv_alloc
N
_
(
srv_inv
γ
hd
γ
gn
γ
2
s
Q
)
with
""
)
as
"#?"
.
wp_let
.
done
.
iVsIntro
.
iPureIntro
Qed
.
\ No newline at end of file
End
proof
.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment