{v_1}{}\tstimes\tyof{v_1}{}$. Then we have $v\in t\iffdef\tyof
v{}\leq t$.
We also need to perform intersections of type schemes so as to intersect the static type of an expression (i.e., the one deduced by conventional rules) with the one deduced by occurrence typing (i.e., the one derived by $\vdashp$). For our algorithmic system (see \Rule{Env$_{\scriptscriptstyle\mathcal{A}}$} in Section~\ref{sec:algorules}) all we need to define is the intersection of a type scheme with a type:
\begin{lemma}[\cite{Frisch2008}]
Let $\ts$ be a type scheme and $t$ a type. We can compute a type scheme, written $t \tsand\ts$, such that
\(\tsint{t \tsand\ts}=\{s \alt\exists t' \in\tsint\ts.\ t \land t' \leq s \}\)
\end{lemma}
Finally, given a type scheme $\ts$ it is straightforward to choose in its interpretation a type $\tsrep\ts$ which serves as the canonical representative of the set (i.e., $\tsrep\ts\in\tsint\ts$):
\begin{definition}[Representative]
We define a function $\tsrep{\_}$ that maps every non-empty type scheme into a type, \textit{representative} of the set of types denoted by the scheme.\vspace{-2mm}
\begin{align*}
\begin{array}{lcllcl}
\tsrep t &=& t &\tsrep{\ts_1 \tstimes\ts_2}&=&\pair{\tsrep{\ts_1}}{\tsrep{\ts_2}}\\
If we restrict the language to positive expressions $e_+$, the algorithmic type system is complete and type schemes can be removed from it (we can use regular types instead).
With such restrictions, the rule \Rule{Abs-} is not needed anymore
because the negative part of functional types (i.e. the $N_i$ part of their DNF) is useless.
Indeed, when typing an application $e_1 e_2$, the negative part of the type of $e_1$
is ignored by the operator $\apply{}{}$.
Moreover, as there is no negated arrows in the domain of lambda-abstractions,
the negative arrows of the type of $e_2$ can also be ignored.
Similarly, negative arrows can be ignored when refining an application ($\worra{}{}$ also ignore the negative part
of the type of $e_1$).
Finally, as the only functional type that we can test is $\arrow\Empty\Any$, a functional type
cannot be refined to $\Empty$ due to its negative part, and thus we can ignore its negative part
(it makes no difference relatively to the rule \Rule{Efq}).
\end{proof}
From this result, we will now prove a stronger but more complex completeness theorem.
We were not able to prove full completeness, just a partial form of it. Indeed,
the use of nested \Rule{PAppL} yields a precision that the algorithm loses by applying \tsrep{}
in the definition of \constrf{}. Completeness is recovered by forbidding nested negated arrows on the
left-hand side of negated arrows.
\begin{definition}[Rank-0 negated derivation]
A derivation of the declarative type system is said rank-0 negated iff any application of \Rule{PAppL}
has a positive derivation as first premise ($\pvdash\Gamma e t \varpi.1:t_1$).
\end{definition}
\noindent The use of this terminology is borrowed from the ranking of higher-order
types, since, intuitively, it corresponds to typing a language in
which in the types used in dynamic tests, a negated arrow never occurs on the
left-hand side of another negated arrow.
\begin{lemma}
If $e$ is an application, then $\tyof e \Gamma$ does not contain any constructor $\tsfun\cdots$.
Consequently, we have $\tsrep{\tyof e \Gamma}\simeq\tyof e \Gamma$.
...
...
@@ -1634,3 +1699,32 @@
\end{description}
\end{description}
\end{proof}
\subsection{The algorithmic type system without type schemes}
TODO: states the inclusion between the regular type system and the one with type schemes
\begin{corollary}\label{app:completeness}
If we restrict the language to positive expressions $e_+$, the algorithmic type system is complete and type schemes can be removed from it (we can use regular types instead).