You are on page 1of 17

10/11/2021

“ARTIFICIAL INTELLIGENCE SYLLABUS


UNIT IV”  Knowledge Based Agents
 Logic, Prepositional Logic
 Inference Equivalence
Knowledge Based Agents  Validity and satisfiability
 Resolution
 Forward and Backward Chaining
 DPLL algorithm
By  Local search algorithm
 First Order Logic & its syntax and semantics
Ms.C.B.Thaokar
Assistant Professor  Inference in FOL
Department of Information Technology  Unification and Lifting
RCOEM  Forward and Backward Chaining
2
 Resolution
1

What is Knowledge?

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.
LOGICAL AGENTS
Knowledge is an useful term to judge the understanding of
an individual on a given subject.

3 4

WUMPUS WORLD PROBLEM WUMPUS WORLD PROBLEM

• Environment
• Wumpus world is a cave - Squares adjacent to the Wumpus are smelly
consisting of rooms - Square adjacent to pit are breezy
- Glitter if gold in the square
• Wumpus (Beast) that eats
anyone who enters its room is
present in one of the rooms • Performance Measure
- gold + 1000 death -1000
• Some rooms contain bottomless - -1 per step , -10 using the arrow
holes called pit that will trap
anyone who enters the room
except Wumpus •Actuators Left , Right Forward Grab, shoot
• The wumpus can be shot dead
by an agent but the agent has •Sensors Agent can perceive stench, Breeze and Glitter
only one arrow.
• One of the rooms contains a5 6

heap of gold.

1
10/11/2021

WUMPUS WORLD PROBLEM HOW DO YOU REPRESENT KNOWLEDGE IN A


MACHINE
 We need a language to represent knowledge
- Propositional Logic
- First order Logic

o Every Language has a grammar


o Grammar has syntax and Semantics
o Both syntax and semantics must be well defined to
understand a language

Example – Syntax and Semantics ( English Language):


- Smith is smart
7 8
- Mary likes pets

PROPOSITIONAL LOGIC PROPOSITIONAL LOGIC : SYNTAX

 Propositions: Proposition are nothing but sentences  Proposition logic is the simplest logic – illustrates basic
 Representing sentences in propositional logic ideas
Smith is smart  The proposition symbols S1 , S2 etc are sentences
if S is sentence , ⌐ is a sentence ( negation)
if S1 and S2 are sentences S1 ^ S2 is a sentence ( Conjunction)
Mary likes pets
P= Rohan is intelligent,
Q= Rohan is hardworking
There is breeze in cell 21 if S1 and S2 are sentences S1 ν S2 is a sentence ( Disjunction)
if S1 and S2 are sentences S1 S2 is a sentence ( Implication)(If then rule)
If it is raining, then the street is wet.
More formally a proposition is constituted of objects and
relations if S1 and S2 are sentences S1 S2 is a sentence ( Biconditional)
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.
- Propositional Symbols True False
9 10

TRUTH TABLE FOR CONNECTIVES PROPOSITIONAL LOGIC: SEMANTICS

 Semantics - Gives Meaning of propositional


sentences
- Interpretation in world
- A proposition which is true in a world may not be
true in some other world
- When we interpret a sentence in a world , we
assign meaning to it and it evaluates to either
TRUE or FALSE

11 12

2
10/11/2021

CONCEPT OF WORLD
HOW DO WE GET THE MEANING
 Example  Sentences can be compound propositions
 Interpret each atomic proposition in the same world
T World 1  Assign truth value to each proposition
Nursery
Child can speak  Compute the truth value of compound proposition

Example
Given P Q R
F T False true false
child can write World 2 ⌐ P ^ Q v R ) = true ^ (true v false ) = true ^ true = true
T Class III

13 14

WUMPUS WORLD SENTENCES


INFERENCE TECHNIQUES
Let Pi,j be true if there is a pit in [ i,j]
Let Bi,j be true if there is a breeze in [i,j]
To derive conclusion from available knowledge,
following techniques are used:
⌐ P1,1 - Truth Table enumeration method
- Theorem Proving
⌐ B1,1 - Resolution
B2,1 Entailment
- Something logically follows with whatever
“ Pits cause breezes in adjacent squares” has been given
- Entailment is a relationship between sentences
B1,1 ( P1,2 V P2,1) (i.e., syntax) that is based on semantics
B2,1 ( P1,1 V P2,2 V P3,1) 15 16

TRUTH TABLE FOR INFERENCE


