2. Artificial Intelligence
Unit – III
Logic Concepts: Introduction, propositional calculus, propositional logic, natural
deduction system, axiomatic system, semantic tableau system in propositional logic,
resolution refutation in propositional logic, predicate logic.
3. Aditya Engineering College (A)
LOGIC CONCEPTS
Logic helps in investigating and classifying the structure of statements and
arguments through the system of formal study of inference.
Logic is a study of principles used to
– distinguish correct from incorrect reasoning.
– Logical system should possesses properties such as consistency, soundness, and
completeness.
– Consistency implies that none of the theorems of the system should contradict each other.
– Soundness means that the inference rules shall never allow a false inference from true
premises.
Formally it deals with
– the notion of truth in an abstract sense and is concerned with the principles of valid
inferencing.
4. Aditya Engineering College (A)
Logic…
A proposition in logic is a declarative statements which are either true or
false (but not both) in a given context. For example,
– “Jack is a male”,
– "Jack loves Mary" etc.
Givensome propositions to be true ina given context,
– logic helps in inferencing new proposition, which is also true in the
same context.
Suppose we are given a set of propositions as
– “It is hot today" and
– “If it is hot it will rain", then
– we can infer that
“It will rain today".
5. Propositional Calculus
Aditya Engineering College (A)
Propositional Calculus is a language of propositions basically
refers
– to set of rules used to combine the propositions to form compound
propositions using logical operators often called connectives such as
or dot, V, ~, or ( ),
1.Well-Formed Formula
Well-formed formula is defined as:
– 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.
6. Propositional Calculus
Aditya Engineering College (A)
Well-Formed Formula Examples
R1-An atom is a well-formed formula.
R2-If is a WFF, then ~ is a
well-formed formula.
R3-If and are well formed formulae, then ( ),
( V ), ( ),( ) are also well-formed
formulae.
7. Aditya Engineering College (A)
Propositional Calculus…
2.Truth Table
Truth table gives us operational definitions of
important logical operators.
– By using truth table, the truth values of well-formed
formulae are calculated.
● Truth table elaborates all possible truth values of a
formula.
● The meanings of the logical operators are given by
the following truth table.
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
Q) Compute the TT: (AVB) ∧ (~B->A)
Negation ~
Conjunction ^ or dot
Disjunction V
If-then(Implication) ->
iff(Biconditional) <->
8. Aditya Engineering College (A)
3.Equivalence Laws
1. P Q Q P
2. P V Q Q V P
Commutation
Association
1. P (Q R) (P Q) R
2. P V (Q V R) (P V Q) V R
Double Negation
~ (~ P)
Distributive Laws
P
1. P ( Q V R) (P Q) V (P R)
2. P V ( Q R) (P V Q) (P V R)
Morgan’s Laws
1. ~ (P Q) ~ P V ~ Q
2. ~ (P V Q) ~ P ~ Q
De
Law of Excluded Middle
P V ~ P
Law of Contradiction
P ~ P
T (true)
F (false)
Propositional Calculus…
9. Aditya Engineering College (A)
Propositional Logic
• Knowledge Representation can be done with
1)Propositional Logic 2)First Order Logic
• Propositional logic (PL) is the simplest form of logic where all the
statements are made by propositions.
• A proposition is a declarative statement which is either true or false.
It is a technique of knowledge representation in logical and
mathematical form.
• Propositional logic is also called Boolean logic as it works on 0 and
• Machine In AI can be given input in terms of knowledge but machine cannot understand this
knowledge which is framed using English sentences.
• So this knowledge must be represented ina way understandable to machine , this is called
knowledge representation.
10. Aditya Engineering College (A)
Propositional Logic
• In propositional logic, we use symbolic variables to represent the logic, and we can
use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
• Propositions can be either true or false, but it cannot be both.
• Propositional logic consists of an object, relations or function, and logical
connectives.
• These connectives are also called logical operators.
• The propositions and connectives are the basic elements of the propositional logic.
• Connectives can be said as a logical operator which connects two sentences.
• A proposition formula which is always true is called tautology, and it is also called a
valid sentence.
•A proposition formula which is always false is called Contradiction.
•A proposition formula which has both true and false values is called.
•Statements which are questions, commands, or opinions are not propositions
such as "Where is ", "How are you", "What is your name", are not propositions.
11. Aditya Engineering College (A)
Propositional Logic
Syntax of propositional logic:
• The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
Atomic Propositions:
Atomic Proposition: Atomic propositions are the simple propositions. It consists of a
single proposition symbol. These are the sentences which must be either true or false.
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
Compound propositions
•Compound propositions are constructed by combining simpler or atomic
propositions, using parenthesis and logical connectives.
Example:
a) "It is raining today, and street is wet."
b) “Raj is a doctor, and his clinic is in Mumbai."
12. Aditya Engineering College (A)
Propositional Logic
Logical Connectives
Negation ~
Conjunction ^
Disjunction V
If-then(Implication) ->
iff(Biconditional) <->
Logical connectives are used to connect two simpler propositions or representing a sentence
logically. We can create compound propositions with the help of logical connectives.
Example:
X: It is cold
Y: It is sunny
Z:It is breezy
1. It is not cold ~X
2. It is cold and it is breezy X^Z
3. It is cold or it is breezy XvZ
4. If it is breezy then it is cold Z->X
5. If it is breezy and cold then it is not sunny Z^X -> ~Y
6. It will be cold iff it is breezy X <-> Z
13. Aditya Engineering College (A)
Propositional Logic
Examples:
Raj did not read book
~ read(Raj,book)
Raj watches Amazon or Netflix
Watches(Raj,Amazon) v Watches(Raj,Netflix)
If Raj buys mobile then color is black
Buys(Raj,Mobile) -> Color( Mobile,black)
Raj becomes happy if and only if Raj eats dairy milk.
becomes(Raj,happy) <-> eats( Raj,Dairy milk)
14. Limitations of Propositional logic:
•We cannot represent relations like ALL, some, or none with propositional
logic. Example:
• All the boys are intelligent.
• Some apples are sweet.
•Propositional logic has limited expressive power.
•In propositional logic, we cannot describe statements in terms of their
properties or logical relationships.
Propositional Logic
15. Aditya Engineering College (A)
Natural Deduction System
● ND is based on the set of few deductive inference rules.
● The name natural deductive system is given because it mimics
the pattern of natural reasoning.
● It has about 10 deductive inference rules.
Conventions:
– E for Elimination, I for Introducing.
– P, Pk , (1 k n) are atoms.
– k, (1 k n) and are formulae.
16. Aditya Engineering College (A)
Natural Deduction System
ND RULES:
Rule 1: I- (Introducing )
I- : If P1, P2, …, Pn then P1 P2 … Pn
Interpretation: If we have hypothesized or proved P1, P2, … and Pn , then their conjunction
P1 P2 … Pn is also proved or derived.
Rule 2: E- ( Eliminating )
E- : If P1 P2 … Pn then Pi ( 1 i n)
Interpretation: If we have proved P1 P2 … Pn , then any Pi is also proved or derived.
This rule shows that can be eliminated to yield one of its conjuncts.
Rule 3: I-V (Introducing V)
I-V : If Pi ( 1 i n) then P1V P2 V …V Pn
Interpretation: If any Pi (1 i n) is proved, then P1V … V Pn is also proved.
17. Aditya Engineering College (A)
Natural Deduction System
ND RULES…
Rule 4: E-V ( Eliminating V)
E-V : If P1 V … V Pn, P1 P, … , Pn P then P
Interpretation: If P1 V … V Pn, P1 P, … , and Pn P are proved, then P is proved.
Rule 5: I- (Introducing )
I- : If from 1, …, n infer is proved then
1 … n is proved
Interpretation: If given 1, 2, …and n to be proved and from these we deduce then 1 2 … n
is also proved.
Rule 6: E- (Eliminating ) - Modus Ponen
E- : If P1 P, P1 then P
18. Aditya Engineering College (A)
Natural Deduction System
ND RULES…
Rule 7: I- (Introducing )
I- : If P1 P2, P2 P1 then P1 P2
Rule 8: E- (Elimination )
E- : If P1 P2 then P1 P2 , P2 P1
Rule 9:I- ~ (Introducing ~)
I- ~ : If from P infer P1 ~ P1 is proved then
~P is proved
Rule 10: E- ~ (Eliminating ~)
E- ~ : If from ~ P infer P1 ~ P1 is proved
then P is proved
19. Aditya Engineering College (A)
Natural Deduction System
Cont…
● If a formula is derived / proved from a set of
premises / hypotheses { 1,…, n },
– then one can write it as from 1, …, n
● In natural deductive system,
infer .
– a theorem to be proved should have
from 1, …, n infer .
a form
● Theorem infer means that
– there are no premises and is true under all
interpretations i.e., is a tautology or valid.
20. Aditya Engineering College (A)
Natural Deduction System
● If we assume that is a premise, then we
conclude that is proved if is given i.e.,
– if ‘from infer ’ is a theorem then is concluded.
– The converse of this is also true.
Deduction Theorem: Infer (1 2 … n )
is a theorem of natural deductive system if and
only if
from 1, 2,… ,n infer is a theorem.
Useful tips: To prove a formula 1 2 … n
, it is sufficient to prove a theorem
from 1, 2, …, n infer .
Cont..
21. Aditya Engineering College (A)
Natural Deduction System
Example
Example1: Prove that P(QVR) follows from PQ
Solution: This problem is restated in natural deductive system as "from P
Q infer P (Q V R)". The formal proof is given as follows:
{Theorem}
{ premise}
from P Q infer P (Q V R)
P Q (1)
{ E- , (1)} P (2)
{ E- , (1)} Q (3)
{ I-V , (3) } Q V R (4)
{ I-, ( 2, 4)} P (Q V R) Conclusion
22. Aditya Engineering College (A)
Axiomatic System (AS)
● AS is based on the set of only three axioms and one rule of
deduction.
– It is minimal in structure but as powerful as the truth table and natural
deduction approaches.
– The proofs of the theorems are often difficult and require a guess in
selection of appropriate axiom(s) and rules.
– These methods basically require forward chaining strategy where we start
with the given hypotheses and prove the goal.
– Only two logical operators not(~) and implies (->) are allowed.
(V , , <-> can be converted into the above operators).
Example:
A B = ~(A->~B)
A V B = ~A->B
A<-> B = (A->B) (B->A) = ~[((A->B) -> ~((B->A) ]
23. Aditya Engineering College (A)
Axiomatic System (AS)
● Three axioms and one rule of deduction.
Axiom1 (A1): ( )
Axiom2 (A2): ( ()) (( ) ( ))
Axiom3 (A3): (~ ~ ) ( )
Modus Ponen (MP) defined as follows:
Hypotheses: and Consequent:
24. Aditya Engineering College (A)
Axiomatic System (AS)
Definition: A deduction of a formula in Axiomatic
System for Propositional Logic is a sequence of well-
formed formulae 1, 2, ..., n such that for each i,
(1 i n), either
– Either i is an axiom or i is a hypothesis (given to be true)
– Or i is derived from j and k where j, k < i using modus
ponen inference rule.
We call i to be a deductive consequence of {1,
...,i-1 }.
It is denoted by {1, .. , i-1 } |- i. More formally,
deductive consequence is defined on next slide.
Cont…
25. Aditya Engineering College (A)
Examples
Establish the following:
Ex1:
{Q} |- (PQ) i.e.,PQ is a deductive consequence of {Q}.
{Hypothesis} Q (1)
{Axiom A1}
{MP, (1,2)}
Q
P
(P
Q
Q) (2)
proved
Axiomatic System (AS)
26. Aditya Engineering College (A)
Examples – Cont…
Ex2:
{ P Q, Q R } |- ( P R ) i.e., P R is a
deductive consequence of { P Q, Q R }.
P Q (1)
Q R
{Hypothesis}
{Hypothesis}
{Axiom A1}
{MP, (2, 3)}
{Axiom A2}
(2)
(Q R) (P (Q R)) (3)
P (Q R)
(P (Q R))
((P Q) (P R))
(4)
(5)
{MP , (4, 5)}
{MP, (1, 6)}
(P Q) (P R)
P R
(6)
proved
Axiomatic System (AS)
27. Aditya Engineering College (A)
Semantic Tableaux System in PL
● Earlier approaches require
– construction of proof of a formula from given set of formulae and
are called direct methods.
● In semantic tableaux,
– the set of rules are applied systematically on a formula or set of formulae
to establish its consistency or inconsistency.
● Semantic tableau
– binary tree constructed by using semantic rules formula as a root
● Assume and be any two formulae.
28. Aditya Engineering College (A)
Semantic Tableaux System…
● Semantic tableau
– binary tree constructed by using semantic rules formula as a root
● Assume and be any two formulae.
RULES
Let and be any two formulae.
Rule 1: A tableau for a formula ( ) is constructed by adding both and to
the same path (branch). This can be represented as follows:
Interpretation: is true if both and are true
29. Aditya Engineering College (A)
Semantic Tableaux System…
Rules - Cont…
Rule 2: A tableau for a formula ~ ( ) is
constructed by adding two alternative paths one
containing ~ and other containing ~
~ ( )
~ ~
Interpretation:
or ~ is true
~ ( ) is true if either ~
30. Aditya Engineering College (A)
Semantic Tableaux System…
Cont…
Rule 3: A tableau for a formula ( V ) is
constructed by adding two new paths one
containing and other containing .
V
Interpretation: V is true if either
or is true
31. Aditya Engineering College (A)
Semantic Tableaux System…
Rule 4: A tableau for a formula ~ ( V ) is
constructed by adding both ~ and ~ to the
same path. This can be expressed as follows:
~ ( V )
~
~
Rule 5: Semantic tableau for ~~
~~
34. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Consistency and Inconsistency: Satisfiability and Unsatisfiability
If an atom P and ~ P appear on a same path of a
semantic tableau,
– then inconsistency is indicated and such path is said to
be contradictory or closed (finished) path.
– Even if one path remains non contradictory or
unclosed (open), then the formula at the root of a
tableau is consistent.
35. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
A valuation is said to be a model of (or
satisfies ) iff () = T.
In tableaux approach, model for a consistent formula is
constructed as follows:
– On an open path, assign truth values to atoms (positive or
negative) of which is at the root of a tableau such that is made
to be true.
– It is achieved by assigning truth value T to each atomic formula
(positive or negative) on that path.
Valuation
36. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Contradictory tableau (or finished tableau) is defined to
be a tableau in which all the paths are contradictory or
closed (finished).
Consistent and Inconsistent
If a tableau for a formula at the root is a contradictory
tableau, then a formula is said to be inconsistent.
A formula is consistent if there is at least on open path
in a tableau with root
Contradictory Tableau
37. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Example: Show that
: (P Q R) (~P S) Q ~ R ~ S is
inconsistent(Unsatisfiable) using tableaux method.
R) ( ~P S) Q ~ R ~ S
{T-root} (P Q
{Apply rule 1 to 1}
(1)
(2)
(3)
P Q R
~P S
Q
~ R
~ S
S
{Apply rule 6 to 3} P
{Apply rule 6 to 2)} ~ (P Q)
Closed: {S, ~ S} on the path
R
Closed { R, ~ R}
~P ~ Q
{P, ~ P}
Closed Closed{~ Q, Q}
38. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Problem: Show that : ( Q ~R) (R P) is
consistent( satisfiable) and find its model.
Solution:
{T-root} ( Q ~ R) ( R P)
{Apply rule 1 to 1}
(1)
(2)
(3)
(Q ~ R)
( R P)
{Apply rule 1 to 2} Q
{Apply rule 6 to 3} ~R
~ R P
open open
39. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Since tableau for has open paths, we conclude that is
consistent.
The models are constructed by assigning T to all atomic formulae
appearing on open paths.
– Assign Q = T and ~ R = T i.e., R = F.
• So { Q = T, R = F } is a model of .
– Assign Q = T and ~ R = T and P = T.
• So { P = T , Q = T, R = F } is another model.
Useful Tip:
– Thumb rule for constructing a tableau is to apply non
branching rules before the branching rules in any order
Example -Cont…
40. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Theorem: (Soundness)
If is tableau provable ( |- ) , then is
valid ( |= ) i.e., |- |= .
Theorem: (Completeness)
If is valid, then is tableau provable i.e.,
|= |- .
Soundness and Completeness
41. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Semantic Tableaux System…
Example - Validity
Example: Show that : P ( Q P) is valid
Solution: In order to show that is a valid, we will try
to show that is tableau provable i.e., ~ is
inconsistent.
{T-root} ~ (P ( Q P)) (1)
P) (2)
{Apply rule 7 to 2}
{Apply rule7 to 1} P
~ ( Q
Q
~P
Closed {P, ~ P}
Hence P ( Q P) is valid.
42. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Resolution refutation is another simple method to prove a formula by
contradiction.
– Here negation of goal to be proved is added to given set of clauses.
– It is shown then that there is a refutation in new set using resolution principle.
Resolution: During this process we need to identify
– two clauses, one with positive atom (P) and other with negative atom (~P) for the
application of resolution rule.
Resolution is based on modus ponen inference rule.
– This method is most favoured for developing computer based theorem
provers.
– Automatic theorem provers using resolution are simple and efficient systems .
Resolution is performed on special types of formulae called clauses.
– Clause is propositional formula expressed using
• {V, ~ } operators.
43. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Conjunctive and Disjunctive Normal Forms
In Disjunctive Normal Form (DNF),
– a formula is represented in the form
– (L11 ….. L1n ) V ..… V (Lm1 ….. Lmk ), where all Lijare
literals. It is a disjunction of conjunction.
In Conjunctive Normal Form (CNF),
– a formula is represented in the form
– (L11 V ….. V L1n ) … … (Lp1 V ….. V Lpm ) ,
Lij
where all are literals. It is a
conjunction of disjunction.
A clause is a special formula expressed as disjunction of literals. If
a clause contains only one literal, then it is called unit clause.
44. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Conversion of a Formula to its CNF
Each formula in Propositional Logic can be easily
transformed into its equivalent DNF or CNF representation
using equivalence laws .
– Eliminate and by using the following
equivalence laws.
P Q
P Q
~ P V Q
( P Q) ( Q P)
– Eliminate double negation signs by using
~ ~ P P
45. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Cont…
Use De Morgan’s laws to push ~ (negation)
immediately before atomic formula.
~ ( P Q)
~ ( P V Q)
~ P V ~ Q
~ P ~ Q
Use distributive law to get CNF.
P V (Q R) (P V Q) (P V R)
We notice that CNF representation of a formula is
of the form
– (C1 ….. Cn ) , where each Ck , (1 k n ) is
a clause that is disjunction of literals.
46. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Resolution of Clauses
If two clauses C1 and C2 contain a complementary pair
of literals {L, ~L}, then
– these clauses can be resolved together by deleting L from C1
and ~ L from C2 and constructing a new clause by the
disjunction of the remaining literals in C1 and C2.
The new clause thus generated is called
resolvent of C1 and C2 .
– Here C1 and C2 are called parents of resolved clause.
– If the resolvent contains one or more set of
is
complementary pair of literals, then resolvent
always true.
47. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Resolution Tree
Inverted binary tree is generated with the last node of
the binary tree to be a resolvent.
This also called resolution tree.
Example: Find resolvent of:
C1 = P V Q V R
C2 = ~ Q V ~ W
C3 = ~ P V ~ W
48. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Example- Resolution Tree
P V Q V R ~ Q V ~W
{Q, ~ Q}
P V R V ~W
{P, ~P}
~ P V ~ W
R V ~W
Thus Resolvent(C1,C2, C3) = R V ~W
49. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Example: “Mary will get her degree 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 above listed sentences are as
follows:
50. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Mary will get her degree if she registers as a
student and pass her exam.
R P D (~ R V ~ P V D)
She has registered herself as a student.
R
She has passed her exam.
P
Conclude “Mary will get a degree”.
D
Cont…
51. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Set of clauses are:
– S = {~ R V ~ P V D , R, P }
Add negation of "Mary gets her degree (= D)" to S.
New set S' is:
– S' = {~ R V ~ P V D , R, P, ~ D}
We can easily see that empty clause is deduced
from above set.
Hence we can conclude that “Mary gets her degree”
Example – Cont…
52. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Deriving Contradiction
~ R V ~ P V D R
~ P V D P
D ~ D
53. Aditya Engineering College (A)
Artificial Intelligence Dr P Udayakumar
Resolution Refutation in PL
Exercises
I. Establish the following:
1. { P Q, Q R } |- ( P R )
2. { P Q} |- (R P) (R Q)
3. { P } |- (~ P Q)
4. { ~Q, P ( ~Q R) } |- P R
5. {P Q , ~ Q } |- ~ P. This is called Modus Tollen rule.
II. Prove the following theorems
1. |- (P P)
2. |- (~ P P) P
3. |- (P Q) (~ Q ~ P)
4. |- (P ~ Q) ( Q ~ P)
III. Give tableau proof of each of the following formulae and show that formulae are valid.
1. P ( Q P)
2. (P (Q V R) (( P Q) V ( P R))
3. ~ (P V Q) (~ P ~ Q)
IV. Are the following arguments valid?
1. If John lives in England then he lives in UK. John lives in England. Therefore, John lives in UK.
2. If John lives in England then he lives in UK. John lives in UK. Therefore, John lives in England.
3. If John lives in England then he lives in UK. John does not live in UK. Therefore, John does not live in England.
V. Prove by resolution refutation
1. {P Q , ~ P V R} |= Q V R
2. { P , Q R , P R} |= P R
3. {P Q R , P} |= R