# Logic for Computer Scientists/Propositional Logic/Resolution
## Resolution

In this subsection we will develop a calculus for propositional logic. Until now we have a language, i.e. a set of formulae and we have investigated into semantics and some properties of formulae or sets of clauses. Now we will introduce an inference rule, namely the resolution rule, which allows to derive new clauses from given ones.

## Definition 10

A clause $R$ is a resolvent of clauses $C_{1}$ and $C_{2}$, if there is a literal $L\in C_{1}$ and ${\overline {L}}\in C_{2}$ and
$R=(C_{1}-\{L\})\cup (C_{2}-\{{\overline {L}}\})$
where
${\overline {L}}={\begin{cases}\;\;\,\lnot A\;{\text{ if }}L=A\\\;\;\,A\;{\text{ if }}L=\lnot A\end{cases}}$
Note that there is a special case, if we construct the resolvent out of two literals, i.e. $L$ and ${\overline {L}}$ can be resolved upon and yield the empty set. This empty resolvent is depicted by the special symbol $\square$. $\square$ denotes an unsatisfiable formula. We define a clause set, which contains this empty clause to be unsatisfiable,
In the following we investigate in properties of the resolution rule and the entire calculus. The following Lemma is stating the correctness of one single application of the resolution rule.

## Theorem 7

If $S$ is a set of clauses and $R$ a resolvent of $C_{1},C_{2}\in S$, then $S\equiv S\cup \{R\}$
Proof: Let ${\mathcal {A}}$ be an assignment for $S$; hence it is an assignment for $S\equiv S\cup \{R\}$ as well. Assume ${\mathcal {A}}\models S$: hence for all clauses $C$ from $S$, we have that ${\mathcal {A}}\models C$. The resolvent $R$ of $C_{1}$ and $C_{2}$ looks like:
$R=(C_{1}-\{L\})\cup (C_{2}-\{{\overline {L}}\})$
where $L\in C_{1}$ and ${\overline {L}}\in C_{2}$. Now there are two cases:
* ${\mathcal {A}}\models L$: From ${\mathcal {A}}\models C_{2}$ and ${\mathcal {A}}\not \models {\overline {L}}$, we conclude ${\mathcal {A}}\models (C_{2}-\{{\overline {L}}\})$ and hence ${\mathcal {A}}\models R$.
* ${\mathcal {A}}\not \models L$: From ${\mathcal {A}}\models C_{1}$ we conclude ${\mathcal {A}}\models (C_{1}-\{L\})$ and hence ${\mathcal {A}}\models R$. The opposite direction of the lemma is obvious.

## Definition 11

Let $S$ be s set of clauses and
$Res(S)=S\cup \{R\mid R{\text{ is a resolvent of two clauses in }}S\}$
then
$Res^{0}(S)=S$
$Res^{n+1}(S)=Res(Res^{n}(S)),n\geq 0$ $Res^{*}(S)=\bigcup _{n\geq 0}Res^{n}(S)$
If we understand the process of iterating the Res-operator as a procedure for deriving new clauses from a given set, and in particular to derive possibly the empty clause, we have to ask, under which circumstances we get the empty clause, and vice versa, what does it mean if we get it. These properties are investigates in the following two Theorems.

## Theorem 8 (Correctness)

Let $S$ be a set of clauses. If $\square \in Res^{*}(S)$ then $S$ is unsatisfiable.
Proof: From $\square \in Res^{*}(S)$ we conclude, that $\square$ is obtained by resolution from two clauses $C_{1}=\{L\}$ and $C_{2}=\{{\overline {L}}\}$. Hence there is a $\exists n\geq 0$ such that $\square \in Res^{n}(S)$ and $C_{1},C_{2}\in Res^{n}(S)$ and therefore $Res^{n}(S)$ is unsatisfiable. From Theorem (resolution-lemma) we conclude that $Res^{n}(S)\equiv S$ and hence $S$ is unsatisfiable.

## Theorem 9 (Completeness)