ILLUSTRATION OF ENTAILMENT
 Draw the TT containing all the symbols in KB
 If there are n varaibles , than there will 2 N
rows in TT
Set of Decision Yes/ No
sentences Machine  Find out in which rows KB is true . If in all rows
α is also true then knowledge base entails α
KB is it true
 Alternatively we say that knowledge KB
entails sentence α if and only if α is true in
New proposition
all interpretations where KB is true.

α
Knowledge base KB entails sentence α 17 18

KB = α

3
10/11/2021

EXAMPLE
Given R1 = B11 P12 v P21 LOGICAL EQUIVALENCE
R2= ⌐ B11, KB = R1 ^ R2
Find out : ⌐P12

B11 P12 P21 P12 V P21 R1 R2 KB α


F F F F T T T T
F F T T F T F T
F T F T F T F F
F T T T F T F F
T F F F F F F T
T F T T T F F T
T T F T T F F F
19 20
T T T T T F F F

INFERENCE RULES
INFERENCE RULES
 Modus ponens
 AND Elimination
P Q given
- From a conjunct any of the conjunct can be inferred
P given
Q ( we can derive)
Given P ^ Q we can infer either

Example : lets say P, Q, R denotes the following


Example
P : It is the month of August
1) WumpusAhead ^ WumpusAlive
Q : its rains
2) Intelligent(Ram) ^ Hardworking(Ram)
R: P Q ( if it the month of August then it rains)
Now
Given 1) if it is the month of august then it rain
2) It is the month of august 21 22

Conclusion ?

INFERENCE USING MODUS PONEN EXAMPLE

 Mammal ( Tom) drink( Tom ,Milk)


 Man(Tom) Mortal(Tom)
 Man(Tom) Mammal(Tom)
 Man (Tom)

Resolution
- Tom drinks Milk ???

23 24

4
10/11/2021

VALIDITY AND SATISFIABILITY HAT IS A CLAUSE

 A sentence is valid if is true in all models • Literal : an atomic proposition or its negation
eg: True , A v ⌐ A A -> A eg P , ⌐P
• Clause : A special form . A clause is a disjunction
of literals
o A sentence is satisfiable if is true in atleast one model
eg A v B
• Example : ( P v Q v ⌐ R ) is a clause
o A sentence is unsatisfiable if is true in no models
eg A^ ⌐ A

o Satisfiability is connected to inference via the following


KB = α if and only if KB ^ ⌐ α is un satisfiable
25 26

CONJUNCTIVE NORMAL FORM(CNF)/


CLAUSAL FORM SIGNIFICANCE OF CLAUSAL FORM
Let C1 ^ C2 ^ C3 …. ^ Cn be a set of clauses
each clause Ci is given by the following  It allows us a very important inference technique
called resolution.
Ci = D1 v D2 v D3 ... v Dk
 Most popular inference technique

Where each Di is an atomic proposition or literal , say P


or ⌐ P
 Resolution Rule
Example: - Given : ( A v B ) and (⌐A v C ) then after
( P v Q ) ^ ( ⌐ P v R) ^ ( S v T v ⌐ P) applying resolution rule we get
- (BvC)
Above example denotes the CNF of a sentence 27 28
consisting of three clauses

RESOLUTION RULE RESOLUTION RULE EXAMPLE


 Given the following  Ex-1
C1= D1 v D2 v D3 .. v Di-1 v Di v Di+1 ..v Dk C1 = ( P v Q) and
C2 = (⌐P v R v S)
C2 = E1 v E2 v E3 … v Ej-1 v Ej v Ej+1 … V Em
C3 = Q v R v S
If Di and Ej are complementary propositions then
they can be resolved and we get Ex-2
C1 = A v ⌐B v C and
C3 = D1 v D2 v D3 .. v Di-1 v Di+1 ..v Dk C2 = D v E v B v F then
v E1 v E2 v E3 … v Ej-1 v Ej+1 … V Em
29 30
C3 = A v C v D v E v F
- C3 is called as resolvent

5
10/11/2021

EXAMPLE INFERENCE USING RESOLUTION


RESOLUTION ALGO
 KB
 Convert KB ^ ⌐ α into CNF R1 : B11 P12 v P21
 Apply resolution rule R2: ⌐ P11
 If application of resolution derives an empty R3: ⌐ B11
string or null clause then KB entails α
α= ⌐P12
 The proof is by contradiction and called as
refutation

