Introduction to Logic

Logic Definitions

Syntax of Propsitional Logic

Complex propositions (sentences) can be built from simpler propositions using logical connectives, such as

Model Example

For each InI_n describe whether it is a model of the knowledge base

KB={pqqrsKB=\begin{cases}p\Leftarrow q\\q\\r\Leftarrow s\end{cases}
p q r s
I1I_1 True True True True
I2I_2 False False False False
I3I_3 True True False False

For I1I_1 we have p=TRUE, q=TRUE, r=TRUE and s=TRUE

pq          TrueTrue          Trueq          TrueTruers          TrueTrueTrue\def\true{\text{True}} \def\false{\text{False}} \def\tab{\ \ \ \ \ \ \ \ \ \ } \begin{align*} p\Leftarrow q &\tab\true \Leftarrow \true &\tab\true\\ q &\tab \true & \true\\ r\Leftarrow s &\tab \true\Leftarrow\true &\true \end{align*}

Since each clause is true, I1I_1 is a model of the knowledge base KBKB


For I2I_2 we have p=FALSE, q=FALSE, r=FALSE, s=FALSE

pq          FalseFalse          Trueq          FalseFalsers          FalseFalseTrue\def\true{\text{True}} \def\false{\text{False}} \def\tab{\ \ \ \ \ \ \ \ \ \ } \begin{align*} p\Leftarrow q &\tab\false \Leftarrow \false &\tab\true\\ q &\tab \false & \false\\ r\Leftarrow s &\tab \false\Leftarrow\false &\true \end{align*}

Since not every clause of I2I_2 is true, this is not a model of the knowledge base KBKB


For I3I_3 we have p=TRUE, q= TRUE, r=FALSE, s=FALSE

pq          TrueTrue          Trueq          TrueTruers          FalseFalseTrue\def\true{\text{True}} \def\false{\text{False}} \def\tab{\ \ \ \ \ \ \ \ \ \ } \begin{align*} p\Leftarrow q &\tab\true \Leftarrow \true &\tab\true\\ q &\tab \true & \true\\ r\Leftarrow s &\tab \false\Leftarrow\false &\true \end{align*}

Since not every clause of I3I_3 is true, this is not a model of the knowledge base KBKB


Conjunctive Normal Form (CNF)

A conjunction of disjunctions

  1. Eliminate the arrows, using the rule AB¬ABA\Rightarrow B \equiv \neg A \vee B
¬(AB)(¬CD)\neg (A \vee B) \vee (\neg C \vee D)
  1. Drive in the negations
(¬A¬B)(¬CD)(\neg A \vee \neg B) \vee (\neg C \vee D)
  1. Distribute OR over AND
(¬A¬CD)(¬B¬CD)(\neg A \vee \neg C \vee D) \wedge (\neg B \vee \neg C \vee D)

Exercise 5.1

Mr Jones finds three trunks A, B and C in a cave. Based on studying the history of where these trunks came about, he knows that one trunk contains gold while two are empty. On the wall of the cave he found three clues: "A is empty", "B is empty" and "gold is in B". From studying the historical social norm of the villages around the cave, Mr Jones knows that only one of the clues is true, while the other two are false. Which trunk has the gold?

Hint: Break down the problem into the following steps

  1. Convert to atoms (symbols that we want to evaluate the truth of)
  2. Build logical statements using atoms
  3. Convert to Conjunctive Normal Form
  4. Evaluate the CNF sentences

We want to encode the clauses (atoms/rules in the problem) that are true in the intended interpretation by axiomatizing the domain.

  1. Associate an atom with the situation we wish to validate (i.e., gold in trunk)
  2. Encode Mr Jones’ knowledge of the situation into a set of logical sentences
  3. Use these sentences to determine if there is a solution, where one of the chests is guaranteed to contain gold.

We begin by associating a variable for each of the trunks containing gold.

A: Trunk A contains gold.

B: Trunk B contains gold.

C: Trunk C contains gold.

Then, ¬A\neg A means that Trunk A does not contain gold.

Encode Mr Jones' knowledge

One trunk contains gold, while the other two are empty.

S1=(A¬B¬C)(¬AB¬C)(¬A¬BC)S_1=(A\wedge \neg B \wedge \neg C) \vee(\neg A \wedge B \wedge \neg C) \vee (\neg A \wedge \neg B \wedge C)

Additional Clues

Additionally, Mr Jones knows of three clues, but additionally knows that only one of the clues is true, with the other two being false. We also want to encode this knowledge using logic. We know that the three clues were given as:

A: Trunk A contains gold.

B: Trunk B contains gold.

C: Trunk C contains gold.

We begin by representing the three clues as ¬A,¬B,B\neg A, \neg B, B respectively. Since Mr Jones knows that only one of these are true, we now need to consider each possibility to form our second logical sentence.

S2=(¬A¬(¬B)¬B)(¬(¬A)¬B¬B)(¬(¬A)¬(¬B)B)S_2=(\neg A \wedge \neg (\neg B) \wedge \neg B) \vee (\neg(\neg A)\wedge\neg B \wedge \neg B) \vee (\neg(\neg A) \wedge \neg(\neg B) \wedge B)

Simplifying the Problem

We can now use both sentences to determine if there is a situation in which one of the chests is guaranteed to contain gold.
S1=(A¬B¬C)(¬AB¬C)(¬A¬BC)S_1=(A\wedge \neg B \wedge \neg C) \vee(\neg A \wedge B \wedge \neg C) \vee (\neg A \wedge \neg B \wedge C)
S2=(¬A¬(¬B)¬B)(¬(¬A)¬B¬B)(¬(¬A)¬(¬B)B)S_2=(\neg A \wedge \neg (\neg B) \wedge \neg B) \vee (\neg(\neg A)\wedge\neg B \wedge \neg B) \vee (\neg(\neg A) \wedge \neg(\neg B) \wedge B)

Simplifying the Second Sentence

  1. Through the elimination of double negatives, we get
S2=(¬AB¬B)(A¬B¬B)(ABB)S_2=(\neg A \wedge B \wedge \neg B) \vee (A \wedge \neg B \wedge \neg B) \vee (A\wedge B \wedge B)
  1. We know that X¬X=FalseX\wedge\neg X=\text{False}, so applying this we get:
S2=(¬AFalse)(A¬B¬B)(ABB)S_2=(\neg A \wedge False) \vee(A \wedge\neg B \wedge \neg B) \vee (A \wedge B\wedge B)
  1. We additionally know that AA=AA\wedge A=A:
S2=(¬AFalse)(A¬B)(AB)S_2=(\neg A \wedge False) \vee(A \wedge\neg B) \vee (A \wedge B)
  1. Additionally, we know that FalseA=A\text{False}\wedge A=A
S2=(A¬B)(AB)S_2=(A \wedge\neg B) \vee (A \wedge B)
  1. By the distributivity law, we know that the above statement is equivalent to
S2=A(¬BB)S_2=A \wedge (\neg B \wedge B)
  1. We know that (¬XX)=T(\neg X \wedge X) = T
S2=AS_2=A

Therefore, to satisfy S2,AS_2, A must be true (that is, the gold is in trunk A). However, we are not done at this point. We need to check the combination of truth values for A, B and C that makes S1S_1 true. If we didn't do this, that means that there is a possibility that the gold is in trunk A, but it is also in one of the other trunks, violating our rule.

Rule Validation

We can perform the validation of rule S1S_1 through the construction of a truth table.

AA BB CC S1=(A¬B¬C)(¬ABnegC)(¬A¬BC)S_1=(A\wedge \neg B \wedge \neg C) \vee (\neg A \wedge B \wedge neg C) \vee (\neg A \wedge \neg B \wedge C) S2=AS_2=A
F F F F F
F F T T F
F T F T F
F T T F F
T F F T T
T F T F T
T T F F T
T T T F T

While S1S_1 looks difficult to compute, remember what it actually represents – It’s true when only one of A,B,CA, B, C are true. Since A=T,B=F,C=FA=T, B=F, C=F is the only row in which both S1S_1 and S2S_2 are true, we can guarantee that the gold is only in trunk A.

Exercise 5.2

Are the following entailments correct? Please provide the proof.
  1. (AB)(AB)(A\wedge B)\models (A \Leftrightarrow B)
  2. (AB)(AB)(A\Leftrightarrow B) \models (A \wedge B)

Hint: When we are asked to determine if an entailment is correct (or holds, or is true), we can convert the entailment into an implication and check if the implication is valid. Checking whether or not the implication is valid means solving a validity problem. Remember that a sentence is valid when very combination of variable assignments in the sentence causes it to be true

Exercise 5.2a

AA BB ABA\wedge B (AB)(AB)(A\wedge B)\rightarrow (A \Leftrightarrow B)
F F F T
F T F T
T F F T
T T T T

Since all of the rows of the implication column of the truth table is true, the implication is valid, and thus the original entailment is correct.

Exercise 5.2b

AA BB ABA\Leftrightarrow B ABA\wedge B (AB)(AB)(A\wedge B)\rightarrow (A \Leftrightarrow B)
F F T F F
F T F F T
T F F F T
T T T T T

Since not every row of the implication column is true, the implication is not valid, and thus the original entailment is not correct.

Resolution Refutation

Resolution refutation is a technique for simplifying local propositions. There are three steps to perform resolution refutation:

  1. Convert all sentences to Conjugative Normal Form (CNF)
  2. Negate the desired conclusion
  3. Apply the resolution rule, until we either:
    1. Derive false (a contradiction)
    2. Can't apply the rule anymore.

The resolution refutation rule is sound and complete (for propositional logic):

Exercise 5.3

Use the resolution refutation rule to show

(P¬P)R(P\wedge\neg P)\models R

(Note: negation can be represented by "¬\neg" or "~" or "!" or just plain "not")

Use the resolution refutation rule to show that (P¬P)R(P\wedge\neg P)\models R. Resolution refutation is like a proof by contradiction. Assume that the statement that we want to prove is false, and then derive a contradiction (show that the knowledge base cannot be true, for the negated statement we want to prove).

Recall that the resolution refutation rule is given as follows:

AB¬BCAC\begin{equation*} \begin{split} &A\vee B \\ \neg &B\vee C \\ \hline &A\vee C \end{split} \end{equation*}

  1. The first step of resolution refutation is to convert all sentences in our axioms to Conjugative Normal Form. In this case, we only have a single sentence, which is straightforward to convert.
    (P¬P)=(FP)(¬PF)(P\wedge\neg P)=(F\vee P)\wedge(\neg P \vee F)
  2. Secondly, we negate the conclusion to get
    ¬(R)¬R\neg (R) \equiv \neg R
  3. We then apply the resolution refutation rule. Our first and second clauses are FPF\vee P and ¬PF\neg P \vee F with conclusion ¬R\neg R.
FP¬PF¬R\begin{equation*} \begin{split} &F\vee P \\ \neg &P\vee F \\ \hline &\neg R \end{split} \end{equation*}
  1. Applying the resolution refutation rule yields FF=FF \vee F = F. We have derived False\text{False} which is a contradiction. Since False\text{False} entails anything including RR in this case, it is valid.

UQPark is a theme park with 5 rides. Bumper cars, carousel, haunted class, roller coaster and ferris wheel, where each ride can be turned off and on independently of other rides. After performing a cost-benefit analysis, UQPark Management decided that only 3 rides should be open on any given day, and that the set of rides that are open/closed must satisfy the following constraints:

  1. Either bumper cars or carousel must be open
  2. If bumper cars is closed, then roller coaster must be open.
  3. If carousel is open, the either bumper cars or haunted class must be open too
  4. If haunted class is open, then ferris wheel must be open too.
  5. Bumper cars and ferris wheel cannot both be open at the same day.
  6. If roller coaster is open, then ferris wheel must be open too.
  7. If roller coaster is closed, then either haunted class or ferris wheel must be open.

UQ Park facilities thinks there is no combination of rides that can satisfy all of Management's constraints.

  1. Please frame this problem as a satisfiability problem with propositional logic representation
  2. Please solve the problem in (a) using DPLL. If both Management and Facilities are correct or both are incorrect, please also explain why using DPLL.

Tip: Assign W=Ferris Wheel.

Exercise 5.4a

We begin solving the problem by assigning some atoms:
  1. Either bumper cars or carousel must be open
    BCB \vee C
  2. If bumper cars is closed, then roller coaster must be open
    ¬BR¬(¬B)RBR\neg B \rightarrow R \Rightarrow \neg (\neg B)\vee R\Rightarrow B \vee R
  3. If carousel is open, then either bumper cars or haunted class must be open
    C(BH)¬CBHC\rightarrow (B \vee H) \Rightarrow \neg C \vee B \vee H
  4. If haunted class is open, then ferris wheel must be open too
    HW¬HWH\rightarrow W \Rightarrow \neg H \vee W
  5. Bumper cars and ferris wheel cannot both be open on the same day
    ¬(BW)¬B¬W\neg(B\wedge W)\Rightarrow\neg B \vee \neg W
  6. If roller coaster is open, then ferris wheel must be open too
    RW¬RWR \rightarrow W \Rightarrow \neg R \vee W
  7. If roller coaster is closed, then either haunted class or ferris wheel must be open
    ¬R(HW)¬(¬R)(HW)RHW\neg R \rightarrow (H \vee W) \Rightarrow \neg(\neg R)\vee(H\vee W)\Rightarrow R\vee H\vee W
We then combine each of the clauses using the CNF syntax
(BC)(BR)(¬CBH)(¬HW)(¬B¬W)(¬RW)(RHW)(B\vee C)\wedge(B\vee R)\wedge(\neg C\vee B\vee H)\wedge(\neg H\vee W)\wedge(\neg B\vee \neg W)\wedge(\neg R\vee W)\wedge(R\vee H\vee W)

Exercise 5.4b

We count the occurrences of each variable in the CNF statement

B=4B=4
C=2C=2
H=3H=3
R=3R=3
W=4W=4

Since B is the variable with the most entries (and will lead to the most simple answer) we choose to assign it first. We choose to assign B=True

(TC)(TR)(¬CTH)(¬HW)(¬T¬W)(¬RW)(RHW)(¬HW)(F¬W)(¬RW)(RHW)(¬HW)(¬W)(¬RW)(RHW) (T\vee C)\wedge(T\vee R)\wedge(\neg C\vee T\vee H)\wedge(\neg H\vee W)\wedge(\neg T\vee \neg W)\wedge(\neg R\vee W)\wedge(R\vee H\vee W)\\ (\neg H \vee W) (F\vee \neg W)\wedge(\neg R \vee W)\wedge (R\vee H \vee W)\\ (\neg H \vee W)\wedge(\neg W)\wedge(\neg R \vee W)\wedge(R\vee H\vee W)

This doesn't lead to a case where the statement is false, so we proceed with the assignment. We once again count the occurrences of each variable in our statement.

W=4          H=2          R=2W=4\ \ \ \ \ \ \ \ \ \ H=2\ \ \ \ \ \ \ \ \ \ R=2

Since WW is the variable with the next-most entries we choose to assign it next. We first choose to assign W=True.

(¬HT)(¬T)(¬RT)(RHT)(¬HW)(¬W)(¬RW)(RHW)(¬T)F (\neg H \vee T)\wedge(\neg T)\wedge(\neg R \vee T)\wedge(R\vee H\vee T)\\ (\neg H \vee W)\wedge(\neg W)\wedge(\neg R \vee W)\wedge(R\vee H\vee W)\\ (\neg T)\\ F

Since this assignment doesn't hold (statement isn't true for all assignment), we try W=False.