Let $S$ be a finite set of clauses. If $S$ is unsatisfiable then $\square \in Res^{*}(S)$.
Proof: Induction over the number $n$ of atomic formulae in $S$. With $n=0$ we have $S=\{\square \}$and hence $\square \in S\subseteq Res^{*}(S)$.
Assume $n$ fixed and for every unsatisfiable set of clauses $S$ with $n$ atomic formulae $A_{1},\cdots ,A_{n}$ it holds that $\square \in Res^{*}(S)$.
Assume a set of clauses $S$ with atomic formulae $A_{1},\cdots ,A_{n},A_{n+1}$. In the following we construct two clause sets $S_{f}$ and $S_{t}$:
* $S_{f}$ is received from $S$ by deleting every occurrence of $A_{n+1}$ in a clause and by deleting every clause which contains an occurrence of $\lnot A_{n+1}$. This transformation obviously corresponds to interpreting the atom $A_{n+1}$ with $false$,
* $S_{t}$ results from a similar transformation, where occurrences of $\lnot A_{n+1}$ and clauses containing $A_{n+1}$ are deleted, hence $A_{n+1}$ is interpreted with $true$.
Let us show, that both $S_{f}$ and $S_{t}$ are unsatisfiable: Assume an assignment ${\mathcal {A}}$ for the atomic formale $\{A_{1},\cdots ,A_{n}\}$ which is a model for $S_{f}$. Hence the assignment ${\mathcal {A}}'(B)={\begin{cases}\;\;\,{\mathcal {A}}(B)\;{\text{ if }}B\in \{A_{1},\cdots ,A_{n}\}\\\;\;\,false{\text{ if }}B=A_{n+1}\end{cases}}$ is a model for $S$, which leads to a contradiction. A similar construction shows that $S_{t}$ is unsatisfiable. Hence then we can use the induction assumption to conclude that $\square \in Res^{*}(S_{t})$ and $\square \in Res^{*}(S_{f})$. Hence there is a sequence of clauses
$C_{1},\cdots ,C_{m}=\square$
such that $\forall 1\leq i\leq m$ it holds $C_{i}\in S_{f}$ or $C_{i}$ is a resolvent of two clauses $C_{a}$ and $C_{b}$ with $a,b<i$.There is an analog sequence for $S_{t}$:
$C_{1}',\cdots ,C_{t}'=\square$
Now we are going to reintroduce the previously deleted literals $A_{n+1}$ and $\lnot A_{n+1}$ in the two sequences:
* Clause $C_{i}$ which has been the result of deleting $A_{n+1}$ from the original clause in $S$ are again modified to $C_{i}\cup \{A_{n}+1\}$. This results in a sequence ${\overline {C_{1}}},\cdots ,{\overline {C_{m}}}$
where ${\overline {C_{m}}}$ is either $\square$ or $A_{n+1}$.
* Analogous we introduce $\lnot A_{n+1}$ in the second sequence, such that ${\overline {C_{t}'}}$ is either $\square$ or $\lnot A_{n+1}$
In any of the above cases we get $\square \in Res^{*}(S)$ latest after one resolution step with ${\overline {C_{m}}}$ and ${\overline {C_{t}'}}$.
Based on the theorems for correctness and completeness, we give a procedure for deciding the satisfiability of propositional formulae.
Given a propositional formula $F$.
* Transform $F$ into an equivalent CNF $S$.
* Compute $Res^{n}(S)$ for $n=0,1,2,\cdots$
** If $\square \in Res^{n}(S)$ then Stop: unsatisfiable .
** if $Res^{n}(S)=Res^{n+1}(S)$ then Stop: satisfiable .

## Theorem 10

If $S$ is a finite set of clauses, then there exists a $k\geq 0$ such that
$Res^{k}(S)=Res^{k+1}(S)$
Until now, we have been dealing with sets of clauses. In the following it will turn out, that it is helpful to talk about sequences of applications of the resolution rule.

## Definition 12

A deduction of a clause $C$ from a set of clauses $S$ is a sequence $C_{1},\cdots ,C_{n}$, such that
* $C_{n}=C$ and
* $\forall 1\leq i\leq n:(C_{i}\in S{\text{ or }}\exists l,r<i:C_{i}{\text{ is a resolvent of }}C_{l}=and=C_{r})$
A deduction of the empty clause $\square$ from $S$ is called a refutation of $S$.
Example We want to show, that the formula $K=((B\land \lnot A)\lor C)$ is a logical consequence of $F=((A\lor (B\lor C))\land (C\lor \lnot A))$. For this negate $K$ and prove the unsatisfiability of $F\land \lnot K$
For this you can use the interaction in this book in various forms:
* Use the interaction Truth Tables for proving the unsatisfiability, or
* use the interaction CNF Transformation for transforming the formula into CNF, and then
* use the following interaction Resolution.

## Problems
#### Problem 23 (Propositional)

Compute $Res^{n}(M)$ for all $n\geq 0$ and $Res^{*}(M)$ for the following set of clauses:
* $M=\{\{A\},\{B\},\{\lnot A,C\},\{B,\lnot C,\lnot D\},\{\lnot C,D\},\{\lnot D\}$
* $M=\{\{A,\lnot B\},\{A,B\},\{\lnot A\}\}$
* $M=\{\{A,B,C\},\{\lnot B,\lnot C\},\{\lnot A,C\}\}$
* $M=\{\{\lnot A,\lnot B\},\{B,C\},\{\lnot C,A\}\}$
Which formula is satisfiable or which is unsatisfiable?
$\Box$

#### Problem 24 (Propositional)

Indicate all resolvent of the clauses in S, where $S=\{\{A,\lnot B,C\},\{A,B,E\},\{\lnot A,C,\lnot D\},\{A,\lnot E\}\}$
$\Box$

#### Problem 25 (Propositional)

Prove: A resolvent $R$ of two clauses $C_{1}$ and $C_{2}$ is a logical consequence from $C_{1}$ and $C_{2}$. Note: Use the definition of "consequence".
$\Box$

#### Problem 26 (Propositional)

Let $M$ be a set of formulae and $F$ a formula. Prove:
$M\models F$
$M\cup \{\lnot F\}$
$\Box$

#### Problem 27 (Propositional)

Compute $Res^{n}(S)$ with $n=0,1,2$ and
$S=\{\{A,\lnot B,C\},\{B,C\},A\{\lnot ,C\},\{B,\lnot C\},\{\lnot C\}\}$
$\Box$

#### Problem 28 (Propositional)

Show that the following set $S$ of formulae is unsatisfiable, by giving a refutation. $S=(B\lor C\lor D)\land (\lnot C)\land (\lnot B\lor C)\land (B\lor \lnot D)$ $\Box$

#### Problem 29 (Propositional)

Show by using the resolution rule, that $\lnot A\land \lnot B\land C$ is an inference from the set of clauses $F=\{\{A,C\},\{\lnot B,\lnot C\},\{\lnot A\}\}$.
$\Box$

#### Problem 30 (Propositional)

Show by using the resolution rule, that $((P\to Q{\text{ is }})\land P)\to Q$ is a tautology. $\Box$