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
c242af05
Commit
c242af05
authored
Jan 18, 2020
by
Robbert Krebbers
Browse files
Syntactic typing exercises.
parent
fd46e3a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
theories/typed.v
View file @
c242af05
...
...
@@ -137,3 +137,72 @@ with val_typed : val → ty → Prop :=
⊢
ᵥ
RecV
f
x
e
:
TArr
τ
1
τ
2
where
"Γ ⊢ₜ e : τ"
:
=
(
typed
Γ
e
τ
)
and
"⊢ᵥ v : τ"
:
=
(
val_typed
v
τ
).
Lemma
Lam_typed
Γ
x
e
τ
1
τ
2
:
(
binder_insert
x
τ
1
Γ
⊢
ₜ
e
:
τ
2
)
→
Γ
⊢
ₜ
(
λ
:
x
,
e
)
:
TArr
τ
1
τ
2
.
Proof
.
intros
He
.
apply
Rec_typed
.
simpl
.
done
.
Qed
.
Lemma
LamV_typed
x
e
τ
1
τ
2
:
(
binder_insert
x
τ
1
∅
⊢
ₜ
e
:
τ
2
)
→
⊢
ᵥ
(
λ
:
x
,
e
)
:
TArr
τ
1
τ
2
.
Proof
.
intros
He
.
apply
RecV_typed
.
simpl
.
done
.
Qed
.
Lemma
Let_typed
Γ
x
e1
e2
τ
1
τ
2
:
(
Γ
⊢
ₜ
e1
:
τ
1
)
→
(
binder_insert
x
τ
1
Γ
⊢
ₜ
e2
:
τ
2
)
→
Γ
⊢
ₜ
(
let
:
x
:
=
e1
in
e2
)
:
τ
2
.
Proof
.
intros
He1
He2
.
apply
App_typed
with
τ
1
.
-
by
apply
Lam_typed
.
-
done
.
Qed
.
Lemma
Seq_typed
Γ
e1
e2
τ
1
τ
2
:
(
Γ
⊢
ₜ
e1
:
τ
1
)
→
(
Γ
⊢
ₜ
e2
:
τ
2
)
→
Γ
⊢
ₜ
(
e1
;;
e2
)
:
τ
2
.
Proof
.
intros
He1
He2
.
by
apply
Let_typed
with
τ
1
.
Qed
.
Lemma
Skip_typed
Γ
:
Γ
⊢
ₜ
Skip
:
().
Proof
.
apply
App_typed
with
()%
ty
.
-
apply
Val_typed
,
RecV_typed
.
apply
Val_typed
,
UnitV_typed
.
-
apply
Val_typed
,
UnitV_typed
.
Qed
.
Definition
swap
:
val
:
=
λ
:
"l1"
"l2"
,
let
:
"x"
:
=
!
"l1"
in
"l1"
<-
!
"l2"
;;
"l2"
<-
"x"
.
Lemma
swap_typed
τ
:
⊢
ᵥ
swap
:
(
ref
τ
→
ref
τ
→
()).
Proof
.
unfold
swap
.
apply
LamV_typed
.
apply
Lam_typed
.
apply
Let_typed
with
τ
.
{
apply
Load_typed
.
by
apply
Var_typed
.
}
apply
Seq_typed
with
()%
ty
.
{
apply
Store_typed
with
τ
.
-
by
apply
Var_typed
.
-
apply
Load_typed
.
by
apply
Var_typed
.
}
apply
Store_typed
with
τ
.
-
by
apply
Var_typed
.
-
by
apply
Var_typed
.
Qed
.
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