(¬HW)(¬W)(¬RW)(RHW)(¬H)(¬R)(RH) (\neg H \vee W)\wedge(\neg W)\wedge(\neg R \vee W)\wedge(R\vee H\vee W) (\neg H)\wedge(\neg R)\wedge(R\vee H)

Counting the variable occurrences, we get H=2 and R=2. We choose to assign H=True

(¬T)(¬R)(RT)(F)(¬R)F(\neg T)\wedge(\neg R)\wedge(\R \vee T)\\(F)\wedge(\neg R)\\F

Since this variable assignment doesn't hold, we try to assign H=False.

(¬F)(¬R)(RF)(¬R)R=F(\neg F)\wedge(\neg R)\wedge(R\vee F)\\(\neg R)\wedge R=F

Since this variable assignment doesn’t hold, and we have tried setting it to both true and false, we backtrack to the assignment of W. However, we have already tried all possibilities of assigning to W so we backtrack to the assignment of B. We try B=False.

(BC)(BR)(¬CBH)(¬HW)(¬B¬W)(¬RW)(RHW)(FC)(FR)(¬CFH)(¬HW)(¬F¬W)(¬RW)(RHW)(C)(R)(¬CH)(¬HW)(¬RW)(RHW)(B\vee C)\wedge(B\vee R)\wedge(\neg C\vee B\vee H)\wedge(\neg H\vee W)\wedge(\neg B\vee \neg W)\wedge(\neg R\vee W)\wedge(R\vee H\vee W)\\ (F\vee C)\wedge(F\vee R)\wedge(\neg C\vee F\vee H)\wedge(\neg H\vee W)\wedge(\neg F\vee \neg W)\wedge(\neg R\vee W)\wedge(R\vee H\vee W)\\ (C)\wedge(R)\wedge(\neg C\vee H)\wedge(\neg H \vee W)\wedge(\neg R \vee W)\wedge(R\vee H \vee W)

Counting the variable occurrences gives us C=2, H=3, R=3, W=3. Since H is the variable with the next-most occurrences we choose to assign H=True.

(C)(R)(¬CH)(¬HW)(¬RW)(RHW)(C)(R)(¬CT)(¬TW)(¬RW)(RTW)(C)(R)(W)(¬RW)(C)\wedge(R)\wedge(\neg C\vee H)\wedge(\neg H \vee W)\wedge(\neg R \vee W)\wedge(R\vee H \vee W)\\ (C)\wedge(R)\wedge(\neg C\vee T)\wedge(\neg T \vee W)\wedge(\neg R \vee W)\wedge(R\vee T \vee W)\\ (C)\wedge(R)\wedge(W)\wedge(\neg R \vee W)

Counting of variable occurrences gives us C=1, W=2, R=2. We choose to set W=True

(C)(R)(W)(¬RW)(C)(R)(T)(¬RT)(C)(R)(C)\wedge(R)\wedge(W)\wedge(\neg R \vee W)\\(C)\wedge(R)\wedge(T)\wedge(\neg R \vee T)\\(C)\wedge(R)

We then set C=True

RR

We set R=True

T\text{T}