- if we want to prove α we actually disprove ⌐ α

31 32

SOLUTION: INFERENCE USING RESOLUTION SOLUTION: INFERENCE USING RESOLUTION


step 1) apply foll to rule 1
- Eliminate biconditional implication from rule1
- Remove Implication from result of step 1
- Simplify negate sign
- Use distributive law
Step 2) keep R2 and R3 as it is
Step 4) Apply KB ^ ⌐ α to resolve

33 34

CONTENTS
 Why FOL

 Syntax and Semantics of FOL

 Using FOL
First Order Logic

35 36

6
10/11/2021

PROS AND CONS OF PROPOSITIONAL LOGIC FOL


 Whereas propositional assumes the world contains fact,
 Propositional logic is declarative
 FOL assumes world contains
 Propositional logic allows partial / disjunctive/ negated
information - Objects: which are things with individual
- ( unlike most data structures and databases) identities
Propositional logic is compositional People, houses, numbers, colors etc
- meaning of B1,1 ^ P1,2 is derived from meaning of - Relations : that hold among sets of objects. It can be
B1,1 and of P1,2 unary relation such as: red, round, is adjacent, or
Meaning in Propositional logic is context independent n-any relation such as
- ( unlike natural language , where meaning depends the sister of, brother of, has color, comes between
on context) - Functions : which are a subset of relations
Propositional logic has very limited expressive power where there is only one “value” for any given
- Cannot say “ pits cause breeze in adjacent squares” 37 “input” 38
( except by writing one sentence for each square) Father of, best friend, one or more, plus,…

SYNTAX OF FOL : BASIC ELEMENTS


ATOMIC SENTENCES
 Constants john, ram , rcoem, 4
 Predicates Brother, > , sister
 Functions sqrt, leftlegOf,..
 Variables X, Y , a, b…..  Atomic sentence = predicate ( term1, --, termn)
 Connectives ⌐ , , ,v,^
 Equality = Term = function( term1, ---, termn)
 Quantifiers Ǝ ∀ or variable or constant

Example : Brother( John, Richard)

> ( Length(LeftLegOf(Richard)),Length(LeftLegOf(John)))
39 40

COMPLEX SENTENCES TRUTH IN FOL


 Complex sentences are made from atomic  Sentence are truth with respect to model and an interpretation
sentences using connectives
S1 ^ S2, S1 v S2 , S1 S  Model contains objects ( domain elements) and relations among them

 Interpretation specifies referents for


Eg. > (1,2) ^ Γ > (1,2 ) constant symbols - > objects
predicate symbols -> relations
> (1,2 ) v <= (1,2)
function symbols -> functional relations

An atomic sentence predicate ( term1, … ,termn) is true


if the objects referred to by term…term are in relation referred to
by predicate.
41 42

7
10/11/2021

UNIVERSAL QUANTIFICATION COMMON MISTAKE TO AVOID

 ∀ < variables> <sentence>  Typically -> is the main connective with ∀

Everyone at RCOEM is smart  Common mistake : using ^ as the main connective


∀x At ( x, RCOEM) -> smart(x) with ∀ :
∀x P is true in model m Iff P is true with x
being each possible object in the model ∀x At ( x, RCOEM) ^ smart(x)

Roughly speaking equivalent to the conjunction of means “ Everyone is at RCOEM and everyone is smart
instantiations of P
At( john, RCOEM) -> smart(john)
^ At( Richard, RCOEM) -> smart(richard)
43 44
^ At(RCOEM, RCOEM) -> smart(RCOEM)

EXISTENTIAL QUANTIFICATION
COMMON MISTAKE TO AVOID
 Ǝ <variable > < sentence>
 Typically ^ is the main connective with Ǝ
someone at RCOEM is smart:
Ǝx At(x,RCOEM) ^ smart(x)  Common mistake : using -> as the main connective
with Ǝ :
- Ǝ x P is true in a model m iff P is true with x
being some possible object in the model Ǝ x At ( x, RCOEM) -> smart(x)

Roughly speaking equivalent to the disjunction of Is true if there is anyone who is not at RCOEM
instantiations of P
At( john, RCOEM) ^ smart(john)
v At( Richard, RCOEM) ^ smart(richard)
45 46
v At(RCOEM, RCOEM) ^ smart(RCOEM)

PROPERTIES OF QUANTIFIERS EQUALITY


 ∀x ∀y is same as ∀y ∀x
 Ǝx Ǝy is same as Ǝy Ǝx  term1 = term2 is true under a given
