0% found this document useful (0 votes)
38 views211 pages

Unit 2

The document outlines a unit on knowledge-based agents and first-order logic. It discusses knowledge-based agents, the Wumpus world example, propositional logic, and an introduction to first-order logic including syntax, semantics and inference.

Uploaded by

Himanshu Vaswani
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)
38 views211 pages

Unit 2

The document outlines a unit on knowledge-based agents and first-order logic. It discusses knowledge-based agents, the Wumpus world example, propositional logic, and an introduction to first-order logic including syntax, semantics and inference.

Uploaded by

Himanshu Vaswani
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/ 211

M.S.

Ramaiah Institute of Technology


(Autonomous Institute, Affiliated to VTU)
Department of Computer Science and Engineering

Course Name: Artificial Intelligence(AI)


Course Code: CS53
Credits: 3:0:0:1
UNIT -2
Term: October 2021 – Feb 2022

Faculty:
Dr. Sangeetha V
Assistant Professor
Department of CSE

Department of Computer Science and Engineering 1


UNIT -2 Outline
First Order Logic
Knowledge-based agents
• Wumpus world • Representation revisited
• Logic • Syntax and semantics of first-order logic
• Propositional (Boolean) logic • Using first-order logic
• Reasoning patterns in Propositional logic
• Equivalence Proportional Model checking • Knowledge engineering in first-order logic
• Agents based on Propositional logic Inference in First Order Logic
• Propositional vs. First-order inference
• Unification and lifting
• Forward chaining
• Backward chaining
• Resolution

Department of Computer Science and Engineering 2


Introduction
An agent is anything that can be viewed as perceiving its
environment through sensors and acting upon that environment
through actuators.
Knowledge - facts, skills, education, experience
Intelligence – ability to use that knowledge
Reasoning – Processing of Knowledge

Department of Computer Science and Engineering 3


Knowledge based Agent
• Knowledge-based agent
uses some task-specific
knowledge to solve a ?
problem efficiently. environme
• Every Knowledge-based agent nt
agent has a knowledge base
and an inference system Domain-specific content

Knowledge base
Inference Engine
Domain-independent algorithms

Department of Computer Science and Engineering 4


4
Knowledge based Agent
Central component of Knowledge based Agent is a Knowledge-base(KB)
KB = set of sentences in a formal language

Two generic functions are


1. TELL – add new sentence to KB (TELL IT WHAT IT NEEDS TO KNOW)
2. ASK – Query what is know from KB ( ASK WHAT TO DO NEXT)

Tell facts
Ask for inference

Department of Computer Science and Engineering 5


Knowledge based Agent
A knowledge-based agent must able to do the following:

• An agent should be able to represent states, actions, etc.


• An agent Should be able to incorporate new percepts
• 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.

Department of Computer Science and Engineering 6


Generic KB-Based Agent
Agent maintains a knowledge base KB in 3 steps:
▪ First it TELLS the KB what it perceives
▪ It asks the KB what action it should perform
▪ Process of answering the query requires lots of reasoning

7 Department of Computer Science and Engineering


A simple knowledge-based agent

◦ MAKE-PERCEPT-SENTENCE
generates a sentence, what the
agent perceived at the given
time.

◦ MAKE-ACTION-QUERY generates a
sentence to ask which action
should be done at the current
time.

◦ MAKE-ACTION-SENTENCE
generates a sentence which
asserts that the chosen action
was executed.

Department of Computer Science and Engineering 8


Approaches to designing a knowledge-based agent
There are mainly two approaches to build a knowledge-based agent:

Declarative approach: We can create a knowledge-based agent by initializing with an


empty knowledge base and telling the agent all the sentences with which we want to
start with.

Example : Constraints and rules

Procedural approach: We directly encode desired behavior as a program code.


Which means we just need to write a program that already encodes the desired
behavior or agent.

Example: Functions

Department of Computer Science and Engineering 9


Wumpus World
Wumpus world – example to illustrate the worth of a knowledge
based agent and to represent knowledge
It was inspired by a video game Hunt the Wumpus by Gregory Yob
in 1973

Department of Computer Science and Engineering 10


A Wumpus World
The wumpus world is a cave consisting of
rooms connected by passageways.

Goal – Agent should pick the Gold present in a


Particular room

Agent has only one arrow

Department of Computer Science and Engineering 11


Wumpus World PEAS description
Performance measure
◦ gold +1000, death -1000
◦ -1 per step, -10 for using the arrow

Environment: 4 x 4 grid of rooms


◦ [1,1] start of an Agent

Sensors: Stench, Breeze, Glitter, Bump(Hit wall), Scream (shot Wumpus)


Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot

Department of Computer Science and Engineering 12


Exploring the Wumpus World
Percepts given to the agent
1. Stench
2. Breeze
3. Glitter
4. Bumb (ran into a wall)
5. Scream (wumpus has been hit by
arrow)

Department of Computer Science and Engineering 13


Exploring the Wumpus World

Initial situation:

Agent in 1,1 and percept is [None, None, None, None, None]


[Stench,Breeze,Glitter,Bumb,Scream] [None, Breeze, None, None, None]

Department of Computer Science and Engineering 14


Exploring the Wumpus World

[Stench,None,None,None,None] [None, None, None, None, None]

Department of Computer Science and Engineering 15


Exploring the Wumpus World

[Stench,Breeze,Glitter,None,None]

Department of Computer Science and Engineering 16


Logic
Logics are formal languages for representing information such that conclusions can be
drawn
• Syntax
• Semantics

E.g., the language of arithmetic


◦ x+2 ≥ y is a sentence; x2+y > {} is not a sentence
◦ x+2 ≥ y is true iff the number x+2 is no less than the number y
◦ x+2 ≥ y is true in a world where x = 7, y = 1
◦ x+2 ≥ y is false in a world where x = 0, y = 6

Department of Computer Science and Engineering 17


Syntax
• Syntax is the way sentences are expressed.
• The syntax are the rules that determine whether or not a sentence is well
formed.
• Example : name John my is
my name is John
• 1+=2 3
1+2=3

Department of Computer Science and Engineering 18


Semantics
• Semantics is the meaning behind the sentences.
• In logic, semantics talk about whether a sentence is true or false.
• Example : my name is Paul - False
my name is John - True

