Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
c
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Iris
c
Commits
cd7f2ee5
Commit
cd7f2ee5
authored
Nov 26, 2018
by
Léon Gondelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cbv_of_args
parent
7b59d2c8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
0 deletions
+114
-0
cbv_of_args.v
theories/tests/cbv_of_args.v
+114
-0
No files found.
theories/tests/cbv_of_args.v
0 → 100644
View file @
cd7f2ee5
From
iris_c
.
vcgen
Require
Import
proofmode
.
Section
Incr_Ptr
.
(* In the program below, after the execution of 'main',
the global pointer 'l' has the value 43. *)
(* // C
void incr(int* x) {
*x = *x + 1;
}
int* l = 42;
int main() {
incr(&l);
return 0
}
*)
(* // λMC (paper version)
incr(x) {
*x = *x + 1;
}
l <- alloc 42;
main() {
incr(l);
0;
}
*)
Let
incr
:
val
:=
λᶜ
"x"
,
(
c_ret
"x"
)
=
ᶜ
∗ᶜ
(
c_ret
"x"
)
+
ᶜ
♯
1
;
ᶜ
♯
().
Let
main
:
val
:=
λᶜ
"()"
,
"r"
←ᶜ
alloc
ᶜ
(
♯
1
,
♯
42
)
;
ᶜ
call
ᶜ
(
c_ret
incr
)
(
c_ret
"r"
)
;
ᶜ
♯
0
.
Let
main_spec
`
{
cmonadG
Σ
}
:
CWP
main
#()
{{
v
,
⌜
v
=
#
0
⌝
∗
∃
ptr
,
ptr
↦
C
#
43
%
nat
}}%
I
.
Proof
.
iIntros
.
iApply
cwp_fun
;
simpl
.
vcg
.
iIntros
(
ptr
)
"_ _ Hptr !> _ !>"
.
iApply
cwp_fun
;
simpl
.
vcg
.
iIntros
"Hptr !>"
.
iSplit
;
eauto
.
vcg_continue
.
eauto
with
iFrame
.
Qed
.
End
Incr_Ptr
.
Section
Incr_Int
.
(* In the program below, after the execution of 'main',
the global pointer 'l' has the value 42. *)
(* // C
void incr(int x) {
x = x + 1;
}
int* l = 42;
int main() {
incr(l);
return 0
}
*)
(* // λMC (paper version)
incr(x) {
r <- alloc x ;
*r = *r + 1;
}
l <- alloc 42 ;
main() {
incr(∗l);
0
}
*)
Let
incr
:
val
:=
λᶜ
"x"
,
"r"
←
mut
ᶜ
(
c_ret
"x"
)
;
ᶜ
(
c_ret
"r"
)
=
ᶜ
∗ᶜ
(
c_ret
"r"
)
+
ᶜ
♯
1
;
ᶜ
♯
().
Let
main
:
val
:=
λᶜ
"()"
,
"r"
←ᶜ
alloc
ᶜ
(
♯
1
,
♯
42
)
;
ᶜ
call
ᶜ
(
c_ret
incr
)
(
∗ᶜ
c_ret
"r"
)
;
ᶜ
♯
0
.
Let
main_spec
`
{
cmonadG
Σ
}
:
CWP
main
#()
{{
v
,
⌜
v
=
#
0
⌝
∗
∃
ptr
,
ptr
↦
C
#
42
%
nat
}}%
I
.
Proof
.
iIntros
.
iApply
cwp_fun
;
simpl
.
vcg
.
iIntros
(
ptr
)
"_ _ Hptr !> _ !>"
.
iApply
cwp_fun
;
simpl
.
vcg
.
iIntros
(?)
"Hptr !>"
.
iSplit
;
eauto
.
vcg_continue
.
eauto
with
iFrame
.
Qed
.
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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