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
afcc7d41
Commit
afcc7d41
authored
2 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
sketch of a naive view of gradual types
parent
0cc2ee67
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
denotational-gradual-typing.tex
+133
-0
133 additions, 0 deletions
denotational-gradual-typing.tex
with
133 additions
and
0 deletions
denotational-gradual-typing.tex
0 → 100644
+
133
−
0
View file @
afcc7d41
\documentclass
{
article
}
\usepackage
{
amssymb
}
\usepackage
{
amsmath
}
\usepackage
{
amsthm
}
\usepackage
{
tikz-cd
}
\usepackage
{
mathpartir
}
\usepackage
{
stmaryrd
}
\newtheorem
{
theorem
}{
Theorem
}
[section]
\newtheorem
{
nonnum-theorem
}{
Theorem
}
[section]
\newtheorem
{
corollary
}{
Corollary
}
[section]
\newtheorem
{
definition
}{
Definition
}
[section]
\newtheorem
{
lemma
}{
Lemma
}
[section]
\newcommand
{
\dynv
}{
\text
{
Dyn
}^
+
}
\newcommand
{
\dync
}{
\text
{
Dyn
}^
-
}
\newcommand
{
\good
}
[1]
{
\text
{
good
}_{
#1
}}
\newcommand
{
\prop
}{
\mathbb
P
}
\newcommand
{
\with
}{
\mathrel
{
\&
}}
\newcommand
{
\eqv
}{
\simeq
}
\newcommand
{
\soln
}{
\text
{
Sol
}}
\newcommand
{
\police
}
[1]
{
\text
{
police
}_{
#1
}}
\newcommand
{
\later
}{{
\blacktriangleright
}}
\begin{document}
\title
{
Gradual Types as Subsets
}
\author
{
Max S. New
}
\maketitle
We fix a predomain
$
\dynv
$
with poset structure and a domain
$
\dync
$
with bounded below poset structure as solutions to the domain
equations:
\[
\dynv
=
2
+
\dync
\]
\[
\dync
=
(
\dynv
\to
\dync
)
\with
L
(
\dynv
_{
\mho
}
)
\]
Q: does this actually get us the right order?
Q: what domain-theoretic properties does the order have that matter?
There are several ways to define essentially the same interpretation
of CBV gradually typed lambda calculus with booleans into this
semantics:
\begin{enumerate}
\item
Types as ((Co-)Kleisli) co-reflections
\item
Types as interior operators
\end{enumerate}
I want to explore one that I previously dismissed as somewhat na
\"
ive:
value types are (well-behaved) subsets of the universal predomain and
computation types are (well-behaved) quotients of the universal
domain.
\begin{enumerate}
\item
A value type
$
A
$
is a
\emph
{
policeable
}
predicate
$
\good
A :
\dynv
\to
\prop
$
\item
A computation type
$
B
$
is a
\emph
{
envelopable
}
equivalence
relation
$
\eqv
B :
\text
{
Equivalence
}
(
\dynv
)
$
\end{enumerate}
Let's explain what these mean.
%
First, define
$
\soln
A
$
to be the set of ``good'' elements of
$
\dynv
$
according to
$
A
$
, i.e.,
$
\{
d :
\dynv
\,
|
\,
\good
A d
\}
$
.
%
$
\good
A
$
is
\emph
{
policeable
}
when there exists a function
$
\police
A
:
\dynv
\to
(
\soln
A
)
_
\mho
$
satisfying two properties:
\begin{enumerate}
\item
(monotonicity)
$
\forall
d
\sqsubseteq
d'.
\police
A d
\sqsubseteq
\police
A d'
$
\item
(retraction)
$
\forall
x
\in
\soln
A.
\police
A x
=
\eta
x
$
\item
(projection)
$
\forall
d
\in
\dynv
.
\police
d
\sqsubseteq
\eta
d
$
\end{enumerate}
If
$
\sqsubseteq
$
is a poset and
$
\eta
: A
\to
A
_
\mho
$
is order-reflecting,
then
$
\police
A
$
is uniquely determined by these two properties, for
if there were another such function
$
(
\police
A
)
'
$
we would have
\[
\]
\subsection
{
Synthetic Guarded Domain Theory
}
We can solve the domain equation using synthetic guarded domain
theory.
\begin{align*}
\dynv
&
=
\mu
(
\lambda
D
^
+. 2 +
\mu
(
\lambda
D
^
-. L (1 + D
^
+)
\times
(D
^
+
\to
D
^
-) ))
\\
\dync
&
=
\mu
(
\lambda
D
^
-. L (1 +
\later
\dynv
)
\times
(
\later
\dynv
\to
D
^
-) )
\end{align*}
unfolding this gives us
\begin{align*}
\dynv
&
\cong
2 +
\dync
\\
\dync
&
= L (1 +
\later
\dynv
)
\times
(
\later
\dynv
\to
\later
\dync
)
\\
&
\cong
L (1 +
\later
\dynv
)
\times
\later
(
\dynv
\to
\dync
)
\end{align*}
\begin{lemma}
{
Universal Domain
}
$
\dync
$
is a domain with algebra
\[
\theta
_
\dync
=
\lambda
p:
\later
\dync
.
(
\pi
_
1
p,
)
\]
\end{lemma}
Let's define orderings.
\begin{verbatim}
data
_
<=
_
: Dyn+ -> Dyn+ -> Prop where
bool : forall b : 2. inl b <= inl b
data
_
<=
_
: Dyn- -> Dyn- -> Prop where
err-ord : BinRel a -> BinRel (a + 1)
err-ord
_
<=
_
(inr *) y = T
err-ord
_
<=
_
(inl x) (inl y) = x <= y
err-ord
_
<=
_
_
_
=
_
|
_
laterr-ord< BinRel a -> BinRel (L (a + 1))
laterr-ord<
_
<=
_
(done (inr *))
_
= T
laterr-ord<
_
<=
_
(done (inl *))
_
= T
laterr-ord> BinRel a -> BinRel (L (a + 1))
err : Dyn-
err = mu (
\e
. ((inl (inl *)),
\x
. e))
\end{verbatim}
Let's define
\end{document}
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