2. Propositional Logic Concepts
• Logic is a study of methods and principles
used to distinguish correct from incorrect
reasoning.
It is supposed to explicate the laws of thought.
Formally it deals with the notion of truth in an
abstract sense and is concerned with the
principles of valid inferencing.
A proposition in logic is a declarative
statement such as “Jack is a male”, "Jack loves
Mary" etc. which is either true or false (but not
both) in a given context.
Dr. Amit Kumar, Dept of CSE,
3. If we are given some propositions to be true in
a given context, then logic helps in inferencing
new proposition, which is also true in the
same context.
For example, if a set of propositions "it is hot
today" and "if it is hot it will rain" are given,
then one can infer that "it will rain today".
Dr. Amit Kumar, Dept of CSE,
4. It basically refers to set of rules used to combine
propositions to form compound propositions
using logical operators often called connectives.
This is a syntactic part of logic, which deals with
just strings of propositional symbols and with the
method or process used for performing
manipulation of the symbols according to some
rules and laws.
If inference rules are associated with PC, then
it becomes Propositional Logic.
Propositional Calculus
(language of propositions)
Dr. Amit Kumar, Dept of CSE,
5. Propositional Calculus alphabets
Two parentheses ‘(‘ and ‘)’.
A set of propositional
symbols or variables
P, Q, R, … often called
atoms.
Logical constants true ( T ) and false ( F ).
A set of logical operators (connectives):
V
~
And (conjunction) Or
(disjunction) Not (negation)
Implies (conditional i.e., If .. then)
Equivalence (biconditional )
Set of equivalence relations (laws)
Formal definition of Propositional Calculus is given as follows:
Rank -1
Rank-2
Rank-3
Rank-4
Rank-5
Dr. Amit Kumar, Dept of CSE,
6. Well-formed formula in Propositional Calculus
is defined as follows:
An atom is a well-formed formula
If is a well-formed formula, then ~ is a
well-formed formula.
If and are well formed formulae, then (
), ( V ), ( ), ( ) are also well-
formed formulae.
A propositional expression is a well-formed
formula if and only if it can be obtained by
using above conditions.
Dr. Amit Kumar, Dept of CSE,
7. There are various approaches for proving
validity, consistency and inconsistency of a
propositional expression or set of expressions.
Truth Table Approach
It gives us operational definitions of important
logical operators.
Using truth table, the truth values of well-
formed formulae are calculated.
Dr. Amit Kumar, Dept of CSE,
8. Each well-formed formula has a unique truth
value, which is computed from the truth values
of its constituents in accordance with the
precedence rules of operators.
Truth table elaborates all possible truth values
of a formula.
If formula contains n distinct atoms, then there
are 2n distinct rows in a truth table.
The meanings of the logical operators are
given by the following truth table.
Dr. Amit Kumar, Dept of CSE,
9. P Q ~P P Q P V Q P Q P Q
T T F T T T T
T F F F T F F
F T T F T T F
F F T F F T T
Dr. Amit Kumar, Dept of CSE,
10. • Evaluate the truth value of the formula,
(P Q) R P Q V S given the truth
values of atoms in a set {P, Q, R , S} as
{ F, T, F, T}.
(P Q) R P Q V S
= (F T) F F T V T
= T F F T V T
= F F T V T
= F F V T
= F T = F
Dr. Amit Kumar, Dept of CSE,
11. Equivalence Laws
Commutation
Q P
Q V P
(P Q) R
(P V Q) V R
1. P Q
2. P V Q
Association
1. P (Q R)
2. P V (Q V R)
Double Negation
~ (~ P) P
Dr. Amit Kumar, Dept of CSE,
12. (P Q) V (P R)
(P V Q) (P V R)
Distributive Laws
1.P ( Q V
R)
2.P V ( Q R)
De
Morgan’s Laws 1. ~
(P Q)
2. ~ (P V Q)
~ P V ~ Q
~ P ~ Q
Law of Excluded Middle
P V ~ P T (true)
F (false)
Law of Contradiction
P ~ P
Idempotence
1. P P P
2. P V P P
Dr. Amit Kumar, Dept of CSE,
13. Absorption
1.P (P V Q)
2.P V (P Q)
3. P V ( ~ P Q)
4. P ( ~ P V Q)
P P
P
V
Q
P
Q
• There are some commonly used equivalence relations
listed below:
P F F
P T P
P V F P
P V T T
P Q ~ P V Q
P Q
(P Q) (Q P)
(P Q) V (~ P ~ Q)
Dr. Amit Kumar, Dept of CSE,
14. Method1
•(Syntactic method): Derive a formula
from formulae known as valid in a
formal (syntactic) manner.
Method2
•(Semantic method): Calculate the truth
value of a formula for each assignment
using truth table.
Dr. Amit Kumar, Dept of CSE,
15. Use of truth table for
• Checking Validity
• Checking satisfiability /consistence
• Checking unsatisfiability / inconsistence
• Checking logically equivalency
• Checking logically consequence
Dr. Amit Kumar, Dept of CSE,
16. • Propositional Logic basically deals with the
validity, satisfiability and unsatisfiability of a
formula and derivation of a new formula using
equivalence laws.
• A formula is called tautology if and only if KB
is true for all interpretations.
• A formula KB is said to be inconsistent
(unsatisfiable), if and only if KB is always false
under all interpretations.
• Each row of a truth table for a given formula is
called its interpretation under which a formula
can be true or false.
Dr. Amit Kumar, Dept of CSE,
17. • An interpretation is called a model of a formula KB
if it is evaluated to be true under that interpretation.
• Validity: a formula is also said to be valid, if it
is a tautology.
• Let KB be a formula and if there exist at least one
interpretation for which KB is true, then KB is said
to be consistent (satisfiable) i.e., if a model for
KB.
• Sentence P entails sentence Q(in other words Q is
logical consequence of P), written P |= Q, means that
whenever P is True, so is Q. In other words, all
models of P are also models of Q .
Dr. Amit Kumar, Dept of CSE,
18. •Intuitively, we think of two sentences as being equivalent if
they say the same thing, i.e. they are true in exactly the same
worlds.
•More formally, we say that a sentence φ is logically
equivalent to a sentence ψ if and only if every truth
assignment that satisfies φ satisfies ψ and every truth
assignment that satisfies ψ satisfies φ.
Dr. Amit Kumar, Dept of CSE,
19. Example: Consider KB = { P V Q R Q , P V
Q} a set of formulae. Show that R Q is a logical
consequence of KB .
Solution:
Let : P V Q R Q
• Draw truth table and see that for {P = T,
Q = T, R = T} and {P = F, Q = T, R = T}, all
formulae in
KB= {, P V Q} are true and so is R Q.
• Hence R Q is a logical
consequenceof
{ P V Q R Q , P V Q }.
Check logical consequence
Dr. Amit Kumar, Dept of CSE,
20. P Q R P V Q R Q P V Q R Q KB
T T T T T T T
T T F T F F F
T F T T F F F
T F F T F F F
F T T T T T T
F T F T F F F
F F T F F T F
F F F F F T F
KB = (P V Q R Q ) P V Q
Dr. Amit Kumar, Dept of CSE,
21. • We can also translate simple, declarative
and conditional (if
sentences into
.. then) English
its corresponding
propositional formulae.
•Using truth table, one can easily test the
validity or inconsistency of English text as
follows:
– Convert entire text into a set of corresponding
propositional formulae and
--- then draw a truth table to check whether a
formula is true or false under all interpretations in
order to prove validity or inconsistency of text.
Dr. Amit Kumar, Dept of CSE,
22. Example: Show that "If I look into the sky and I
am alert then either I will see a dim star or if I
am not alert then I will not see a dim star" is
valid.
Solution: Let us symbolize the statements by
using propositional atoms.
P. :
Q. :
R. :
I look into the sky;
I am alert
I will see a dim star
Check validity and inconsistency
Dr. Amit Kumar, Dept of CSE,
23. • Formula corresponding to a text:
"If I look into the sky and I am alert then either I
will see a dim star or if I am not alert then I will
not see a dim star" is
: ((P Q) R) V ( ~ Q ~
R)
• From the following truth table we see that
above formula is true under all
interpretations.
Dr. Amit Kumar, Dept of CSE,
24. P Q R P Q P Q R ~ Q ~ R
T T T T T T T
T T F T F T T
T F T F T F T
T F F F T T T
F T T F T T T
F T F F T T T
F F T F T F T
F F F F T T T
Dr. Amit Kumar, Dept of CSE,
25. Example: Consider the three facts we know about the weather:
(1)"If it is hot and humid, then it is raining,"
(2)"If it is humid, then it is hot,"
(3)"It is humid."
Now let's ask the query "Is it raining?" That is, is the query sentence R is a
logical consequence of KB? Using the truth-table approach to
answering this query we have:
Solution:
Let us symbolize the statements by using propositional atoms
P = If it is hot
Q = It is humid
R = it is raining
Using the "weather" sentences from above, let
KB = (((P ^ Q) => R) ^ (Q => P) ^ Q)
Logical consequence, Validity and Consistence
Dr. Amit Kumar, Dept of CSE,
27. In this problem
1. There is only one model of KB, when P, Q, and R are all
True. And in this case R is also True, so R is logical
consequence of KB.
2. Also, you can see that the last column is all True values, so
the sentence KB => R is valid.
3. The KB => R is also consistent as it contain T in first row.
Dr. Amit Kumar, Dept of CSE,
28. • Show that the set of statements "I will be wet if
it rains and I go out of the house. It is raining
now. I go out of the house. I will not be wet"
are inconsistent.
• Show that "it is raining" is a logical
consequence of the sentences "If it is hot then
it will rain" and "It is hot today"
• Given "If it is Sunday and nice weather then
we go swimming. Today is Sunday. Weather is
nice" show that "we will go swimming" is
logical consequence of the above text.
Tutorial
Dr. Amit Kumar, Dept of CSE,
29. Natural Deduction Systems in Propositional
Logic
• Truth table method for problem solving is simple and
straightforward.
• It is very good at presenting a survey of all the truth
possibilities in a given situation.
• Truth table approach is an easy method of evaluating
a consistency, inconsistency or validity of a formula,
but the problem with truth table is that the size of the
table grows rapidly.
Dr. Amit Kumar, Dept of CSE,
30. • If a formula contains n atoms, then the truth table
will contain 2n entries. Truth table method is good
for small values of n.
• This method can be easily programmed on
computer but is highly uneconomical from
storage point of view because the size of the table
grows exponentially.
• For example,
– if we have to show that a formula : (P Q R) ( Q V
S) is valid using truth table approach, then we have to
construct a table of 16 rows for which the truth values of
are computed.
Dr. Amit Kumar, Dept of CSE,
31. • If we carefully analyze , we realize that if (P Q
R) is false, then is bound to be true because of
the definition of . Since (P Q R) is false for
14 entries out of 16, we are left only with two
entries to be tested for which P Q R.
• Therefore, we may find that in order to prove the
validity of a formula, all the entries in the truth
table are not relevant in this case.
• Lot of time is wasted in computing non relevant
entries. Therefore, different and more direct
methods are needed.
Dr. Amit Kumar, Dept of CSE,
32. • There are other methods in which the treatment
is more of a syntactic in nature where we will
be concerned with proofs and deductions.
• These are Natural Deductive System
and
Axiomatic System.
• These methods do not rely on any notion of
truth but only on manipulating sequence of
formulae.
Dr. Amit Kumar, Dept of CSE,
33. Limitation of Propositional Logic
•The facts: “peter is a man”, “paulis a man”, “john is a man” can
be symbolized by P, Q and R, respectively in PL.
•But we would not be able to draw any conclusions about
similarities between P, Q and R.
•It would be much better to represent these facts as MAN(peter),
MAN(paul) and MAN(john).
•Further, we are even in more difficulty, if we try to represent
sentences like “All men are mortal” in PL.
Dr. Amit Kumar, Dept of CSE,
34. •In Predicate Logic, such sentences can be easily represented and
the limitations of propositional logic are removed to great extent.
•The predicate logic is logical extension of propositional logic.
The first order predicate logic is one where the quantification is
over simple variables.
Predicate Calculus
•It has three more logical notions as compared to propositional
calculus.
Terms,
Predicates
Quantifiers (universal or existential quantifiers i.e. “for all' and
“there exists”)
Dr. Amit Kumar, Dept of CSE,
35. •Term: A term is a constant (single individual or concept i.e., 5,
john etc.), a variable that stands for different individuals and n-
place function f(t1, …, tn) where t1, …, tn are terms.
•A function is a mapping that maps ‘n’ terms to a term. In other
words, it represents a relation that is functional.
Ex: the cosine of any angle can be only one number :
Cosine(angle,number)
•A predicate is a relation that maps ‘n’ terms to a truth value true
(T) or false (F).
Examples:
•A statement x is greater than y is represented in predicate calculus
as GREATER(x, y). It is defined as follows:
GREATER( x, y) =T , if x >y
= F , otherwise
Dr. Amit Kumar, Dept of CSE,
36. •A statement x loves y is represented as LOVE(x, y) which maps
it to true or false when x and y get instantiated to actual values.
•A statement john’s father loves john is represented as
LOVE(father(john), john). Here, father is a function that maps
john to his father.
•The predicate names GREATER and LOVE take two terms and
map to T or F depending upon the values of their terms.
Quantifiers: Variables are used in conjunction with quantifiers.
There are two types of quantifiers viz.., “there exist” (∃) and “for
all” (∀).
Ex: All dogs are mammals : ∀x Dog(x) mammals(x)
Spot has a sister who is dog : ∃y sister (y, spot) Λ Dog(y)
everyone is loyal to someone : ∀x, ∃y loyalto(x,y)
Dr. Amit Kumar, Dept of CSE,
37. Example: Translate the text "Every man is mortal. John is a
man. Therefore, John is mortal" into Predicate Calculus
formula.
Solution: Let
MAN(x), MORTAL(x) represent ‘x is a man’ and ‘x is mortal’
respectively.
•Every man is mortal :(∀x) (MAN(x) →MORTAL(x))
•John is a man: MAN(john)
•John is mortal: MORTAL(john)
The whole text can be represented by the following formula.
(∀x) ((MAN(x) →MORTAL(x)) ΛMAN(john))
→MORTAL(john)
Dr. Amit Kumar, Dept of CSE,
38. First Order Predicate Logic (FOL)
•First order predicate calculus becomes First Order Predicate
Logic if inference rules are added to it.
•Using inference rules one can derive new formula using the
existing ones.
Interpretations of Formulae in FOL
•In PL, an interpretation is simply an assignment of truth
values to the atoms. In FOL, there are variables, so we have to
do more than that.
Dr. Amit Kumar, Dept of CSE,
39. •We use notation I[α] = T (or F), which means that α is
evaluated to be true or false under interpretation I over a
domain D.
•Let α and β are formulae and I be an interpretation over any
domain D. The following holds true.
•I[αΛβ] = I[α] ΛI[β]
•I[αV β] = I[α] V I[β]
•I[α→β] = I[α] →I[β]
•I[~α] = ~ I[α]
= T if and only if I[α] = F
•For any interpretation I and formulae using (∀x) and (∃x),
the following results holds true.
•I[(∀x)P(x)] = T iff I[P(x)] = T, ∀x ∈D
= F, otherwise
•I[(∃x) P(x)] = T iff ∃c∈D such that I[P(c)] = T
= F, otherwise
Dr. Amit Kumar, Dept of CSE,
40. •A formula α is said to be consistent (satisfiable) if and only if
there exists an interpretation I such that I[α] = T. Alternatively we
say that I is a model of α or I satisfies α.
•A formula α is said to be inconsistent(unsatisfiable) if and only
if ∃no interpretation that satisfies αor there exists no model for α.
•A formula α is valid if and only if for every interpretation I, I[α] =
T.
•A formula α is a logical consequence of a set of formulae {α1,
α2, ..., αn} if and only if for every interpretation I, if I[α1Λ…Λαn]
= T, then I[α] = T.
Dr. Amit Kumar, Dept of CSE,
41. we now explore the use of predicate logic as a way of representing
knowledge. Consider the following set of sentences:
1. Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian.
Pompeian(Marcus)
3. All Pompeians were Romans.
∀ x : Pompeian(x) Roman(x)
4. Caesar was a ruler.
ruler(Caesar)
Dr. Amit Kumar, Dept of CSE,
42. 5. All Romans were either loyal to Caesar or hated him.
∀ x: Roman(x) loyalto(x, Caesar) V hate(x,Caesar)
6. Everyone is loyal to someone.
∀x, ∃y loyalto(x,y)
7. People only try to assassinate rulers they are not loyal to.
∀ x : ∀ y : person(x) Λ ruler(y) Λ tryassasinate(x,y)
~loyalto(x,y)
8. Marcus tried to assassinate Caesar.
tryassasinate (Marcus,Caesar)
say suppose we wish to answer the following question:
Was Marcus loyal to Caesar?
Dr. Amit Kumar, Dept of CSE,
43. •we do is start reasoning backward from the
desired goal which is represented in predicate
logic as given in figure.
•Aim is to produce a proof of the goal by reducing
the set of necessary but as yet unattained goals
to the empty sets.
•In given example, attempts fail as we do not
have any statement to prove person(Marcus).
• The problem is solved just by adding an
additional statement i.e.
All men are people.
∀ x : man(x) person(x)
Dr. Amit Kumar, Dept of CSE,
44. Let’s take another example to make things more clear. Consider the
following sentences.
1. John likes all kinds of food.
2. Apples are food.
3. Anything anyone eats and is not killed by is food.
4. Bill eats peanuts and is alive.
5. Sue eats every thing Bill eats.
Now we prove that “John likes peanuts” using backward chaining.
1. John like all kinds of food.
∀ x : food (x) likes (Johns ,x)
2. Apples are food.
food (apple)
3. Anything anyone eats and is not killed by is food.
∀ x : ∀ y: eats (x, y) Λ ~ killedby (x, y) food (y).Dr. Amit Kumar, Dept of CSE,
45. 4. Bill eats peanuts and is alive.
eats (Bill, peanuts) Λ ~killedby (Bill,peanuts)
here we assume that alive is same as not killed by. Or, we can add additional fact
as if you are still alive then you haven’t been killed by anything
∀ x : ∀ y : alive(x) ~killedby(x,y)
5. Sue eats everything Bill eats.
∀ x : food(x) Λ eats (Bill, x) eats (Sue, x)
likes (John, peanuts)
(1, substitution)
food (peanuts)
(3, substitution)
eats (Bill, peanuts) ~ killed by (Bill, peanuts)
(4)
nil
(3, substitution)
Dr. Amit Kumar, Dept of CSE,
46. Representing Instance and is a Relationships
1. The predicate logic have not used the predicates instance and isa explicitly.
However, the relationships they are used to express, namely class
membership and class inclusion, is captured implicitly.
Ex:
man(Marcus)
Pompeian(Marcus)
∀ x : Pompeian(x) Roman(x)
ruler(Caesar)
∀ x: Roman(x) loyalto(x, Caesar) V hate(Caesar)
Explicit representation:
The predicate instance is a binary one, whose first argument is an object and whose
second argument is a class to which the object belongs.
Instance(Marcus,man)
Instance(Marcus, Pompeian)
∀ x : Instance(x,Pompeian) Instance(x,Roman)
Instance( Caesar, ruler)
∀ x: Instance(x,Roman) loyalto(x, Caesar) V hate(x, Caesar)
Dr. Amit Kumar, Dept of CSE,
47. Representing Instance and is a Relationships
1. The predicate logic have not used the predicates instance and isa explicitly.
However, the relationships they are used to express, namely class
membership and class inclusion, is captured implicitly.
Ex:
man(Marcus)
Pompeian(Marcus)
∀ x : Pompeian(x) Roman(x)
ruler(Caesar)
∀ x: Roman(x) loyalto(x, Caesar) V hate(Caesar)
Explicit representation:
The predicate instance is a binary one, whose first argument is an object and whose
second argument is a class to which the object belongs.
1. Instance(Marcus,man)
2. Instance(Marcus, Pompeian)
3. ∀ x : Instance(x,Pompeian) Instance(x,Roman)
4. Instance( Caesar, ruler)
5. ∀ x: Instance(x,Roman) loyalto(x, Caesar) V hate(x, Caesar)
Dr. Amit Kumar, Dept of CSE,
48. Isa relationship
1. Isa predicate is used to show subclass-superclass relationship.
2. The implication rule in sentence 3 states that if an object is an instance of
the subclass Pompeian then it is an instance of the superclass Roman.
1. Instance(Marcus,man)
2. Instance(Marcus, Pompeian)
3. Isa(Pompeian, Roman)
4. Instance( Caesar, ruler)
5. ∀ x: Instance(x,Roman) loyalto(x, Caesar) V hate(x, Caesar)
6. ∀ x: ∀ y: ∀ z: Instance( x, y) Λ isa(y,z) Instance( x, z)
In logical representation, it is difficult to define overriding property
Suppose, for example, that, in addition to the facts we already have, we add the
following:
Pompeian(Paulus)
~ [loyalto(Paulus, Caesar) V hate(Paulus, Caesar)]
•In other words, suppose we want to make Paulus an exception to the general rule
about Romans and their feelings toward Caesar.
•Unfortunately, we cannot simply add these facts to our existing knowledge base.
•The difficulty is that if the old assertions are left unchanged, then the addition of
the new assertions makes the knowledge base inconsistent. So our original
sentence 5 must become
1. ∀ x : Roman(x) Λ ~eq(x, Paulus) loyalto(x, Caesar) V hate(x, Caesar)
Dr. Amit Kumar, Dept of CSE,
49. Computable Functions and Predicates
•Till now all the examples we have discussed all the facts were expressed as
combinations of individual predicates, such as:
tryassassinate(Marcus, Caesar)
This is fine if the number of facts is not very large
•But suppose we want to express simple facts, such as the following greater-than and
less-than relationships:
gt(1,0) lt(0,1)
gt(2,1) lt(1,2)
gt(3,2) lt(2,3)
: :
: :
• There was no need to write out the representation of each of these facts individually.
For one thing, there are infinitely many of them.
•To represent such facts, computable predicates are used.
When such commutable predicates are encountered by reasoning process, we can
simply invoke a procedure, which we will specify in addition to our regular rules, that will
evaluate it and return true or false.
Ex: gt(2+3,1) , To do so requires that we first compute the value of the plus function
given the arguments 2 and 3, and then send the arguments 5 and 1 to gt.Dr. Amit Kumar, Dept of CSE,
50. Computable Functions example
Original facts given as:
1. man(Marcus)
2. Pompeian(Marcus)
3. Marcus was born in 40 A.D. : born(Marcus, 40)
4. All men are mortal. ∀ x : man(x) mortal(x)
All Pompeians died when the volcano erupted in 79 A.D.
erupted(volcano, 79) Λ ∀ x : [Pompeian(x) died(x, 79)] can be written as
5. ∀ x : [Pompeian(x) died(x, 79)] 6. erupted(volcano, 79)
7. No mortal lives longer than 150 years.
∀ x: ∀ t1 : ∀ t2 : mortal(x) Λ born(x, t1) Λ gt(t2-t1,150) dead(x, t2)
Or ∀ x: mortal(x) Λ gt(age(x), 150) dead(x)
8. It is now 1991. now = 1991
Additional Fact: added later
9. Alive means not dead. ∀ x : ∀ t : [alive(x,t) ~dead(x,t)] Λ [~dead(x,t) alive(x,t)
10. If someone dies, then he is dead at all later times.
∀ x: ∀ t1 : ∀ t2 : died(x,t1) Λ gt(t2, t1) dead(x, t2)
Dr. Amit Kumar, Dept of CSE,
51. Is Marcus alive?
Answer : No
Reason 1: Marcus is dead because he was killed by the volcano.
Reason2: he must be dead because he would otherwise be more than 150
years old, which we know is not possible
Dr. Amit Kumar, Dept of CSE,
52. Resolution
Two things should be clear from the proofs we have just shown:
1. Even very simple conclusions can require many steps to prove.
2. A variety of processes, such as matching, substitution, and
application of modus ponens are involved in the production of a
proof, This is true even for the simple statements we are using, It
would be worse if we had implications with more than a single term
on the right or with complicated expressions involving ands and ors
on the left.
3. Therefore, we introduce, a proof procedure called resolution that
reduces some of the complexity because it operates on statements
that have first been converted to a single canonical form.
Dr. Amit Kumar, Dept of CSE,
53. Resolution
1. Resolution is such a procedure, which gains its efficiency from the fact that it
operates on statements that have been converted to a very convenient standard
form.
2. Resolution produces proofs by refutation. In other words, to prove a statement
(i.e. show that it is valid), resolution attempts to show that the negation of the
statement produces a contradiction with the known statements (i.e., that it is
unsatisfiable).
3. This approach contrasts with the technique that we have been using to generate
proofs by chaining backward from the theorem to be proved to the axioms.
4. For resolution to work, we need to go one step further. We need to reduce a set
of wff's to a set of clauses, where a clause is defined to be a wff in conjunctive
normal form but with no instances of the connector Λ .
5. We can do this by first converting each wff into conjunctive normal form and then
breaking apart each such expression into clauses, one for each conjunct.
6. All the conjuncts will be considered to be conjoined together as the proof
procedure operates. Dr. Amit Kumar, Dept of CSE,
54. Conversion to Clause Form
1. Eliminate , using the fact that a b is equivalent to ~ a V b. Performing this
transformation on the following wff for fact :
All the roman who knows marcus either hate caesar or think that anyone who hates anyone
is crazy Wff
∀ x: [Roman(x) Λ know(x, Marcus)] [hate(x, Caesar) V
(∀ y : (∃z : hate(y, z)) thinkcrazy(x,y))]
Clause form
∀ x: ~ [Roman(x) Λ know(x, Marcus)] V [hate(x, Caesar) V
(∀ y : ~(∃z : hate(y, z)) V thinkcrazy(x,y))]
2. Reduce the scope of each ~ to a single term, using the fact that ~ (~ p) = p,
deMorgan's laws [which say that
~(a Λ b) = ~ a V ~b and ~(a V b) = ~ a Λ ~ b], and
the standard correspondences between quantifiers
[~∀ x : P(x) = ∃ x : ~P(x) and ~ ∃ x : P(x) = ∀ x : ~ P(x)].
Performing this transformation on the wff from step 1 yields
∀ x: [~Roman(x) V ~know(x, Marcus)] V [hate(x, Caesar) V
(∀ y : ∀ z : ~hate(y, z) V thinkcrazy(x,y))]
For equivalence relationship use formula: P ↔Q ≅( P →Q) Λ( Q →P)
Dr. Amit Kumar, Dept of CSE,
55. 3. Standardize variables so that each quantifier binds a unique variable. Since
variables are just dummy names, this process cannot affect the truth-value of
the wff. For example, the formula
∀ x : P(x) V ∀ x : Q(x)
would be converted to
∀ x: P(x1) V ∀ x2 : Q(x2)
4. Move all quantifiers to the left of the formula without changing their relative
order. This is possible since there is no conflict among variable names.
Performing this operation on the formula of step 2, we get
∀ x: ∀ y : ∀ z : [~Roman(x) V ~know(x, Marcus)] V [hate(x, Caesar) V
(~hate(y, z) V thinkcrazy(x,y))]
At this point, the formula is in what is known as prenex normal form. It consists of a
prefix of quantifiers followed by a matrix, which is quantifier free.
5. Eliminate existential quantifiers. A formula that contains an existentially
quantified variable asserts that there is a value that can be substituted for the
variable that makes the formula true. We can eliminate the quantifier by
substituting for the variable a reference to a function
∃ y : President(y) can be transformed into the formula President(S1)
where S1 is a function with no arguments that somehow produces a value that
satisfies President. Dr. Amit Kumar, Dept of CSE,
56. If existential quantifiers occur within the scope of universal quantifiers, then the value
that satisfies the predicate may depend on the values of the universally quantified
variables. For example, in the formula
∀ x: ∃ y: father-of(y,x)
the value of y that satisfies father-of depends on the particular value of x. Thus we
must generate functions with the same number of arguments as the number of
universal quantifiers in whose scope the expression occurs. So this example would be
transformed into
∀ x :father-of(S2(x),x))
These generated functions are called Skolem functions. Sometimes ones with no
arguments are called Skolem constants.
6. Drop the prefix. At this point, all remaining variables are universally quantified, so
the prefix can just be dropped
[~Roman(x) V ~know(x, Marcus)] V [hate(x, Caesar) V (~hate(y, z) V thinkcrazy(x,y))]
7. Convert the matrix into a conjunction of disjuncts. In the case of our
example, since there are no and's (i.e. Λ ), it is only necessary to exploit the
associative property of or(i.e. V) [i.e., a V (b V c) = (a V b) V c] and simply
remove the parentheses, giving
~Roman(x) V ~know(x, Marcus) V hate(x, Caesar) V ~hate(y, z) V thinkcrazy(x,y)
Dr. Amit Kumar, Dept of CSE,
57. However, it is also frequently necessary to exploit the distributive property
[i.e., (a Λ b) V c = (a V c) Λ (b V c)]
For example, the formula
(winterΛ wearingboots) V (summerΛ wearingsandals)
becomes, after one application of the rule
[winter V (summerΛ wearingsandals)] Λ
[wearingboots V (summerΛwearingsandals)]
and then, after a second application.
(winter V summer) Λ
(winter V wearing sandals) Λ
(wearingboots V summer) Λ
(wearingboots V wearingsandals)
9. Create a separate clause corresponding to each conjunct. In order for a wff to be true,
all the clauses that are generated from it must be true. If we are going to be working
with several wff's, all the clauses generated by each of them can now be combined to
represent the same set of facts as were represented by the original wff's.
10. Standardize apart the variables in the set of clauses generated in step 8. By this we
mean rename the variables so that no two clauses make reference to the same
variable. In making this transformation, we rely on the fact that
(∀ x : P(x) Λ Q(x)) = ∀ x : P(x) Λ ∀ x : Q(x)Dr. Amit Kumar, Dept of CSE,
58. The Basis of Resolution
• The resolution procedure is a simple iterative process: at each step, two
clauses, called the parent clauses, are compared (resolved), yielding a new
clause that has been inferred from them. The new clause called as resolvent
,represents ways that the two parent clauses interact with each other.
Suppose that there are two clauses in the system:
1. winter V summer
2. ~winter V cold
By deleting winter from 1 and ~winter from 2 and constructing a new clause by
the disjunction of the remaining literals, these two clauses we can deduce
summer V cold
• If the clause that is produced is the empty clause, then a contradiction has
been found. For example, the two clauses
winter
~winter
will produce the empty clause. If a contradiction exists, then eventually it will be
found. Of course, if no contradiction exists, it is possible that the procedure will
never terminate, although as we will see, there are often ways of detecting that
no contradiction exists.
Dr. Amit Kumar, Dept of CSE,
59. Resolution in Propositional Logic
Given following axiom:
(P Λ Q) R , (S V T) Q, P , T
Prove R
Solution:
1. Covert axioms in clause
Given Axioms Converted to Clause Form
P P (1)
(P Λ Q) R ~P V ~Q V R (2)
(S V T) Q ~S V Q (3) {~(SVT)VQ = (~S Λ ~T)V Q }
~T V Q (4)
T T (5)
Proof
Dr. Amit Kumar, Dept of CSE,
60. Example : 2
Find resolvent of:
C1 = P V Q V R
C2 = ~ Q V ~ W
C3 = ~ P V ~ W
Inverted Resolution Tree
Resolvent(C1,C2, C3) = R V ~WDr. Amit Kumar, Dept of CSE,
61. Example : 3
Example: “Mary will get her degree only if she registers as a
student and pass her exam. She has registered herself as a
student. She has passed her exam”. Show that she will get a
degree.
Solution: Symbolize above statements as follows:
R:Mary is a registered student
P:Mary has passed her exam
D:Mary gets her degree
The formulae corresponding to the following sentence is as
follows:
R ΛP →D ≅~ R V ~ P V D ,
Conclude “Mary will get a degree”.
S= {~ R V ~ P V D , R, P }
By adding negation of "Mary gets her degree (= D)" to S, we get
S' ={~ R V ~ P V D , R, P, ~ D}
We can easily see that empty clause is deduced from above set.
Given below is the resolution tree.Dr. Amit Kumar, Dept of CSE,
62. Try to solve
1. Either Heather attended the meeting or Heather was not invited.
2. If the boss wanted Heather at the meeting, then she was invited.
3. Heather did not attend the meeting.
4. If the boss did not want Heather there, and the boss did not invite her there, then
she is going to be fired.
Prove Heather is going to be fired.
Solution:
Sentence in propositional logic
P= Heather attended the meeting
Q = Heather was invited
R= boss wanted Heather at the meeting
S = Heather is going to be fired
1. P V ~Q
2. R -> Q
3. ~P
4. ~R Λ ~Q S
Now convert above propositional formulas in clause and use resolution to prove
Heather is going to be fired
Dr. Amit Kumar, Dept of CSE,
63. Resolution in Predicate Logic
1. Resolution for the clauses containing no variables is very simple and is
similar to PL. It becomes complicated when clauses contain variables.
2. For example man (John) and ~man(John) is a contradiction, while
man(John) and ~man(Spot) is not
3. In such case, two complementary literals are resolved after proper
substitutions so that both the literals have same arguments. There is a
straightforward recursive procedure, called the unification algorithm that
does just this.
Dr. Amit Kumar, Dept of CSE,
64. 1. The basic idea of unification is very simple.
1. To attempt to unify two literals, we first check if their initial predicate
symbols are the same. If so, we can proceed. Otherwise, there is no way they
can be unified, regardless of their arguments. For example, the two literals
– tryassassinate(Marcus, Caesar)
– hate(Marcus, Caesar)
cannot be unified.
2. If the predicate symbols match, then we must check the arguments, one
pair at a time. If the first matches, we can continue with the second, and so
on.
3. The matching rules are simple.
• Different constants or predicates cannot match; identical ones can.
• A variable can match another variable, any constant, or a predicate
expression, with the restriction that the predicate expression must not
contain any instances of the variable being matched.
Ex: Suppose we were attempting to unify the expressions
f(x, x)
f(g(x), g(x))
If we accepted g(x) as a substitution for x, then we would have to substitute it for x in
the remainder of the expressions. But this leads to infinite recursion since it will never
be possible to eliminate x.
Unification
Dr. Amit Kumar, Dept of CSE,
65. • The only complication in this procedure is that we must find a single, consistent
substitution for the entire literal, not separate ones for each piece of it.
• To do this, we must take each substitution that we find and apply it to the
remainder of the literals before we continue trying to unify them.
For example, suppose we want to unify the expressions
P(x, x)
P(y, z)
The two instances of P match fine.
Next we compare x and y, and decide that if we substitute y for x, they could
match. We will write that substitution as y/x
But now, if we simply continue and match x and z, we produce the substitution z/
x.
we cannot substitute both y and z for x, so we have not produced a consistent
substitution.
What we need to do after finding the first substitution y/x is to make that
substitution throughout the literals, giving
P(y,y)
P(y, z)
Now we can attempt to unify arguments y and z, which succeeds with the
substitution z/y.
The entire unification process has now succeeded with a substitution that is the
composition of the two substitutions we found. We write the composition as
(z/y)(y/x)
Dr. Amit Kumar, Dept of CSE,
66. The object of the unification procedure is to discover at least one substitution
that causes two literals to match. Usually, if there is one such substitution there
are many. For example, the literals
hate(x,y)
hate(Marcus,z)
could be unified with any of the following substitutions:
(Marcus/x,z/y)
(Marcus/x,y/z)
(Marcus/x,Caesar/y,Caesar/z)
(Marcus/x,Polonius/y,Polonius/z)
Dr. Amit Kumar, Dept of CSE,
67. 1. We now have an easy way of determining that two literals are
contradictory-they are if one of them can be unified with the negation of
the other. So, for example, man (x) and ~man(Spot) are contradictory, since
man(x) and man(Spot) can be unified.
2. This corresponds to the intuition that says that man(x) cannot be true for all
x if there is known to be some x, say Spot, for which man(x) is false.
3. Thus in order to use resolution for expressions in the predicate logic, we
use the unification algorithm to locate pairs of literals that cancel out.
4. We also need to use the unifier produced by the unification algorithm to
generate the resolvent clause. For example, suppose we want to resolve
two clauses:
man(Marcus) (1)
~man(x1) V mortal(x1) (2)
Substitute marcus/x1 in (2) and cancel contradictory literal
Mortal(Marcus)
Resolution in Predicate Logic
Dr. Amit Kumar, Dept of CSE,
68. Take following axioms:
1. man(Marcus)
2. Pompeian(Marcus)
3. ∀ x : Pompeian(x) Roman(x)
4. ruler(Caesar)
5. ∀ x: Roman(x) loyalto(x, Caesar) V hate(x,Caesar)
6. ∀x, ∃y loyalto(x,y)
7. ∀ x : ∀ y : person(x) Λ ruler(y) Λ tryassasinate(x,y) ~loyalto(x,y)
8. tryassasinate (Marcus,Caesar)
9. ∀ x : man(x) person(x)
Axioms in clause form:
1. man(Marcus)
2. Pompeian(Marcus)
3. ~ Pompeian(x1) V Roman(x1)
4. ruler(Caesar)
5. ~ Roman(x2) V loyalto(x2, Caesar) V hate(x2,Caesar)
6. loyalto(x3,f(x3))
7. ~person(x4) V ~ ruler(y1) V ~ tryassasinate(x4,y1) V ~loyalto(x4,y1)
8. tryassasinate (Marcus,Caesar)
9. ~ man(x5) V person(x5)
Dr. Amit Kumar, Dept of CSE,
69. Prove hate( Marcus, Caesar)
~hate( Marcus, Caesar) 5
Marcus/x2
~ Roman(Marcus) V loyalto(Marcus, Caesar)3
Marcus/x1
~ Pompeian(Marcus) V loyalto(Marcus, Caesar)
2
loyalto(Marcus, Caesar)7
Marcus/x4, Caesar/y1
~person(Marcus) V ~ ruler(Caesar) V ~ tryassasinate(Marcus, Caesar)9
Marcus/x5,
~man(Marcus) V ~ ruler(Caesar) V ~ tryassasinate(Marcus, Caesar) 1
~ ruler(Caesar) V ~ tryassasinate(Marcus, Caesar)4
~ tryassasinate(Marcus, Caesar) 8
1. man(Marcus)
2. Pompeian(Marcus)
3. ~ Pompeian(x1) V Roman(x1)
4. ruler(Caesar)
5. ~ Roman(x2) V loyalto(x2, Caesar) V
hate(x2,Caesar)
6. loyalto(x3,f(x3))
7. ~person(x4) V ~ ruler(y1) V ~
tryassasinate(x4,y1) V ~loyalto(x4,y1)
8. tryassasinate (Marcus,Caesar)
9. ~ man(x5) V person(x5)
Dr. Amit Kumar, Dept of CSE,
70. John like peanuts
1. John like all kinds of food.
∀ x : food (x) likes (Johns ,x) = 1. ~ food (x1) V likes (Johns ,x1)
2. Apples are food.
food (apple) = 2. food (apple)
3. Anything anyone eats and is not killed by is food.
∀ x : ∀ y: eats (x, y) Λ ~ killedby (x, y) food (y) = ~(eats (x, y) Λ ~ killedby (x, y)) V food (y)
=3. ~eats (x2, y1) V killedby (x2, y1) V food (y1)
4. Bill eats peanuts and is alive.
eats (Bill, peanuts) Λ ~killedby (Bill,peanuts) =
4(a). eats (Bill, peanuts)
4(b). ~killedby (Bill,peanuts)
5. Sue eats everything Bill eats.
∀ x : food(x) Λ eats (Bill, x) eats (Sue, x)
5. ~( food(x3) Λ eats (Bill, x3) ) V eats (Sue, x3) = ~food(x3) V ~eats (Bill, x3) V eats (Sue, x3)
We add the negation of the Coff of the sentence “John likes peanuts” which we have to
prove
~ likes (John, peanuts) = ~likes (John, peanuts)Dr. Amit Kumar, Dept of CSE,
71. Resolution
~likes (John, peanuts)
1. ~ food (x1) V likes (Johns ,x1)
2. food (apple)
3. ~eats (x2, y1) V killedby (x2, y1) V food (y1)
4. (a). eats (Bill, peanuts) 4(b). ~killedby (Bill,peanuts)
5. ~food(x3) V ~eats (Bill, x3) V eats (Sue, x3)
1
~ food (peanuts)
X1/ peanuts
3
~eats (bill, peanuts ) V killedby (bill, peanuts)
y1/ peanuts ,x2/bill
4a
killedby (bill, peanuts) 4b
Dr. Amit Kumar, Dept of CSE,