interpretation if and only if term1 and term2
Ǝx ∀y is not the same as ∀y Ǝx refers to the same object
Ǝx ∀y loves(x,y)
- “There exists a person who loves everyone in the Eg- definition of sibling in terms of parent
world”
∀y Ǝx loves(x,y) ∀x ,y siblings(x,y) ⇔ [⌐(x =y) ^ Ǝm, f ⌐ (m =f) ^
- Everyone in the world is loved by atleast one person parent (m,x) ^ parent(f,x) ^ parent(m,y) ^
Quantifier duality : each can be expressed using other parent(f,y)]

∀x Likes(x, Icecream) ⌐ Ǝx ⌐Likes(x, icecream)


47 48
Ǝx Likes(x, Broccoil) ⌐ ∀x ⌐ Likes(x, Broccoil)

8
10/11/2021

USING FOL INTERACTTING WITH FOL KB


 Tell (KB , King(john))
- Richard has atleast two brothers  Tell ( KB, ∀x King(x) -> Person(x))
Ǝ x, y brother(x, richard) ^ brother(y, richard) ^  Tell ( KB, Person( Richard))
⌐(x = y)  Ask ( KB, Ǝx person(x))

- Richard has exactly two brothers Sol- Yes { x | john , x| richard}


Ǝ x, y [brother(x, richard) ^ brother(y, richard) ^
⌐(x = y) ^
∀z ( brother(z,richard) -> (x=z) v (y=z)]

49 50

FOL / PREDICATE LOGIC (PL) EXAMPLES


SUMMARY Operators/Symbols used in Predicate logic:
Arithmetic operators: < , >, <=, >=, ≠, etc.
 FoL
we consider now basic conversions of statements into FOL:
- Objects and relations are semantic primitives 1. Marcus is a Man
- syntax: constants, functions, predicattes, Proper noun Predicate
equality, quantifiers

In Predicate logic this will be represented as


Increased expressive power : sufficient to define Man (Marcus)
wumpus world.
Marcus is an object / instance of the class Man

51

FOL / PREDICATE LOGIC (PL) EXAMPLES


FOL / PREDICATE LOGIC (PL) EXAMPLES
CONTD
CONTD

2. Marcus was a pompien 4. Every Gardener likes Sun

Pompien (Marcus) Predicate Noun

3. All pompiens were romans When we analyse we get,


When we analyse that any instance of class pompiens is also the Likes (Gardener, Sun)
instance of class romans.
We will use implications So for all instances of gardener, there exits a sun
Hence, we represent it as,
Represents:
For all pompien x implies roman x x : Gardener (x)  likes (x,sun)

That is
x : Pompien (x)  Roman (x) 5. All purple Mushrooms are poisonous
Information Inference x : Mushrooms (x) ^ purple (x)  poisonous (x)

9
10/11/2021

FOL / PREDICATE LOGIC (PL) EXAMPLES CONTD FOL / PREDICATE LOGIC (PL) EXAMPLES CONTD

8. Everyone loves everyone except himself


6. Everyone is loyal to someone
x y : loves (x,y) ^ ¬ loves(x,x)
x Ǝ y : loyal (x,y)

7. Everyone loves everyone 9. All romans were either loyal to Ceaser or hated him

x y : loves (x,y) x : Roman(x)  loyal (x,Ceaser) v hates(x,Ceaser)

10. People only try to assassinate rulers they are not loyal to

x y: Person(x) ^ Ruler (y) ^ tryassassinate (x,y)  ¬ loyal (x,y)

FOL / PREDICATE LOGIC (PL) EXAMPLES CONTD


EXAMPLE - WORKOUT
11. Anyone who is married and has more than one spouse is a Bigamist

x : Married (x) ^ (no. of spouse(x) > 1)  Bigamist(x)


 John likes all kind of food.
x : Married (x) ^ gt (no. of spouse(x) , 1)  Bigamist(x)  Apple and vegetable are food
 Anything anyone eats and not killed is food.

12. You can fool all the people some of the time  Anil eats peanuts and still alive

 Harry eats everything that Anil eats.


x Ǝ t : Person (x)  time(t) ^ canfool (x,t)

13. You can fool some of the people all the time

Ǝx t : Person (x) ^ time(t)  canfool (x,t)

58

SOLUTION - EXAMPLE - WORKOUT


 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.
Inference Engine - FOL
∀x ∀ y : eats(x,y) ^ ¬ killed(x) -> food(y)
 Anil eats peanuts and still alive

peanuts(anil, peanuts) ^ alive(anil)


 Harry eats everything that Anil eats.

∀x : eats(anil,x) -> eats(harry,x)

59 60

10
10/11/2021

INFERENCING FOL UNIVERSAL INSTANTIATION (UI)


 UI or universal elimination is a valid inference rule. It can be applied multiple
o Unification times to add new sentences.
o Genaralized Modus Ponen  The new KB is logically equivalent to the previous KB.
As per UI, we can infer any sentence obtained by substituting a ground
o Forward Chaining 
term for the variable.
o Backward Chaining  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
o Resolution universe of discourse.
 It can be represented as:.

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


"John likes ice-cream" => P(c)
2) All kings who are greedy are Evil.
∀x king(x) ∧ greedy (x) → Evil (x),

