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
757bfea7
Commit
757bfea7
authored
6 years ago
by
Max New
Browse files
Options
Downloads
Patches
Plain Diff
universal property for products
parent
27b7ba92
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
main.tex
+174
-3
174 additions, 3 deletions
main.tex
with
174 additions
and
3 deletions
main.tex
+
174
−
3
View file @
757bfea7
\documentclass
{
article
}
\usepackage
{
amsmath,amssymb
}
\usepackage
{
amsmath,amssymb
,amsthm
}
\usepackage
{
tikz-cd
}
\usepackage
{
mathpartir
}
\newtheorem
{
theorem
}{
Theorem
}
\newtheorem
{
corollary
}
[theorem]
{
Corollary
}
\newtheorem
{
definition
}{
Definition
}
\newcommand
{
\type
}{
\,\,\text
{
type
}}
\newcommand
{
\ctx
}{
\,\,\text
{
ctx
}}
\newcommand
{
\ltdyn
}{
\sqsubseteq
}
\newcommand
{
\gtdyn
}{
\sqsupseteq
}
\newcommand
{
\equidyn
}{
\mathrel
{
\gtdyn\ltdyn
}}
\newcommand
{
\ltdynv
}{
\mathrel
{
\sqsubseteq
_
V
}}
\newcommand
{
\ltdynt
}{
\mathrel
{
\sqsubseteq
_
T
}}
\newcommand
{
\upcast
}
[2]
{
\langle
#2
\leftarrowtail
#1
\rangle
}
\newcommand
{
\dncast
}
[2]
{
\langle
#1
\twoheadleftarrow
#2
\rangle
}
\newcommand
{
\Set
}{
\text
{
Set
}}
\newcommand
{
\relto
}{
\to
}
\newcommand
{
\M
}{
\mathcal
{
M
}}
...
...
@@ -76,11 +82,11 @@
\inferrule
{
x:A
\in
\Gamma
}
{
\Gamma
\vdash
^
v x : A
}
\inferrule
{
\gamma
:
\p
i
_{
x:A
\in
\Gamma
}
\Delta
\vdash
\gamma
(x) : A
\and
\inferrule
{
\gamma
:
\p
rod
_{
x:A
\in
\Gamma
}
\Delta
\vdash
\gamma
(x) : A
\and
\Gamma
\vdash
v : B
}{
\Delta
\vdash
v[
\gamma
] : B
}
\inferrule
{
\gamma
:
\p
i
_{
x:A
\in
\Gamma
}
\Delta
\vdash
\gamma
(x) : A
\and
\inferrule
{
\gamma
:
\p
rod
_{
x:A
\in
\Gamma
}
\Delta
\vdash
\gamma
(x) : A
\and
\Gamma
\vdash
t : B
}{
\Delta
\vdash
t[
\gamma
] : B
}
...
...
@@ -101,6 +107,171 @@
\caption
{
GTTv Judgmental Term, Value Rules
}
\end{figure}
\begin{mathpar}
\inferrule
{}
{
\Phi
, x
\ltdyn
x' : A
\ltdyn
A'
\vdash
\ret
x
\ltdyn
\ret
x' : A
\ltdyn
A'
}
\inferrule
{
\Phi
\vdash
t
\ltdyn
t' : A
\ltdyn
A'
\and
\Phi
, x
\ltdyn
x' : A
\ltdyn
A'
\vdash
u
\ltdyn
u' : C
\ltdyn
C'
}
{
\Phi
\vdash
\lett
x = t; u
\ltdyn
\lett
x' = t'; u' : C
\ltdyn
C'
}
\end{mathpar}
\begin{mathpar}
\inferrule
{
\Gamma
\vdash
^
v v : A
\and
A
\ltdyn
A'
}
{
\Gamma
\vdash
^
T
\upcast
{
A
}{
A'
}
v : A'
}
\inferrule
{
\Gamma
\vdash
^
v v : A'
\and
A
\ltdyn
A'
}
{
\Gamma
\vdash
^
T
\dncast
{
A
}{
A'
}
v : A
}
\inferrule
{}
{
x
\ltdyn
x' : A
\ltdyn
A'
\vdash
\upcast
{
A
}{
A'
}
x
\ltdyn
\ret
x' : A'
}
\inferrule
{}
{
x : A
\vdash
\ret
x
\ltdyn
\upcast
{
A
}{
A'
}
x : A
\ltdyn
A'
}
\inferrule
{}
{
x
\ltdyn
x' : A
\ltdyn
A'
\vdash
\ret
x
\ltdyn
\dncast
{
A
}{
A'
}
x' : A'
}
\inferrule
{}
{
x' : A'
\vdash
\dncast
{
A
}{
A'
}
x'
\ltdyn
x' : A
\ltdyn
A'
}
\end{mathpar}
\begin{mathpar}
\inferrule
{
A
\type
\and
B
\type
}{
A
\times
B
\type
}
\inferrule
{
\Gamma
\vdash
v
_
1 : A
_
1
\and
\Gamma
\vdash
v
_
2 : A
_
2
}
{
\Gamma
\vdash
^{
V
}
(v
_
1, v
_
2) : A
_
1
\times
A
_
2
}
\inferrule
{
\Gamma
\vdash
t : A
_
1
\times
A
_
2
\and
\Gamma
, x
_
1 : A
_
1, x
_
2 : A
_
2
\vdash
u : C
}
{
\Gamma
\vdash
\lett
(x,x') = t; u : C
}
\inferrule
{}
{
x
\ltdyn
x' : A
\ltdyn
A', y
\ltdyn
y' : B
\ltdyn
B'
\vdash
\ret
(x,y)
\ltdyn
\ret
(x',y') : A
\times
B
\ltdyn
A'
\times
B'
}
\inferrule
{
\Phi
\vdash
t
\ltdyn
t' : A
\times
B
\ltdyn
A'
\times
B'
\and
\Phi
, x
\ltdyn
x' : A
\ltdyn
A', y
\ltdyn
y' : B
\ltdyn
B'
\vdash
u
\ltdyn
u' : C
\ltdyn
C'
}
{
\Phi
\vdash
\lett
(x,y) = t; u
\ltdyn
\lett
(x',y') = t'; u' : C
\ltdyn
C'
}
\inferrule
{}
{
\Gamma
\vdash
\lett
(x
_
1,x
_
2) = (v
_
1,v
_
2); t
\equidyn
t[v
_
1/x
_
1,v
_
2/x
_
2] : C
}
\inferrule
{}
{
\Gamma
\vdash
t
\equidyn
\lett
(x
_
1,x
_
2) = t;
\ret
(x
_
1,x
_
2) : A
_
1
\times
A
_
2
}
\end{mathpar}
\begin{theorem}
[Product Contract]
If
$
A
_
1
\ltdyn
A
_
1
'
$
and
$
A
_
2
\ltdyn
A
_
2
'
$
then
\begin{align*}
x' : A
_
1'
\times
A
_
2'
\vdash
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
x'
&
\equidyn\\
\lett
(x
_
1', x
_
2') = x';
\lett
y
_
1 =
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1';
\lett
y
_
2 =
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2';
\ret
(y
_
1,y
_
2)
&
\equidyn\\
\lett
(x
_
1', x
_
2') = x';
\lett
y
_
2 =
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2';
\lett
y
_
1 =
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1';
\ret
(y
_
1,y
_
2)
\\
\end{align*}
\end{theorem}
\begin{proof}
First, we show the direction that requires
$
\eta
$
expansion.
\begin{mathpar}
\inferrule
{}
{
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
x'
\ltdyn
\lett
(x
_
1', x
_
2') = x';
\lett
y
_
1 =
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1';
\lett
y
_
2 =
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2';
\ret
(y
_
1,y
_
2)
}
\end{mathpar}
By the Down-Left rule, it is sufficient to prove that under
$
x
\ltdyn
x' :
(
A
_
1
\times
A
_
2
)
\ltdyn
(
A
_
1
'
\times
A
_
2
'
)
$
,
\begin{mathpar}
{
x
\ltdyn
\lett
(x
_
1', x
_
2') = x';
\lett
y
_
1 =
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1';
\lett
y
_
2 =
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2';
\ret
(y
_
1,y
_
2)
}
\end{mathpar}
By the
$
\eta
$
rule for products and the let-rule for values,
$
x :
A
_
1
\times
A
_
2
$
can be expanded as follows:
\begin{align*}
x
&
\equidyn
\lett
(x
_
1,x
_
2) = x;
\ret
(x
_
1,x
_
2)
\\
&
\equidyn
\lett
(x
_
1,x
_
2) = x;
\lett
y
_
1 =
\ret
x
_
1;
\ret
(y
_
1,x
_
2)
\\
&
\equidyn
\lett
(x
_
1,x
_
2) = x;
\lett
y
_
1 =
\ret
x
_
1;
\lett
y
_
2 =
\ret
x
_
2;
\ret
(y
_
1,y
_
2)
\end{align*}
Now that we have the two sides with the same structre, we use the
congruence rules for product pattern matching and we have to use the
Down-Right rule twice:
\begin{mathpar}
x
_
1
\ltdyn
x
_
1' : A
_
1
\ltdyn
A
_
1'
\vdash
\ret
x
_
1
\ltdyn
\dncast
{
A
_
1
}{
A
_
1'
}{
x
_
1'
}
: A
_
1
x
_
2
\ltdyn
x
_
2' : A
_
2
\ltdyn
A
_
2'
\vdash
\ret
x
_
2
\ltdyn
\dncast
{
A
_
2
}{
A
_
2'
}{
x
_
2'
}
: A
_
2
\end{mathpar}
Next, we show the reverse inequality using
$
\eta
$
contraction
\begin{mathpar}
{
\lett
(x
_
1', x
_
2') = x';
\lett
y
_
1 =
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1';
\lett
y
_
2 =
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2';
\ret
(y
_
1,y
_
2)
\ltdyn
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
x'
}
\end{mathpar}
This time, we need to use congruence
\emph
{
first
}
, because the
downcast is on the right, we can't use the Down-Right rule unless
the left side is already at the less dynamic type.
So we rewrite the right side as
\begin{align*}
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
x'
&
\ltdyn
\lett
(x
_
1',x
_
2') = x';
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
(x
_
1',x
_
2')
\\
&
\ltdyn
\lett
(x
_
1',x
_
2') = x';
\lett
y
_
1' = x
_
1';
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
(x
_
1',x
_
2')
\\
&
\ltdyn
\lett
(x
_
1',x
_
2') = x';
\lett
y
_
1' = x
_
1';
\lett
y
_
2' = x
_
2';
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
(x
_
1',x
_
2')
\end{align*}
\end{proof}
Then the proof is again by the congruence rules, using Down-Left twice
and Down-Right once:
\begin{mathpar}
x
_
1' : A
_
1'
\vdash
\dncast
{
A
_
1
}{
A
_
1'
}
x
_
1'
\ltdyn
\ret
x
_
1'
x
_
2' : A
_
2'
\vdash
\dncast
{
A
_
2
}{
A
_
2'
}
x
_
2'
\ltdyn
\ret
x
_
2'
x
_
1
\ltdyn
x
_
1', x
_
2
\ltdyn
x
_
2'
\vdash
(x
_
1,x
_
2)
\ltdyn
\dncast
{
A
_
1
\times
A
_
2
}{
A
_
1'
\times
A
_
2'
}
(x
_
1',x
_
2')
\end{mathpar}
\begin{corollary}
[Projections commute]
For any
$
A
\ltdyn
A', B
\ltdyn
B'
$
and
$
\Gamma
, x:A, y : B
\vdash
t : C
$
,
\[
\lett
x
=
\dncast
{
A
}{
A'
}
x';
\lett
y
=
\dncast
B
{
B'
}
y'; t
\equidyn
\lett
y
=
\dncast
B
{
B'
}
y';
\lett
x
=
\dncast
{
A
}{
A'
}
x'; t
\]
\end{corollary}
\begin{proof}
By the previous theorem, both are equivalent to
\[
\lett
z
=
\dncast
{
A
\times
B
}{
A'
\times
B'
}
(
x',y'
)
;
\lett
(
x,y
)
=
z;
t
\]
\end{proof}
\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