Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Iris
c
Commits
061dad60
Commit
061dad60
authored
Jul 02, 2018
by
Robbert Krebbers
Browse files
length function on lists.
parent
28730768
Changes
1
Hide whitespace changes
Inline
Side-by-side
theories/lib/list.v
View file @
061dad60
...
...
@@ -50,6 +50,13 @@ Definition llist_member : val :=
else
let
:
"l"
:
=
(
Snd
"p"
)
in
"go"
"x"
"l"
end
.
Definition
llength
:
val
:
=
rec
:
"go"
"l"
:
=
match
:
"l"
with
NONE
=>
#
0
|
SOME
"p"
=>
#
1
+
"go"
(
Snd
"p"
)
end
.
Section
lists
.
Context
`
{
heapG
Σ
}.
Implicit
Types
i
:
nat
.
...
...
@@ -122,4 +129,15 @@ Proof.
wp_op
.
rewrite
Nat2Z
.
inj_succ
-
Z
.
add_1_l
Z
.
add_simpl_l
.
wp_apply
"IH"
;
iIntros
(
hd'
Hl
).
wp_let
.
by
iApply
(
lcons_spec
with
"[//]"
).
Qed
.
Lemma
llength_spec
hd
vs
:
{{{
⌜
is_list
hd
vs
⌝
}}}
llength
hd
{{{
RET
#(
length
vs
)
;
True
}}}.
Proof
.
iIntros
(
Φ
Hl
)
"HΦ"
.
iInduction
vs
as
[|
v'
vs
]
"IH"
forall
(
hd
Hl
Φ
)
;
simplify_eq
/=.
{
wp_lam
.
wp_match
.
by
iApply
"HΦ"
.
}
destruct
Hl
as
(
hd'
&->&?).
wp_lam
.
wp_match
.
wp_proj
.
wp_apply
(
"IH"
$!
hd'
with
"[//]"
)
;
iIntros
"_ /="
.
wp_op
.
rewrite
(
Nat2Z
.
inj_add
1
).
by
iApply
"HΦ"
.
Qed
.
End
lists
.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment