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
Model registry
Operate
Environments
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
Daniël Louwrink
lambda-rust
Commits
afaf93f3
Commit
afaf93f3
authored
4 years ago
by
Daniël Louwrink
Browse files
Options
Downloads
Patches
Plain Diff
prove retag (unique/sharedro)
parent
05577c8d
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/lang/stbor/stbor_sim.v
+220
-262
220 additions, 262 deletions
theories/lang/stbor/stbor_sim.v
with
220 additions
and
262 deletions
theories/lang/stbor/stbor_sim.v
+
220
−
262
View file @
afaf93f3
...
@@ -4,7 +4,7 @@ From lrust.lang Require Export lang_base.
...
@@ -4,7 +4,7 @@ From lrust.lang Require Export lang_base.
From
lrust
.
lang
.
stbor
Require
Export
stbor_semantics
.
From
lrust
.
lang
.
stbor
Require
Export
stbor_semantics
.
Set
Default
Proof
Using
"Type"
.
Set
Default
Proof
Using
"Type"
.
(** Simulation relation *)
(**
*
Simulation relation *)
Inductive
stack_is_tail_item
:
item
→
Prop
:=
Inductive
stack_is_tail_item
:
item
→
Prop
:=
|
stack_is_tail_item_unique
tg
:
stack_is_tail_item
(
ItUnique
tg
)
|
stack_is_tail_item_unique
tg
:
stack_is_tail_item
(
ItUnique
tg
)
|
stack_is_tail_item_disabled
:
stack_is_tail_item
ItDisabled
.
|
stack_is_tail_item_disabled
:
stack_is_tail_item
ItDisabled
.
...
@@ -60,7 +60,7 @@ Inductive stack_sub : stack → stack → Prop :=
...
@@ -60,7 +60,7 @@ Inductive stack_sub : stack → stack → Prop :=
Definition
stack_rel_stack
(
stkphys
stklog
:
stack
)
:
Prop
:=
Definition
stack_rel_stack
(
stkphys
stklog
:
stack
)
:
Prop
:=
∃
stkparsed
,
stack_parse
stkphys
stkparsed
∧
stack_sub
stklog
stkparsed
.
∃
stkparsed
,
stack_parse
stkphys
stkparsed
∧
stack_sub
stklog
stkparsed
.
(** Access predicates *)
(**
*
Access predicates *)
Inductive
stack_log_grants_write
(
tg
:
tag
)
:
stack
→
Prop
:=
Inductive
stack_log_grants_write
(
tg
:
tag
)
:
stack
→
Prop
:=
|
stack_log_grants_write_here
it
stk
:
|
stack_log_grants_write_here
it
stk
:
item_grants_write
tg
it
→
item_grants_write
tg
it
→
...
@@ -75,7 +75,9 @@ Inductive stack_log_grants_read (tg : tag) : stack → Prop :=
...
@@ -75,7 +75,9 @@ Inductive stack_log_grants_read (tg : tag) : stack → Prop :=
stack_log_grants_read
tg
stk
→
stack_log_grants_read
tg
stk
→
stack_log_grants_read
tg
(
it
::
stk
)
.
stack_log_grants_read
tg
(
it
::
stk
)
.
(** Writing *)
Definition
stack_log_no_sharedro
(
stklog
:
stack
)
:
Prop
:=
¬
∃
tgs
stklog'
,
stklog
=
ItSharedRO
tgs
::
stklog'
.
(** * Writing *)
Lemma
stack_sub_write_skip_sharedro
tg
tgs
stklog
stkparsed
:
Lemma
stack_sub_write_skip_sharedro
tg
tgs
stklog
stkparsed
:
stack_log_grants_write
tg
stklog
→
stack_log_grants_write
tg
stklog
→
stack_sub
stklog
(
ItSharedRO
tgs
::
stkparsed
)
→
stack_sub
stklog
(
ItSharedRO
tgs
::
stkparsed
)
→
...
@@ -129,11 +131,11 @@ Proof.
...
@@ -129,11 +131,11 @@ Proof.
-
apply
stack_sub_drop_shared
.
apply
Hsub
.
-
apply
stack_sub_drop_shared
.
apply
Hsub
.
Qed
.
Qed
.
Lemma
write_single_preserve
tg
stklog
stkphys1
stkphys2
:
Lemma
write_single_preserve
'
tg
stklog
stkphys1
stkphys2
:
write_single
tg
stkphys1
=
Some
stkphys2
→
write_single
tg
stkphys1
=
Some
stkphys2
→
stack_log_grants_write
tg
stklog
→
stack_log_grants_write
tg
stklog
→
stack_rel_stack
stkphys1
stklog
→
stack_rel_stack
stkphys1
stklog
→
stack_rel_stack
stkphys2
stklog
.
∃
stkparsed
,
stack_parse_tail
stkphys2
stkparsed
∧
stack_sub_tail
stklog
stkparsed
.
Proof
.
Proof
.
intros
Hwrite
Hgrants
Hrel
.
intros
Hwrite
Hgrants
Hrel
.
destruct
Hrel
as
(
stkparsed
&
Hparse
&
Hsub
)
.
destruct
Hrel
as
(
stkparsed
&
Hparse
&
Hsub
)
.
...
@@ -144,26 +146,87 @@ Proof.
...
@@ -144,26 +146,87 @@ Proof.
case_decide
as
Hgrants'
;
case_decide
as
Hgrants'
;
rewrite
-/
write_single
in
Hwrite
;
rewrite
-/
write_single
in
Hwrite
;
first
inversion
Hgrants'
.
first
inversion
Hgrants'
.
eapply
stack_rel_from_tail
;
by
eapply
write_single_preserve_tail
.
by
eapply
write_single_preserve_tail
.
-
(* No SharedRO on top *)
-
(* No SharedRO on top *)
eapply
stack_sub_write_skip_sharedro
in
Hsub
;
last
done
.
eapply
stack_sub_write_skip_sharedro
in
Hsub
;
last
done
.
eapply
stack_rel_from_tail
;
by
eapply
write_single_preserve_tail
.
by
eapply
write_single_preserve_tail
.
Qed
.
Lemma
write_single_preserve
tg
stklog
stkphys1
stkphys2
:
write_single
tg
stkphys1
=
Some
stkphys2
→
stack_log_grants_write
tg
stklog
→
stack_rel_stack
stkphys1
stklog
→
stack_rel_stack
stkphys2
stklog
.
Proof
.
intros
Hwrite
Hgrants
Hrel
.
eapply
stack_rel_from_tail
;
by
eapply
write_single_preserve'
.
Qed
.
(** * Reading *)
(** ** Inversion lemmas about semantics *)
Lemma
read_single_sharedrw_inv
tg
tgs
stkphys1
stkphys2
:
read_single
tg
(
ItSharedRW
tgs
::
stkphys1
)
=
Some
stkphys2
→
(
item_grants_read
tg
(
ItSharedRW
tgs
)
∧
stkphys2
=
ItSharedRW
tgs
::
stkphys1
)
∨
(
∃
stkphys2'
,
¬
item_grants_read
tg
(
ItSharedRW
tgs
)
∧
stkphys2
=
ItSharedRW
tgs
::
stkphys2'
∧
read_single
tg
stkphys1
=
Some
stkphys2'
)
.
Proof
.
intros
Hread
.
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
-
left
.
inversion
Hread
;
split
;
done
.
-
right
.
apply
fmap_Some_1
in
Hread
as
(
stkphys2'
&
Hread'
&
Heq
)
.
rewrite
/
read_traverse_item
decide_True
in
Heq
;
last
constructor
.
exists
stkphys2'
;
split
;
last
split
;
assumption
.
Qed
.
Lemma
stack_is_tail_item_traverse
it
stk
:
stack_is_tail_item
it
→
read_traverse_item
it
stk
=
ItDisabled
::
stk
.
Proof
.
inversion
1
.
-
by
rewrite
/
read_traverse_item
decide_False
;
last
inversion
1
.
-
by
rewrite
/
read_traverse_item
decide_True
;
last
constructor
.
Qed
.
Qed
.
(** Reading *)
Lemma
read_single_unique_inv
tg
it
stkphys1
stkphys2
:
Lemma
stack_log_grants_not_sharedro
tg
tgs1
tgs2
:
stack_is_tail_item
it
→
read_single
tg
(
it
::
stkphys1
)
=
Some
stkphys2
→
(
item_grants_read
tg
it
∧
stkphys2
=
it
::
stkphys1
)
∨
(
∃
stkphys2'
,
¬
item_grants_read
tg
it
∧
stkphys2
=
ItDisabled
::
stkphys2'
∧
read_single
tg
stkphys1
=
Some
stkphys2'
)
.
Proof
.
intros
Htailit
Hread
.
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
-
left
.
inversion
Hread
;
split
;
done
.
-
right
.
apply
fmap_Some_1
in
Hread
as
(
stkphys2'
&
Hread'
&
Heq
)
.
rewrite
stack_is_tail_item_traverse
in
Heq
;
last
assumption
.
exists
stkphys2'
;
split
;
last
split
;
assumption
.
Qed
.
Lemma
read_single_sharedro_inv
tg
tgs
stkphys1
stkphys2
:
read_single
tg
(
ItSharedRO
tgs
::
stkphys1
)
=
Some
stkphys2
→
(
item_grants_read
tg
(
ItSharedRO
tgs
)
∧
stkphys2
=
ItSharedRO
tgs
::
stkphys1
)
∨
(
∃
stkphys2'
,
¬
item_grants_read
tg
(
ItSharedRO
tgs
)
∧
stkphys2
=
ItSharedRO
tgs
::
stkphys2'
∧
read_single
tg
stkphys1
=
Some
stkphys2'
)
.
Proof
.
intros
Hread
.
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
-
left
.
by
inversion
Hread
.
-
right
.
apply
fmap_Some_1
in
Hread
as
(
stkphys2'
&
Hread
&
Heq
)
.
rewrite
/
read_traverse_item
decide_True
in
Heq
;
last
constructor
.
rewrite
Heq
.
by
exists
stkphys2'
.
Qed
.
(** ** Properties of access predicates *)
Lemma
item_grants_read_not_sharedro
tg
tgs1
tgs2
:
tgs1
⊆
tgs2
→
tgs1
⊆
tgs2
→
¬
item_grants_read
tg
(
ItSharedRO
tgs2
)
→
¬
item_grants_read
tg
(
ItSharedRO
tgs2
)
→
¬
item_grants_read
tg
(
ItSharedRO
tgs1
)
.
¬
item_grants_read
tg
(
ItSharedRO
tgs1
)
.
Proof
.
intros
Hsub
Hit2
Hit1
.
apply
Hit2
.
constructor
.
inversion
Hit1
.
set_solver
.
Qed
.
Proof
.
intros
Hsub
Hit2
Hit1
.
apply
Hit2
.
constructor
.
inversion
Hit1
.
set_solver
.
Qed
.
Lemma
stack_log
_grants_not_sharedrw
tg
tgs1
tgs2
:
Lemma
item
_grants_
read_
not_sharedrw
tg
tgs1
tgs2
:
tgs1
⊆
tgs2
→
tgs1
⊆
tgs2
→
¬
item_grants_read
tg
(
ItSharedRW
tgs2
)
→
¬
item_grants_read
tg
(
ItSharedRW
tgs2
)
→
¬
item_grants_read
tg
(
ItSharedRW
tgs1
)
.
¬
item_grants_read
tg
(
ItSharedRW
tgs1
)
.
Proof
.
intros
Hsub
Hit2
Hit1
.
apply
Hit2
.
constructor
.
inversion
Hit1
.
set_solver
.
Qed
.
Proof
.
intros
Hsub
Hit2
Hit1
.
apply
Hit2
.
constructor
.
inversion
Hit1
.
set_solver
.
Qed
.
Lemma
stack_log_grants_not_subitem
tg
it1
it2
:
Lemma
item_grants_read_not_unique
tg
it1
it2
:
stack_sub_unique
it1
it2
→
stack_sub_unique
it1
it2
→
¬
item_grants_read
tg
it2
→
¬
item_grants_read
tg
it2
→
¬
item_grants_read
tg
it1
.
¬
item_grants_read
tg
it1
.
...
@@ -189,7 +252,7 @@ Lemma stack_log_grants_is_disabled_1 tg it1 it2 stklog :
...
@@ -189,7 +252,7 @@ Lemma stack_log_grants_is_disabled_1 tg it1 it2 stklog :
Proof
.
Proof
.
intros
Hit
Hsubit
Hgrants
.
intros
Hit
Hsubit
Hgrants
.
inversion
Hgrants
as
[|?
?
Hskip
]
.
inversion
Hgrants
as
[|?
?
Hskip
]
.
{
exfalso
.
by
eapply
stack_log_grants_not_subitem
.
}
{
exfalso
.
by
eapply
item_grants_read_not_unique
.
}
inversion
Hsubit
;
[
done
|
done
|]
.
inversion
Hsubit
;
[
done
|
done
|]
.
subst
.
inversion
Hskip
.
subst
.
inversion
Hskip
.
Qed
.
Qed
.
...
@@ -204,11 +267,29 @@ Lemma stack_log_grants_is_disabled_2 tg tgs tgs' it1 it2 stklog :
...
@@ -204,11 +267,29 @@ Lemma stack_log_grants_is_disabled_2 tg tgs tgs' it1 it2 stklog :
Proof
.
Proof
.
intros
Hit1
Hit2
Htgs
Hsubit
Hgrants
.
intros
Hit1
Hit2
Htgs
Hsubit
Hgrants
.
inversion
Hgrants
.
inversion
Hgrants
.
{
exfalso
.
by
eapply
stack_log
_grants_not_sharedrw
.
}
{
exfalso
.
by
eapply
item
_grants_
read_
not_sharedrw
.
}
by
eapply
stack_log_grants_is_disabled_1
.
by
eapply
stack_log_grants_is_disabled_1
.
Qed
.
Qed
.
Lemma
stack_log_grants_drop_both
tg
tgs
it
stklog
stkparsed
:
Lemma
stack_log_grants_split_sharedro
tg
tgs
stklog
stkparsed
:
¬
item_grants_read
tg
(
ItSharedRO
tgs
)
→
stack_log_grants_read
tg
stklog
→
stack_sub
stklog
(
ItSharedRO
tgs
::
stkparsed
)
→
∃
stklog'
,
stack_log_grants_read
tg
stklog'
∧
stack_sub_tail
stklog'
stkparsed
∧
(
∀
stkparsed'
,
stack_sub_tail
stklog'
stkparsed'
→
stack_sub
stklog
(
ItSharedRO
tgs
::
stkparsed'
))
.
Proof
.
intros
Hit
Hgrants
Hsub
.
inversion
Hsub
;
subst
.
-
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
by
eapply
item_grants_read_not_sharedro
.
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
intros
stkparsed'
Hsub'
.
by
apply
stack_sub_keep_shared
.
-
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
intros
stkparsed'
Hsub'
.
by
apply
stack_sub_drop_shared
.
Qed
.
Lemma
stack_log_grants_split_sharedrw
tg
tgs
it
stklog
stkparsed
:
¬
item_grants_read
tg
(
ItSharedRW
tgs
)
→
¬
item_grants_read
tg
(
ItSharedRW
tgs
)
→
¬
item_grants_read
tg
it
→
¬
item_grants_read
tg
it
→
stack_log_grants_read
tg
stklog
→
stack_log_grants_read
tg
stklog
→
...
@@ -222,61 +303,25 @@ Proof.
...
@@ -222,61 +303,25 @@ Proof.
inversion
Hsub
.
inversion
Hsub
.
-
exists
stklog
;
split
;
last
split
;
[
assumption
|
assumption
|]
.
-
exists
stklog
;
split
;
last
split
;
[
assumption
|
assumption
|]
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_drop_both
.
assumption
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_drop_both
.
assumption
.
-
subst
.
-
subst
.
assert
(
Hdisabled
:
it1
=
ItDisabled
)
.
assert
(
Hdisabled
:
it1
=
ItDisabled
)
.
{
by
eapply
stack_log_grants_is_disabled_1
;
first
apply
Hit2
.
}
{
by
eapply
stack_log_grants_is_disabled_1
;
first
apply
Hit2
.
}
rewrite
Hdisabled
.
rewrite
Hdisabled
.
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
by
eapply
stack_log_grants_not_subitem
.
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
by
eapply
item_grants_read_not_unique
.
clear
Hsub
.
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
clear
Hsub
.
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_drop_one
;
last
assumption
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_drop_one
;
last
assumption
.
constructor
.
constructor
.
-
subst
.
-
subst
.
assert
(
Hdisabled
:
it1
=
ItDisabled
)
.
assert
(
Hdisabled
:
it1
=
ItDisabled
)
.
{
eapply
stack_log_grants_is_disabled_2
;
eauto
.
}
{
eapply
stack_log_grants_is_disabled_2
;
eauto
.
}
rewrite
Hdisabled
.
rewrite
Hdisabled
.
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
first
.
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
first
.
{
by
eapply
stack_log
_grants_not_sharedrw
.
}
{
by
eapply
item
_grants_
read_
not_sharedrw
.
}
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
first
.
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
first
.
{
by
eapply
stack_log_grants_not_subitem
.
}
{
by
eapply
item_grants_read_not_unique
.
}
clear
Hsub
.
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
clear
Hsub
.
eexists
;
split
;
last
split
;
[
eassumption
|
eassumption
|]
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_keep
;
[
assumption
|
constructor
|
assumption
]
.
intros
stkparsed'
Hsub'
.
apply
stack_sub_tail_keep
;
[
assumption
|
constructor
|
assumption
]
.
Qed
.
Qed
.
Lemma
read_single_sharedrw_inv
tg
tgs
it
stkphys1
stkphys2
:
(** ** Preservation properties *)
read_single
tg
(
ItSharedRW
tgs
::
it
::
stkphys1
)
=
Some
stkphys2
→
(
item_grants_read
tg
(
ItSharedRW
tgs
)
∧
stkphys2
=
ItSharedRW
tgs
::
it
::
stkphys1
)
∨
(
∃
stkphys2'
,
¬
item_grants_read
tg
(
ItSharedRW
tgs
)
∧
stkphys2
=
ItSharedRW
tgs
::
stkphys2'
∧
read_single
tg
(
it
::
stkphys1
)
=
Some
stkphys2'
)
.
Proof
.
intros
Hread
.
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
-
left
.
inversion
Hread
;
split
;
done
.
-
right
.
apply
fmap_Some_1
in
Hread
as
(
stkphys2'
&
Hread'
&
Heq
)
.
rewrite
/
read_traverse_item
decide_True
in
Heq
;
last
constructor
.
exists
stkphys2'
;
split
;
last
split
;
assumption
.
Qed
.
Lemma
stack_is_tail_item_traverse
it
stk
:
stack_is_tail_item
it
→
read_traverse_item
it
stk
=
ItDisabled
::
stk
.
Proof
.
inversion
1
.
-
by
rewrite
/
read_traverse_item
decide_False
;
last
inversion
1
.
-
by
rewrite
/
read_traverse_item
decide_True
;
last
constructor
.
Qed
.
Lemma
read_single_unique_inv
tg
it
stkphys1
stkphys2
:
stack_is_tail_item
it
→
read_single
tg
(
it
::
stkphys1
)
=
Some
stkphys2
→
(
item_grants_read
tg
it
∧
stkphys2
=
it
::
stkphys1
)
∨
(
∃
stkphys2'
,
¬
item_grants_read
tg
it
∧
stkphys2
=
ItDisabled
::
stkphys2'
∧
read_single
tg
stkphys1
=
Some
stkphys2'
)
.
Proof
.
intros
Htailit
Hread
.
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
-
left
.
inversion
Hread
;
split
;
done
.
-
right
.
apply
fmap_Some_1
in
Hread
as
(
stkphys2'
&
Hread'
&
Heq
)
.
rewrite
stack_is_tail_item_traverse
in
Heq
;
last
assumption
.
exists
stkphys2'
;
split
;
last
split
;
assumption
.
Qed
.
Lemma
read_single_preserve_tail
tg
stklog
stkphys1
stkphys2
stkparsed1
:
Lemma
read_single_preserve_tail
tg
stklog
stkphys1
stkphys2
stkparsed1
:
read_single
tg
stkphys1
=
Some
stkphys2
→
read_single
tg
stkphys1
=
Some
stkphys2
→
stack_log_grants_read
tg
stklog
→
stack_log_grants_read
tg
stklog
→
...
@@ -294,7 +339,7 @@ Proof.
...
@@ -294,7 +339,7 @@ Proof.
{
rewrite
Heq
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_shared
.
}
{
rewrite
Heq
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_shared
.
}
apply
read_single_unique_inv
in
Hread'
as
[[
Hit3
Heq3
]|(
stkphys3
&
Hit3
&
Heq3
&
Hread3
)];
last
assumption
.
apply
read_single_unique_inv
in
Hread'
as
[[
Hit3
Heq3
]|(
stkphys3
&
Hit3
&
Heq3
&
Hread3
)];
last
assumption
.
{
subst
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_shared
.
}
{
subst
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_shared
.
}
eapply
stack_log_grants_
drop_both
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
eassumption
..]
.
eapply
stack_log_grants_
split_sharedrw
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
eassumption
..]
.
clear
Hgrants
.
subst
.
clear
Hgrants
.
subst
.
edestruct
IH
as
(
stkparsed4
&
Hparse4
&
Hsub4
);
[
eassumption
..|]
.
edestruct
IH
as
(
stkparsed4
&
Hparse4
&
Hsub4
);
[
eassumption
..|]
.
eexists
;
split
;
last
first
.
eexists
;
split
;
last
first
.
...
@@ -303,7 +348,7 @@ Proof.
...
@@ -303,7 +348,7 @@ Proof.
-
(* No SharedRW on top *)
-
(* No SharedRW on top *)
apply
read_single_unique_inv
in
Hread
as
[[
Hit3
Heq3
]|(
stkphys2'
&
Hit
&
Heq
&
Hread'
)];
last
assumption
.
apply
read_single_unique_inv
in
Hread
as
[[
Hit3
Heq3
]|(
stkphys2'
&
Hit
&
Heq
&
Hread'
)];
last
assumption
.
{
subst
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_noshared
.
}
{
subst
.
eexists
.
split
;
last
eassumption
.
by
apply
stack_parse_tail_noshared
.
}
eapply
stack_log_grants_
drop_both
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
|
eassumption
..];
last
first
.
eapply
stack_log_grants_
split_sharedrw
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
|
eassumption
..];
last
first
.
{
inversion
1
.
set_solver
.
}
{
inversion
1
.
set_solver
.
}
clear
Hgrants
.
subst
.
clear
Hgrants
.
subst
.
edestruct
IH
as
(
stkparsed4
&
Hparse4
&
Hsub4
);
[
eassumption
..|]
.
edestruct
IH
as
(
stkparsed4
&
Hparse4
&
Hsub4
);
[
eassumption
..|]
.
...
@@ -323,210 +368,123 @@ Proof.
...
@@ -323,210 +368,123 @@ Proof.
destruct
stkphys1
as
[|
it
stkphys1
];
first
inversion
Hread
.
destruct
stkphys1
as
[|
it
stkphys1
];
first
inversion
Hread
.
inversion
Hparse
;
subst
.
inversion
Hparse
;
subst
.
-
(* SharedRO on top *)
-
(* SharedRO on top *)
rewrite
/
read_single
in
Hread
;
case_decide
as
Hit
;
rewrite
-/
read_single
in
Hread
.
apply
read_single_sharedro_inv
in
Hread
as
[[
Hit
->
]|(
stkphys3
&
Hit3
&
->
&
Hread
)];
first
by
eexists
.
{
inversion
Hread
;
eexists
_;
split
;
eassumption
.
}
eapply
stack_log_grants_split_sharedro
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
eassumption
..]
.
destruct
(
read_single
_
_)
as
[
stknew
|]
eqn
:
Hread'
;
last
inversion
Hread
.
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse2
&
Hsub2
);
[
eassumption
..|]
.
rewrite
/
read_traverse_item
/=
in
Hread
.
rewrite
decide_True
in
Hread
;
last
constructor
.
eexists
.
split
;
last
eauto
.
inversion
Hread
.
apply
stack_parse_shared
.
apply
Hparse2
.
inversion
Hsub
;
subst
.
(* Is the SharedRO part of the logical stack? *)
+
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
by
eapply
stack_log_grants_not_sharedro
.
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse'
&
Hsub'
);
[
eassumption
..|]
.
eexists
;
split
;
constructor
;
eassumption
.
+
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse'
&
Hsub'
);
[
eassumption
..|]
.
eexists
;
split
;
constructor
;
eassumption
.
-
(* No SharedRO on top *)
-
(* No SharedRO on top *)
inversion
Hsub
;
subst
.
eapply
stack_log_grants_split_sharedro
in
Hsub
as
(
stklog'
&
Hgrants'
&
Hsub'
&
Hback
);
[|
|
eassumption
];
last
first
.
(* Is the (empty) SharedRO part of the logical stack? *)
{
inversion
1
.
set_solver
.
}
+
apply
stack_log_grants_drop_not_matching
in
Hgrants
;
last
(
inversion
1
;
set_solver
)
.
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse2
&
Hsub2
);
[
eassumption
..|]
.
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse'
&
Hsub'
);
[
eassumption
..|]
.
eexists
.
split
;
last
eauto
.
eexists
;
split
;
constructor
;
eassumption
.
apply
stack_parse_noshared
.
apply
Hparse2
.
+
edestruct
read_single_preserve_tail
as
(
stkparsed2
&
Hparse'
&
Hsub'
);
[
eassumption
..|]
.
Qed
.
eexists
;
split
;
constructor
;
eassumption
.
(** * Retagging (Unique) *)
Lemma
retag_unique_single_preserve
tgold
tgnew
stkphys1
stkphys2
stklog
:
retag_unique_single
tgold
tgnew
stkphys1
=
Some
stkphys2
→
stack_log_grants_write
tgold
stklog
→
stack_rel_stack
stkphys1
stklog
→
stack_rel_stack
stkphys2
stklog
.
Proof
.
intros
Hretag
Hgrants
Hrel
.
rewrite
/
retag_unique_single
/=
in
Hretag
.
apply
bind_Some
in
Hretag
as
(
stkphys3
&
Hwrite
&
Heq
)
.
inversion
Heq
.
edestruct
write_single_preserve'
as
(
stkphys4
&
Hparse4
&
Hsub4
);
[
eassumption
..|]
.
eexists
;
split
;
last
first
.
-
apply
stack_sub_drop_shared
.
apply
stack_sub_tail_drop_both
.
apply
Hsub4
.
-
apply
stack_parse_noshared
.
apply
stack_parse_tail_noshared
;
first
constructor
.
apply
Hparse4
.
Qed
.
(** * Retagging (SharedRO) initial *)
Lemma
retag_sharedro_single_initial_preserve
stklog
stkphys
:
stack_log_no_sharedro
stklog
→
stack_rel_stack
stkphys
stklog
→
stack_rel_stack
stkphys
(
ItSharedRO
∅
::
stklog
)
.
Proof
.
intros
Hnoshared
Hrel
.
destruct
Hrel
as
(
stkparsed
&
Hparse
&
Hsub
)
.
inversion
Hparse
;
subst
.
-
eexists
;
split
.
+
apply
stack_parse_shared
;
eassumption
.
+
destruct
Hsub
.
{
exfalso
.
apply
Hnoshared
;
eauto
.
}
apply
stack_sub_keep_shared
;
first
set_solver
.
assumption
.
-
eexists
;
split
.
+
apply
Hparse
.
+
apply
stack_sub_keep_shared
;
first
set_solver
.
inversion
Hsub
;
subst
.
{
exfalso
.
apply
Hnoshared
;
eauto
.
}
assumption
.
Qed
.
Qed
.
(* (** Retagging (Unique) *) *)
(** * Retagging (SharedRO) extend *)
(* Lemma stack_write_single_no_sharedro_tail tg stkphys1 stkphys2 : *)
Lemma
retag_sharedro_single_inv
tgold
tgsnew
stkphys1
stkphys2
:
(* stack_is_tail stkphys1 → *)
retag_sharedro_single
tgold
tgsnew
stkphys1
=
Some
stkphys2
→
(* write_single tg stkphys1 = Some stkphys2 → *)
∃
stkphys2'
,
stkphys2
=
merge_push
(
ItSharedRO
tgsnew
)
stkphys2'
∧
read_single
tgold
stkphys1
=
Some
stkphys2'
.
(* stack_is_tail stkphys2. *)
Proof
.
(* Proof. *)
intros
Hretag
.
(* intros Htail Hwrite. *)
rewrite
/
retag_sharedro_single
in
Hretag
.
(* induction Htail as [|it stkphys1 Hit Htail IH]; first inversion Hwrite. *)
apply
bind_Some
in
Hretag
as
(
stkphys2'
&
Hread
&
Heq2'
)
.
(* rewrite /write_single in Hwrite; case_decide; rewrite -/write_single in Hwrite. *)
inversion
Heq2'
.
(* - inversion Hwrite. apply Forall_cons; split; done. *)
eexists
;
split
;
done
.
(* - apply IH. apply Hwrite. *)
Qed
.
(* Qed. *)
Lemma
merge_push_tail
tgs
stkphys
stkparsed
:
(* Lemma stack_write_single_no_sharedro tg stkphys1 stkphys2 stklog : *)
stack_parse_tail
stkphys
stkparsed
→
(* stack_rel_stack stkphys1 stklog → *)
merge_push
(
ItSharedRO
tgs
)
stkphys
=
ItSharedRO
tgs
::
stkphys
.
(* write_single tg stkphys1 = Some stkphys2 → *)
Proof
.
(* stack_is_tail stkphys2. *)
intros
Hparse
.
(* Proof. *)
destruct
Hparse
as
[|
|?
?
?
Htailit
];
try
done
.
(* intros Hrel Hwrite. *)
inversion
Htailit
;
done
.
(* destruct Hrel as (stkp & Hrel & Hsub). *)
Qed
.
(* destruct Hrel. *)
(* - rewrite /write_single in Hwrite; case_decide; rewrite -/write_single in Hwrite; first contradiction. *)
Lemma
stack_sub_tail_no_sharedro
stklog
stkparsed
:
(* apply stack_write_single_no_sharedro_tail in Hwrite; done. *)
stack_sub_tail
stklog
stkparsed
→
¬
∃
tgs
stklog'
,
stklog
=
ItSharedRO
tgs
::
stklog'
.
(* - apply stack_write_single_no_sharedro_tail in Hwrite; done. *)
Proof
.
(* Qed. *)
intros
Hsub
.
induction
Hsub
as
[|?
?
?
?
?
IH
|?
?
?
?
?
Hsubit
|
z
w
x
y
p
]
.
(* Lemma stack_log_grants_write_sub stklog stkphys tg : *)
-
intros
(?
&
?
&
Heq
)
.
inversion
Heq
.
(* stack_log_grants_write stklog tg → *)
-
apply
IH
.
(* stack_rel_stack stkphys stklog → *)
-
intros
(?
&
?
&
Heq
)
.
inversion
Hsubit
;
subst
;
inversion
Heq
.
(* stklog `sublist_of` stkphys. *)
-
intros
(?
&
?
&
Heq
)
.
inversion
Heq
.
(* Proof. *)
Qed
.
(* intros Hgrants Hrel. *)
(* destruct Hrel as (stkp & Hrel & Hsub). *)
Lemma
retag_sharedro_single_extend_preserve
tgsnew
tgold
tgs
stkphys1
stkphys2
stklog
:
(* destruct Hrel. *)
retag_sharedro_single
tgold
tgsnew
stkphys1
=
Some
stkphys2
→
(* - apply sublist_cons_r in Hsub as [Hsub|(stklog'&Heq&Hsub)]. *)
stack_log_grants_read
tgold
(
ItSharedRO
tgs
::
stklog
)
→
(* + by apply sublist_cons. *)
stack_rel_stack
stkphys1
(
ItSharedRO
tgs
::
stklog
)
→
(* + rewrite Heq in Hgrants. inversion Hgrants. *)
stack_rel_stack
stkphys2
(
ItSharedRO
(
tgsnew
∪
tgs
)
::
stklog
)
.
(* contradiction. *)
Proof
.
(* - apply sublist_cons_r in Hsub as [Hsub|(stklog'&Heq&Hsub)]. *)
intros
Hretag
Hgrants
Hrel
.
(* + apply Hsub. *)
apply
retag_sharedro_single_inv
in
Hretag
as
(
stkphys2'
&
Heq
&
Hread
)
.
(* + rewrite Heq in Hgrants. inversion Hgrants. *)
edestruct
read_single_preserve
as
(
stkparsed3
&
Hparse3
&
Hsub3
);
[
done
..|]
.
(* contradiction. *)
inversion
Hsub3
;
subst
;
last
first
.
(* Qed. *)
{
exfalso
.
eapply
stack_sub_tail_no_sharedro
;
[
eassumption
|
eauto
]
.
}
inversion
Hparse3
;
subst
.
(* Lemma stack_retag_unique_single_preserve tgnew tgold stkphys1 stkphys2 stklog : *)
-
eexists
;
split
.
(* retag_unique_single tgold tgnew stkphys1 = Some stkphys2 → *)
+
by
apply
stack_parse_shared
.
(* stack_log_grants_write stklog tgold → *)
+
by
apply
stack_sub_keep_shared
;
first
set_solver
.
(* stack_rel_stack stkphys1 stklog → *)
-
assert
(
Heq1
:
tgs
=
∅
)
by
set_solver
.
(* stack_rel_stack stkphys2 (ItUnique tgnew :: stklog). *)
assert
(
Heq2
:
tgsnew
∪
∅
=
tgsnew
)
by
set_solver
.
(* Proof. *)
rewrite
Heq1
Heq2
.
(* intros Hretag Hgrants Hrel. *)
erewrite
merge_push_tail
;
last
done
.
(* rewrite /retag_unique_single in Hretag. *)
eexists
;
split
.
(* destruct (write_single tgold stkphys1) as [stkphys3|] eqn:Hwrite; inversion Hretag. *)
+
by
apply
stack_parse_shared
.
(* assert (stack_is_tail stkphys3) as Htail. *)
+
by
apply
stack_sub_keep_shared
;
first
set_solver
.
(* { eapply stack_write_single_no_sharedro; done. } *)
Qed
.
(* eapply stack_write_single_preserve in Hwrite; try done. *)
(* exists (ItSharedRO ∅ :: ItUnique tgnew :: stkphys3); split; first constructor. *)
(** * Retagging (SharedRW) initial *)
(* { apply Forall_cons; split; last done; constructor. } *)
(** * Retagging (SharedRW) extend *)
(* eapply stack_log_grants_write_sub in Hwrite; last done. *)
(* apply sublist_cons, sublist_skip, Hwrite. *)
(** * Logical popping *)
(* Qed. *)
Lemma
pop_prefix_preserve
stkphys
stklog1
stklog2
:
stklog2
`
suffix_of
`
stklog1
→
(* Lemma stack_retag_unique_single_step tgold tgnew stkphys1 stklog : *)
stack_rel_stack
stkphys
stklog1
→
(* stack_log_grants_write stklog tgold → *)
stack_rel_stack
stkphys
stklog2
.
(* stack_rel_stack stkphys1 stklog → *)
Proof
.
Admitted
.
(* ∃ stkphys2, retag_unique_single tgold tgnew stkphys1 = Some stkphys2. *)
(* Proof. *)
(** * Logical disabling *)
(* intros Hgrants Hrel. *)
(* edestruct stack_write_single_step as (stkphys3 & Hwrite); try done. *)
(* exists (ItUnique tgnew :: stkphys3). *)
(* by rewrite /retag_unique_single Hwrite. *)
(* Qed. *)
(* (** Retagging (SharedRO) *) *)
(* Lemma push_sharedro_subseteq tgsnew stk : *)
(* ∃ tgs' stkrest, push_sharedro tgsnew stk = ItSharedRO tgs' :: stkrest ∧ tgsnew ⊆ tgs'. *)
(* Proof. *)
(* destruct stk as [|[tgit|tgsit|tgsit] stk]. *)
(* - by exists tgsnew, []. *)
(* - by exists tgsnew, (ItUnique tgit :: stk). *)
(* - by exists tgsnew, (ItSharedRW tgsit :: stk). *)
(* - by exists (tgsnew ∪ tgsit), stk; split; last set_solver. *)
(* Qed. *)
(* Lemma stack_is_tail_push_sharedro tgsnew stk : *)
(* stack_is_tail stk → *)
(* push_sharedro tgsnew stk = ItSharedRO tgsnew :: stk. *)
(* Proof. by intros [|? ? [|]]. Qed. *)
(* Lemma stack_is_tail_sublist stk1 stk2 : *)
(* stk1 `sublist_of` stk2 → *)
(* stack_is_tail stk2 → *)
(* stack_is_tail stk1. *)
(* Proof. *)
(* intros Hsub. rewrite /stack_is_tail Forall_forall. *)
(* intros Htail. *)
(* apply Forall_forall. *)
(* intros it Helem. *)
(* apply Htail. *)
(* by eapply sublist_submseteq, elem_of_submseteq in Hsub; last done. *)
(* Qed. *)
(* Lemma stack_rel_stack_push_sharedro_empty stkphys stklog : *)
(* stack_rel_stack stkphys stklog → *)
(* stack_rel_stack stkphys (push_sharedro ∅ stklog). *)
(* Proof. *)
(* intros Hrel. *)
(* destruct Hrel as (stkp & [|] & Hsub); apply sublist_cons_r in Hsub as [Hsub|(stklog'&Heq&Hsub)]. *)
(* - assert (stack_is_tail stklog) by by eapply stack_is_tail_sublist. *)
(* rewrite (stack_is_tail_push_sharedro ∅ stklog); last done. *)
(* exists (ItSharedRO ∅ :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - rewrite Heq. *)
(* exists (ItSharedRO (∅ ∪ tgs') :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - assert (stack_is_tail stklog) by by eapply stack_is_tail_sublist. *)
(* rewrite (stack_is_tail_push_sharedro ∅ stklog); last done. *)
(* exists (ItSharedRO ∅ :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - rewrite Heq. *)
(* exists (ItSharedRO ∅ :: stk); split; first (constructor; set_solver). *)
(* assert (Heq2 : (∅ : gset tag) ∪ ∅ = ∅) by set_solver. *)
(* simpl. rewrite Heq2. by apply sublist_skip. *)
(* Qed. *)
(* Lemma stack_rel_stack_push_sharedro tgsnew stkphys stklog : *)
(* stack_rel_stack stkphys stklog → *)
(* stack_rel_stack (push_sharedro tgsnew stkphys) (push_sharedro tgsnew stklog). *)
(* Proof. *)
(* intros Hrel. *)
(* destruct Hrel as (stkp & [|] & Hsub); apply sublist_cons_r in Hsub as [Hsub|(stklog'&Heq&Hsub)]. *)
(* - assert (stack_is_tail stklog) by by eapply stack_is_tail_sublist. *)
(* rewrite (stack_is_tail_push_sharedro tgsnew stklog); last done. *)
(* exists (ItSharedRO tgsnew :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - rewrite Heq. *)
(* exists (ItSharedRO (tgsnew ∪ tgs') :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - assert (stack_is_tail stklog) by by eapply stack_is_tail_sublist. *)
(* rewrite (stack_is_tail_push_sharedro tgsnew stklog); last done. *)
(* rewrite (stack_is_tail_push_sharedro tgsnew stk); last done. *)
(* exists (ItSharedRO tgsnew :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* - rewrite Heq. *)
(* rewrite (stack_is_tail_push_sharedro tgsnew stk); last done. *)
(* exists (ItSharedRO (tgsnew ∪ ∅) :: stk); split; first (constructor; set_solver). *)
(* by apply sublist_skip. *)
(* Qed. *)
(* Lemma stack_retag_sharedro_single_preserve tgold tgsnew stkphys1 stkphys2 stklog : *)
(* retag_sharedro_single tgold tgsnew stkphys1 = Some stkphys2 → *)
(* stack_log_grants_read stklog tgold → *)
(* stack_rel_stack stkphys1 stklog → *)
(* stack_rel_stack stkphys2 (push_sharedro tgsnew stklog). *)
(* Proof. *)
(* intros Hretag Hgrants Hrel. *)
(* rewrite /retag_sharedro_single in Hretag. *)
(* destruct (read_single tgold stkphys1) as [stkphys3|] eqn:Hread; inversion Hretag. *)
(* eapply stack_read_single_preserve in Hread; try done. *)
(* apply stack_rel_stack_push_sharedro. apply Hread. *)
(* Qed. *)
(* Lemma stack_retag_sharedro_single_step tgsnew tgold stklog stkphys1 : *)
(* stack_log_grants_read stklog tgold → *)
(* stack_rel_stack stkphys1 stklog → *)
(* ∃ stkphys2, retag_sharedro_single tgold tgsnew stkphys1 = Some stkphys2. *)
(* Proof. *)
(* intros Hgrants Hrel. *)
(* edestruct stack_read_single_step as [stkphys3 Hread]; try done. *)
(* exists (push_sharedro tgsnew stkphys3). *)
(* by rewrite /retag_sharedro_single Hread. *)
(* Qed. *)
(* (** Logical removal *) *)
(* Lemma stack_remove_preserve stklog1 stklog2 stkphys : *)
(* stklog2 `sublist_of` stklog1 → *)
(* stack_rel_stack stkphys stklog1 → *)
(* stack_rel_stack stkphys stklog2. *)
(* Proof. *)
(* intros Hsub (stkp & Hrel & Hsub'). *)
(* exists stkp; split; first done. *)
(* by transitivity stklog1. *)
(* Qed. *)
(* (** Retagging (SharedRW) *) *)
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