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
d465e2a6
Commit
d465e2a6
authored
1 year ago
by
Eric Giovannini
Browse files
Options
Downloads
Patches
Plain Diff
updates to abstract categorical model section
parent
f2c182e2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
paper-new/categorical-model.tex
+122
-51
122 additions, 51 deletions
paper-new/categorical-model.tex
paper-new/defs.tex
+22
-1
22 additions, 1 deletion
paper-new/defs.tex
paper-new/paper.tex
+3
-3
3 additions, 3 deletions
paper-new/paper.tex
with
147 additions
and
55 deletions
paper-new/categorical-model.tex
+
122
−
51
View file @
d465e2a6
...
...
@@ -319,7 +319,7 @@ In summary, an extensional model consists of:
\item
The CBPV connectives
$
U,F,
\times
,
\to
$
are all
\emph
{
covariant
}
functorial on relations
\begin{itemize}
\item
$
U
(
dd'
)
=
U
(
d
)
U
(
d'
)
$
\item
$
F
(
cc'
'
)
=
F
(
c
)
F
(
c'
)
$
\item
$
F
(
cc'
)
=
F
(
c
)
F
(
c'
)
$
\item
$
(
cc'
)
\to
(
dd'
)
=
(
c
\to
d
)(
c'
\to
d'
)
$
\item
$
(
c
_
1
c
_
1
'
)
\times
(
c
_
2
c
_
2
'
)
=
(
c
_
1
\times
c
_
2
)(
c
_
1
'
\times
c
_
2
'
)
$
\end{itemize}
...
...
@@ -379,6 +379,7 @@ For the sake of ease of reference, we recap the definition of a step-0 model:
% $\mathcal E_e$, and $\mathcal E_{sq}$.
% But we now have horizontal composition of squares as well.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection
{
Bisimilarity
}
\label
{
sec:abstract-model-bisimilarity
}
...
...
@@ -435,6 +436,8 @@ with the additional categories and functors for bisimiarity described above, as
the existence of a distinguised computation morphism
$
\delta
_
A
^
*
\bisim
\id
_{
FA
}$
for each
$
A
$
.
\end{definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection
{
Perturbations
}
\label
{
sec:abstract-model-perturbations
}
A second consequence of working intensionally is that the squares in the representable
...
...
@@ -443,22 +446,31 @@ keep the function morphisms on each side in lock-step. Intuitively, the perturba
have no effect other than to cause the function to which they are applied to ``wait''
in a specific manner.
We formalize this notion by requiring that for each object
$
A
$
in
$
\vf
$
,
there is a monoid of
\emph
{
perturbations
}
$
P
^
V
_
A
$
and a monoid homomorphism
$
\ptbv
_
A :
\pv
_
A
\to
\vf
(
A,A
)
$
.
Similarly, for each
$
B :
\ef
$
there is a monoid
$
P
^
C
_
B
$
and a
homomorphism
$
\ptbe
_
B :
\pe
_
B
\to
\ef
(
B,B
)
$
.
If
$
\delta
\in
P
^
V
_
A
$
, we will sometimes omit the homomorphism
$
\ptbv
_
A
$
and simply write
$
\delta
$
to refer to the morphism
$
\ptbv
_
A
(
\delta
)
\in
\vf
(
A,A
)
$
, and likewise
for computation perturbations. The context will make clear whether we are referring
to an element of the perturbation monoid or the corresponding morphism.
there is a monoid of
\emph
{
value perturbations
}
$
\pv
_
A
$
that is a submonoid of
$
\{
f
\in
\vf
(
A,A
)
\mid
f
\bisim
\id
\}
$
.
Similarly, for each
$
B :
\ef
$
there is a monoid
$
\pe
_
B
$
of
\emph
{
computation perturbations
}
that is a submonoid of
$
\{
g
\in
\ef
(
B,B
)
\mid
g
\bisim
\id
\}
$
.
% If $\delta \in P^V_A$, we will sometimes omit the homomorphism $\ptbv_A$ and simply write
% $\delta$ to refer to the morphism $\ptbv_A(\delta) \in \vf(A,A)$, and likewise
% for computation perturbations. The context will make clear whether we are referring
% to an element of the perturbation monoid or the corresponding morphism.
Note that we require that all perturbations be weakly bisimilar to the identity morphism,
capturing the notion that they have no effect other than to delay.
% We observe that
% the set of endomorphisms $f$ such that $f$ is weakly bisimilar to the identity
% forms a monoid under composition.
We require that
$
\delta
_
A
^
*
\in
\pe
_{
FA
}$
for all
$
A
$
, where
$
\delta
_
A
^
*
$
is the distinguished
morphism that is required to be present in every hom-set
$
\ef
(
FA, FA
)
$
per the definition
of a step-1 model.
The perturbations must be preserved by
$
\times
$
,
$
\arr
$
,
$
U
$
, and
$
F
$
.
The perturbations must be preserved by
$
\times
$
$
\timesk
$
,
$
\arr
$
,
$
\tok
$
,
$
U
$
,
$
\Uk
$
,
$
F
$
, and
$
\Fk
$
.
For reasons that will be made clear in the next section, perturbations must also satisfy a property that we call the ``push-pull'' property,
For reasons that will be made clear in the next section, perturbations must also satisfy
a property that we call the ``push-pull'' property,
which is formulated as follows. Let
$
c : A
\rel
A'
$
.
Given a perturbation
$
\delta
\in
\pv
_
A
$
, there is a corresponding perturbation
$
\push
_
c
(
\delta
)
\in
\pv
_{
A'
}$
.
% making the following square commute:
...
...
@@ -492,25 +504,27 @@ Moreover, push-pull states that the following squares must commute:
The analogous property should also hold for computation relations and perturbations.
Lastly, we require that all perturbations be weakly bisimilar to the identity morphism,
capturing the notion that they have no effect other than to delay. We observe that
the set of endomorphisms
$
f
$
such that
$
f
$
is weakly bisimilar to the identity
forms a monoid under composition.
This is summarized below:
\begin{definition}
\label
{
def:step-2-model
}
A
\emph
{
step-2
}
model of intensional gradual typing consists of all the data of a step-1 model plus:
\begin{enumerate}
\item
$
\pv
_
A
$
and a monoid homomorphism
\[
\ptbv
_
A :
\pv
_
A
\to
\{
f
\in
\vf
(
A,A
)
\mid
f
\bisim
\id
\}
\]
\item
$
\pe
_
B
$
and a monoid homomorphism
\[
\ptbe
_
B :
\pe
_
B
\to
\{
g
\in
\ef
(
B,B
)
\mid
g
\bisim
\id
\}
\]
\item
The functors
$
\times
$
,
$
\arr
$
,
$
U
$
, and
$
F
$
preserve perturbations.
\item
For each value type
$
A
$
, there is a monoid
$
\pv
_
A
$
that is a submonoid of
$
\{
f
\in
\vf
(
A,A
)
\mid
f
\bisim
\id
\}
$
.
\item
For each computation type
$
B
$
, there is a monoid
$
\pe
_
B
$
that is a submonoid of
$
\{
g
\in
\ef
(
B,B
)
\mid
g
\bisim
\id
\}
$
.
\item
For all
$
A
$
, the distinguished endomorphism
$
\delta
_
A
^
*
$
is in
$
\pe
_{
FA
}$
.
% \item $\pv_A$ and a monoid homomorphism
% \[ \ptbv_A : \pv_A \to \{ f \in \vf(A,A) \mid f \bisim \id \} \]
% \item $\pe_B$ and a monoid homomorphism
% \[ \ptbe_B : \pe_B \to \{ g \in \ef(B,B) \mid g \bisim \id \} \]
\item
The functors
$
\times
,
\timesk
$
,
$
\arr
,
\tok
$
,
$
U,
\Uk
$
,
$
F,
\Fk
$
preserve perturbations.
\item
The push-pull property holds for all
$
c : A
\rel
A'
$
and all
$
d : B
\rel
B'
$
.
\end{enumerate}
\end{definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection
{
Behavior of Casts
}
...
...
@@ -524,6 +538,8 @@ but as mentioned above, now there
are perturbations involved in order to keep both sides ``in lock-step".
The precise definitions are as follows.
% TODO: Give these squares names
\begin{definition}
\label
{
def:quasi-left-representable
}
Let
$
c : A
\rel
A'
$
be a value relation. We say that
$
c
$
is
\emph
{
quasi-left-representable by
}
$
f
\in
\vf
(
A, A'
)
$
if there are perturbations
$
\delta
_
c
^{
l,e
}
\in
\pv
_
A
$
and
...
...
@@ -552,6 +568,9 @@ $\delta_c^{r,e} \in \pv_{A'}$ such that the following squares commute:
\end{tikzcd}
\end{tabular}
\end{center}
We call the first square
$
\upl
$
and the second square
$
\upr
$
.
\end{definition}
\begin{definition}
\label
{
def:quasi-right-representable
}
...
...
@@ -583,6 +602,9 @@ $\delta_d^{r,p} \in \pe_{B'}$ such that the following squares commute:
\end{tikzcd}
\end{tabular}
\end{center}
We call the first square
$
\dnr
$
and the second square
$
\dnl
$
.
\end{definition}
Besides the perturbations, one other difference between the extensional
...
...
@@ -594,27 +616,80 @@ is required to derive the versions of the rules that build in composition
from the versions that do not.
In the intensional setting, we do have horizontal composition of squares,
so we can take the simpler versions as primitive and derive the ones
involving composition (though we must be careful about the perturbations
when doing so!).
involving composition.
Lastly, we require that the model satisfy a weak version of functoriality for
the CBPV connectives
$
U,F,
\times
,
\to
$
.
First, we will need a definition:
\begin{definition}
Let
$
c, c' : A
\rel
A'
$
. We say that
$
c
$
and
$
c'
$
are
\emph
{
quasi-order-equivalent
}
,
written
$
c
\qordeq
c'
$
, if there exist perturbations
$
\delta
^
l
_
1
,
\delta
^
l
_
2
\in
\pv
_
A
$
and
$
\delta
^
r
_
1
,
\delta
^
r
_
2
\in
\pv
_{
A'
}$
such that the following two squares exist:
\begin{center}
\begin{tabular}
{
m
{
9em
}
m
{
9em
}
}
\begin{tikzcd}
[ampersand replacement=
\&
]
A
\&
{
A'
}
\\
A
\&
{
A'
}
\arrow
["\delta^l_1"', from=1-1, to=2-1]
\arrow
["\delta^r_1", from=1-2, to=2-2]
\arrow
["c", "\shortmid"{marking}, no head, from=1-1, to=1-2]
\arrow
["c'"', "\shortmid"{marking}, no head, from=2-1, to=2-2]
\end{tikzcd}
&
\begin{tikzcd}
[ampersand replacement=
\&
]
A
\&
{
A'
}
\\
A
\&
{
A'
}
\arrow
["\delta^l_2"', from=1-1, to=2-1]
\arrow
["\delta^r_2", from=1-2, to=2-2]
\arrow
["c'", "\shortmid"{marking}, no head, from=1-1, to=1-2]
\arrow
["c"', "\shortmid"{marking}, no head, from=2-1, to=2-2]
\end{tikzcd}
\end{tabular}
\end{center}
We make the analogous definition for computation relations
$
d, d' : B
\rel
B'
$
.
\end{definition}
We require that the CBPV connectives
$
U,F,
\times
,
\to
$
are
\emph
{
quasi-functorial
}
on relations,
which we specify as follows:
\begin{itemize}
\item
$
U
(
d
\comp
d'
)
\qordeq
U
(
d
)
U
(
d'
)
$
\item
$
F
(
c
\comp
c''
)
\qordeq
F
(
c
)
F
(
c'
)
$
\item
$
(
cc'
)
\to
(
dd'
)
\qordeq
(
c
\to
d
)(
c'
\to
d'
)
$
\item
$
(
c
_
1
c
_
1
'
)
\times
(
c
_
2
c
_
2
'
)
\qordeq
(
c
_
1
\times
c
_
2
)(
c
_
1
'
\times
c
_
2
'
)
$
\end{itemize}
We summarize the requirements of a step-3 model below:
\begin{definition}
\label
{
def:step-3-model
}
A
\emph
{
step-3 intensional model
}
consists
of all the data of a step-2 intensional model,
wit
h th
e following
additional
data
:
of all the data of a step-2 intensional model,
suc
h th
at
additional
ly
:
\begin{enumerate}
\item
F
unctors
$
\upf
:
\ve
\to
\vf
$
and
$
\dnf
:
\ee
^{
op
}
\to
\ef
$
% TODO: image is thin?
\item
There are f
unctors
$
\upf
:
\ve
\to
\vf
$
and
$
\dnf
:
\ee
^{
op
}
\to
\ef
$
% TODO: image is thin?
\item
Every value edge
$
c : A
\rel
A'
$
is quasi-left-representable by
$
\upf
(
c
)
$
and
every computation edge
$
d : B
\rel
B'
$
is quasi-right-representable by
$
\dnf
(
d
)
$
.
\item
The CBPV connectives
$
U,F,
\times
,
\to
$
are quasi-functorial on relations.
\end{enumerate}
\end{definition}
% Want: U d \comp U d' = U(d \comp d')
% F c \comp F c' = F(c \comp c')
% Add requirement: Either the model is functorial with respect to up/downcasts or with repsect to relations
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection
{
The Dynamic Type
}
Now we can discuss what it means for an intensional model to model the dynamic type.
This applies to any of the above abstract model definitions, i.e., steps 0-3.
%
This applies to any of the above abstract model definitions, i.e., steps 0-3.
\begin{definition}
\label
{
def:step-4-model
}
A
\emph
{
step-
$
i
$
intensional model with dyn
}
is a step-
$
i
$
model
$
\mathcal
M
$
such that:
% A \emph{step-$i$ intensional model with dyn} is a step-$i$ model $\mathcal M$ such that:
A step-4 intensional model is a step-3 intensional model
$
\mathcal
M
$
such that:
%a distinguished value object $D \in \ob(\vf)$ such that:
%
\begin{enumerate}
...
...
@@ -622,10 +697,13 @@ This applies to any of the above abstract model definitions, i.e., steps 0-3.
\item
For each value type
$
A
$
, there is a value relation
$
\text
{
inj
}_
A : A
\rel
D
$
.
\item
If
$
c : A
\rel
A'
$
, then
$
\text
{
inj
}_{
A
}
=
c
\comp
\text
{
inj
}_{
A'
}$
.
%
\item
\eric{Do we need this?}
If $c : A \rel A'$, then $\text{inj}_{A} = c \comp \text{inj}_{A'}$.
\end{enumerate}
\end{definition}
% (By definition of a step-3 model, this relation satisfies the push-pull property and is
% quasi-left-representable.)
...
...
@@ -652,7 +730,7 @@ construction does not depend on the details of the previous ones.
\subsubsection
{
Adding Perturbations
}
Suppose we have a
\hyperref
[def:step-1-model]
{
step-1 intensional model
}
$
\mathcal
{
M
}$
with dyn
.
Suppose we have a
\hyperref
[def:step-1-model]
{
step-1 intensional model
}
$
\mathcal
{
M
}$
.
Recall that a step-1 intensional model consists of a step-0 model (i.e., a
category internal to the category of CBPV models), along with the necessary
categories and functors for bisimilarity as discussed in Section
...
...
@@ -660,22 +738,11 @@ categories and functors for bisimilarity as discussed in Section
Further, recall that a
\hyperref
[def:step-2-model]
{
step-2 model
}
has everything
a step-1 model has, with the addition of perturbation monoids
$
\pv
_
A
$
for all
$
A
$
and
$
\pe
_
B
$
for all
$
B
$
.
These perturbations must be interpretable via homomorphisms
$
\ptb
_
A
$
and
$
\ptb
_
B
$
as endomorphisms bisimilar to the identity,
and moreover, the push-pull property must hold for all
Moreover, the push-pull property must hold for all
value relations
$
c
$
and all computation relations
$
d
$
.
% TODO do we really need all of this data?
What ``external" data do we need to define such a model?
Suppose we are given, for each value type
$
A
$
, a monoid
$
\pv
_
A
$
with homomorphism
$
\ptb
_
A
$
into the endomorphisms on
$
A
$
bisimilar to the identity, and likewise, for
each computation type
$
B
$
, a monoid
$
\pv
_
B
$
and homomorphism
$
\ptb
_
B
$
.
Furthermore, suppose we are given, for each value type
$
A
$
, a distinguished endomorphism
$
\delta
_
A
\in
\ef
(
FA, FA
)
$
such that
$
\delta
_
A
\bisim
\id
_{
FA
}$
.
Finally, suppose that each value relation
$
c : A
\rel
A'
$
satisfies the push-pull property
and likewise for each computation relation
$
d : B
\rel
B'
$
.
Then we claim that from the above data, we can construct a step-2 intensional model.
We claim that from a step-1 model, we can construct a step-2 model.
% TODO give overview
For the proof, see Lemma
\ref
{
lem:step-1-model-to-step-2-model
}
in the Appendix.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
@@ -683,18 +750,19 @@ For the proof, see Lemma \ref{lem:step-1-model-to-step-2-model} in the Appendix.
\subsubsection
{
Adding Quasi-Representability
}
Now suppose we have a step-2 intensional model
$
\mathcal
{
M
}$
.
We will describe how to construct a
\hyperref
[def:step-3-model]
{
step-3 intensional model
}
$
\mathcal
{
M'
}$
.
We now describe the construction of a step-3 model
$
\mathcal
M'
$
.
We claim that we can construct a
\hyperref
[def:step-3-model]
{
step-3 intensional model
}
$
\mathcal
{
M'
}$
.
% TODO give overview
For the proof, see Lemma
\ref
{
lem:step-2-model-to-step-3-model
}
in the Appendix.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection
{
Defining an Extensional Model
}
\subsubsection
{
Defining an Extensional Model
}
\label
{
sec:extensional-model-definition
}
Finally, suppose
$
\mathcal
M
$
is a step-3 intensional model.
Finally, suppose
$
\mathcal
M
$
is a
\hyperref
[def:step-4-model]
{
step-4 intensional model
}
(i.e., a step-3 model with an interpretation of the dynamic type).
We now describe how to build an extensional model.
The idea is to define an extensional model whose squares are the ``bisimilarity-closure''
...
...
@@ -718,9 +786,12 @@ Using our existing notation, we say that $f \le_{c_o}^{c_i} g$ if there exist $f
We make the analogous construction for the computation squares.
Next, we check that the requirements of an extensional model are satisfied.
In particular, we need to verify the representability properties.
We define functors
$
\upf
$
and
$
\dnf
$
The proof that this indeed defines an extensional model is given in the Appendix
(see Section
\ref
{
sec:extensional-construction-appendix
}
).
% Next, we check that the requirements of an extensional model are satisfied.
% In particular, we need to verify the representability properties.
% We define functors $\upf$ and $\dnf$
...
...
This diff is collapsed.
Click to expand it.
paper-new/defs.tex
+
22
−
1
View file @
d465e2a6
...
...
@@ -228,4 +228,25 @@
\newcommand
{
\bind
}
[3]
{{
#1
}
<-
{
#2
}
\,
;
\,
{
#3
}}
\newcommand
{
\piv
}{
\Pi
^
\mathcal
{
V
}}
\newcommand
{
\pie
}{
\Pi
^
\mathcal
{
E
}}
\ No newline at end of file
\newcommand
{
\pie
}{
\Pi
^
\mathcal
{
E
}}
\newcommand
{
\upl
}{
\textsc
{
UpL
}}
\newcommand
{
\upr
}{
\textsc
{
UpR
}}
\newcommand
{
\dnl
}{
\textsc
{
DnL
}}
\newcommand
{
\dnr
}{
\textsc
{
DnR
}}
\newcommand
{
\delre
}{
\delta
^{
r,e
}}
\newcommand
{
\delle
}{
\delta
^{
l,e
}}
\newcommand
{
\delrp
}{
\delta
^{
r,p
}}
\newcommand
{
\dellp
}{
\delta
^{
l,p
}}
\newcommand
{
\qordeq
}{
\bisim
}
\newcommand
{
\inat
}{
\text
{
Inj
}_
\mathbb
{
N
}}
\newcommand
{
\itimes
}{
\text
{
Inj
}_
\times
}
\newcommand
{
\iarr
}{
\text
{
Inj
}_
\to
}
\newcommand
{
\tnat
}{
\text
{
nat
}}
\newcommand
{
\ttimes
}{
\text
{
times
}}
\newcommand
{
\tfun
}{
\text
{
fun
}}
This diff is collapsed.
Click to expand it.
paper-new/paper.tex
+
3
−
3
View file @
d465e2a6
...
...
@@ -67,7 +67,7 @@
with realistic languages featuring furthermore runtime allocation of
memory locations and dynamic type tags. Further, the desired
metatheoretic properties of gradually typed languages have become
increasingly sophisticated: validity of type
d
based equational
increasingly sophisticated: validity of type based equational
reasoning as well as the relational property known as the gradual
guarantee or graduality. Many recent works have tackled verifying
these properties, but the resulting mathematical developments are
...
...
@@ -135,8 +135,8 @@
\newif\ifdraft
\drafttrue
\renewcommand
{
\max
}
[1]
{
\ifdraft
{
\color
{
blue
}
[
{
\bf
Max
}
: #1]
}
\fi
}
\newcommand
{
\eric
}
[1]
{
\ifdraft
{
\color
{
orange
}
[
{
\bf
Steven
}
: #1]
}
\fi
}
\newcommand
{
\tingting
}
[1]
{
\ifdraft
{
\color
{
red
}
[
{
\bf
Pedro
}
: #1]
}
\fi
}
\newcommand
{
\eric
}
[1]
{
\ifdraft
{
\color
{
orange
}
[
{
\bf
Eric
}
: #1]
}
\fi
}
\newcommand
{
\tingting
}
[1]
{
\ifdraft
{
\color
{
red
}
[
{
\bf
Tingting
}
: #1]
}
\fi
}
\input
{
intro
}
...
...
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