Department of Computer Science and Engineering 19


Models
• A model is a version of the environment where variable states
take on a specific value, and this helps us evaluate the
truthfulness of sentences.
• Example: x+2 ≥ y is true in a world where x = 7, y = 1
• When a sentence is true under a particular model and we use
the word “satisfies”

Department of Computer Science and Engineering 20


Models
• Sentence is represented as α
• We use the notation M(α) - set of all models of α

• If a sentence α is true in model m,


we say that m satisfies α or sometimes m is a model of α.

Department of Computer Science and Engineering 21


Entailment
Entailment is a specific kind of relationship between two sentences.
Example
◦ Statement A: "I will turn 28 this year;"
◦ Statement B: "I am currently living."

Entailment is present here because the truth of A requires the truth of B:


if I am not currently living, then I cannot age, and therefore I will not turn
28 this year.

Department of Computer Science and Engineering 22


Logical Entailment
In mathematical notation,
we write : α ╞ β, sentence α entails the sentence β

The formal definition of entailment is this:


α |= β if and only if, in every model in which α is true, β is also true.

we can write α |= β if and only if M(α) ⊆ M(β) .

Department of Computer Science and Engineering 23


Models and Entailment
Logicians typically think in terms of models, which are formally structured worlds
with respect to which truth can be evaluated

We say m is a model of a sentence α if α is true in m

M(α) is the set of all models of α

Then KB ╞ α iff M(KB) ⊆ M(α)

Department of Computer Science and Engineering 24


Inference and Entailment
Inference is a procedure that allows new sentences to be derived from
a knowledge base.

If an inference algorithm i can derive α from KB, we write

Pronounced “α is derived from KB by i” or “i derives α from KB”.

Department of Computer Science and Engineering 25


Inference and Entailment
• An inference algorithm that derives only entailed sentences is called
sound or TRUTH-PRESERVING
• KB is true in the real world, then any sentence α derived from KB by a
sound inference procedure is also true in the real world.

Department of Computer Science and Engineering 26


Propositional logic(Boolean Logic)
• One of the Knowledge representation scheme called
propositional logic.
• Syntax and Semantics of Propositional Logic

Department of Computer Science and Engineering 27


Propositional logic Syntax
• The Atomic sentences consist of a single proposition symbol.
Example: P, Q, R, W1,3 and North.
• Complex sentences are constructed from simpler sentences,
using parentheses and logical connectives.

Department of Computer Science and Engineering 28


Propositional logic Syntax
There are five connectives in common use

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.

Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction, where P and Q are the proposit
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.

Department of Computer Science and Engineering 29


Propositional logic Syntax
Implication: A sentence such as P → Q, is called an implication.
Implications are also known as if-then rules.
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.

Department of Computer Science and Engineering 30


Propositional logic Syntax
Figure 7.7 gives a formal grammar of propositional logic with the BNF notation

Department of Computer Science and Engineering 31


Propositional logic Semantics
• The semantics defines the rules for determining the truth of a
sentence with respect to a particular model.
• All sentences are constructed from atomic sentences and the five
connectives

Department of Computer Science and Engineering 32


Propositional logic Semantics
• How to compute the truth of atomic sentences
True is true in every model and False is false in every model
• For complex sentences, we have five rules, which hold for any subsentences P and Q in any
model m (here “iff” means “if and only if”):

Department of Computer Science and Engineering 33


Propositional logic Semantics
• The rules can also be expressed with truth tables

Department of Computer Science and Engineering 34


Propositional logic Semantics
• The rules can also be expressed with truth tables

Department of Computer Science and Engineering 35


Propositional Theorem Proving
Entailment by theorem proving, so we need additional
concepts
• Logical equivalence
• Validity
• Satisfiability

36 Department of Computer Science and Engineering


Propositional Theorem Proving
Logical equivalence
• Two sentences α and β are logically equivalent if they are
true in the same set of models.
α≡β
• For example, P ∧ Q and Q ∧ P are logically equivalent;

• Any two sentences α and β are equivalent only if each of


them entails the other: α ≡ β if and only if α |= β and β |= α

37 Department of Computer Science and Engineering


Propositional Theorem Proving
Laws of Logic

38 Department of Computer Science and Engineering


Propositional Theorem Proving
Validity
A sentence is valid if it is true in all models.
Example, the sentence P ∨ ¬P is valid.

Valid sentences are also known as tautologies—they are


necessarily true.

α and β, α |= β if and only if the sentence (α ⇒ β) is valid

39 Department of Computer Science and Engineering


Propositional Theorem Proving
Satisfiability
A Compound proposition is satisfiable if there is at least one
TRUE results in Truth table

Example : P ^ Q

The problem of determining the satisfiability of sentences in


propositional logic — SAT problem

40 Department of Computer Science and Engineering


Propositional Theorem Proving
Inference Rule
AI , we need intelligent computers which can create new logic from old
logic or by evidence, so generating the conclusions from evidence and
facts is termed as Inference.

Inference : Deriving conclusion from evidences(Premises/Assumptions)

Rules of Inference : Are the templates for constructing valid arguments

Department of Computer Science and Engineering 41


Propositional Theorem Proving
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 for the “weather problem” given above.
1 Hu Premise “It is humid”
2 Hu→Ho Premise “If it is humid, it is hot”

Department of Computer Science and Engineering


Propositional Theorem Proving
Arguments in Propositional Logic
• A argument in propositional logic is a sequence of propositions.
• All the proposition are called premises. The last
statement is the conclusion.
• The argument is valid if the premises imply the conclusion.

Department of Computer Science and Engineering 43


Propositional Theorem Proving
Types of Inference Rule :
•Modus Ponens
•And-Elimination
•Resolution

Department of Computer Science and Engineering 44


Propositional Theorem Proving
Modus Ponens
The Modus Ponens rule states that if α and α → β is true, then we can infer that β will be true.
It can be represented as:

Any sentences of the form α ⇒ β and α are given, then the sentence β can be inferred.

Department of Computer Science and Engineering 45


Propositional Theorem Proving
And-Elimination
From a conjunction, any of the conjuncts can be inferred

Example
"He studies very hard and he is the best boy in the class", P∧Q
Therefore − "He studies very hard” P

Department of Computer Science and Engineering 46


Propositional Theorem Proving
All of the logical equivalences in Figure 7.11 can be used as inference rules.

Department of Computer Science and Engineering 47


Determine the validity of the following argument using propositional logic: If there is a cream, then I will drink coffee. If
there is a donut , then I will drink coffee. There is no cream and there is a donut. So, I drink coffee

P – If there is a cream P Q ~P R P🡪Q R🡪Q ~P ∧ R (P 🡪 Q) ∧ (P 🡪 Q) ∧ (R 🡪 Q) ∧


(R 🡪 Q) ∧ (~P ∧ R )
(~P ∧ R ) 🡪Q
Q- I will drink coffee
T T F T T T F F T

R - If there is a donut T T F F F T F F T

T F F T F F F F T

Premises P🡪Q T F F F F T F F T
R🡪Q F T T T T T T T T
~P ∧ R
F T T F T T F F T
_______
F F T T T F T F T
Conclusion Q
F F T F T T F F T

(P 🡪 Q) ∧ (R 🡪 Q) ∧ (~P ∧ R ) 🡪 Department of Computer Science and Engineering 48


Department of Computer Science and Engineering 49
Department of Computer Science and Engineering 50
Propositional Theorem Proving

51 Department of Computer Science and Engineering


52 Department of Computer Science and Engineering
Propositional Theorem Proving
Monotonicity
• In monotonicity, once the conclusion is taken, then it will
remain the same even if we add some other information to
existing information in our knowledge base.
Example:
• “Earth revolves around the Sun”

• It is a true fact, and it cannot be changed even if we add


another sentence in knowledge base like, "The moon
revolves around the earth" Or "Earth is not round," etc.
53 Department of Computer Science and Engineering
Propositional Theorem Proving
Monotonicity
• Monotonicity means that inference rules can be applied whenever
suitable premises are found in the knowledge base—the conclusion
of the rule must follow regardless of what else is in the knowledge
base
• Set of entailed sentences can increase as information is added to
the knowledge base.
• For any sentences α and β

if KB |= α then KB ∧ β |= α

54 Department of Computer Science and Engineering


Propositional Theorem Proving
Literal : Is either a propositional variable P or a negated propositional
variable ¬P.

Clause : is
– A literal or
– Disjunction of two or more literals or
– The empty clause
Example: { } , P, P ∨ ¬Q ∨ R

55 Department of Computer Science and Engineering


Propositional Theorem Proving
Resolution Method
Resolution method is an inference rule which is used in both
propositional logic as well as First order predicate logic

This method is used for proving the satisfiability of a sentence

56 Department of Computer Science and Engineering


Propositional Theorem Proving
Resolution Rule
In PL, resolution method is the inference rule takes two
premises in the form of clauses and gives the clause as a
conclusion.

The resolution rule applies only to clauses

57 Department of Computer Science and Engineering


Propositional Theorem Proving
Two Normal form
Conjunctive Normal Form (CNF)
Disjunctive Normal Form (DNF)

58 Department of Computer Science and Engineering


Propositional Theorem Proving
Conjunctive Normal Form:
A sentence expressed as a conjunction of clauses is said to be
in conjunctive normal form

59 Department of Computer Science and Engineering


Propositional Theorem Proving
Procedure to convert sentence into CNF : Steps
1. Remove Bicondition
Eliminate ⇔, replacing α ⇔ β with (α ⇒ β) ∧ (β ⇒ α)
2. Remove Implication
Eliminate ⇒, replacing α ⇒ β with ¬α ∨ β

60 Department of Computer Science and Engineering


Propositional Theorem Proving
Procedure to convert sentence into CNF : Steps
3. Move Negation inwards

4. Apply Distributive and/or Commutative law

61 Department of Computer Science and Engineering


Propositional Theorem Proving
Example : A ⇔ ( B V C)
1. Remove ⇔
α ⇔ β with (α ⇒ β) ∧ (β ⇒ α)
[A ⇒ ( B V C)] ∧ [( B V C) ⇒ A]
2. Remove Implication
α ⇒ β with ¬α ∨ β
[ ¬ A ∨ ( B V C)] ∧ [¬ ( B V C) ∨ A]

62 Department of Computer Science and Engineering


Propositional Theorem Proving
[ ¬ A ∨ ( B V C)] ∧ [¬ ( B V C) ∨ A]
3. Move Negation inwards
[ ¬ A ∨ ( B V C)] ∧ [(¬ B ∧ ¬ C) ∨ A ]
4. Apply Distributive and/or Commutative law
(¬A∨ BVC) ∧ (¬ B ∨ A) ∧ (¬ C ∨ A)

This Sentence is now in CNF, as a conjunction of three clauses.

63 Department of Computer Science and Engineering


Propositional Theorem Proving
A resolution algorithm
To show that KB |= α, we show that (KB ∧ ¬α) is unsatisfiable.

64 Department of Computer Science and Engineering


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.

65 Department of Computer Science and Engineering


Propositional Theorem Proving
Completeness of resolution
Resolution closure RC(S) of a set of clauses S, which is the set of all
clauses derivable by repeated application of the resolution rule to clauses
in S or their derivatives.

The completeness theorem for resolution in propositional logic is called


the ground resolution theorem

66 Department of Computer Science and Engineering


Propositional Theorem Proving
Completeness of resolution
Ground resolution theorem : If a set of clauses is unsatisfiable, then the
resolution closure of those clauses contains the empty clause.
Construct a model for S with suitable truth values for P1, . . . , Pk.
The construction procedure is as follows:
For i from 1 to k,
◦ If a clause in RC(S) contains the literal ¬Pi and all its other literals are false under
the assignment chosen for P1, . . . , Pi−1, then assign false to Pi.
◦ Otherwise, assign true to Pi.

67 Department of Computer Science and Engineering


Propositional Theorem Proving
Horn clause
A clause which is a disjunction of literals of with at most one positive
literal.

Example : ¬A ∨ ¬C ∨ D

68 Department of Computer Science and Engineering


Propositional Theorem Proving
Types of Horn Clauses :

◦ Definite clause / Strict Horn clause


