Skip to content
Snippets Groups Projects
Commit 3c84c803 authored by Max New's avatar Max New
Browse files

fundamental property, generically over the pole

parent d503d981
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,7 @@
\newcommand{\ltdynv}{\mathrel{\sqsubseteq_V}}
\newcommand{\ltdynt}{\mathrel{\sqsubseteq_T}}
\newcommand{\ltlogty}[2]{\mathrel{\ltdyn^{#1}_{#2}}}
\newcommand{\logpole}{\mathrel{\lesssim^{log}_{\pole}}}
\newcommand{\pole}{\Bot}
\newcommand{\ipole}[1]{\mathrel{\pole^{#1}}}
\newcommand{\logty}[2]{\mathrel{\lesssim^{#1}_{#2,\pole}}}
......@@ -738,6 +739,7 @@ corecursive type.
\begin{figure}
\begin{mathpar}
S[\err] \stepzero \err
S[\caseofXthenYelseZ{\inl V}{x_1. M_1}{x_2. M_2}] \stepzero S[M_1[V/x_1]]\\
S[\caseofXthenYelseZ{\inr V}{x_1. M_1}{x_2. M_2}] \stepzero S[M_2[V/x_2]]\\
S[\pmpairWtoXYinZ{(V_1,V_2)}{x_1}{x_2}{M} \stepzero S[M[V_1/x_1,V_2/x_2]]]\\
......@@ -773,6 +775,10 @@ Next, we give the inequational theory for our CBPV language.
{}
{\Gamma,x : A,\Gamma' \vdash x \ltdyn x : A}
\inferrule
{}
{\Gamma \vdash \err \ltdyn \err : \u B}
\inferrule
{\Gamma \vdash V \ltdyn V' : A \and
\Gamma, x : A \vdash M \ltdyn M' : \u B
......@@ -780,8 +786,8 @@ Next, we give the inequational theory for our CBPV language.
{\Gamma \vdash \letXbeYinZ V x M \ltdyn \letXbeYinZ {V'} {x} {M'} : \u B}
\inferrule
{\Gamma \vdash V : 0}
{\Gamma \vdash \abort V : \u B}
{\Gamma \vdash V \ltdyn V' : 0}
{\Gamma \vdash \abort V \ltdyn \abort V' : \u B}
\inferrule
{\Gamma \vdash V \ltdyn V' : A_1}
......@@ -849,17 +855,17 @@ Next, we give the inequational theory for our CBPV language.
{\Gamma \vdash M\,V \ltdyn M'\,V' : \u B }
\inferrule
{\Gamma \vdash M_1 \ltdyn M_1' : A_1\and
\Gamma \vdash M_2 \ltdyn M_2' : A_2}
{\Gamma \vdash \pair {M_1} {M_2} \ltdyn \pair {M_1'} {M_2'} : A_1 \with A_2}
{\Gamma \vdash M_1 \ltdyn M_1' : \u B_1\and
\Gamma \vdash M_2 \ltdyn M_2' : \u B_2}
{\Gamma \vdash \pair {M_1} {M_2} \ltdyn \pair {M_1'} {M_2'} : \u B_1 \with \u B_2}
\inferrule
{\Gamma \vdash M \ltdyn M' : A_1 \with A_2}
{\Gamma \vdash \pi M \ltdyn \pi M' : A_1}
{\Gamma \vdash M \ltdyn M' : \u B_1 \with \u B_2}
{\Gamma \vdash \pi M \ltdyn \pi M' : \u B_1}
\inferrule
{\Gamma \vdash M \ltdyn M' : A_1 \with A_2}
{\Gamma \vdash \pi' M \ltdyn \pi' M' : A_2}
{\Gamma \vdash M \ltdyn M' : \u B_1 \with \u B_2}
{\Gamma \vdash \pi' M \ltdyn \pi' M' : \u B_2}
\inferrule
{\Gamma \vdash M \ltdyn M' : \u B[{\nu \u Y. \u B}/\u Y]}
......@@ -935,6 +941,7 @@ Next, we give the inequational theory for our CBPV language.
closed programs of type $\u F (1 + 1)$ satisfying
\begin{enumerate}
\item Downward closure: If $M_1 \ipole i M_2$ and $j \leq i$ then $M_1 \ipole j M_2$.
\item Triviality at $0$: For any appropriately typed terms, $M_1 \ipole 0 M_2$
\item Step-indexed anti-reduction: If $M_1 \stepsin j M_1'$ and $M_2
\step M_2'$ and $M_1' \ipole i M_2'$ then $M_1' \ipole {i+j} M_2'$.
\item Step-indexed transitivity: If $M_1 \ipole i M_2$ and $M_2
......@@ -945,17 +952,227 @@ Next, we give the inequational theory for our CBPV language.
\end{enumerate}
\end{definition}
\begin{definition}[Logical, Contextual Lifting of a Pole]
Given a pole $\pole$, we define
\begin{enumerate}
\item Contextual lifting TODO of a pole to be the congruence
closure.
\item Logical lifting of a pole to be given by the rules in figure
TODO ref.
\end{enumerate}
\end{definition}
Next, we show that downward-closure is inherited by the logical
relation from the pole.
\begin{lemma}[Logical Relation Downward Closure]
For any pole $\pole$, and $j \leq i$, we have
\[ \logty{i}{A} \subseteq \logty{j}{A} \qquad\qquad
\logty{i}{\u B} \subseteq \logty{j}{\u B} \qquad\qquad \]
\end{lemma}
\begin{theorem}[Logical Relations Theorem/Fundamental property]
For any pole $\pole$, the logical relation generated by it is a
congruence, i.e. a model of the congruence rules of CBPV.
For any pole $\pole$, the logical lifting generated by it is sound
with respect to the contextual lifting.
\end{theorem}
\begin{proof}
By induction on the congruence proofs of CBPV.
Since the contextual lifting is the congruence closure of the pole,
it is sufficient to show that the logical lifting of the pole models
all of the congruence rules.
\begin{enumerate}
\item
\item $\inferrule {} {\Gamma,x : A,\Gamma' \vDash x \logpole x :
A}$. Given $\gamma_1 \logty i {\Gamma,x:A,\Gamma'} \gamma_2$,
then by definition $\gamma_1(x) \logty i A \gamma_2(x)$.
\item $\inferrule{}{\Gamma \vdash \err \ltdyn \err : \u B}$ We
need to show $S_1[\err] \ipole i S_2[\err]$. By anti-reduction
it is sufficient to show $\err \ipole i \err$, which follows by
error awareness.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A \and
\Gamma, x : A \vDash M \logpole M' \in \u B
}
{\Gamma \vDash \letXbeYinZ V x M \logpole \letXbeYinZ {V'} {x} {M'} \in \u B}$
Each side takes $0$ steps so by anti-reduction, this reduces to
\[ S_1[M[\gamma_1,V/x]] \ipole i S_2[M'[\gamma_2,V'/x]] \] which follows by assumption that $\Gamma, x : A \vDash M \logpole M' \in \u B$ are related.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in 0}
{\Gamma \vDash \abort V \logpole \abort V' \in \u B}$.
By assumption, we get $V[\gamma_1] \logty i {0} V'[\gamma_2]$, but this is a contradiction.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A_1}
{\Gamma \vDash \inl V \logpole \inl V' \in A_1 + A_2}$.
Direct from assumption, rule for sums.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A_2}
{\Gamma \vDash \inr V \logpole \inr V' \in A_1 + A_2}$
Direct from assumption, rule for sums.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A_1 + A_2\and
\Gamma, x_1 : A_1 \vDash M_1 \logpole M_1' \in \u B\and
\Gamma, x_2 : A_2 \vDash M_2 \logpole M_2' \in \u B
}
{\Gamma \vDash \caseofXthenYelseZ V {x_1. M_1}{x_2.M_2} \logpole \caseofXthenYelseZ {V'} {x_1. M_1'}{x_2.M_2'} \in \u B}$
By case analysis of $V[\gamma_1] \logpole V'[\gamma_2]$.
\begin{enumerate}
\item If $V[\gamma_1]=\inl V_1, V'[\gamma_2] = \inl V_1'$ with $V_1 \logty i {A_1}$, then taking $0$ steps, by anti-reduction the problem reduces to
\[ S_1[M_1[\gamma_1,V_1/x_1]] \ipole i S_1[M_1[\gamma_1,V_1/x_1]]\]
which follows by assumption.
\item For $\inr{}$, the same argument.
\end{enumerate}
\item $\inferrule
{}
{\Gamma \vDash () \logpole () \in 1}$ Immediate by unit rule.
\item $\inferrule
{\Gamma \vDash V_1 \logpole V_1' \in A_1\and
\Gamma\vDash V_2 \logpole V_2' \in A_2}
{\Gamma \vDash (V_1,V_2) \logpole (V_1',V_2') \in A_1 \times A_2}$
Immediate by pair rule.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A_1 \times A_2\and
\Gamma, x : A_1,y : A_2 \vDash M \logpole M' \in \u B
}
{\Gamma \vDash \pmpairWtoXYinZ V x y M \logpole \pmpairWtoXYinZ {V'} {x} {y} {M'} \in \u B}$
By $V \logty i {A_1 \times A_2} V'$, we know $V[\gamma_1] =
(V_1,V_2)$ and $V'[\gamma_2] = (V_1', V_2')$ with $V_1 \logty i
{A_1} V_1'$ and $V_2 \logty i {A_2} V_2'$.
Then by anti-reduction, the problem reduces to
\[ S_1[M[\gamma_1,V_1/x,V_2/y]] \ipole i S_1[M'[\gamma_1,V_1'/x,V_2'/y]] \]
which follows by assumption.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A[\mu X.A/X]}
{\Gamma \vDash \rollty{\mu X.A} V \logpole \rollty{\mu X.A} V' \in \mu X.A }$
If $i = 0$, we're done. Otherwise $i=j+1$, and our assumption is
that $V[\gamma_1] \logty {j+1} V'[\gamma_2]$ and we need to show
that $\roll V[\gamma_1] \logty {j+1} {\mu X. A}\roll
V'[\gamma_2]$. By definition, we need to show $V[\gamma_1] \logty
j V'[\gamma_2]$, which follows by downward-closure.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in \mu X. A\and
\Gamma, x : A[\mu X. A/X] \vDash M \logpole M' \in \u B}
{\Gamma \vDash \pmmuXtoYinZ V x M \logpole \pmmuXtoYinZ {V'} {x} {M'} \in \u B}$
If $i = 0$, then by triviality at $0$, we're done.
Otherwise, $V[\gamma_1] \logty {j+1} {\mu X. A} V'[\gamma_2]$ so
$V[\gamma_1] = \roll V_\mu, V'[\gamma_2] = \roll V_\mu'$ with
$V_\mu \logty j {A[\mu X.A/X]} V_\mu'$. Then each side takes $1$ step, so by anti-reduction it is sufficient to show
\[ S_1[M[\gamma_1,V_\mu/x]] \ipole j S_2[M'[\gamma_2,V_\mu'/x]] \] which follows by assumption and downward closure of the stack, value relations.
\item $\inferrule {\Gamma \vDash M \logpole M' \in \u B} {\Gamma
\vDash \thunk M \logpole \thunk M' \in U \u B}$. We need to show
$M[\gamma_1] \logty i {U \u B} M'[\gamma_2]$, so let $S_1 \logty
j {\u B} S_2$. Then by downward-closure $\gamma_1 \logty j
{\Gamma} \gamma_2$, so by assumption, $S_1[M_1[\gamma_1]] \ipole
j S_2[M_2[\gamma_2]] $.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in U \u B}
{\Gamma \vDash \force V \logpole \force V' \in \u B}$.
We need to show $S_1[\force V[\gamma_1]] \ipole i S_2[\force
V'[\gamma_2]]$, which follows by the orthogonality definition of
$V[\gamma_1] \logty i {U \u B} V'[\gamma_2]$.
\item $\inferrule
{\Gamma \vDash V \logpole V' \in A}
{\Gamma \vDash \ret V \logpole \ret V' \in \u F A}$
We need to show $S_1[\ret V[\gamma_1]] \ipole i S_2[\ret
V'[\gamma_2]]$, which follows by the orthogonality definition of
$S_1 \logty i {\u F A} S_2$.
\item $\inferrule
{\Gamma \vDash M \logpole M' \in \u F A\and
\Gamma, x: A \vDash N \logpole N' \in \u B}
{\Gamma \vDash \bindXtoYinZ M x N \logpole \bindXtoYinZ {M'} {x} {N'} \in \u B}$.
We need to show $\bindXtoYinZ {M[\gamma_1]} x {N[\gamma_2]} \ipole i \bindXtoYinZ {M'[\gamma_2]} {x} {N'[\gamma_2]}$.
By $M \logpole M' \in \u F A$, it is sufficient to show that
\[ \bindXtoYinZ \bullet x {N[\gamma_1]} \logty i {\u F A} \bindXtoYinZ \bullet {x} {N'[\gamma_2]}\]
So let $j \leq i$ and $V \logty j A V'$, then we need to show
\[ \bindXtoYinZ {\ret V} x {N[\gamma_1]} \logty j {\u F A} \bindXtoYinZ {\ret V'} {x} {N'[\gamma_2]} \]
By anti-reduction, it is sufficient to show
\[ N[\gamma_1,V/x] \ipole j N'[\gamma_2,V'/x] \]
which follows by anti-reduction for $\gamma_1 \logty i {\Gamma} \gamma_2$ and $N \logpole N'$.
\item $\inferrule
{\Gamma, x: A \vDash M \logpole M' \in \u B}
{\Gamma \vDash \lambda x : A . M \logpole \lambda x:A. M' \in A \to \u B}$
We need to show $S_1[\lambda x:A. M[\gamma_1]] \ipole i S_2[\lambda x:A.M'[\gamma_2]]$.
By $S_1 \logty i {A \to \u B} S_2$, we know $S_1 = S_1'[\bullet V_1]$, $S_2 = S_2'[\bullet V_2]$ with $S_1' \logty i {\u B} S_2'$ and $V_1 \logty i {A} V_2$.
Then by anti-reduction it is sufficient to show
\[
S_1'[M[\gamma_1,V_1/x]] \ipole i S_2'[M'[\gamma_2,V_2/x]]
\]
which follows by $M \logpole M'$.
\item $\inferrule
{\Gamma \vDash M \logpole M' \in A \to \u B\and
\Gamma \vDash V \logpole V' \in A}
{\Gamma \vDash M\,V \logpole M'\,V' \in \u B }$
We need to show $S_1[M[\gamma_1]\,V[\gamma_1]] \ipole i S_2[M'[\gamma_2]\,V'[\gamma_2]]$ so by $M \logpole M'$ it is sufficient to show $S_1[\bullet V[\gamma_1]] \logty i {A \to \u B} S_2[\bullet V'[\gamma_2]]$ which follows by definition and assumption that $V \logpole V'$.
\item $\inferrule
{\Gamma \vDash M_1 \logpole M_1' \in \u B_1\and
\Gamma \vDash M_2 \logpole M_2' \in \u B_2}
{\Gamma \vDash \pair {M_1} {M_2} \logpole \pair {M_1'} {M_2'} \in \u B_1 \with \u B_2}$
We need to show $S_1[\pair{M_1[\gamma_1]}{M_2[\gamma_1]}] \ipole i S_2[\pair{M_1'[\gamma_1]}{M_2'[\gamma_2]}]$.
We proceed by case analsysis of $S_1 \logty i {\u B_1 \with \u B_2} S_2$
\begin{enumerate}
\item In the first possibility $S_1 = S_{1}'[\pi \bullet], S_2 =
S_2'[\pi \bullet]$ and $S_1' \logty i {\u B_1} S_2'$.
Then by anti-reduction, it is sufficient to show
\[ S_1'[M_1[\gamma_1]] \ipole i S_2'[M_1'[\gamma_2]] \]
which follows by $M_1 \logpole M_1'$.
\item Same as previous case.
\end{enumerate}
\item $\inferrule
{\Gamma \vDash M \logpole M' \in \u B_1 \with \u B_2}
{\Gamma \vDash \pi M \logpole \pi M' \in \u B_1}$
We need to show $S_1[\pi M[\gamma_1]] \ipole i S_2[\pi
M'[\gamma_2]]$, which follows by $S_1[\pi \bullet] \logty i {\u
B_1 \with \u B_2} S_2[\pi \bullet]$ and $M \logpole M'$.
\item $\inferrule {\Gamma \vDash M \logpole M' \in \u B_1 \with \u
B_2} {\Gamma \vDash \pi' M \logpole \pi' M' \in \u B_2}$ Similar
to previous case.
\item $\inferrule
{\Gamma \vDash M \logpole M' \in \u B[{\nu \u Y. \u B}/\u Y]}
{\Gamma \vDash \rollty{\nu \u Y. \u B} M \logpole \rollty{\nu \u Y. \u B} M' \in {\nu \u Y. \u B}}$
We need to show that
\[ S_1[ \rollty{\nu \u Y. \u B} M[\gamma_1]]
\ipole i S_2[ \rollty{\nu \u Y. \u B} M'[\gamma_2]] \]
If $i = 0$, we invoke triviality at $0$.
Otherwise, $i = j + 1$ and we know by $S_1 \logty {j+1} {\nu \u Y. \u B} S_2$ that
$S_1 = S_1'[\unroll \bullet]$ and $S_2 = S_2'[\unroll \bullet]$ with $S_1' \logty j {\u B[{\nu \u Y. \u B}/\u Y]} S_2'$, so by anti-reduction it is sufficient to show
\[ S_1'[ M[\gamma_1]] \ipole i S_2'[ M'[\gamma_2]] \]
which follows by $M \logpole M'$ and downward-closure.
\item $\inferrule
{\Gamma \vDash M \logpole M' \in {\nu \u Y. \u B}}
{\Gamma \vDash \unroll M \logpole \unroll M' \in \u B[{\nu \u Y. \u B}/\u Y]}$
We need to show $S_1[\unroll M] \ipole i S_2[\unroll M']$, which
follows because $S_1[\unroll \bullet] \logty i {\nu \u Y. \u B}
S_2[\unroll \bullet]$ and $M \logpole M'$.
\end{enumerate}
\end{proof}
\begin{theorem}[Completeness of Logical wrt Contextual]
For any pole $\pole$, the logical lifting is complete with respect
to the contextual lifting.
\end{theorem}
\begin{proof}
TODO: modify the proof below
\end{proof}
\begin{theorem}[LR is Sound for Contextual Error Approximation]
\begin{enumerate}
\item If $\Gamma \vDash M_1 \ltdyn M_2 \in \u B$, then $\Gamma \vDash M_1 \ltctx M_2 \in \u B$.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment