0% found this document useful (0 votes)
288 views101 pages

AI Mod 4

The document discusses knowledge-based agents and their components including knowledge bases and inference systems. It describes different knowledge representation techniques such as logical, semantic network, frame and production rule representations. It also covers propositional logic and its basic concepts.

Uploaded by

Sriram yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
288 views101 pages

AI Mod 4

The document discusses knowledge-based agents and their components including knowledge bases and inference systems. It describes different knowledge representation techniques such as logical, semantic network, frame and production rule representations. It also covers propositional logic and its basic concepts.

Uploaded by

Sriram yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 101

ARTIFICIAL INTELLIGENCE

L T P C
BCSE306L - 3 0 0 3

Dr. S M SATAPATHY
Associate Professor Sr.,
School of Computer Science and Engineering,
VIT Vellore, TN, India – 632 014.
Module – 4

LOGIC & REASONING

1. Logical systems

2. Knowledge Based systems

3. Propositional Logic Constraints

4. Predicate Logic

5. First Order Logic

6. Inference in First Order Logic

2
KNOWLEDGE BASED
SYSTEMS

3
Knowledge based Agent :: Definition
 An intelligent agent needs knowledge about the real world for taking
decisions and reasoning to act efficiently.
 Knowledge-based agents are those agents who have the capability
of maintaining an internal state of knowledge, reason over that
knowledge, update their knowledge after observations and take actions.
These agents can represent the world with some formal representation
and act intelligently. Inference engine is a component of the system that
applies logical rules to the knowledge base to deduce new information
 Knowledge-based agents are composed of two main parts:
 Knowledge-base and
 Inference system.

4
Knowledge based Agent :: Properties
 An agent should be able to represent states, actions, etc.
 An agent should be able to incorporate new precepts.
 An agent can update the internal representation of the world.
 An agent can deduce the internal representation of the world.
 An agent can deduce appropriate actions.

5
Knowledge based Agent :: Architecture

 The above diagram is representing a generalized architecture for a


knowledge-based agent.
 The knowledge-based agent (KBA) take input from the environment by
perceiving the environment.
 The input is taken by the inference engine of the agent and which also
communicate with KB to decide as per the knowledge store in KB.
 The learning element of KBA regularly updates the KB by learning new
knowledge. 6
Why use a knowledge base?
 Knowledge-base is required for updating knowledge for an agent to
learn with experiences and take action as per the knowledge.
 Knowledge-base is a central component of a knowledge-based agent, it
is also known as KB.
 It is a collection of sentences (here 'sentence' is a technical term and it
is not identical to sentence in English).
 These sentences are expressed in a language which is called a
knowledge representation language.
 The Knowledge-base of KBA stores fact about the world.

7
Knowledge Base :: Architecture
Knowledge level
 Knowledge level is the first level of knowledge-based agent, and in this
level, we need to specify what the agent knows, and what the agent
goals are. With these specifications, we can fix its behavior. For
example, suppose an automated taxi agent needs to go from a station A
to station B, and he knows the way from A to B, so this comes at the
knowledge level.
Logical level
 At this level, we understand that how the knowledge representation of
knowledge is stored. At this level, sentences are encoded into different
logics. At the logical level, an encoding of knowledge into logical
sentences occurs. At the logical level we can expect to the automated
taxi agent to reach to the destination B.
8
Knowledge Base :: Architecture
Implementation level
 This is the physical representation of logic and knowledge. At the
implementation level agent perform actions as per logical and
knowledge level. At this level, an automated taxi agent actually
implement his knowledge and logic so that he can reach to the
destination.

9
Knowledge Representation Techniques
 There are mainly four ways of knowledge representation which are
given as follows:
 Logical Representation
 Semantic Network Representation
 Frame Representation
 Production Rules

10
Techniques :: Logical Representation
 Logical representation means drawing a conclusion based on various
conditions.
 This representation lays down some important communication rules.
 It consists of precisely defined syntax and semantics which supports the