It has exactly one positive literal.
Example: ¬p ∨ ¬q ∨ ... ∨ ¬t ∨ u
◦ Unit clause
Definite clause with no negative literals.
Example: u
◦ Goal clause
Horn clause without a positive literal.
Example : ¬p ∨ ¬q ∨ ... ∨ ¬t
69 Department of Computer Science and Engineering
Propositional Theorem Proving
KB containing only definite clauses are interesting for three
reasons:
1. Every definite clause can be written as an implication whose premise
is a conjunction of positive literals and whose conclusion is a single
positive literal.
2. Inference with Horn clauses can be done through the forward-
chaining and backward chaining algorithms
3. Deciding entailment with Horn clauses can be done in time that is
linear in the size of the knowledge base

70 Department of Computer Science and Engineering


Propositional Theorem Proving
Forward and backward chaining

71 Department of Computer Science and Engineering


Propositional Theorem Proving
Forward chaining

72 Department of Computer Science and Engineering


Propositional Theorem Proving
Backward chaining

Example :

Patient -> Fever (Conclusion)

Temperature/Symptoms( Rules)

viral/bacterial Infection ( fact)

73 Department of Computer Science and Engineering


Propositional Theorem Proving
Forward chaining algorithm

74 Department of Computer Science and Engineering


Propositional Theorem Proving
In Forward chaining algorithm knowledge base is drawn as an
AND–OR graph

75 Department of Computer Science and Engineering


Outline
First Order logic
• Representation revisited
• Syntax and semantics of
first-order logic
• Using first-order logic
• Knowledge engineering in
first-order logic

Department of Computer Science and Engineering 76


First Order logic
• Propositional logic is too puny a language to represent knowledge
of complex environments in a concise way.
• The prepositional logic only deals with the facts, that may be true
or false.
• The first order logic assumes that the world contains objects,
relations and functions.

Department of Computer Science and Engineering 77


First Order logic
First-order logic statements can be divided into two parts:
Subject: Subject is the main part of the statement.
Predicate: A predicate can be defined as a relation, which binds two atoms
together in a statement

Integer (x) : x is an integer

Pinky is a cat

cat(x)
Department of Computer Science and Engineering 78
First Order logic
• First Order Logic (FOL) is a way of knowledge representation.
• It is an extension of PL
• It is also known as Predicate Logic.
• FOL is a collection of objects, their attributes and relations among them to represent knowledge.
• Objects: houses, numbers, theories, Ronald McDonald, colors, baseball games, wars, centuries . . .
• Relations: these can be unary relations or properties such as red, round, bogus, prime,multistoried . . .,
or more general n-ary relations such as brother of, bigger than, inside,part of, has color, occurred after,
owns, comes between, . . .
• Function: Father of, best friend, third inning of, end of, ......

Department of Computer Science and Engineering 79


First Order logic
Object
1. Richard the Lionheart, King of England from 1189 to 1199;
2. his younger brother, the evil King John, who ruled from 1199
to 1215;
3. the left leg of Richard
4. the left leg of John
5. Crown

A tuple is a collection of objects arranged in


a fixed order and is written with angle
brackets surrounding the objects.)
<Richard the Lionheart, King John>

Department of Computer Science and Engineering 80


First Order logic
• FOL has two main parts
• Syntax
• Semantics

The syntax of FOL determines which collection of symbols is a logical


expression in first-order logic.

We write statements in short-hand notation in FOL.

Department of Computer Science and Engineering 81


First Order logic
Syntax of FOL: Basic elements

Department of Computer Science and Engineering 82


First Order logic
The symbols come in three kinds:
1. Constant symbols which stand for objects
2. Predicate symbols which stand for relations
3. Function symbols which stand for functions

We adopt the convention that these symbols will begin with


uppercase letters.

Department of Computer Science and Engineering 83


First Order logic
For example,

Constant symbols Richard and John

Predicate symbols Brother , OnHead,


Person, King, and Crown

Function symbol LeftLeg.

Department of Computer Science and Engineering 84


First Order logic
Each model includes an interpretation that
specifies exactly which objects, relations and
functions are referred to by the constant,
predicate, and function symbols.

❑Richard refers to Richard the Lionheart and John


refers to the evil King John.
❑Brother refers to the brotherhood relation
❑LeftLeg refers to the “left leg” function

Department of Computer Science and Engineering 85


First Order logic
Terms
A term is a logical expression that refers to an object.
Constant symbols are therefore terms
A complex term is formed by a function symbol followed by a parenthesized list of
terms as arguments to the function symbol.

f(t1, . . . , tn), f refers to some function in the model

Example : LeftLeg(John)

Department of Computer Science and Engineering 86


First Order logic
Atomic sentences:
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.
We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Brother (Richard , John)
Complex Sentences:
Complex sentences are made by combining atomic sentences using connectives.
Example : King(Richard ) ∨ King(John)

Department of Computer Science and Engineering 87


First Order logic
Quantifiers in First-order logic
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).

Department of Computer Science and Engineering 88


First Order logic
Universal Quantifier
Universal quantifier is a symbol of logical representation, which specifies that the
statement within its range is true for everything or every instance of a particular
thing.
The Universal quantifier is represented by a symbol ∀, which resembles an
inverted A.

The main connective for universal quantifier ∀ is implication →.

Example : “All kings are persons” ∀ x King(x) ⇒ Person(x)


For all x, if x is a king, then x is a person.

Department of Computer Science and Engineering 89


First Order logic
Universal Quantifier
Example : “All kings are persons” ∀ x King(x) ⇒ Person(x)
For all x, if x is a king, then x is a person.
The symbol x is called a variable.
By convention, variables are lowercase letters.

A variable is a term all by itself, and as such can also serve as the argument of a
function

Department of Computer Science and Engineering 90


First Order logic
Existential Quantifier
Existential quantifiers express that the statement within its scope is true for at
least one instance of something.
• It is denoted by the logical operator ∃, which resembles as inverted E.
• When it is used with a predicate variable then it is called as an existential
quantifier.
• The main connective for existential quantifier ∃ is and ∧.
• Example : King John has a crown on his head
∃ x Crown(x) ∧ OnHead(x, John)
∃x is pronounced “There exists an x such that . . .” or “For some x . . .”.

