219 lines
6.6 KiB
TeX
219 lines
6.6 KiB
TeX
% This is samplepaper.tex, a sample chapter demonstrating the
|
|
% LLNCS macro package for Springer Computer Science proceedings;
|
|
% Version 2.21 of 2022/01/12
|
|
%
|
|
\documentclass[runningheads]{llncs}
|
|
%
|
|
\usepackage[T1]{fontenc}
|
|
% T1 fonts will be used to generate the final print and online PDFs,
|
|
% so please use T1 fonts in your manuscript whenever possible.
|
|
% Other font encondings may result in incorrect characters.
|
|
%
|
|
\usepackage{graphicx}
|
|
% Used for displaying a sample figure. If possible, figure files should
|
|
% be included in EPS format.
|
|
%
|
|
% If you use the hyperref package, please uncomment the following two lines
|
|
% to display URLs in blue roman font according to Springer's eBook style:
|
|
%\usepackage{color}
|
|
%\renewcommand\UrlFont{\color{blue}\rmfamily}
|
|
%\urlstyle{rm}
|
|
%
|
|
\include{prolog}
|
|
\usepackage{mathpartir}
|
|
\usepackage{amsmath}
|
|
\usepackage{amssymb}
|
|
|
|
\begin{document}
|
|
%
|
|
\title{Global Type Inference for Java using SAT Solvers}
|
|
%
|
|
%\titlerunning{Abbreviated paper title}
|
|
% If the paper title is too long for the running head, you can set
|
|
% an abbreviated paper title here
|
|
%
|
|
\author{First Author\inst{1}\orcidID{0000-1111-2222-3333} \and
|
|
Second Author\inst{2,3}\orcidID{1111-2222-3333-4444} \and
|
|
Third Author\inst{3}\orcidID{2222--3333-4444-5555}}
|
|
%
|
|
\authorrunning{F. Author et al.}
|
|
% First names are abbreviated in the running head.
|
|
% If there are more than two authors, 'et al.' is used.
|
|
%
|
|
\institute{Princeton University, Princeton NJ 08544, USA \and
|
|
Springer Heidelberg, Tiergartenstr. 17, 69121 Heidelberg, Germany
|
|
\email{lncs@springer.com}\\
|
|
\url{http://www.springer.com/gp/computer-science/lncs} \and
|
|
ABC Institute, Rupert-Karls-University Heidelberg, Heidelberg, Germany\\
|
|
\email{\{abc,lncs\}@uni-heidelberg.de}}
|
|
%
|
|
\maketitle % typeset the header of the contribution
|
|
%
|
|
\begin{abstract}
|
|
The abstract should briefly summarize the contents of the paper in
|
|
150--250 words.
|
|
|
|
\keywords{First keyword \and Second keyword \and Another keyword.}
|
|
\end{abstract}
|
|
%
|
|
%
|
|
%
|
|
\section{Type Inference}
|
|
Every major typed programming language uses some form of type inference.
|
|
Rust, Java, C++, Haskell, etc... %(see: https://en.wikipedia.org/wiki/Type_inference)
|
|
Type inference adds alot of value to a programming language.
|
|
\begin{itemize}
|
|
\item Code is more readable.
|
|
\item Type inference usually does a better job at finding types than a programmer.
|
|
\item Type inference can use types that are not denotable by the programmer.
|
|
\item Better reusability.
|
|
\item Allows for faster development and the programmer to focus on the actual task instead of struggling with the type system.
|
|
\end{itemize}
|
|
|
|
Java has adopted more and more type inference features over time.
|
|
%TODO: list type inference additions
|
|
Currently Java only has local type inference.
|
|
We want to bring type inference for Java to the next level.
|
|
|
|
\section{Unify}
|
|
Input: Every type placeholder must have an upper bound.
|
|
Output: Every $\tv{a} \lessdot \type{T}$ constraint gets a
|
|
|
|
We have to formulate the unification algorithm with implication rules.
|
|
Those can be directly translated to ASP.
|
|
\begin{mathpar}
|
|
\inferrule[Subst-L]{
|
|
\tv{a} \doteq \type{T}_1 \\
|
|
\tv{a} \lessdot \type{T}_2
|
|
}{
|
|
\type{T}_1 \lessdot \type{T}_2
|
|
}
|
|
\and
|
|
\inferrule[Subst-R]{
|
|
\tv{a} \doteq \type{T}_1 \\
|
|
\type{T}_2 \lessdot \tv{a}
|
|
}{
|
|
\type{T}_2 \lessdot \type{T}_1
|
|
}
|
|
\and
|
|
\inferrule[Subst-Equal]{
|
|
\tv{a} \doteq \type{T}_1 \\
|
|
\tv{a} \doteq \type{T}_2
|
|
}{
|
|
\type{T}_1 \doteq \type{T}_2
|
|
}
|
|
\and
|
|
\inferrule[Swap]{
|
|
\type{T}_1 \doteq \type{T}_2
|
|
}{
|
|
\type{T}_2 \doteq \type{T}_1
|
|
}
|
|
\and
|
|
\inferrule[Match]{
|
|
\tv{a} \lessdot \type{N}_1 \\
|
|
\tv{a} \lessdot \type{N}_2 \\
|
|
\type{N}_1 << \type{N}_2
|
|
}{
|
|
\type{T}_1 \lessdot \type{T}_2
|
|
}
|
|
\and
|
|
\inferrule[Adopt]{
|
|
\tv{a} \lessdot \tv{b} \\
|
|
\tv{b} \lessdot \type{T}
|
|
}{
|
|
\tv{a} \lessdot \type{T}
|
|
}
|
|
\and
|
|
\inferrule[Subst-Param]{
|
|
\tv{a} \doteq \type{N} \\
|
|
\tv{a} = \type{T}_i \\
|
|
\exptype{C}{\type{T}_1 \ldots \type{T}_n} <: \type{T} \\
|
|
}{
|
|
\type{T}_i \doteq \type{N} \\
|
|
}
|
|
\and
|
|
\inferrule[Adapt]{
|
|
\type{N}_1 \lessdot \exptype{C}{\type{T}_1 \ldots \type{T}_n} \\
|
|
\type{N}_1 <: \exptype{C}{\type{S}_1 \ldots \type{S}_n} \\
|
|
}{
|
|
\exptype{C}{\type{S}_1 \ldots \type{S}_n} \doteq \exptype{C}{\type{T}_1 \ldots \type{T}_n} \\
|
|
}
|
|
\and
|
|
\inferrule[Reduce]{
|
|
\exptype{C}{\type{S}_1 \ldots \type{S}_n} \doteq \exptype{C}{\type{T}_1 \ldots \type{T}_n} \\
|
|
}{
|
|
\type{S}_i \doteq \type{T}_i \\
|
|
}
|
|
\end{mathpar}
|
|
|
|
\begin{mathpar}
|
|
\inferrule[Super]{
|
|
\type{T} \lessdot \tv{a}\\
|
|
\type{T} <: \type{N}
|
|
}{
|
|
\tv{a} \doteq \type{N}
|
|
}
|
|
\end{mathpar}
|
|
|
|
\begin{mathpar}
|
|
\inferrule[Fail]{
|
|
\type{T} \lessdot \type{N}\\
|
|
\type{T} \nless : \type{N}
|
|
}{
|
|
\emptyset
|
|
}
|
|
\and
|
|
\inferrule[Fail]{
|
|
\exptype{C}{\ldots} \doteq \exptype{D}{\ldots}\\
|
|
\type{C} \neq \type{D}
|
|
}{
|
|
\emptyset
|
|
}
|
|
\and
|
|
\inferrule[Fail]{
|
|
\tv{a} \lessdot \type{N}_1 \\
|
|
\tv{a} \lessdot \type{N}_2 \\
|
|
\text{not}\ \type{N}_1 << \type{N}_2 \\
|
|
\text{not}\ \type{N}_2 << \type{N}_1
|
|
}{
|
|
\emptyset
|
|
}
|
|
\end{mathpar}
|
|
% Subst
|
|
% a =. N, a <. T, N <: T
|
|
% --------------
|
|
% N <. T
|
|
|
|
% how to proof completeness and termination?
|
|
% TODO: how to proof termination?
|
|
|
|
\section{Completeness}
|
|
To proof completeness we have to show that every type can be replaced by a placeholder in a correct constraint set.
|
|
|
|
Completeness -> we never exclude a solution
|
|
Following constraints stay: $\tv{a} \lessdot \type{T}$ if $\tv{a}$ is never on a right side of another constraint.
|
|
Every other type placeholder will be reduced to $\tv{a} \doteq \type{T}$, if there is a solution.
|
|
Proof:
|
|
%Induction over every possible constraint variation:
|
|
a =. T -> induction start
|
|
a <. T -> if no other constraint then it can stay otherwise there is either a =. T or a <. T
|
|
in latter case: a <. T, a <. T'
|
|
|
|
Proof that every type can be replaced by a Type Placeholder.
|
|
% Whats with a =. T, can T be replaced by a Type Placeholder?
|
|
% What is our finish condition? a <. T constraints stay, a =. b constraints stay.
|
|
% Algorithm does not fail -> \emptyset if a solution exists
|
|
% Otherwise there exists a substitution. If the algorithm succeeds we have to pick one of the possible solutions
|
|
% by: a <. T -> a =.T
|
|
% a =. b, b =. T -> use the solution generation from other paper
|
|
% TODO: try to include solution generation in the algorithm and proof that this solution is valid and will always occur as long as there is a solution
|
|
|
|
Soundness -> we never make a wrong implication
|
|
%$\tv{a} \doteq \type{T}$ means that $\[type{T}/\tv{a}]C$ is correct
|
|
If it succeeds then we can substitute all $\tv{a} \doteq \type{T}$
|
|
constraints in the original constraint set and
|
|
there exists a typing for the remaining type placeholders
|
|
so that the constraint set is satisfied.
|
|
|
|
\end{document}
|