Commit b744911d authored by Mickael Laurent's avatar Mickael Laurent
Browse files

simplify grammar

parent 8df46b7f
......@@ -8,10 +8,9 @@
\begin{equation}\label{expressions2}
\begin{array}{lrclr}
\textbf{Atomic Expr} &a &::=& c\alt x\alt\lambda x:t.e\alt (a,a)\\[.3mm]
\textbf{U-Expr} &u &::=& x x\alt \tcase{x}{t}{e}{e}\alt \pi_i x\\[.3mm]
\textbf{P-Expr} &p &::=& u\alt a\\[.3mm]
\textbf{Expressions} &e &::=& \letexp{x}{p}{e}\alt p \\[.3mm]
\textbf{Atomic expr} &a &::=& c\alt x\alt\lambda x:t.e\alt (x,x)
\alt x x\alt \tcase{x}{t}{e}{e}\alt \pi_i x\\[.3mm]
\textbf{Expressions} &e &::=& \letexp{x}{a}{e}\alt a \\[.3mm]
\textbf{Values} &v &::=& c\alt\lambda x:t.e\alt (v,v)\\
\end{array}
\end{equation}
......@@ -25,8 +24,6 @@ TODO: Which restrictions on types? (cannot test a precise arrow type, etc)
TODO: Should we allow expr as let definition?
TODO: Simplify pairs (only with variables) + simplify grammar accordingly (no need to distinguish a and u)
\subsection{Typing rules}
\begin{mathpar}
......@@ -61,8 +58,8 @@ TODO: Simplify pairs (only with variables) + simplify grammar accordingly (no ne
{ }
\qquad
\Infer[Pair]
{\Gamma \vdash a_1:t_1 \and \Gamma \vdash a_2:t_2}
{\Gamma \vdash (a_1,a_2):\pair {t_1} {t_2}}
{\Gamma \vdash x_1:t_1 \and \Gamma \vdash x_2:t_2}
{\Gamma \vdash (x_1,x_2):\pair {t_1} {t_2}}
{ }
\\
\Infer[App]
......@@ -110,7 +107,7 @@ TODO: Simplify pairs (only with variables) + simplify grammar accordingly (no ne
{
\Gamma,(x:u)\vdash e:t}
{
\Gamma\vdash_{u}\letexp x p e : t
\Gamma\vdash_{u}\letexp x a e : t
}
{ }
\\
......@@ -118,21 +115,21 @@ TODO: Simplify pairs (only with variables) + simplify grammar accordingly (no ne
{
\Gamma,(x:t')\vdash e\triangleright_x\dt\\
\dt' = \dt\cup\{t'\setminus\textstyle\bigcup_{u\in\dt}u\}\\
\forall u\in \dt'.\ \Gamma\bvdash{p}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt'.\ \forall i\in I_u.\ \Gamma_u^i\vdash_{t_u^i}\letexp x p e : t}
\forall u\in \dt'.\ \Gamma\bvdash{a}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt'.\ \forall i\in I_u.\ \Gamma_u^i\vdash_{t_u^i}\letexp x a e : t}
{
\Gamma\vdash_{t'}\letexp x p e : t
\Gamma\vdash_{t'}\letexp x a e : t
}
{ }
\\
\Infer[Let]
{%\Gamma\cvdash p:\{(t_i,\Gamma_i)\}_{i\in I}\\
%\forall i\in I.\ \Gamma_i\vdash_{t_i}\letexp x p e : t
\Gamma\vdash p:s\\
\Gamma\vdash_{s}\letexp x p e : t
\Gamma\vdash a:s\\
\Gamma\vdash_{s}\letexp x a e : t
}
{
\Gamma\vdash\letexp x p e : t
\Gamma\vdash\letexp x a e : t
}
{ }
\end{mathpar}
......@@ -188,8 +185,8 @@ TODO: Algorithmic rules
\\
\Infer[Pair]
{i\in\{1,2\}\\
\Gamma \vdash a_i\triangleright_x\dt}
{\Gamma \vdash (a_1,a_2)\triangleright_x \dt}
\Gamma \vdash x_i\triangleright_x\dt}
{\Gamma \vdash (x_1,x_2)\triangleright_x \dt}
{}
\\
\Infer[ProjDom]
......@@ -223,7 +220,7 @@ TODO: Algorithmic rules
{\Gamma\vdash \tcase{y}{t}{e_1}{e_2}\triangleright_x\dt}
{}
\\
\Infer[App1]
\Infer[AppL]
{
\Gamma \vdash x : t\\
t\land(\arrow{\Empty}{\Any}) \equiv \textstyle{\bigvee_{i \in I}t_i}
......@@ -231,7 +228,7 @@ TODO: Algorithmic rules
{ \Gamma \vdash x y\triangleright_x\textstyle{\bigcup_{i\in I} \{t_i\}}}
{}
\qquad
\Infer[App2]
\Infer[AppR]
{
\Gamma \vdash y : \arrow{s}{t}
}
......@@ -243,7 +240,7 @@ TODO: Algorithmic rules
{ \Gamma \vdash y z\triangleright_x\{\}}
{}
\\
\Infer[App2*]
\Infer[AppR*]
{
\Gamma \vdash y : \textstyle{\bigwedge_{i \in I}s_i\to t_i}
}
......@@ -253,9 +250,9 @@ TODO: Algorithmic rules
\Infer[LetBase]
{
\Gamma, (y:u) \vdash e\triangleright_y\dt\\
\forall v\in \dt.\ \Gamma\fvdash{p}{v}\{(\_,\Gamma_v^i)\}_{i\in I_v}
\forall v\in \dt.\ \Gamma\fvdash{a}{v}\{(\_,\Gamma_v^i)\}_{i\in I_v}
}{
\Gamma\vdash_{u}\letexp y p e \triangleright_x \textstyle{
\Gamma\vdash_{u}\letexp y a e \triangleright_x \textstyle{
\bigcup_{v\in \dt}\bigcup_{i\in I_v}\{\Gamma_v^i(x)\}
}}
{ }
......@@ -263,31 +260,31 @@ TODO: Algorithmic rules
\Infer[LetSplit]
{
\Gamma,(y:t')\vdash e\triangleright_y\dt\\
\forall u\in \dt.\ \Gamma\bvdash{p}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt.\ \forall i\in I_u.\ \Gamma_u^i\vdash_{t_u^i}\letexp x p e \triangleright_x \dt_u^i
\forall u\in \dt.\ \Gamma\bvdash{a}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt.\ \forall i\in I_u.\ \Gamma_u^i\vdash_{t_u^i}\letexp x a e \triangleright_x \dt_u^i
}
{
\Gamma\vdash_{t'}\letexp y p e \triangleright_x \textstyle\bigcup_{u\in \dt}\bigcup_{i\in I_u} \dt_u^i
\Gamma\vdash_{t'}\letexp y a e \triangleright_x \textstyle\bigcup_{u\in \dt}\bigcup_{i\in I_u} \dt_u^i
}
{ }
\\
\Infer[LetDef]
{
\Gamma\vdash p\triangleright_x \dt
\Gamma\vdash a\triangleright_x \dt
}
{
\Gamma\vdash\letexp y p e \triangleright_x \dt
\Gamma\vdash\letexp y a e \triangleright_x \dt
}
{ }
\qquad
\Infer[Let]
{%\Gamma\cvdash p:\{(t_i,\Gamma_i)\}_{i\in I}\\
%\forall i\in I.\ \Gamma_i\vdash_{t_i}\letexp x p e \triangleright_x \dt_i
\Gamma\vdash p:s\\
\Gamma\vdash_{s}\letexp x p e \triangleright_x \dt
\Gamma\vdash a:s\\
\Gamma\vdash_{s}\letexp x a e \triangleright_x \dt
}
{
\Gamma\vdash\letexp y p e \triangleright_x \dt%\textstyle\bigcup_{i\in I} \dt_i
\Gamma\vdash\letexp y a e \triangleright_x \dt%\textstyle\bigcup_{i\in I} \dt_i
}
{ }
\end{mathpar}
......@@ -368,9 +365,14 @@ TODO: Algorithmic rules
{ }
\\
\Infer[Pair]
{\forall i\in I.\ \Gamma\bvdash{a_1}{t_i}\{(t_i^j,\Gamma_{1,i}^j)\}_{j\in J_i}\\
\forall i\in I.\ \Gamma\bvdash{a_2}{s_i}\{(s_i^k,\Gamma_{2,i}^k)\}_{k\in K_i}}
{\Gamma\bvdash {(a_1,a_2)} {\bigcup_{i\in I}(t_i,s_i)} \bigcup_{i\in I}\{(\pair{t_i^j}{s_i^k}, \Gamma_{1,i}^j\land\Gamma_{2,i}^k)\ |\ j\in J_i, k\in K_i\}}
{%\forall i\in I.\ \Gamma\bvdash{x_1}{t_i}\{(t_i^j,\Gamma_{1,i}^j)\}_{j\in J_i}\\
\Gamma\vdash x_1:t_\circ\\
\Gamma\vdash x_2:s_\circ\\
\forall i\in I.\ \Gamma_1^i = \Gamma\subst{x_1}{t_\circ\land t_i}\\
%\forall i\in I.\ \Gamma\bvdash{x_2}{s_i}\{(s_i^k,\Gamma_{2,i}^k)\}_{k\in K_i}
\forall i\in I.\ \Gamma_2^i = \Gamma\subst{x_2}{s_\circ\land s_i}\\
}
{\Gamma\bvdash {(x_1,x_2)} {\bigcup_{i\in I}(t_i,s_i)} \bigcup_{i\in I}\{(\pair{(t_\circ\land t_i)}{(s_\circ\land s_i)}, \Gamma_1^i\land\Gamma_2^i)\}}
{ }
\\
\Infer[Proj]
......@@ -418,7 +420,7 @@ TODO: Algorithmic rules
\Gamma,(x:s)\bvdash{e}{t} \{(t_i,\Gamma_i)\}_{i\in I}
}
{
\Gamma\ubvdash{s}{\letexp{x}{p}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
\Gamma\ubvdash{s}{\letexp{x}{a}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
}
{ }
\\
......@@ -426,20 +428,20 @@ TODO: Algorithmic rules
{
\Gamma,(x:s)\vdash e\triangleright_x\dt\\
\dt' = \dt\cup\{s\setminus\textstyle\bigcup_{u\in\dt}u\}\\
\forall u\in \dt'.\ \Gamma\bvdash{p}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt'.\ \forall i\in I_u.\ \Gamma\ubvdash{u}{\letexp{x}{p}{e}}{t} \{(t_i^j,\Gamma_i^j)\}_{j\in J_i}}
\forall u\in \dt'.\ \Gamma\bvdash{a}{u} \{t_u^i, \Gamma_u^i\}_{i\in I_u}\\
\forall u\in \dt'.\ \forall i\in I_u.\ \Gamma\ubvdash{u}{\letexp{x}{a}{e}}{t} \{(t_i^j,\Gamma_i^j)\}_{j\in J_i}}
{
\Gamma\ubvdash{s}{\letexp{x}{p}{e}}{t} \bigcup_{u\in\dt'}\bigcup_{i\in I_u} \{(t_i^j,\Gamma_i^j)\}_{j\in J_i}
\Gamma\ubvdash{s}{\letexp{x}{a}{e}}{t} \bigcup_{u\in\dt'}\bigcup_{i\in I_u} \{(t_i^j,\Gamma_i^j)\}_{j\in J_i}
}
{ }
\\
\Infer[Let]
{
\Gamma\vdash p:s\\
\Gamma\ubvdash{s}{\letexp{x}{p}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
\Gamma\vdash a:s\\
\Gamma\ubvdash{s}{\letexp{x}{a}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
}
{
\Gamma\bvdash{\letexp{x}{p}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
\Gamma\bvdash{\letexp{x}{a}{e}}{t} \{(t_i,\Gamma_i)\}_{i\in I}
}
{ }
\end{mathpar}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment