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
7e2f7f6e
Commit
7e2f7f6e
authored
8 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
prove MutexGuard::drop
parent
00ee1d5e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/typing/lib/mutex/mutexguard.v
+32
-1
32 additions, 1 deletion
theories/typing/lib/mutex/mutexguard.v
with
32 additions
and
1 deletion
theories/typing/lib/mutex/mutexguard.v
+
32
−
1
View file @
7e2f7f6e
...
...
@@ -104,7 +104,7 @@ Section code.
let
:
"guard"
:=
new
[
#
1
]
in
acquire
[
"m"
];;
"guard"
+
ₗ
#
0
<-
"m"
;;
delete
[
#
1
;
"mutex"
];;
return
:
[
"guard"
]
.
delete
[
#
1
;
"mutex"
];;
return
:
[
"guard"
]
.
Lemma
mutex_lock_type
ty
`{
!
TyWf
ty
}
:
typed_val
mutex_lock
(
fn
(
∀
α
,
∅
;
&
shr
{
α
}
mutex
ty
)
→
mutexguard
α
ty
)
.
...
...
@@ -135,4 +135,35 @@ Section code.
iApply
type_jump
;
solve_typing
.
Qed
.
Definition
mutexguard_drop
:
val
:=
funrec
:
<>
[
"g"
]
:=
let
:
"m"
:=
!
"g"
in
release
[
"m"
];;
delete
[
#
1
;
"g"
];;
let
:
"r"
:=
new
[
#
0
]
in
return
:
[
"r"
]
.
Lemma
mutexguard_drop_type
ty
`{
!
TyWf
ty
}
:
typed_val
mutexguard_drop
(
fn
(
∀
α
,
∅
;
mutexguard
α
ty
)
→
unit
)
.
Proof
.
intros
E
L
.
iApply
type_fn
;
[
solve_typing
..|]
.
iIntros
"/= !#"
.
iIntros
(
α
ϝ
ret
arg
)
.
inv_vec
arg
=>
g
.
simpl_subst
.
iApply
type_deref
;
[
solve_typing
..|];
iIntros
(
m
);
simpl_subst
.
(* Switch to Iris. *)
iIntros
(
tid
)
"#LFT #HE Hna HL Hk [Hg [Hm _]]"
.
rewrite
!
tctx_hasty_val
[[
g
]]
lock
/=.
destruct
m
as
[[|
lm
|]|];
try
done
.
iDestruct
"Hm"
as
(
γ
β
)
"(Hlcked & #Hαβ & #Hshr & Hcnt)"
.
(* All right, we are done preparing our context. Let's get going. *)
iMod
(
lctx_lft_alive_tok
α
with
"HE HL"
)
as
(
q
)
"(Hα & HL & Hclose1)"
;
[
solve_typing
..|]
.
wp_apply
(
release_spec
with
"[] [Hα $Hlcked Hcnt]"
);
first
by
iApply
(
mutex_acc
with
"LFT Hshr Hαβ"
)
.
{
by
iFrame
.
}
iIntros
"Htok"
.
wp_seq
.
iMod
(
"Hclose1"
with
"Htok HL"
)
as
"HL"
.
(* Switch back to typing mode. *)
iApply
(
type_type
_
_
_
[
g
◁
own_ptr
_
_
]
with
"[] LFT HE Hna HL Hk"
);
last
first
.
{
rewrite
tctx_interp_singleton
tctx_hasty_val
.
unlock
.
iFrame
.
}
iApply
type_delete
;
[
solve_typing
..|]
.
iApply
type_new
;
[
solve_typing
..|];
iIntros
(
r
);
simpl_subst
.
iApply
type_jump
;
solve_typing
.
Qed
.
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