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
97bb9b8b
Commit
97bb9b8b
authored
8 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
Prove that Cell<T> is a type and copy if T is copy
parent
27e2cf0a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
theories/lifetime/na_borrow.v
+6
-6
6 additions, 6 deletions
theories/lifetime/na_borrow.v
theories/typing/uniq_bor.v
+2
-2
2 additions, 2 deletions
theories/typing/uniq_bor.v
theories/typing/unsafe/cell.v
+74
-0
74 additions, 0 deletions
theories/typing/unsafe/cell.v
with
82 additions
and
8 deletions
theories/lifetime/na_borrow.v
+
6
−
6
View file @
97bb9b8b
...
@@ -30,13 +30,13 @@ Section na_bor.
...
@@ -30,13 +30,13 @@ Section na_bor.
iExists
i
.
iFrame
"#"
.
iApply
(
na_inv_alloc
tid
E
N
with
"[Hown]"
)
.
auto
.
iExists
i
.
iFrame
"#"
.
iApply
(
na_inv_alloc
tid
E
N
with
"[Hown]"
)
.
auto
.
Qed
.
Qed
.
Lemma
na_bor_acc
q
κ
E
:
Lemma
na_bor_acc
q
κ
E
F
:
↑
lftN
⊆
E
→
↑
N
⊆
E
→
↑
lftN
⊆
E
→
↑
N
⊆
E
→
↑
N
⊆
F
→
lft_ctx
-∗
&
na
{
κ
,
tid
,
N
}
P
-∗
q
.[
κ
]
-∗
na_own
tid
E
=
{
E
}
=∗
lft_ctx
-∗
&
na
{
κ
,
tid
,
N
}
P
-∗
q
.[
κ
]
-∗
na_own
tid
F
=
{
E
}
=∗
▷
P
∗
na_own
tid
(
E
∖
↑
N
)
∗
▷
P
∗
na_own
tid
(
F
∖
↑
N
)
∗
(
▷
P
-∗
na_own
tid
(
E
∖
↑
N
)
=
{
E
}
=∗
q
.[
κ
]
∗
na_own
tid
E
)
.
(
▷
P
-∗
na_own
tid
(
F
∖
↑
N
)
=
{
E
}
=∗
q
.[
κ
]
∗
na_own
tid
F
)
.
Proof
.
Proof
.
iIntros
(??)
"#LFT#HP Hκ Hnaown"
.
iIntros
(??
?
)
"#LFT#HP Hκ Hnaown"
.
iDestruct
"HP"
as
(
i
)
"(#Hpers&#Hinv)"
.
iDestruct
"HP"
as
(
i
)
"(#Hpers&#Hinv)"
.
iMod
(
na_inv_open
with
"Hinv Hnaown"
)
as
"(>Hown&Hnaown&Hclose)"
;
try
done
.
iMod
(
na_inv_open
with
"Hinv Hnaown"
)
as
"(>Hown&Hnaown&Hclose)"
;
try
done
.
iMod
(
idx_bor_acc
with
"LFT Hpers Hown Hκ"
)
as
"[HP Hclose']"
.
done
.
iMod
(
idx_bor_acc
with
"LFT Hpers Hown Hκ"
)
as
"[HP Hclose']"
.
done
.
...
...
This diff is collapsed.
Click to expand it.
theories/typing/uniq_bor.v
+
2
−
2
View file @
97bb9b8b
...
@@ -154,7 +154,7 @@ Section typing.
...
@@ -154,7 +154,7 @@ Section typing.
Proof
.
Proof
.
iIntros
(
Hκ
???)
"#LFT HE HL Huniq"
.
iIntros
(
Hκ
???)
"#LFT HE HL Huniq"
.
iMod
(
Hκ
with
"HE HL"
)
as
(
q
)
"[Htok Hclose]"
;
[
try
done
..|]
.
iMod
(
Hκ
with
"HE HL"
)
as
(
q
)
"[Htok Hclose]"
;
[
try
done
..|]
.
rewrite
/
tctx_interp
!
big_sepL
_singleton
/=.
rewrite
!
tctx_interp_singleton
/=.
iDestruct
"Huniq"
as
(
v
)
"[% Huniq]"
.
iDestruct
"Huniq"
as
(
v
)
"[% Huniq]"
.
iDestruct
"Huniq"
as
(
l
P
)
"[[% #HPiff] HP]"
.
iDestruct
"Huniq"
as
(
l
P
)
"[[% #HPiff] HP]"
.
iMod
(
bor_iff
with
"LFT [] HP"
)
as
"H↦"
.
set_solver
.
by
eauto
.
iMod
(
bor_iff
with
"LFT [] HP"
)
as
"H↦"
.
set_solver
.
by
eauto
.
...
@@ -171,7 +171,7 @@ Section typing.
...
@@ -171,7 +171,7 @@ Section typing.
iDestruct
(
elctx_interp_persist
with
"HE"
)
as
"#HE'"
.
iDestruct
(
elctx_interp_persist
with
"HE"
)
as
"#HE'"
.
iDestruct
(
llctx_interp_persist
with
"HL"
)
as
"#HL'"
.
iFrame
"HE HL"
.
iDestruct
(
llctx_interp_persist
with
"HL"
)
as
"#HL'"
.
iFrame
"HE HL"
.
iDestruct
(
Hκκ'
with
"HE' HL'"
)
as
"Hκκ'"
.
iDestruct
(
Hκκ'
with
"HE' HL'"
)
as
"Hκκ'"
.
rewrite
/
tctx_interp
big_sepL
_singleton
big_sepL_cons
big_sepL
_singleton
.
rewrite
tctx_interp_singleton
tctx_interp_cons
tctx_interp
_singleton
.
iDestruct
"H"
as
(
v
)
"[% Hown]"
.
iDestruct
"Hown"
as
(
l
P
)
"[[EQ #Hiff] Hb]"
.
iDestruct
"H"
as
(
v
)
"[% Hown]"
.
iDestruct
"Hown"
as
(
l
P
)
"[[EQ #Hiff] Hb]"
.
iDestruct
"EQ"
as
%
[
=->
]
.
iMod
(
bor_iff
with
"LFT [] Hb"
)
as
"Hb"
.
done
.
by
eauto
.
iDestruct
"EQ"
as
%
[
=->
]
.
iMod
(
bor_iff
with
"LFT [] Hb"
)
as
"Hb"
.
done
.
by
eauto
.
iMod
(
rebor
with
"LFT Hκκ' Hb"
)
as
"[Hb Hext]"
.
done
.
iModIntro
.
iSplitL
"Hb"
.
iMod
(
rebor
with
"LFT Hκκ' Hb"
)
as
"[Hb Hext]"
.
done
.
iModIntro
.
iSplitL
"Hb"
.
...
...
This diff is collapsed.
Click to expand it.
theories/typing/unsafe/cell.v
0 → 100644
+
74
−
0
View file @
97bb9b8b
From
iris
.
proofmode
Require
Import
tactics
.
From
lrust
.
lifetime
Require
Import
na_borrow
.
From
lrust
.
typing
Require
Export
type
.
From
lrust
.
typing
Require
Import
type_context
programs
.
Set
Default
Proof
Using
"Type"
.
Section
cell
.
Context
`{
typeG
Σ
}
.
Local
Hint
Extern
1000
(_
⊆
_)
=>
set_solver
:
ndisj
.
Program
Definition
cell
(
ty
:
type
)
:=
{|
ty_size
:=
ty
.(
ty_size
);
ty_own
:=
ty
.(
ty_own
);
ty_shr
κ
tid
l
:=
(
&
na
{
κ
,
tid
,
shrN
.
@
l
}
l
↦∗:
ty
.(
ty_own
)
tid
)
%
I
|}
.
Next
Obligation
.
apply
ty_size_eq
.
Qed
.
Next
Obligation
.
iIntros
(
ty
E
κ
l
tid
q
?)
"#LFT Hown $"
.
by
iApply
bor_na
.
Qed
.
Next
Obligation
.
iIntros
(
ty
??
tid
l
)
"#LFT"
.
iApply
na_bor_shorten
.
Qed
.
(* TODO: non-expansiveness, proper wrt. eqtype *)
Global
Instance
cell_type
:
Copy
ty
→
Copy
(
cell
ty
)
.
Proof
.
intros
ty
Hcopy
.
split
;
first
by
intros
;
simpl
;
apply
_
.
iIntros
(
κ
tid
E
F
l
q
??)
"#LFT #Hshr Htl Htok"
.
iExists
1
%
Qp
.
simpl
in
*.
(* Size 0 needs a special case as we can't keep the thread-local invariant open. *)
destruct
(
ty_size
ty
)
as
[|
sz
]
eqn
:
Hsz
.
{
iMod
(
na_bor_acc
with
"LFT Hshr Htok Htl"
)
as
"(Hown & Htl & Hclose)"
;
[
solve_ndisj
..|]
.
iDestruct
"Hown"
as
(
vl
)
"[H↦ #Hown]"
.
simpl
.
assert
(
F
∖
∅
=
F
)
as
->
by
set_solver
+.
iAssert
(
▷
⌜
length
vl
=
ty_size
ty
⌝
)
%
I
with
"[#]"
as
">EQ"
.
{
iNext
.
by
iApply
ty_size_eq
.
}
rewrite
Hsz
.
iDestruct
"EQ"
as
%
EQ
.
iMod
(
"Hclose"
with
"[H↦] Htl"
)
as
"[$ $]"
.
{
iExists
vl
.
by
iFrame
.
}
iModIntro
.
iSplitL
""
.
{
iNext
.
iExists
vl
.
destruct
vl
;
last
done
.
iFrame
"Hown"
.
by
iApply
heap_mapsto_vec_nil
.
}
by
iIntros
"$ _"
.
}
(* Now we are in the non-0 case. *)
iMod
(
na_bor_acc
with
"LFT Hshr Htok Htl"
)
as
"($ & Htl & Hclose)"
;
[
solve_ndisj
..|]
.
iDestruct
(
na_own_acc
with
"Htl"
)
as
"($ & Hclose')"
;
first
by
set_solver
.
iIntros
"!> Htl Hown"
.
iPoseProof
(
"Hclose'"
with
"Htl"
)
as
"Htl"
.
iMod
(
"Hclose"
with
"Hown Htl"
)
as
"[$ $]"
.
done
.
Qed
.
Global
Instance
cell_send
:
Send
ty
→
Send
(
cell
ty
)
.
Proof
.
intros
.
split
.
simpl
.
apply
send_change_tid
.
Qed
.
End
cell
.
Section
typing
.
Context
`{
typeG
Σ
}
.
(* Constructing a cell is a coercion. *)
Lemma
tctx_mk_cell
E
L
ty
p
:
tctx_incl
E
L
[
p
◁
ty
]
[
p
◁
cell
ty
]
.
Proof
.
iIntros
(???)
"#LFT $ $ Hty"
.
rewrite
!
tctx_interp_singleton
/=.
done
.
Qed
.
(* Same for the other direction *)
Lemma
tctx_unmk_cell
E
L
ty
p
:
tctx_incl
E
L
[
p
◁
ty
]
[
p
◁
cell
ty
]
.
Proof
.
iIntros
(???)
"#LFT $ $ Hty"
.
rewrite
!
tctx_interp_singleton
/=.
done
.
Qed
.
(* TODO: get, set; potentially more operations? *)
End
typing
.
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