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
a4c68278
There was a problem fetching the pipeline metadata.
Commit
a4c68278
authored
8 years ago
by
Jacques-Henri Jourdan
Browse files
Options
Downloads
Patches
Plain Diff
Typecheck refcell::new.
parent
2b9a48be
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/typing/unsafe/refcell.v
+45
-48
45 additions, 48 deletions
theories/typing/unsafe/refcell.v
with
45 additions
and
48 deletions
theories/typing/unsafe/refcell.v
+
45
−
48
View file @
a4c68278
...
@@ -392,52 +392,49 @@ End refmut.
...
@@ -392,52 +392,49 @@ End refmut.
Hint
Resolve
refcell_mono'
refcell_proper'
ref_mono'
ref_proper'
Hint
Resolve
refcell_mono'
refcell_proper'
ref_mono'
ref_proper'
refmut_mono'
refmut_proper'
:
lrust_typing
.
refmut_mono'
refmut_proper'
:
lrust_typing
.
(* Section refcell_functions. *)
Section
refcell_functions
.
(* Context `{typeG Σ, refcellG Σ}. *)
Context
`{
typeG
Σ
,
refcellG
Σ
}
.
(* (* Constructing a cell. *) *)
(* Definition refcell_new ty : val := *)
(* funrec: <> ["x"] := *)
(* let: "r" := new [ #(S ty.(ty_size))] in *)
(* "r" +ₗ #0 <- #0;; *)
(* "r" +ₗ #1 <-{ty.(ty_size)} !"x";; *)
(* "k" ["r"] *)
(* cont: "k" ["r"] := *)
(* delete [ #ty.(ty_size) ; "x"];; "return" ["r"]. *)
(* Lemma refcell_new_type ty : *)
(* typed_instruction_ty [] [] [] (refcell_new ty) *)
(* (fn (λ _, [])%EL (λ _, [# ty]) (λ _:(), refcell ty)). *)
(* Proof. *)
(* apply type_fn; [apply _..|]. move=>/= _ ret arg. inv_vec arg=>x. simpl_subst. *)
(* eapply (type_cont [_] [] *)
(* (λ r, [x ◁ box (uninit ty.(ty_size)); r!!!0 ◁ box (refcell ty)])%TC); *)
(* [solve_typing..| |]; last first. *)
(* - simpl. intros k arg. inv_vec arg=>r. simpl_subst. *)
(* eapply type_delete; [solve_typing..|]. *)
(* eapply (type_jump [_]); solve_typing. *)
(* - intros k. simpl_subst. eapply type_new; [solve_typing..|]. *)
(* iIntros (r) "!# * #HEAP #LFT Hna HE _ Hk HT". simpl_subst. *)
(* rewrite (Nat2Z.id (S ty.(ty_size))) tctx_interp_cons *)
(* tctx_interp_singleton !tctx_hasty_val. *)
(* iDestruct "HT" as "[Hr Hx]". *)
(* destruct x as [[]|]; try iDestruct "Hx" as "[]". iDestruct "Hx" as "[Hx Hx†]". *)
(* destruct r as [[]|]; try iDestruct "Hr" as "[]". iDestruct "Hr" as "[Hr Hr†]". *)
(* iDestruct "Hr" as (vl) "Hr". rewrite uninit_own. iDestruct "Hr" as "[Hr↦ >%]". *)
(* destruct vl as [|]; try done. rewrite heap_mapsto_vec_cons. *)
(* iDestruct "Hr↦" as "[Hr↦0 Hr↦1]". wp_op. rewrite shift_loc_0. wp_write. *)
(* etrans. admit. apply wp_lam. wp_done. apply _. wp_done. *)
(* wp_seq. *)
(* simpl *)
(* simpl. *)
(* simpl. *)
(* simpl_subst. *)
(* eapply type_new; [solve_typing..|]=>r. simpl_subst. *)
(* eapply (type_jump [_]); first solve_typing. *)
(* Constructing a cell. *)
(* iIntros (???) "#LFT $ $ Hty". rewrite !tctx_interp_singleton /=. done. *)
Definition
refcell_new
ty
:
val
:=
(* Qed. *)
funrec
:
<>
[
"x"
]
:=
let
:
"r"
:=
new
[
#
(
S
ty
.(
ty_size
))]
in
"r"
+
ₗ
#
0
<-
#
0
;;
"r"
+
ₗ
#
1
<-
{
ty
.(
ty_size
)}
!
"x"
;;
"k"
[
"r"
]
cont
:
"k"
[
"r"
]
:=
delete
[
#
ty
.(
ty_size
)
;
"x"
];;
"return"
[
"r"
]
.
Lemma
refcell_new_type
ty
:
typed_instruction_ty
[]
[]
[]
(
refcell_new
ty
)
(
fn
(
λ
_,
[])
%
EL
(
λ
_,
[
#
ty
])
(
λ
_:(),
refcell
ty
))
.
Proof
.
apply
type_fn
;
[
apply
_..|]
.
move
=>
/=
_
ret
arg
.
inv_vec
arg
=>
x
.
simpl_subst
.
eapply
(
type_cont
[_]
[]
(
λ
r
,
[
x
◁
box
(
uninit
ty
.(
ty_size
));
r
!!!
0
◁
box
(
refcell
ty
)])
%
TC
);
[
solve_typing
..|
|];
last
first
.
{
simpl
.
intros
k
arg
.
inv_vec
arg
=>
r
.
simpl_subst
.
eapply
type_delete
;
[
solve_typing
..|]
.
eapply
(
type_jump
[_]);
solve_typing
.
}
intros
k
.
simpl_subst
.
eapply
type_new
;
[
solve_typing
..|]
.
iIntros
(
r
)
"!# * #HEAP #LFT Hna HE HL Hk HT"
.
simpl_subst
.
rewrite
(
Nat2Z
.
id
(
S
ty
.(
ty_size
)))
tctx_interp_cons
tctx_interp_singleton
!
tctx_hasty_val
.
rewrite
cctx_interp_cons
cctx_interp_singleton
.
iDestruct
(
"Hk"
with
"HE"
)
as
"[Hk _]"
.
iDestruct
"HT"
as
"[Hr Hx]"
.
destruct
x
as
[[]|];
try
iDestruct
"Hx"
as
"[]"
.
iDestruct
"Hx"
as
"[Hx Hx†]"
.
iDestruct
"Hx"
as
(
vl
)
"[Hx↦ Hx]"
.
destruct
r
as
[[]|];
try
iDestruct
"Hr"
as
"[]"
.
iDestruct
"Hr"
as
"[Hr Hr†]"
.
iDestruct
"Hr"
as
(
vl'
)
"Hr"
.
rewrite
uninit_own
.
iDestruct
"Hr"
as
"[Hr↦ >SZ]"
.
destruct
vl'
as
[|];
iDestruct
"SZ"
as
%
[
=
]
.
rewrite
heap_mapsto_vec_cons
.
iDestruct
"Hr↦"
as
"[Hr↦0 Hr↦1]"
.
wp_op
.
rewrite
shift_loc_0
.
wp_write
.
wp_op
.
iDestruct
(
ty
.(
ty_size_eq
)
with
"Hx"
)
as
%
?
.
wp_bind
(_
<-
{_}
!
_)
%
E
.
iApply
(
wp_memcpy
with
"[$HEAP $Hr↦1 $Hx↦]"
);
[
done
..|]
.
iIntros
"!> [Hr↦1 Hx↦]"
.
wp_seq
.
iApply
(
"Hk"
$!
[
#
#
_]
with
"Hna HL"
)
.
rewrite
tctx_interp_cons
tctx_interp_singleton
/=
!
tctx_hasty_val'
//=.
iFrame
.
iSplitL
"Hx↦"
.
-
iExists
vl
.
iFrame
.
rewrite
uninit_own
.
auto
.
-
iExists
(_::_)
.
rewrite
heap_mapsto_vec_cons
.
iFrame
"Hr↦0 ∗"
.
auto
.
Qed
.
End
refcell_functions
.
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