Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sgdt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gradual-typing
sgdt
Commits
1a8ea286
Commit
1a8ea286
authored
6 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
make upcasts uparrows, dncast down, add model stuff, start function types
parent
10deb9d3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gcbpv.tex
+122
-8
122 additions, 8 deletions
gcbpv.tex
with
122 additions
and
8 deletions
gcbpv.tex
+
122
−
8
View file @
1a8ea286
...
...
@@ -3,10 +3,12 @@
\usepackage
{
amsmath,amssymb
}
\usepackage
{
tikz-cd
}
\usepackage
{
mathpartir
}
\usepackage
{
rotating
}
\newtheorem
{
theorem
}{
Theorem
}
\newtheorem
{
definition
}{
Definition
}
\newcommand
{
\vtype
}{
\,\,\text
{
val type
}}
\newcommand
{
\ctype
}{
\,\,\text
{
comp type
}}
\newcommand
{
\ctx
}{
\,\,\text
{
ctx
}}
...
...
@@ -20,8 +22,15 @@
\newcommand
{
\ltdynt
}{
\mathrel
{
\sqsubseteq
_
T
}}
\newcommand
{
\dyn
}{{
?
}}
\newcommand
{
\upcast
}
[2]
{
\langle
{
#2
}
\leftarrowtail
{
#1
}
\rangle
}
\newcommand
{
\dncast
}
[2]
{
\langle
{
#1
}
\twoheadleftarrow
{
#2
}
\rangle
}
\newcommand
{
\dynv
}{{
?
}}
\newcommand
{
\dync
}{
\u
{
\text
{
?`
}}}
\newcommand
{
\uarrow
}{
\mathrel
{
\rotatebox
[origin=c]
{
-30
}{$
\leftarrowtail
$}}}
\newcommand
{
\darrow
}{
\mathrel
{
\rotatebox
[origin=c]
{
30
}{$
\twoheadleftarrow
$}}}
\newcommand
{
\upcast
}
[2]
{
\langle
{
#2
}
\uarrow
{
#1
}
\rangle
}
\newcommand
{
\dncast
}
[2]
{
\langle
{
#1
}
\darrow
{
#2
}
\rangle
}
\newcommand
{
\err
}{
\mho
}
\newcommand
{
\roll
}{
\text
{
roll
}
\,\,
}
\newcommand
{
\unroll
}{
\text
{
unroll
}
\,\,
}
\newcommand
{
\Set
}{
\text
{
Set
}}
...
...
@@ -29,6 +38,7 @@
\newcommand
{
\M
}{
\mathcal
{
M
}}
\newcommand
{
\sq
}{
\square
}
\newcommand
{
\lett
}{
\text
{
let
}
\,\,
}
\newcommand
{
\case
}{
\text
{
case
}
\,\,
}
\newcommand
{
\ret
}{
\text
{
ret
}
\,\,
}
\newcommand
{
\thunk
}{
\text
{
thunk
}
\,\,
}
\newcommand
{
\force
}{
\text
{
force
}
\,\,
}
...
...
@@ -236,12 +246,6 @@ for each.
\caption
{
GCBPV Basic Judgmental Rules 2 (Reflexivities, Transitivities)
}
\end{figure}
Errors are least terms at every computation type (not stacks).
%
The dynamic type is probably a greatest
\emph
{
value type
}
.
%
Casts are, naturally, the most interesting case.
%
A na
\"
ive attempt to add casts in the style of cbn gradual type theory
(TODO: cite) would be to add an upcast and downcast
\emph
{
values
}
for
every value type dynamism judgment and upcast and downcast
...
...
@@ -509,6 +513,116 @@ from a preordering.
\caption
{
Functoriality Preserves Representability (Proofs)
}
\end{figure}
\begin{figure}
\begin{mathpar}
\inferrule
{}{
\dynv
\vtype
}
\inferrule
{}{
\dync
\ctype
}
\inferrule
{
A
\vtype
}{
A
\ltdyn
\dynv
}
\inferrule
{
\u
B
\ctype
}{
\u
B
\ltdyn
\dync
}
\end{mathpar}
\caption
{
Dynamic Types
}
\end{figure}
\section
{
Models
}
A model of gcbpv consists of a preorder-enriched cbpv model with
specified interpretations of
$
\dynv
,
\dync
$
and the following
precision judgments. Note that we don't need
$
0
\ltdyn
\dynv
$
and
$
\top
\ltdyn
\dync
$
because those are uniquely determined by the
universal property.
\begin{mathpar}
1
\ltdyn
\dynv
\dynv
\times
\dynv
\ltdyn
\dynv
\dynv
+
\dynv
\ltdyn
\dynv
U
\dync
\ltdyn
\dynv\\
\dync
\wedge
\dync
\ltdyn
\dync
\dynv
\to
\dync
\ltdyn
\dync
\u
F
\dynv
\ltdyn
\dync
\end{mathpar}
Next, we will use poset CBPV as a metalanguage and compile GCBPV into
poset CBPV with recursive types.
\begin{mathpar}
\dynv
(X,
\u
Y) = 1 + (X
\times
X) + (X + X) + U
\u
Y
\dync
(X,
\u
Y) = (
\u
Y
\wedge
\u
Y)
\wedge
(X
\to
\u
Y)
\wedge
\u
F X
\dynv
=
\mu
X.
\dynv
(X,
\u
\mu
\u
Y.
\dync
(X,
\u
Y))
\dync
=
\mu
\u
Y.
\dync
(
\mu
X.
\dynv
(X,
\u
Y),
\u
Y)
\end{mathpar}
We call the cases of
$
\dynv
$
the ``tag types'' and abbreviate them
$
T
$
because they are the tags of the sum, and the cases of the
$
\dync
$
the
``message types'' and abbreviate them
$
\u
M
$
because they are the
possible messages of the ``coinductive'' dynamic type.
%
We implement the appropriate casts and their adjoints as follows
\[
\upcast
T
\dynv
x
=
\roll
\sigma
_
T x
\]
\[
\dncast
{
\u
F T
}
{
\u
F
\dynv
}
\hole
=
\lett
x
=
\hole
;
\case
\unroll
x
\{
\sigma
_
T y
\mapsto
y;
\sigma
_{
T'
}
y
\mapsto
\err
\}
\]
\[
\dncast
{
\u
M
}
\dync
\hole
=
\pi
_{
\u
M
}
\u
\unroll
\hole
\]
\[
\upcast
{
U
\u
M
}
{
U
\dync
}
x
=
\u
\roll
\thunk
[
\pi
_{
\u
M
}
\mapsto
\force
x;
\pi
_{
\u
M'
}
\mapsto
\err
]
\]
\begin{figure}
\inferrule
{
A
\vtype
\and
\u
B
\ctype
}
{
A
\to
\u
B
\ctype
}
\inferrule
{
A
_
1
\ltdyn
A
_
2
\and
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
A
_
1
\to
\u
B
_
1
\ltdyn
A
_
2
\to
\u
B
_
2
}
\inferrule
{
\Gamma
, x : A
\pipe
\Delta
\vdash
M : B
}
{
\Gamma
\pipe
\Delta
\vdash
\lambda
x:A. M : A
\to
\u
B
}
\inferrule
{
\Phi
, x
_
1
\ltdyn
x
_
2 : A
_
1
\ltdyn
A
_
2
\pipe
\Psi
\vdash
M
_
1
\ltdyn
M
_
2 : B
_
1
\ltdyn
B
_
2
}
{
\Phi
\pipe
\Psi
\vdash
\lambda
x
_
1:A
_
1. M
_
1
\ltdyn
\lambda
x
_
2:A
_
2. M
_
2 : A
_
1
\to
\u
B
_
1
\ltdyn
A
_
2
\to
\u
B
_
2
}
\inferrule
{
\Gamma
\pipe
\Delta
\vdash
M : A
\to
\u
B
\and
\Gamma
\vdash
v : A
}
{
\Gamma
\pipe
\Delta
\vdash
M(v) :
\u
B
}
\inferrule
{
\Phi
\pipe
\Psi
\vdash
M
_
1
\ltdyn
M
_
2 : A
_
1
\to
\u
B
_
1
\ltdyn
A
_
2
\to
\u
B
_
2
\and
\Phi
\vdash
v
_
1
\ltdyn
v
_
2 : A
_
1
\ltdyn
A
_
2
}
{
\Phi
\pipe
\Psi
\vdash
M
_
1(v
_
1)
\ltdyn
M
_
2(v
_
2) :
\u
B
_
1
\ltdyn
\u
B
_
2
}
\caption
{
Function Type
}
\end{figure}
\begin{figure}
\inferrule
{}
{
\dncast
{
A
_
1
\to
\u
B
_
1
}{
A
_
2
\to
\u
B
_
2
}
\bullet
\equidyn
\lambda
x:A
_
1.
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
(
\bullet
(
\upcast
{
A
_
1
}
{
A
_
2
}
))
}
\inferrule
{}
{
\upcast
{
U(
{
A
_
1
\to
\u
B
_
1
}
)
}{
U(
{
A
_
2
\to
\u
B
_
2
}
)
}
(f : U(A
_
1
\to
\u
B
_
1))
\equidyn
\thunk
\lambda
x
_
2 : A
_
2.
\force
\upcast
{
U
\u
B
_
1
}{
U
\u
B
_
2
}
(
\thunk
((
\force
f)))
}
\caption
{
Function Contract Theorem, Proof
}
\end{figure}
\end{document}
%% Local Variables:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment