Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Tutorial POPL20
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arthur Azevedo de Amorim
Tutorial POPL20
Commits
b4277dfb
Commit
b4277dfb
authored
Jan 19, 2020
by
Robbert Krebbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move stuff about polymorphism to its own file.
parent
c147e8d1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
47 deletions
+49
-47
_CoqProject
_CoqProject
+1
-0
theories/language.v
theories/language.v
+0
-45
theories/polymorphism.v
theories/polymorphism.v
+46
-0
theories/sem_types.v
theories/sem_types.v
+1
-1
theories/types.v
theories/types.v
+1
-1
No files found.
_CoqProject
View file @
b4277dfb
...
...
@@ -9,6 +9,7 @@
-arg -w -arg -ambiguous-paths
theories/language.v
theories/polymorphism.v
theories/types.v
theories/typed.v
theories/sem_types.v
...
...
theories/language.v
View file @
b4277dfb
...
...
@@ -448,48 +448,3 @@ Lemma wp_unsafe_ref `{!heapG Σ} :
wp_load
.
auto
.
Qed
.
(** * Polymorphic functions in HeapLang *)
(** We model type-level lambdas and applications as thunks since heap_lang does
not have them. *)
Notation
"Λ: e"
:
=
(
λ
:
<>,
e
)%
E
(
at
level
200
,
only
parsing
)
:
expr_scope
.
Notation
"Λ: e"
:
=
(
λ
:
<>,
e
)%
V
(
at
level
200
,
only
parsing
)
:
val_scope
.
Notation
"e '<_>'"
:
=
(
App
e
%
E
#())
(
at
level
10
,
only
parsing
)
:
expr_scope
.
(** We wrap [pack] and [unpack] into an explicitly function so that we can have
a nice notation for it. *)
Definition
exist_pack
:
val
:
=
λ
:
"x"
,
"x"
.
Definition
exist_unpack
:
val
:
=
λ
:
"x"
"y"
,
"x"
"y"
.
Notation
"'pack:' e"
:
=
(
exist_pack
e
%
E
)
(
at
level
200
,
e
at
level
200
,
format
"'[' 'pack:' e ']'"
)
:
expr_scope
.
Notation
"'unpack:' x := e1 'in' e2"
:
=
(
exist_unpack
(
Lam
x
%
binder
e2
%
E
)
e1
%
E
)
(
at
level
200
,
x
at
level
1
,
e1
,
e2
at
level
200
,
format
"'[' 'unpack:' x := '[' e1 ']' 'in' '/' e2 ']'"
)
:
expr_scope
.
Notation
"'unpack:' x := e1 'in' e2"
:
=
(
exist_unpack
(
LamV
x
%
binder
e2
%
E
)
e1
%
E
)
(
at
level
200
,
x
at
level
1
,
e1
,
e2
at
level
200
,
format
"'[' 'unpack:' x := '[' e1 ']' 'in' '/' e2 ']'"
)
:
val_scope
.
Definition
swap_poly
:
val
:
=
Λ
:
λ
:
"l1"
"l2"
,
let
:
"x"
:
=
!
"l1"
in
"l1"
<-
!
"l2"
;;
"l2"
<-
"x"
.
Lemma
wp_swap_poly
`
{!
heapG
Σ
}
l1
l2
v1
v2
:
l1
↦
v1
-
∗
l2
↦
v2
-
∗
WP
swap_poly
<
_
>
#
l1
#
l2
{{
v
,
⌜
v
=
#()
⌝
∗
l1
↦
v2
∗
l2
↦
v1
}}.
(* REMOVE *)
Proof
.
iIntros
"Hl1 Hl2"
.
rewrite
/
swap_poly
.
wp_pures
.
wp_load
.
(* wp_pures is performed implicitly, so not needed *)
wp_load
.
wp_store
.
wp_store
.
iFrame
.
auto
.
Qed
.
theories/polymorphism.v
0 → 100644
View file @
b4277dfb
From
tutorial_popl20
Require
Export
language
.
(** * Polymorphic functions in HeapLang *)
(** We model type-level lambdas and applications as thunks since heap_lang does
not have them. *)
Notation
"Λ: e"
:
=
(
λ
:
<>,
e
)%
E
(
at
level
200
,
only
parsing
)
:
expr_scope
.
Notation
"Λ: e"
:
=
(
λ
:
<>,
e
)%
V
(
at
level
200
,
only
parsing
)
:
val_scope
.
Notation
"e '<_>'"
:
=
(
App
e
%
E
#())
(
at
level
10
,
only
parsing
)
:
expr_scope
.
(** We wrap [pack] and [unpack] into an explicitly function so that we can have
a nice notation for it. *)
Definition
exist_pack
:
val
:
=
λ
:
"x"
,
"x"
.
Definition
exist_unpack
:
val
:
=
λ
:
"x"
"y"
,
"x"
"y"
.
Notation
"'pack:' e"
:
=
(
exist_pack
e
%
E
)
(
at
level
200
,
e
at
level
200
,
format
"'[' 'pack:' e ']'"
)
:
expr_scope
.
Notation
"'unpack:' x := e1 'in' e2"
:
=
(
exist_unpack
(
Lam
x
%
binder
e2
%
E
)
e1
%
E
)
(
at
level
200
,
x
at
level
1
,
e1
,
e2
at
level
200
,
format
"'[' 'unpack:' x := '[' e1 ']' 'in' '/' e2 ']'"
)
:
expr_scope
.
Notation
"'unpack:' x := e1 'in' e2"
:
=
(
exist_unpack
(
LamV
x
%
binder
e2
%
E
)
e1
%
E
)
(
at
level
200
,
x
at
level
1
,
e1
,
e2
at
level
200
,
format
"'[' 'unpack:' x := '[' e1 ']' 'in' '/' e2 ']'"
)
:
val_scope
.
Definition
swap_poly
:
val
:
=
Λ
:
λ
:
"l1"
"l2"
,
let
:
"x"
:
=
!
"l1"
in
"l1"
<-
!
"l2"
;;
"l2"
<-
"x"
.
Lemma
wp_swap_poly
`
{!
heapG
Σ
}
l1
l2
v1
v2
:
l1
↦
v1
-
∗
l2
↦
v2
-
∗
WP
swap_poly
<
_
>
#
l1
#
l2
{{
v
,
⌜
v
=
#()
⌝
∗
l1
↦
v2
∗
l2
↦
v1
}}.
(* REMOVE *)
Proof
.
iIntros
"Hl1 Hl2"
.
rewrite
/
swap_poly
.
wp_pures
.
wp_load
.
(* wp_pures is performed implicitly, so not needed *)
wp_load
.
wp_store
.
wp_store
.
iFrame
.
auto
.
Qed
.
theories/sem_types.v
View file @
b4277dfb
From
tutorial_popl20
Require
Export
language
.
From
tutorial_popl20
Require
Export
polymorphism
.
From
iris
.
heap_lang
Require
Export
proofmode
.
From
iris
.
base_logic
.
lib
Require
Export
invariants
.
...
...
theories/types.v
View file @
b4277dfb
From
tutorial_popl20
Require
Export
language
.
From
tutorial_popl20
Require
Export
polymorphism
.
Inductive
ty
:
=
|
TVar
:
nat
→
ty
...
...
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