sound inference.
 Each sentence can be translated into logics using syntax and
semantics.

11
Techniques :: Logical Representation
Syntax
 Syntaxes are the rules which decide how we can construct legal
sentences in the logic.
 It determines which symbol we can use in knowledge representation.
 How to write those symbols.
Semantics
 Semantics are the rules by which we can interpret the sentence in the
logic.
 Semantic also involves assigning a meaning to each sentence.

 Logical representation can be categorized into mainly two logics


 Propositional Logics
 Predicate logics
12
Techniques :: Logical Representation – Adv. & Disadv.
 Logical representation enables us to do logical reasoning.
 Logical representation is the basis for the programming languages.
 Logical representations have some restrictions and are challenging to
work with.
 Logical representation technique may not be very natural, and inference
may not be so efficient.

13
Techniques :: Semantic Network Representation
 Semantic networks are alternative of predicate logic for knowledge
representation.
 In Semantic networks, we can represent our knowledge in the form of
graphical networks.
 This network consists of nodes representing objects and arcs which
describe the relationship between those objects.
 Semantic networks can categorize the object in different forms and can
also link those objects.
 Semantic networks are easy to understand and can be easily extended.
 This representation consist of mainly two types of relations:
 IS-A relation (Inheritance)
 Kind-of-relation

14
Techniques :: Semantic Network Representation
 Jerry is a cat.
 Jerry is a mammal
 Jerry is owned by Priya.
 Jerry is white colored.
 All Mammals are animal.

15
Techniques :: Semantic Network Representation -
Drawbacks
 Semantic networks take more computational time at runtime as we
need to traverse the complete network tree to answer some questions.
It might be possible in the worst case scenario that after traversing the
entire tree, we find that the solution does not exist in this network.
 Semantic networks do not have any standard definition for the link
names.
 These networks are not intelligent and depend on the creator of the
system.

16
Techniques :: Semantic Network Representation -
Advantages
 Semantic networks are a natural representation of knowledge.
 Semantic networks convey meaning in a transparent manner.
 These networks are simple and easily understandable.

17
Techniques :: Frame Representation
 A frame is a record like structure which consists of a collection of
attributes and its values to describe an entity in the world.

18
Techniques :: Production Rule
 Production rules system consist of (condition, action) pairs which mean,
"If condition then action“.
 Example:
 IF (at bus stop AND bus arrives) THEN action (get into the bus)
 IF (on the bus AND paid AND empty seat) THEN action (sit down).
 IF (on bus AND unpaid) THEN action (pay charges).
 IF (bus arrives at destination) THEN action (get down from the bus).

19
Techniques :: Production Rule – Adv. & Disadv.
 The production rules are expressed in natural language.
 The production rules are highly modular, so we can easily remove, add
or modify an individual rule.
 Production rule system does not exhibit any learning capabilities, as it
does not store the result of the problem for the future uses.
 During the execution of the program, many rules may be active hence
rule-based production systems are inefficient.

20
Propositional 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.

Example
 It is Sunday.
 The Sun rises from West (False proposition)
 3+3= 7(False proposition)
 5 is a prime number. (True Proposition)

21
Propositional Logic
 Propositional logic is also called Boolean logic as it works on 0 and 1.
 In propositional logic, we use symbolic variables to represent the logic,
and we can use any symbol for 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.

22
Propositional Logic
 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.
 Statements which are questions, commands, or opinions are not
propositions such as "Where is Rohini", "How are you", "What is your
name", are not propositions.

23
Propositional Logic
 There are two types of Propositions
 Atomic Propositions
 Compound 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.

Compound proposition
 Compound propositions are constructed by combining simpler or atomic
propositions, using parenthesis and logical connectives.

24
Propositional Logic
 Example

25
Logical Connectives
 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. There are mainly five
connectives, which are given as follows:
 Negation: A sentence such as ¬ P is called negation of P. A literal can
be either Positive literal or negative literal.
 Conjunction: A sentence which has ∧ connective such as, P ∧ Q is
called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.

