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
20ba9d4c
Commit
20ba9d4c
authored
Jan 20, 2020
by
Ralf Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update exercises
parent
697ba6c8
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
28 additions
and
26 deletions
+28
-26
exercises/compatibility.v
exercises/compatibility.v
+1
-1
exercises/demo.v
exercises/demo.v
+1
-1
exercises/fundamental.v
exercises/fundamental.v
+1
-1
exercises/interp.v
exercises/interp.v
+7
-11
exercises/parametricity.v
exercises/parametricity.v
+7
-1
exercises/polymorphism.v
exercises/polymorphism.v
+1
-1
exercises/safety.v
exercises/safety.v
+1
-1
exercises/sem_operators.v
exercises/sem_operators.v
+1
-1
exercises/sem_type_formers.v
exercises/sem_type_formers.v
+2
-2
exercises/sem_typed.v
exercises/sem_typed.v
+1
-1
exercises/sem_types.v
exercises/sem_types.v
+1
-1
exercises/typed.v
exercises/typed.v
+1
-1
exercises/types.v
exercises/types.v
+1
-1
exercises/unsafe.v
exercises/unsafe.v
+2
-2
No files found.
exercises/compatibility.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_typed
sem_operators
.
From
solutions
Require
Export
sem_typed
sem_operators
.
(** * Compatibility lemmas *)
(** We prove that the logical relations, i.e., the semantic typing judgment,
...
...
exercises/demo.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Import
language
.
From
solutions
Require
Import
language
.
From
iris
.
base_logic
.
lib
Require
Import
invariants
.
From
iris
.
heap_lang
Require
Import
adequacy
.
...
...
exercises/fundamental.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
typed
compatibility
interp
.
From
solutions
Require
Export
typed
compatibility
interp
.
(** * The fundamental theorem of logical relations *)
(** The fundamental theorem of logical relations says that any syntactically
...
...
exercises/interp.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_typed
sem_type_formers
types
.
From
solutions
Require
Export
sem_typed
sem_type_formers
types
.
(** * Interpretation of syntactic types *)
(** We use semantic type formers to define the interpretation [⟦ τ ⟧ : sem_ty]
of syntactic types [τ : ty]. The interpretation is defined recursively on the
structure of syntactic types. *)
structure of syntactic types. To account for type variables (that appear freely
in [τ]), we need to keep track of their corresponding semantic types. We
represent these semantic types as a list, since de use De Bruijn indices for
type variables. *)
Reserved
Notation
"⟦ τ ⟧"
.
Fixpoint
interp
`
{!
heapG
Σ
}
(
τ
:
ty
)
(
ρ
:
list
(
sem_ty
Σ
))
:
sem_ty
Σ
:
=
match
τ
return
_
with
...
...
@@ -20,16 +22,10 @@ Fixpoint interp `{!heapG Σ} (τ : ty) (ρ : list (sem_ty Σ)) : sem_ty Σ :=
|
TRef
τ
=>
ref
(
⟦
τ
⟧
ρ
)
end
%
sem_ty
where
"⟦ τ ⟧"
:
=
(
interp
τ
).
Instance
:
Params
(@
interp
)
2
:
=
{}.
(** Given a syntactic typing context [Γ : gmap string ty] (a mapping from
variables [string] to syntactic types [ty]) together with a mapping
[ρ : list (sem_ty Σ)] from type variables (that appear freely in [Γ]) to
their corresponding semantic types (represented as a list, since de use De
Bruijn indices for type variables), we define a semantic typing context
[interp_env Γ ρ : gmap string (sem_ty Σ)], i.e., a mapping from variables
(strings) to semantic types. *)
(** We now lift the interpretation of types to typing contexts. This is done in
a pointwise fashion using the [<$> : (A → B) → gmap K A → gmap K B] operator. *)
Definition
interp_env
`
{!
heapG
Σ
}
(
Γ
:
gmap
string
ty
)
(
ρ
:
list
(
sem_ty
Σ
))
:
gmap
string
(
sem_ty
Σ
)
:
=
flip
interp
ρ
<$>
Γ
.
Instance
:
Params
(@
interp_env
)
3
:
=
{}.
...
...
exercises/parametricity.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
safety
.
From
solutions
Require
Export
safety
.
(** * Parametricity *)
Section
parametricity
.
Context
`
{!
heapG
Σ
}.
(** * The polymorphic identity function *)
Lemma
identity_param
`
{!
heapPreG
Σ
}
e
(
v
:
val
)
σ
w
es
σ
'
:
(
∀
`
{!
heapG
Σ
},
(
∅
⊨
e
:
∀
A
,
A
→
A
)%
I
)
→
rtc
erased_step
([
e
<
_
>
v
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
w
=
v
.
...
...
@@ -20,23 +22,27 @@ Section parametricity.
wp_apply
(
wp_wand
with
"Hu"
).
iIntros
(
w'
)
"Hw'"
.
by
iApply
"Hw'"
.
Qed
.
(** * Exercise (empty_type_param, easy) *)
Lemma
empty_type_param
`
{!
heapPreG
Σ
}
e
(
v
:
val
)
σ
w
es
σ
'
:
(
∀
`
{!
heapG
Σ
},
(
∅
⊨
e
:
∀
A
,
A
)%
I
)
→
rtc
erased_step
([
e
<
_
>]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
False
.
Proof
.
(* FILL IN YOUR PROOF *)
Qed
.
(** * Exercise (boolean_param, moderate) *)
Lemma
boolean_param
`
{!
heapPreG
Σ
}
e
(
v1
v2
:
val
)
σ
w
es
σ
'
:
(
∀
`
{!
heapG
Σ
},
(
∅
⊨
e
:
∀
A
,
A
→
A
→
A
)%
I
)
→
rtc
erased_step
([
e
<
_
>
v1
v2
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
w
=
v1
∨
w
=
v2
.
Proof
.
(* FILL IN YOUR PROOF *)
Qed
.
(** * Exercise (nat_param, hard) *)
Lemma
nat_param
`
{!
heapPreG
Σ
}
e
σ
w
es
σ
'
:
(
∀
`
{!
heapG
Σ
},
(
∅
⊨
e
:
∀
A
,
(
A
→
A
)
→
A
→
A
)%
I
)
→
rtc
erased_step
([
e
<
_
>
(
λ
:
"n"
,
"n"
+
#
1
)%
V
#
0
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
∃
n
:
nat
,
w
=
#
n
.
Proof
.
(* FILL IN YOUR PROOF *)
Qed
.
(** * Exercise (strong_nat_param, hard) *)
Lemma
strong_nat_param
`
{!
heapPreG
Σ
}
e
σ
w
es
σ
'
(
vf
vz
:
val
)
φ
:
(
∀
`
{!
heapG
Σ
},
∃
Φ
:
sem_ty
Σ
,
(
∅
⊨
e
:
∀
A
,
(
A
→
A
)
→
A
→
A
)%
I
∧
...
...
exercises/polymorphism.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
language
.
From
solutions
Require
Export
language
.
(** * Polymorphism and existential types in HeapLang *)
(** In order to define a type system for HeapLang (in the file [typed.v]), we
...
...
exercises/safety.v
View file @
20ba9d4c
From
iris
.
heap_lang
Require
Export
adequacy
.
From
tutorial_popl20
Require
Export
fundamental
.
From
solutions
Require
Export
fundamental
.
(** * Semantic and syntactic type safety *)
(** We prove *semantic type safety*, which says that any _closed_ expression
...
...
exercises/sem_operators.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_typed
.
From
solutions
Require
Export
sem_typed
.
(** Semantic operator typing *)
Class
SemTyUnboxed
`
{!
heapG
Σ
}
(
A
:
sem_ty
Σ
)
:
=
...
...
exercises/sem_type_formers.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_types
.
From
solutions
Require
Export
sem_types
.
(** * Semantic type formers *)
(** For all of the type formers in the syntactic type system, we now define
...
...
@@ -89,7 +89,7 @@ Section types.
Definition
sem_ty_ref
(
A
:
sem_ty
Σ
)
:
sem_ty
Σ
:
=
SemTy
(
λ
w
,
∃
l
:
loc
,
⌜
w
=
#
l
⌝
∧
inv
(
tyN
.@
l
)
(
∃
v
,
l
↦
v
∗
A
v
))%
I
.
(** Intuitively, values of the reference type [sem_ty_ref A] should
be locations
l
that hold a value [w] in the semantic type [A] at
be locations
[l]
that hold a value [w] in the semantic type [A] at
all times. In order to express this intuition in a formal way, we
make use of two features of Iris:
...
...
exercises/sem_typed.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_type_formers
.
From
solutions
Require
Export
sem_type_formers
.
(** * The semantic typing judgment *)
...
...
exercises/sem_types.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
polymorphism
.
From
solutions
Require
Export
polymorphism
.
From
iris
.
heap_lang
Require
Export
proofmode
.
From
iris
.
base_logic
.
lib
Require
Export
invariants
.
...
...
exercises/typed.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
types
polymorphism
.
From
solutions
Require
Export
types
polymorphism
.
(** * Syntactic typing for HeapLang *)
(** In this file, we define a syntactic type system for HeapLang. We do this
...
...
exercises/types.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
language
.
From
solutions
Require
Export
language
.
(** * Syntactic types for HeapLang *)
(** The inductive type [ty] defines the syntactic types for HeapLang. We make
...
...
exercises/unsafe.v
View file @
20ba9d4c
From
tutorial_popl20
Require
Export
sem_typed
.
From
tutorial_popl20
Require
Import
symbol_ghost
two_state_ghost
.
From
solutions
Require
Export
sem_typed
.
From
solutions
Require
Import
symbol_ghost
two_state_ghost
.
Section
unsafe
.
Context
`
{!
heapG
Σ
}.
...
...
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