\documentclass[t]{beamer}
\mode<presentation>

\newcommand{\lecnumber}{10}

\include{cocmacros}
\newcommand{\uuline}[1]{\underline{\underline{#1}}}
\newcommand{\ures}[3]{
  \begin{array}{c@{\hspace*{2em}}c} 
    #1 & #2 \\ \hline \multicolumn{2}{c}{#3} 
  \end{array}}
\newcommand{\uex}{\underline{Example}}
\newcommand{\un}{\underline{Note}}
\newcommand{\utitle}[1]{\underline{#1}\\\smallskip}

\title{\lecnumber. Combining Decision Procedures}
\date{}
\institute[Stanford University]

\begin{document}

\setbeamertemplate{footline}[text line]
{
	%\begin{large}
	\hspace*{\stretch{1}}\lecnumber - \insertframenumber \bigskip
	%\end{large}
}

\begin{frame}[c]
\Large
\textsc{The Calculus of Computation:}\\
Decision Procedures with\\
Applications to Verification

\bigskip
\bigskip
by\\
Aaron Bradley\\
Zohar Manna

\bigskip
\bigskip
Springer 2007
\end{frame}

\begin{frame}
	\titlepage
\end{frame}

\newcommand{\conceptbox}[2]{
  #1
  \hspace*{2em}\begin{minipage}[t]{27em}
  #2
  \end{minipage} \\
}

\begin{frame}
\utitle{Combining Decision Procedures: Nelson-Oppen Method}

\bigskip
\conceptbox{{\bf Given}}{
Theories $T_i$ over \emph{signatures} $\Sigma_i$ \\
(constants, functions, predicates) \\
with corresponding decision procedures $P_i$ for $T_i$-satisfiability.
}

\bigskip
\conceptbox{{\bf Goal}}{
Decide satisfiability of a sentence in theory $\cup_i T_i$.
}

\bigskip
{\bf Example}:
How do we show that
\[
   F:\ 1 \le x\ \wedge\ x \le 2\ \wedge\ f(x) \ne f(1)\ \wedge\ f(x) \ne f(2)
\]
is $(T_E \cup T_\integers)$-unsatisfiable?
\end{frame}

\begin{frame}
\utitle{Combining Decision Procedures}

\begin{center}
\begin{tabular}{l@{\hspace{5em}}l}
   $\Sigma_1$-theory $T_1$ & $\Sigma_2$-theory $T_2$ \\
   \rnode{A}{\fbox{$P_1$} for $T_1$-satisfiability} &
   \rnode{B}{\fbox{$P_2$} for $T_2$-satisfiability} \\ \\ \\
   \multicolumn{2}{c}{?} \\
   \multicolumn{2}{c}{\rnode{C}{\fbox{$P$} for $(T_1 \cup T_2)$-satisfiability}}
\end{tabular}
\end{center}
{\psset{nodesep=3pt}
\ncline{->}{A}{C}
\ncline{->}{B}{C}}

{\bf Problem}: \\
Decision procedures are domain specific. \\
How do we combine them?
\end{frame}

\begin{frame}
\utitle{Nelson-Oppen Combination Method (N-O Method)}

\begin{tabular}{@{}l@{\hspace{4em}}l@{}}
   \\
   \multicolumn{2}{c}{$\Sigma_1 \cap \Sigma_2 = \emptyset$} \\
   \\
   $\Sigma_1$-theory $T_1$ &
   $\Sigma_2$-theory $T_2$ \\
   stably infinite  & stably infinite \\ \\
   \fbox{$P_1$} for $T_1$-satisfiability &
   \fbox{$P_2$} for $T_2$-satisfiability \\
   \rnode{A}{of quantifier-free $\Sigma_1$-formulae} &
   \rnode{B}{of quantifier-free $\Sigma_2$-formulae} \\ \\ \\ \\
   \multicolumn{2}{c}{\rnode{C}{\fbox{$P$} for $(T_1 \cup T_2)$-satisfiability}} \\
   \multicolumn{2}{c}{of quantifier-free $(\Sigma_1 \cup \Sigma_2)$-formulae}
\end{tabular}
{\psset{nodesep=3pt}
\ncline{->}{A}{C}
\ncline{->}{B}{C}}

\end{frame}

\begin{frame}
\utitle{Nelson-Oppen: Limitations}

Given formula $F$ in theory $T_1 \cup T_2$.
\begin{enumerate}
\item $F$ must be quantifier-free.
\item Signatures $\Sigma_i$ of the combined theory \underline{only share $=$}, i.e.,
\[ \Sigma_1 \cap \Sigma_2 = \set{=} \]
\item Theories must be \underline{stably infinite}.
\end{enumerate}

\bigskip
\un:\\
\begin{itemize}
\item Algorithm can be extended to combine arbitrary number of theories $T_i$ ---
combine two, then combine with another, and so on.
\item We restrict $F$ to be conjunctive formula --- otherwise convert to DNF
and check each disjunct.
\end{itemize}
\end{frame}

\begin{frame}
\utitle{Stably Infinite Theories}

A $\Sigma$-theory $T$ is \underline{\emph{stably infinite}} iff

~~for every quantifier-free $\Sigma$-formula $F$:

~~~~~if $F$ is $T$-satisfiable

~~~~~then there exists some $T$-interpretation that satisfies $F$.

\vspace{3ex}

{\bf Example:} $\Sigma$-theory $T$
\[   \Sigma : \{a, b, =\} \]
Axiom\\
\smallskip
\qquad $\forall x.\ x = a\ \vee\ x = b$ \hspace{\stretch{1}}

\bigskip
For every $T$-interpretation $I$, $|D_I| \le 2$ (at most two elements). \\
Hence, $T$ is \emph{not} stably infinite.

\bigskip
{\bf All the other theories mentioned so far are stably infinite.}

\end{frame}

\begin{frame}
\uex: Theory of partial orders\\
\smallskip
$\Sigma$-theory $\tpo$\\
\smallskip
\qquad $\Sigma_\preceq:\ \set{\preceq,\ =}$\\
\smallskip
where $\preceq$ is a binary predicate.

\smallskip
Axioms
\begin{enumerate}
\item $\forall x.\ x \preceq x$ \naxiom{$\preceq$ reflexivity}
\item $\forall x,y.\ x \preceq y \band y \preceq x \bimplies x = y$
\naxiom{$\preceq$ antisymmetry}
\item $\forall x,y,z.\ x \preceq y \band y \preceq z \bimplies x
\preceq z$ \naxiom{$\preceq$ transitivity}
\end{enumerate}

\smallskip
\end{frame}

\begin{frame}
We prove $\tpo$ is stably infinite.\\
\medskip
Consider $\tpo$-satisfiable quantifier-free $\spo$-formula $F$.\\
Consider arbitrary satisfying $\tpo$-interpretation $I: (\idom, \iasgn)$,\\
\quad where $\iasgn$ maps $\preceq$ to $\le_I$.
\begin{itemize}
\item Let $A$ be any infinite set disjoint from $\idom$
\item Construct new interpretation $J: (\Idom{J},\Iasgn{J})$
\begin{itemize}
\item $\Idom{J} = \idom \cup A$
\item $\Iasgn{J} = \set{\preceq \Mapsto \le_J}$, where for $a,b \in
\Idom{J}$,\\
\qquad 
$a \le_J b\ \eqdef\
\left\{\begin{array}{l@{\hspace{3em}}l}
a \le_I b & \mbox{if $a, b \in \idom$} \\
a = b & \mbox{otherwise}
\end{array}\right.$
\end{itemize}
\end{itemize}
$J$ is $\tpo$-interpretation satisfying $F$ with infinite domain.\\
Hence, $\tpo$ is stably infinite.


\end{frame}

\begin{frame}
\uex: Consider quantifier-free conjunctive $(\Sigma_E \cup \sint)$-formula
\[
F:\ 1 \le x \band x \le 2 \band f(x) \ne f(1) \band f(x) \ne f(2)~.
\]
The signatures of $T_E$ and $\tint$ only share $=$.  Also, both
theories are stably infinite.  Hence, the NO combination of the
decision procedures for $T_E$ and $\tint$ decides the $(T_E \cup
\tint)$-satisfiability of $F$.

\bigskip
Intuitively, $F$ is $(T_E \cup \tint)$-unsatisfiable.\\
For the first two literals imply $x = 1 \bor x = 2$ so that $f(x) = f(1) \bor f(x) = f(2)$.\\
Contradict last two literals.\\
Hence, $F$ is $(T_E \cup \tint)$-unsatisfiable.

\end{frame}

\newcommand{\separate}{$\langle \Sigma_1, \Sigma_2 \rangle$-separate}
\newcommand{\shared}{{\sf shared}}
\newcommand{\variables}{{\sf vars}}

\begin{frame}
\utitle{N-O Overview}

Phase 1: Variable Abstraction
\begin{itemize}
\item Given conjunction $\Gamma$ in theory $T_1 \cup T_2$.
\item Convert to conjunction $\Gamma_1 \cup \Gamma_2$ s.t.
\begin{itemize}
\item $\Gamma_i$ in theory $T_i$
\item $\Gamma_1 \cup \Gamma_2$ satisfiable iff $\Gamma$ satisfiable.
\end{itemize}
\end{itemize}

Phase 2: Check
\begin{itemize}
\item If there is some set $S$ of equalities and disequalities between
the shared variables of $\Gamma_1$ and $\Gamma_2$ \\
$\shared(\Gamma_1, \Gamma_2) =
\freev(\Gamma_1) \cap \freev(\Gamma_2)$ \\
s.t. $S \cup \Gamma_i$ are $T_i$-satisfiable for all $i$, \\
then $\Gamma$ is {\bf satisfiable}.
\item Otherwise, {\bf unsatisfiable}.
\end{itemize}
\end{frame}

\begin{frame}
\utitle{Nelson-Oppen Method: Overview}

Consider quantifier-free conjunctive $(\Sigma_1 \cup \Sigma_2)$-formula $F$.\\

\smallskip
Two versions:
\begin{itemize}
\item \underline{nondeterministic} --- simple to present, but high complexity
\item \underline{deterministic} --- efficient
\end{itemize}

\smallskip
Nelson-Oppen (N-O) method proceeds in two steps:
\begin{itemize}
\item \underline{Phase 1} (variable abstraction)\\
--- same for both versions
\item \underline{Phase 2}\\
nondeterministic: guess equalities/disequalities and check\\
deterministic: generate equalities/disequalities by equality propagation
\end{itemize}
\end{frame}

\begin{frame}
\utitle{Phase 1: Variable abstraction}

Given quantifier-free conjunctive  $(\Sigma_1 \cup \Sigma_2)$-formula $F$.\\
Transform $F$ into two quantifier-free conjunctive formulae\\
\smallskip
\qquad $\Sigma_1$-formula $F_1$ \qquad and \qquad $\Sigma_2$-formula $F_2$\\
\smallskip
s.t. $F$ is $(T_1 \cup T_2)$-satisfiable iff $F_1 \band F_2$ is $(T_1 \cup T_2)$-satisfiable\\
$F_1$ and $F_2$ are linked via a set of shared variables.

\bigskip
For term $t$, let $\thd(t)$ be the root symbol, e.g. $\thd(f(x)) = f$.

\end{frame}

\begin{frame}
\utitle{Generation of $F_1$ and $F_2$}
For $i,j \in \set{1,2}$ and $i \ne j$, repeat the transformations
\begin{enumerate}
\item[(1)] if function $f \in \Sigma_i$ and $\thd(t) \in \Sigma_j$,
\[
F[f(t_1,\ldots,t,\ldots,t_n)]
\quad\Rightarrow\quad
F[f(t_1,\ldots,w,\ldots,t_n)] \band w = t
\]
\item[(2)] if predicate $p \in \Sigma_i$ and $\thd(t) \in \Sigma_j$,
\[
F[p(t_1,\ldots,t,\ldots,t_n)]
\quad\Rightarrow\quad
F[p(t_1,\ldots,w,\ldots,t_n)] \band w = t
\]
\item[(3)] if $\thd(s) \in \Sigma_i$ and $\thd(t) \in \Sigma_j$,
\[
F[s = t]
\quad\Rightarrow\quad
F[\true] \band w = s \band w = t
\]
\item[(4)] if $\thd(s) \in \Sigma_i$ and $\thd(t) \in \Sigma_j$,
\[
F[s \ne t]
\quad\Rightarrow\quad
F[w_1 \ne w_2] \band w_1 = s \band w_2 = t
\]
\end{enumerate}
where $w$, $w_1$, and $w_2$ are fresh variables.

\end{frame}

\begin{frame}
\uex: Consider $(\Sigma_E \cup \sint)$-formula
\[
F:\ 1 \le x \band x \le 2 \band f(x) \ne f(1) \band f(x) \ne f(2)~.
\]
According to transformation 1, since $f \in \Sigma_E$ and $1 \in
\Sigma_\integers$, replace $f(1)$ by $f(w_1)$ and add $w_1 = 1$.
Similarly, replace $f(2)$ by $f(w_2)$ and add $w_2 = 2$.

Now, the literals
\[
\Gamma_\integers:\ \set{1 \le x,\ x \le 2,\ w_1 = 1,\ w_2 = 2}
\]
are $\tint$-literals, while the literals
\[
\Gamma_E:\ \set{f(x) \ne f(w_1),\ f(x) \ne f(w_2)}
\]
are $T_E$-literals.  Hence, construct the $\sint$-formula
\[
F_1:\ 1 \le x \band x \le 2 \band w_1 = 1 \band w_2 = 2
\]
and the $\Sigma_E$-formula
\[
F_2:\ f(x) \ne f(w_1) \band f(x) \ne f(w_2)~.
\]
$F_1$ and $F_2$ share the variables $\set{x,w_1,w_2}$.\\
$F_1 \band F_2$ is $(T_E \cup \tint)$-equisatisfiable to $F$.

\end{frame}

\begin{frame}
\uex: Consider $(\Sigma_E \cup \sint)$-formula
\[
F:\ f(x) = x + y \band x \le y + z \band x + z \le y \band y = 1 \band f(x) \ne f(2)~.
\]
In the first literal, $\thd(f(x)) = f \in \Sigma_\equ$ and $\thd(x+y)
= + \in \Sigma_\integers$; thus, by (3), replace the
literal with\\
\smallskip
\qquad $w_1 = f(x) \band w_1 = x + y~.$\\
\smallskip
In the final literal, $f \in \Sigma_E$ but
$2 \in \sint$, so by (1), replace it with\\
\smallskip
\qquad $f(x) \ne f(w_2) \band w_2 = 2~.$\\
\smallskip
Now, separating the literals results in two formulae:\\
\smallskip
\qquad $F_1:\ w_1 = x + y \band x \le y + z \band x + z \le y \band y = 1 \band w_2 = 2$\\
\smallskip
is a $\sint$-formula, and\\
\smallskip
\qquad $F_2:\ w_1 = f(x) \band f(x) \ne f(w_2)$\\
\smallskip
is a $\Sigma_E$-formula.\\
The conjunction $F_1 \band F_2$ is $(T_E \cup
\tint)$-equisatisfiable to $F$.

\end{frame}

\begin{frame}
\frametitle{Nondeterministic Version}
\utitle{Phase 2: Guess and Check}
\begin{itemize}
\item Phase 1 \underline{separated} $(\Sigma_1 \cup \Sigma_2)$-formula $F$ into two
formulae:\\
\qquad $\Sigma_1$-formula $F_1$ and $\Sigma_2$-formula $F_2$

\item $F_1$ and $F_2$ are linked by a set of \underline{shared variables}:\\
\qquad $V = \sharedv(F_1,F_2) = \freev(F_1) \cap \freev(F_2)$

\item Let $E$ be an \underline{equivalence relation} over $V$.
\item The \underline{arrangement} $\alpha(V,E)$ of $V$ induced by $E$ is:\\
\qquad $\displaystyle
\alpha(V,E):\
\bigwedge_{u,v\ \in\ V.\ uEv} u = v
\band
\bigwedge_{u,v\ \in\ V.\ \bnot(uEv)} u \ne v$
\end{itemize}
\uuline{Then},\\
the original formula $F$ is $(T_1 \cup T_2)$-satisfiable iff\\
\underline{there exists} an equivalence relation $E$ of $V$ s.t.\\
\quad (1) $F_1 \band \alpha(V,E)$ is $T_1$-satisfiable, \underline{and}\\
\quad (2) $F_2 \band \alpha(V,E)$ is $T_2$-satisfiable.\\
Otherwise, $F$ is $(T_1 \cup T_2)$-unsatisfiable.

\end{frame}

\begin{frame}
\uex: Consider $(\Sigma_E \cup \sint)$-formula\\
\qquad $F:\ 1 \le x \band x \le 2 \band f(x) \ne f(1) \band f(x) \ne f(2)$\\
\smallskip
Phase 1 separates this formula into the $\sint$-formula\\
\qquad $F_1:\ 1 \le x \band x \le 2 \band w_1 = 1 \band w_2 = 2$\\
\smallskip
and the $\Sigma_E$-formula\\
\qquad $F_2:\ f(x) \ne f(w_1) \band f(x) \ne f(w_2)$\\
with\\
\qquad $V = \sharedv(F_1,F_2) = \set{x,w_1,w_2}$\\
\smallskip
There are $5$ equivalence relations to consider, which we list by
stating the partitions:
\end{frame}

\begin{frame}
\begin{enumerate}
\item $\set{\set{x,w_1,w_2}}$, \ie, $x = w_1 = w_2$:\\
\mbox{$x = w_1$ and $f(x) \ne f(w_1) \Bimplies F_2 \band \alpha(V,E)$ is $T_E$-unsatisfiable.}
\item $\set{\set{x,w_1},\set{w_2}}$, \ie, $x = w_1$, $x \ne w_2$:\\
\mbox{$x = w_1$ and $f(x) \ne f(w_1) \Bimplies F_2 \band \alpha(V,E)$ is $T_E$-unsatisfiable.}
\item $\set{\set{x,w_2},\set{w_1}}$, \ie, $x = w_2$, $x \ne w_1$:\\
\mbox{$x = w_2$ and $f(x) \ne f(w_2) \Bimplies F_2 \band \alpha(V,E)$ is $T_E$-unsatisfiable.}
\item $\set{\set{x},\set{w_1,w_2}}$, \ie, $x \ne w_1$, $w_1 = w_2$:\\
$w_1 = w_2$ and $w_1 = 1 \band w_2 = 2$\\
$\Bimplies F_1 \band \alpha(V,E)$ is $\tint$-unsatisfiable.
\item $\set{\set{x},\set{w_1},\set{w_2}}$, \ie, $x \ne w_1$, $x \ne
  w_2$, $w_1 \ne w_2$:\\
$x \ne w_1 \band x \ne w_2$ and $x = w_1 = 1 \bor x = w_2 = 2$\\
 (since $1 \le x \le 2$ implies that $x = 1 \bor x = 2$ in $\tint$) 
$\Bimplies F_1 \band \alpha(V,E)$ is $\tint$-unsatisfiable.
\end{enumerate}
Hence, $F$ is $(T_E \cup \tint)$-unsatisfiable.
\end{frame}

\begin{frame}
\uex: Consider the $(\scons \cup \sint)$-formula
\[
F:\ \car(x) + \car(y) = z \band \cons(x,z) \ne \cons(y,z)~.
\]
After two applications of (1), Phase 1 separates $F$ into
the $\scons$-formula\\
\qquad $F_1:\ w_1 = \car(x) \band w_2 = \car(y) \band \cons(x,z) \ne \cons(y,z)$\\
\smallskip
and the $\sint$-formula\\
\qquad $F_2:\ w_1 + w_2 = z~,$\\
\smallskip
with\\
\qquad $V = \sharedv(F_1,F_2) = \set{z,w_1,w_2}~.$\\
\smallskip
Consider the equivalence relation $E$ given by the partition\\
\qquad $\set{\set{z},\set{w_1},\set{w_2}}~.$\\
\smallskip
The arrangement\\
\qquad $\alpha(V,E):\ z \ne w_1 \band z \ne w_2 \band w_1 \ne w_2$\\
\smallskip
satisfies both $F_1$ and $F_2$: $F_1 \band \alpha(V,E)$ is
$\tcons$-satisfiable, and $F_2 \band \alpha(V,E)$ is
$\tint$-satisfiable.

Hence, $F$ is $(\tcons \cup \tint)$-satisfiable.

\end{frame}

\begin{frame}
\utitle{Practical Efficiency}

Phase 2 was formulated as ``guess and check'':\\
First, guess an equivalence relation $E$,\\
then check the induced arrangement.

\bigskip
The number of equivalence relations grows super-exponentially
with the \# of shared variables.  
It is given by \underline{Bell numbers}.\\
e.g., $12$ shared variables $\Bimplies$ over four million equivalence relations.

\bigskip
\underline{Solution}: Deterministic Version

\end{frame}

\begin{frame}
\frametitle{Deterministic Version}
\underline{Phase 1} as before\\
\underline{Phase 2} asks the decision procedures $P_1$ and $P_2$ to propagate new equalities.

\smallskip
\utitle{Example 1:}

\begin{center}
\begin{tabular}{c@{\hspace{6em}}c}
   Real linear arithmethic $\talg$ & Theory of equality $T_E$ \\
   \fbox{$P_\reals$} & \fbox{$P_E$}
\end{tabular}
\end{center}

\begin{equation*}
   F: \quad f(f(x){-}f(y)) \neq f(z)\ \wedge\
               x \le y\ \wedge\ y + z \le x\ \wedge\ 0 \le z
\end{equation*}

\begin{center}
$(\talg \cup T_E)$-unsatisfiable
\end{center}

Intuitively,\\
last 3 conjuncts $\Bimplies x=y \band z=0$\\
contradicts 1st conjunct
\end{frame}

\begin{frame}
\utitle{Phase 1: Variable Abstraction}
\[
F:\ f(f(x) - f(y)) \ne f(z)\ \wedge\ x \le y\ \wedge\ y + z \le x\
\wedge\ 0 \le z
\]
\[
f(x)\ \Rightarrow\ u ~~~~~ f(y)\ \Rightarrow\ v ~~~~~ u - v\ \Rightarrow\ w
\]

\begin{align*}
\Gamma_E &: \quad \set{f(w) \neq f(z),\ u = f(x),\ v = f(y)}
          &\ldots T_E\text{-formula}\\[2ex]
\Gamma_\reals &: \quad \set{x \le y,\  y + z \le x,\ 0 \le z,\ w = u - v}
          &\ldots\talg\text{-formula}
\end{align*}
\begin{equation*}
\shared(\Gamma_\reals, \Gamma_E) = \{x, y, z, u, v, w\}
\end{equation*}

Nondeterministic version --- over 200 $E$s! \\
Let's try the deterministic version.

\end{frame}

\newcommand{\retuple}[1]{\tuple{\Gamma_\reals, \Gamma_E, \set{#1}}}
\begin{frame}

\utitle{Phase 2: Equality Propagation}

\[
\renewcommand{\arraystretch}{1.2}
\begin{array}{l@{\hspace{5em}}c@{\hspace{5em}}r}
\fbox{$P_\reals$} &
\rnode{0}{s_0: \retuple{}} &
\fbox{$P_E$} \\

\multicolumn{3}{l}{\Gamma_\reals \models x = y} \\

&
\rnode{1}{s_1: \retuple{x = y}}
& \\

\multicolumn{3}{r}{\Gamma_E \cup \set{x = y} \models u = v} \\

&
\rnode{2}{s_2: \retuple{x = y, u = v}}
& \\

\multicolumn{3}{l}{\Gamma_\reals \cup \set{u = v} \models z = w} \\

&
\rnode{3}{s_3: \retuple{x = y, u = v, z = w}}
& \\

\multicolumn{3}{r}{\Gamma_E \cup \set{z = w} \models \falsev} \\

&
\rnode{4}{s_4: \falsev}

\ncline{-}{0}{1}
\ncline{-}{1}{2}
\ncline{-}{2}{3}
\ncline{-}{3}{4}
\end{array}
\]
Contradiction. Thus, $F$ is $(T_\reals \cup T_E)$-unsatisfiable. \\
If there were no contradiction, $F$ would be $(T_\reals \cup T_E)$-satisfiable.


\end{frame}

\begin{frame}
\utitle{Convex Theories}

\fbox{
\begin{minipage}{.95\textwidth}
{\bf Claim}: \\
Equality propagation is a decision procedure for convex theories.
\end{minipage}}

{\vspace{2ex}}

{\bf Def.} A $\Sigma$-theory $T$ is \emph{convex} iff

\hspace*{1.5em}for every quantifier-free conjunction $\Sigma$-formula $F$\\
\hspace*{1.5em}and for every disjunction $\displaystyle
\bigvee_{i=1}^n (u_i = v_i)$

\hspace*{3em}if $\displaystyle F ~\models~
\bigvee_{i=1}^n (u_i = v_i)$

\hspace*{3em}then $F ~\models~ u_i = v_i$,~ for some
$i \in \{1, \ldots, n\}$

\end{frame}

\begin{frame}
\utitle{Convex Theories}

\begin{itemize}
\item $T_E$, $\talg$, $\trat$, $\tcons$ are convex

\item $T_\integers, \tarr$ are not convex
\end{itemize}

{\vspace{2ex}}

\uex: $T_\integers$ is not convex

\smallskip
Consider quantifier-free conjunctive
\begin{equation*}
F: \quad 1 \le z ~\sband~ z \le 2 ~\sband~ u =1 ~\sband~ v = 2
\end{equation*}
Then
\begin{equation*}
F\ \models\ z = u \lor z= v
\end{equation*}
but
\begin{align*}
F\ &\not\models\ z =u \\
F\ &\not\models\ z =v
\end{align*}

\end{frame}

\begin{frame}
\uex:\\
\smallskip
The theory of arrays $\tarr$ is not convex.\\
Consider the quantifier-free conjunctive $\sarr$-formula
\[
F:\ \ard{\awt{a}{i}{v}}{j} = v~.
\]
Then
\[
F \Bimplies i = j \bor \ard{a}{j} = v~,
\]
but 
\[
\begin{array}{l}
F \not\Rightarrow i = j\\
F \not\Rightarrow \ard{a}{j} = v~.
\end{array}
\]
\end{frame}

\begin{frame}
\utitle{What if $T$ is Not Convex?}

Case split when:
\begin{equation*}
   \Gamma \models \bigvee_{i=1}^n (u_i = v_i)
\end{equation*}
but
\begin{align*}
   \Gamma \not\models u_i = v_i &&\text{for all } i = 1, \ldots, n
\end{align*}

\begin{itemize}
\item For each $i = 1, \ldots, n$, construct a branch on which \\
$u_i = v_i$ is assumed.
\item If \underline{all} branches are contradictory, then {\bf unsatisfiable}. \\
Otherwise, {\bf satisfiable}.
\end{itemize}
\[
\begin{array}{c@{\hspace{6em}}c@{\hspace{6em}}c}
& \rnode{0}{\cdot} \\
\\
\\
\rnode{1}{\vdots} &
\rnode{2}{\vdots} &
\rnode{3}{\vdots}

\ncline{0}{1}
\nbput{u_1 = v_1}
\ncline{0}{2}
\ncput*{u_i = v_i}
\ncline{0}{3}
\naput{u_n = v_n}
\end{array}
\]

\end{frame}

\begin{frame}
\utitle{Example 2: Non-Convex Theory}

\renewcommand{\arraystretch}{1}
\begin{tabular}{c@{\hspace{17em}}c}
$T_\integers$ not convex! & $T_E$ convex \\
\fbox{$P_\integers$} & \fbox{$P_E$}
\end{tabular}
\[
\Gamma:\
\left\{\begin{array}{ll}
1 \le x, &
x \le 2, \\
f(x) \ne f(1), &
f(x) \ne f(2)
\end{array}\right\}
~~~ \mbox{in $T_\integers \cup T_E$}
\]
\begin{itemize}
\item Replace $f(1)$ by $f(w_1)$, and add $w_1 = 1$.
\item Replace $f(2)$ by $f(w_2)$, and add $w_2 = 2$.
\end{itemize}

\medskip
Result:

\begin{tabular}{ccc}
$\Gamma_\integers = \left\{\begin{array}{l}
1 \le x, \\
x \le 2, \\
w_1 = 1, \\
w_2 = 2
\end{array}\right\}$
& and &
$\Gamma_E = \left\{\begin{array}{l}
f(x) \ne f(w_1), \\
f(x) \ne f(w_2)
\end{array}\right\}$
\end{tabular}

\medskip
$\shared(\Gamma_\integers, \Gamma_E) = \set{x, w_1, w_2}$


\end{frame}

\newcommand{\zetuple}[1]{\tuple{\Gamma_\integers, \Gamma_E, \set{#1}}}
\begin{frame}

\utitle{Example 2: Non-Convex Theory}
\[
\renewcommand{\arraystretch}{1.2}
\begin{array}{cc}
\multicolumn{2}{c}{\rnode{0}{s_0: \zetuple{}}} \\
\multicolumn{2}{c}{\star}
\\ \\
\rnode{1}{s_1: \zetuple{x = w_1}} &
\rnode{3}{s_3: \zetuple{x = w_2}} \\
\\ \\
\rnode{2}{s_2: \false} &
\rnode{4}{s_4: \false}

\ncline{0}{1}
\ncput*{x = w_1}
\ncline{1}{2}
\tlput{\Gamma_E \cup \set{x = w_1} \models \false}
\ncline{0}{3}
\ncput*{x = w_2}
\ncline{3}{4}
\trput{\Gamma_E \cup \set{x = w_2} \models \false}

\end{array}
\]
$\star:\ \Gamma_\integers \models x = w_1\ \vee\ x = w_2$

\bigskip
All leaves are labeled with $\false$ $\Rightarrow$ $\Gamma$ is
$(T_\integers \cup T_E)$-unsatisfiable.


\end{frame}

\begin{frame}
\utitle{Example 3: Non-Convex Theory}
\renewcommand{\arraystretch}{1}
\[
\Gamma:\
\left\{\begin{array}{c}
1 \le x, \quad x \le 3, \\
f(x) \ne f(1),\ f(x) \ne f(3),\ f(1) \ne f(2)
\end{array}\right\}
~~~ \mbox{in $T_\integers \cup T_E$}
\]
\begin{itemize}
\item Replace $f(1)$ by $f(w_1)$, and add $w_1 = 1$.
\item Replace $f(2)$ by $f(w_2)$, and add $w_2 = 2$.
\item Replace $f(3)$ by $f(w_3)$, and add $w_3 = 3$.
\end{itemize}

\bigskip
Result:

\begin{tabular}{ccc}
$\Gamma_\integers = \left\{\begin{array}{l}
1 \le x, \\
x \le 3, \\
w_1 = 1, \\
w_2 = 2, \\
w_3 = 3
\end{array}\right\}$
& and &
$\Gamma_E = \left\{\begin{array}{l}
f(x) \ne f(w_1), \\
f(x) \ne f(w_3), \\
f(w_1) \ne f(w_2)
\end{array}\right\}$
\end{tabular}

\medskip
$\shared(\Gamma_\integers, \Gamma_E) = \set{x, w_1, w_2, w_3}$


\end{frame}

\begin{frame}
\utitle{Example 3: Non-Convex Theory}
\[
\hspace*{-1.8ex}
\renewcommand{\arraystretch}{1.3}
\begin{array}{@{}ccc@{}}
\multicolumn{3}{c}{\rnode{0}{s_0: \zetuple{}}} \\
& ~~\star
\\ \\
\rnode{1}{s_1: \zetuple{x = w_1}} &
\rnode{3}{s_3: \zetuple{x = w_2}} &
\rnode{5}{s_5: \zetuple{x = w_3}} \\
\\ \\
\rnode{2}{s_2: \false} &&
\rnode{6}{s_6: \false}

\ncline{0}{1}
\ncput*{x = w_1}
\ncline{1}{2}
\trput{\Gamma_E \cup \set{x = w_1} \models \false}

\ncline{0}{3}
\ncput*{x = w_2}

\ncline{0}{5}
\ncput*{x = w_3}
\ncline{5}{6}
\tlput{\Gamma_E \cup \set{x = w_3} \models \false}

\end{array}
\]
$\star:\ \Gamma_\integers \models x = w_1\ \vee\ x = w_2\ \vee\ x = w_3$ \\

\bigskip
No more equations on middle leaf $\Rightarrow$ $\Gamma$ is
$(T_\integers \cup T_E)$-satisfiable.

\end{frame}


\end{document}
