Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
examples
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iris
examples
Commits
e72057ce
Commit
e72057ce
authored
Jun 11, 2019
by
Ralf Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
have a dedicated spec file for cinc, and show that we have an instance
parent
0c530c68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
29 deletions
+95
-29
_CoqProject
_CoqProject
+2
-1
cinc.v
theories/logatom/conditional_increment/cinc.v
+43
-28
spec.v
theories/logatom/conditional_increment/spec.v
+50
-0
No files found.
_CoqProject
View file @
e72057ce
...
...
@@ -91,7 +91,6 @@ theories/hocap/lib/oneshot.v
theories/hocap/concurrent_runners.v
theories/hocap/parfib.v
theories/logatom/cinc.v
theories/logatom/treiber.v
theories/logatom/treiber2.v
theories/logatom/elimination_stack/hocap_spec.v
...
...
@@ -105,3 +104,5 @@ theories/logatom/flat_combiner/atomic_sync.v
theories/logatom/flat_combiner/misc.v
theories/logatom/snapshot/spec.v
theories/logatom/snapshot/atomic_snapshot.v
theories/logatom/conditional_increment/spec.v
theories/logatom/conditional_increment/cinc.v
theories/logatom/cinc.v
→
theories/logatom/c
onditional_increment/c
inc.v
View file @
e72057ce
...
...
@@ -3,6 +3,7 @@ From iris.base_logic.lib Require Export invariants.
From
iris
.
program_logic
Require
Export
atomic
.
From
iris
.
proofmode
Require
Import
tactics
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
iris_examples
.
logatom
.
conditional_increment
Require
Import
spec
.
Import
uPred
bi
List
Decidable
.
Set
Default
Proof
Using
"Type"
.
...
...
@@ -144,8 +145,8 @@ Section conditional_counter.
by
apply
auth_update
,
option_local_update
,
exclusive_local_update
.
Qed
.
Definition
counter_content
(
γ
s
:
gname
*
gname
)
(
c
:
bool
*
Z
)
:=
(
own
γ
s
.
1
(
◯
Excl'
c
.
1
)
∗
own
γ
s
.
2
(
◯
Excl'
c
.
2
))%
I
.
Definition
counter_content
(
γ
s
:
gname
*
gname
)
(
b
:
bool
)
(
n
:
Z
)
:=
(
own
γ
s
.
1
(
◯
Excl'
b
)
∗
own
γ
s
.
2
(
◯
Excl'
n
))%
I
.
(** Definition of the invariant *)
...
...
@@ -206,8 +207,8 @@ Section conditional_counter.
∨
own
γ
_s
(
Cinr
$
to_agree
())
∗
done_state
Q
l
l_ghost_winner
γ
_t
))%
I
.
Definition
pau
P
Q
γ
s
:=
(
▷
P
-
∗
◇
AU
<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
(
b
,
n
)
>>
@
⊤∖↑
N
,
∅
<<
counter_content
γ
s
(
b
,
(
if
b
then
n
+
1
else
n
)
),
COMM
Q
>>)%
I
.
(
▷
P
-
∗
◇
AU
<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>
@
⊤∖↑
N
,
∅
<<
counter_content
γ
s
b
(
if
b
then
n
+
1
else
n
),
COMM
Q
>>)%
I
.
Definition
counter_inv
γ
_b
γ
_n
f
c
:=
(
∃
(
b
:
bool
)
(
l
:
loc
)
(
q
:
Qp
)
(
s
:
abstract_state
),
...
...
@@ -235,10 +236,16 @@ Section conditional_counter.
Global
Instance
is_counter_persistent
γ
s
ctr
:
Persistent
(
is_counter
γ
s
ctr
)
:=
_.
Global
Instance
counter_content_timeless
γ
s
ctr
:
Timeless
(
counter_content
γ
s
ctr
)
:=
_.
Global
Instance
counter_content_timeless
γ
s
b
n
:
Timeless
(
counter_content
γ
s
b
n
)
:=
_.
Global
Instance
abstract_state_inhabited
:
Inhabited
abstract_state
:=
populate
(
injl
0
).
Lemma
counter_content_exclusive
γ
s
f1
c1
f2
c2
:
counter_content
γ
s
f1
c1
-
∗
counter_content
γ
s
f2
c2
-
∗
False
.
Proof
.
iIntros
"[Hb1 _] [Hb2 _]"
.
iDestruct
(
own_valid_2
with
"Hb1 Hb2"
)
as
%?.
done
.
Qed
.
(** A few more helper lemmas that will come up later *)
...
...
@@ -457,14 +464,14 @@ Section conditional_counter.
(** ** Proof of [cinc] *)
Lemma
cinc_spec
c
f
γ
s
:
is_counter
γ
s
(
f
,
c
)
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
(
b
,
n
)
>>>
cinc
(
f
,
c
)%
V
@
⊤∖↑
N
<<<
counter_content
γ
s
(
b
,
if
b
then
n
+
1
else
n
),
RET
#()
>>>.
Lemma
cinc_spec
γ
s
v
:
is_counter
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
cinc
v
@
⊤∖↑
N
<<<
counter_content
γ
s
b
(
if
b
then
n
+
1
else
n
),
RET
#()
>>>.
Proof
.
iIntros
"#InvC"
.
iDestruct
"InvC"
as
(
γ
_b
γ
_n
f_l
c_l
)
"[Heq InvC]"
.
iDestruct
"Heq"
as
%[->
[=->->]
].
iIntros
(
Φ
)
"AU"
.
iL
ö
b
as
"IH"
.
iDestruct
"Heq"
as
%[->
->
].
iIntros
(
Φ
)
"AU"
.
iL
ö
b
as
"IH"
.
wp_lam
.
wp_proj
.
wp_let
.
wp_proj
.
wp_let
.
wp_bind
(!_)%
E
.
iInv
counterN
as
(
b'
l'
q
s
)
"(>Hf & >Hc & >[Hl Hl'] & >Hb● & >Hltok & Hrest)"
.
wp_load
.
destruct
s
as
[
n
|
n
p
].
...
...
@@ -518,7 +525,7 @@ Section conditional_counter.
Lemma
new_counter_spec
:
{{{
True
}}}
new_counter
#()
{{{
ctr
γ
s
,
RET
ctr
;
is_counter
γ
s
ctr
∗
counter_content
γ
s
(
true
,
0
)
}}}.
{{{
ctr
γ
s
,
RET
ctr
;
is_counter
γ
s
ctr
∗
counter_content
γ
s
true
0
}}}.
Proof
.
iIntros
(
Φ
)
"_ HΦ"
.
wp_lam
.
wp_apply
wp_fupd
.
wp_apply
(
loc_token_alloc
with
"[//]"
);
iIntros
(
l_n
)
"[Hl_n Hltok]"
.
...
...
@@ -537,15 +544,14 @@ Section conditional_counter.
iSplitR
;
last
by
iFrame
.
iExists
γ
_b
,
γ
_n
,
l_f
,
l_c
.
iSplit
;
done
.
Qed
.
Lemma
set_flag_spec
γ
s
f
c
(
new_b
:
bool
)
:
is_counter
γ
s
(
f
,
c
)
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
(
b
,
n
)
>>>
set_flag
(
f
,
c
)%
V
#
new_b
@
⊤∖↑
N
<<<
counter_content
γ
s
(
new_b
,
n
)
,
RET
#()
>>>.
Lemma
set_flag_spec
γ
s
v
(
new_b
:
bool
)
:
is_counter
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
set_flag
v
#
new_b
@
⊤∖↑
N
<<<
counter_content
γ
s
new_b
n
,
RET
#()
>>>.
Proof
.
iIntros
"#InvC"
(
Φ
)
"AU"
.
wp_lam
.
wp_let
.
wp_proj
.
iDestruct
"InvC"
as
(
γ
_b
γ
_n
l_f
l_c
)
"[[HEq1 HEq2] InvC]"
.
iDestruct
"HEq1"
as
%->.
iDestruct
"HEq2"
as
%
HEq
.
inversion
HEq
;
subst
;
clear
HEq
.
iIntros
"#InvC"
(
Φ
)
"AU"
.
iDestruct
"InvC"
as
(
γ
_b
γ
_n
f_l
c_l
)
"[Heq InvC]"
.
iDestruct
"Heq"
as
%[->
->].
wp_lam
.
wp_let
.
wp_proj
.
iInv
counterN
as
(
b
c
q
s
)
"(>Hf & >Hc & >[Hl Hl'] & >Hb● & >Hltok & Hrest)"
.
iMod
"AU"
as
(
b'
n'
)
"[[Hb◯ Hn◯] [_ Hclose]]"
;
simpl
.
wp_store
.
...
...
@@ -556,15 +562,14 @@ Section conditional_counter.
iNext
.
iExists
new_b
,
c
,
q
,
_.
iFrame
.
done
.
Qed
.
Lemma
get_spec
γ
s
f
c
:
is_counter
γ
s
(
f
,
c
)
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
(
b
,
n
)
>>>
get
(
f
,
c
)%
V
@
⊤∖↑
N
<<<
counter_content
γ
s
(
b
,
n
)
,
RET
#
n
>>>.
Lemma
get_spec
γ
s
v
:
is_counter
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
get
v
@
⊤∖↑
N
<<<
counter_content
γ
s
b
n
,
RET
#
n
>>>.
Proof
.
iIntros
"#InvC"
(
Φ
)
"AU"
.
iL
ö
b
as
"IH"
.
wp_lam
.
repeat
(
wp_proj
;
wp_let
).
wp_bind
(!
_)%
E
.
iDestruct
"InvC"
as
(
γ
_b
γ
_n
l_f
l_c
)
"[[HEq1 HEq2] InvC]"
.
iDestruct
"HEq1"
as
%->.
iDestruct
"HEq2"
as
%
HEq
.
inversion
HEq
;
subst
.
iIntros
"#InvC"
(
Φ
)
"AU"
.
iDestruct
"InvC"
as
(
γ
_b
γ
_n
f_l
c_l
)
"[Heq InvC]"
.
iDestruct
"Heq"
as
%[->
->].
iL
ö
b
as
"IH"
.
wp_lam
.
repeat
(
wp_proj
;
wp_let
).
wp_bind
(!
_)%
E
.
iInv
counterN
as
(
b
c
q
s
)
"(>Hf & >Hc & >[Hl Hl'] & >Hb● & >Hltok & Hrest)"
.
wp_load
.
destruct
s
as
[
n
|
n
p
].
...
...
@@ -586,3 +591,13 @@ Section conditional_counter.
Qed
.
End
conditional_counter
.
Definition
atomic_cinc
`
{!
heapG
Σ
,
cincG
Σ
}
:
spec
.
atomic_cinc
Σ
:=
{|
spec
.
new_counter_spec
:=
new_counter_spec
;
spec
.
cinc_spec
:=
cinc_spec
;
spec
.
set_flag_spec
:=
set_flag_spec
;
spec
.
get_spec
:=
get_spec
;
spec
.
counter_content_exclusive
:=
counter_content_exclusive
|}.
Typeclasses
Opaque
counter_content
is_counter
.
theories/logatom/conditional_increment/spec.v
0 → 100644
View file @
e72057ce
From
stdpp
Require
Import
namespaces
.
From
iris
.
heap_lang
Require
Export
lifting
notation
.
From
iris
.
program_logic
Require
Export
atomic
.
Set
Default
Proof
Using
"Type"
.
(** A general logically atomic interface for conditional increment. *)
Record
atomic_cinc
{
Σ
}
`
{!
heapG
Σ
}
:=
AtomicCinc
{
(* -- operations -- *)
new_counter
:
val
;
cinc
:
val
;
set_flag
:
val
;
get
:
val
;
(* -- other data -- *)
name
:
Type
;
name_eqdec
:
EqDecision
name
;
name_countable
:
Countable
name
;
(* -- predicates -- *)
is_counter
(
N
:
namespace
)
(
γ
s
:
name
)
(
v
:
val
)
:
iProp
Σ
;
counter_content
(
γ
s
:
name
)
(
flag
:
bool
)
(
c
:
Z
)
:
iProp
Σ
;
(* -- predicate properties -- *)
is_counter_persistent
N
γ
s
v
:
Persistent
(
is_counter
N
γ
s
v
);
counter_content_timeless
γ
s
f
c
:
Timeless
(
counter_content
γ
s
f
c
);
counter_content_exclusive
γ
s
f1
c1
f2
c2
:
counter_content
γ
s
f1
c1
-
∗
counter_content
γ
s
f2
c2
-
∗
False
;
(* -- operation specs -- *)
new_counter_spec
N
:
{{{
True
}}}
new_counter
#()
{{{
ctr
γ
s
,
RET
ctr
;
is_counter
N
γ
s
ctr
∗
counter_content
γ
s
true
0
}}};
cinc_spec
N
γ
s
v
:
is_counter
N
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
cinc
v
@
⊤∖↑
N
<<<
counter_content
γ
s
b
(
if
b
then
n
+
1
else
n
),
RET
#()
>>>;
set_flag_spec
N
γ
s
v
(
new_b
:
bool
)
:
is_counter
N
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
set_flag
v
#
new_b
@
⊤∖↑
N
<<<
counter_content
γ
s
new_b
n
,
RET
#()
>>>;
get_spec
N
γ
s
v
:
is_counter
N
γ
s
v
-
∗
<<<
∀
(
b
:
bool
)
(
n
:
Z
),
counter_content
γ
s
b
n
>>>
get
v
@
⊤∖↑
N
<<<
counter_content
γ
s
b
n
,
RET
#
n
>>>;
}.
Arguments
atomic_cinc
_
{_}.
Existing
Instances
is_counter_persistent
counter_content_timeless
name_countable
name_eqdec
.
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