61 King(John) ∧ Greedy (John) → Evil (John), 62


King(Richard) ∧ Greedy (Richard) → Evil (Richard),
King(Father(John)) ∧ Greedy (Father(John)) → Evil (Father(John)),

EXISTENTIAL INSTANTIATION(EI)
 EI as Existential Elimination,
 It can be applied only once to replace the existential a. ¬ food(x) V likes(John, x)
sentence. food(Apple)
 The new KB is not logically equivalent to old KB, but it food(vegetables)
will be satisfiable if old KB was satisfiable. ¬ eats(y, z) V killed(y) V food(z)
 This rule states that one can infer P(c) from the formula eats (Anil, Peanuts)
given in the form of ∃x P(x) for a new constant symbol c. alive(Anil)
 The restriction with this rule is that c used in the rule ¬ eats(Anil, w) V eats(Harry, w)
must be a new term for which P(c ) is true. killed(g) V alive(g)
¬ alive(k) V ¬ killed(k)

63 64

EXISTENTIAL INSTANTIATION(EI) GENERALIZED MODUS PONENS


Eg: ∃x Crown(x) ∧ OnHead(x, John),  For the inference process in FOL, we have a single
inference rule which is called Generalized Modus
 So we can infer:
Ponens. It is lifted version of Modus ponens.
Crown(K) ∧ OnHead( K, John), as long as K
 Generalized Modus Ponens can be summarized as, " P
does not appear in the knowledge base.
implies Q and P is asserted to be true, therefore Q must
 The above used K is a constant symbol, which is
be True."
called Skolem constant.
 According to Modus Ponens, for atomic sentences pi, pi',
 The Existential instantiation is a special case
