% 
% \documentclass[acmsmall,screen,review,anonymous,nonacm]{acmart}
\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.

\PassOptionsToPackage{dvipsnames}{xcolor}
%%

\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 line
% to display URLs in blue roman font according to Springer's eBook style:
% \renewcommand\UrlFont{\color{blue}\rmfamily}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\usepackage{hyperref}
\usepackage{url}
\usepackage{listings}
\usepackage{xspace}
\usepackage{array}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{tcolorbox, soul} % for sample conversations
\usepackage{makecell, multicol, color}
\usepackage{booktabs}
% \usepackage{subcaption}
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{lipsum}
% math
% \usepackage{amsmath,comment}
% \usepackage{mathtools}
% \usepackage{amsthm}
% \DeclareMathOperator*{\argmax}{arg\,max}
% \DeclareMathOperator*{\argmin}{arg\,min}

% \let\proof\relax\let\endproof\relax
% \usepackage{amssymb}


% //////
\usepackage{longtable}
\usepackage{tikz}
\usepackage[numbers]{natbib}  % Use numbers citation style for LNCS
\usepackage[ruled, vlined, linesnumbered, commentsnumbered, longend]{algorithm2e}
\usepackage{hyperref}

\usepackage{xcolor}
\usepackage{xspace}
\usepackage{booktabs, multirow}
\usepackage{soul}
\usepackage{listings}
\usepackage{subcaption}
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{wrapfig}
% \usepackage{natbib}

\renewcommand{\ttdefault}{txtt}

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.97,0.97,0.95}
\definecolor{forestgreen}{rgb}{0.28,0.62,0.37}
\definecolor{codeblue}{rgb}{0,0.5,1}
% \definecolor{codedelete}{rgb}{1, 0.4, 0.4}

\lstdefinelanguage{markdown}{
    morekeywords={*, \#, \_, `},
    sensitive=false,
    morecomment=[l]{//},   % to allow comments in markdown syntax
    morestring=[b]",        % double quotes for strings
    postbreak={},
breakindent=0pt,
breakautoindent=false,
}


\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codepurple},
    keywordstyle=\color{codepurple},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{blue},
    basicstyle=\ttfamily\scriptsize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=4
}

\lstset{style=mystyle}
\newcommand{\HighlightBG}{\makebox[0pt][l]{\color{yellow!50}\rule[-0.45em]{\linewidth}{1.3em}}}

\usetikzlibrary{shapes, arrows}

\begin{document}
\input{macro}

\title{\tech: Class Invariant Synthesis using Large Language Models}

\authorrunning{C. Sun et al.}

\author{Chuyue Sun\inst{1} \and
Viraj Agashe\inst{2} \and
Saikat Chakraborty\inst{2} \and
Jubi Taneja\inst{2} \and
Clark Barrett\inst{1} \and
David Dill\inst{1} \and
Xiaokang Qiu\inst{3} \and
Shuvendu K. Lahiri\inst{2}}

\institute{Stanford University, USA\\
\and
Microsoft Research, USA\\
\and
Purdue University, USA}

\maketitle

\begin{abstract}
Formal program specifications in the form of preconditions, postconditions, and class invariants have several benefits for the construction and maintenance of programs. They not only aid in program understanding due to their unambiguous semantics but can also be enforced dynamically (or even statically when the language supports a formal verifier).  However, synthesizing high-quality specifications in an underlying programming language is limited by the expressivity of the specifications or the need to express them in a declarative manner. Prior work has demonstrated the potential of large language models (LLMs) for synthesizing high-quality method pre/postconditions for Python and Java, but does not consider class invariants.

In this work, we describe \tech, a method for co-generating executable class invariants and test inputs to produce high-quality class invariants for a mainstream language such as C++, leveraging LLMs' ability to synthesize pure functions. We demonstrate that \tech outperforms a pure LLM-based technique for generating specifications (from code) as well as prior data-driven invariant inference techniques such as Daikon. We contribute a benchmark of standard C++ data structures along with a harness that can help measure both the correctness and completeness of generated specifications using tests and mutants. We also demonstrate its applicability to real-world code by performing a case study on several classes within a widely used and high-integrity C++ codebase.
%We discuss challenges as well as future research directions informed by our findings.

\keywords{Program Synthesis \and Large Language Models \and Class Invariants \and Formal Verification}
\end{abstract}

\livia{TODO: Related Work. Mention duplication in limitation}
\section{Introduction}
\input{intro}



\section{Running Example: AVL Tree}
\label{sec:avl_intro}
% \dave{Where did the code come from?  Is it yours?  Is it one of the examples from github?}\livia{addressed}

\dave{Where did the class invariants come from (written by the authors?)}

\input{motivation}

\section{Approach}
\label{sec:approach}
\input{approach}

% \include{prompt}


\section{Results}
\label{sec:results}
\subsection{Benchmark}
\label{sec:benchmark}
\input{benchmark}
% \subsection{Evaluation: Automatic Validation Pipeline}
% \label{subsec:verification}
% \input{validation}
\subsection{Evaluation}
\input{experiments}
\input{results}

\section{Case study: Z3 \CodeIn{bdd\_manager} class}
\label{sec:z3}
\input{z3}

\section{Related Work}
\input{related-work}

\section{Limitation}
\label{sec:limitation}
\input{discussion}

\section{Conclusion}
\label{sec:concl}
\input{concl}

% Bibliography entries for the entire Anthology, followed by custom entries
%\bibliography{anthology,custom}
% Custom bibliography entries only
\bibliographystyle{splncs04}
\bibliography{custom}

% \appendix
\appendix
\include{prompt_refine}
\include{appendix/inv_table}
\include{appendix/approach_details}

\end{document}
\endinput
%%
%% End of file `sample-acmcp.tex'.