Department of Computer Science and Engineering 91


First Order logic
Nested quantifiers
• We will often want to express more complex sentences using
multiple quantifiers.
• written ∃1 or ∃!, that means “There exists exactly one”
For example, “Brothers are siblings”
∀ x ∀ y Brother (x, y) ⇒ Sibling(x, y)

Department of Computer Science and Engineering 92


First Order logic
Equality
First-order logic includes one more way to make atomic sentences
Equality symbol signify that two terms refer to the same object.
It can also be used with negation to insist that two terms are not the
same object.
For example,
Father (John)=Henry

Department of Computer Science and Engineering 93


Using First Order logic
Assertions and queries in first-order logic
Sentences are added to a knowledge base using TELL, exactly as in
propositional logic. Such sentences are called assertions.
For example, we can assert that
John is a king, Richard is a person, and all kings are persons
◦ TELL(KB, King(John)) .
◦ TELL(KB, Person(Richard)) .
◦ TELL(KB, ∀ x King(x) ⇒ Person(x))

Department of Computer Science and Engineering 94


Using First Order logic
Assertions and queries in first-order logic

We can ask questions of the knowledge base using ASK.


Questions asked with ASK are called queries or goals.
For example, ASK(KB, King(John))

Department of Computer Science and Engineering 95


Example: Write statement in PL
1. Marcus was a man
man(marcus)

2. X is an integer
integer(x)

3. Caesor was a rular


rular(caesor)

Department of Computer Science and Engineering 96


Example: Write statement in PL
4.Ravi and Rama are brothers
brothers(ravi,rama)

5. Marcus tried to assassinate Caesar


trytoassassinate(marcus,Caesar)

Department of Computer Science and Engineering 97


Example: Write statement in PL
1. All man drink coffee
∀ x : man(x) 🡪 drink (x, cricket)

2. Every may respects his parent


∀ x : man(x) 🡪 respects (x, parent)

3. Some boys play cricket


∃ x : boys(x) ∧ play (x, cricket)

Department of Computer Science and Engineering 98


Example : Write statement in PL
4.Not all students like both maths and science
~ ∀ x : students(x) 🡪 like(x, maths) ∧ like(x, science)

5.Everyone is loyal to Someone


∀ x ∃ y loyal (x, y)

6. Everyone loves everyone


∀ x ∃ y loves(x, y)

Department of Computer Science and Engineering 99


Example : Write statement in PL
• Universal Quantifier

7. “All boys like cricket”


∀ x : boys(x) 🡪 like (x, cricket)

• Existential Quantifier
8. “Some boys like cricket”
∃ x : boys(x) ∧ like (x, cricket)

Department of Computer Science and Engineering 100


Using First Order logic
In knowledge representation,

A domain is some part of the world about which we wish to


express some knowledge.

Domains of
◦ Family relationships(The kinship domain)
◦ Wumpus world

Department of Computer Science and Engineering 101


Using First Order logic

Department of Computer Science and Engineering 102


Using First Order logic
The kinship domain

Department of Computer Science and Engineering 103


Using First Order logic

Department of Computer Science and Engineering 104


Using First Order logic
The Wumpus World

Department of Computer Science and Engineering 105


Using First Order logic
The Wumpus World

Department of Computer Science and Engineering 106


Knowledge engineering in first-order logic
The knowledge-engineering Process
• AI goal is to imitate the intelligence of a human being.
• Human uses his/ her intelligence based on his/ her knowledge to
make decisions.
• Example: Automate the teaching process for children in the
subject of mathematics
• Knowledge engineering is a field of study where we do the
engineering of all thought processes for specific domains.

Department of Computer Science and Engineering 107


Knowledge engineering in first-order logic
The knowledge-engineering Process

• The general process of constructing knowledge base is


called knowledge engineering
• A knowledge engineer investigates a
• Particular domain
• learns what concepts are important in that domain
• creates a formal representation of the objects and
relations in the domain

Department of Computer Science and Engineering 108


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
1. Identify the task
2. Assemble the relevant knowledge
3. Decide on a vocabulary of predicates, functions, and
constants
4. Encode general knowledge about the domain
5. Encode a description of the specific problem instance
6. Pose queries to the inference procedure and get answers
7. Debug the knowledge base

Department of Computer Science and Engineering 109


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
1.Identify the task

Department of Computer Science and Engineering 110


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
2.Assemble the relevant knowledge

Department of Computer Science and Engineering 111


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
3. Decide on a vocabulary of predicates, functions, and constants

Department of Computer Science and Engineering 112


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
4. Encode general knowledge about the domain
5. Encode a description of the specific problem instance
6. Pose queries to the inference procedure and get
answers
7. Debug the knowledge base

Department of Computer Science and Engineering 113


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process

Develop a knowledge base which will allow us to reason


about digital circuit (One-bit full adder) which is given
below

Department of Computer Science and Engineering 114


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
1. Identify the task
At the first level,we will examine the functionality of the circuit:
Does the circuit add properly?
What will be the output of gate A2, if all the inputs are high?
At the second level, we will examine the circuit structure details such as:
Which gate is connected to the first input terminal?
Does the circuit have feedback loops?

Department of Computer Science and Engineering 115


Knowledge engineering in first-order logic
Steps in the knowledge-engineering process
2.Assemble the relevant knowledge
We will assemble the relevant knowledge which is required for digital circuits.
So for digital circuits, we have the following required knowledge:
◦ Logic circuits are made up of wires and gates.
◦ Signal flows through wires to the input terminal of the gate, and each gate
produces the corresponding output which flows further.
◦ In this logic circuit, there are four types of gates used: AND, OR, XOR, and NOT.
◦ All these gates have one output terminal and two input terminals (except NOT
gate, it has one input terminal).

Department of Computer Science and Engineering 116


Knowledge engineering in first-order logic
3.Decide on a vocabulary of predicates, functions, and constants
Select functions, predicate, and constants to represent the circuits, terminals, signals, and gates.
Each gate is represented as an object which is named by a constant, Gate(X1).
Circuits will be identified by a predicate:  Circuit (C1)
Terminal(x)
Objects two signal values 1 and 0, and a function Signal(t) that denotes the signal value for the terminal t.
The functionality of each gate is determined by its type, which is taken as constants such as AND, OR, XOR,
or NOT.

