Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Iris
c
Commits
f0967467
Commit
f0967467
authored
Nov 11, 2018
by
Dan Frumin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Uncurry the swap function
parent
4832c173
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
theories/tests/swap.v
theories/tests/swap.v
+14
-10
No files found.
theories/tests/swap.v
View file @
f0967467
...
...
@@ -3,7 +3,10 @@ From iris_c.vcgen Require Import proofmode.
Section
tests_vcg
.
Context
`
{
amonadG
Σ
}.
Definition
swap
:
val
:
=
λ
:
"l1"
"l2"
"r"
,
Definition
swap
:
val
:
=
λ
:
"a"
,
let
:
"l1"
:
=
Fst
"a"
in
let
:
"l2"
:
=
Fst
(
Snd
"a"
)
in
let
:
"r"
:
=
Snd
(
Snd
"a"
)
in
(
a_ret
"r"
)
=
ᶜ
∗ᶜ
(
a_ret
"l1"
)
;
ᶜ
(
a_ret
"l1"
)
=
ᶜ
∗ᶜ
(
a_ret
"l2"
)
;
ᶜ
(
a_ret
"l2"
)
=
ᶜ
∗ᶜ
(
a_ret
"r"
)
;
ᶜ
...
...
@@ -11,16 +14,17 @@ Section tests_vcg.
Lemma
swap_spec
(
l1
l2
r
:
cloc
)
(
v1
v2
:
val
)
R
:
r
↦
C
#
0
-
∗
l1
↦
C
v1
∗
l2
↦
C
v2
-
∗
awp
(
swap
(
cloc_to_val
l1
)
(
cloc_to_val
l2
)
(
cloc_to_val
r
))
R
(
λ
_
,
l2
↦
C
v1
∗
l1
↦
C
v2
).
AWP
swap
(
cloc_to_val
l1
,
(
cloc_to_val
l2
,
cloc_to_val
r
))
@
R
{{
_
,
l2
↦
C
v1
∗
l1
↦
C
v2
}}.
Proof
.
iIntros
"Hr [Hl1 Hl2]"
.
awp_lam
.
awp_pure
_
.
awp_pure
_
.
awp_pure
_
.
awp_lam
.
(* TODO: ^ if we do awp_pures here it unfolds too much!
Perhaps it unlocks something it shouldnt? *)
awp_pures
.
awp_lam
.
do
11
(
awp_pure
_
).
vcg
.
eauto
with
iFrame
.
Qed
.
Definition
swap_with_alloc
:
val
:
=
λ
:
"l1"
"l2"
,
Definition
swap_with_alloc
:
val
:
=
λ
:
"a"
,
let
:
"l1"
:
=
Fst
"a"
in
let
:
"l2"
:
=
Snd
"a"
in
"r"
←ᶜ
alloc
ᶜ
(
♯
1
,
♯
0
)
;
ᶜ
(
a_ret
"r"
)
=
ᶜ
∗ᶜ
(
a_ret
"l1"
)
;
ᶜ
(
a_ret
"l1"
)
=
ᶜ
∗ᶜ
(
a_ret
"l2"
)
;
ᶜ
...
...
@@ -29,11 +33,11 @@ Section tests_vcg.
Lemma
swap_with_alloc_spec
(
l1
l2
:
cloc
)
(
v1
v2
:
val
)
R
:
l1
↦
C
v1
-
∗
l2
↦
C
v2
-
∗
AWP
(
swap_with_alloc
(
cloc_to_val
l1
))
(
cloc_to_val
l2
)
@
R
{{
_
,
l1
↦
C
v2
∗
l2
↦
C
v1
}}.
AWP
swap_with_alloc
(
cloc_to_val
l1
,
cloc_to_val
l2
)
@
R
{{
_
,
l1
↦
C
v2
∗
l2
↦
C
v1
}}.
Proof
.
iIntros
"Hl1 Hl2"
.
awp_lam
.
awp_pure
_
.
awp_pure
_
.
vcg
.
iIntros
(
l3
)
"? l1 l2 l3"
.
eauto
with
iFrame
.
iIntros
"Hl1 Hl2"
.
awp_pure
s
.
awp_lam
.
do
6
(
awp_pure
_
)
.
vcg
.
iIntros
(
l3
)
"? l1 l2 l3"
.
eauto
with
iFrame
.
Qed
.
End
tests_vcg
.
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