Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Actris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Iris
Actris
Commits
e5d7df97
Commit
e5d7df97
authored
5 years ago
by
jihgfee
Browse files
Options
Downloads
Patches
Plain Diff
Moved list sort instance to separate file
parent
a3ec1bc7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
_CoqProject
+1
-0
1 addition, 0 deletions
_CoqProject
theories/examples/list_sort.v
+0
-37
0 additions, 37 deletions
theories/examples/list_sort.v
theories/examples/list_sort_instances.v
+48
-0
48 additions, 0 deletions
theories/examples/list_sort_instances.v
with
49 additions
and
37 deletions
_CoqProject
+
1
−
0
View file @
e5d7df97
...
...
@@ -7,3 +7,4 @@ theories/channel/channel.v
theories/channel/proto_model.v
theories/channel/proto_channel.v
theories/examples/list_sort.v
theories/examples/list_sort_instances.v
This diff is collapsed.
Click to expand it.
theories/examples/list_sort.v
+
0
−
37
View file @
e5d7df97
...
...
@@ -3,9 +3,6 @@ From osiris.channel Require Import proto_channel.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
osiris
.
utils
Require
Import
list
.
Definition
compare_vals
:
val
:=
λ
:
"x"
"y"
,
"x"
≤
"y"
.
Definition
lmerge
:
val
:=
rec
:
"go"
"cmp"
"hys"
"hzs"
:=
match
:
"hys"
with
...
...
@@ -216,38 +213,4 @@ Section list_sort.
wp_pures
.
iApply
"HΦ"
.
iFrame
.
Qed
.
(* Example: Sort of integers *)
Definition
IZ
(
x
:
Z
)
(
v
:
val
)
:
iProp
Σ
:=
⌜∃
w
,
v
=
LitV
$
LitInt
w
∧
x
=
w
⌝%
I
.
Lemma
compare_vals_spec
:
cmp_spec
IZ
(
≤
)
compare_vals
.
Proof
.
iIntros
(
x
x'
v
v'
Φ
)
"!>"
.
iIntros
([[
w
[
->
->
]]
[
w'
[
->
->
]]])
"HΦ"
.
wp_lam
.
wp_pures
.
iApply
"HΦ"
.
eauto
10
with
iFrame
.
Qed
.
Local
Arguments
val_encode
_
_
!
_
/.
Lemma
list_sort_client_le_spec
l
(
xs
:
list
Z
)
:
{{{
l
↦
val_encode
xs
}}}
list_sort_client
compare_vals
#
l
{{{
ys
,
RET
#
();
⌜
Sorted
(
≤
)
ys
⌝
∗
⌜
ys
≡
ₚ
xs
⌝
∗
l
↦
val_encode
ys
}}}
.
Proof
.
assert
(
∀
zs
:
list
Z
,
val_encode
zs
=
val_encode
(
LitV
∘
LitInt
<$>
zs
))
as
Henc
.
{
intros
zs
.
induction
zs
;
f_equal
/=
;
auto
with
f_equal
.
}
iIntros
(
Φ
)
"Hl HΦ"
.
iApply
(
list_sort_client_spec
IZ
(
≤
)
_
_
(
LitV
∘
LitInt
<$>
xs
)
xs
with
"[] [Hl] [HΦ]"
)
.
{
iApply
compare_vals_spec
.
}
{
rewrite
-
Henc
.
iFrame
"Hl"
.
iInduction
xs
as
[|
x
xs
]
"IH"
;
csimpl
;
first
by
iFrame
.
iFrame
"IH"
.
by
iExists
x
.
}
iIntros
"!>"
(
ys
ws
)
"(?&?&?&HI)"
.
iAssert
⌜
ws
=
(
LitV
∘
LitInt
)
<$>
ys
⌝%
I
with
"[HI]"
as
%->
.
{
iInduction
ys
as
[|
y
ys
]
"IH"
forall
(
ws
);
destruct
ws
as
[|
w
ws
];
csimpl
;
try
done
.
iDestruct
"HI"
as
"[HI1 HI2]"
;
iDestruct
"HI1"
as
%
(?
&
->
&
->
)
.
by
iDestruct
(
"IH"
with
"HI2"
)
as
%->
.
}
rewrite
-
Henc
.
iApply
(
"HΦ"
$!
ys
with
"[$]"
)
.
Qed
.
End
list_sort
.
This diff is collapsed.
Click to expand it.
theories/examples/list_sort_instances.v
0 → 100644
+
48
−
0
View file @
e5d7df97
From
stdpp
Require
Import
sorting
.
From
osiris
.
channel
Require
Import
proto_channel
.
From
iris
.
heap_lang
Require
Import
proofmode
notation
.
From
osiris
.
utils
Require
Import
list
.
From
osiris
.
examples
Require
Import
list_sort
.
Section
list_sort_instances
.
Context
`{
!
heapG
Σ
,
!
proto_chanG
Σ
}
(
N
:
namespace
)
.
(* Example: Sort of integers *)
Definition
IZ
(
x
:
Z
)
(
v
:
val
)
:
iProp
Σ
:=
⌜∃
w
,
v
=
LitV
$
LitInt
w
∧
x
=
w
⌝%
I
.
Definition
compareZ
:
val
:=
λ
:
"x"
"y"
,
"x"
≤
"y"
.
Lemma
compareZ_spec
:
cmp_spec
IZ
(
≤
)
compareZ
.
Proof
.
iIntros
(
x
x'
v
v'
Φ
)
"!>"
.
iIntros
([[
w
[
->
->
]]
[
w'
[
->
->
]]])
"HΦ"
.
wp_lam
.
wp_pures
.
iApply
"HΦ"
.
eauto
10
with
iFrame
.
Qed
.
Local
Arguments
val_encode
_
_
!
_
/.
Lemma
list_sort_client_le_spec
l
(
xs
:
list
Z
)
:
{{{
l
↦
val_encode
xs
}}}
list_sort_client
compareZ
#
l
{{{
ys
,
RET
#
();
⌜
Sorted
(
≤
)
ys
⌝
∗
⌜
ys
≡
ₚ
xs
⌝
∗
l
↦
val_encode
ys
}}}
.
Proof
.
assert
(
∀
zs
:
list
Z
,
val_encode
zs
=
val_encode
(
LitV
∘
LitInt
<$>
zs
))
as
Henc
.
{
intros
zs
.
induction
zs
;
f_equal
/=
;
auto
with
f_equal
.
}
iIntros
(
Φ
)
"Hl HΦ"
.
iApply
(
list_sort_client_spec
N
IZ
(
≤
)
_
_
(
LitV
∘
LitInt
<$>
xs
)
xs
with
"[] [Hl] [HΦ]"
)
.
{
iApply
compareZ_spec
.
}
{
rewrite
-
Henc
.
iFrame
"Hl"
.
iInduction
xs
as
[|
x
xs
]
"IH"
;
csimpl
;
first
by
iFrame
.
iFrame
"IH"
.
by
iExists
x
.
}
iIntros
"!>"
(
ys
ws
)
"(?&?&?&HI)"
.
iAssert
⌜
ws
=
(
LitV
∘
LitInt
)
<$>
ys
⌝%
I
with
"[HI]"
as
%->
.
{
iInduction
ys
as
[|
y
ys
]
"IH"
forall
(
ws
);
destruct
ws
as
[|
w
ws
];
csimpl
;
try
done
.
iDestruct
"HI"
as
"[HI1 HI2]"
;
iDestruct
"HI1"
as
%
(?
&
->
&
->
)
.
by
iDestruct
(
"IH"
with
"HI2"
)
as
%->
.
}
rewrite
-
Henc
.
iApply
(
"HΦ"
$!
ys
with
"[$]"
)
.
Qed
.
End
list_sort_instances
.
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