26
Logical Connectives
 Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is
called disjunction, where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Engineer,
so we can write it as P ∨ Q.
 Implication: A sentence such as P → Q, is called an implication.
Implications are also known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
 Biconditional: A sentence such as P⇔ Q is a Biconditional sentence,
example If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.

27
Semantics
 Valid Statements
 Inconsistent Statements/ Contradiction
 P entails Q written P ⊧ Q, means that whenever P is True, so is Q.

28
Propositional Logic Connectives

29
Propositional Logic Connectives :: Truth Table

30
Propositional Logic Connectives :: Truth Table

31
Truth table with three propositions

32
Example

33
Example

34
Example

35
Models of complex sentences

36
Example

37
Example

Show that (p → q) ∧ (q → p) is logically equivalent to p ↔ q.

38
Logical equivalence
 Logical equivalence is one of the features of propositional logic. Two
propositions are said to be logically equivalent if and only if the columns
in the truth table are identical to each other.
 Let's take two propositions A and B, so for logical equivalence, we can
write it as A⇔B. In below truth table we can see that column for ¬A∨ B
and A→B, are identical hence A is Equivalent to B

39
Properties of Operators
Commutative: Distributive:
 P∧ Q= Q ∧ P, or  P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
 P ∨ Q = Q ∨ P.  P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).

Associative: DE Morgan's Law:


 (P ∧ Q) ∧ R= P ∧ (Q ∧ R),  ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
 (P ∨ Q) ∨ R= P ∨ (Q ∨ R)  ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).

Identity element: Double-negation elimination:


 P ∧ True = P,  ¬ (¬P) = P.
 P ∨ True= True.

40
Entailment and derivation
Entailment: KB |= Q
 Q is entailed by KB (a set of premises or assumptions) if and only if
there is no logically possible world in which Q is false while all the
premises in KB are true.
 Or, stated positively, Q is entailed by KB if and only if the conclusion is
true in every logically possible world in which all the premises in KB are
true.

Derivation: KB |- Q
 We can derive Q from KB if there is a proof consisting of a sequence of
valid inference steps starting from the premises in KB and resulting in Q

41
Two important properties for inference
Soundness: If KB |- Q then KB |= Q
 If Q is derived from a set of sentences KB using a given set of rules of
inference, then Q is entailed by KB.
 Hence, inference produces only real entailments,
 or any sentence that follows deductively from the premises is valid.

Completeness: If KB |= Q then KB |- Q
 If Q is entailed by a set of sentences KB, then Q can be derived from
KB using the rules of inference.
 Hence, inference produces all entailments,
 or all valid sentences can be proved from the premises.

42
Inference Rule
 Inference rules are the templates for generating valid arguments.
 Inference rules are applied to derive proofs in artificial intelligence, and
the proof is a sequence of the conclusion that leads to the desired goal.
 Logical inference is used to create new sentences that logically follow
from a given set of predicate calculus sentences (KB).
 An inference algorithm that derives only entailed sentences is called
sound or truth-preserving.
 An inference algorithm is complete if it can derive any sentence that is
entailed.
 Grounding – the connection between logical reasoning processes and
the real environment in which the agent exists.
 Learning – Rules that are produced by a sentence construction process

43
Inference Rule :: Terminologies
 Implication: It is one of the logical connectives which can be
represented as P → Q. It is a Boolean expression.
 Converse: The converse of implication, which means the right-hand
side proposition goes to the left-hand side and vice-versa. It can be
written as Q → P.
 Contrapositive: The negation of converse is termed as contrapositive,
and it can be represented as ¬ Q → ¬ P.
 Inverse: The negation of implication is called inverse. It can be
represented as ¬ P → ¬ Q.

44
Inference Rule

45
Inference Rule

46
Inference Rule

47
Inference Rule

48
Inference Rule

49
Proving things: what are proofs and theorems?
 A proof is a sequence of sentences, where each sentence is either a
premise or a sentence derived from earlier sentences in the proof by
one of the rules of inference.
 The last sentence is the theorem (also called goal or query) that we
want to prove.
Example
(P ^ Q) => R [“If it is hot and humid, then it is raining”]
Q => P [“If it is humid, then it is hot”]
Q [“It is humid.”]
Prove: R

50
Proving things: what are proofs and theorems?
 Example for the “weather problem” given above.
1 Hu Premise “It is humid”
2 Hu=>Ho Premise “If it is humid, it is hot”
3 Ho Modus Ponens(1,2) “It is hot”
4 (Ho^Hu)=>R Premise “If it’s hot & humid, it’s raining”
5 Ho^Hu And Introduction(1,2) “It is hot and humid”
6R Modus Ponens(4,5) “It is raining”

51
Proof methods
 Proof methods divide into (roughly) two kinds:
 Application of inference rules
 Legitimate (sound) generation of new sentences from old
 Proof = a sequence of inference rule applications
Can use inference rules as operators in a standard search
algorithm
 Typically require transformation of sentences into a normal form
 Model checking
 truth table enumeration (always exponential in n)
 improved backtracking, e.g., Davis--Putnam-Logemann-Loveland
(DPLL)
 heuristic search in model space (sound but incomplete)
e.g., min-conflicts-like hill-climbing algorithms
52
Normal forms of PL sentences
 Disjunctive normal form (DNF)
 Any sentence can be written as a disjunction of conjunctions of
literals.
 Examples: P ^ Q ^ ~R; A^B v C^D v P^Q^R; P
 Widely used in logical circuit design (simplification)
 Conjunctive normal form (CNF)
 Any sentence can be written as a conjunction of disjunctions of
literals.
 Examples: P v Q v ~R; (A v B) ^ (C v D) ^ (P v Q v R); P

53
Normal forms of PL sentences
 Normal forms can be obtained by applying equivalence laws
[(A v B) => (C v D)] => P
 ~[~(A v B) v (C v D)] v P // law for implication
 [~~(A v B) ^ ~(C v D)] v P // de Morgan’s law
 [(A v B)^(~C ^ ~D)] v P // double negation and de Morgan’s law
 (A v B v P)^(~C^~D v P) // distribution law
 (A v B v P)^(~C v P)^(~D v P) // a CNF

54
Conversion to CNF
 B1,1  (P1,2  P2,1)
 Eliminate , replacing α  β with (α  β) (β  α).
(B1,1  (P1,2  P2,1))  ((P1,2  P2,1)  B1,1)

 Eliminate , replacing α  β with  α  β.


( B1,1  P1,2  P2,1)  ((P1,2  P2,1)  B1,1)

 Move  inwards using de Morgan's rules and double-negation:


( B1,1  P1,2  P2,1)  (( P1,2   P2,1)  B1,1)

 Apply distributivity law ( over ) and flatten:


( B1,1  P1,2  P2,1)  ( P1,2  B1,1)  ( P2,1  B1,1)

55
Proof methods
 Definite clause: is a disjunction of literals of which exactly one is
positive.
 Horn clause: is a disjunction of literals of which at most one is positive
 Goal clauses: All definite clauses are Horn clauses, as are clauses with
no positive literals
 In Horn form
 The premise is called the body
 Conclusion is called the head
 A sentence consisting of a single positive literal is called a fact

56
Horn sentences
 A Horn sentence or Horn clause has the form:
P1 ^ P2 ^ P3 ... ^ Pn => Q
or alternatively
~P1 v ~P2 v ~P3 ... V ~Pn v Q
where Ps and Q are non-negated atoms
 To get a proof for Horn sentences, apply Modus Ponens repeatedly until
nothing can be done
 Can be used with forward chaining or backward chaining.
 These algorithms are very natural and run in linear time

57
Forward vs. backward chaining
 Forward Chaining: starts with known facts and asserts newly generated
fact to reach on to a conclusion (goal).
 Backward Chaining: starts with the goal and works backward to assert
what facts (statements) are needed to be asserted to reach on to a
conclusion (goal)

 FC is data-driven, automatic, unconscious processing,


e.g., object recognition, routine decisions
 May do lots of work that is irrelevant to the goal

 BC is goal-driven, appropriate for problem-solving,


e.g., Where are my keys? How do I get into a PhD program?
 Complexity of BC can be much less than linear in size of KB
58
Forward chaining

59
Forward chaining

60
Forward chaining

61
Backward chaining

62
Backward chaining

63
Limitation of Propositional Logic
 We cannot represent relations like ALL, some, or none with
propositional logic. Example:
 All the students 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

64
Propositional logic is a weak language
 Hard to identify "individuals." E.g., Mary, 3
 Individuals cannot be PL sentences themselves.
 Can’t directly talk about properties of individuals or relations between
individuals. (hard to connect individuals to class properties).
 E.g., property of being a human implies property of being mortal
 E.g. “Bill is tall”
 Generalizations, patterns, regularities can’t easily be represented.
 E.g., all triangles have 3 sides
 All members of a class have this property
 Some members of a class have this property
 A better representation is needed to capture the relationship (and
distinction) between objects and classes, including properties belonging
to classes and individuals.
65
PREDICATE LOGIC

66
Predicate Logic
 Logical expressions are built out of components
 Objects (Constants)
 Variables
 Functions
 The above three are called Terms
 Predicates
 Connectives
 Quantifiers

67
Predicate Logic :: Objects
 Symbols that denote specific things or individuals
 JOHN
 MARY
 BASKETBALL
 TRIANGLE

68
Predicate Logic :: Variables
 Unspecific references to objects
 x
 y
 z

69
Predicate Logic :: Functions
 An argument to a function is either an object or a variable
 Starting with a lowercase letter
 The value of a function is either an object or a variable
 exp(0) = 1
 next-day(THURSDAY) = FRIDAY
 brother(JOHN) = JIM

70
Predicate Logic :: Predicates
 Functions which denote attributes of objects or relationships between
individuals
 Starting with a uppercase letter
 Loves(JOHN, MARY)
 Man(SOCRATES)
 Sunny(THURDAY)

71
Predicate Logic :: Connectives
 Logical operators which computes truth values
∧ AND
∨ OR
¬ NOT
→ IMPLIES

72
Predicate Logic :: Quantifiers
 Logical operators which assert the scope of a predicate
∀ For All (universal quantifier)
∃ There Exists (existential quantifier)

 A quantifier is a language element which generates quantification, and


quantification specifies the quantity of specimen in the universe of
discourse.
 These are the symbols that permit to determine or identify the range
and scope of the variable in the logical expression. There are two types
of quantifier:
 Universal Quantifier, (for all, everyone, everything)
 Existential quantifier, (for some, at least one).

73
Predicate Logic :: Basic Elements

74
Predicate Logic
 Atomic sentences are the most basic sentences of first-order logic.
These sentences are formed from a predicate symbol followed by a
parenthesis with a sequence of terms
Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => Cat (Chinky)

 A well-formed formula (wff) is a sentence containing no “free” variables.


That is, all variables are “bound” by universal or existential quantifiers.
(∀x)P(x,y) has x bound as a universally quantified variable, but y is free.

75
Conversion from Natural Language Sentences to
Predicate Logic
 Marcus was a man
Man(Marcus)
 Marcus was a Pompeian
Pompeian(Marcus)
 All Pompeians were Romans
∀x [Pompeian(x) → Roman(x)]
 Caesar was a ruler
Ruler(Caesar)
 All Romans were either loyal to Caesar or hated him
∀x [Roman(x) ⊃ (loyalto(x,Caesar) ∨ hate(x,Caesar))]
 Everyone is loyal to someone
∀x ∃y loyalto(x,y)
76
Conversion from Natural Language Sentences to
Predicate Logic
 People only try to assassinate rulers they aren't loyal to
∀x ∀y[(Person(x) ∧ Ruler(y) ∧ tryassassinate(x,y)) → ¬loyalto(x,y)]
 Marcus tried to assassinate Caesar
