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

\newcommand{\lecnumber}{1}

\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}}

\title{\lecnumber. Propositional Logic(PL)}
\date{}
\institute[Stanford University]

\begin{document}

\setbeamertemplate{footline}[text line]
{
	\normalsize\hspace*{\stretch{1}}\lecnumber - \insertframenumber
}

\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}[c]
	\bigskip
	\bigskip
	\bigskip
	\bigskip
	\center{{\Large Part I: FOUNDATIONS}}\\
	\titlepage
\end{frame}

\begin{frame}
\frametitle{Propositional Logic(PL)}
{\Large PL Syntax}

\medskip
\begin{tabular}{ll}
	{\underline{Atom}} & \underline{truth symbols} $\true$(``true'') and $\false$(``false'')\\
	& \underline{propositional variables} $P, Q, R, P_1, Q_1, R_1, \cdots$\\
	\underline{Literal} & atom $\alpha$ or its negation $\neg \alpha$\\
	\underline{Formula} & literal or application of a\\
	& \underline{logical connective} to formulae $F, F_1, F_2$\\
	& \begin{tabular}{lll}
		$\neg F$ & ``not'' & (negation)\\
		$F_1 \band F_2$ & ``and'' & (conjunction)\\
		$F_1 \bor F_2$ & ``or'' & (disjunction)\\
		$F_1 \bimplies F_2$ & ``implies'' & (implication)\\
		$F_1 \biff F_2$ & ``if and only if'' & (iff)
	\end{tabular}
\end{tabular}
\end{frame}

\begin{frame}
\frametitle{}
\underline{Example}:\\
\medskip
\begin{tabular}{l}
formula $F: (P \band Q) \bimplies (\true \bor \neg Q)$\\
atoms: $P, Q, \true$\\
literal: $\neg Q$\\
subformulas: $P \band Q,\quad \true \bor \neg Q$\\
abbreviation\\
\qquad $F: P \band Q \bimplies \true \bor \neg Q$
\end{tabular}
\end{frame}

\begin{frame}[shrink]
\frametitle{PL Semantics (meaning)}
\begin{tabular}{@{}lc}
Sentence $F$ + Interpretation $I$ = & Truth value\\
& (true, false)
\end{tabular}

Interpretation
$$I: \set{P \mapsto \truev, Q \mapsto \falsev, \cdots}$$

Evaluation of $F$ under $I$:\\
\smallskip
\qquad\begin{tabular}{ll}
	\begin{tabular}{c||c}
	$F$ & $\neg F$\\
	\hline \hline
	0 & 1\\
	1 & 0\\
	\end{tabular}
&
	\begin{tabular}{l@{\hspace*{0.5em}}c@{\hspace*{0.5em}}c@{\hspace*{0.5em}}c}
	where & 0 & corresponds to value & false\\
	& 1 & & true
	\end{tabular}
\end{tabular}
\[
\begin{array}{c|c||c|c|c|c}
F_1 & F_2 & F_1 \band F_2 & F_1 \bor F_2 & F_1 \bimplies F_2 & F_1 \biff F_2\\
\hline \hline
0 & 0 & 0 & 0 & 1 & 1\\
0 & 1 & 0 & 1 & 1 & 0\\
\hline
1 & 0 & 0 & 1 & 0 & 0\\
1 & 1 & 1 & 1 & 1 & 1
\end{array}
\]
\end{frame}

\begin{frame}
\underline{Example}:\\
\medskip
\qquad $F: P \band Q \bimplies P \bor \neg Q$\\
\qquad $I: \set{P \mapsto \truev, Q \mapsto \falsev}$\\
\[
\begin{array}{|c|c||c|c|c|c|}
\hline
P & Q & \neg Q & P \band Q & P \bor \neg Q & F\\
\hline \hline
1 & 0 & 1 & 0 & 1 & 1\\
\hline
\end{array}
\]
\center{1 = true \qquad\qquad 0 = false}\\
\medskip
\qquad $F$ evaluates to $\truev$ under $I$
\end{frame}

\begin{frame}
\frametitle{Inductive Definition of PL's Semantics}

\begin{tabular}{@{\qquad}rccl}
$I\Models F$ & if $F$ evaluates to & true & under $I$\\
$I\Nmodels F$ & & false &\\
\end{tabular}

\medskip
\underline{Base Case}:\\
\qquad $I \Models \true$\\
\qquad $I \Nmodels \false$\\
\smallskip
\qquad $I \Models P$ \quad iff \quad $I[P] = \truev$\\
\qquad $I \Nmodels P$ \quad iff \quad $I[P] = \falsev$\\

\medskip
\underline{Inductive Case}:\\
\begin{tabular}{@{\qquad}ll}
$I \Models \bnot F$ & iff $I \Nmodels F$ \\
$I \Models F_1 \band F_2$ & iff $I \Models F_1$ and $I \Models F_2$ \\
$I \Models F_1 \bor F_2$ & iff $I \Models F_1$ or $I \Models F_2$ \\
$I \Models F_1 \bimplies F_2$ & iff, if $I \Models F_1$ then $I \Models F_2$ \\
$I \Models F_1 \biff F_2$ & iff, $I \Models F_1 $ and $ I \Models F_2$,\\ 
&\ \ \ \ or $ I \Nmodels F_1 $ and $ I \Nmodels F_2$
\end{tabular}

\medskip
\underline{Note}:\\
\qquad $I \Nmodels F_1 \bimplies F_2$ \quad iff \quad $I \Models F_1$ and $I \Nmodels F_2$

\end{frame}

\begin{frame}
\underline{Example}:
\[
F:\ P \band Q \bimplies P \bor \bnot Q
\]
\[
I:\ \set{P \Mapsto \truev,\ Q \Mapsto \falsev}
\]
\[
\begin{nsemantics}
1. & I & \Models & P & \mbox{since $I[P] = \truev$} \\
2. & I & \Nmodels & Q & \mbox{since $I[Q] = \falsev$} \\
3. & I & \Models & \bnot Q & \mbox{by 2 and $\bnot$} \\
4. & I & \Nmodels & P \band Q & \mbox{by 2 and $\band$} \\
5. & I & \Models & P \bor \bnot Q & \mbox{by 1 and $\bor$} \\
6. & I & \Models & F & \mbox{by 4 and $\bimplies$\qquad Why?}
\end{nsemantics}
\]
\quad Thus, $F$ is true under $I$.
\end{frame}

\begin{frame}
\frametitle{Satisfiability and Validity}
$F$ \underline{satisfiable} iff there exists an interpretation $I$ such that $I\Models F$.
$F$ \underline{valid} iff for all interpretations $I$, $I\Models F$.
\begin{center}\fbox{$F$ is valid iff $\neg F$ is unsatisfiable}\end{center}

\uuline{Method 1: Truth Tables}\\
\smallskip
\underline{Example}\qquad$F: P \band Q \bimplies P \bor \neg Q$\\
\smallskip
\qquad\begin{tabular}{|c|c|c|c||c|}
\hline
$P\ Q$ & $P\band Q$ & $\neg Q$ & $P \bor \neg Q$ & $F$\\
\hline \hline
0\ \ 0 & 0 & 1 & 1 & 1\\
0\ \ 1 & 0 & 0 & 0 & 1\\
\hline
1\ \ 0 & 0 & 1 & 1 & 1\\
1\ \ 1 & 1 & 0 & 1 & 1\\
\hline
\end{tabular}\\
\bigskip
\quad Thus $F$ is valid.
\end{frame}

\begin{frame}
\underline{Example}\qquad$F: P \bor Q \bimplies P \band Q$\\
\smallskip
\qquad\begin{tabular}{|c|c|c||c|l}
\cline{1-4}
$P\ Q$ & $P\bor Q$ & $P \band Q$ & $F$ &\\
\cline{1-4} \cline{1-4}
0\ \ 0 & 0 & 0 & 1 & $\leftarrow$ satisfying $I$ \\
0\ \ 1 & 1 & 0 & 0 & $\leftarrow$ falsifying $I$ \\
\cline{1-4}
1\ \ 0 & 1 & 0 & 0 & \\
1\ \ 1 & 1 & 1 & 1 & \\
\cline{1-4}
\end{tabular}\\
\bigskip
\quad Thus $F$ is satisfiable, but invalid.
\end{frame}

\begin{frame}[shrink=5]
\uuline{Method 2: Semantic Argument}\\
Proof rules
\begin{footnotesize}
\[
\begin{array}{c@{\hspace{2em}}c}
\bigskip
  \prule{
    I \Models \sbnot F
  }{
    I \Nmodels F
  }
  &
  \prule{
    I \Nmodels \sbnot F
  }{
    I \Models F
  }
\\
\bigskip
  \begin{array}{@{}l@{}}
    \begin{array}{@{}l@{}} I \Models F \sband G \end{array} \\
    \hline
    \begin{array}{@{}l@{}} I \Models F \\
    I \Models G
    \end{array} \ \leftarrow $and$
  \end{array}
  &
  \begin{array}{@{}c@{}}
    \begin{array}{@{}c@{}} I \Nmodels F \sband G \end{array} \\
    \hline
    \begin{array}{@{}c@{\hspace{1em}|\hspace{1em}}c@{}} I \Nmodels F & I \Nmodels G \end{array}\\
	{\hspace*{1.5em}}^\nwarrow $or$
  \end{array}
\\
\bigskip
  \pbrule{
    I \Models F \sbor G
  }{
    I \Models F & I \Models G
  }
  &
  \prule{
    I \Nmodels F \sbor G
  }{
    I \Nmodels F \\
    I \Nmodels G
  }
\\
\bigskip
  \pbrule{
    I \Models F \sbimplies G
  }{
    I \Nmodels F & I \Models G
  }
  &
  \prule{
    I \Nmodels F \sbimplies G
  }{
    I \Models F \\
    I \Nmodels G
  }
\\
\bigskip
  \pbrule{
    I \Models F \sbiff G
  }{
    I \Models F \sband G & I \Nmodels F \sbor G
  }
  &
  \pbrule{
    I \Nmodels F \sbiff G
  }{
    I \Models F \sband \sbnot G & I \Models \sbnot F \sband G
  }
\\
\bigskip
	\prule{
	  I \Models F \\
	  I \Nmodels F
	}{
	  I \Models \false
	}
\end{array}
\]
\end{footnotesize}
\end{frame}

\begin{frame}
\underline{Example 1}: Prove\\
\bigskip
\qquad\qquad\qquad$F:\ P \band Q \bimplies P \bor \bnot Q$ \quad is valid.\\
\bigskip
Let's assume that $F$ is not valid and that $I$ is a falsifying interpretation.
\[
\begin{nsemantics}
1. & I & \Nmodels & P \band Q \bimplies P \bor \bnot Q & \mbox{assumption} \\
2. & I & \Models & P \band Q & \mbox{1 and $\bimplies$} \\
3. & I & \Nmodels & P \bor \bnot Q & \mbox{1 and $\bimplies$} \\
4. & I & \Models & P & \mbox{2 and $\band$} \\
5. & I & \Nmodels & P & \mbox{3 and $\bor$} \\
6. & I & \Models & \false & \mbox{4 and 5 are contradictory}
\end{nsemantics}
\]
\quad Thus $F$ is valid.

\end{frame}

\begin{frame}
\underline{Example 2}: Prove\\
\bigskip
\qquad\qquad $F:\ (P \bimplies Q) \band (Q \bimplies R) \bimplies (P \bimplies R)$ \quad is valid.\\
\bigskip
Let's assume that $F$ is not valid.
\[
\begin{nsemantics}
1. & I & \Nmodels & F & \mbox{assumption} \\
2. & I & \Models & (P \bimplies Q) \band (Q \bimplies R) & \mbox{1 and $\bimplies$} \\
3. & I & \Nmodels & P \bimplies R & \mbox{1 and $\bimplies$} \\
4. & I & \Models & P & \mbox{3 and $\bimplies$} \\
5. & I & \Nmodels & R & \mbox{3 and $\bimplies$} \\
6. & I & \Models & P \bimplies Q & \mbox{2 and of $\band$} \\
7. & I & \Models & Q \bimplies R & \mbox{2 and of $\band$} \\
\end{nsemantics}
\]
\end{frame}
\begin{frame}
Two cases from 6
\[
\begin{nsemantics}
8a. & I & \Nmodels & P & \mbox{6 and $\bimplies$} \\
9a. & I & \Models & \false & \mbox{4 and 8a are contradictory}
\end{nsemantics}
\]
and
\[
\begin{nsemantics}
8b. & I & \Models & Q & \mbox{6 and $\bimplies$}
\end{nsemantics}
\]
Two cases from 7
\[
\begin{nsemantics}
9ba. & I & \Nmodels & Q & \mbox{7 and $\bimplies$} \\
10ba. & I & \Models & \false & \mbox{8b and 9ba are contradictory}
\end{nsemantics}
\]
and
\[
\begin{nsemantics}
9bb. & I & \Models & R & \mbox{7 and $\bimplies$} \\
10bb. & I & \Models & \false & \mbox{5 and 9bb are contradictory}
\end{nsemantics}
\]
Our assumption is incorrect in all cases --- $F$ is valid.
\end{frame}

\begin{frame}
\underline{Example 3}: Is\\
\smallskip
\qquad\qquad $F:\ P \bor Q \bimplies P \band Q$ \quad valid?\\
\bigskip
Let's assume that $F$ is not valid.
\[
\begin{nsemantics}
1. & I & \Nmodels & P \bor Q \bimplies P \band Q & \mbox{assumption} \\
2. & I & \Models & P \bor Q & \mbox{1 and $\bimplies$} \\
3. & I & \Nmodels & P \band Q & \mbox{1 and $\bimplies$}
\end{nsemantics}
\]
Two options
\[
\begin{array}{cc}
\begin{nsemantics}
4a. & I & \sModels & P & \mbox{2 and $\bor$} \\
5a. & I & \sNmodels & Q & \mbox{3 and $\band$}
\end{nsemantics}
&
\begin{nsemantics}
4b. & I & \sModels & Q & \mbox{2 and $\bor$} \\
5b. & I & \sNmodels & P & \mbox{3 and $\band$}
\end{nsemantics}
\end{array}
\]
We cannot derive a contradiction. $F$ is not valid.\\
\bigskip
\underline{Falsifying interpretation}:\\
$I_1:\ \set{P \Mapsto \truev,\ Q \Mapsto \falsev}$\qquad
$I_2:\ \set{Q \Mapsto \truev,\ P \Mapsto \falsev}$\\
\smallskip
We have to derive a contradiction in \underline{both} cases for $F$ to be valid.
\end{frame}

\begin{frame}
\frametitle{Equivalence}
$F_1$ and $F_2$ are \underline{equivalent} ($F_1 \sBequiv F_2$)\\
\smallskip
\qquad iff for all interpretations $I$, $I \Models F_1 \biff F_2$\\
\bigskip
To prove $F_1 \sBequiv F_2$ show $F_1 \biff F_2$ is valid.

\bigskip
\bigskip
$F_1$ \underline{implies} $F_2$ ($F_1 \sBimplies F_2$)\\
\smallskip
\qquad iff for all interpretations $I$, $I \Models F_1 \bimplies F_2$\\

\bigskip
\bigskip
$F_1 \sBequiv F_2$ and $F_1 \sBimplies F_2$ are not formulae!

\end{frame}

\begin{frame}
\frametitle{Normal Forms}
1. \underline{Negation Normal Form (NNF)}\\
\smallskip
\qquad Negations appear only in literals. (only $\neg,\band,\bor$)\\
\smallskip
\qquad To transform $F$ to equivalent $F'$ in NNF use recursively\\
\qquad the following template equivalences (left-to-right):
\[
\begin{array}{l}
  \smallskip
  \bnot \bnot F_1 \Bequiv F_1 \qquad \bnot \true \Bequiv \false \qquad \bnot \false \Bequiv \true \\
  \smallskip
  \left. \begin{array}{@{}l}
  \smallskip
  \bnot (F_1 \band F_2) \Bequiv \bnot F_1 \bor \bnot F_2 \\
  \bnot (F_1 \bor F_2) \Bequiv \bnot F_1 \band \bnot F_2 
  \end{array} \right\} $De Morgan's Law$\\
  \smallskip
  F_1 \bimplies F_2 \Bequiv \bnot F_1 \bor F_2 \\
  F_1 \biff F_2 \Bequiv (F_1 \bimplies F_2) \band (F_2 \bimplies F_1)
\end{array}
\]
\bigskip
\underline{Example}: Convert \qquad $F:\ \bnot (P \bimplies \bnot (P \band Q))$ to NNF
\[
\begin{array}{r@{\ :\ }l@{\hspace*{2em}}l}
F' & \bnot (\bnot P \bor \bnot (P \band Q)) & \bimplies $ to $ \bor \\
F'' & \bnot\bnot P \band \bnot\bnot (P \band Q) & $De Morgan's Law$ \\
F''' & P \band P \band Q & \neg\neg
\end{array}
\]
$F'''$ is equivalent to $F$ ($F''' \sBequiv F$) and is in NNF
\end{frame}

\begin{frame}
2. \underline{Disjunctive Normal Form (DNF)}\\
\smallskip
\qquad Disjunction of conjunctions of literals
\[
\bigvee_i \bigwedge_j \ell_{i,j}\quad
\mbox{for literals $\ell_{i,j}$}
\]
\qquad To convert $F$ into equivalent $F'$ in DNF,\\
\qquad transform $F$ into NNF and then\\
\qquad use the following template equivalences (left-to-right):
\[
\left.
\begin{array}{rcl}
\smallskip
(F_1 \bor F_2) \band F_3 
& \Bequiv &
(F_1 \band F_3) \bor (F_2 \band F_3) \\
\smallskip
F_1 \band (F_2 \bor F_3)
& \Bequiv &
(F_1 \band F_2) \bor (F_1 \band F_3)
\end{array}
\right\} dist
\]
\bigskip
\underline{Example}: Convert\\
\qquad\qquad $F:\ (Q_1 \bor \bnot\bnot Q_2) \band (\bnot R_1 \bimplies R_2)$ into DNF
\[
\begin{array}{r@{\ :\ }l@{\hspace*{1em}}l}
F' & (Q_1 \sbor Q_2) \sband (R_1 \sbor R_2) & $in NNF$\\
F'' & (Q_1 \sband (R_1 \sbor R_2)) \sbor (Q_2 \sband (R_1 \sbor R_2)) & $dist$\\
F''' & (Q_1 \sband R_1) \sbor (Q_1 \sband R_2) \sbor (Q_2 \sband R_1) \sbor (Q_2 \sband R_2) & $dist$\\
\end{array}
\]
$F'''$ is equivalent to $F$ ($F''' \sBequiv F$) and is in DNF
\end{frame}

