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
2db04def
Commit
2db04def
authored
6 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
some comments on the general picture
parent
294b2fcb
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
+132
-4
132 additions, 4 deletions
gcbpv.tex
with
132 additions
and
4 deletions
gcbpv.tex
+
132
−
4
View file @
2db04def
\documentclass
{
article
}
\usepackage
{
float
}
\usepackage
{
amsmath,amssymb
}
\usepackage
{
amsmath,amssymb
, amsthm
}
\usepackage
{
tikz-cd
}
\usepackage
{
mathpartir
}
\usepackage
{
rotating
}
...
...
@@ -532,10 +532,138 @@ from a preordering.
\section
{
Connectives and Contract Uniqueness Theorems
}
Next we consider the
multiplicative and additiv
e connectives
of
gradual
call-by-push
value
, and their corresponding contracts
.
Next we consider the
contract uniqueness theorems for th
e connectives
of
call-by-push
-
value.
%
We start with the additives because they are comparatively easier.
First, an abstract perspective on the following theorems.
%
The primitive rules of upcasts and downcasts covariantly assign an
upcast
$
\upcast
{
A
}{
A'
}$
to any value type dynamism judgment
$
A
\ltdyn
A'
$
and contravariantly assign a downcast
$
\dncast
{
\u
B
}{
\u
B'
}$
to
any computation type dynamism judgment
$
\u
B
\ltdyn
\u
B'
$
.
%
Next, note that
\emph
{
every
}
type constructor in call-by-push-value is
jointly functorial in its arguments, with the domain of the function
type being the only contravariant position of any of the connectives
(though if we have EEC connectives, it's more complex).
%
When these two variances align, the contract uniqueness theorem is
very simple.
%
We call any connective where all
\emph
{
covariant
}
arguments are of the
same
\emph
{
sort
}
(i.e., value vs computation type) and all
\emph
{
contravariant
}
arguments are of the opposite sort a
\emph
{
nice
}
connective.
%
Then every nice connective has a nice uniqueness theorem for its
same-sorted cast, i.e., upcasts for value types and downcasts for
computation types.
The only two connectives in CBPV that are not
\emph
{
nice
}
are the
$
\u
F
$
and the
$
U
$
types since each are covariant in their argument but
swap sorts.
%
And correspondingly, neither of these types has a fully general
contract uniquness theorem.
%
That is, for a base value type dynamism
$
X
_
1
\ltdyn
X
_
2
$
, we have no
contract uniqueness theorem for the downcast given by
$
\u
F X
_
1
\ltdyn
\u
F X
_
2
$
.
%
However, that's not to say that
$
\u
F
$
and
$
U
$
have
\emph
{
no
}
associated uniqueness principles: instead, we will show in what
follows that the application of
$
\u
F
$
or
$
U
$
to any connective can be
shown to have a uniqueness principle.
%
Unlike with functoriality, we do not know the general principle, but
it seems closely related to work on so-called ``direct models'' of
effectful computation, i.e. Freyd Categories, Fuhrmann's Abstract
Kleisli Categories and Munch-Maccagnoni's duploids.
\begin{theorem}
[Admissibility of (Almost All) Downcasts]
Any upcast or downcast associated to a cut-free type dynamism
judgment (i.e., one only built out of monotonicity rules) in gradual
call-by-push-value is equivalent to a term whose only upcasts and
downcasts are those that are ``axiomatically undetermined'': defined in
figure
\ref
{
axiomatically-free
}
.
\end{theorem}
\begin{proof}
We prove the theorem by induction on dynamism derivations with
$
4
$
mutually recursive cases
\begin{mathpar}
\inferrule
{
A
\ltdyn
A'
}{
\upcast
A
{
A'
}}
\inferrule
{
A
\ltdyn
A'
}{
\dncast
{
\u
F A
}{
\u
F A'
}}
\inferrule
{
\u
B
\ltdyn
\u
B'
}{
\dncast
{
\u
B
}{
\u
B'
}}
\inferrule
{
\u
B
\ltdyn
\u
B'
}{
\upcast
{
U
\u
B
}{
U
\u
B'
}}
\end{mathpar}
The cases are all in other sections, we record them here to state
precisely the inductive structure of the proof and cover the trivial
cases (units).
\begin{enumerate}
\item
Value Types
\begin{enumerate}
\item
$
1
\ltdyn
1
$
: upcast is identity, by decomposition theorem,
similarly for downcast.
\item
$
A
_
1
\times
A
_
2
\ltdyn
A
_
1
'
\times
A
_
2
'
$
: see multiplicatives and use the inductive hypothesis.
\item
$
0
\ltdyn
0
$
: By
$
\eta
$
for
$
0
$
, must be
$
\case
x
\{
\}
$
,
similarly the downcast must be equivalent to
$
\lett
x
=
\bullet
;
\case
x
\{
\}
$
.
\item
$
A
_
1
+
A
_
2
\ltdyn
A
_
1
'
+
A
_
2
'
$
: see additives and use
inductive hypothesis
\item
$
U
\u
B
\ltdyn
U
\u
B'
$
: by inductive hypothesis on
$
\u
B
\ltdyn
\u
B'
$
, there is an upcast
$
U
\u
B
\ltdyn
U
\u
B'
$
. For
the downcast, we need a downcast
$
\dncast
{
\u
F U
\u
B
}{
\u
F U
\u
B'
}$
, for which we use the inductive hypothesis for
$
\u
B
\ltdyn
\u
B'
$
and the functoriality of
$
U,
\u
F
$
(see the
exponential section).
\end{enumerate}
\item
Computation Types.
\begin{enumerate}
\item
$
\top
\ltdyn
\top
$
: by
$
\eta
$
for
$
\top
$
, the downcast must by
$
\{\}
$
. Similarly, the upcast must be
$
\thunk\{\}
$
\item
$
\inferrule
{
A
_
1
\ltdyn
A
_
1
'
\and
A
_
2
\ltdyn
A
_
2
'
}{
A
_
1
\times
A
_
2
\ltdyn
A
_
1
'
\times
A
_
2
'
}$
See additives section and use the
inductive hypotheses
\item
$
\inferrule
{
A
\ltdyn
A'
\and
\u
B
\ltdyn
\u
B'
}{
A
\to
\u
B
\ltdyn
A
\to
\u
B'
}$
See multiplicatives section and use the
inductive hypotheses.
\item
$
\inferrule
{
A
\ltdyn
A'
}{
\u
F A
\ltdyn
\u
F A'
}$
for the
downcast, use the inductive hypothesis. For the upcast, use the
inductive hypothesis and see the exponential section.
\end{enumerate}
\end{enumerate}
\end{proof}
\begin{figure}
\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}
\caption
{
Cut-Free Type Dynamism (with
$
\dynv
,
\dync
$
)
}
\end{figure}
\begin{figure}
\begin{mathpar}
\upcast
{
T
}{
\dynv
}
\upcast
{
U
\u
M
}{
U
\dync
}
\dncast
{
\u
M
}{
\dync
}
\dncast
{
\u
F T
}{
\u
F
\dynv
}
\end{mathpar}
\caption
{
Axiomatically Undetermined Upcasts, Downcasts
}
\label
{
axiomatically-free
}
\end{figure}
\subsection
{
Additive Connectives: Positive Sum, Negative Product
}
...
...
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