For gate input, we will use the function


In(1, X1) - first input terminal of the gate
Out (1, X1) - output terminal

The connectivity between gates can be represented by predicate Connect(Out(1, X1), In(1, X1)).
Department of Computer Science and Engineering 117
Knowledge engineering in first-order logic
4.Encode general knowledge about the domain
To encode the general knowledge about the logic circuit,
we need some following rules:

Department of Computer Science and Engineering 118


Knowledge engineering in first-order logic
5.Encode a description of the specific problem instance

This step write simple atomics sentences of instances of


concepts
For the given circuit C1, we can encode the problem instance in atomic sentences :

In circuit there are two XOR, two AND, and one OR gate so atomic sentences for these gates will be:

Department of Computer Science and Engineering 119


Knowledge engineering in first-order logic
6.Pose queries to the inference procedure and get answers
Find all the possible set of values of all the terminal for the
adder circuit.
The first query will be: What should be the combination of input which would generate the first
output of circuit C1 as 0 and a second output to be 1?

Department of Computer Science and Engineering 120


Knowledge engineering in first-order logic
7.Debug the knowledge base
In this step, we will try to debug the issues of knowledge
base.

Department of Computer Science and Engineering 121


Outline
Inference in First Order logic
• Propositional vs. First-order
inference
• Unification
• Forward chaining
• Backward chaining
• Resolution

Department of Computer Science and Engineering 122


Propositional vs. First-order inference

Department of Computer Science and Engineering 123


Propositional vs. First-order inference
Substitutions

SUBST(θ,α) denote the result of applying the substitution θ to the


sentence α.

Department of Computer Science and Engineering 124


Propositional vs. First-order inference
Inference rules for quantifiers
• Universal Generalization

• Universal Instantiation

• Existential Instantiation

• Existential introduction

Department of Computer Science and Engineering 125


Propositional vs. First-order inference
Universal Generalization
• It is a valid inference rule which states that if premise P(c) is
true for any arbitrary element c in the universe of discourse,
then we can have a conclusion as ∀ x P(x).

Example
Let's represent, P(c): "A byte contains 8 bits",
so for ∀ x P(x) "All bytes contain 8 bits.", it will also be true.

Department of Computer Science and Engineering 126


Propositional vs. First-order inference
Universal Instantiation/elimination

It is a valid inference rule, It can be applied multiple times to add new


sentences.
As per UI, we can infer any sentence obtained by substituting a
ground term for the variable.

The UI rule state that we can infer any sentence P(c) by substituting a
ground term c (a constant within domain x) from ∀ x P(x) for any
object in the universe of discourse.

It can be represented as:       


Department of Computer Science and Engineering 127
Propositional vs. First-order inference
Universal Instantiation/elimination

It can be represented as:

Example 1:
IF "Every person like ice-cream"=> ∀x P(x)
so we can infer that "John likes ice-cream" => P(c)

Department of Computer Science and Engineering 128


Propositional vs. First-order inference
Universal Instantiation/elimination
Example 2:

"All kings who are greedy are Evil“


∀x king(x) ∧ greedy (x) → Evil (x)

we can infer any of the following statements using Universal Instantiation:

King(John) ∧ Greedy (John) → Evil (John)


King(Richard) ∧ Greedy (Richard) → Evil (Richard)

Department of Computer Science and Engineering 129


Propositional vs. First-order inference
Existential Instantiation/Elimination
• It is a valid inference rule in first-order logic, It can be applied only once to replace
the existential sentence.
• The new KB is not logically equivalent to old KB, but it will be satisfiable if old KB
was satisfiable.
• This rule states that one can infer P(c) from the formula given in the form of ∃x
P(x) for a new constant symbol c.
• The restriction with this rule is that c used in the rule must be a new term for
which P(c ) is true.
• It can be represented as:

Department of Computer Science and Engineering 130


Propositional vs. First-order inference
Existential Instantiation/Elimination
Example
• From the given sentence: ∃x Crown(x) ∧ OnHead(x, John)

• So we can infer: Crown(K) ∧ OnHead( K, John), as long as K


does not appear in the knowledge base.
• The above used K is a constant symbol, which is called
Skolem constant.
• The Existential instantiation is a special case of Skolemization
process.
Department of Computer Science and Engineering 131
Propositional vs. First-order inference
Existential introduction/generalization

• It is a valid inference rule in first-order logic.


• This rule states that if there is some element c in the
universe of discourse which has a property P, then we
can infer that there exists something in the universe
which has the property P.

• It can be represented as:

Department of Computer Science and Engineering 132


Propositional vs. First-order inference
Existential introduction

Example

"Pinky got good marks in English.“ c=


pinky
"Therefore, someone got good marks in English."

Department of Computer Science and Engineering 133


Substitution
A substitution is a Finite set {t1/v1, · · · ,tn/vn}
where vi is a variable
ti is a term, different from vi ,
and no two elements in the set have the same variable after the /
symbol.

Department of Computer Science and Engineering 134


