\(%\usepackage{color}\)
\(%\usepackage{tcolorbox}\)
\(%\tcbuselibrary{skins}\)
\(\usepackage{pifont}\)
\(\)
\(\definecolor{fakeaaltobluel}{RGB}{00,141,229} % 0065BD\)
\(\definecolor{aaltoblue}{RGB}{00,101,189} % 0065BD\)
\(\definecolor{aaltored}{RGB}{237,41,57} % ED2939\)
\(\)
\(\definecolor{MyBoxBackground}{rgb}{0.98,0.98,1.0}\)
\(\definecolor{MyBoxBorder}{rgb}{0.90,0.90,1.0}\)
\(\definecolor{backgroundred}{rgb}{1.0,0.98,0.98}\)
\(\definecolor{shadowred}{rgb}{1.0,0.90,0.90}\)
\(\)
\(%\newcommand{\subheading}[1]{\textbf{\large\color{fakeaaltobluel}#1}}\)
\(\newcommand{\subheading}[1]{\large{\usebeamercolor[fg]{frametitle} #1}}\)
\(\)
\(\)
\(%\newtcbox{\mybox}[1][red]{on line,arc=0pt,outer arc=0pt,colback=#1!10!white,colframe=#1!50!black,boxsep=0pt,left=1pt,right=1pt,top=2pt,bottom=2pt,boxrule=0pt,bottomrule=1pt,toprule=1pt}\)
\(%\newtcbox{\mybox}[1][MyBoxBackground]{on line,arc=0pt,outer arc=0pt,colback=#1!10!white,colframe=#1!50!black,boxsep=0pt,left=1pt,right=1pt,top=2pt,bottom=2pt,boxrule=0pt,bottomrule=1pt,toprule=1pt}\)
\(\)
\(\newtcolorbox{MyBoxTitled}[1]{colback=MyBoxBackground!100!black,colframe=MyBoxBorder!100!black,boxsep=2pt,left=0pt,right=0pt,top=2pt,bottom=0pt,%enhanced,%\)
\( coltitle=red!25!black,title=#1,boxrule=1pt}\)
\(\)
\(\newtcolorbox{MyBox}[1][]{colback=MyBoxBackground!100!black,colframe=MyBoxBorder!100!black,boxsep=0pt,left=2pt,right=0pt,top=0pt,bottom=0pt,%enhanced,%\)
\( coltitle=red!25!black,boxrule=1pt,#1}\)
\(\)
\(\newenvironment{EqnBox}[1]{\begin{adjustbox}{valign=t}\begin{minipage}{#1}\begin{MyBox}[colback=backgroundred!100!black,colframe=shadowred!100!black]}{\end{MyBox}\end{minipage}\end{adjustbox}}\)
\(\)
\(\newenvironment{topbox}[1]{\begin{adjustbox}{valign=t}\begin{minipage}{#1}}{\end{minipage}\end{adjustbox}}\)
\(\)
\(\newcommand{\Blue}[1]{{\color{aaltoblue}#1}}\)
\(\newcommand{\Red}[1]{{\color{aaltored}#1}}\)
\(%\newcommand{\Emph}[1]{\emph{\color{aaltoblue}#1}}\)
\(\newcommand{\Emph}[1]{\emph{\usebeamercolor[fg]{structure} #1}}\)
\(\newcommand{\TextDef}[1]{{\bf\usebeamercolor[fg]{structure} #1}}\)
\(\)
\(\newcommand{\todo}[1]{\textbf{\Red{\Pointer #1}}}\)
\(\newcommand{\TODO}[1]{\todo{#1}}\)
\(\)
\(\newcommand{\Pointer}{\raisebox{-1ex}{\huge\ding{43}}\ }\)
\(\)
\(\)
\(%\)
\(% Common math definitions\)
\(%\)
\(\newcommand{\Set}[1]{\{#1\}}\)
\(\newcommand{\Setdef}[2]{\{{#1}\mid{#2}\}}\)
\(\newcommand{\PSet}[1]{\mathcal{P}(#1)}\)
\(\newcommand{\Pair}[2]{(#1,#2)}\)
\(\newcommand{\Card}[1]{{\vert{#1}\vert}}\)
\(\newcommand{\Tuple}[1]{(#1)}\)
\(\newcommand{\Seq}[1]{[#1]}\)
\(\newcommand{\bbZ}{\mathbb{Z}}\)
\(\newcommand{\Ints}{\mathbb{Z}}\)
\(\newcommand{\Reals}{\mathbb{R}}\)
\(\newcommand{\bbQ}{\mathbb{Q}}\)
\(\newcommand{\Rats}{\bbQ}\)
\(\newcommand{\bbN}{\mathbb{N}}\)
\(\newcommand{\Nats}{\bbN}\)
\(\)
\(\newcommand{\Floor}[1]{\lfloor #1 \rfloor}\)
\(\newcommand{\Ceil}[1]{\lceil #1 \rceil}\)
\(\)
\(\newcommand{\False}{\textsf{F}}\)
\(\newcommand{\True}{\textsf{T}}\)
\(\)
\(\newcommand{\Implies}{\rightarrow}\)
\(\newcommand{\Iff}{\leftrightarrow}\)
\(%\newcommand{\Implies}{\Rightarrow}\)
\(%\newcommand{\Iff}{\Leftrightarrow}\)
\(\newcommand{\Xor}{\oplus}\)
\(\)
\(\newcommand{\Equiv}{\equiv}\)
\(\)
\(\newcommand{\Oh}[1]{O(#1)}\)
\(%\newcommand{\Theta}[1]{\Theta(#1)}\)
\(\)
\(\newcommand{\PHP}[2]{\mathrm{php}_{#1,#2}}\)
\(\newcommand{\PH}[2]{\mathit{x}_{#1,#2}}\)
\(\)
\(\newcommand{\NP}{\textbf{NP}}\)
\(\newcommand{\coNP}{\textbf{co-NP}}\)
\(\)
\(\newcommand{\bnfdef}{\mathrel{\textup{::=}}}\)
\(\newcommand{\bnfor}{\mathrel{\mid}}\)
\(\)
\(\newcommand{\Def}{\mathrel{:=}}\)
\(\)
\(\newcommand{\LSF}{\alpha}\)
\(\newcommand{\RSF}{\beta}\)
\(\newcommand{\SF}{\phi}\)
\(\newcommand{\MF}{\gamma}\)
\(%\newcommand{\Abbrv}{\equiv}\)
\(\newcommand{\Abbrv}{\Def}\)
\(\newcommand{\AbbrvEq}{\equiv}\)
\(\newcommand{\Exists}[2]{\exists{#1}.\,#2}\)
\(%\newcommand{\E}[3]{\exists{#1{:}#2}.\,#3}\)
\(\newcommand{\E}[3]{\exists{#1{:}\,#3}}\)
\(\newcommand{\Forall}[2]{\forall{#1}.\,#2}\)
\(%\newcommand{\Furall}[3]{\forall{#1{:}#2}.\,#3}\)
\(%\newcommand{\A}[3]{\forall{#1{:}#2}.\,#3}\)
\(\newcommand{\A}[3]{\forall{#1{:}\,#3}}\)
\(\newcommand{\Models}{\models}\)
\(\newcommand{\NotModels}{\not\models}\)
\(\)
\(\newcommand{\Substf}[3]{#1[#2 \mapsto #3]}\)
\(\newcommand{\Functions}[2]{[#1 \to #2]}\)
\(\)
\(\)
\(\newcommand{\Eq}{\approx}\)
\(\newcommand{\EqS}[1]{\approx_{#1}}\)
\(\newcommand{\Neq}{\not\approx}\)
\(\)
\(%\newcommand{\Th}{\mathcal{T}}\)
\(\newcommand{\Th}{T}\)
\(\newcommand{\ThI}[1]{\Th_{#1}}\)
\(\)
\(\newcommand{\Sig}{\Sigma}\)
\(\newcommand{\SigI}[1]{\Sigma_{#1}}\)
\(\newcommand{\Interp}{I}\)
\(%\newcommand{\Interp}{{\mathcal{I}}}\)
\(\newcommand{\InterpOf}[1]{#1^\Interp}\)
\(\newcommand{\InterpIOf}[2]{#2^{#1}}\)
\(\newcommand{\InterpRestr}[1]{\Interp^{#1}}\)
\(\newcommand{\InterpI}[1]{I_{#1}}\)
\(%\newcommand{\InterpI}[1]{{\mathcal{I}_{#1}}}\)
\(%\newcommand{\InterpIOf}[2]{#2^{\InterpI{#1}}}\)
\(\newcommand{\InterpDom}{D_{\Interp}}\)
\(\newcommand{\InterpSubst}[2]{\Interp[{#1}\mapsto{#2}]}\)
\(\newcommand{\ThModels}{\mathrel{\models_{\Th}}}\)
\(\newcommand{\ThIModels}[1]{\mathrel{\models_{\ThI{#1}}}}\)
\(\)
\(% Example interpretations\)
\(\newcommand{\IInts}{\InterpI{\textrm{ints}}}\)
\(\newcommand{\IIntsOf}[1]{\InterpIOf{\IInts}{#1}}\)
\(\newcommand{\IMods}{\InterpI{\textrm{mod7}}}\)
\(\newcommand{\IModsOf}[1]{\InterpIOf{\IMods}{#1}}\)
\(\newcommand{\ISilly}{\InterpI{\textrm{silly}}}\)
\(\newcommand{\ISillyOf}[1]{\InterpIOf{\ISilly}{#1}}\)
\(\)
\(\)
\(%\newcommand{\El}[1]{\textup{e}_{#1}}\)
\(\)
\(\newcommand{\ElemI}{\textup{\ding{40}}}\)
\(\newcommand{\ElemII}{\textup{\ding{41}}}\)
\(\newcommand{\ElemIII}{\textup{\ding{46}}}\)
\(\)
\(\newcommand{\ElemA}{\circ}\)
\(\newcommand{\ElemB}{\bullet}\)
\(\)
\(\newcommand{\AxiomMarg}[1]{\makebox{}\hfill(\Blue{#1})}\)
\(\newcommand{\Comment}[1]{\makebox{}\hfill\Blue{#1}}\)
\(\)
\(\newcommand{\DLZ}{\mathit{DL}(\bbZ)}\)
\(\newcommand{\DLQ}{\mathit{DL}(\bbQ)}\)
\(\newcommand{\EUF}{\mathit{EUF}}\)
\(\newcommand{\TEUF}{\ThI{\mathit{EUF}}}\)
\(\newcommand{\LIA}{\mathit{LIA}}\)
\(\newcommand{\TLIA}{\ThI{\mathit{LIA}}}\)
\(\newcommand{\TNRA}{\ThI{\mathit{NRA}}}\)
\(\newcommand{\TNIA}{\ThI{\mathit{NIA}}}\)
\(\newcommand{\LRA}{\mathit{LRA}}\)
\(\newcommand{\TLRA}{\ThI{\mathit{LRA}}}\)
\(\newcommand{\IDL}{\mathit{IDL}}\)
\(\newcommand{\RDL}{\mathit{RDL}}\)
\(\newcommand{\EUFModels}{\mathrel{\models_{\TEUF}}}\)
\(\newcommand{\EUFModelsNot}{\mathrel{{\not\models}_{\TEUF}}}\)
\(\newcommand{\LIAModels}{\mathrel{\models_{\LIA}}}\)
\(\newcommand{\LIANotModels}{\mathrel{\not\models_{\LIA}}}\)
\(\newcommand{\LIAEntails}{\mathrel{\models_{\LIA}}}\)
\(\newcommand{\IDLEntails}{\mathrel{\models_{\IDL}}}\)
\(\newcommand{\NIAModels}{\mathrel{\models_{\TNIA}}}\)
\(\newcommand{\Div}[2]{{{#1}\mid{#2}}}\)
\(\)
\(\newcommand{\Sort}{s}\)
\(\newcommand{\SortI}[1]{s_{#1}}\)
\(\newcommand{\Sorts}{S}\)
\(\newcommand{\Func}{f}\)
\(\newcommand{\Funcs}{F}\)
\(\newcommand{\Pred}{p}\)
\(\newcommand{\Preds}{P}\)
\(\newcommand{\SortName}[1]{\textsf{#1}}\)
\(\)
\(\newcommand{\Var}{x}\)
\(\newcommand{\Vars}{X}\)
\(\newcommand{\BVar}{a}\)
\(\newcommand{\BVars}{\mathcal{B}}\)
\(\newcommand{\Val}{v}\)
\(\)
\(\newcommand{\DomOf}[1]{D_{#1}}\)
\(\)
\(\newcommand{\Term}{t}\)
\(\newcommand{\TermI}[1]{t_{#1}}\)
\(\newcommand{\TermP}[1]{t'}\)
\(\newcommand{\Atom}{A}\)
\(\)
\(\)
\(%\)
\(% EUF\)
\(%\)
\(\newcommand{\UFEq}{\equiv}\)
\(\newcommand{\UFEqP}{\mathrel{\equiv'}}\)
\(\newcommand{\UFEqNot}{\not\equiv}\)
\(\newcommand{\UFNeq}{\not\equiv}\)
\(\)
\(\)
\(\)
\(%\)
\(% Arithmetics\)
\(%\)
\(\newcommand{\IntsSort}{\textrm{Int}}\)
\(\newcommand{\IntsSig}{\SigI{\textrm{Int}}}\)
\(\newcommand{\RealsSort}{\textrm{Real}}\)
\(\newcommand{\Mul}{\mathbin{*}}\)
\(\)
\(%\)
\(% Arrays\)
\(%\)
\(\newcommand{\IndexSort}{\SortName{idx}}\)
\(%\newcommand{\IndexSort}{\SortName{index}}\)
\(\newcommand{\ElemSort}{\SortName{elem}}\)
\(%\newcommand{\ArraySort}{\SortName{array}}\)
\(\newcommand{\ArraySort}{\SortName{arr}}\)
\(\newcommand{\ArrSig}{\Sigma_{\mathit{arrays}}}\)
\(\newcommand{\ArrE}[1]{\textrm{a}_{#1}}\)
\(\)
\(\)
\(\newcommand{\TArrays}{\ThI{\mathit{arrays}}}\)
\(\newcommand{\TArraysExt}{\ThI{\mathit{arrays}}^{=}}\)
\(\newcommand{\ArrModels}{\mathrel{{\models_\mathit{arrays}}}}\)
\(\)
\(\)
\(%\)
\(% Theories of Lisp-like lists\)
\(%\)
\(\newcommand{\ThCons}{\ThI{\textrm{cons}}}\)
\(\newcommand{\ThConsAcyclic}{\ThI{\textrm{cons+}}}\)
\(\newcommand{\SigCons}{\SigI{\textrm{cons}}}\)
\(\newcommand{\Cons}{\FuncName{cons}}\)
\(\newcommand{\Car}{\FuncName{car}}\)
\(\newcommand{\Cdr}{\FuncName{cdr}}\)
\(\newcommand{\LAtom}{\PredName{atom}}\)
\(% Sorted version additions\)
\(\newcommand{\ListSort}{\SortName{list}}\)
\(\newcommand{\Nil}{\FuncName{nil}}\)
\(\newcommand{\Length}{\FuncName{length}}\)
\(\)
\(\)
\(\newcommand{\BVT}{\ThI{\mathsf{BV}}}\)
\(\newcommand{\BVSig}{\SigI{\mathsf{BV}}}\)
\(\newcommand{\BVS}[1]{\SortName{[}#1\SortName{]}}\)
\(%\newcommand{\BVS}[1]{[{#1}]}\)
\(\newcommand{\BVAdd}[1]{\mathbin{{+}_{\BVS{#1}}}}\)
\(\newcommand{\BVLE}[1]{\mathbin{{\le}_{\BVS{#1}}}}\)
\(\newcommand{\BVGE}[1]{\mathbin{{\ge}_{\BVS{#1}}}}\)
\(\newcommand{\BVSL}[1]{\mathbin{{\ll}_{\BVS{#1}}}}\)
\(\newcommand{\BVTermB}[1]{\hat{t}_{(#1)}}\)
\(%\newcommand{\BVTermBI}[2]{\hat{t}_{#1}^{(#2)}}\)
\(\newcommand{\BVAtom}{\hat{A}}\)
\(\newcommand{\BVXB}[1]{\hat{x}_{(#1)}}\)
\(\newcommand{\BVYB}[1]{\hat{y}_{(#1)}}\)
\(\newcommand{\BVVar}[1]{\hat{x}_{(#1)}}\)
\(\)
\(\)
\(% SMTLIB logics\)
\(\newcommand{\SMTLIBLogic}[1]{\textrm{#1}}\)
\(\newcommand{\QFUF}{\SMTLIBLogic{QF\_UF}}\)
\(\newcommand{\QFLIA}{\SMTLIBLogic{QF\_LIA}}\)
\(\newcommand{\QFUFLRA}{\SMTLIBLogic{QF\_UFLRA}}\)
\(\newcommand{\SMTLIBLIA}{\SMTLIBLogic{LIA}}\)
\(\)
\(\newcommand{\CG}[1]{G_{#1}}\)
\(\newcommand{\DiffEdge}[1]{\overset{#1}{\longrightarrow}}\)
\(\)
\(\newcommand{\FuncName}[1]{\textsf{#1}}\)
\(\newcommand{\PredName}[1]{\textsf{#1}}\)
\(\newcommand{\ReadF}{\FuncName{read}}\)
\(\newcommand{\Read}[2]{\ReadF(#1,#2)}\)
\(\newcommand{\WriteF}{\FuncName{write}}\)
\(\newcommand{\Write}[3]{\WriteF(#1,#2,#3)}\)
\(\)
\(\newcommand{\Abs}[1]{\alpha_{#1}}\)
\(\)
\(\newcommand{\Expl}[1]{\textit{explain}(#1)}\)
\(\)
\(\newcommand{\SMTAssertF}{\textsf{assert}}\)
\(\newcommand{\SMTAssert}[1]{\SMTAssertF(#1)}\)
\(\)
\(\newcommand{\UFRoot}{\textit{parent}}\)
\(\newcommand{\UFRootOf}[1]{{#1}.\UFRoot}\)
\(\newcommand{\UFRank}{\textit{rank}}\)
\(\newcommand{\UFRankOf}[1]{{#1}.\UFRank}\)
\(\newcommand{\UFFind}[1]{\textsf{find}(#1)}\)
\(\newcommand{\UFMerge}[2]{\textsf{merge}(#1,#2)}\)
\(\)
\(\newcommand{\CCPending}{\textit{pending}}\)
\(\)
\(\)
\(%\)
\(% Theory solver interface\)
\(%\)
\(\newcommand{\TSinit}[1]{\mathop{init}(#1)}\)
\(\newcommand{\TSassert}[1]{\mathop{assert}(#1)}\)
\(\newcommand{\TSretract}{\mathop{retract}()}\)
\(\newcommand{\TSisSat}{\mathop{isSat}()}\)
\(\newcommand{\TSgetModel}{\mathop{getModel}()}\)
\(\newcommand{\TSgetImplied}{\mathop{getImplied}()}\)
\(\newcommand{\TSexplain}[1]{\mathop{explain}(#1)}\)
\(\)
\(\)
\(\newcommand{\VarsOf}[1]{\mathop{vars}(#1)}\)
\(\)
\(\newcommand{\Dist}[1]{\mathit{dist}(#1)}\)
\(%\newcommand{\Dist}[1]{\mathit{dist}(#1)}\)
\(\)
\(%\)
\(% Nelson-Oppen\)
\(%\)
\(\newcommand{\TComb}{\cup}\)
\(\newcommand{\NOShared}[1]{\mathop{\textrm{shared}}(#1)}\)
\(\newcommand{\NOPart}{P}\)
\(\newcommand{\NOPartI}[1]{P_{#1}}\)
\(%\newcommand{\NOEq}{\mathrel{\approx}}\)
\(%\newcommand{\NOEqNot}{\mathrel{\not\approx}}\)
\(\newcommand{\NOEq}{\mathrel{{\equiv_{P}}}}\)
\(%\newcommand{\NOEq}{\stackrel{\NOPart}{\equiv}}\)
\(\newcommand{\NOEqNot}{\mathrel{\not\equiv_{\NOPart}}}\)
\(%\newcommand{\NOEqNot}{\stackrel{\NOPart}{\not\equiv}}\)
\(\newcommand{\NOArr}{\mathop{arr}(P)}\)
\(\newcommand{\NOArrI}[1]{\mathop{arr}(P_{#1})}\)
\(\)
\(%\)
\(% Example formulas in Nelson-Oppen part\)
\(%\)
\(\newcommand{\NOF}{\phi}\)
\(%\newcommand{\NOFA}{\phi_1}\)
\(%\newcommand{\NOFB}{\phi_2}\)
\(%\newcommand{\NOTA}{\ThI{1}}\)
\(%\newcommand{\NOTB}{\ThI{2}}\)
\(\newcommand{\NOFEUF}{\phi_\mathit{EUF}}\)
\(\newcommand{\NOFLIA}{\phi_\mathit{LIA}}\)
\(\newcommand{\NOFLRA}{\phi_\mathit{LRA}}\)
\(\newcommand{\NOFCons}{\phi_\textup{cons}}\)
\(\)
\(%\newcommand{\Asgn}{\mathrel{:=}}\)
\(\newcommand{\Asgn}{\mathrel{\leftarrow}}\)
\(\)
\(%\newcommand{\Engl}[1]{(engl.\ #1)}\)
\(\)
\(\newcommand{\Ack}[1]{\mathop{ack}(#1)}\)
\(\newcommand{\VVar}[1]{v_{#1}}\)
\(\newcommand{\FVar}[2]{{#1}_{#2}}\)
\(\newcommand{\PVar}[2]{{#1}_{#2}}\)
\(\newcommand{\Flat}{{\phi_\textrm{flat}}}\)
\(\newcommand{\Cong}{{\phi_\textrm{cong}}}\)
\(\)
\(\newcommand{\In}{\mathit{in}}\)
\(\newcommand{\Out}{\mathit{out}}\)
\(\)
\(\newcommand{\SubType}{\FuncName{subtype}}\)
\(\)
\(%\)
\(% Fourier-Motzkin elimination\)
\(%\)
\(\newcommand{\FM}{\phi}\)
\(\newcommand{\FMup}{\phi^\textrm{up}}\)
\(\newcommand{\FMlo}{\phi^\textrm{low}}\)
\(%\newcommand{\FMup}{\phi^{\le}}\)
\(%\newcommand{\FMlo}{\phi^{\ge}}\)
\(\newcommand{\FMindep}{\phi^{\ast}}\)
\(\newcommand{\Nup}{n^\textrm{up}}\)
\(\newcommand{\Nlo}{n^\textrm{low}}\)
\(%\newcommand{\Nup}{n^{\le}}\)
\(%\newcommand{\Nlo}{n^{\ge}}\)
\(\newcommand{\Rup}[1]{A^\textrm{up}_{#1}}\)
\(\newcommand{\Rlo}[1]{A^\textrm{low}_{#1}}\)
\(%\newcommand{\Rup}[1]{A^{\le}_{#1}}\)
\(%\newcommand{\Rlo}[1]{A^{\ge}_{#1}}\)
\(%\newcommand{\FMless}{\mathrel{\triangleleft}}\)
\(%\newcommand{\FMmore}{\mathrel{\triangleright}}\)
\(\)
\(\)
\(\)
\(\newcommand{\ProblemName}[1]{\textup{#1}}\)
\(\newcommand{\ATM}{A_\textup{TM}}\)
\(\newcommand{\PCP}{\ProblemName{PCP}}\)
\(\newcommand{\MPCP}{\ProblemName{MPCP}}\)
\(\newcommand{\PCPAst}{\star}\)
\(\)
\(\newcommand{\Eps}{\varepsilon}\)
\(\)
\(\newcommand{\List}[1]{[#1]}\)
\(\newcommand{\Strings}[1]{\{#1\}^\star}\)
\(\newcommand{\StringsOver}[1]{{#1}^\star}\)
\(\newcommand{\SigmaStrings}{\Sigma^\star}\)
\(\newcommand{\GammaStrings}{\Gamma^\star}\)
\(\newcommand{\Complement}[1]{\overline{#1}}\)
\(\)
\(\)
\(%\)
\(% SSA example\)
\(%\)
\(\newcommand{\In}{\mathit{in}}\)
\(\newcommand{\Out}{\mathit{out}}\)
\(\)
\(%\)
\(%\)
\(%\)
\(\newcommand{\DA}{♠}\)
\(\newcommand{\DB}{♥}\)
\(\newcommand{\DC}{♦}\)
\(\newcommand{\DD}{♣}\)
A Theory Solver for Difference Logic
Recall that the difference logic is a syntactic restriction of
linear arithmetic in which the atoms must be of the form
\[x - y \bowtie c\]
(or, equivalently, \( x \bowtie y + c \)), where \( x \) and \( y \) are variables,
\( c \in \Rats \),
and \( \bowtie \) is \( = \), \( \neq \), \( < \), \( \le \), \( \ge \), or \( > \).
That is, the atoms only restrict the difference between the variables \( x \) and \( y \).
Both integer- and real-valued versions were defined:
\( \RDL \), Real Difference Logic, allows the variables to have real or rational values, while
\( \IDL \), Integer Difference Logic, restricts the values of the variables to be integers.
Example
The formula
$$(x < y + 3) \land (y \le z+2) \land (z < x - 4)$$
is
\( \RDL \)-satisfiable as, for instance, \( \Set{x \mapsto 1.5, y \mapsto -1, z \mapsto -3} \) is a model for it, but
\( \IDL \)-unsatisfiable.
For simplicity, let us consider the integer version \( \IDL \);
we discuss the \( \RDL \) case later in the subsection Handling the real/rational case.
Furthermore, we normalize the atoms in the following way so that the
difference logic solver only has to deal with atoms of the form \( x \le y + k \),
where \( k \) is an integer constant, internally.
First we do the following transformations:
The disequalities \( x \neq y + c \) are rewritten into
\( ((x < y + c) \lor (x > y + c)) \)
in the original formula level.
After this, the SAT-solver part in the DPLL(T) solver takes care of
“case splitting” and selects either (or both) of these atoms to
be given to the difference logic solver.
Similarly,
equalities of the form \( x = y + c \)
are rewritten into \( (x \le y+c)\land(x \ge y + c) \).
After these, the CDCL SAT solver can assert
atoms of the forms \( (x < y + c) \), \( (x \le y + c) \), \( (x \ge y + c) \),
and \( (x > y + c) \) to the integer difference logic solver.
As only atoms of the form \( (x \le y + k) \) for an integer \( k \)
are handled in the underlying algorithm,
the integer difference logic solver transforms the remaining cases to this form, when they asserted, as follows:
\( (x \le y + c) \) becomes \( (x \le y + \Floor{c}) \)
\( (x \ge y + c) \) becomes \( (y \le x + \Floor{-c}) \)
\( (x < y + c) \) becomes \( (x \le y + c - 1) \) if \( c \) is an integer and
\( (x \le y + \Ceil{c}) \) otherwise
\( (x > y + c) \) becomes \( (y \le x - c - 1) \) if \( c \) is an integer and
\( (y \le x + \Ceil{-c}) \) otherwise
From conjunctions to graphs
In our normalized setting described above,
the task of an \( \IDL \)-solver is thus to decide the satisfiability of
conjunctions of the form
\[\phi \Def (x_1 \le y_1 + k_1) \land … \land (x_n \le y_n + k_n)\]
where \( x_i,y_i \) are some variables.
One such solver can be obtained by
associating \( \phi \) to the corresponding constraint graph \( \CG{\phi} \),
which is a directed, edge-weighted graph such that
the vertex set consists of the variables in \( \phi \), and
for each atom \( (x_i \le y_i + k_i) \) in \( \phi \),
\( \CG{\phi} \) has an edge from \( x_i \) to \( y_i \) with the weight \( k_i \).
Such an edge will be denoted by \( {x_i} \DiffEdge{k_i} {y_i} \).
in the following.
A path \( x’_1 \DiffEdge{k’_1} x’_2 … \DiffEdge{k’_m} x’_{m+1} \) for \( m \ge 2 \)
in \( \CG{\phi} \) is a negative cycle if \( x’_{m+1} = x’_1 \) and \( \sum_{1 \le i \le m} k’_i < 0 \).
Theorem
A conjunction \( \phi \) of the normalized form above is satisfiable if and only if
the constraint graph \( \CG{\phi} \) has no negative cycles.
Example: An unsatisfiable conjunction
Consider the conjunction
\begin{eqnarray*}
(x_1 \le x_3 - 6) \land (x_1 \le x_4 - 3) &\land&\\\\
(x_2 \le x_1 + 3) \land (x_3 \le x_2 + 2) &\land&\\\\
(x_3 \le x_4 - 1) \land (x_4 \le x_2 + 5).
\end{eqnarray*}
The constraint graph is
The graph has a negative cycle \( x_1 \to x_3 \to x_2 \to x_1 \).
And in fact the conjunction is unsatisfiable by the following reasoning:
Take the atoms \( (x_1 \le x_3-6) \), \( (x_3 \le x_2+2) \) and \( (x_2 \le x_1+3) \)
corresponding to the edges in the negative cycle.
\( (x_1 \le x_3-6) \land (x_3 \le x_2+2) \) implies \( x_1+6 \le x_3 \le x_2+2 \) and thus \( x_1 \le x_2-4 \).
\( (x_1 \le x_2-4) \land (x_2 \le x_1+3) \) implies \( x_1+4 \le x_2 \le x_1+3 \) and thus \( x_1 \le x_1-1 \) and \( 0 \le -1 \), which is a contradiction.
Example: A satisfiable conjunction
For the conjunction
\begin{eqnarray*}
&&(x_1 \le x_3 - 5) \land (x_1 \le x_4 - 3) \land\\\\
&&(x_2 \le x_1 + 3) \land (x_3 \le x_2 + 2) \land\\\\
&&(x_3 \le x_4 - 1) \land (x_4 \le x_2 + 5)
\end{eqnarray*}
the constraint graph is
The constraint graph has no negative cycles and
in fact
\[\Set{x_1 \mapsto -2, x_2 \mapsto 1, x_3 \mapsto 3, x_4 \mapsto 4}\]
is a model for the conjunction.
Therefore,
in order to decide whether a normalized conjunction \( \phi \) is
\( \IDL \)-satisfiable, we can
build the constraint graph \( \CG{\phi} \), and
check whether \( \CG{\phi} \) has negative cycles.
Detecting negative cycles
How do we detect if a constraint graph has a negative cycle?
One solutions is as follows:
Add an extra “root” vertex \( r \) to \( \CG{\phi} \)
and
an edge with weight \( 0 \) from it to each other vertex.
Run a single-source shortest path algorithm that is capable of
detecting negative cycles for the root node \( r \).
One such negative-cycle deteting single-source shortest-path algorithm
is the Bellman–Ford algorithm
(recall the course CS-A1140 Data Structures and Algorithms).
It works as follows.
Each vertex \( x \) is associated with
an upper bound for the shortest distance \( \Dist{x} \) from the root \( r \) to \( x \), and
a link to the “parent” vertex in a shortest path.
Initially, \( \Dist{r} = 0 \) for the root vertex \( r \) and
\( \Dist{x} = \infty \) for all the other non-root vertices.
After this,
iterate the following \( n \) times to compute the shortest distances:
At the end,
a negative cycle exists if and only if
\( \Dist{x}+k < \Dist{y} \) for some edge \( x \DiffEdge{k} y \).
Of course, the above described algorithm is a basic version,
optimizations do exists.
Example
Consider again the unsatisfiable conjunction
\begin{eqnarray*}
(x_1 \le x_3 - 6) \land (x_1 \le x_4 - 3) &\land&\\\\
(x_2 \le x_1 + 3) \land (x_3 \le x_2 + 2) &\land&\\\\
(x_3 \le x_4 - 1) \land (x_4 \le x_2 + 5).
\end{eqnarray*}
In the beginning, before the first iteration,
the augmented constraint graph is the following,
where the yellow boxes are the current upper bounds
for the shortest distances from the root vertex \( r \).
After the first iteration,
when the edges are relaxed in the lexicographical order,
the distance upper bounds are as in the figure below.
The parent vertex information is visualized by highlighting the edge
whose source is the current parent of the target vertex.
After the second iteration,
the situation is the following:
Finally, after the 5th iteration, the upper bounds are the following:
Now \( \Dist{x_2} + 3 < \Dist{x_1} \) and
thus we have a negative cycle.
We can find one such cycle by performing a depth-first search on the subgraph
induced by the edges corresponding to the parent vertex pointers
(the highlighted egdes in the figure).
Model construction
Assume that we have a satisfiable conjunction (again, in the normalized form).
We can find a model for the conjunction as follows.
Run the Bellman–Ford algorithm on the augmented constraint graph.
As the conjunction is satisfiable,
the constraint graph does not have any negative cycles
and
therefore,
for each vertex \( x \), \( \Dist{x} \) is the minimum distance
from the root node \( r \) to \( x \) when the Bellman–Ford algorithm terminates.
After this, consider any equation \( x_i \le x_j + d_{i,j} \).
It must hold that \( \Dist{x_i}+d_{i,j} \ge \Dist{x_j} \)
because if \( \Dist{x_i}+d_{i,j} < \Dist{x_j} \),
then \( \Dist{x_j} \) would not be the minimum distance from the root vertex.
\( \Dist{x_i}+d_{i,j} \ge \Dist{x_j} \) is equal to
\( \Dist{x_i} \ge \Dist{x_j}-d_{i,j} \),
which in turn equals to \( -\Dist{x_i} \le -\Dist{x_j} + d_{i,j} \).
Thus we get a model for the conjunction by taking
\[x \mapsto -\Dist{x}\]
for each variable \( x \).
Example: A satisfiable conjunction
For the satisfiable conjunction
\begin{eqnarray*}
&&(x_1 \le x_3 - 5) \land (x_1 \le x_4 - 3) \land\\\\
&&(x_2 \le x_1 + 3) \land (x_3 \le x_2 + 2) \land\\\\
&&(x_3 \le x_4 - 1) \land (x_4 \le x_2 + 5)
\end{eqnarray*}
the augmented constraint graph in the beginning is
After the first iteration,
the distance upper bounds are the following:
Now \( w(x_i) + d_{i,j} \ge w(x_j) \) for each edge \( x_i \DiffEdge{d_{i,j}} x_j \)
and the upper bounds are the exact distances.
From the distances,
we get the model \( \Set{x_1 \mapsto 0, x_2 \mapsto 3, x_3 \mapsto 5, x_4 \mapsto 6} \) by using the construction described above.
Theory Implied Literals
Recall that theory implied literals are the literals whose truth value the theory solver
can deduce based on the values of the literals asserted to it earlier.
In the case of difference logic, observe that
\( x \le y + c \) implies \( x \le y + c’ \) for all \( c’ \ge c \), and
\( (x_1 \le x_2 + c_1) \land (x_2 \le x_3 + c_2) \land … \land (x_{n-1} \le x_n + c_{n-1}) \) implies \( x_1 \le x_n + \sum_{1 \le i \le {n-1}}c_i \).
Example
Consider again the satisfiable conjunction of difference logic atoms
\begin{eqnarray*}
\phi &=&(x_1 \le x_3 - 5) \land (x_1 \le x_4 - 3) \land\\\\
&&(x_2 \le x_1 + 3) \land (x_3 \le x_2 + 2) \land\\\\
&&(x_3 \le x_4 - 1) \land (x_4 \le x_2 + 5)
\end{eqnarray*}
Now \( \phi \) implies \( x_1 \le x_2 - 1 \) because
\( (x_1 \le x_3 - 5) \land (x_3 \le x_2 + 2) \) implies
\( (x_1 + 5 \le x_3 \le x_2 + 2) \) and
thus
\( (x_1 \le x_2 - 5 + 2) \) and \( (x_1 \le x_2 - 1) \).
From the above observation, we directly get the following:
Theorem
Given a satisfiable conjunction \( \phi \) and an atom \( x \le y + c \),
$$\phi \IDLEntails (x \le y + c)$$
if and only if
\( \CG{\phi} \) has a path from \( x \) to \( y \) with weight \( c \) or less.
This means that we can find all the implied atoms
by computing all the shortest paths between the vertices in \( \CG{\phi} \).
This can be done with, e.g., the Floyd–Warshall algorithm.
The explanation of an implied atom \( x \le y + c \) is the conjunction
of the atoms corresponding to the shortest path from \( x \) to \( y \).
Handling the real/rational case
So far we assumed integer-valued solutions, i.e., the logic \( \IDL \).
What about \( \RDL \) allowing real-valued solutions?
For that logic, one can use the approach in A. Armando, C. Castellini, E. Giunchiglia, M. Maratea:
A SAT-Based Decision Procedure for the Boolean Combination of Difference Constraints, Proc. SAT 2004, pp 16–29.
The idea is that the “problematic” conjunctions of the form \( x < y + c \)
are rewritten into \( x \le y + c’ \),
where \( c’ = c - \frac{1}{10^p(n^2+1)} \),
\( n \) is the number of variables in the difference logic atoms, and
\( p \) is the maximal number of digits appearing the right-hand side of the decimal points in the constants of the difference logic atoms.
After this, a graph-based algorithm similar to the one described above can be used.
Some further reading
A. Armando, C. Castellini, E. Giunchiglia, M. Maratea:
A SAT-Based Decision Procedure for the Boolean Combination of Difference Constraints, Proc. SAT 2004, pp 16–29
R. Nieuwenhuis and A. Oliveras:
DPLL(T) with Exhaustive Theory Propagation and Its Application to Difference Logic, Proc. CAV 2005, pp. 321–334
S. Cotton and O. Maler:
Fast and Flexible Difference Constraint Propagation for DPLL(T), Proc. SAT 2006, pp 170–183
S. Lahiri, M. Musuvathi: An Efficient Decision Procedure for UTVPI Constraints, Proc. FroCoS 2005, pp 168–183
Negative-cycle detection algorithms: