Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
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
Package Registry
Model registry
Operate
Terraform modules
Monitor
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
Gaëtan Gilbert
Iris
Commits
cc67112b
Commit
cc67112b
authored
5 years ago
by
Dan Frumin
Browse files
Options
Downloads
Patches
Plain Diff
Add twp_ lemmas for the arrays.
parent
740affc3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/heap_lang/array.v
+93
-0
93 additions, 0 deletions
theories/heap_lang/array.v
with
93 additions
and
0 deletions
theories/heap_lang/array.v
+
93
−
0
View file @
cc67112b
...
@@ -139,10 +139,25 @@ Proof.
...
@@ -139,10 +139,25 @@ Proof.
iDestruct
(
"Hl2"
$!
v
)
as
"Hl2"
.
rewrite
list_insert_id
;
last
done
.
iDestruct
(
"Hl2"
$!
v
)
as
"Hl2"
.
rewrite
list_insert_id
;
last
done
.
iApply
"Hl2"
.
iApply
"Hl1"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Qed
.
Lemma
twp_load_offset
s
E
l
off
vs
v
:
vs
!!
off
=
Some
v
→
[[{
l
↦∗
vs
}]]
!
#
(
l
+
ₗ
off
)
@
s
;
E
[[{
RET
v
;
l
↦∗
vs
}]]
.
Proof
.
iIntros
(
Hlookup
Φ
)
"Hl HΦ"
.
iDestruct
(
update_array
l
_
_
_
Hlookup
with
"Hl"
)
as
"[Hl1 Hl2]"
.
iApply
(
twp_load
with
"Hl1"
)
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iDestruct
(
"Hl2"
$!
v
)
as
"Hl2"
.
rewrite
list_insert_id
;
last
done
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Lemma
wp_load_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
:
Lemma
wp_load_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
:
{{{
▷
l
↦∗
vs
}}}
!
#
(
l
+
ₗ
off
)
@
s
;
E
{{{
RET
vs
!!!
off
;
l
↦∗
vs
}}}
.
{{{
▷
l
↦∗
vs
}}}
!
#
(
l
+
ₗ
off
)
@
s
;
E
{{{
RET
vs
!!!
off
;
l
↦∗
vs
}}}
.
Proof
.
apply
wp_load_offset
.
by
apply
vlookup_lookup
.
Qed
.
Proof
.
apply
wp_load_offset
.
by
apply
vlookup_lookup
.
Qed
.
Lemma
twp_load_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
:
[[{
l
↦∗
vs
}]]
!
#
(
l
+
ₗ
off
)
@
s
;
E
[[{
RET
vs
!!!
off
;
l
↦∗
vs
}]]
.
Proof
.
apply
twp_load_offset
.
by
apply
vlookup_lookup
.
Qed
.
Lemma
wp_store_offset
s
E
l
off
vs
v
:
Lemma
wp_store_offset
s
E
l
off
vs
v
:
is_Some
(
vs
!!
off
)
→
is_Some
(
vs
!!
off
)
→
...
@@ -153,6 +168,15 @@ Proof.
...
@@ -153,6 +168,15 @@ Proof.
iApply
(
wp_store
with
"Hl1"
)
.
iNext
.
iIntros
"Hl1"
.
iApply
(
wp_store
with
"Hl1"
)
.
iNext
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Qed
.
Lemma
twp_store_offset
s
E
l
off
vs
v
:
is_Some
(
vs
!!
off
)
→
[[{
l
↦∗
vs
}]]
#
(
l
+
ₗ
off
)
<-
v
@
s
;
E
[[{
RET
#
();
l
↦∗
<
[
off
:=
v
]
>
vs
}]]
.
Proof
.
iIntros
([
w
Hlookup
]
Φ
)
"Hl HΦ"
.
iDestruct
(
update_array
l
_
_
_
Hlookup
with
"Hl"
)
as
"[Hl1 Hl2]"
.
iApply
(
twp_store
with
"Hl1"
)
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Lemma
wp_store_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v
:
Lemma
wp_store_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v
:
{{{
▷
l
↦∗
vs
}}}
#
(
l
+
ₗ
off
)
<-
v
@
s
;
E
{{{
RET
#
();
l
↦∗
vinsert
off
v
vs
}}}
.
{{{
▷
l
↦∗
vs
}}}
#
(
l
+
ₗ
off
)
<-
v
@
s
;
E
{{{
RET
#
();
l
↦∗
vinsert
off
v
vs
}}}
.
...
@@ -160,6 +184,12 @@ Proof.
...
@@ -160,6 +184,12 @@ Proof.
setoid_rewrite
vec_to_list_insert
.
apply
wp_store_offset
.
setoid_rewrite
vec_to_list_insert
.
apply
wp_store_offset
.
eexists
.
by
apply
vlookup_lookup
.
eexists
.
by
apply
vlookup_lookup
.
Qed
.
Qed
.
Lemma
twp_store_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v
:
[[{
l
↦∗
vs
}]]
#
(
l
+
ₗ
off
)
<-
v
@
s
;
E
[[{
RET
#
();
l
↦∗
vinsert
off
v
vs
}]]
.
Proof
.
setoid_rewrite
vec_to_list_insert
.
apply
twp_store_offset
.
eexists
.
by
apply
vlookup_lookup
.
Qed
.
Lemma
wp_cmpxchg_suc_offset
s
E
l
off
vs
v'
v1
v2
:
Lemma
wp_cmpxchg_suc_offset
s
E
l
off
vs
v'
v1
v2
:
vs
!!
off
=
Some
v'
→
vs
!!
off
=
Some
v'
→
...
@@ -174,6 +204,19 @@ Proof.
...
@@ -174,6 +204,19 @@ Proof.
iApply
(
wp_cmpxchg_suc
with
"Hl1"
);
[
done
..|]
.
iApply
(
wp_cmpxchg_suc
with
"Hl1"
);
[
done
..|]
.
iNext
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
iNext
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Qed
.
Lemma
twp_cmpxchg_suc_offset
s
E
l
off
vs
v'
v1
v2
:
vs
!!
off
=
Some
v'
→
v'
=
v1
→
vals_compare_safe
v'
v1
→
[[{
l
↦∗
vs
}]]
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
[[{
RET
(
v'
,
#
true
);
l
↦∗
<
[
off
:=
v2
]
>
vs
}]]
.
Proof
.
iIntros
(
Hlookup
??
Φ
)
"Hl HΦ"
.
iDestruct
(
update_array
l
_
_
_
Hlookup
with
"Hl"
)
as
"[Hl1 Hl2]"
.
iApply
(
twp_cmpxchg_suc
with
"Hl1"
);
[
done
..|]
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Lemma
wp_cmpxchg_suc_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
Lemma
wp_cmpxchg_suc_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
vs
!!!
off
=
v1
→
vs
!!!
off
=
v1
→
...
@@ -185,6 +228,16 @@ Proof.
...
@@ -185,6 +228,16 @@ Proof.
intros
.
setoid_rewrite
vec_to_list_insert
.
eapply
wp_cmpxchg_suc_offset
=>
//.
intros
.
setoid_rewrite
vec_to_list_insert
.
eapply
wp_cmpxchg_suc_offset
=>
//.
by
apply
vlookup_lookup
.
by
apply
vlookup_lookup
.
Qed
.
Qed
.
Lemma
twp_cmpxchg_suc_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
vs
!!!
off
=
v1
→
vals_compare_safe
(
vs
!!!
off
)
v1
→
[[{
l
↦∗
vs
}]]
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
[[{
RET
(
vs
!!!
off
,
#
true
);
l
↦∗
vinsert
off
v2
vs
}]]
.
Proof
.
intros
.
setoid_rewrite
vec_to_list_insert
.
eapply
twp_cmpxchg_suc_offset
=>
//.
by
apply
vlookup_lookup
.
Qed
.
Lemma
wp_cmpxchg_fail_offset
s
E
l
off
vs
v0
v1
v2
:
Lemma
wp_cmpxchg_fail_offset
s
E
l
off
vs
v0
v1
v2
:
vs
!!
off
=
Some
v0
→
vs
!!
off
=
Some
v0
→
...
@@ -201,6 +254,21 @@ Proof.
...
@@ -201,6 +254,21 @@ Proof.
iIntros
"!> Hl1"
.
iApply
"HΦ"
.
iDestruct
(
"Hl2"
$!
v0
)
as
"Hl2"
.
iIntros
"!> Hl1"
.
iApply
"HΦ"
.
iDestruct
(
"Hl2"
$!
v0
)
as
"Hl2"
.
rewrite
list_insert_id
;
last
done
.
iApply
"Hl2"
.
iApply
"Hl1"
.
rewrite
list_insert_id
;
last
done
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Qed
.
Lemma
twp_cmpxchg_fail_offset
s
E
l
off
vs
v0
v1
v2
:
vs
!!
off
=
Some
v0
→
v0
≠
v1
→
vals_compare_safe
v0
v1
→
[[{
l
↦∗
vs
}]]
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
[[{
RET
(
v0
,
#
false
);
l
↦∗
vs
}]]
.
Proof
.
iIntros
(
Hlookup
HNEq
Hcmp
Φ
)
"Hl HΦ"
.
iDestruct
(
update_array
l
_
_
_
Hlookup
with
"Hl"
)
as
"[Hl1 Hl2]"
.
iApply
(
twp_cmpxchg_fail
with
"Hl1"
);
first
done
.
{
destruct
Hcmp
;
by
[
left
|
right
]
.
}
iIntros
"Hl1"
.
iApply
"HΦ"
.
iDestruct
(
"Hl2"
$!
v0
)
as
"Hl2"
.
rewrite
list_insert_id
;
last
done
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Lemma
wp_cmpxchg_fail_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
Lemma
wp_cmpxchg_fail_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
vs
!!!
off
≠
v1
→
vs
!!!
off
≠
v1
→
...
@@ -209,6 +277,13 @@ Lemma wp_cmpxchg_fail_offset_vec s E l sz (off : fin sz) (vs : vec val sz) v1 v2
...
@@ -209,6 +277,13 @@ Lemma wp_cmpxchg_fail_offset_vec s E l sz (off : fin sz) (vs : vec val sz) v1 v2
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
{{{
RET
(
vs
!!!
off
,
#
false
);
l
↦∗
vs
}}}
.
{{{
RET
(
vs
!!!
off
,
#
false
);
l
↦∗
vs
}}}
.
Proof
.
intros
.
eapply
wp_cmpxchg_fail_offset
=>
//.
by
apply
vlookup_lookup
.
Qed
.
Proof
.
intros
.
eapply
wp_cmpxchg_fail_offset
=>
//.
by
apply
vlookup_lookup
.
Qed
.
Lemma
twp_cmpxchg_fail_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
v1
v2
:
vs
!!!
off
≠
v1
→
vals_compare_safe
(
vs
!!!
off
)
v1
→
[[{
l
↦∗
vs
}]]
CmpXchg
#
(
l
+
ₗ
off
)
v1
v2
@
s
;
E
[[{
RET
(
vs
!!!
off
,
#
false
);
l
↦∗
vs
}]]
.
Proof
.
intros
.
eapply
twp_cmpxchg_fail_offset
=>
//.
by
apply
vlookup_lookup
.
Qed
.
Lemma
wp_faa_offset
s
E
l
off
vs
(
i1
i2
:
Z
)
:
Lemma
wp_faa_offset
s
E
l
off
vs
(
i1
i2
:
Z
)
:
vs
!!
off
=
Some
#
i1
→
vs
!!
off
=
Some
#
i1
→
...
@@ -220,6 +295,16 @@ Proof.
...
@@ -220,6 +295,16 @@ Proof.
iApply
(
wp_faa
with
"Hl1"
)
.
iApply
(
wp_faa
with
"Hl1"
)
.
iNext
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
iNext
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Qed
.
Lemma
twp_faa_offset
s
E
l
off
vs
(
i1
i2
:
Z
)
:
vs
!!
off
=
Some
#
i1
→
[[{
l
↦∗
vs
}]]
FAA
#
(
l
+
ₗ
off
)
#
i2
@
s
;
E
[[{
RET
LitV
(
LitInt
i1
);
l
↦∗
<
[
off
:=
#
(
i1
+
i2
)]
>
vs
}]]
.
Proof
.
iIntros
(
Hlookup
Φ
)
"Hl HΦ"
.
iDestruct
(
update_array
l
_
_
_
Hlookup
with
"Hl"
)
as
"[Hl1 Hl2]"
.
iApply
(
twp_faa
with
"Hl1"
)
.
iIntros
"Hl1"
.
iApply
"HΦ"
.
iApply
"Hl2"
.
iApply
"Hl1"
.
Qed
.
Lemma
wp_faa_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
(
i1
i2
:
Z
)
:
Lemma
wp_faa_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
(
i1
i2
:
Z
)
:
vs
!!!
off
=
#
i1
→
vs
!!!
off
=
#
i1
→
...
@@ -229,6 +314,14 @@ Proof.
...
@@ -229,6 +314,14 @@ Proof.
intros
.
setoid_rewrite
vec_to_list_insert
.
apply
wp_faa_offset
=>
//.
intros
.
setoid_rewrite
vec_to_list_insert
.
apply
wp_faa_offset
=>
//.
by
apply
vlookup_lookup
.
by
apply
vlookup_lookup
.
Qed
.
Qed
.
Lemma
twp_faa_offset_vec
s
E
l
sz
(
off
:
fin
sz
)
(
vs
:
vec
val
sz
)
(
i1
i2
:
Z
)
:
vs
!!!
off
=
#
i1
→
[[{
l
↦∗
vs
}]]
FAA
#
(
l
+
ₗ
off
)
#
i2
@
s
;
E
[[{
RET
LitV
(
LitInt
i1
);
l
↦∗
vinsert
off
#
(
i1
+
i2
)
vs
}]]
.
Proof
.
intros
.
setoid_rewrite
vec_to_list_insert
.
apply
twp_faa_offset
=>
//.
by
apply
vlookup_lookup
.
Qed
.
End
lifting
.
End
lifting
.
...
...
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