Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
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
Package Registry
Model registry
Operate
Terraform modules
Monitor
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
Pierre Roux
Iris
Commits
c9169b9d
Commit
c9169b9d
authored
2 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
add proof that TaDA-style lock can be derived from standard CAP-style lock
parent
949ab7bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
iris_heap_lang/lib/logatom_lock.v
+85
-0
85 additions, 0 deletions
iris_heap_lang/lib/logatom_lock.v
with
86 additions
and
0 deletions
_CoqProject
+
1
−
0
View file @
c9169b9d
...
@@ -174,6 +174,7 @@ iris_heap_lang/lib/increment.v
...
@@ -174,6 +174,7 @@ iris_heap_lang/lib/increment.v
iris_heap_lang/lib/diverge.v
iris_heap_lang/lib/diverge.v
iris_heap_lang/lib/arith.v
iris_heap_lang/lib/arith.v
iris_heap_lang/lib/array.v
iris_heap_lang/lib/array.v
iris_heap_lang/lib/logatom_lock.v
iris_staging/algebra/list.v
iris_staging/algebra/list.v
iris_staging/base_logic/algebra.v
iris_staging/base_logic/algebra.v
...
...
This diff is collapsed.
Click to expand it.
iris_heap_lang/lib/logatom_lock.v
0 → 100644
+
85
−
0
View file @
c9169b9d
(** A TaDA-style logically atomic specification for a lock, derived for an
arbitrary implementation of the lock interfacne. The opposite direction
could also be derived rather easily, as shown in the TaDA paper.
In essence, this is an instance of the general fact that 'invariant-based'
("HoCAP-style") logically atomic specifications are equivalent to TaDA-style
logically atomic specifications; see
<https://gitlab.mpi-sws.org/iris/examples/-/blob/master/theories/logatom/elimination_stack/hocap_spec.v>
for that being worked out and explained in more detail for a stack specification.
*)
From
iris
.
proofmode
Require
Import
proofmode
.
From
iris
.
base_logic
.
lib
Require
Import
ghost_var
.
From
iris
.
program_logic
Require
Export
atomic
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
atomic_heap
lock
.
From
iris
.
prelude
Require
Import
options
.
Inductive
state
:=
Free
|
Locked
.
Class
lockG
Σ
:=
LockG
{
lock_tokG
:
ghost_varG
Σ
state
}
.
Local
Existing
Instance
lock_tokG
.
Definition
lockΣ
:
gFunctors
:=
#
[
ghost_varΣ
state
]
.
Global
Instance
subG_lockΣ
{
Σ
}
:
subG
lockΣ
Σ
→
lockG
Σ
.
Proof
.
solve_inG
.
Qed
.
Section
tada
.
Context
`{
!
heapGS
Σ
,
!
lockG
Σ
}
(
l
:
lock
)
.
Record
tada_lock_name
:=
TadaLockName
{
tada_lock_name_state
:
gname
;
tada_lock_name_lock
:
l
.(
name
);
}
.
Definition
tada_lock_state
(
γ
:
tada_lock_name
)
(
s
:
state
)
:
iProp
Σ
:=
ghost_var
γ
.(
tada_lock_name_state
)
(
1
/
2
)
s
∗
if
s
is
Locked
then
l
.(
locked
)
γ
.(
tada_lock_name_lock
)
∗
ghost_var
γ
.(
tada_lock_name_state
)
(
1
/
2
)
Locked
else
True
.
Definition
tada_is_lock
(
γ
:
tada_lock_name
)
(
lk
:
val
)
:
iProp
Σ
:=
l
.(
is_lock
)
γ
.(
tada_lock_name_lock
)
lk
(
ghost_var
γ
.(
tada_lock_name_state
)
(
1
/
2
)
Free
)
.
Lemma
newlock_tada_spec
:
{{{
True
}}}
l
.(
newlock
)
#
()
{{{
lk
γ
,
RET
lk
;
tada_is_lock
γ
lk
∗
tada_lock_state
γ
Free
}}}
.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
iMod
(
ghost_var_alloc
Free
)
as
(
γvar
)
"[Hvar1 Hvar2]"
.
wp_apply
(
l
.(
newlock_spec
)
with
"Hvar2"
)
.
iIntros
(
lk
γlock
)
"Hlock"
.
iApply
(
"HΦ"
$!
lk
(
TadaLockName
_
_))
.
iFrame
.
Qed
.
Lemma
acquire_tada_spec
γ
lk
:
tada_is_lock
γ
lk
-∗
<<<
∀∀
s
,
tada_lock_state
γ
s
>>>
l
.(
acquire
)
lk
@
∅
<<<
tada_lock_state
γ
Locked
,
RET
#
()
>>>.
Proof
.
iIntros
"#Hislock %Φ AU"
.
iApply
wp_fupd
.
wp_apply
(
l
.(
acquire_spec
)
with
"Hislock"
)
.
iIntros
"[Hlocked Hvar1]"
.
iMod
"AU"
as
(
s
)
"[[Hvar2 _] [_ Hclose]]"
.
iDestruct
(
ghost_var_agree
with
"Hvar1 Hvar2"
)
as
%<-.
iMod
(
ghost_var_update_halves
Locked
with
"Hvar1 Hvar2"
)
as
"[Hvar1 Hvar2]"
.
iMod
(
"Hclose"
with
"[$Hvar2 $Hlocked $Hvar1]"
)
.
done
.
Qed
.
Lemma
release_tada_spec
γ
lk
:
tada_is_lock
γ
lk
-∗
<<<
tada_lock_state
γ
Locked
>>>
l
.(
release
)
lk
@
∅
<<<
tada_lock_state
γ
Free
,
RET
#
()
>>>.
Proof
.
iIntros
"#Hislock %Φ AU"
.
iApply
fupd_wp
.
iMod
"AU"
as
"[[Hvar1 [Hlocked Hvar2]] [_ Hclose]]"
.
iMod
(
ghost_var_update_halves
Free
with
"Hvar1 Hvar2"
)
as
"[Hvar1 Hvar2]"
.
iMod
(
"Hclose"
with
"[$Hvar2]"
)
.
iModIntro
.
wp_apply
(
l
.(
release_spec
)
with
"[$Hislock $Hlocked $Hvar1]"
)
.
auto
.
Qed
.
End
tada
.
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