Logic is a formal language used to represent a set of state
A convenient abstraction for dealing with many states
Regardless of whether there's a natural notion of "near" or not (i.e. not a metric space), we can use logic to group different states together
For example:
I have a laptop ⇒ Includes any brand and model
There is a laptop on the table ⇒ Can be at any position on the table.
Logic Definitions
Interpretation Assignment of values to all variables
Model An interpretation (assignment of values) that satisfies the constraints
Often we don't just want to find a model, but we want to know what is true in all mdoels.
Proposition A statement that is true or false in each interpretation
The formal language representation and reasoning system is made up of:
Syntax describes what sentences are legal
Semantics specified the meanings of symbols
Atoms are symbols, starting with a lowercase letter
Definite Clause is an atom or rule of the form Atom ⇐ symbol
Knowledge Base is a set of definite clauses. A knowledge base is true iff every definite clause within it is true in every model (interpretation; assignment)
Syntax of Propsitional Logic
Complex propositions (sentences) can be built from simpler propositions using logical connectives, such as
Brackets ()
Negation ¬
And; Conjunction ∧
Or; Disjunction ∨
Implication ⇒
Biconditional/Equivalence ⇔
Model Example
For each In describe whether it is a model of the knowledge base
KB=⎩⎨⎧p⇐qqr⇐s
p
q
r
s
I1
True
True
True
True
I2
False
False
False
False
I3
True
True
False
False
For I1 we have p=TRUE, q=TRUE, r=TRUE and s=TRUE
p⇐qqr⇐sTrue⇐TrueTrueTrue⇐TrueTrueTrueTrue
Since each clause is true, I1 is a model of the knowledge base KB
For I2 we have p=FALSE, q=FALSE, r=FALSE, s=FALSE
Since not every clause of I2 is true, this is not a model of the knowledge base KB
For I3 we have p=TRUE, q= TRUE, r=FALSE, s=FALSE
p⇐qqr⇐sTrue⇐TrueTrueFalse⇐FalseTrueTrueTrue
Since not every clause of I3 is true, this is not a model of the knowledge base KB
Conjunctive Normal Form (CNF)
A conjunction of disjunctions
CNF statements are statements of the form (¬A∨B)∧(C∨D)∧(E∨F)
Suppose we have the statement (A∨B)⇒(C⇒D) that we want to convert to CNF.
To do this, we follow three steps
Eliminate the arrows, using the rule A⇒B≡¬A∨B
¬(A∨B)∨(¬C∨D)
Drive in the negations
(¬A∨¬B)∨(¬C∨D)
Distribute OR over AND
(¬A∨¬C∨D)∧(¬B∨¬C∨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
Convert to atoms (symbols that we want to evaluate the truth of)
Build logical statements using atoms
Convert to Conjunctive Normal Form
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.
Associate an atom with the situation we wish to validate (i.e., gold in trunk)
Encode Mr Jones’ knowledge of the situation into a set of logical sentences
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 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)∨(¬A∧B∧¬C)∨(¬A∧¬B∧C)
(A∧¬B∧¬C) translates to trunk A contains gold, while trunk B and C are empty.
(¬A∧B∧¬C) translates to trunk B has gold while the other two are empty.
(¬A∧¬B∧C) translates to trunk C has gold while the other two are empty.
We have essentially enumerated all possible outcomes of this statement
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
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)
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)∨(¬A∧B∧¬C)∨(¬A∧¬B∧C)S2=(¬A∧¬(¬B)∧¬B)∨(¬(¬A)∧¬B∧¬B)∨(¬(¬A)∧¬(¬B)∧B)
Simplifying the Second Sentence
Through the elimination of double negatives, we get
S2=(¬A∧B∧¬B)∨(A∧¬B∧¬B)∨(A∧B∧B)
We know that X∧¬X=False, so applying this we get:
S2=(¬A∧False)∨(A∧¬B∧¬B)∨(A∧B∧B)
We additionally know that A∧A=A:
S2=(¬A∧False)∨(A∧¬B)∨(A∧B)
Additionally, we know that False∧A=A
S2=(A∧¬B)∨(A∧B)
By the distributivity law, we know that the above statement is equivalent to
S2=A∧(¬B∧B)
We know that (¬X∧X)=T
S2=A
Therefore, to satisfy S2,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 S1 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 S1 through the construction of a truth table.
A
B
C
S1=(A∧¬B∧¬C)∨(¬A∧B∧negC)∨(¬A∧¬B∧C)
S2=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 S1 looks difficult to compute, remember what it actually represents – It’s true when only one of A,B,C are true. Since A=T,B=F,C=F is the only row in which both S1 and S2 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.
(A∧B)⊨(A⇔B)
(A⇔B)⊨(A∧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
We can convert the entailment (A∧B)⊨(A⇔B) to an implication of the form A∧B→(A⇔B)
By constructing a truth table, we can determine whether the implication is valid.
A
B
A∧B
(A∧B)→(A⇔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
We can convert the entailment (A⇔B)⊨(A∧B) to an implication of the form (A⇔B)→(A∨B)
By constructing a truth table, we can determine whether the implication is valid.
A
B
A⇔B
A∧B
(A∧B)→(A⇔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:
Convert all sentences to Conjugative Normal Form (CNF)
Negate the desired conclusion
Apply the resolution rule, until we either:
Derive false (a contradiction)
Can't apply the rule anymore.
The resolution refutation rule is sound and complete (for propositional logic):
If we derive a contradiction, the conclusion follows from the axioms (proof by contradiction)
If we can't apply the rule any more, the conclusion cannot be proven from the axioms (no entailment, invalid statement).
Exercise 5.3
Use the resolution refutation rule to show
(P∧¬P)⊨R
(Note: negation can be represented by "¬" or "~" or "!" or just plain "not")
Use the resolution refutation rule to show that (P∧¬P)⊨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:
¬A∨BB∨CA∨C
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)=(F∨P)∧(¬P∨F)
Secondly, we negate the conclusion to get¬(R)≡¬R
We then apply the resolution refutation rule. Our first and second clauses are F∨P and ¬P∨F with conclusion ¬R.
¬F∨PP∨F¬R
Applying the resolution refutation rule yields F∨F=F. We have derived False which is a contradiction. Since False entails anything including R 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:
Either bumper cars or carousel must be open
If bumper cars is closed, then roller coaster must be open.
If carousel is open, the either bumper cars or haunted class must be open too
If haunted class is open, then ferris wheel must be open too.
Bumper cars and ferris wheel cannot both be open at the same day.
If roller coaster is open, then ferris wheel must be open too.
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.
Please frame this problem as a satisfiability problem with propositional logic representation
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:
Either bumper cars or carousel must be openB∨C
If bumper cars is closed, then roller coaster must be open¬B→R⇒¬(¬B)∨R⇒B∨R
If carousel is open, then either bumper cars or haunted class must be openC→(B∨H)⇒¬C∨B∨H
If haunted class is open, then ferris wheel must be open tooH→W⇒¬H∨W
Bumper cars and ferris wheel cannot both be open on the same day¬(B∧W)⇒¬B∨¬W
If roller coaster is open, then ferris wheel must be open tooR→W⇒¬R∨W
If roller coaster is closed, then either haunted class or ferris wheel must be open¬R→(H∨W)⇒¬(¬R)∨(H∨W)⇒R∨H∨W
We then combine each of the clauses using the CNF syntax
(B∨C)∧(B∨R)∧(¬C∨B∨H)∧(¬H∨W)∧(¬B∨¬W)∧(¬R∨W)∧(R∨H∨W)
Exercise 5.4b
We count the occurrences of each variable in the CNF statement
B=4C=2H=3R=3W=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
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=4H=2R=2
Since W is the variable with the next-most entries we choose to assign it next. We first choose to assign W=True.
Since this assignment doesn't hold (statement isn't true for all assignment), we try W=False.
(¬H∨W)∧(¬W)∧(¬R∨W)∧(R∨H∨W)(¬H)∧(¬R)∧(R∨H)
Counting the variable occurrences, we get H=2 and R=2. We choose to assign H=True
(¬T)∧(¬R)∧(R∨T)(F)∧(¬R)F
Since this variable assignment doesn't hold, we try to assign H=False.
(¬F)∧(¬R)∧(R∨F)(¬R)∧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.