tryassassinate(Marcus, Caesar)

77
Conversion of facts into first-order logic
 John likes all kind of food.
 Apple and vegetable are food
 Anything anyone eats and not killed is food.
 Anil eats peanuts and still alive
 Harry eats everything that Anil eats.
 John likes peanuts.

78
Conversion of facts into first-order logic
 John likes all kind of food.
∀x: food(x) → likes(John, x)
 Apple and vegetable are food
food(Apple) Λ food(vegetables)
 Anything anyone eats and not killed is food.
∀x ∀y: [eats(x, y) Λ ¬ killed(x)] → food(y)
 Anil eats peanuts and still alive
eats (Anil, Peanuts) Λ alive(Anil)
 Harry eats everything that Anil eats.
∀x: eats(Anil, x) → eats(Harry, x)
 John likes peanuts.
likes(John, Peanuts).

79
Conversion to CNF
 Standardize variables apart by renaming them: each quantifier should
use a different variable.
 Skolemize: each existential variable is replaced by a Skolem constant
or Skolem function of the enclosing universally quantified variables.
For instance, ∃x Rich(x) becomes Rich(G1) where G1 is a new Skolem
constant.
 Drop universal quantifiers
For instance, ∀ x Person(x) becomes Person(x).

80
Convert FOL statements into CNF
Eliminate all implication (→) and rewrite
 ∀x: ¬ food(x) V likes(John, x)
 food(Apple) Λ food(vegetables)
 ∀x ∀y: ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
 eats (Anil, Peanuts) Λ alive(Anil)
 ∀x: ¬ eats(Anil, x) V eats(Harry, x)
 likes(John, Peanuts).

81
Convert FOL statements into CNF
Move negation (¬)inwards and rewrite
 ∀x: ¬ food(x) V likes(John, x)
 food(Apple) Λ food(vegetables)
 ∀x ∀y: ¬ eats(x, y) V killed(x) V food(y)
 eats (Anil, Peanuts) Λ alive(Anil)
 ∀x: ¬ eats(Anil, x) V eats(Harry, x)
 likes(John, Peanuts).

82
Convert FOL statements into CNF
Rename variables or standardize variables
 ∀x: ¬ food(x) V likes(John, x)
 food(Apple) Λ food(vegetables)
 ∀y ∀z: ¬ eats(y, z) V killed(y) V food(z)
 eats (Anil, Peanuts) Λ alive(Anil)
 ∀w: ¬ eats(Anil, w) V eats(Harry, w)
 likes(John, Peanuts).

83
Convert FOL statements into CNF
Eliminate existential instantiation quantifier by elimination.
 In this step, we will eliminate existential quantifier ∃, and this
process is known as Skolemization.
 But in this example problem since there is no existential quantifier so
all the statements will remain same in this step.

84
Convert FOL statements into CNF
Drop Universal quantifiers.
In this step we will drop all universal quantifier since all the statements
are not implicitly quantified so we don't need it.
 ¬ food(x) V likes(John, x)
 food(Apple)
 food(vegetables)
 ¬ eats(y, z) V killed(y) V food(z)
 eats (Anil, Peanuts)
 alive(Anil)
 ¬ eats(Anil, w) V eats(Harry, w)
 likes(John, Peanuts).

85
Resolution Proof – Generating nil
Consider:

 Resolution is a way of finding contradictions in a database of


clauses with minimum use of substitution. Resolution is a proof
technique that works on conjunctive normal form expressions. It
involves:
 Selecting two clauses that contain conflicting terms.
 Combining the terms contained in those two clauses.
 Cancelling the terms that conflict
 It is used for proving the satisfiability of a sentence. 86
Resolution Proof – Generating nil

87
Resolution Proof – Example

88
Resolution Proof – Example

