Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Fengmin Zhu
Tutorial POPL20
Commits
2a75020b
Commit
2a75020b
authored
Jan 17, 2020
by
Robbert Krebbers
Browse files
Misc changes.
parent
510554ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
theories/fundamental.v
View file @
2a75020b
...
...
@@ -19,8 +19,6 @@ Section fundamental.
Implicit
Types
τ
:
ty
.
Implicit
Types
ρ
:
list
(
sem_ty
Σ
).
(* I'm not sure where I should move the following but they don't
seem to belong here! *)
Instance
ty_unboxed_sound
τ
ρ
:
ty_unboxed
τ
→
SemTyUnboxed
(
⟦
τ
⟧
ρ
).
Proof
.
destruct
1
;
simpl
;
apply
_
.
Qed
.
Instance
ty_un_op_sound
op
τ
σ
ρ
:
...
...
theories/parametricity.v
View file @
2a75020b
...
...
@@ -71,7 +71,7 @@ Section parametricity.
Lemma
nat_param
`
{!
heapPreG
Σ
}
e
σ
w
es
σ
'
:
(
∀
`
{
heapG
Σ
},
∅
⊨
e
:
∀
A
,
(
A
→
A
)
→
A
→
A
)
→
rtc
erased_step
([
e
<
_
>
(
λ
:
"n"
,
"n"
+
#
1
)%
V
#
0
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
∃
n
:
nat
,
w
=
#
n
.
(
of_val
w
::
es
,
σ
'
)
→
∃
n
:
nat
,
w
=
#
n
.
(* REMOVE *)
Proof
.
intros
He
.
apply
sem_gen_type_safety
with
(
φ
:
=
λ
w
,
∃
n
:
nat
,
w
=
#
n
)=>
?.
...
...
@@ -95,50 +95,43 @@ Section parametricity.
by
iExists
0
%
nat
.
Qed
.
(* REMOVE *)
Definition
strong_nat_param_sem_ty
Σ
(
ψ
:
nat
→
val
→
Prop
)
:
sem_ty
Σ
:
=
SemTy
(
λ
w
,
∃
n
:
nat
,
⌜ψ
n
w
⌝
)%
I
.
(* REMOVE *)
Definition
strong_nat_param_sem_ty
{
A
Σ
}
(
Ψ
:
A
→
sem_ty
Σ
)
:
sem_ty
Σ
:
=
SemTy
(
λ
w
,
∃
x
:
A
,
Ψ
x
w
)%
I
.
Definition
strong_nat_param_semtyp_family
{
A
Σ
}
(
Ψ
:
A
→
sem_ty
Σ
)
:
sem_ty
Σ
:
=
SemTy
(
λ
w
,
∃
n
,
Ψ
n
w
)%
I
.
Lemma
strong_nat_param
`
{!
heapPreG
Σ
}
e
σ
w
es
σ
'
(
f
z
:
val
)
ψ
:
(
∀
`
{
heapG
Σ
},
∅
⊨
e
:
∀
A
,
(
A
→
A
)
→
A
→
A
)
→
(
∀
`
{
heapG
Σ
},
∃
(
Ψ
:
nat
→
sem_ty
Σ
),
(
∀
n
w
,
Ψ
n
w
-
∗
⌜ψ
n
w
⌝
)
∧
(
∀
n
w
,
{{{
Ψ
n
w
}}}
f
w
{{{
w'
,
RET
w'
;
Ψ
(
S
n
)
w'
}}})
∧
(
Ψ
0
%
nat
z
)%
I
)
→
rtc
erased_step
([
e
<
_
>
f
z
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
∃
n
:
nat
,
ψ
n
w
.
Lemma
strong_nat_param
`
{!
heapPreG
Σ
}
e
σ
w
es
σ
'
(
vf
vz
:
val
)
ψ
:
(
∀
`
{
heapG
Σ
},
∃
(
Ψ
:
nat
→
sem_ty
Σ
),
(
∅
⊨
e
:
∀
A
,
(
A
→
A
)
→
A
→
A
)
∧
(
∀
n
w
,
{{{
Ψ
n
w
}}}
vf
w
{{{
w'
,
RET
w'
;
Ψ
(
S
n
)
w'
}}})
∧
(
Ψ
0
%
nat
vz
)
∧
(
∀
n
w
,
Ψ
n
w
-
∗
⌜ψ
n
w
⌝
))
→
rtc
erased_step
([
e
<
_
>
vf
vz
]%
E
,
σ
)
(
of_val
w
::
es
,
σ
'
)
→
∃
n
:
nat
,
ψ
n
w
.
(* REMOVE *)
Proof
.
intros
He
Hfz
.
intros
He
.
apply
sem_gen_type_safety
with
(
φ
:
=
λ
w
,
∃
n
,
ψ
n
w
)=>
?.
exists
(
strong_nat_param_sem_ty
Σ
ψ
).
split
.
{
iIntros
(
?).
iDestruct
1
as
(?)
"%"
.
eauto
.
}
specialize
(
H
fz
_
)
as
(
Ψ
&
H
Ψ
&
Hf
&
H
z
).
exists
(
strong_nat_param_sem_ty
(
λ
n
:
nat
,
SemTy
(
λ
w
,
⌜ψ
n
w
⌝
)%
I
)
).
split
.
{
iIntros
(
v
[
n
?])
;
eauto
.
}
specialize
(
H
e
_
)
as
(
Ψ
&
H
e
&
H
v
f
&
H
vz
&
H
ψ
).
iIntros
(
vs
)
"!# #Hvs"
.
iPoseProof
(
He
with
"Hvs"
)
as
"He /="
.
wp_apply
(
wp_wand
with
"He"
).
iIntros
(
u
)
"#Hu"
.
iSpecialize
(
"Hu"
$!
(
strong_nat_param_semt
yp_famil
y
Ψ
)).
iSpecialize
(
"Hu"
$!
(
strong_nat_param_sem
_
ty
Ψ
)).
wp_apply
(
wp_wand
with
"Hu"
).
iIntros
(
w'
)
"#Hw'"
.
iSpecialize
(
"Hw'"
$!
f
with
"[]"
).
iSpecialize
(
"Hw'"
$!
v
f
with
"[]"
).
{
iIntros
"!#"
(
u'
)
"Hu'"
.
iDestruct
"Hu'"
as
(
k
)
"Hu'"
.
iApply
(
Hf
with
"Hu'"
).
iNext
.
iIntros
(
u''
)
"Hu''"
.
iApply
(
Hvf
with
"Hu'"
).
iIntros
"!>"
(
u''
)
"Hu''"
.
by
iExists
_
.
}
wp_apply
(
wp_wand
with
"Hw'"
).
iIntros
(
w''
)
"#Hw''"
.
iApply
wp_wand
.
{
iApply
(
"Hw''"
$!
z
with
"[]"
)
;
eauto
.
{
iApply
(
"Hw''"
$!
v
z
with
"[]"
)
;
eauto
.
iExists
0
%
nat
.
iApply
Hz
.
}
iApply
H
v
z
.
}
iIntros
(
v
).
iDestruct
1
as
(
k
)
"Hv"
.
iExists
k
.
by
iApply
H
Ψ
.
by
iApply
H
ψ
.
Qed
.
End
parametricity
.
theories/sem_type_formers.v
View file @
2a75020b
...
...
@@ -99,8 +99,8 @@ Section types.
types. However, for the sake of simplicity we did not consider
recursive types for this tutorial. In particular, to give the
semantics of recursive types one needs to use Iris's guarded
fixpoints which
in turn requires us to enforce that semantics types,
in addition to being persistent, are also non-expansive
. *)
fixpoints
,
which
require some additional bookkeeping related to
contractiveness
. *)
End
types
.
(** We introduce nicely looking notations for our semantic types. This allows
...
...
theories/sem_typed.v
View file @
2a75020b
...
...
@@ -43,10 +43,15 @@ Section sem_typed.
Global
Instance
env_sem_typed_ne
n
:
Proper
(
dist
n
==>
(=)
==>
dist
n
)
(@
env_sem_typed
Σ
_
).
Proof
.
Admitted
.
Proof
.
intros
Γ
1
Γ
2
H
Γ
ρ
?
<-.
apply
big_sepM2_ne_2
=>
//
k
A1
v1
A2
v2
_
_
HA
_
_
/
discrete_iff
/
leibniz_equiv_iff
->.
by
apply
HA
.
Qed
.
Global
Instance
env_sem_typed_proper
:
Proper
((
≡
)
==>
(=)
==>
(
≡
))
(@
env_sem_typed
Σ
_
).
Proof
.
intros
??????.
subst
.
rewrite
/
env_sem_typed
.
Admitted
.
Proof
.
intros
Γ
1
Γ
2
H
Γ
ρ
?
<-.
apply
equiv_dist
=>
n
.
f_equiv
.
by
rewrite
H
Γ
.
Qed
.
Global
Instance
sem_typed_ne
n
:
Proper
(
dist
n
==>
(=)
==>
dist
n
==>
dist
n
)
(@
sem_typed
Σ
_
).
Proof
.
solve_proper
.
Qed
.
...
...
theories/sem_types.v
View file @
2a75020b
...
...
@@ -3,22 +3,25 @@ From iris.heap_lang Require Export proofmode.
From
iris
.
base_logic
.
lib
Require
Export
invariants
.
(** * The domain of semantics types. *)
(** Here we define the domain of semantics types as persistent
i
ris
(** Here we define the domain of semantics types as persistent
I
ris
predicates over values. That is, to capture the semantics of a
type [τ], we need to define what
programs are
belong to the
type [τ], we need to define what
expressions
belong to the
semantics of [τ]. We do this in two steps:
- We define what values semantically belong to type [τ]
- We define what values semantically belong to type [τ]. We do
this in the file [sem_type_formers].
- We define the expressions that semantically belong to [τ]. An
expression [e] semantically belongs to type [τ] if [e] is
_safe_, and whenever it evaluates to a value [v], [v]
semantically belongs to [τ].
semantically belongs to [τ].
We do this in the file [sem_typed].
Here we use
i
ris predicates as value semantics of types. The power
i
ris's logic then allows us to define many semantic types
Here we use
I
ris predicates as value semantics of types. The power
of I
ris's logic then allows us to define many semantic types
including those that we need to interpret syntactic types for
heap_lang, e.g., higher-order references, parametric polymorphism,
etc. It is crucial for value semantics of types to be persistent
etc.
It is crucial for value semantics of types to be persistent
predicates. This is due to the fact that our type system (as
opposed to substructural type systems, e.g., affine type systems)
allows values to be used multiple times. Hence, the fact that a
...
...
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