Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Paolo G. Giarrusso
examples
Commits
0247cec5
Commit
0247cec5
authored
Jul 06, 2018
by
Ralf Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
concurrent stacks: also unify concurrent bag (per-element) specs for stacks 1 and 2
parent
68473b43
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
22 deletions
+58
-22
theories/concurrent_stacks/concurrent_stack1.v
theories/concurrent_stacks/concurrent_stack1.v
+16
-6
theories/concurrent_stacks/concurrent_stack2.v
theories/concurrent_stacks/concurrent_stack2.v
+11
-1
theories/concurrent_stacks/concurrent_stack3.v
theories/concurrent_stacks/concurrent_stack3.v
+9
-8
theories/concurrent_stacks/concurrent_stack4.v
theories/concurrent_stacks/concurrent_stack4.v
+9
-7
theories/concurrent_stacks/spec.v
theories/concurrent_stacks/spec.v
+13
-0
No files found.
theories/concurrent_stacks/concurrent_stack1.v
View file @
0247cec5
...
...
@@ -5,6 +5,9 @@ From iris.program_logic Require Export weakestpre hoare.
From
iris
.
heap_lang
Require
Export
lang
.
From
iris
.
algebra
Require
Import
agree
list
.
From
iris
.
heap_lang
Require
Import
assert
proofmode
notation
.
From
iris_examples
.
concurrent_stacks
Require
Import
spec
.
Set
Default
Proof
Using
"Type"
.
(** Stack 1: No helping, bag spec. *)
...
...
@@ -14,10 +17,10 @@ Definition mk_stack : val :=
let
:
"r"
:
=
ref
NONEV
in
(
rec
:
"pop"
"n"
:
=
match
:
!
"r"
with
NONE
=>
#-
1
NONE
=>
NONE
|
SOME
"hd"
=>
if
:
CAS
"r"
(
SOME
"hd"
)
(
Snd
!
"hd"
)
then
Fst
!
"hd"
then
SOME
(
Fst
!
"hd"
)
else
"pop"
"n"
end
,
rec
:
"push"
"n"
:
=
...
...
@@ -81,8 +84,8 @@ Section stacks.
(* Per-element invariant (i.e., bag spec). *)
Theorem
stack_works
P
Φ
:
(
∀
(
f
₁
f
₂
:
val
),
(
∀
(
v
:
val
),
□
WP
f
₁
#()
{{
v
,
P
v
∨
v
≡
#-
1
}})
▷
(
∀
(
f
₁
f
₂
:
val
),
(
□
WP
f
₁
#()
{{
v
,
(
∃
v'
,
v
≡
SOMEV
v'
∗
P
v
'
)
∨
v
≡
NONEV
}})
-
∗
(
∀
(
v
:
val
),
□
(
P
v
-
∗
WP
f
₂
v
{{
v
,
True
}}))
-
∗
Φ
(
f
₁
,
f
₂
)%
V
)%
I
-
∗
WP
mk_stack
#()
{{
Φ
}}.
...
...
@@ -98,7 +101,7 @@ Section stacks.
wp_let
.
iModIntro
.
iApply
"HΦ"
.
-
iIntros
(
v
)
"!#"
.
-
iIntros
"!#"
.
iL
ö
b
as
"IH"
.
wp_rec
.
wp_bind
(!
#
l
)%
E
.
...
...
@@ -129,7 +132,7 @@ Section stacks.
wp_if
.
wp_load
.
wp_proj
.
iLeft
;
auto
.
e
auto
.
*
simpl
in
Hne
.
wp_cas_fail
.
iMod
(
"Hclose"
with
"[Hl'' Hstack]"
).
{
iExists
v''
;
iFrame
;
auto
.
}
...
...
@@ -172,3 +175,10 @@ Section stacks.
done
.
Qed
.
End
stacks
.
Program
Definition
is_concurrent_bag
`
{!
heapG
Σ
}
:
concurrent_bag
Σ
:
=
{|
spec
.
mk_bag
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(???
P
Φ
)
"_ HΦ"
.
iApply
stack_works
.
iNext
.
iIntros
(
f
₁
f
₂
)
"Hpop Hpush"
.
iApply
"HΦ"
.
iFrame
.
Qed
.
theories/concurrent_stacks/concurrent_stack2.v
View file @
0247cec5
...
...
@@ -3,6 +3,9 @@ stricter CAS requirements yet. *)
From
iris
.
program_logic
Require
Export
weakestpre
hoare
.
From
iris
.
heap_lang
Require
Export
lang
proofmode
notation
.
From
iris
.
algebra
Require
Import
excl
.
From
iris_examples
.
concurrent_stacks
Require
Import
spec
.
Set
Default
Proof
Using
"Type"
.
(** Stack 2: With helping, bag spec. *)
...
...
@@ -268,7 +271,7 @@ Section stack_works.
(* Per-element invariant (i.e., bag spec). *)
Theorem
stack_works
{
channelG0
:
channelG
Σ
}
P
Φ
:
(
∀
(
f
₁
f
₂
:
val
),
▷
(
∀
(
f
₁
f
₂
:
val
),
(
□
WP
f
₁
#()
{{
v
,
(
∃
(
v'
:
val
),
v
≡
SOMEV
v'
∗
P
v'
)
∨
v
≡
NONEV
}})
-
∗
(
∀
(
v
:
val
),
□
(
P
v
-
∗
WP
f
₂
v
{{
v
,
True
}}))
-
∗
Φ
(
f
₁
,
f
₂
)%
V
)%
I
...
...
@@ -405,3 +408,10 @@ Section stack_works.
done
.
Qed
.
End
stack_works
.
Program
Definition
is_concurrent_bag
`
{!
heapG
Σ
,
!
channelG
Σ
}
:
concurrent_bag
Σ
:
=
{|
spec
.
mk_bag
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(????
P
Φ
)
"_ HΦ"
.
iApply
stack_works
.
iNext
.
iIntros
(
f
₁
f
₂
)
"Hpop Hpush"
.
iApply
"HΦ"
.
iFrame
.
Qed
.
theories/concurrent_stacks/concurrent_stack3.v
View file @
0247cec5
From
iris
.
program_logic
Require
Export
weakestpre
hoare
.
From
iris
.
heap_lang
Require
Export
lang
proofmode
notation
.
From
iris
.
algebra
Require
Import
excl
.
Set
Default
Proof
Using
"Type"
.
From
iris_examples
.
concurrent_stacks
Require
Import
spec
.
Set
Default
Proof
Using
"Type"
.
(** Stack 3: No helping, view-shift spec. *)
Definition
mk_stack
:
val
:
=
...
...
@@ -213,11 +214,11 @@ Section stack_works.
wp_if
.
iApply
(
"IH"
with
"Hpush"
).
Qed
.
Program
Definition
is_concurrent_stack
:
concurrent_stack
Σ
:
=
{|
spec
.
mk_stack
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(?????
Φ
)
"HP HΦ"
.
iApply
(
stack_works
with
"[HΦ] HP"
).
iNext
.
iIntros
(
f
₁
f
₂
)
"Hpop Hpush"
.
iApply
"HΦ"
.
iFrame
.
Qed
.
End
stack_works
.
Program
Definition
is_concurrent_stack
`
{!
heapG
Σ
}
:
concurrent_stack
Σ
:
=
{|
spec
.
mk_stack
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(???????
Φ
)
"HP HΦ"
.
iApply
(
stack_works
with
"[HΦ] HP"
).
iNext
.
iIntros
(
f
₁
f
₂
)
"Hpop Hpush"
.
iApply
"HΦ"
.
iFrame
.
Qed
.
theories/concurrent_stacks/concurrent_stack4.v
View file @
0247cec5
...
...
@@ -6,6 +6,8 @@ From iris.algebra Require Import excl.
From
iris_examples
.
concurrent_stacks
Require
Import
spec
.
Set
Default
Proof
Using
"Type"
.
(** Stack 3: Helping, view-shift spec. *)
Definition
mk_offer
:
val
:
=
...
...
@@ -620,11 +622,11 @@ Section stack_works.
wp_cas_fail
.
by
iDestruct
(
own_valid_2
with
"Hγ Hγ'"
)
as
%?.
Qed
.
Program
Definition
is_concurrent_stack
`
{!
channelG
Σ
}
:
concurrent_stack
Σ
:
=
{|
spec
.
mk_stack
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(??????
Φ
)
"HP HΦ"
.
iApply
(
stack_works
with
"[HΦ] HP"
).
iNext
.
iIntros
(
f
₁
f
₂
)
"#[Hpop Hpush]"
.
iApply
"HΦ"
.
iFrame
"#"
.
Qed
.
End
stack_works
.
Program
Definition
is_concurrent_stack
`
{!
heapG
Σ
,
!
channelG
Σ
}
:
concurrent_stack
Σ
:
=
{|
spec
.
mk_stack
:
=
mk_stack
|}.
Next
Obligation
.
iIntros
(????????
Φ
)
"HP HΦ"
.
iApply
(
stack_works
with
"[HΦ] HP"
).
iNext
.
iIntros
(
f
₁
f
₂
)
"#[Hpop Hpush]"
.
iApply
"HΦ"
.
iFrame
"#"
.
Qed
.
theories/concurrent_stacks/spec.v
View file @
0247cec5
...
...
@@ -2,6 +2,19 @@ From stdpp Require Import namespaces.
From
iris
.
program_logic
Require
Export
weakestpre
.
From
iris
.
heap_lang
Require
Export
proofmode
notation
.
(** General (HoCAP-style) spec for a concurrent bag ("per-elemt spec") *)
Record
concurrent_bag
{
Σ
}
`
{!
heapG
Σ
}
:
=
ConcurrentBag
{
mk_bag
:
val
;
mk_bag_spec
(
N
:
namespace
)
(
P
:
val
→
iProp
Σ
)
:
{{{
True
}}}
mk_bag
#()
{{{
(
f
₁
f
₂
:
val
),
RET
(
f
₁
,
f
₂
)
;
(
□
WP
f
₁
#()
{{
v
,
(
∃
(
v'
:
val
),
v
≡
SOMEV
v'
∗
P
v'
)
∨
v
≡
NONEV
}})
∗
(
∀
(
v
:
val
),
□
(
P
v
-
∗
WP
f
₂
v
{{
v
,
True
}}))
}}}
}.
Arguments
concurrent_bag
_
{
_
}.
(** General (HoCAP-style) spec for a concurrent stack *)
Record
concurrent_stack
{
Σ
}
`
{!
heapG
Σ
}
:
=
ConcurrentStack
{
...
...
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