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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Service Desk
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
Iris
lambda-rust
Commits
a500b561
Commit
a500b561
authored
8 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
prove Mutex::into_inner
parent
804e4148
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/typing/lib/mutex/mutex.v
+41
-1
41 additions, 1 deletion
theories/typing/lib/mutex/mutex.v
with
41 additions
and
1 deletion
theories/typing/lib/mutex/mutex.v
+
41
−
1
View file @
a500b561
...
@@ -103,7 +103,7 @@ Section code.
...
@@ -103,7 +103,7 @@ Section code.
typed_val
(
mutex_new
ty
)
(
fn
(
∅
;
ty
)
→
mutex
ty
)
.
typed_val
(
mutex_new
ty
)
(
fn
(
∅
;
ty
)
→
mutex
ty
)
.
Proof
.
Proof
.
intros
E
L
.
iApply
type_fn
;
[
solve_typing
..|]
.
iIntros
"/= !#"
.
intros
E
L
.
iApply
type_fn
;
[
solve_typing
..|]
.
iIntros
"/= !#"
.
iIntros
(
α
ϝ
ret
arg
)
.
inv_vec
arg
=>
x
.
simpl_subst
.
iIntros
(
_
ϝ
ret
arg
)
.
inv_vec
arg
=>
x
.
simpl_subst
.
iApply
type_new
;
[
solve_typing
..|];
iIntros
(
m
);
simpl_subst
.
iApply
type_new
;
[
solve_typing
..|];
iIntros
(
m
);
simpl_subst
.
rewrite
(
Nat2Z
.
id
(
S
ty
.(
ty_size
)))
.
(* FIXME: Having to do this after every type_new is rather annoying... *)
rewrite
(
Nat2Z
.
id
(
S
ty
.(
ty_size
)))
.
(* FIXME: Having to do this after every type_new is rather annoying... *)
(* FIXME: The following should work. We could then go into Iris later.
(* FIXME: The following should work. We could then go into Iris later.
...
@@ -134,4 +134,44 @@ Section code.
...
@@ -134,4 +134,44 @@ Section code.
iApply
type_jump
;
solve_typing
.
iApply
type_jump
;
solve_typing
.
Qed
.
Qed
.
Definition
mutex_into_inner
ty
:
val
:=
funrec
:
<>
[
"m"
]
:=
let
:
"x"
:=
new
[
#
ty
.(
ty_size
)
]
in
"x"
<-
{
ty
.(
ty_size
)}
!
(
"m"
+
ₗ
#
1
);;
delete
[
#
(
mutex
ty
).(
ty_size
);
"m"
];;
return
:
[
"x"
]
.
Lemma
mutex_into_inner_type
ty
`{
!
TyWf
ty
}
:
typed_val
(
mutex_into_inner
ty
)
(
fn
(
∅
;
mutex
ty
)
→
ty
)
.
Proof
.
intros
E
L
.
iApply
type_fn
;
[
solve_typing
..|]
.
iIntros
"/= !#"
.
iIntros
(_
ϝ
ret
arg
)
.
inv_vec
arg
=>
m
.
simpl_subst
.
iApply
type_new
;
[
solve_typing
..|];
iIntros
(
x
);
simpl_subst
.
rewrite
(
Nat2Z
.
id
ty
.(
ty_size
))
.
(* Switch to Iris. *)
iIntros
(
tid
)
"#LFT #HE Hna HL Hk [Hx [Hm _]]"
.
rewrite
!
tctx_hasty_val
/=.
iDestruct
(
ownptr_uninit_own
with
"Hx"
)
as
(
lx
vlx
)
"(% & Hx & Hx†)"
.
subst
x
.
(* FIXME: Shouldn't things be printed as "#x"? *)
destruct
m
as
[[|
lm
|]|];
try
done
.
iDestruct
"Hm"
as
"[Hm Hm†]"
.
iDestruct
(
heap_mapsto_ty_own
with
"Hm"
)
as
(
vlm
)
"[>Hm Hvlm]"
.
inv_vec
vlm
=>
m
vlm
.
destruct
m
as
[[|
m
|]|];
try
by
iDestruct
"Hvlm"
as
">[]"
.
simpl
.
iDestruct
(
heap_mapsto_vec_cons
with
"Hm"
)
as
"[Hm0 Hm]"
.
iDestruct
"Hvlm"
as
"[_ Hvlm]"
.
(* All right, we are done preparing our context. Let's get going. *)
wp_op
.
wp_apply
(
wp_memcpy
with
"[$Hx $Hm]"
);
[
by
rewrite
vec_to_list_length
..|]
.
(* FIXME: Swapping the order of $Hx and $Hm breaks. *)
iIntros
"[Hx Hm]"
.
wp_seq
.
(* Switch back to typing mode. *)
iApply
(
type_type
_
_
_
[
#
lx
◁
box
ty
;
#
lm
◁
box
(
uninit
(
mutex
ty
).(
ty_size
))]
with
"[] LFT HE Hna HL Hk"
);
last
first
.
(* TODO: It would be nice to say [{#}] as the last spec pattern to clear the context in there. *)
{
rewrite
tctx_interp_cons
tctx_interp_singleton
tctx_hasty_val'
//
tctx_hasty_val'
//.
iFrame
.
iSplitR
"Hm0 Hm"
.
-
iExists
_
.
iFrame
.
-
iExists
(_
::
_)
.
rewrite
heap_mapsto_vec_cons
.
iFrame
.
rewrite
uninit_own
.
rewrite
/=
vec_to_list_length
.
eauto
.
}
iApply
type_delete
;
[
solve_typing
..|]
.
iApply
type_jump
;
solve_typing
.
Qed
.
End
code
.
End
code
.
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