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
d344c353
Commit
d344c353
authored
8 years ago
by
Zhen Zhang
Browse files
Options
Downloads
Patches
Plain Diff
srv ... token exchange is too complex
parent
b2ba5bcb
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
srv.v
+110
-67
110 additions, 67 deletions
srv.v
with
110 additions
and
67 deletions
srv.v
+
110
−
67
View file @
d344c353
...
@@ -16,7 +16,7 @@ Definition srv : val :=
...
@@ -16,7 +16,7 @@ Definition srv : val :=
Definition
wait
:
val
:=
Definition
wait
:
val
:=
rec:
"wait"
"p"
:=
rec:
"wait"
"p"
:=
match:
!
"p"
with
match:
!
"p"
with
InjR
"r"
=>
"p"
<-
InjR
#
0
;;
"r"
InjR
"r"
=>
"r"
|
InjL
"_"
=>
"wait"
"p"
|
InjL
"_"
=>
"wait"
"p"
end
.
end
.
...
@@ -60,38 +60,53 @@ Section proof.
...
@@ -60,38 +60,53 @@ Section proof.
Context
`
{!
heapG
Σ
,
!
lockG
Σ
,
!
srvG
Σ
}
(
N
:
namespace
).
Context
`
{!
heapG
Σ
,
!
lockG
Σ
,
!
srvG
Σ
}
(
N
:
namespace
).
Definition
srv_inv
Definition
srv_inv
(
γ
x
γ
1
γ
2
γ
3
:
gname
)
(
p
:
loc
)
(
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
:
gname
)
(
p
:
loc
)
(
Q
:
val
→
val
→
Prop
)
:
iProp
Σ
:=
(
Q
:
val
→
val
→
Prop
)
:
iProp
Σ
:=
((
∃
(
x
:
val
),
p
↦
InjRV
x
★
own
γ
1
(
Excl
()))
∨
((
∃
(
x
:
val
),
p
↦
InjRV
x
★
own
γ
1
(
Excl
())
★
own
γ
3
(
Excl
()))
∨
(
∃
(
x
:
val
),
p
↦
InjLV
x
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
2
(
Excl
()))
∨
(
∃
(
x
y
:
val
),
p
↦
InjRV
y
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
■
Q
x
y
★
own
γ
2
(
Excl
())
★
own
γ
3
(
Excl
()))
∨
(
∃
(
x
y
:
val
),
p
↦
InjRV
y
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
■
Q
x
y
★
own
γ
3
(
Excl
())))
%
I
.
(
∃
(
x
:
val
),
p
↦
InjLV
x
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
5
(
Excl
())
★
own
γ
3
(
Excl
()))
∨
(
∃
(
x
:
val
),
p
↦
InjLV
x
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
5
(
Excl
())
★
own
γ
4
(
Excl
())))
%
I
.
Lemma
srv_inv_timeless
γ
x
γ
1
γ
2
γ
3
p
Q
:
TimelessP
(
srv_inv
γ
x
γ
1
γ
2
γ
3
p
Q
).
Lemma
srv_inv_timeless
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
p
Q
:
TimelessP
(
srv_inv
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
p
Q
).
Proof
.
apply
_.
Qed
.
Proof
.
apply
_.
Qed
.
Lemma
wait_spec
(
Φ
:
val
→
iProp
Σ
)
(
Q
:
val
→
val
→
Prop
)
x
γ
x
γ
1
γ
2
γ
3
p
:
Lemma
wait_spec
(
Φ
:
val
→
iProp
Σ
)
(
Q
:
val
→
val
→
Prop
)
x
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
p
:
heapN
⊥
N
→
heapN
⊥
N
→
heap_ctx
★
inv
N
(
srv_inv
γ
x
γ
1
γ
2
γ
3
p
Q
)
★
heap_ctx
★
inv
N
(
srv_inv
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
p
Q
)
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
1
(
Excl
())
★
own
γ
3
(
Excl
())
★
own
γ
x
((
1
/
2
)
%
Qp
,
DecAgree
x
)
★
own
γ
1
(
Excl
())
★
own
γ
5
(
Excl
())
★
(
∀
y
,
own
γ
1
(
Excl
())
★
own
γ
2
(
Excl
())
-
★
own
γ
x
(
1
%
Qp
,
DecAgree
x
)
-
★
■
Q
x
y
-
★
Φ
y
)
(
∀
y
,
own
γ
2
(
Excl
())
-
★
own
γ
x
(
1
%
Qp
,
DecAgree
x
)
-
★
■
Q
x
y
-
★
Φ
y
)
⊢
WP
wait
#
p
{{
Φ
}}
.
⊢
WP
wait
#
p
{{
Φ
}}
.
Proof
.
Proof
.
iIntros
(
HN
)
"(#Hh & #Hsrv & Hx & Hempty & Hfinished & HΦ)"
.
iIntros
(
HN
)
"(#Hh & #Hsrv & Hx & Hempty & Hfinished & HΦ)"
.
iL
ö
b
as
"IH"
.
iL
ö
b
as
"IH"
.
wp_rec
.
wp_bind
(
!
#
p
)
%
E
.
wp_rec
.
wp_bind
(
!
#
p
)
%
E
.
iInv
N
as
">[Hinv|[Hinv|Hinv]]"
"Hclose"
.
iInv
N
as
">[Hinv|[Hinv|
[
Hinv
|Hinv]
]]"
"Hclose"
.
+
iExFalso
.
iDestruct
"Hinv"
as
(
?
)
"[_ Ho1]"
.
-
iExFalso
.
iDestruct
"Hinv"
as
(
?
)
"[_
[
Ho1
_]
]"
.
iCombine
"Hempty"
"Ho1"
as
"Hempty"
.
iCombine
"Hempty"
"Ho1"
as
"Hempty"
.
by
iDestruct
(
own_valid
with
"Hempty"
)
as
"%"
.
by
iDestruct
(
own_valid
with
"Hempty"
)
as
"%"
.
+
iDestruct
"Hinv"
as
(
x
'
)
"(Hp & Hx' & Hissued)"
.
-
iDestruct
"Hinv"
as
(
x
'
y
'
)
"(Hp & Hx' & % & Ho2 & Ho3)"
.
wp_load
.
destruct
(
decide
(
x
=
x
'
))
as
[
->|
Hneq
].
iVs
(
"Hclose"
with
"[Hp Hx' Hissued]"
).
+
wp_load
.
iVs
(
"Hclose"
with
"[Hp Hx' Ho2 Ho3]"
).
{
iNext
.
iRight
.
iLeft
.
iExists
x
'
.
by
iFrame
.
}
{
iNext
.
rewrite
/
srv_inv
.
iRight
.
iLeft
.
iExists
x
'
,
y
'
.
iVsIntro
.
wp_match
.
by
iApply
(
"IH"
with
"Hx Hempty Hfinished"
).
by
iFrame
.
}
+
iDestruct
"Hinv"
as
(
x
'
y
'
)
"(Hp & Hx' & % & Ho3)"
.
iVsIntro
.
wp_match
.
iCombine
"Hfinished"
"Ho3"
as
"Hfinished"
.
iInv
N
as
">[Hinv|[Hinv|[Hinv|Hinv]]]"
"Hclose"
.
by
iDestruct
(
own_valid
with
"Hfinished"
)
as
"%"
.
*
admit
.
Qed
.
*
iDestruct
"Hinv"
as
(
x
''
y
''
)
"(Hp & Hx'' & % & Ho2 & Ho3)"
.
iVs
(
"Hclose"
with
"[Hp Hempty Ho3]"
).
{
iNext
.
rewrite
/
srv_inv
.
iLeft
.
iExists
y
''
.
by
iFrame
.
}
destruct
(
decide
(
x
'
=
x
''
))
as
[
->|
Hneq
].
{
iCombine
"Hx"
"Hx''"
as
"Hx"
.
iDestruct
(
own_update
with
"Hx"
)
as
"==>Hx"
;
first
by
apply
pair_l_frac_op
.
by
iApply
(
"HΦ"
with
"Ho2 Hx"
).
}
{
admit
.
}
*
admit
.
*
admit
.
+
admit
.
-
admit
.
-
admit
.
Admitted
.
Lemma
mk_srv_spec
(
f
:
val
)
Q
:
Lemma
mk_srv_spec
(
f
:
val
)
Q
:
heapN
⊥
N
→
heapN
⊥
N
→
...
@@ -102,57 +117,85 @@ Section proof.
...
@@ -102,57 +117,85 @@ Section proof.
wp_let
.
wp_alloc
p
as
"Hp"
.
wp_let
.
wp_alloc
p
as
"Hp"
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
1
)
"Hempty"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
1
)
"Hempty"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
2
)
"Hissued"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
2
)
"Hissued"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
3
)
"Hfinished"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
3
)
"Hblack"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
4
)
"Hwhite"
;
first
done
.
iVs
(
own_alloc
(
Excl
()))
as
(
γ
5
)
"Hfinished"
;
first
done
.
iVs
(
own_alloc
(
1
%
Qp
,
DecAgree
#
0
))
as
(
γ
x
)
"Hx"
;
first
done
.
iVs
(
own_alloc
(
1
%
Qp
,
DecAgree
#
0
))
as
(
γ
x
)
"Hx"
;
first
done
.
iVs
(
inv_alloc
N
_
(
srv_inv
γ
x
γ
1
γ
2
γ
3
p
Q
)
with
"[Hp Hempty]"
)
as
"#?"
.
iVs
(
inv_alloc
N
_
(
srv_inv
γ
x
γ
1
γ
2
γ
3
γ
4
γ
5
p
Q
)
with
"[Hp Hempty
Hblack
]"
)
as
"#?"
.
{
iNext
.
rewrite
/
srv_inv
.
iLeft
.
iExists
#
0.
by
iFrame
.
}
{
iNext
.
rewrite
/
srv_inv
.
iLeft
.
iExists
#
0.
by
iFrame
.
}
(
*
iVs
(
inv_alloc
N
_
(
own
γ
3
(
Excl
())
∨
own
γ
4
(
Excl
()))
%
I
with
"[Hwhite]"
)
as
"#Hsinv"
.
*
)
(
*
{
iNext
.
by
iRight
.
}
*
)
wp_let
.
wp_bind
(
newlock
_
).
wp_let
.
wp_bind
(
newlock
_
).
iApply
newlock_spec
=>
//. iFrame "Hh".
iApply
newlock_spec
=>
//. iFrame "Hh".
iAssert
(
∃
x
,
own
γ
x
(
1
%
Qp
,
DecAgree
x
)
★
own
γ
2
(
Excl
())
★
own
γ
3
(
Excl
()))
%
I
with
"[Hissued Hfinished Hx]"
as
"Hinv"
.
iAssert
(
∃
x
,
own
γ
x
(
1
%
Qp
,
DecAgree
x
)
★
own
γ
2
(
Excl
())
★
own
γ
5
(
Excl
()))
%
I
with
"[Hissued Hfinished Hx]"
as
"Hinv"
.
{
iExists
#
0.
by
iFrame
.
}
{
iExists
#
0.
by
iFrame
.
}
iFrame
"Hinv"
.
iIntros
(
lk
γ
lk
)
"#Hlk"
.
iFrame
"Hinv"
.
iIntros
(
lk
γ
lk
)
"#Hlk"
.
wp_let
.
wp_apply
wp_fork
.
wp_let
.
wp_apply
wp_fork
.
iSplit
L
.
iSplit
R
"Hwhite"
.
-
(
*
client
closure
*
)
-
(
*
(
*
client
closure
*
)
*
)
iVsIntro
.
wp_seq
.
iVsIntro
.
(
*
iVsIntro
.
wp_seq
.
iVsIntro
.
*
)
iAlways
.
iIntros
(
x
).
(
*
iAlways
.
iIntros
(
x
).
*
)
wp_let
.
wp_bind
(
acquire
_
).
iApply
acquire_spec
.
(
*
wp_let
.
wp_bind
(
acquire
_
).
iApply
acquire_spec
.
*
)
iFrame
"Hlk"
.
iIntros
"Hlked Ho"
.
(
*
iFrame
"Hlk"
.
iIntros
"Hlked Ho"
.
*
)
iDestruct
"Ho"
as
(
x
'
)
"[Hx [Hissued Hfinished]]"
.
(
*
iDestruct
"Ho"
as
(
x
'
)
"[Hx [Hissued Hfinished]]"
.
*
)
wp_seq
.
wp_bind
(
_
<-
_
)
%
E
.
(
*
wp_seq
.
wp_bind
(
_
<-
_
)
%
E
.
*
)
iInv
N
as
">Hinv"
"Hclose"
.
(
*
iInv
N
as
">Hinv"
"Hclose"
.
*
)
rewrite
/
srv_inv
.
(
*
rewrite
/
srv_inv
.
*
)
iDestruct
"Hinv"
as
"[Hinv|[Hinv|Hinv]]"
.
(
*
iDestruct
"Hinv"
as
"[Hinv|[Hinv|Hinv]]"
.
*
)
+
iDestruct
"Hinv"
as
(
x
''
)
"[Hp Hempty]"
.
(
*
+
iDestruct
"Hinv"
as
(
x
''
)
"[Hp Hempty]"
.
*
)
wp_store
.
(
*
wp_store
.
*
)
iAssert
(
|=
r
=>
own
γ
x
(
1
%
Qp
,
DecAgree
x
))
%
I
with
"[Hx]"
as
"Ho"
.
(
*
iAssert
(
|=
r
=>
own
γ
x
(
1
%
Qp
,
DecAgree
x
))
%
I
with
"[Hx]"
as
"Ho"
.
*
)
{
iDestruct
(
own_update
with
"Hx"
)
as
"Hx"
;
last
by
iAssumption
.
(
*
{
iDestruct
(
own_update
with
"Hx"
)
as
"Hx"
;
last
by
iAssumption
.
*
)
apply
cmra_update_exclusive
.
done
.
}
(
*
apply
cmra_update_exclusive
.
done
.
}
*
)
iVs
"Ho"
.
iDestruct
(
own_update
with
"Ho"
)
as
"==>[Ho1 Ho2]"
;
first
by
apply
pair_l_frac_op
'
.
(
*
iVs
"Ho"
.
iDestruct
(
own_update
with
"Ho"
)
as
"==>[Ho1 Ho2]"
;
first
by
apply
pair_l_frac_op
'
.
*
)
iVs
(
"Hclose"
with
"[Hp Hissued Ho1]"
).
(
*
iVs
(
"Hclose"
with
"[Hp Hissued Ho1]"
).
*
)
{
rewrite
/
locked
.
iNext
.
iRight
.
iLeft
.
(
*
{
rewrite
/
locked
.
iNext
.
iRight
.
iLeft
.
*
)
iExists
x
.
by
iFrame
.
}
(
*
iExists
x
.
by
iFrame
.
}
*
)
iVsIntro
.
wp_seq
.
(
*
iVsIntro
.
wp_seq
.
*
)
wp_bind
(
wait
_
).
(
*
wp_bind
(
wait
_
).
*
)
iApply
(
wait_spec
with
"[Hempty Hfinished Ho2 Hlked]"
);
first
by
done
.
(
*
iApply
(
wait_spec
with
"[Hempty Hfinished Ho2 Hlked]"
);
first
by
done
.
*
)
{
iFrame
"Hh"
.
iFrame
"#"
.
iFrame
.
(
*
{
iFrame
"Hh"
.
iFrame
"#"
.
iFrame
.
*
)
iIntros
(
y3
)
"[Hempty Hissued] Hx %"
.
(
*
iIntros
(
y3
)
"[Hempty Hissued] Hx %"
.
*
)
wp_let
.
wp_bind
(
release
_
).
(
*
wp_let
.
wp_bind
(
release
_
).
*
)
iApply
pvs_wp
.
(
*
iApply
pvs_wp
.
*
)
iInv
N
as
">[Hinv|[Hinv|Hinv]]"
"Hclose"
.
(
*
iInv
N
as
">[Hinv|[Hinv|Hinv]]"
"Hclose"
.
*
)
-
admit
.
(
*
-
admit
.
*
)
-
admit
.
(
*
-
admit
.
*
)
-
iDestruct
"Hinv"
as
(
x4
y4
)
"(Hp & _ & _ & Hfinished)"
.
(
*
-
iDestruct
"Hinv"
as
(
x4
y4
)
"(Hp & _ & _ & Hfinished)"
.
*
)
iVs
(
"Hclose"
with
"[Hp Hempty]"
).
(
*
iVs
(
"Hclose"
with
"[Hp Hempty]"
).
*
)
{
iNext
.
iLeft
.
iExists
y4
.
by
iFrame
.
}
(
*
{
iNext
.
iLeft
.
iExists
y4
.
by
iFrame
.
}
*
)
iApply
release_spec
.
(
*
iApply
release_spec
.
*
)
iFrame
"Hlk Hlked"
.
(
*
iFrame
"Hlk Hlked"
.
*
)
iSplitL
"Hissued Hfinished Hx"
.
(
*
iSplitL
"Hissued Hfinished Hx"
.
*
)
{
iExists
x
.
by
iFrame
.
}
(
*
{
iExists
x
.
by
iFrame
.
}
*
)
by
wp_seq
.
(
*
by
wp_seq
.
*
)
}
(
*
}
*
)
+
admit
.
(
*
+
admit
.
*
)
+
admit
.
(
*
+
admit
.
*
)
admit
.
-
(
*
server
side
*
)
-
(
*
server
side
*
)
iL
ö
b
as
"IH"
.
wp_rec
.
wp_let
.
wp_bind
(
!
_
)
%
E
.
iInv
N
as
">[Hinv|[Hinv|[Hinv|Hinv]]]"
"Hclose"
.
+
iDestruct
"Hinv"
as
(
x
)
"[Hp Hrest]"
.
wp_load
.
iVs
(
"Hclose"
with
"[Hp Hrest]"
).
{
iNext
.
rewrite
/
srv_inv
.
iLeft
.
iExists
x
.
by
iFrame
.
}
iVsIntro
.
wp_match
.
by
iApply
"IH"
.
+
iDestruct
"Hinv"
as
(
x
y
)
"[Hp Hrest]"
.
wp_load
.
iVs
(
"Hclose"
with
"[Hp Hrest]"
).
{
iNext
.
rewrite
/
srv_inv
.
iRight
.
iLeft
.
iExists
x
,
y
.
by
iFrame
.
}
iVsIntro
.
wp_match
.
by
iApply
"IH"
.
+
iDestruct
"Hinv"
as
(
x
)
"(Hp & Hx & Hfinished & Hblack)"
.
wp_load
.
iVs
(
"Hclose"
with
"[Hp Hx Hfinished Hwhite]"
).
{
iNext
.
rewrite
/
srv_inv
.
iRight
.
iRight
.
iRight
.
iExists
x
.
by
iFrame
.
}
iVsIntro
.
wp_match
.
wp_bind
(
_
<-
_
)
%
E
.
iApply
pvs_wp
.
iInv
N
as
">[Hinv|[Hinv|[Hinv|Hinv]]]"
"Hclose"
.
*
admit
.
*
admit
.
*
admit
.
*
iDestruct
"Hinv"
as
(
x
'
)
"(Hp & Hx & Hfinished & Hwhite)"
.
iVs
(
"Hclose"
with
"[Hp Hx Hfinished Hblack]"
).
Admitted
.
Admitted
.
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