Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lambda-rust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Spies
lambda-rust
Commits
4622cb39
Commit
4622cb39
authored
8 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
wp_alloc provides a vector of allocated values
parent
9edc1b15
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
theories/lang/lifting.v
+6
-3
6 additions, 3 deletions
theories/lang/lifting.v
theories/lang/new_delete.v
+4
-1
4 additions, 1 deletion
theories/lang/new_delete.v
theories/lang/proofmode.v
+14
-5
14 additions, 5 deletions
theories/lang/proofmode.v
theories/lang/spawn.v
+1
-6
1 addition, 6 deletions
theories/lang/spawn.v
with
25 additions
and
15 deletions
theories/lang/lifting.v
+
6
−
3
View file @
4622cb39
...
...
@@ -40,16 +40,19 @@ Lemma wp_bindi {E e} Ki Φ :
WP
fill_item
Ki
e
@
E
{{
Φ
}}
.
Proof
.
exact
:
weakestpre
.
wp_bind
.
Qed
.
Lemma
wp_alloc
E
n
:
Lemma
wp_alloc
E
(
n
:
Z
)
:
0
<
n
→
{{{
True
}}}
Alloc
(
Lit
$
LitInt
n
)
@
E
{{{
l
vl
,
RET
LitV
$
LitLoc
l
;
⌜
n
=
length
vl
⌝
∗
†
l
…
(
Z
.
to_nat
n
)
∗
l
↦∗
vl
}}}
.
{{{
l
sz
(
vl
:
vec
val
sz
)
,
RET
LitV
$
LitLoc
l
;
⌜
n
=
sz
⌝
∗
†
l
…
(
Z
.
to_nat
n
)
∗
l
↦∗
vl
}}}
.
Proof
.
iIntros
(?
Φ
)
"HΦ"
.
iApply
wp_lift_atomic_head_step_no_fork
;
auto
.
iIntros
(
σ1
)
"Hσ !>"
;
iSplit
;
first
by
auto
.
iNext
;
iIntros
(
v2
σ2
efs
Hstep
);
inv_head_step
.
iMod
(
heap_alloc
with
"Hσ"
)
as
"[Hσ Hl]"
;
[
done
..|]
.
iModIntro
;
iSplit
=>
//.
iFrame
.
iApply
"HΦ"
;
auto
.
iModIntro
;
iSplit
=>
//.
iFrame
.
(* FIXME: Merging these two into one "iApply" doesn't work. *)
iSpecialize
(
"HΦ"
$!
_
(
length
init
))
.
iApply
(
"HΦ"
$!
(
list_to_vec
init
))
.
rewrite
vec_to_list_of_list
.
auto
.
Qed
.
Lemma
wp_free
E
(
n
:
Z
)
l
vl
:
...
...
This diff is collapsed.
Click to expand it.
theories/lang/new_delete.v
+
4
−
1
View file @
4622cb39
...
...
@@ -25,7 +25,10 @@ Section specs.
iIntros
(?
Φ
)
"HΦ"
.
wp_lam
.
wp_op
;
intros
?
.
-
wp_if
.
assert
(
n
=
0
)
as
->
by
lia
.
iApply
(
"HΦ"
$!
_
[])
.
rewrite
heap_mapsto_vec_nil
.
auto
.
-
wp_if
.
wp_alloc
l
vl
as
"H↦"
"H†"
.
iApply
"HΦ"
.
iFrame
.
auto
.
-
wp_if
.
wp_alloc
l
vl
as
"H↦"
"H†"
.
(* FIXME: I have to state the coercion vec_to_list explicitly here. *)
iApply
(
"HΦ"
$!
_
(
vec_to_list
vl
))
.
rewrite
vec_to_list_length
-
{
2
}
Hsz
Z2Nat
.
id
//.
iFrame
.
auto
.
Qed
.
Lemma
wp_delete
E
(
n
:
Z
)
l
vl
:
...
...
This diff is collapsed.
Click to expand it.
theories/lang/proofmode.v
+
14
−
5
View file @
4622cb39
...
...
@@ -146,7 +146,7 @@ Implicit Types Δ : envs (iResUR Σ).
Lemma
tac_wp_alloc
Δ
Δ'
E
j1
j2
n
Φ
:
0
<
n
→
IntoLaterNEnvs
1
Δ
Δ'
→
(
∀
l
vl
,
n
=
length
vl
→
∃
Δ''
,
(
∀
l
sz
(
vl
:
vec
val
sz
),
n
=
sz
→
∃
Δ''
,
envs_app
false
(
Esnoc
(
Esnoc
Enil
j1
(
l
↦∗
vl
))
j2
(
†
l
…
(
Z
.
to_nat
n
)))
Δ'
=
Some
Δ''
∧
(
Δ''
⊢
Φ
(
LitV
$
LitLoc
l
)))
→
...
...
@@ -154,10 +154,10 @@ Lemma tac_wp_alloc Δ Δ' E j1 j2 n Φ :
Proof
.
intros
??
HΔ
.
rewrite
-
wp_fupd
.
eapply
wand_apply
;
first
exact
:
wp_alloc
.
rewrite
-
always_and_sep_l
.
apply
and_intro
;
first
done
.
rewrite
into_laterN_env_sound
;
apply
later_mono
,
forall_intro
=>
l
;
apply
forall_intro
=>
vl
.
apply
wand_intro_l
.
rewrite
-
assoc
.
rewrite
into_laterN_env_sound
;
apply
later_mono
,
forall_intro
=>
l
.
apply
forall_intro
=>
sz
.
apply
forall_intro
=>
vl
.
apply
wand_intro_l
.
rewrite
-
assoc
.
apply
pure_elim_sep_l
=>
Hn
.
apply
wand_elim_r'
.
destruct
(
HΔ
l
vl
)
as
(
Δ''
&
?
&
HΔ'
)
.
done
.
destruct
(
HΔ
l
_
vl
)
as
(
Δ''
&
?
&
HΔ'
)
;
first
done
.
rewrite
envs_app_sound
//
;
simpl
.
by
rewrite
right_id
HΔ'
-
fupd_intro
.
Qed
.
...
...
@@ -233,7 +233,16 @@ Tactic Notation "wp_alloc" ident(l) ident(vl) "as" constr(H) constr(Hf) :=
eapply
tac_wp_alloc
with
_
H
Hf
;
[
try
fast_done
|
apply
_
|
first
[
intros
l
vl
?
|
fail
1
"wp_alloc:"
l
"or"
vl
"not fresh"
];
|
let
sz
:=
fresh
"sz"
in
let
Hsz
:=
fresh
"Hsz"
in
first
[
intros
l
sz
vl
Hsz
|
fail
1
"wp_alloc:"
l
"or"
vl
"not fresh"
];
(* If Hsz is "constant Z = nat", change that to an equation on nat and
potentially substitute away the sz. *)
try
(
match
goal
with
Hsz
:
?x
=
_
|
-
_
=>
rewrite
<-
(
Z2Nat
.
id
x
)
in
Hsz
;
last
done
end
;
apply
Nat2Z
.
inj
in
Hsz
;
try
(
cbv
[
Z
.
to_nat
Pos
.
to_nat
]
in
Hsz
;
simpl
in
Hsz
;
(* Substitute only if we have a literal nat. *)
match
goal
with
Hsz
:
S
_
=
_
|
-
_
=>
subst
sz
end
));
eexists
;
split
;
[
env_cbv
;
reflexivity
||
fail
"wp_alloc:"
H
"or"
Hf
"not fresh"
|
wp_finish
]]
...
...
This diff is collapsed.
Click to expand it.
theories/lang/spawn.v
+
1
−
6
View file @
4622cb39
...
...
@@ -67,14 +67,9 @@ Lemma spawn_spec (Ψ : val → iProp Σ) e (f : val) :
spawn
[
e
]
{{{
c
,
RET
#
c
;
join_handle
c
Ψ
}}}
.
Proof
.
iIntros
(
<-%
of_to_val
Φ
)
"Hf HΦ"
.
rewrite
/
spawn
/=.
wp_let
.
wp_alloc
l
vl
as
"Hl"
"H†"
.
wp_let
.
wp_let
.
wp_alloc
l
vl
as
"Hl"
"H†"
.
wp_let
.
inv_vec
vl
=>
v0
v1
.
iMod
(
own_alloc
(
Excl
()))
as
(
γf
)
"Hγf"
;
first
done
.
iMod
(
own_alloc
(
Excl
()))
as
(
γj
)
"Hγj"
;
first
done
.
(* TODO: maybe we should get vl as a vector here instead of a separate hypothesis for the length? *)
assert
(
2
=
length
vl
)
%
nat
as
Hvl
.
{
apply
Nat2Z
.
inj
.
done
.
}
destruct
vl
as
[|
v0
vl
];
first
done
.
destruct
vl
as
[|
v1
vl
];
first
done
.
destruct
vl
;
last
done
.
clear
H
Hvl
.
rewrite
heap_mapsto_vec_cons
heap_mapsto_vec_singleton
.
iDestruct
"Hl"
as
"[Hc Hd]"
.
wp_write
.
clear
v0
.
iMod
(
inv_alloc
N
_
(
spawn_inv
γf
γj
l
Ψ
)
with
"[Hc]"
)
as
"#?"
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment