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
Iris
examples
Commits
c1161885
Commit
c1161885
authored
Sep 16, 2016
by
Zhen Zhang
Browse files
Upgrade srv invariants
parent
5d985306
Changes
1
Hide whitespace changes
Inline
Side-by-side
srv.v
View file @
c1161885
From
iris
.
program_logic
Require
Export
weakestpre
.
From
iris
.
program_logic
Require
Export
auth
weakestpre
.
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
.
From
iris
.
algebra
Require
Import
frac
excl
dec_agree
upred_big_op
gset
gmap
.
From
iris
.
tests
Require
Import
treiber_stack
.
From
flatcomb
Require
Import
misc
.
...
...
@@ -41,33 +41,65 @@ Definition flat : val :=
Global
Opaque
doOp
install
loop
flat
.
Definition
hdset
:
=
gset
loc
.
Definition
gnmap
:
=
gmap
loc
(
dec_agree
(
gname
*
gname
*
gname
*
gname
*
gname
)).
Definition
srvR
:
=
prodR
fracR
(
dec_agreeR
val
).
Class
srvG
Σ
:
=
FlatG
{
srv_tokG
:
>
inG
Σ
srvR
}.
Definition
srv
Σ
:
gFunctors
:
=
#[
GFunctor
(
constRF
srvR
)].
Definition
hdsetR
:
=
gset_disjUR
loc
.
Definition
gnmapR
:
=
gmapUR
loc
(
dec_agreeR
(
gname
*
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
))
].
Instance
subG_srv
Σ
{
Σ
}
:
subG
srv
Σ
Σ
→
srvG
Σ
.
Proof
.
intros
[?%
subG_inG
_
]%
subG_inv
.
split
;
apply
_
.
Qed
.
Proof
.
intros
[?%
subG_inG
[
?subG_inG
[
?subG_inG
_
]%
subG_inv
]%
subG_inv
]%
subG_inv
.
split
;
apply
_
.
Qed
.
Section
proof
.
Context
`
{!
heapG
Σ
,
!
lockG
Σ
,
!
srvG
Σ
}
(
N
:
namespace
).
Definition
srv
_inv
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
.
Lemma
srv_inv_timeless
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
:
TimelessP
(
srv_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
).
Definition
p_inv'
(
γ
s
:
dec_agree
(
gname
*
gname
*
gname
*
gname
*
gname
))
p
Q
:
=
match
γ
s
with
|
DecAgreeBot
=>
False
%
I
|
DecAgree
(
γ
x
,
γ
1
,
γ
2
,
γ
3
,
γ
4
)
=>
p_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
end
.
Definition
srv_inv
(
γ
hd
γ
gn
:
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'
γ
s
p
Q
)
)%
I
.
Instance
stack_inv_timeless
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
:
TimelessP
(
srv_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
).
Proof
.
apply
_
.
Qed
.
Lemma
wait
_spec
(
Φ
:
val
→
iProp
Σ
)
(
Q
:
val
→
val
→
Prop
)
x
γ
x
γ
1
γ
2
γ
3
γ
4
p
:
Lemma
install
_spec
(
Φ
:
val
→
iProp
Σ
)
(
Q
:
val
→
val
→
Prop
)
x
γ
3
γ
4
γ
x
p
s
:
heapN
⊥
N
→
heap_ctx
★
inv
N
(
s
rv
_inv
γ
x
γ
1
γ
2
γ
3
γ
4
p
Q
)
★
heap_ctx
★
inv
N
(
s
tack
_inv
s
Q
)
★
own
γ
x
((
1
/
2
)%
Qp
,
DecAgree
x
)
★
own
γ
3
(
Excl
())
★
(
∀
y
,
own
γ
4
(
Excl
())
-
★
own
γ
x
(
1
%
Qp
,
DecAgree
x
)
-
★
■
Q
x
y
-
★
Φ
y
)
⊢
WP
wait
#
p
{{
Φ
}}.
⊢
WP
install
#
p
#
s
{{
Φ
}}.
Proof
.
iIntros
(
HN
)
"(#Hh & #Hsrv & Hx & Ho3 & HΦ)"
.
iL
ö
b
as
"IH"
.
...
...
@@ -165,7 +197,7 @@ Section proof.
*
admit
.
*
iDestruct
"Hinv"
as
(
x'
)
"(Hp & Hx' & Ho2 & Ho4)"
.
destruct
(
decide
(
x
=
x'
))
as
[->|
Hneq
]
;
last
by
admit
.
wp_store
.
iCombine
"Hx2"
"Hx'"
as
"Hx"
.
wp_store
.
iCombine
"Hx2"
"Hx'"
as
"Hx"
.
iDestruct
(
own_update
with
"Hx"
)
as
"==>Hx"
;
first
by
apply
pair_l_frac_op
.
rewrite
Qp_div_S
.
iVs
(
"Hclose"
with
"[Hp Hx Ho1 Ho4]"
).
...
...
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