q. Where there is a substitution θ such that SUBST (θ,
of Skolemization process. pi',) = SUBST(θ, pi), it can be represented as

65 66

11
10/11/2021

GENERALIZED MODUS PONENS INFERENCE ENGINE


 Eg All kings who are greedy are Evil. Inference is nothing but coming to a conclusion.
∀x king(x) ∧ greedy (x) → Evil (x), IE is the component of the system that applies logical rules to
the knowledge base to derive new information.

Two modes in which IE works is:


p1' is king(John) p1 is king(x) 1. Forward Chaining / Forward Reasoning
p2' is Greedy(y) p2 is Greedy(x) 2. Backward Chaining / Backward Reasoning
θ is {x/John, y/John} q is evil(x)
Forward Chaining / Forward Reasoning
Starts with the known facts and asserts new facts.

SUBST(θ,q). Backward Chaining / Backward Reasoning


Starts with goals and works backward to determine what
67
facts must be asserted so that the goal can be achieved
Both method uses Modus Ponens

BACKWARD-CHAINING
FORWARD AND BACKWARD CHAINING EXAMPLE  A backward chaining algorithm is a form of reasoning, which starts with
Example of FC: the goal and works backward, chaining through rules to find known facts
Conclude from ‘A’ and ‘A  B’ to ‘B’ that support the goal.
Properties of backward chaining:
Example: A= It is raining
A B: If it is raining , the road is wet  It is known as a top-down approach.

 Backward-chaining is based on modus ponens inference rule.


Hence, B = The road is wet  In backward chaining, the goal is broken into sub-goal or sub-goals to
prove the facts true.
Example of BC:  It is called a goal-driven approach, as a list of goals decides which rules
Conclude from ‘B’ and ‘A  B’ to ‘A’ are selected and used.
 Backward -chaining algorithm is used in game theory, automated theorem
Example: B = The road is wet proving tools, inference engines, proof assistants, and various AI
A B: If it is raining , the road is wet
applications.
Hence, A= It is raining  The backward-chaining method mostly used a depth-first search strategy
for proof. 70

BACKWARD CHAINING / BACKWARD REASONING BACKWARD CHAINING / BACKWARD REASONING


It is based on the decision , the initial state is fetched , then it is
called as backward chaining. To prove this we need to convert these given facts into FOL
1. American(x) ˄ Weapon (y) ˄ sell (x,y,z) ˄ enemy(z,America)
Backward Chaining is also called as decision-driven or goal driven  Criminal (x)
inference technique.
2. Enemy (Nono, America)
EXAMPLE:
3. Has (Nono,x)
We need to prove that Colonel is a Criminal. Missile(x)
Some general facts given:
1. It is crime for an American to sell weapons to the enemy of 4. x: Missile(x) ˄ Has (Nono,x)  sell (Colonel,x,Nono)
America.
2. Country Nono is an enemy of America 5. Missile(x)  Weapon (y)
3. Nono has some Missiles. 6. American (Colonel)
4. All the missiles were sold to Nono by Colonel
5. Missile is a Weapon
6. Colonel is American

12
10/11/2021

BACKWARD CHAINING / BACKWARD REASONING FORWARD-CHAINING


We need to prove that Colonel is a Criminal.
 The Forward-chaining algorithm starts from known facts, triggers all
We prove this by Backward Chaining after conversion to FOL
We start with goal: Goal is Criminal (Colonel) rules whose premises are satisfied, and add their conclusion to the
known facts. This process repeats until the problem is solved.
1) We check the left hand side, criminal logic is coming in whose right hand side. Properties of Forward-Chaining:
and so on..
2. We terminate by true, if that is complete fact as it is already present.  It is a down-up approach, as it moves from bottom to top.

 It is a process of making a conclusion based on known facts or data,

Criminal (Colonel) by starting from the initial state and reaches the goal state.
 Forward-chaining approach is also called as data-driven as we reach
to the goal using available data.
American(colonel) Weap sell (Colonel,y,z) enemy(z,America)
on (y)

True Missile (y) Missile (y) Has (Nono,y) Enemy (Nono,


America )

74
True True True
True

FORWARD CHAINING / FORWARD REASONING FORWARD CHAINING / FORWARD REASONING


To prove this we need to convert these given facts into FOL
1. American(x) ˄ Weapon (y) ˄ sell (x,y,z) ˄ enemy(z,America) Steps:
 Criminal (x) 1. Identify facts first from the logic representation and
write them as root node.
2. Enemy (Nono, America) 2. For generating the next level, Identify whether any of
the root node is being used to derive any right side of
3. Has (Nono,x)
Missile(x) the implication , then write the right hand side as the
next node.
4. x: Missile(x) ˄ Has (Nono,x)  sell (Colonel,x,Nono) 3. Uses conjunction for deriving
5. Missile(x)  Weapon (x)

6. American (Colonel)

FORWARD CHAINING / FORWARD REASONING RESOLUTION IN PREDICATE LOGIC


American Missile(x) Has (Nono,x) Enemy (Nono, When computer is given some facts represented in some logic
(Colonel) America) based on which system proves /derives / concludes
something… The procedure is called as Resolution. Computer
Weapon (x) Sell decides on something based upon the given facts that process
(Colonel,x,Nono) is actually resolution.

Resolution is the complete inference procedure which it


performs on the knowledge base / facts.

Criminal (Colonel) Steps for Resolution of statement


• Negate the statement to be proved
• Convert given facts into FOL.
• Convert FOL to CNF (Conjunctive/closed Normal Form)
• Resolve using a Resolution Tree /Graph (Unification)

13
10/11/2021

RESOLUTION IN PREDICATE LOGIC RESOLUTION IN PREDICATE LOGIC


Steps for Resolution of statement
Resolution is deciding over to do or not to do: • Negate the statement to be proved
• Convert given facts into FOL.
• Convert FOL to CNF (Conjunctive/closed Normal Form)
Question : • Resolve using a Resolution Tree /Graph (Unification)
Prove the following statement using Resolution:
Ravi likes Peanuts Step 1: Negate the statement to be proved after converting it to FOL
Ravi likes Peanuts

Facts given: FOL: likes (Ravi , Peanuts)


