Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
George Pirlea
Iris
Commits
7c354ddb
Commit
7c354ddb
authored
Mar 12, 2016
by
Ralf Jung
Browse files
change some lfiting lemmas to make it clear why they are called 'atomic'
parent
0dbb9032
Changes
4
Hide whitespace changes
Inline
Side-by-side
docs/derived.tex
View file @
7c354ddb
...
...
@@ -208,13 +208,13 @@ The following rules can be derived for Hoare triples.
We can derive some specialized forms of the lifting axioms for the operational semantics.
\begin{mathparpagebreakable}
\infer
[wp-lift-atomic-step]
{
\to
val
(
\expr
_
1)
=
\bot
\and
{
\
a
to
mic
(
\expr
_
1)
\and
\red
(
\expr
_
1,
\state
_
1)
\and
\All
\expr
_
2,
\state
_
2,
\expr
_
f.
\expr
_
1,
\state
_
1
\step
\expr
_
2,
\state
_
2,
\expr
_
f
\Ra
\
Exists\val
_
2.
\toval
(
\expr
_
2) =
\val
_
2
\land
\pred
(
\val
_
2,
\state
_
2,
\expr
_
f)
}
{
\later\ownPhys
{
\state
_
1
}
*
\later\All
\val
,
\state
_
2,
\expr
_
f.
\pred
(
\val
,
\state
_
2,
\expr
_
f)
\land
\ownPhys
{
\state
_
2
}
\wand
\prop
*
\wpre
{
\expr
_
f
}
[
\top
]
{
\Ret\any
.
\TRUE
}
\proves
\wpre
{
\expr
_
1
}
[
\mask
_
1]
{
\Ret\va
l
.
\prop
}}
\All
\expr
_
2,
\state
_
2,
\expr
_
f.
\expr
_
1,
\state
_
1
\step
\expr
_
2,
\state
_
2,
\expr
_
f
\Ra
\
pred
(
\expr
_
2,
\state
_
2,
\expr
_
f)
}
{
\later\ownPhys
{
\state
_
1
}
*
\later\All
\val
_
2
,
\state
_
2,
\expr
_
f.
\pred
(
\
of
val
(
\val
)
,
\state
_
2,
\expr
_
f)
\land
\ownPhys
{
\state
_
2
}
\wand
\prop
[\val_2/\var]
*
\wpre
{
\expr
_
f
}
[
\top
]
{
\Ret\any
.
\TRUE
}
\proves
\wpre
{
\expr
_
1
}
[
\mask
_
1]
{
\Ret\va
r
.
\prop
}}
\infer
[wp-lift-atomic-det-step]
{
\to
val
(
\expr
_
1)
=
\bot
\and
{
\
a
to
mic
(
\expr
_
1)
\and
\red
(
\expr
_
1,
\state
_
1)
\and
\All
\expr
'
_
2,
\state
'
_
2,
\expr
_
f'.
\expr
_
1,
\state
_
1
\step
\expr
_
2,
\state
_
2,
\expr
_
f
\Ra
\state
_
2 =
\state
_
2'
\land
\toval
(
\expr
_
2') =
\val
_
2
\land
\expr
_
f =
\expr
_
f'
}
{
\later\ownPhys
{
\state
_
1
}
*
\later
(
\ownPhys
{
\state
_
2
}
\wand
\prop
[\val_2/\var]
*
\wpre
{
\expr
_
f
}
[
\top
]
{
\Ret\any
.
\TRUE
}
)
\proves
\wpre
{
\expr
_
1
}
[
\mask
_
1]
{
\Ret\var
.
\prop
}}
...
...
heap_lang/lang.v
View file @
7c354ddb
...
...
@@ -447,7 +447,7 @@ Proof.
end
;
auto
with
f_equal
.
Qed
.
Instance
:
Inj
(=)
(=)
of_val
.
Instance
of_val_inj
:
Inj
(=)
(=)
of_val
.
Proof
.
by
intros
??
Hv
;
apply
(
inj
Some
)
;
rewrite
-!
to_of_val
Hv
.
Qed
.
Instance
fill_item_inj
Ki
:
Inj
(=)
(=)
(
fill_item
Ki
).
...
...
heap_lang/lifting.v
View file @
7c354ddb
...
...
@@ -25,16 +25,18 @@ Lemma wp_alloc_pst E σ e v Φ :
⊢
WP
Alloc
e
@
E
{{
Φ
}}.
Proof
.
(* TODO RJ: This works around ssreflect bug #22. *)
intros
.
set
(
φ
v'
σ
'
ef
:
=
∃
l
,
ef
=
None
∧
v
'
=
Loc
V
l
∧
σ
'
=
<[
l
:
=
v
]>
σ
∧
σ
!!
l
=
None
).
intros
.
set
(
φ
(
e'
:
expr
[])
σ
'
ef
:
=
∃
l
,
ef
=
None
∧
e
'
=
Loc
l
∧
σ
'
=
<[
l
:
=
v
]>
σ
∧
σ
!!
l
=
None
).
rewrite
-(
wp_lift_atomic_step
(
Alloc
e
)
φ
σ
)
//
/
φ
;
last
by
intros
;
inv_step
;
eauto
8
.
last
(
by
intros
;
inv_step
;
eauto
8
)
;
last
(
by
simpl
;
eauto
)
.
apply
sep_mono
,
later_mono
;
first
done
.
apply
forall_intro
=>
e
2
;
apply
forall_intro
=>
σ
2
;
apply
forall_intro
=>
ef
.
apply
forall_intro
=>
v
2
;
apply
forall_intro
=>
σ
2
;
apply
forall_intro
=>
ef
.
apply
wand_intro_l
.
rewrite
always_and_sep_l
-
assoc
-
always_and_sep_l
.
apply
const_elim_l
=>-[
l
[->
[->
[->
?]]]].
by
rewrite
(
forall_elim
l
)
right_id
const_equiv
//
left_id
wand_elim_r
.
apply
const_elim_l
=>-[
l
[->
[
Hl
[->
?]]]].
rewrite
(
forall_elim
l
)
right_id
const_equiv
//
left_id
wand_elim_r
.
rewrite
-(
of_to_val
(
Loc
l
)
(
LocV
l
))
//
in
Hl
.
apply
of_val_inj
in
Hl
.
by
subst
.
Qed
.
Lemma
wp_load_pst
E
σ
l
v
Φ
:
...
...
@@ -42,7 +44,7 @@ Lemma wp_load_pst E σ l v Φ :
(
▷
ownP
σ
★
▷
(
ownP
σ
-
★
Φ
v
))
⊢
WP
Load
(
Loc
l
)
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_atomic_det_step
σ
v
σ
None
)
?right_id
//
;
last
by
intros
;
inv_step
;
eauto
using
to_of_val
.
last
(
by
intros
;
inv_step
;
eauto
using
to_of_val
)
;
simpl
;
by
eauto
.
Qed
.
Lemma
wp_store_pst
E
σ
l
e
v
v'
Φ
:
...
...
@@ -51,7 +53,7 @@ Lemma wp_store_pst E σ l e v v' Φ :
⊢
WP
Store
(
Loc
l
)
e
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_atomic_det_step
σ
(
LitV
LitUnit
)
(<[
l
:
=
v
]>
σ
)
None
)
?right_id
//
;
last
by
intros
;
inv_step
;
eauto
.
?right_id
//
;
last
(
by
intros
;
inv_step
;
eauto
)
;
simpl
;
by
eauto
.
Qed
.
Lemma
wp_cas_fail_pst
E
σ
l
e1
v1
e2
v2
v'
Φ
:
...
...
@@ -60,7 +62,8 @@ Lemma wp_cas_fail_pst E σ l e1 v1 e2 v2 v' Φ :
⊢
WP
CAS
(
Loc
l
)
e1
e2
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_atomic_det_step
σ
(
LitV
$
LitBool
false
)
σ
None
)
?right_id
//
;
last
by
intros
;
inv_step
;
eauto
.
?right_id
//
;
last
(
by
intros
;
inv_step
;
eauto
)
;
simpl
;
split_and
?
;
by
eauto
.
Qed
.
Lemma
wp_cas_suc_pst
E
σ
l
e1
v1
e2
v2
Φ
:
...
...
@@ -69,7 +72,8 @@ Lemma wp_cas_suc_pst E σ l e1 v1 e2 v2 Φ :
⊢
WP
CAS
(
Loc
l
)
e1
e2
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_atomic_det_step
σ
(
LitV
$
LitBool
true
)
(<[
l
:
=
v2
]>
σ
)
None
)
?right_id
//
;
last
by
intros
;
inv_step
;
eauto
.
(<[
l
:
=
v2
]>
σ
)
None
)
?right_id
//
;
last
(
by
intros
;
inv_step
;
eauto
)
;
simpl
;
split_and
?
;
by
eauto
.
Qed
.
(** Base axioms for core primitives of the language: Stateless reductions *)
...
...
program_logic/lifting.v
View file @
7c354ddb
...
...
@@ -61,40 +61,42 @@ Qed.
Import
uPred
.
Lemma
wp_lift_atomic_step
{
E
Φ
}
e1
(
φ
:
val
Λ
→
state
Λ
→
option
(
expr
Λ
)
→
Prop
)
σ
1
:
to
_val
e1
=
None
→
(
φ
:
expr
Λ
→
state
Λ
→
option
(
expr
Λ
)
→
Prop
)
σ
1
:
a
to
mic
e1
→
reducible
e1
σ
1
→
(
∀
e2
σ
2
ef
,
prim_step
e1
σ
1 e2
σ
2
ef
→
∃
v2
,
to_val
e2
=
Some
v2
∧
φ
v
2
σ
2
ef
)
→
(
▷
ownP
σ
1
★
▷
∀
v2
σ
2
ef
,
■
φ
v2
σ
2
ef
∧
ownP
σ
2
-
★
Φ
v2
★
wp_fork
ef
)
prim_step
e1
σ
1 e2
σ
2
ef
→
φ
e
2
σ
2
ef
)
→
(
▷
ownP
σ
1
★
▷
∀
v2
σ
2
ef
,
■
φ
(
of_val
v2
)
σ
2
ef
∧
ownP
σ
2
-
★
Φ
v2
★
wp_fork
ef
)
⊢
WP
e1
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_step
E
E
(
λ
e2
σ
2
ef
,
∃
v2
,
to_val
e2
=
Some
v2
∧
φ
v2
σ
2
ef
)
_
e1
σ
1
)
//
;
[].
intros
.
rewrite
-(
wp_lift_step
E
E
(
λ
e2
σ
2
ef
,
is_Some
(
to_val
e2
)
∧
φ
e2
σ
2
ef
)
_
e1
σ
1
)
//
;
try
by
(
eauto
using
atomic_not_val
,
atomic_step
).
rewrite
-
pvs_intro
.
apply
sep_mono
,
later_mono
;
first
done
.
apply
forall_intro
=>
e2'
;
apply
forall_intro
=>
σ
2
'
.
apply
forall_intro
=>
ef
;
apply
wand_intro_l
.
rewrite
always_and_sep_l
-
assoc
-
always_and_sep_l
.
apply
const_elim_l
=>-[
v2
'
[
Hv
?]
]
/=.
apply
const_elim_l
=>-[
[
v2
Hv
]
?]
/=.
rewrite
-
pvs_intro
.
rewrite
(
forall_elim
v2'
)
(
forall_elim
σ
2
'
)
(
forall_elim
ef
)
const_equiv
//.
by
rewrite
left_id
wand_elim_r
-(
wp_value
_
_
e2'
v2'
).
rewrite
(
forall_elim
v2
)
(
forall_elim
σ
2
'
)
(
forall_elim
ef
)
const_equiv
//.
rewrite
left_id
wand_elim_r
-(
wp_value
_
_
e2'
v2
)
//.
by
erewrite
of_to_val
.
Qed
.
Lemma
wp_lift_atomic_det_step
{
E
Φ
e1
}
σ
1
v2
σ
2
ef
:
to
_val
e1
=
None
→
a
to
mic
e1
→
reducible
e1
σ
1
→
(
∀
e2'
σ
2
'
ef'
,
prim_step
e1
σ
1 e2
'
σ
2
'
ef'
→
σ
2
=
σ
2
'
∧
to_val
e2'
=
Some
v2
∧
ef
=
ef'
)
→
(
▷
ownP
σ
1
★
▷
(
ownP
σ
2
-
★
Φ
v2
★
wp_fork
ef
))
⊢
WP
e1
@
E
{{
Φ
}}.
Proof
.
intros
.
rewrite
-(
wp_lift_atomic_step
_
(
λ
v
2'
σ
2
'
ef'
,
σ
2
=
σ
2
'
∧
v2
=
v2
'
∧
ef
=
ef'
)
σ
1
)
//
;
last
naive_solver
.
intros
.
rewrite
-(
wp_lift_atomic_step
_
(
λ
e
2'
σ
2
'
ef'
,
σ
2
=
σ
2
'
∧
to_val
e2'
=
Some
v2
∧
ef
=
ef'
)
σ
1
)
//.
apply
sep_mono
,
later_mono
;
first
done
.
apply
forall_intro
=>
e2'
;
apply
forall_intro
=>
σ
2
'
;
apply
forall_intro
=>
ef'
.
apply
wand_intro_l
.
rewrite
always_and_sep_l
-
assoc
-
always_and_sep_l
.
apply
const_elim_l
=>-[->
[->
->]]
/=.
by
rewrite
wand_elim_r
.
rewrite
always_and_sep_l
-
assoc
-
always_and_sep_l
to_of_val
.
apply
const_elim_l
=>-[->
[
[->
]
->]]
/=.
by
rewrite
wand_elim_r
.
Qed
.
Lemma
wp_lift_pure_det_step
{
E
Φ
}
e1
e2
ef
:
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment