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
c61a9523
Commit
c61a9523
authored
1 year ago
by
Eric Giovannini
Browse files
Options
Downloads
Patches
Plain Diff
begin section on concrete model
parent
e4c07041
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
paper-new/concrete-model.tex
+226
-0
226 additions, 0 deletions
paper-new/concrete-model.tex
paper-new/paper.tex
+2
-1
2 additions, 1 deletion
paper-new/paper.tex
with
228 additions
and
1 deletion
paper-new/concrete-model.tex
0 → 100644
+
226
−
0
View file @
c61a9523
\section
{
Constructing a Concrete Model
}
In this section, we build a concrete extensional model of gradual typing.
We begin by defining a step-1 intensional model, and then
apply the abstract constructions outlined in the previous section
to obtain an extensional model.
We begin with some definitions. These concepts were first introduced in the section
on the term semantics (Section
\ref
{
sec:domain-theory
}
), but for completeness we repeat them here.
% for ease of reference when instantiating the definition of step-1 model.
\begin{definition}
A
\textbf
{
predomain
}
$
A
$
consists of a set
$
A
$
along with two relations:
\begin{itemize}
\item
A partial order
$
\le
_
A
$
.
\item
A reflexive, symmetric ``bisimilarity'' relation
$
\bisim
_
A
$
.
\end{itemize}
\end{definition}
% TODO: later of a predomain
Given a predomain
$
A
$
, we can form the predomain
$
\later
A
$
.
The underlying set is
$
\later
|A|
$
and the relation is defined in the obvious way,
i.e.,
$
\tilde
{
x
}
\le
_{
\later
A
}
\tilde
{
x'
}$
iff
$
\later
_
t
(
\tilde
{
x
}_
t
\le
_
A
\tilde
{
x'
}_
t
)
$
.
Morphisms of predomains are functions between the underlying sets that preserve the ordering
and the bisimilarity relation. More formally:
%
\begin{definition}
Let
$
A
$
and
$
A'
$
be predomains.
A morphism
$
f : A
\to
A'
$
is a function between the underlying sets such that for all
$
x, x'
$
,
if
$
x
\le
_
A x'
$
, then
$
f
(
x
)
\le
f
(
x'
)
$
, and if
$
x
\bisim
_
A x'
$
, then
$
f
(
x
)
\bisim
_{
A'
}
f
(
x'
)
$
.
\end{definition}
\begin{definition}
An
\textbf
{
error domain
}
$
B
$
consists of a predomain
$
B
$
along with the following data:
\begin{itemize}
\item
A distinguished ``error" element
$
\mho
_
B
\in
B
$
\item
A morphism of predomains
$
\theta
_
B
\colon
\later
B
\to
B
$
\end{itemize}
\end{definition}
Morphisms of error domains are morphisms of the underlying predomains that preserve the
algebraic structure. More formally:
%
\begin{definition}
Let
$
B
$
and
$
B'
$
be error domains.
A morphism
$
\phi
: B
\wand
B'
$
is a morphism between the underlying predomains such that:
\begin{enumerate}
\item
$
\phi
(
\mho
_
B
)
=
\mho
_{
B'
}$
\item
$
\phi
(
\theta
_
B
(
\tilde
{
x
}
))
=
\theta
_{
B'
}
(
\lambda
t.
\phi
(
\tilde
{
x
}_
t
))
$
\end{enumerate}
\end{definition}
We define a (monotone) relation on predomains
$
A
$
and
$
A'
$
to be a relation on the
underlying sets that is downward-closed under
$
\le
_
A
$
and upward-closed under
$
\le
_{
A'
}$
.
More formally:
\begin{definition}
Let
$
A
$
and
$
A'
$
be predomains. A
\emph
{
predomain relation
}
between
$
A
$
and
$
A'
$
is a relation
$
R
$
between the underlying sets such that:
\begin{enumerate}
\item
(Downward closure): For all
$
x
_
1
, x
_
2
\in
A
$
and
$
y
\in
A'
$
,
if
$
x
_
1
\le
_
A x
_
2
$
and
$
x
_
2
\mathbin
{
R
}
y
$
, then
$
x
_
1
\mathbin
{
R
}
y
$
.
\item
(Upward closure): For all
$
x
\in
A
$
and
$
y
_
1
, y
_
2
\in
A'
$
,
if
$
x
\mathbin
{
R
}
y
_
1
$
and
$
y
_
1
\le
_{
A'
}
y
_
2
$
, then
$
x
\mathbin
{
R
}
y
_
2
$
.
\end{enumerate}
\end{definition}
Composition of relations on predomains is the usual relational composition.
Similarly, we define a (monotone) relation on error domains to be a relation on the
underlying predomains that respects error and preserves
$
\theta
$
.
%
\begin{definition}
Let
$
B
$
and
$
B'
$
be error domains. An
\emph
{
error domain relation
}
between
$
B
$
and
$
B'
$
is a relation
$
R
$
between the underlying predomains such that
\begin{enumerate}
\item
(Respects error): For all
$
y
\in
B'
$
, we have
$
\mho
_
B
\mathbin
{
R
}
y
$
.
\item
(Preserves
$
\theta
$
): For all
$
\tilde
{
x
}$
in
$
\later
B
$
and
$
\tilde
{
y
}
\in
\later
B'
$
,
if
\[
\later
_
t
(
\tilde
{
x
}_
t
\mathbin
{
R
}
\tilde
{
y
}_
t
)
,
\]
then
\[
\theta
_
B
(
\tilde
{
x
}
)
\mathbin
{
R
}
\theta
_{
B'
}
(
\tilde
{
y
}
)
.
\]
\end{enumerate}
\end{definition}
We define composition of error domain relations
$
R
$
on
$
B
_
1
$
and
$
B
_
2
$
and
$
S
$
on
$
B
_
2
$
and
$
B
_
3
$
to be the least relation containing
$
R
$
and
$
S
$
that respects
error and preserves
$
\theta
$
.
Specifically, it is defined inductively by the following rules:
\begin{mathpar}
\inferrule*
[right = Comp]
{
b
_
1
\mathbin
{
R
}
b
_
2
\and
b
_
2
\mathbin
{
S
}
b
_
3
}
{
b
_
1
\mathbin
{
R
\relcomp
S
}
b
_
3
}
\inferrule*
[right = PresErr]
{
}
{
\mho
_{
B
_
1
}
\mathbin
{
R
\relcomp
S
}
b
_
3
}
\inferrule*
[right = PresTheta]
{
\later
_
t(
\tilde
{
b
_
1
}
\mathbin
{
R
\relcomp
S
}
\tilde
{
b
_
3
}
)
}
{
\theta
_{
B
_
1
}
(
\tilde
{
b
_
1
}
)
\mathbin
{
R
\relcomp
S
}
\theta
_{
B
_
3
}
(
\tilde
{
b
_
3
}
)
}
\end{mathpar}
% We note that this composition has the following universal property.
We now describe the ``commuting squares".
Suppose we are given predomains
$
A
_
i, A
_
o, A
_
i'
$
, and
$
A
_
o'
$
,
relations
$
R
_
i
$
and
$
R
_
o
$
, and morphisms
$
f, f'
$
as shown below.
% https://q.uiver.app/#q=WzAsNCxbMCwwLCJBX2kiXSxbMSwwLCJBX2knIl0sWzAsMSwiQV9vIl0sWzEsMSwiQV9vJyJdLFswLDIsImYiLDJdLFsxLDMsImYnIl0sWzAsMSwiUl9pIiwwLHsic3R5bGUiOnsiYm9keSI6eyJuYW1lIjoiYmFycmVkIn0sImhlYWQiOnsibmFtZSI6Im5vbmUifX19XSxbMiwzLCJSX28iLDIseyJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJiYXJyZWQifSwiaGVhZCI6eyJuYW1lIjoibm9uZSJ9fX1dLFs0LDUsIlxcbHRkeW4iLDEseyJzaG9ydGVuIjp7InNvdXJjZSI6MjAsInRhcmdldCI6MjB9LCJzdHlsZSI6eyJib2R5Ijp7Im5hbWUiOiJub25lIn0sImhlYWQiOnsibmFtZSI6Im5vbmUifX19XV0=
\[
\begin
{
tikzcd
}
[
ampersand replacement
=
\&
]
{
A
_
i
}
\&
{
A
_
i'
}
\\
{
A
_
o
}
\&
{
A
_
o'
}
\arrow
[
""
{
name
=
0
, anchor
=
center, inner sep
=
0
}
, "f"', from
=
1
-
1
, to
=
2
-
1
]
\arrow
[
""
{
name
=
1
, anchor
=
center, inner sep
=
0
}
, "
{
f'
}
", from
=
1
-
2
, to
=
2
-
2
]
\arrow
[
"
{
R
_
i
}
", "
\shortmid
"
{
marking
}
, no head, from
=
1
-
1
, to
=
1
-
2
]
\arrow
[
"
{
R
_
o
}
"', "
\shortmid
"
{
marking
}
, no head, from
=
2
-
1
, to
=
2
-
2
]
\arrow
[
"
\ltdyn
"
{
description
}
, draw
=
none, from
=
0
, to
=
1
]
\end
{
tikzcd
}\]
We say that the above square commutes, written
$
f
\le
f'
$
, if for all
$
x
\in
A
_
i
$
and
$
x'
\in
A
_
i'
$
with
$
x
\mathbin
{
R
_
i
}
x'
$
, we have
$
f
(
x
)
\mathbin
{
R
_
o
}
f'
(
x'
)
$
.
We make the analogous definition for error domains.
% Lift monad
The guarded lift monad
$
\li
$
takes a predomain
$
A
$
to the error domain
$
\li
A
$
;
the precise definition is given in Section
\ref
{
sec:lift-monad
}
.
The partial order
$
\le
_{
\li
A
}$
is the lock-step error ordering defined in Section
\ref
{
sec:lock-step
}
, and the bisimilarity relation
$
\bisim
_{
\li
A
}$
is the weak bisimilarity
relation defined in Section
\ref
{
sec:weak-bisimilarity
}
.
We define the action of
$
\li
$
on a relation
$
R
$
between
$
A
$
and
$
A'
$
to be the
``heterogeneous" version of the lock-step error lifting of
$
R
$
(see Section
\ref
{
sec:lift-monad
}
).
% TODO action of \li on commuting squares
There is a functor
$
U
$
from error domains to predomains that on objects simply takes the
underlying predomain, and on morphisms takes the underlying morphism of predomains.
%
% TODO check this
One can verify that there is a free-forgetful adjunction between the functors
$
\li
$
and
$
U
$
;
this holds because
$
\li
A
$
is the initial/free error- and later-algebra on the predomain
$
A
$
,
i.e., error domain morphisms from
$
\li
A
$
to
$
B
$
are in one-to-one correspondence with
predomain morphisms from
$
A
$
to
$
UB
$
.
% internal hom for predomains and error domains
Given predomains
$
A
$
and
$
A'
$
, we can form the predomain of
predomain morphisms from
$
A
$
to
$
A'
$
, denoted
$
A
\To
A'
$
.
\begin{itemize}
% Should we give the definition involving x and x'?
\item
The ordering is defined by
$
f
\le
_{
A
\To
A'
}
f'
$
iff for all
$
x
\in
A
$
, we have
$
f
(
x
)
\le
_{
A'
}
f'
(
x
)
$
.
\item
The bisimilarity relation is defined by
$
f
\bisim
_{
A
\To
A'
}
f'
$
iff
for all
$
x, x'
\in
A
$
with
$
x
\bisim
_{
A
}
x'
$
, we have
$
f
(
x
)
\bisim
_{
A'
}
f'
(
x'
)
$
.
\end{itemize}
Given a predomain
$
A
$
and error domain
$
B
$
, we define
$
A
\arr
B :
=
A
\To
UB
$
.
We note that
$
A
\arr
B
$
carries a natural error domain structure
(in the below, the lambda is a meta-theoretic notation):
\begin{itemize}
\item
The error is given by
$
\lambda
x .
\mho
_
B
$
\item
The
$
\theta
$
operation is defined by
\[
\theta
_{
A
\arr
B
}
(
\tilde
{
f
}
)
=
\lambda
x .
\theta
_
B
(
\lambda
t .
\tilde
{
f
}_
t
(
x
))
.
\]
\end{itemize}
It is easily verified that
$
A
\arr
B
$
is an exponential of
$
UB
$
by
$
A
$
in the category of predomains and their morphisms.
Lastly, given a relation of predomains
$
R
$
between
$
A
$
and
$
A'
$
, and a relation
of error domains
$
S
$
between
$
B
$
and
$
B'
$
, we can form a relation
$
R
\arr
S
$
between
$
A
\arr
B
$
and
$
A'
\arr
B'
$
in the obvious way, i.e.,
$
f
\in
A
\arr
B
$
is related to
$
g
\in
A'
\arr
B'
$
iff for all
$
x
\in
A
$
and
$
x'
\in
A'
$
with
$
x
\mathrel
{
R
}
x'
$
, we have
$
f
(
x
)
\mathrel
{
S
}
g
(
x'
)
$
.
With all of the above data, we can form a step-1 intensional model of gradual typing
(See Definition
\ref
{
def:step-1-model
}
).
\subsection
{
The Dynamic Type
}
% dynamic type
The underlying set of the dynamic type will be defined using guarded recursion as the
solution to the equation
\[
D
\cong
\mathbb
{
N
}
+
\later
(
D
\to
\li
D
)
.
\]
The perturbation monoid for
$
D
$
is defined inductively as the free monoid
$
M
$
equipped
with an operation
$
\To
: M
\times
M
\to
M
$
, i.e., we take the set defined inductively by
\begin{mathpar}
\inferrule*
[]
{}
{
e
\in
M
}
\inferrule*
[]
{
p
\in
M
\and
p'
\in
M
}
{
p
\odot
p'
\in
M
}
\inferrule*
[]
{
p
\in
M
\and
p'
\in
M
}
{
p
\To
p'
\in
M
}
\end{mathpar}
and quotient by the necessary monoid equations.
% perturbations and quasi-representability
\subsection
{
Obtaining an Extensional Model
}
Now that we have defined an intensional model, we can apply
the abstract construction introduced in Section
\ref
{
sec:extensional-model-construction
}
.
Doing so, we obtain an extensional model of gradual typing.
This diff is collapsed.
Click to expand it.
paper-new/paper.tex
+
2
−
1
View file @
c61a9523
...
...
@@ -141,7 +141,8 @@
\input
{
categorical-model
}
\input
{
denotational-model
}
%\input{denotational-model}
\input
{
concrete-model
}
% \section{Discussion}\label{sec:discussion}
...
...
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