89
Resolution Proof
Marcus was a man.
Marcus was a Pompeian.
All Pompeians were Romans.
Caesar was a ruler.
All Romans were either loyal to Caesar or hated him.
Everyone is loyal to someone.
People only try to assassinate rulers they aren't loyal to.
Marcus tried to assassinate Caesar.

Prove that Marcus hated Caesar.

90
Resolution Proof
1. Marcus was a man.
man(Marcus)
2. Marcus was a Pompeian
pompeian(Marcus)
3. All Pompeians were Romans.
∀x: pompeian(x) → roman(x)
~pompeian(x) v roman(x)
4. Caesar was a ruler.
ruler(Caesar)
5. All Romans were either loyal to Caesar or hated him.
∀x: roman(x) → loyalto(x, Caesar) v hate(x, Caesar)
~roman(y) v loyalto(y, Caesar) v hate(y, Caesar)
91
Resolution Proof
6. Everyone is loyal to someone.
∀x ∃y: loyalto(x, y)
loyalto(z, f(z)) // f is a skolem function and returns a person
that z is loyal to
7. People only try to assassinate rulers they aren't loyal to.
∀x ∀y: (man(a) ∧ ruler(b) ∧ tryassassinate(a,b)) → ¬loyalto(a,b)]
¬(man(a) ∧ ruler(b) ∧ tryassassinate(a,b)) v ¬ loyalto(a, b)
= ¬ man(a) v ¬ ruler(b) v ¬ trytoassassinate(a, b) v ¬ loyalto(a, b)
8. Marcus tried to assassinate Caesar.
trytoassassinate(Marcus, Caesar)

Prove hated(Marcus, Caesar).


92
Resolution Proof
 Introduce 9. ~hated(Marcus, Caesar).
Resolve 9 with 5 unifying Marcus to y yields
 ~roman(Marcus) v loyalto(Marcus, Caesar)
Resolve 10 with 3 unifying Marcus to x yields
 ~pompeian(Marcus) v loyalto(Marcus, Caesar)
Resolve 11 with 2 yields
 loyalto(Marcus, Caesar)
Resolve 12 with 7 unifying Marcus to a and Caesar to b yields
 ~man(Marcus) v ~ruler(Caesar) v ~trytoassassinate(Marcus,Caesar)
Resolve 13 with 1 yields
 ~ruler(Caesar) v ~trytoassassinate(Marcus, Caesar)
Resolve 14 with 4 yields
 ~ trytoassassinate(Marcus, Caesar) 93
Resolution Proof
Resolve 15 with 8 yields the null hypothesis.

Therefore, ~hate(Marcus, Caesar) is false, so hate(Marcus, Caesar) is


true.

94
Resolution Proof - Practice
Marcus was a man.
Marcus was a Pompeian.
All Pompeians were Romans.
Caesar was a ruler.
All Romans were either loyal to Caesar or hated him.
Everyone is loyal to someone.
People only try to assassinate rulers they aren't loyal to.
Marcus tried to assassinate Caesar.

Was Marcus loyal to Caesar?

95
Resolution Proof - Practice

96
Resolution Proof - Practice

97
Quantifier Scope
 Switching the order of universal quantifiers does not change the
meaning:
(x)(y)P(x,y) ↔ (y)(x) P(x,y)
 Similarly, you can switch the order of existential quantifiers:
(x)(y)P(x,y) ↔ (y)(x) P(x,y)
 Switching the order of universals and existentials does change
meaning:
 Everyone likes someone: (x)(y) likes(x,y)
 Someone is liked by everyone: (y)(x) likes(x,y)

98
Connections between All and Exists
 We can relate sentences involving  and  using De Morgan’s laws:
(x) P(x) ↔ (x) P(x)
(x) P(x) ↔ (x) P(x)
(x) P(x) ↔  (x) P(x)
(x) P(x) ↔ (x) P(x)

99
Disclaimer

The material for the presentation has been compiled


from various sources such as prescribed text books by
Russell and Norvig and other tutorials and lecture notes.
The information contained in this lecture/ presentation is
for educational purpose only.

100
Thank You for Your Attention !

101

You might also like