1. Ravi likes all kinds of food.
2. Apple and chicken are food Negate: ̚ likes (Ravi , Peanuts)

3. Anything anyone eats and is not killed is food.


4. Raj eats peanuts and is still alive. Step 2: Convert given facts into FOL.

RESOLUTION IN PREDICATE LOGIC RESOLUTION IN PREDICATE LOGIC


Step 2: Convert given facts into FOL. Step 3: Convert FOL to CNF (Conjunctive/closed Normal Form)

Rules required:
1. Ravi likes all kinds of food. 1. Eliminate  &
FOL: x: food(x)  likes (ravi,x) if for example:
A  B then it must be represented as ̚ A v B
2. Apple and chicken are food
FOL: food (apple) food(chicken) A B then it must be represented as A  B ˄ B  A
y x
2. Move negation ̚ inward
3. Anything anyone eats and is not killed is food.
FOL: x y: eats (x,y) ˄ ̚ killed (x)  food (y) Example:
i. ̚ ( x p) = Ǝ x ̚ p
4. raj eats peanuts and is still alive. ii. ̚ (Ǝ x p) = x ̚ p
FOL: eats(Raj,peanuts) ˄ alive (Raj)
iii. ̚ (a ˅ b) = ̚ a ˄ ̚ b

iv. ̚ (a ˄ b) = ̚ a ˅ ̚ b

v. ̚ ̚ a = a

RESOLUTION IN PREDICATE LOGIC RESOLUTION IN PREDICATE LOGIC


Step 3: Convert FOL into CNF
3. Rename Variables

4. Replace Existential quantifiers by skolem constant.


1. Ravi likes all kinds of food.
FOL: x: food(x)  likes (ravi,x)
Ex. Ǝ x Rich (x) == Rich (G1)
CNF: ̚ food (x) ˅ likes (Ravi,x)
5. Drop Universal Quantifier
2. Apple and chicken are food
Applying these rules FOL will get converted into CNF
FOL: food (apple) food(chicken)
CNF: food (apple) food(chicken)

y x
3. Anything anyone eats and is not killed is food.
FOL: x y: eats (x,y) ˄ ̚ killed (x)  food (y)

CNF: ̚ [eats (x,y) ˄ ̚ killed (x) ] ˅ food (y)

̚ eats (x,y) ˅ ̚ ̚ killed(x) ˅ food (y)

̚ eats (x,y) ˅ killed(x) ˅ food (y)

14
10/11/2021

RESOLUTION IN PREDICATE LOGIC RESOLUTION IN PREDICATE LOGIC


Step 3: Convert FOL into CNF Step 4:CNF into resolution graph

Drawn CNF:
1. ̚ food (x) ˅ likes (Ravi,x)
4. Raj eats peanuts and is still alive.
FOL: eats(Raj,peanuts) ˄ alive (Raj) 2. ̚ eats (x,y) ˅ killed(x) ˅ food (y)
CNF: eats (Raj, peanuts) ˄ alive (Raj)
3. eats (Raj,peanuts) / alive (Raj)
5. X : ¬ killed (x)  alive (x)
4. killed (x) v ̚ alive(x)
¬ ¬ killed (x) v ¬ alive(x)
5. ¬ alive (x) v killed(x)
killed (x) v ¬ alive(x)

X : alive (x)  ¬ killed(x)

¬ alive (x) v ¬ ¬ killed(x)


¬ alive (x) v killed(x)

RESOLUTION EXAMPLE
RESOLUTION IN PREDICATE LOGIC
¬ likes (Ravi, Peanuts)
 John likes all kind of food.
X / peanuts 1. ¬ food (x) ˅ likes (Ravi,x)
 Apple and vegetable are food
¬ food (peanuts)
 Anything anyone eats and not killed is food.
y / peanuts 2. ¬ eats (x,y) ˅ killed(x) ˅ food (y)  Anil eats peanuts and still alive

 Harry eats everything that Anil eats.


¬ eats (x,peanuts) ˅ killed(x)

x / Raj 3. eats (ajay,peanuts)

killed(ajay) Prove by resolution that:


5. ¬ alive (x) v killed(x)
John likes peanuts.
x / Raj

¬ alive (x)
6. alive (Raj) 88
x / Ravi
Ø

RESOLUTION EXAMPLE SOLUTION RESOLUTION EXAMPLE SOLUTION CONTD

Step1: Convert to FOL Step2 : convert FOL to CNF


 John likes all kind of food. a) Eliminate all implication (→) and rewrite
