Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
Stacked Borrows Coq
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
FP
Stacked Borrows Coq
Commits
2c54350f
Commit
2c54350f
authored
Sep 20, 2019
by
Hai Dang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comments to code
parent
fb4a36a8
Changes
6
Hide whitespace changes
Inline
Sidebyside
Showing
6 changed files
with
86 additions
and
4 deletions
+86
4
theories/opt/ex1.v
theories/opt/ex1.v
+19
3
theories/opt/ex1_down.v
theories/opt/ex1_down.v
+13
1
theories/opt/ex2.v
theories/opt/ex2.v
+13
0
theories/opt/ex2_down.v
theories/opt/ex2_down.v
+13
0
theories/opt/ex3.v
theories/opt/ex3.v
+14
0
theories/opt/ex3_down.v
theories/opt/ex3_down.v
+14
0
No files found.
theories/opt/ex1.v
View file @
2c54350f
...
...
@@ 7,13 +7,29 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
mut
i32
*
)
Definition
ex1_unopt
:
function
:=
fun:
[
"i"
],
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
put
argument
into
place
*
)
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Mutable
)
int
Default
;;
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
or
"g"
*
)
Call
#[
ScFnPtr
"f"
]
[]
;;
(
*
Write
42
to
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
*{
int
}
"x"
<
#[
42
]
;;
Call
#[
ScFnPtr
"g"
]
[]
;;
(
*
Read
the
value
"v"
from
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
let:
"v"
:=
Copy
*{
int
}
"x"
in
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
read
value
*
)
"v"
.
...
...
@@ 58,7 +74,7 @@ Proof.
(
*
Write
local
*
)
sim_apply
sim_simple_write_local
;
[
solve_sim
..

].
intros
s
?
.
simplify_eq
.
(
*
Call
*
)
(
*
Call
unknown
function
*
)
sim_apply
sim_simple_let
=>/=
.
sim_apply
(
sim_simple_call
10
[]
[]
ε
);
[
solve_sim
..

].
intros
rf
frs
frt
???
?
_
_
FREL
.
simplify_eq
/=
.
...
...
@@ 85,7 +101,7 @@ Proof.
(
*
We
can
go
back
to
simple
mode
!
*
)
eapply
(
sim_simplify
(
fun_post_simple
c
)).
{
by
eauto
.
}
simplify_eq
/=
.
clear

AREL
FREL
LOOK
.
(
*
Call
*
)
(
*
Call
unknown
function
*
)
sim_apply
(
sim_simple_call
10
[]
[]
ε
);
[
solve_sim
..

].
intros
rf
'
frs
'
frt
'
???
?
_
_
FREL
'
.
simplify_eq
/=
.
apply:
sim_simple_result
.
simpl
.
...
...
theories/opt/ex1_down.v
View file @
2c54350f
...
...
@@ 9,11 +9,23 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
mut
i32
*
)
Definition
ex1_down_unopt
:
function
:=
fun:
[
"i"
],
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
put
argument
into
place
*
)
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Mutable
)
int
FnEntry
;;
(
*
Read
the
value
"v"
from
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
let:
"v"
:=
Copy
*{
int
}
"x"
in
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
*
)
Call
#[
ScFnPtr
"f"
]
[]
;;
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
read
value
*
)
"v"
.
...
...
theories/opt/ex2.v
View file @
2c54350f
...
...
@@ 8,11 +8,24 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
i32
*
)
Definition
ex2_unopt
:
function
:=
fun:
[
"i"
],
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Immutable
)
int
Default
;;
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
,
which
does
take
the
pointer
value
from
"x"
as
an
argument
.
*
)
Call
#[
ScFnPtr
"f"
]
[
Copy
"x"
]
;;
(
*
Read
the
value
"v"
from
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
let:
"v"
:=
Copy
*{
int
}
"x"
in
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
read
value
*
)
"v"
.
...
...
theories/opt/ex2_down.v
View file @
2c54350f
...
...
@@ 9,11 +9,24 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
i32
*
)
Definition
ex2_down_unopt
:
function
:=
fun:
[
"i"
],
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Immutable
)
int
FnEntry
;;
(
*
Read
the
value
"v"
from
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
let:
"v"
:=
Copy
*{
int
}
"x"
in
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
,
which
does
take
the
pointer
value
from
"x"
as
an
argument
.
*
)
Call
#[
ScFnPtr
"f"
]
[
Copy
"x"
]
;;
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
read
value
*
)
"v"
.
...
...
theories/opt/ex3.v
View file @
2c54350f
...
...
@@ 9,12 +9,26 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
mut
i32
*
)
Definition
ex3_unopt
:
function
:=
fun:
[
"i"
],
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Mutable
)
int
FnEntry
;;
(
*
Write
42
to
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
*{
int
}
"x"
<
#[
42
]
;;
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
*
)
let:
"v"
:=
Call
#[
ScFnPtr
"f"
]
[]
in
(
*
Write
13
to
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
*{
int
}
"x"
<
#[
13
]
;;
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
value
*
)
"v"
.
...
...
theories/opt/ex3_down.v
View file @
2c54350f
...
...
@@ 9,12 +9,26 @@ Set Default Proof Using "Type".
(
*
Assuming
x
:
&
mut
i32
*
)
Definition
ex3_down_unopt
:
function
:=
fun:
[
"i"
],
(
*
"x"
is
the
local
variable
that
stores
the
pointer
value
"i"
*
)
let:
"x"
:=
new_place
(
&
mut
int
)
"i"
in
(
*
retag_place
reborrows
the
pointer
value
stored
in
"x"
(
which
is
"i"
),
then
updates
"x"
with
the
new
pointer
value
*
)
retag_place
"x"
(
RefPtr
Mutable
)
int
FnEntry
;;
(
*
Write
42
to
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
*{
int
}
"x"
<
#[
42
]
;;
(
*
The
unknown
code
is
represented
by
a
call
to
an
unknown
function
"f"
*
)
let:
"v"
:=
Call
#[
ScFnPtr
"f"
]
[]
in
(
*
Write
13
to
the
cell
pointed
to
by
the
pointer
in
"x"
*
)
*{
int
}
"x"
<
#[
13
]
;;
(
*
Free
the
local
variable
*
)
Free
"x"
;;
(
*
Finally
,
return
the
value
*
)
"v"
.
...
...
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