Unification
•Unification means making expression looks identical.
•Can be done with the process of Substitution.
Example : p(x, F(y)) -------- 1
p(x, F(g(z)) --------- 2
1 and 2 are identical if x is replace with a
y is replaced with g(z)

[a/x , g(z)/y] –substitution set


p(a, F(g(z) )

Department of Computer Science and Engineering 135


Unification
Example : p(x, F(y)) -------- 1
p(x, F(g(z)) --------- 2

Unification conditions
1. Predicate symbol must be same
2. Number of arguments in both expressions must be identical
3. If two similar variables present in same expression, then unification fails

Department of Computer Science and Engineering 136


Unification
Example : Q(a, g(x,a), f(y)) -------- 1
Q(a, g(f(b) ,a),x) --------- 2
• Substitute f(b)/x
Q(a, g(f(b),a), f(y)) Q(a, g(f(b) ,a), f(b))
• Substitute b/y
Q(a, g(f(b),a), f(b)) Q(a, g(f(b) ,a), f(b))

Department of Computer Science and Engineering 137


Unification

Department of Computer Science and Engineering 138


Forward chaining
Start from the known facts, it triggers all the rules whose premises
are satisfied, adding their conclusions to the known facts.
The process repeats until the query is answered or no new facts
are added.

Department of Computer Science and Engineering 139


Forward chaining

Department of Computer Science and Engineering 140


Example: Write statement in PL
1. Sky is blue
sky 🡪 blue
2. Knife is a weapon
knife 🡪 weapon
3. John is a king
king(john)

Department of Computer Science and Engineering 141


Example :Forward chaining
"The law says that it is a crime for an American to sell
weapons to hostile nations. The country Nono, an
enemy of America, has some missiles, and all of its
missiles were sold to it by ColonelWest, who is
American.

Prove that ”West is criminal."

Department of Computer Science and Engineering 142


Forward chaining
Convert all the facts into first-order definite clauses, and
then use a forward-chaining algorithm to reach the goal.
There are some facts give here:
◦ It is a crime for an American to sell weapons to an enemy of America
◦ Country A is the enemy of America
◦ A colonel of the army sells missiles to A
◦ Missiles are weapons
◦ The colonel is an American citizen

Department of Computer Science and Engineering 143


Forward chaining

Department of Computer Science and Engineering 144


Forward chaining
Nono has some missiles
There exist something in Universe, that NONO owns, and That
something is missile.

Department of Computer Science and Engineering 145


Forward chaining

Department of Computer Science and Engineering 146


Forward chaining

Department of Computer Science and Engineering 147


Forward chaining

Department of Computer Science and Engineering 148


Forward chaining

Department of Computer Science and Engineering 149


Forward chaining

Department of Computer Science and Engineering 150


Properties of Forward chaining
Sound and complete for first-order definite clauses

Datalog = first-order definite clauses + no functions


(e.g., crime KB)

Department of Computer Science and Engineering 151


Forward chaining
Consider the following sentences:
1.John likes all kinds of food
2.Apples are food
3.Chicken is food
4.Anything anyone eats and isn't killed by is food.
5.Bill eats peanut and is still alive
6. sue eats everything bill eats
(i) Translate these sentences into formulas in predicate logic.
(ii) Prove that john likes peanuts using forward chaining

Department of Computer Science and Engineering 152


Forward chaining
John likes all kinds of food
∀ x : food(x) 🡪 likes (John, x)

Apples are food


Apples(x) 🡪 food(x)

Chicken is food

Chicken(x) 🡪 food(x)

Department of Computer Science and Engineering 153


Forward chaining
Anything anyone eats and isn't killed by is food
∀ x ∀ y eats (x, y ) ∧ ~ killed (y) 🡪 food (x)

Bill eats peanut and is still alive


eats (bill, peanut ) ∧ ~ killed (bill)

sue eats everything bill eats

∀ x eats (bill, x ) 🡪 eat (sue, x)

Department of Computer Science and Engineering 154


Forward chaining
∀ x : food(x) 🡪 likes (John, x)
Apples(x) 🡪 food(x) food(Apple)
Chicken(x) 🡪 food(x) food(Chicken)
∀ x ∀ y eats (x, y ) ∧ ~ killed (y) 🡪 food (x)
eats (bill, peanut ) ∧ ~ killed (bill)
∀ x eats (bill, x ) 🡪 eat (sue, x)

eats (bill, peanut ) ~ killed (bill)

Department of Computer Science and Engineering 155


Forward chaining
∀ x : food(x) 🡪 likes (John, x)
Apples(x) 🡪 food(x)
Chicken(x) 🡪 food(x)
∀ x ∀ y eats (x, y ) ∧ ~ killed (y) 🡪 food (x)
eats (bill, peanut ) ∧ ~ killed (bill)
∀ x eats (bill, x ) 🡪 eat (sue, x) food (peanut )

~ killed (bill)
eats (bill, peanut )

Department of Computer Science and Engineering 156


Forward chaining
∀ x : food(x) 🡪 likes (John, x)
likes (John, peanut)
Apples(x) 🡪 food(x)
Chicken(x) 🡪 food(x)
∀ x ∀ y eats (x, y ) ∧ ~ killed (y) 🡪 food (x)
eats (bill, peanut ) ∧ ~ killed (bill)
food (peanut )
∀ x eats (bill, x ) 🡪 eat (sue, x)

~ killed (bill)
eats (bill, peanut )

Department of Computer Science and Engineering 157


Forward chaining algorithm

Department of Computer Science and Engineering 158


Backward-chaining algorithm

Department of Computer Science and Engineering 159


Backward chaining

Department of Computer Science and Engineering 160


Backward-chaining algorithm
Backward chaining is clearly a depth-first search algorithm.

Department of Computer Science and Engineering 161


Backward chaining
Consider the following sentences:
1.John likes all kinds of food
2.Apples are food
3.Chicken is food
4.Anything anyone eats and isn't killed by is food.
5.Bill eats peanut and is still alive
6. sue eats everything bill eats
(i) Translate these sentences into formulas in predicate logic.
(ii) Prove that john likes peanuts using Backward chaining

Department of Computer Science and Engineering 162


Resolution
▪ First-order resolution requires that sentences to be
in conjunctive normal form (CNF)
▪ The procedure for conversion to CNF
▪ Resolution Refutation

Department of Computer Science and Engineering 163


Steps to convert FOL to Clause form

Department of Computer Science and Engineering 164


ALGORITHM TO CONVERT TO CLAUSAL FORM
1.Eliminate biconditionals and implications
(P ↔ Q) ⇒ ((P → Q) ^ (Q → P))
(P → Q) ⇒ (¬P ∨ Q)
2.Move ¬ inwards
¬ (¬P) ⇒P
¬(P ∨ Q) ⇒ ¬P ∧ ¬Q
¬(P ∧ Q) ⇒ ¬P ∨ ¬Q
¬(∀x)P ⇒ (∃x)¬P
¬(∃x)P ⇒ (∀x)¬P

165
ALGORITHM TO CONVERT TO CLAUSAL FORM
3. Standardize variables: rename all variables so that each quantifier has its
own unique variable name
Example:
∀ x : man(x) ∀ x : man(x)
∀ x : Happy(x) ∀ y : Happy(y)
∃ x : boys(x) ∃ z : boys(z)

166
ALGORITHM TO CONVERT TO CLAUSAL FORM
Skolem constants and functions
4. Skolemization
Eliminate existential quantifier and replace it by skolem constants
Example:
∃ x : Smile(x)
∃ y : Graduating(y )
After Skolemization
Smile(A)
Graduating(B)

167
ALGORITHM TO CONVERT TO CLAUSAL FORM
5. Drop or Remove universal quantifiers by
(1) moving them all to the left end;
(2) making the scope of each the entire sentence;
(3) dropping the “prefix” part Example:
∀ x : Smile(x)
∀ y : Graduating(y )

After Dropping
Smile(x)
Graduating(y) 168
ALGORITHM TO CONVERT TO CLAUSAL FORM
6. Apply distribute law / associative laws
(P ∧ Q) ∨ R ⇒ (P ∨ R) ∧ (Q ∨ R)
(P ∨ Q) ∨ R ⇒ (P ∨ Q ∨ R)
7. Split conjuncts into separate clauses
8. Standardize variables so each clause contains only variable names that do not
occur in any other clause

169
Resolution Refutation
• Resolution is a theorem proving technique that proceeds
by building refutation proofs, i.e., proofs by
contradictions.
• It was invented by a Mathematician John Alan Robinson in
the year 1965.
• Resolution is used, if there are various statements given,
and we need to prove a conclusion of those statements.

Department of Computer Science and Engineering 170


Resolution
• Pair of clauses being resolved is called the
Resolvents.
• The resulting clause is called the Resolute.
• Choosing the correct pair of resolvents is a
matter of search.

Department of Computer Science and Engineering 171


Resolution refutation proofs involve the following
steps:

Department of Computer Science and Engineering 172


Resolution refutation proofs steps:

Department of Computer Science and Engineering 173


Example -1
Problem Statement: Prove by resolution

Department of Computer Science and Engineering 174


1.Convert to FOL

Department of Computer Science and Engineering 175


2.Convert FOL to CNF

Department of Computer Science and Engineering 176


3. Negate the statement to be proved

Department of Computer Science and Engineering 177


Draw resolution graph

Department of Computer Science and Engineering 178


Draw resolution graph
Hence we see that the negation of the
conclusion has been proved as a
complete contradiction with the given
set of facts.

Hence Proved

Department of Computer Science and Engineering 179


Example-2

Department of Computer Science and Engineering 180


Example-2
CNF Form

Department of Computer Science and Engineering 181


Example-2

Department of Computer Science and Engineering 182


Example-2
Hence we see that the
negation of the conclusion
has been proved as a
complete contradiction
with the given set of facts.

Hence Proved

Department of Computer Science and Engineering 183


Problem using Resolution Refutation
Consider the below argument and using Resolution
Refutation Procedure check whether ‘John is happy’

“Anyone passing his history exams and winning the


lottery is happy. But anyone who studies or is lucky can
pass all his exams. John did not study, but John is
lucky. Anyone who is lucky wins the lottery.”

Department of Computer Science and Engineering 184


Problem using Resolution Refutation
Anyone passing his history exams and winning the
lottery is happy.

But anyone who studies or is lucky can pass all his


exams.

John did not study, but John is lucky.

Anyone who is lucky wins the lottery

Department of Computer Science and Engineering 185


Department of Computer Science and Engineering 186
Department of Computer Science and Engineering 187
Department of Computer Science and Engineering 188
Department of Computer Science and Engineering 189
Department of Computer Science and Engineering 190
Department of Computer Science and Engineering 191
Department of Computer Science and Engineering 192
Department of Computer Science and Engineering 193
Department of Computer Science and Engineering 194
Problem – Dead Dog Problem
Axioms :
1. All dogs are animals
2. Fido is a dog
3. All animals will die

Theorem to proof : Fido will die

Department of Computer Science and Engineering 195


Problem – Dead Dog Problem
Axioms :
1. All dogs are animals : ∀ X [dog(X) ⇒ animal(X)]
2. Fido is a dog : dog(fido).
3. All animals will die : ∀ Y [animal(Y ) ⇒ die(Y )]

Theorem to proof :
Fido will die : die(fido).

Department of Computer Science and Engineering 196


Problem – Dead Dog Problem
1.∀ X [dog(X) ⇒ animal(X)]
∀ X ¬ dog(X) ∨ animal(X)
¬ dog(X) ∨ animal(X)

2. dog(fido)

3. ∀ Y [animal(Y ) ⇒ die(Y )]
∀ Y ¬ animal(Y) ∨ die(Y)
¬ animal(Y) ∨ die(Y)

Department of Computer Science and Engineering 197


Problem – Dead Dog Problem
die(fido)
¬ die(fido)

Department of Computer Science and Engineering 198


Problem – Dead Dog Problem
• ¬ dog(X) ∨ animal(X)

• dog(fido)

• animal(Y) ∨ die(Y)

• ¬ die(fido)

Department of Computer Science and Engineering 199


Department of Computer Science and Engineering 200
Fig. One refutation for the “exciting life” problem.

Department of Computer Science and Engineering 201


Fig Unification substitutions applied to the original query.

Department of Computer Science and Engineering 202


Extract the answer for the question “Where is
Fido?”, given the below axioms in the KB.

1. Dog Fido goes wherever John goes.


2. John is at library.

203
Department of Computer Science and Engineering 203
Fig. Answer extraction process on the “finding fido” problem.
Dog Fido goes wherever John goes. John is at library. Where is Fido?

204
Department of Computer Science and Engineering 204
Department of Computer Science and Engineering 205
Department of Computer Science and Engineering 206
Resolution Problem
All teachers are good. Anyone who is good and
intelligent will deliver excellent lecture. Mohan is an
intelligent teacher. Show that Mohan will deliver an
excellent lecture.

Department of Computer Science and Engineering 207


•All teachers are good.

•Anyone who is good and


intelligent will deliver excellent
lecture.

•Mohan is an intelligent teacher.

•Show that Mohan will deliver an


excellent lecture.

Department of Computer Science and Engineering 208


Department of Computer Science and Engineering 209
Department of Computer Science and Engineering 210
Thank you

Department of Computer Science and Engineering 211

You might also like