∀x : food(x) -> likes(john, x)  ∀x ¬ food (x) V likes(John, x)
 Apple and vegetable are food
food(Apple) Λ food(vegetables)

food(apple) ^ food(vegetables)
 ∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)
 Anything anyone eats and not killed is food.
eats (Anil, Peanuts) Λ alive(Anil)
∀x ∀ y : eats(x,y) ^ ¬ killed(x) -> food(y)  ∀x ¬ eats(Anil, x) V eats(Harry, x)
 Anil eats peanuts and still alive  ∀x¬ [¬ killed(x) ] V alive(x)
peanuts(anil, peanuts) ^ alive(anil)  ∀x ¬ alive(x) V ¬ killed(x)
 Harry eats everything that Anil eats.  likes(John, Peanuts).
∀x : eats(anil,x) -> eats(harry,x)
89 90

15
10/11/2021

SEMANTIC NETWORKS SEMANTIC NETWORKS


A semantic net (or semantic network) is a knowledge representation In the figure all the objects
technique used for propositional information. So it is also called a propositional are within ovals and
net. Semantic nets convey meaning. They are two dimensional representations connected using labelled
of knowledge. Mathematically a semantic net can be defined as a labelled arcs.
directed graph. there is a link
between Jill and FemalePe
Features: rsons with label MemberOf.
• Semantic nets consist of nodes, links (edges) and link labels. Simlarly there is
a MemberOf link
•In the semantic network diagram, nodes appear as circles or ellipses or between Jack and MalePer
rectangles to represent objects such as physical objects, concepts or sons and SisterOf link
situations. between Jill and Jack.
The MemberOf link
•Links appear as arrows to express the relationships between objects, and between Jill and
link labels specify particular relations. FemalePersons indicates
that Jill belongs to the
•Relationships provide the basic structure for organizing knowledge. category of female persons.
•As nodes are associated with other nodes semantic nets are also referred to
as associative nets

INHERITANCE REASONING DISADVANTAGE OF SEMANTIC NETS


It is assumed that all members of a class (category) will inherit all the One of the drawbacks of semantic network is that the links between the
properties of their superclasses. So semantic network allows us to perform objects represent only binary relations
inheritance reasoning.
For example Jill inherits the property of having two legs as she belongs to the ADVANTAGES OF SEMANTIC NETS
category of FemalePersons which in turn belongs to the category of Persons Semantic nets have the ability to represent default values for categories. In
which has a boxed Legs link with value 2 the above figure Jack has one leg while he is a person and all persons have
two legs. So persons have two legs has only default status which can be
INVERSE LINKS overridden by a specific value.
Semantic network allows a common form of inference known as inverse links. They convey some meaning in a transparent manner.
For example we can have a HasSister link which is the inverse These nets are simple and easy to understand.
of SisterOf link.
The inverse links make the job of inference algorithms much easier to answer
queries such as who the sister of Jack is? . On discovering that HasSister is
the inverse of SisterOf the inference algorithm can follow that link HasSister
from Jack to Jill and answer the query.

SEMANTIC NETWORKS
FRAMES REPRESENTATION
The representation of knowledge in the form of graphical A frame is an artificial intelligence data structure used to divide knowledge into
networks. substructures by representing generalised situations

Ex. Each piece of information about a particular frame is held in a slot.


Tom is a cat The information can contain:
Tom is grey in color Facts or Data
Tom is mammal
Values (called facets)
Tom is owned by sam
Procedures (also called procedural attachments)
IF-NEEDED : deferred evaluation
Mammal
IF-ADDED : updates linked information
Sam Default Values
Is a
For Data
Cat Is a Owned by For Procedures
Tom Other Frames or Subframes

Grey Color is

16
10/11/2021

FRAMES REPRESENTATION
Worth noticing here is the easy analogical reasoning (comparison) that can be
done between a boy and a monkey just by having similarly named slots.
Also notice that Alex, an instance of a boy, inherits default values like "Sex" from
the more general parent object Boy, but the boy may also have different instance
values in the form of exceptions such as the number of legs.

FRAMES REPRESENTATION
 Frames are record like structures that consists of a
collection of slots or attributes and the corresponding slot
values.
 Slots have names and values called as facets or fillers.

 Ex 1:

 (ABC)

 (Profession (Value Engineer))

 (Age (Value 25))

 (City (Value Surat))

 (State (Value Gujrat))

17

You might also like