Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lambda-rust
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
Service Desk
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
Iris
lambda-rust
Commits
9e8900af
Commit
9e8900af
authored
7 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
switch lock spec to be accessor-based
parent
6e29b5c9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
theories/lang/lib/lock.v
+44
-66
44 additions, 66 deletions
theories/lang/lib/lock.v
theories/lifetime/lifetime.v
+6
-0
6 additions, 0 deletions
theories/lifetime/lifetime.v
with
51 additions
and
66 deletions
_CoqProject
+
1
−
0
View file @
9e8900af
...
@@ -53,6 +53,7 @@ theories/typing/lib/fake_shared_box.v
...
@@ -53,6 +53,7 @@ theories/typing/lib/fake_shared_box.v
theories/typing/lib/cell.v
theories/typing/lib/cell.v
theories/typing/lib/spawn.v
theories/typing/lib/spawn.v
theories/typing/lib/rc.v
theories/typing/lib/rc.v
theories/typing/lib/mutex.v
theories/typing/lib/refcell/refcell.v
theories/typing/lib/refcell/refcell.v
theories/typing/lib/refcell/ref.v
theories/typing/lib/refcell/ref.v
theories/typing/lib/refcell/refmut.v
theories/typing/lib/refcell/refmut.v
...
...
This diff is collapsed.
Click to expand it.
theories/lang/lib/lock.v
+
44
−
66
View file @
9e8900af
...
@@ -22,110 +22,88 @@ Proof. solve_inG. Qed.
...
@@ -22,110 +22,88 @@ Proof. solve_inG. Qed.
Section
proof
.
Section
proof
.
Context
`{
!
lrustG
Σ
,
!
lockG
Σ
}
(
N
:
namespace
)
.
Context
`{
!
lrustG
Σ
,
!
lockG
Σ
}
(
N
:
namespace
)
.
Definition
lockname
:=
(
gname
*
gname
)
%
type
.
Definition
lock_proto
(
γ
:
gname
)
(
l
:
loc
)
(
R
:
iProp
Σ
)
:
iProp
Σ
:=
Definition
lock_inv
(
γ
:
gname
)
(
l
:
loc
)
(
R
:
iProp
Σ
)
:
iProp
Σ
:=
(
∃
b
:
bool
,
l
↦
#
b
∗
if
b
then
True
else
own
γ
(
Excl
())
∗
R
)
%
I
.
(
∃
b
:
bool
,
l
↦
#
b
∗
if
b
then
True
else
own
γ
(
Excl
())
∗
R
)
%
I
.
Definition
is_lock
(
γ
:
lockname
)
(
l
:
loc
)
(
R
:
iProp
Σ
)
:
iProp
Σ
:=
Definition
locked
(
γ
:
gname
):
iProp
Σ
:=
own
γ
(
Excl
())
.
cinv
N
(
γ
.
1
)
(
lock_inv
(
γ
.
2
)
l
R
)
.
Definition
own_lock
(
γ
:
lockname
)
:
frac
→
iProp
Σ
:=
cinv_own
(
γ
.
1
)
.
Definition
locked
(
γ
:
lockname
):
iProp
Σ
:=
own
(
γ
.
2
)
(
Excl
())
.
Global
Instance
lock_inv_ne
γ
l
:
NonExpansive
(
lock_proto
γ
l
)
.
Global
Instance
lock_inv_ne
γ
l
:
NonExpansive
(
lock_inv
γ
l
)
.
Proof
.
solve_proper
.
Qed
.
Proof
.
solve_proper
.
Qed
.
Global
Instance
is_lock_contractive
γ
l
:
Contractive
(
is_lock
γ
l
)
.
Proof
.
solve_contractive
.
Qed
.
Global
Instance
is_lock_ne
γ
l
:
NonExpansive
(
is_lock
γ
l
)
.
Proof
.
exact
:
contractive_ne
.
Qed
.
Global
Instance
is_lock_persistent
γ
l
R
:
PersistentP
(
is_lock
γ
l
R
)
.
Proof
.
apply
_
.
Qed
.
Global
Instance
locked_timeless
γ
:
TimelessP
(
locked
γ
)
.
Global
Instance
locked_timeless
γ
:
TimelessP
(
locked
γ
)
.
Proof
.
apply
_
.
Qed
.
Proof
.
apply
_
.
Qed
.
Lemma
locked_exclusive
(
γ
:
lock
name
)
:
locked
γ
-∗
locked
γ
-∗
False
.
Lemma
locked_exclusive
(
γ
:
g
name
)
:
locked
γ
-∗
locked
γ
-∗
False
.
Proof
.
iIntros
"H1 H2"
.
by
iDestruct
(
own_valid_2
with
"H1 H2"
)
as
%
?
.
Qed
.
Proof
.
iIntros
"H1 H2"
.
by
iDestruct
(
own_valid_2
with
"H1 H2"
)
as
%
?
.
Qed
.
Lemma
is_
lock_iff
γ
l
R
R'
:
Lemma
lock_
proto_
iff
γ
l
R
R'
:
□
▷
(
R
↔
R'
)
-∗
is_
lock
γ
l
R
-∗
is_
lock
γ
l
R'
.
□
(
R
↔
R'
)
-∗
lock
_proto
γ
l
R
-∗
lock
_proto
γ
l
R'
.
Proof
.
Proof
.
iIntros
"#HRR' Hlck"
.
iApply
cinv_iff
;
last
done
.
iNext
.
iAlways
.
iIntros
"#HRR' Hlck"
.
iDestruct
"Hlck"
as
(
b
)
"[Hl HR]"
.
iExists
b
.
iSplit
;
iIntros
"Hinv"
;
iDestruct
"Hinv"
as
(
b
)
"[Hl HR]"
;
iExists
b
;
iFrame
"Hl"
.
destruct
b
;
first
done
.
iDestruct
"HR"
as
"[$ HR]"
.
iFrame
"Hl"
;
(
destruct
b
;
first
done
);
iDestruct
"HR"
as
"[$ HR]"
;
by
iApply
"HRR'"
.
by
iApply
"HRR'"
.
Qed
.
Qed
.
(** The main proofs. *)
(** The main proofs. *)
Lemma
new
lock_
inplac
e
(
E
:
coPset
)
(
R
:
iProp
Σ
)
l
(
b
:
bool
)
:
Lemma
lock_
proto_creat
e
(
E
:
coPset
)
(
R
:
iProp
Σ
)
l
(
b
:
bool
)
:
l
↦
#
b
-∗
(
if
b
then
True
else
▷
R
)
=
{
E
}
=∗
∃
γ
,
is_
lock
γ
l
R
∗
own_lock
γ
1
%
Qp
.
l
↦
#
b
-∗
(
if
b
then
True
else
R
)
=
{
E
}
=∗
∃
γ
,
lock
_proto
γ
l
R
.
Proof
.
Proof
.
iIntros
"Hl HR"
.
iIntros
"Hl HR"
.
iMod
(
own_alloc
(
Excl
()))
as
(
γ
)
"Hγ"
;
first
done
.
iMod
(
own_alloc
(
Excl
()))
as
(
γ
)
"Hγ"
;
first
done
.
iMod
(
cinv_alloc
_
N
(
lock_inv
γ
l
R
)
with
"[-]"
)
as
(
γ'
)
"Hlock"
.
iExists
_,
_
.
iFrame
"Hl"
.
destruct
b
;
first
done
.
by
iFrame
.
{
iExists
b
.
destruct
b
;
by
iFrame
.
}
iModIntro
.
iExists
(_,
_)
.
eauto
.
Qed
.
Lemma
newlock_spec
(
R
:
iProp
Σ
)
:
{{{
▷
R
}}}
newlock
[]
{{{
l
γ
,
RET
#
l
;
is_lock
γ
l
R
∗
own_lock
γ
1
%
Qp
}}}
.
Proof
.
iIntros
(
Φ
)
"HR HΦ"
.
iApply
wp_fupd
.
wp_seq
.
wp_alloc
l
vl
as
"Hl"
"H†"
.
inv_vec
vl
=>
x
.
rewrite
heap_mapsto_vec_singleton
.
(* FIXME shouldn't this also compute now, like bigops do? *)
wp_let
.
wp_write
.
iMod
(
newlock_inplace
with
"Hl HR"
)
as
(
γ
)
"?"
.
by
iApply
"HΦ"
.
Qed
.
Qed
.
Lemma
destroy
_lock
E
γ
l
R
:
Lemma
lock_proto_
destroy
E
γ
l
R
:
↑
N
⊆
E
→
↑
N
⊆
E
→
is_
lock
γ
l
R
-∗
own_lock
γ
1
%
Qp
=
{
E
}
=∗
∃
(
b
:
bool
),
l
↦
#
b
∗
if
b
then
True
else
▷
R
.
lock
_proto
γ
l
R
=
{
E
}
=∗
∃
(
b
:
bool
),
l
↦
#
b
∗
if
b
then
True
else
R
.
Proof
.
Proof
.
iIntros
(?)
"#Hinv Hown"
.
iIntros
(?)
"Hlck"
.
iDestruct
"Hlck"
as
(
b
)
"[Hl HR]"
.
iMod
(
cinv_cancel
with
"Hinv Hown"
)
as
(
b
)
"[>Hl HR]"
;
first
done
.
iExists
b
.
iFrame
"Hl"
.
destruct
b
;
first
done
.
iExists
b
.
destruct
b
;
first
by
eauto
.
iDestruct
"HR"
as
"[_ $]"
.
done
.
iDestruct
"HR"
as
"[_ $]"
.
done
.
Qed
.
Qed
.
Lemma
try_acquire_spec
γ
l
R
q
:
(* At this point, it'd be really nice to have some sugar for symmetric
{{{
is_lock
γ
l
R
∗
own_lock
γ
q
}}}
try_acquire
[
#
l
]
accessors. *)
{{{
b
,
RET
#
b
;
(
if
b
is
true
then
locked
γ
∗
R
else
True
)
∗
own_lock
γ
q
}}}
.
Lemma
try_acquire_spec
E
γ
l
R
P
:
□
(
P
=
{
E
,
∅
}
=∗
lock_proto
γ
l
R
∗
(
lock_proto
γ
l
R
=
{
∅
,
E
}
=∗
P
))
-∗
{{{
P
}}}
try_acquire
[
#
l
]
@
E
{{{
b
,
RET
#
b
;
(
if
b
is
true
then
locked
γ
∗
R
else
True
)
∗
P
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"[Hinv Hown]
HΦ"
.
iIntros
"#Hproto !# * HP
HΦ"
.
wp_rec
.
iMod
(
cinv_open
with
"Hinv Hown"
)
as
"(Hinv & Hown & Hclose)"
;
first
done
.
wp_rec
.
iMod
(
"Hproto"
with
"HP"
)
as
"(Hinv & Hclose)"
.
iDestruct
"Hinv"
as
([])
"[Hl HR]"
.
iDestruct
"Hinv"
as
([])
"[Hl HR]"
.
-
wp_apply
(
wp_cas_int_fail
with
"Hl"
);
[
done
..|]
.
iIntros
"Hl"
.
-
wp_apply
(
wp_cas_int_fail
with
"Hl"
);
[
done
..|]
.
iIntros
"Hl"
.
iMod
(
"Hclose"
with
"[Hl]"
);
first
(
iNext
;
iExists
true
;
eauto
)
.
iMod
(
"Hclose"
with
"[Hl]"
);
first
(
iExists
true
;
by
eauto
)
.
iModIntro
.
iApply
(
"HΦ"
$!
false
)
.
auto
.
iModIntro
.
iApply
(
"HΦ"
$!
false
)
.
auto
.
-
wp_apply
(
wp_cas_int_suc
with
"Hl"
);
[
done
..|]
.
iIntros
"Hl"
.
-
wp_apply
(
wp_cas_int_suc
with
"Hl"
);
[
done
..|]
.
iIntros
"Hl"
.
iDestruct
"HR"
as
"[Hγ HR]"
.
iDestruct
"HR"
as
"[Hγ HR]"
.
iMod
(
"Hclose"
with
"[Hl]"
);
first
(
iNext
;
iExists
true
;
eauto
)
.
iMod
(
"Hclose"
with
"[Hl]"
)
as
"HP"
;
first
(
iExists
true
;
by
eauto
)
.
iModIntro
.
rewrite
/
locked
.
iApply
(
"HΦ"
$!
true
with
"[$Hγ $HR $H
own
]"
)
.
iModIntro
.
rewrite
/
locked
.
iApply
(
"HΦ"
$!
true
with
"[$Hγ $HR $H
P
]"
)
.
Qed
.
Qed
.
Lemma
acquire_spec
γ
l
R
q
:
Lemma
acquire_spec
E
γ
l
R
P
:
{{{
is_lock
γ
l
R
∗
own_lock
γ
q
}}}
acquire
[
#
l
]
□
(
P
=
{
E
,
∅
}
=∗
lock_proto
γ
l
R
∗
(
lock_proto
γ
l
R
=
{
∅
,
E
}
=∗
P
))
-∗
{{{
RET
#
();
locked
γ
∗
R
∗
own_lock
γ
q
}}}
.
{{{
P
}}}
acquire
[
#
l
]
@
E
{{{
RET
#
();
locked
γ
∗
R
∗
P
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"[#Hinv Hown] HΦ"
.
iLöb
as
"IH"
.
wp_rec
.
iIntros
"#Hproto !# * HP HΦ"
.
iLöb
as
"IH"
.
wp_rec
.
wp_apply
(
try_acquire_spec
with
"[$Hinv $Hown]"
)
.
iIntros
([])
.
iPoseProof
(
try_acquire_spec
with
"[Hproto] * HP"
)
as
"Hacq"
.
{
iFrame
"Hproto"
.
(* FIXME: Just saying "Hproto" in the pattern above should work. *)
}
wp_apply
"Hacq"
.
(* FIXME: Using `(try_acquire_spec with "[Hproto] * HP")` to avoid the
iPoseProof should work. *)
iIntros
([])
.
-
iIntros
"[[Hlked HR] Hown]"
.
wp_if
.
iApply
"HΦ"
;
iFrame
.
-
iIntros
"[[Hlked HR] Hown]"
.
wp_if
.
iApply
"HΦ"
;
iFrame
.
-
iIntros
"[_ Hown]"
.
wp_if
.
iApply
(
"IH"
with
"Hown [HΦ]"
)
.
auto
.
-
iIntros
"[_ Hown]"
.
wp_if
.
iApply
(
"IH"
with
"Hown [HΦ]"
)
.
auto
.
Qed
.
Qed
.
Lemma
release_spec
γ
l
R
q
:
Lemma
release_spec
E
γ
l
R
P
:
{{{
is_lock
γ
l
R
∗
lock
ed
γ
∗
R
∗
own_lock
γ
q
}}}
release
[
#
l
]
□
(
P
=
{
E
,
∅
}
=∗
lock_proto
γ
l
R
∗
(
lock
_proto
γ
l
R
=
{
∅
,
E
}
=∗
P
))
-∗
{{{
RET
#
();
own_lock
γ
q
}}}
.
{{{
locked
γ
∗
R
∗
P
}}}
release
[
#
l
]
@
E
{{{
RET
#
();
P
}}}
.
Proof
.
Proof
.
iIntros
(
Φ
)
"(Hinv & Hlocked & HR & Hown) HΦ"
.
iIntros
"#Hproto !# * (Hlocked & HR & HP) HΦ"
.
wp_let
.
rewrite
/
release
/=.
wp_let
.
iMod
(
"Hproto"
with
"HP"
)
as
"(Hinv & Hclose)"
.
iMod
(
cinv_open
with
"Hinv Hown"
)
as
"(Hinv & Hown & Hclose)"
;
first
done
.
iDestruct
"Hinv"
as
(
b
)
"[? _]"
.
wp_write
.
iApply
"HΦ"
.
iDestruct
"Hinv"
as
(
b
)
"[? _]"
.
wp_write
.
iApply
"HΦ"
.
iFrame
"Hown"
.
iApply
"Hclose"
.
iExists
false
.
by
iFrame
.
iApply
"Hclose"
.
iNext
.
iExists
false
.
by
iFrame
.
Qed
.
Qed
.
End
proof
.
End
proof
.
Typeclasses
Opaque
is_
lock
locked
.
Typeclasses
Opaque
lock
_proto
locked
.
This diff is collapsed.
Click to expand it.
theories/lifetime/lifetime.v
+
6
−
0
View file @
9e8900af
...
@@ -55,6 +55,12 @@ Proof.
...
@@ -55,6 +55,12 @@ Proof.
iMod
(
bor_exists
(
A
:=
bool
)
with
"LFT H"
)
as
([])
"H"
;
auto
.
iMod
(
bor_exists
(
A
:=
bool
)
with
"LFT H"
)
as
([])
"H"
;
auto
.
Qed
.
Qed
.
Lemma
bor_iff_proper
κ
P
P'
:
▷
□
(
P
↔
P'
)
-∗
□
(
&
{
κ
}
P
↔
&
{
κ
}
P'
)
.
Proof
.
iIntros
"#HP !#"
.
iSplit
;
iIntros
"?"
;
iApply
bor_iff
;
try
done
.
iNext
.
iAlways
.
iSplit
;
iIntros
"?"
;
iApply
"HP"
;
done
.
Qed
.
Lemma
bor_later
E
κ
P
:
Lemma
bor_later
E
κ
P
:
↑
lftN
⊆
E
→
↑
lftN
⊆
E
→
lft_ctx
-∗
&
{
κ
}(
▷
P
)
=
{
E
,
E
∖↑
lftN
}
▷=∗
&
{
κ
}
P
.
lft_ctx
-∗
&
{
κ
}(
▷
P
)
=
{
E
,
E
∖↑
lftN
}
▷=∗
&
{
κ
}
P
.
...
...
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