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
Yixuan Chen
Iris
Commits
c4c3beb4
Commit
c4c3beb4
authored
4 years ago
by
Dan Frumin
Committed by
Robbert Krebbers
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
array_init specs in its own section
parent
56428184
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theories/heap_lang/lib/array.v
+14
-11
14 additions, 11 deletions
theories/heap_lang/lib/array.v
with
14 additions
and
11 deletions
theories/heap_lang/lib/array.v
+
14
−
11
View file @
c4c3beb4
...
@@ -125,8 +125,12 @@ Section proof.
...
@@ -125,8 +125,12 @@ Section proof.
iApply
(
twp_array_clone
with
"H"
);
[
auto
..|];
iIntros
(
l'
)
"H HΦ"
.
by
iApply
"HΦ"
.
iApply
(
twp_array_clone
with
"H"
);
[
auto
..|];
iIntros
(
l'
)
"H HΦ"
.
by
iApply
"HΦ"
.
Qed
.
Qed
.
Local
Lemma
wp_array_init_loop
{
A
:
Type
}
(
g
:
A
→
val
)
(
Q
:
nat
→
A
→
iProp
Σ
)
Section
array_init
.
(
xs
:
list
A
)
i
n
l
(
f
:
val
)
stk
E
:
Context
{
A
:
Type
}
(
g
:
A
→
val
)
(
Q
:
nat
→
A
→
iProp
Σ
)
.
Implicit
Types
xs
:
list
A
.
Implicit
Types
f
:
val
.
Local
Lemma
wp_array_init_loop
xs
i
n
l
f
stk
E
:
0
<
n
→
0
<
n
→
length
xs
=
i
→
length
xs
=
i
→
i
≤
n
→
i
≤
n
→
...
@@ -173,10 +177,9 @@ Section proof.
...
@@ -173,10 +177,9 @@ Section proof.
rewrite
-
app_assoc
.
rewrite
-
app_assoc
.
iExists
([
x
]
++
ys
)
.
iFrame
.
iPureIntro
.
iExists
([
x
]
++
ys
)
.
iFrame
.
iPureIntro
.
by
rewrite
app_assoc
.
by
rewrite
app_assoc
.
Qed
.
Qed
.
Local
Lemma
twp_array_init_loop
{
A
:
Type
}
(
g
:
A
→
val
)
(
Q
:
nat
→
A
→
iProp
Σ
)
Local
Lemma
twp_array_init_loop
xs
i
n
l
f
stk
E
:
(
xs
:
list
A
)
i
n
l
(
f
:
val
)
stk
E
:
0
<
n
→
0
<
n
→
length
xs
=
i
→
length
xs
=
i
→
i
≤
n
→
i
≤
n
→
...
@@ -226,8 +229,7 @@ Section proof.
...
@@ -226,8 +229,7 @@ Section proof.
by
rewrite
app_assoc
.
by
rewrite
app_assoc
.
Qed
.
Qed
.
Theorem
wp_array_init
{
A
:
Type
}
(
g
:
A
→
val
)
(
Q
:
nat
→
A
→
iProp
Σ
)
Theorem
wp_array_init
n
f
stk
E
:
n
(
f
:
val
)
stk
E
:
(
0
<
n
)
%
Z
→
(
0
<
n
)
%
Z
→
{{{
[
∗
list
]
i
∈
seq
0
(
Z
.
to_nat
n
),
WP
f
#
(
i
:
nat
)
@
stk
;
E
{{
v
,
∃
x
:
A
,
⌜
v
=
g
x
⌝
∗
Q
i
x
}}
}}}
{{{
[
∗
list
]
i
∈
seq
0
(
Z
.
to_nat
n
),
WP
f
#
(
i
:
nat
)
@
stk
;
E
{{
v
,
∃
x
:
A
,
⌜
v
=
g
x
⌝
∗
Q
i
x
}}
}}}
array_init
#
n
f
@
stk
;
E
array_init
#
n
f
@
stk
;
E
...
@@ -236,7 +238,7 @@ Section proof.
...
@@ -236,7 +238,7 @@ Section proof.
intros
Hn
.
iIntros
(
Φ
)
"Hf HΦ"
.
intros
Hn
.
iIntros
(
Φ
)
"Hf HΦ"
.
wp_rec
.
wp_pures
.
wp_alloc
l
as
"Hl"
;
first
done
.
wp_rec
.
wp_pures
.
wp_alloc
l
as
"Hl"
;
first
done
.
wp_pures
.
wp_pures
.
iPoseProof
(
wp_array_init_loop
g
Q
[]
0
(
Z
.
to_nat
n
)
with
"[//] [Hf] [Hl]"
)
as
"H"
;
try
by
(
simpl
;
lia
)
.
iPoseProof
(
wp_array_init_loop
[]
0
(
Z
.
to_nat
n
)
with
"[//] [Hf] [Hl]"
)
as
"H"
;
try
by
(
simpl
;
lia
)
.
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
assert
(
Z
.
of_nat
0
%
nat
=
0
%
Z
)
as
->
by
lia
.
assert
(
Z
.
of_nat
0
%
nat
=
0
%
Z
)
as
->
by
lia
.
...
@@ -246,8 +248,7 @@ Section proof.
...
@@ -246,8 +248,7 @@ Section proof.
wp_pures
.
iApply
"HΦ"
.
wp_pures
.
iApply
"HΦ"
.
iFrame
"Hl HQs"
.
iPureIntro
.
lia
.
iFrame
"Hl HQs"
.
iPureIntro
.
lia
.
Qed
.
Qed
.
Theorem
twp_array_init
{
A
:
Type
}
(
g
:
A
→
val
)
(
Q
:
nat
→
A
→
iProp
Σ
)
Theorem
twp_array_init
n
f
stk
E
:
n
(
f
:
val
)
stk
E
:
(
0
<
n
)
%
Z
→
(
0
<
n
)
%
Z
→
[[{
[
∗
list
]
i
∈
seq
0
(
Z
.
to_nat
n
),
WP
f
#
(
i
:
nat
)
@
stk
;
E
[{
v
,
∃
x
:
A
,
⌜
v
=
g
x
⌝
∗
Q
i
x
}]
}]]
[[{
[
∗
list
]
i
∈
seq
0
(
Z
.
to_nat
n
),
WP
f
#
(
i
:
nat
)
@
stk
;
E
[{
v
,
∃
x
:
A
,
⌜
v
=
g
x
⌝
∗
Q
i
x
}]
}]]
array_init
#
n
f
@
stk
;
E
array_init
#
n
f
@
stk
;
E
...
@@ -256,7 +257,7 @@ Section proof.
...
@@ -256,7 +257,7 @@ Section proof.
intros
Hn
.
iIntros
(
Φ
)
"Hf HΦ"
.
intros
Hn
.
iIntros
(
Φ
)
"Hf HΦ"
.
wp_rec
.
wp_pures
.
wp_alloc
l
as
"Hl"
;
first
done
.
wp_rec
.
wp_pures
.
wp_alloc
l
as
"Hl"
;
first
done
.
wp_pures
.
wp_pures
.
iPoseProof
(
twp_array_init_loop
g
Q
[]
0
(
Z
.
to_nat
n
)
with
"[//] [Hf] [Hl]"
)
as
"H"
;
try
by
(
simpl
;
lia
)
.
iPoseProof
(
twp_array_init_loop
[]
0
(
Z
.
to_nat
n
)
with
"[//] [Hf] [Hl]"
)
as
"H"
;
try
by
(
simpl
;
lia
)
.
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
{
simpl
.
assert
(
Z
.
to_nat
n
-
0
=
Z
.
to_nat
n
)
as
->
by
lia
.
done
.
}
assert
(
Z
.
of_nat
0
%
nat
=
0
%
Z
)
as
->
by
lia
.
assert
(
Z
.
of_nat
0
%
nat
=
0
%
Z
)
as
->
by
lia
.
...
@@ -267,6 +268,8 @@ Section proof.
...
@@ -267,6 +268,8 @@ Section proof.
iFrame
"Hl HQs"
.
iPureIntro
.
lia
.
iFrame
"Hl HQs"
.
iPureIntro
.
lia
.
Qed
.
Qed
.
End
array_init
.
(* Version of [wp_array_init] with the auxiliary type [A] set to
(* Version of [wp_array_init] with the auxiliary type [A] set to
[val], and with the persistent assumption on the function [f]. *)
[val], and with the persistent assumption on the function [f]. *)
Lemma
wp_array_init'
(
Q
:
nat
→
val
→
iProp
Σ
)
n
(
f
:
val
)
stk
E
:
Lemma
wp_array_init'
(
Q
:
nat
→
val
→
iProp
Σ
)
n
(
f
:
val
)
stk
E
:
...
...
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