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
10deb9d3
Commit
10deb9d3
authored
6 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
add F, U types, prove that they "preserve" upcasts, downcasts resp.
parent
6a2b644b
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
+206
-0
206 additions, 0 deletions
gcbpv.tex
with
206 additions
and
0 deletions
gcbpv.tex
+
206
−
0
View file @
10deb9d3
...
...
@@ -14,6 +14,8 @@
\newcommand
{
\hole
}{
\bullet
}
\renewcommand
{
\u
}{
\underline
}
\newcommand
{
\ltdyn
}{
\sqsubseteq
}
\newcommand
{
\gtdyn
}{
\sqsupseteq
}
\newcommand
{
\equidyn
}{
\mathrel
{
\gtdyn\ltdyn
}}
\newcommand
{
\ltdynv
}{
\mathrel
{
\sqsubseteq
_
V
}}
\newcommand
{
\ltdynt
}{
\mathrel
{
\sqsubseteq
_
T
}}
...
...
@@ -27,6 +29,9 @@
\newcommand
{
\M
}{
\mathcal
{
M
}}
\newcommand
{
\sq
}{
\square
}
\newcommand
{
\lett
}{
\text
{
let
}
\,\,
}
\newcommand
{
\ret
}{
\text
{
ret
}
\,\,
}
\newcommand
{
\thunk
}{
\text
{
thunk
}
\,\,
}
\newcommand
{
\force
}{
\text
{
force
}
\,\,
}
\begin{document}
\title
{
Gradual Call-By-Push-Value
}
...
...
@@ -306,5 +311,206 @@ dynamism.
\caption
{
Upcasts and Downcasts (Would be simpler with a Stoup)
}
\end{figure}
Next, we add the
$
\u
F
$
and
$
U
$
types that mediate between the worlds
of values and computations. The
$
\u
F
$
type takes a value type and
makes the computation type of ``things that may eventually return
values of type
$
A
$
''. In CBPV, the
$
\u
F
$
type is a lot like the
monadic type in Moggi's metalanguage in that a call-by-value ``term''
is interpreted as a computation whose type is
$
\u
F A
$
. To produce an
$
\u
F A
$
we return a value, and to consume one, we let-bind its
eventual value to a variable and proceed. The
$
\beta
$
rule says that
returning a value and then let-binding it should be that same as
substituting the value in and the
$
\eta
$
rule says that any term where
an
$
\u
F
$
type is in elimination position is equivalent to let-binding
it.
On the other side, the
$
U
$
type constructor turns a computation into a
\emph
{
thunked
}
value that can be
\emph
{
forced
}
to perform its effect
(in a term judgment of course).
In
\emph
{
Gradual
}
call-by-push-value, following the dogma of gradual
type theory, we simply ``make everything monotone''.
%
With this, we can get our ``missing'' downcasts between value types
and upcasts between computation types: they are in the image of
$
\u
F,
U
$
respectively.
%
Both constructors define
\emph
{
monotone functors
}
and it is a general
theorem that monotone functors preserve representability, so we get
that for
$
\u
F
$
and
$
U
$
types, we have both an upcast and a downcast
from a preordering.
\begin{figure}
\begin{mathpar}
\inferrule
{
A
\vtype
}
{
\u
F A
\ctype
}
\inferrule
{
A
_
1
\ltdyn
A
_
2
}
{
\u
F A
_
1
\ltdyn
\u
F A
_
2
}
\\
\inferrule
{
\Gamma
\vdash
v : A
}
{
\Gamma\pipe\cdot
\vdash
\ret
v :
\u
F A
}
\inferrule
{
\Phi
\vdash
v
_
1
\ltdyn
v
_
2 : A
_
1
\ltdyn
A
_
2
}
{
\Phi\pipe\cdot
\vdash
\ret
v
_
1
\ltdyn
\ret
v
_
2 :
\u
F A
_
1
\ltdyn
\u
F A
_
2
}
\\
\inferrule
{
\Gamma
\pipe\Delta
\vdash
M :
\u
F A
\and
\Gamma
, x : A
\vdash
N :
\u
B
}
{
\Gamma
\pipe
\Delta
\vdash
\lett
x = M; N :
\u
B
}
\inferrule
{
\Phi
\pipe\Psi
\vdash
M
_
1
\ltdyn
M
_
2 :
\u
F A
_
1
\ltdyn
\u
F A
_
2
\\
\Phi
, x
_
1
\ltdyn
x
_
2 : A
_
1
\ltdyn
A
_
2
\pipe
\cdot
\vdash
N
_
1
\ltdyn
N
_
2 :
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
\Phi
\pipe
\Psi
\vdash
\lett
x
_
1 = M
_
1; N
_
1
\ltdyn
\lett
x
_
2 = M
_
2; N
_
2 :
\u
B
_
1
\ltdyn
\u
B
_
2
}
\\
\inferrule
{}
{
\lett
x =
\ret
v; N
\equidyn
N[v/x]
}
\inferrule
{}
{
\lett
x =
\ret
y; N
\equidyn
N[y/x]
}
\inferrule
{
\Gamma\pipe\Delta
\vdash
N :
\u
F A
}
{
M[N/
\hole
]
\equidyn
\lett
x = N; M[
\ret
x/
\hole
]
}
\inferrule
{
\Gamma
\pipe
\hole
:
\u
F A
\vdash
M :
\u
B
}
{
M
\equidyn
\lett
x =
\hole
; M[
\ret
x/
\hole
]
}
\\
\inferrule
{
\u
B
\ctype
}
{
U
\u
B
\vtype
}
\inferrule
{
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
\\
\inferrule
{
\Gamma\pipe
\cdot
\vdash
M :
\u
B
}
{
\Gamma
\vdash
\thunk
M : U
\u
B
}
\inferrule
{
\Phi\pipe
\cdot
\vdash
M
_
1
\ltdyn
M
_
2 :
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
\Phi
\vdash
\thunk
M
_
1
\ltdyn
\thunk
M
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
\\
\inferrule
{
\Gamma
\vdash
v : U
\u
B
}
{
\Gamma\pipe
\cdot
\vdash
\force
v :
\u
B
}
\inferrule
{
\Phi
\vdash
v
_
1
\ltdyn
v
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
{
\Phi\pipe
\cdot
\vdash
\force
v
_
1
\ltdyn
\force
v
_
2 :
\u
B
_
1
\ltdyn
\u
B
_
2
}
\\
\inferrule
{}
{
\force
\thunk
M
\equidyn
M
}
\inferrule
{}
{
\force
\thunk
\hole
\equidyn
\hole
}
\\
\inferrule
{}
{
\thunk
\force
v
\equidyn
v
}
\inferrule
{}
{
\thunk
\force
x
\equidyn
x
}
\end{mathpar}
\caption
{
Adjunction Constructors (Stoupified) Beta and Eta are presented with and without cuts
}
\end{figure}
\begin{figure}
\begin{mathpar}
\inferrule
{
\Gamma
, x : A
_
1
\vdash
\upcast
{
A
_
1
}
{
A
_
2
}
x : A
_
2
}
{
\Gamma\pipe
\hole
:
\u
F A
_
1
\vdash
\lett
x =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x :
\u
F A
_
2
}
\inferrule
{
A
_
1
\ltdyn
A
_
2
}
{
\cdot
\pipe
\hole
:
\u
F A
_
1
\vdash
\hole
\ltdyn
\lett
x =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x :
\u
F A
_
1
\ltdyn
\u
F A
_
2
}
\inferrule
{
A
_
1
\ltdyn
A
_
2
}
{
\cdot
\pipe
\hole
\ltdyn
\hole
:
\u
F A
_
1
\ltdyn
\u
F A
_
2
\vdash
\lett
x
_
1 =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x
_
1
\ltdyn
\hole
:
\u
F A
_
2
}
\inferrule
{
\Gamma
\pipe
\hole
:
\u
B
_
2
\vdash
\dncast
{
\u
B
_
1
}
{
\u
B
_
2
}
\hole
:
\u
B
_
1
}
{
\Gamma
, x: U
\u
B
_
2
\vdash
\thunk
\dncast
{
\u
B
_
1
}
{
\u
B
_
2
}
\force
x : U
\u
B
_
1
}
\inferrule
{
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
x : U
\u
B
_
2
\vdash
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
\ltdyn
x : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
\inferrule
{
\u
B
_
1
\ltdyn
\u
B
_
2
}
{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
x
_
1
\ltdyn
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
_
2 : U
\u
B
_
1
}
\end{mathpar}
\caption
{
Functoriality Preserves Representability (Theorem Statments)
}
\end{figure}
\begin{figure}
\begin{mathpar}
\inferrule*
{
\hole
\ltdyn
\lett
x =
\hole
;
\ret
x
\and
\inferrule*
{
\hole
\ltdyn
\hole
\and
\inferrule*
{
x :
\u
F A
_
1
\vdash
x
\ltdyn
\upcast
{
A
_
1
}{
A
_
2
}
x
}
{
x :
\u
F A
_
1
\vdash
\ret
x
\ltdyn
\ret
\upcast
{
A
_
1
}{
A
_
2
}
x
}
}
{
\hole
:
\u
F A
_
1
\vdash
\lett
x =
\hole
;
\ret
x
\ltdyn
\lett
x =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x
}
}
{
\cdot
\pipe
\hole
:
\u
F A
_
1
\vdash
\hole
\ltdyn
\lett
x =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x :
\u
F A
_
1
\ltdyn
\u
F A
_
2
}
\inferrule*
{
\inferrule*
{
\hole
\ltdyn
\hole
\and
\inferrule
{{
x
_
1
\ltdyn
x
_
2 : A
_
1
\ltdyn
A
_
2
\vdash
\upcast
{
A
_
1
}
{
A
_
2
}
x
_
1
\ltdyn
x
_
2
}}
{
x
_
1
\ltdyn
x
_
2 : A
_
1
\ltdyn
A
_
2
\vdash
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x
_
1
\ltdyn
\ret
x
_
2
}}
{
\lett
x
_
1 =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x
_
1
\ltdyn\lett
x
_
2 =
\hole
;
\ret
x
_
2
}
\and
\hole
\ltdyn
\lett
x
_
2 =
\hole
;
\ret
x
_
2
}
{
\cdot
\pipe
\hole
\ltdyn
\hole
:
\u
F A
_
1
\ltdyn
\u
F A
_
2
\vdash
\lett
x
_
1 =
\hole
;
\ret
\upcast
{
A
_
1
}
{
A
_
2
}
x
_
1
\ltdyn
\hole
:
\u
F A
_
2
}
\inferrule
{
\inferrule
{
\inferrule
{{
x : U
\u
B
_
2
\vdash
\force
x
\ltdyn
\force
x : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}}
{
x : U
\u
B
_
2
\vdash
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
\ltdyn
\force
x : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}}
{
x : U
\u
B
_
2
\vdash
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
\ltdyn
\thunk
\force
x : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
\and
\thunk
\force
x
\ltdyn
x
}
{
x : U
\u
B
_
2
\vdash
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
\ltdyn
x : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}
\inferrule
{
x
_
1
\ltdyn
\thunk
\force
x
_
1
\and
\inferrule
{
\inferrule
{
\inferrule
{{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
}}
{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
\force
x
_
1
\ltdyn
\force
x
_
2 :
\u
B
_
1
\ltdyn
\u
B
_
2
}}
{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
\force
x
_
1
\ltdyn
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
_
2 :
\u
B
_
1
}}
{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
\thunk
\force
x
_
1
\ltdyn
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
_
2 : U
\u
B
_
1
}
}
{
x
_
1
\ltdyn
x
_
2 : U
\u
B
_
1
\ltdyn
U
\u
B
_
2
\vdash
x
_
1
\ltdyn
\thunk
\dncast
{
\u
B
_
1
}{
\u
B
_
2
}
\force
x
_
2 : U
\u
B
_
1
}
\end{mathpar}
\caption
{
Functoriality Preserves Representability (Proofs)
}
\end{figure}
\end{document}
%% Local Variables:
%% compile-command: "pdflatex gcbpv.tex"
%% End:
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