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
Iris
Actris
Commits
3879534a
Commit
3879534a
authored
Jul 04, 2019
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More list cleanup; add append function.
parent
f5e2db76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
24 deletions
+30
-24
theories/utils/list.v
theories/utils/list.v
+30
-24
No files found.
theories/utils/list.v
View file @
3879534a
...
...
@@ -54,36 +54,34 @@ Definition llength : val :=
|
SOME
"p"
=>
#
1
+
"go"
(
Snd
"p"
)
end
.
Definition
l
snoc
:
val
:
=
rec
:
"go"
"l"
"
x
"
:
=
Definition
l
app
:
val
:
=
rec
:
"go"
"l"
"
k
"
:
=
match
:
"l"
with
SOME
"p"
=>
(
lcons
(
Fst
"p"
)
(
"go"
(
Snd
"p"
)
"x"
))
|
NONE
=>
lcons
"x"
NONE
NONE
=>
"k"
|
SOME
"p"
=>
lcons
(
Fst
"p"
)
(
"go"
(
Snd
"p"
)
"k"
)
end
.
Definition
lsnoc
:
val
:
=
λ
:
"l"
"x"
,
lapp
"l"
(
lcons
"x"
(
lnil
#())).
Definition
ltake
:
val
:
=
rec
:
"go"
"l"
"n"
:
=
if
:
"n"
≤
#
0
then
NONEV
else
match
:
"l"
with
SOME
"l"
=>
lcons
(
Fst
"l"
)
(
"go"
(
Snd
"l"
)
(
"n"
-#
1
))
|
NONE
=>
NONEV
end
.
if
:
"n"
≤
#
0
then
NONEV
else
match
:
"l"
with
NONE
=>
NONEV
|
SOME
"l"
=>
lcons
(
Fst
"l"
)
(
"go"
(
Snd
"l"
)
(
"n"
-#
1
))
end
.
Definition
ldrop
:
val
:
=
rec
:
"go"
"l"
"n"
:
=
if
:
"n"
≤
#
0
then
"l"
else
match
:
"l"
with
SOME
"l"
=>
"go"
(
Snd
"l"
)
(
"n"
-#
1
)
|
NONE
=>
NONEV
end
.
if
:
"n"
≤
#
0
then
"l"
else
match
:
"l"
with
NONE
=>
NONEV
|
SOME
"l"
=>
"go"
(
Snd
"l"
)
(
"n"
-#
1
)
end
.
Definition
lsplit_at
:
val
:
=
λ
:
"l"
"n"
,
(
ltake
"l"
"n"
,
ldrop
"l"
"n"
).
Definition
lsplit_at
:
val
:
=
λ
:
"l"
"n"
,
(
ltake
"l"
"n"
,
ldrop
"l"
"n"
).
Definition
lsplit
:
val
:
=
λ
:
"l"
,
lsplit_at
"l"
((
llength
"l"
)
`
quot
`
#
2
).
Definition
lsplit
:
val
:
=
λ
:
"l"
,
lsplit_at
"l"
(
llength
"l"
`
quot
`
#
2
).
Section
lists
.
Context
`
{
heapG
Σ
}.
...
...
@@ -164,13 +162,21 @@ Proof.
rewrite
(
Nat2Z
.
inj_add
1
).
by
iApply
"HΦ"
.
Qed
.
Lemma
lapp_spec
vs1
vs2
:
{{{
True
}}}
lapp
(
llist
vs1
)
(
llist
vs2
)
{{{
RET
(
llist
(
vs1
++
vs2
))
;
True
}}}.
Proof
.
iIntros
(
Φ
_
)
"HΦ"
.
iInduction
vs1
as
[|
v1
vs1
]
"IH"
forall
(
Φ
)
;
simpl
.
{
wp_rec
.
wp_pures
.
by
iApply
"HΦ"
.
}
wp_rec
.
wp_pures
.
wp_apply
"IH"
.
iIntros
(
_
).
by
wp_apply
lcons_spec
.
Qed
.
Lemma
lsnoc_spec
vs
v
:
{{{
True
}}}
lsnoc
(
llist
vs
)
v
{{{
RET
(
llist
(
vs
++
[
v
]))
;
True
}}}.
Proof
.
iIntros
(
Φ
_
)
"HΦ"
.
iInduction
vs
as
[|
v'
vs
]
"IH"
forall
(
Φ
).
{
wp_rec
.
wp_pures
.
wp_lam
.
wp_pures
.
by
iApply
"HΦ"
.
}
wp_rec
.
wp_apply
"IH"
;
iIntros
(
_
).
by
wp_apply
lcons_spec
=>
//.
iIntros
(
Φ
_
)
"HΦ"
.
wp_lam
.
wp_apply
(
lnil_spec
with
"[//]"
)
;
iIntros
(
_
).
wp_apply
(
lcons_spec
with
"[//]"
)
;
iIntros
(
_
).
wp_apply
(
lapp_spec
with
"[//]"
)
;
iIntros
(
_
).
by
iApply
"HΦ"
.
Qed
.
Lemma
ltake_spec
vs
(
n
:
nat
)
:
...
...
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