\begin{frame}
3. \underline{Conjunctive Normal Form (CNF)}\\
\smallskip
\qquad Conjunction of disjunctions of literals
\[
\bigwedge_i \bigvee_j \ell_{i,j}\quad
\mbox{for literals $\ell_{i,j}$}
\]
\qquad To convert $F$ into equivalent $F'$ in CNF,\\
\qquad transform $F$ into NNF and then\\
\qquad use the following template equivalences (left-to-right):
\[
\begin{array}{rcl}
(F_1 \band F_2) \bor F_3
& \Bequiv &
(F_1 \bor F_3) \band (F_2 \bor F_3) \\
F_1 \bor (F_2 \band F_3)
& \Bequiv &
(F_1 \bor F_2) \band (F_1 \bor F_3)
\end{array}
\]
\end{frame}

\begin{frame}
\frametitle{Davis-Putnam-Logemann-Loveland (DPLL) Algorithm}
Decides the satisfiability of PL formulae in CNF

\bigskip
In book, \underline{efficient conversion} of $F$ to $F'$ where\\
\smallskip
\qquad $F'$ is in CNF and\\
\qquad $F'$ and $F$ are \underline{equisatisfiable} ($F$ is satisfiable iff $F'$ is satisfiable)

\bigskip
\underline{Decision Procedure DPLL}: Given $F$ in CNF
\begin{small}
\[
\begin{mlrecfunction}{dpll}{F}
  \mletin{F'}{\mlfni{bcp}\ F} \\    
  \mif F' = \true\ \mthen \mkwd{true} \\
  \melse \mif F' = \false\ \mthen \mkwd{false} \\
  \melse \\
  \begin{mblock}
    \mletin{P}{\mlfni{choose}\ \mfn{vars}(F')} \\
    (\mlfn{dpll}\ F'\set{P \mapsto \true}) \bor (\mlfni{dpll}\ F'\set{P \mapsto \false})
  \end{mblock}
\end{mlrecfunction}
\]
Don't $\mlfni{choose}$ only-positive or only-negative variables for splitting.
\end{small}
\end{frame}

\begin{frame}
\underline{Boolean Constraint Propagation (BCP)}\\
\smallskip
\quad Based on unit resolution
\[
  \begin{array}{c@{\hspace*{2em}}cl} 
    \ell & C[\bnot \ell] & \leftarrow $ clause$\\ 
	\cline{1-2} \multicolumn{2}{c}{C[\false]}& 
  \end{array} \qquad where\  \ell=P \ or\  \ell=\bnot P
\]
\quad throughout

\medskip
\underline{Example}:
$$F:\ (\bnot P \bor Q \bor R) \band (\bnot Q \bor R) \band (\bnot Q \bor \bnot R) \band (P \bor \bnot Q \bor \bnot R)$$
\underline{Branching on $Q$}
\[
F\set{Q \Mapsto \true}:\ (R) \band (\bnot R) \band (P \bor \bnot R)
\]
\quad By unit resolution
\[
\ures{R}{(\bnot R)}{\false}
\]
\quad $F\set{Q \Mapsto \true}\ = \ \false \Bimplies \falsev$\\
\end{frame}

\begin{frame}
\underline{On the other branch}\\
\quad $F\set{Q \Mapsto \false}:\ (\bnot P \bor R)$\\
\quad $F\set{Q \Mapsto \false,\ R \Mapsto \true,\ P \Mapsto \false}\ = \ \true \Bimplies \truev$\\
\bigskip
$F$ is satisfiable with satisfying interpretation
\[
I:\ \set{P \Mapsto \falsev,\ Q \Mapsto \falsev,\ R \Mapsto \truev}
\]

\begin{footnotesize}
\begin{figure}[b]
\centering
\begin{tabular}{ccc}
& \rnode{F}{$F$} 
\\ \\ \\
\rnode{1}{$(R) \band (\bnot R) \band (P \bor \bnot R)$}
&&
\rnode{2}{$(\bnot P \bor R)$}
\\ \\
\rnode{1a}{$\ures{R}{(\bnot R)}{\false}$}
&&
\rnode{2a}{$\bnot P$}
\\ \\
&& \rnode{3}{$I:\ \set{P \Mapsto \falsev,\ Q \Mapsto \falsev,\ R \Mapsto \truev}$}\end{tabular}
\ncline{F}{1}
\tlput{$Q \Mapsto \true$}
\ncline{F}{2}
\trput{$Q \Mapsto \false$}
\ncline{2}{2a}
\trput{$R \Mapsto \true$}
\ncline{2a}{3}
\trput{$P \Mapsto \false$}
\end{figure}
\end{footnotesize}

\end{frame}
\end{document}

