SlideShare a Scribd company logo
19CS308T: Artificial Intelligence
UNIT-III
KNOWLEDGE REPRESENTATION
Faculty:Mr.K.Sundar
Syllabus
• First Order Predicate Logic – Prolog
Programming – Unification – Forward
Chaining-Backward Chaining –
Resolution – Knowledge Representation
– Ontological Engineering-Categories
and Objects – Events – Mental Events
and Mental Objects – Reasoning
Systems for Categories – Reasoning with
Default Information.
• Case study : Sets, King Domain,
FIRST ORDER
PREDICATE
CALCULUS
1
2
KNOWLEDGE REPRESENTATION
□Symbolic logic
□Power of representation
□Formal language: syntax, semantics
□Conceptualization + representation in a
language
□Inference rules
PROPOSITIONAL
LOGIC
⚫Repesented in Formal language
Syntax
□ A well-formed formula (wff) in propositional
logic is:
(1)An atom is a wff
(2)If P is a wff, then ~P is a wff.
(3)If P and Q are wffs then P∧Q, P∨Q, P→Q &
P↔Q are wffs.
(4)The set of all wffs can be generated by
repeatedly applying rules (1)..(3).
3
4
PROPOSITIONAL LOGIC: SYNTAX
□Propositional logic is the simplest logic
□The proposition symbols S1, S2 etc are sentences
⚫If S is a sentence, ¬S is a sentence (negation)
⚫If S1 and S2 are sentences, S1 ∧ S2 is a sentence (conjunction)
⚫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 S1 and S2 are sentences, S1 ⇔ S2 is a sentence (biconditional)
PROPOSITIONAL LOGIC: SEMANTICS
Each model specifies true/false for each proposition symbol
E.g.
With these symbols, 8 possible models, can be enumerated
automatically.
Rules for evaluating truth with respect to a model m:
¬S is true iff S is false
S1 ∧ S2is true iff S1 is true and S2 is true S1 ∨
S2 is true iff S1is true or S2 is true
S1 ⇒ S2is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2 is false
1
S1 ⇔ S2 is true iff S ⇒S2 is true and
2
5
6
TRUTH TABLES FOR CONNECTIVES
LOGICAL EQUIVALENCE
• □ Two sentences are logically equivalent} iff true in same models
• : α ≡ ß iff α╞ β and β╞ α
VALIDITY AND SATISFIABILITY
7
A sentence is valid if it is true in all
models,
e.g., True, A ∨¬A, A ⇒ A, (A ∧ (A ⇒
B)) ⇒ B
Validity is connected to inference via the
Deduction Theorem:
KB ╞ α if and only if (KB ⇒ α) is valid
A sentence is satisfiable if it is true in some model
e.g., A∨ B, C
A sentence is unsatisfiable if it is true in no models
e.g., A∧¬A
Satisfiability is connected to inference via the
following:
KB ╞ α if and only if (KB ∧¬α) is unsatisfiable
8
INFERENCE RULES
□ Modus Ponens
□ Chain rule
□ AND introduction
□ Transposition
9
Soundness of resolution inference rule:
li ∨… ∨ lk, m1 ∨ … ∨ mn
li ∨ … ∨ li-1 ∨ li+1 ∨ … ∨ lk ∨ m1 ∨ … ∨ mj-1 ∨
mj+1
∨... ∨ mn
li, mi – contradictory
10
RESOLUTION
CNF, DNF
□Conjunctive normal form (CNF)
F1 … ∧Fn,
∧Fi , i=1,n
□Disjunctive normal form (DNF)
F1 ∨ … ∨Fn, Fi , i=1,n
11
CONVERSION TO CLAUSE FORM
1.Convert all the propositions of KB to clause form
(S).
2.Negate α and convert it to clause form. Add it to S.
3.Repeat until either a contradiction is found or no
progress can be made.
a. Select two clauses (α ∨ ¬P) and ( γ ∨ P).
b. Add the resolvent (α ∨ γ) to S.
12
WUMPUS WORLD
13
❖We must explore a cave consisting of rooms
connected by passageways.
❖Lurking somewhere in the cave is a beast (the
wumpus) that eats anyone who enters his room.
❖Some rooms contain bottomless pits, but another
contains gold.
14
1
5
16
CONVERSION TO CNF
• B1,1 ⇔ (P1,2 ∨ P2,1)
1. Eliminate ⇔, replacing α ⇔ β with (α ⇒ β)∧(β ⇒ α).
• (B1,1 ⇒ (P1,2 ∨ P2,1)) ∧ ((P1,2 ∨ P2,1) ⇒ B1,1)
2. Eliminate ⇒, replacing α ⇒ β with ¬α∨ β.
• (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ (¬(P1,2 ∨ P2,1) ∨ B1,1)
3. Move ¬ inwards using de Morgan's rules and double-negation:
• (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ ((¬P1,2 ∧ ¬P2,1) ∨ B1,1)
4. Apply distributive law (∧ over ∨) and flatten:
• (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ (¬P1,2 ∨ B1,1) ∧ (¬P2,1 ∨ B1,1)
17
PROS AND CONS OF PROPOSITIONAL
LOGIC
☺ Propositional logic is declarative
⚫Propositional logic allows
⚫partial/disjunctive/negated information
☺ Meaning in propositional logic is context-
Independent
⚫(unlike natural language, where meaning
depends on context)
☹ Propositional logic has very limited expressive
Power
⚫(unlike natural language)
18
□Whereas propositional logic assumes the world contains facts,
□first-order logic (like natural language) assumes the world contains
⚫Objects: people, houses, numbers, colors, baseball games, wars, …
⚫Relations: round, prime, brother of, bigger than, part of, comes between,
…
⚫Functions: Gt(), Lt(), Age=Curr-DOB…
20
FIRST ORDER PREDICATE LOGIC
• It has three more logical notions as compared to PL.
• – Terms, Predicates and Quantifiers
● Term
–a constant (single individual or concept i.e.,5, john etc.),
–a variable that stands for different individuals
–n-place function f(t1, …, tn) where t1, …, tn are terms.
–A function is a mapping that maps n terms to a term.
● Predicate
–a relation that maps n terms to a truth value true (T) or false (F).
● Quantifiers
–Universal or existential quantifiers i.e. ∀ and ∃ used in
–conjunction with variables.
• 19
PREDICATE LOGIC
UNIVERSAL QUANTIFICATION
□∀x P(x)
□Example: “Everyone at UNC is smart”
∀x At(x,UNC) ⇒ Smart(x)
□Roughly speaking, equivalent to the conjunction of
all possible instantiations of the variable:
At(John, UNC) ⇒ Smart(John) ∧ ...
At(Richard,UNC) ⇒ Smart(Richard) ∧ ...
□∀x P(x) is true in a model m iff P(x) is true with x
being each possible object in the model
21
22
EXISTENTIAL QUANTIFICATION
□ ∃x P(x)
□ Example: “Someone at UNC is smart”
• ∃x At(x,UNC) ∧ Smart(x)
□ Roughly speaking, equivalent to the disjunction of all possible instantiations:
• [At(John,UNC) ∧ Smart(John)] ∨
• [At(Richard,UNC) ∧ Smart(Richard)] ∨ …
□ ∃x P(x) is true in a model m iff P(x) is true with x being some possible
object in the model
PROPERTIES OF QUANTIFIERS
□∀x ∀y is the same as ∀y ∀x
□∃x ∃y is the same as ∃y ∃x
□∃x ∀y is not the same as ∀y ∃x
“There is a person who loves everyone”
∃x ∀y Loves(x,y)
“Everyone is loved by at least one person”
∀y ∃x Loves(x,y)
□Quantifier duality: each quantifier can be
expressed using the other with the help of negation
∀x Likes(x,IceCream) ¬∃x ¬Likes(x,IceCream)
∃x Likes(x,Broccoli) ¬∀x ¬Likes(x,Broccoli)
23
24
EQUIVALENCE OF QUANTIFIERS
SUBSTITUTION
□ Substitution of variables by ground terms:
• SUBST({g/v},P)
⚫ Result of SUBST({Harry/x, Sally/y}, Loves(x,y)):
Loves(Harry,Sally)
⚫ Result of SUBST({John/x}, King(x) ∧ Greedy(x) ⇒
Evil(x)): King(John) ∧ Greedy(John) ⇒ Evil(John)
INFERENCE RULES
▪ Modus Ponens
▪Substitution
▪Chaining
▪Transposition
▪AND elimination (AE)
▪ AND introduction (AI)
▪ Universal Instantiation (UI)
▪ Existential Instantiation (EI)
▪ Resolution
25
26
GENERALIZED MODUS PONENS (GMP)
p1', p2', … , pn', ( p1 ∧ p2 ∧ … ∧ pn ⇒q)
Subst(θ,q)
where pi'θ = pi θ for all i
□GMP used with KB of definite clauses (positive literal)
□All variables assumed universally quantified
27
28
UNIVERSAL INSTANTIATION (UI)
• □ A universally quantified sentence entails every instantiation
of it:
∀v P(v)
SUBST({g/v}, P(v))
• for any variable v and ground term g
□ E.g., ∀x King(x) ∧ Greedy(x) ⇒ Evil(x) yields:
King(John) ∧ Greedy(John) ⇒ Evil(John)
King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard)
King(Father(John)) ∧ Greedy(Father(John)) ⇒
Evil(Father(John))
EXISTENTIAL INSTANTIATION (EI)
□An existentially quantified sentence entails the
instantiation of that sentence with a new constant:
∃v P(v)
SUBST({C/v}, P(v))
for any sentence P, variable v, and constant C that
does not appear elsewhere in the knowledge base
□E.g., ∃x Crown(x) ∧ OnHead(x,John) yields:
Crown(C1) ∧ OnHead(C1,John)
provided C1 is a new constant symbol, called a Skolem
constant
29
SUBST(θ,q) is Evil(John) 30
GENERALIZED MODUS PONENS (GMP)
• p1', p2', … , pn', (p1 ∧ p2 ∧ … ∧ pn ⇒q)
• such that SUBST(θ, pi')= SUBST(θ, pi) for all I
• SUBST(θ,q)
Used with definite clauses (exactly one positive literal)
□ All variables assumed universally quantified
□ Example:
• p1' is King(John) p1 is King(x) p2' is Greedy(y) p2
is Greedy(x) θ is {x/John,y/John}
• q is Evil(x)
EXAMPLE KNOWLEDGE
BASE
□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 Colonel West,
who is American.
□Prove that Col. West is a criminal
31
32
EXAMPLE KNOWLEDGE BASE
• It is a crime for an American to sell weapons to hostile nations:
• ∀ x ∀ y ∀ z American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧
Hostile(z) ⇒ Criminal(x)
• Nono has some missiles
• ∃y Owns(Nono,y) ∧ Missile(y) Owns(Nono,M1) Missile(M1)
• All of its missiles were sold to it by Colonel West
• ∀y Missile(y) ∧ Owns(Nono,y) ⇒ Sells(West,y,Nono) Missile(M1) ∧ Owns(Nono, M1) ⇒
• Sells(West, M1,Nono)
• West is American
• American(West)
• The country Nono is an enemy of America
Enemy(Nono,America)
General KW
Missiles are weapons:
• ∀y Missile(y) ⇒ Weapon(y) Missile(M1) ⇒
• Weapon(M1)
• An enemy of America counts as “hostile”:
• ∀z Enemy(z,America) ⇒ Hostile(z) Enemy(Nono,America) ⇒ Hostile(Nono)
USING PREDICATE LOGIC
1.
8.
1.Marcus was a man.
2.Marcus was a Pompeian.
3.All Pompeians were Romans.
4.Caesar was a ruler.
5.All Pompeians were either loyal to Caesar or
hated him.
6.Every one is loyal to someone.
7.People only try to assassinate rulers they are not
loyal to. Marcus tried to assassinate Caesar.
33
34
1.
1.Marcus was a man. man(Marcus)
2.Marcus was a Pompeian. Pompeian(Marcus)
3.All Pompeians were Romans.
∀x: Pompeian(x) → Roman(x)
4.Caesar was a ruler. ruler(Caesar)
5.All Pompeians were either loyal to Caesar or hated him. inclusive-or
∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar)
exclusive-or
∀x: Roman(x) → (loyalto(x, Caesar) ∧ ¬hate(x, Caesar)) ∨(¬loyalto(x, Caesar) ∧
hate(x, Caesar))
USING PREDICATE LOGIC
USING PREDICATE LOGIC
6. Every one is loyal to someone.
∀x: ∃y: loyalto(x, y) ∃y: ∀x: loyalto(x, y)
39
7.
7.People only try to assassinate rulers they are not
loyal to.
40
∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y)
→ ¬loyalto(x, y)
8.Marcus tried to assassinate Caesar.
tryassassinate(Marcus, Caesar)
Was Marcus loyal to Caesar?
man(Marcus) ruler(Caesar)tryassassinate(Marcus, Caesar)
⇓
∀x: man(x) → person(x)
¬loyalto(Marcus, Caesar)
RESOLUTION REFUTATION IN PREDICATE
LOGIC
●Resolution method is used to test unsatisfiability of
a set S of clauses in Predicate Logic.
●It is an extension of resolution method for PL.
●The resolution principle basically checks whether
empty clause is contained or derived from S.
●Resolution for the clauses containing no variables
is very simple and is similar to PL.
●It becomes complicated when clauses contain variables.
●In such case, two complementary literals are resolved after
proper substitutions so that both the literals have same
arguments.
RESOLUTION
The basic ideas
KB |= α ⇔
KB ∧ ¬α |= false
(α ∨ ¬β) ∧ ( γ ∨ β) ⇒ (α ∨ γ)
47
RESOLUTION: FOL VERSION
p1 ∨ ··· ∨ pk, q1 ∨ ··· ∨ qn
such that
UNIFY(pi, ¬qj) = θ
SUBST(θ, p1 ∨ ··· ∨ pi-1 ∨ pi+1 ∨ ··· ∨ pk ∨ q1 ∨ ··· ∨ qj-1 ∨ qj+1 ∨ ···
∨ qn)
□ Apply resolution steps to CNF(KB ∧ ¬α); complete for
FOL
48
CONVERSION TO CLAUSE FORM
4.
5.
6.
7.
8.
9.
1.Eliminate →.
2.Reduce the scope of each ¬ to a single term.
3. Standardize variables so that each quantifier binds a
unique variable. 4.Move all quantifiers to the left
without changing their relative order. 5.Eliminate ∃
(Skolemization).
6.Drop ∀.
7.Convert the formula into a conjunction of disjuncts.
Create a separate clause corresponding to each
conjunct.
8.Standardize apart the variables in the set of obtained
clauses.
49
50
1.
2.
3.
CONVERSION TO CLAUSE FORM
• Eliminate →.
P → Q ≡ ¬P ∨ Q
• Reduce the scope of each ¬ to a single term.
¬(P ∨ Q) ≡ ¬P ∧ ¬Q
¬(P ∧ Q) ≡ ¬P ∨ ¬Q
¬∀x: P ≡ ∃x: ¬P
¬∃x: p ≡ ∀x: ¬P
¬¬ P ≡ P
• Standardize variables so that each quantifier binds a unique variable
• (∀x: P(x)) ∨ (∃x: Q(x)) ≡ (∀x: P(x)) ∨ (∃y: Q(y))
CONVERSION TO CLAUSE FORM
4.
Move all quantifiers to the left without changing their
relative order.
(∀x: P(x)) ∨ (∃y: Q(y)) ≡ ∀x: ∃y: (P(x) ∨ (Q(y))
Eliminate ∃ (Skolemization).
5.
∃x: P(x) ≡ P(c)
Skolem constant
∀x: ∃y P(x, y) ≡ ∀x:
P(x, f(x))
Skolem function
6.
7.
Drop ∀.
∀x: P(x) ≡ P(x)
Convert the formula into a conjunction of disjuncts.
(P ∧ Q) ∨ R ≡ (P ∨ R) ∧ (Q ∨ R)
8.Create a separate clause corresponding to each conjunct.
9.Standardize apart the variables in the set of obtained
clauses. 52
EXAMPLE KNOWLEDGE BASE CONTD.
..
. it is a crime for an American to sell weapons to hostile nations:
American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x)
¬(American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧
Hostile(z) ) ∨ Criminal(x)
¬American(x) ∨ ¬ Weapon(y) ∨ ¬ Sells(x,y,z) ∨ ¬ Hostile(z) )∨ Criminal(x)
Nono … has some missiles, i.e., ∃x Owns(Nono,x) ∧ Missile(x):
Owns(Nono,M1) ∧ Missile(M1)
Owns(Nono,M1) , Missile(M1)
… all of its missiles were sold to it by Colonel West
Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
¬(Missile(x) ∧ Owns(Nono,x) )∨ Sells(West,x,Nono)
¬Missile(x) ∨ ¬ Owns(Nono,x) ∨ Sells(West,x,Nono)
Missiles are weapons:
¬ Missile(x) ∨ Weapon(x)
An enemy of America counts as "hostile“:
Enemy(x,America) ⇒ Hostile(x)
¬Enemy(x,America) ∨ Hostile(x)
53
54
RESOLUTION PROOF
EXAMPLE
1.
8.
1. Marcus was a man.
2.Marcus was a Pompeian.
3.All Pompeians were Romans.
4.Caesar was a ruler.
5.All Pompeians were either loyal to Caesar or
hated him.
6.Every one is loyal to someone.
7.People only try to assassinate rulers they are
not loyal to. Marcus tried to assassinate Caesar.
55
56
6.
7.
EXAMPLE
1. Man(Marcus).
2. Pompeian(Marcus).
3. ∀x: Pompeian(x) → Roman(x).
4. ruler(Caesar).
5.∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar).
6.∀x: ∃y: loyalto(x, y).
7.∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y)
→ ¬loyalto(x, y).
8. tryassassinate(Marcus, Caesar).
EXAMPLE
Prove:
hate(Marcus, Caesar)
Using Resolution
Proof by Contradiction 57
58
5
9
60
• Unification:
• UNIFY(p, q) = unifier θ where SUBST(θ, p)
= SUBST(θ, q)
RESOLUTION IN PREDICATE LOGIC
RESOLUTION IN PREDICATE LOGIC
Unification:
∀x: knows(John, x) → hates(John, x) knows(John, Jane)
∀y: knows(y, Leonid)
∀y: knows(y, mother(y))
∀x: knows(x, Elizabeth)
UNIFY(knows(John, x), knows(John, Jane)) = {Jane/x} UNIFY(knows(John, x),
knows(y, Leonid)) = {Leonid/x, John/y}
UNIFY(knows(John, x), knows(y, mother(y))) =
{John/y, mother(John)/x} UNIFY(knows(John, x), knows(x, Elizabeth)) = FAIL
61
RESOLUTION IN PREDICATE LOGIC
Unification: Most general unifier
UNIFY(knows(John, x), knows(y, z)) =
{John/y, John/x, John/z}
= {John/y, Jane/x, Jane/z}
= {John/y, v/x, v/z}
62
CHAINING
□To predict outcomes using the given pool of knowledge.
□Knowledge base is given and using logical rules and reasoning, one has
to predict the outcome.
□These problems are usually solved using Inference Engines,
□Utilize their two special modes:
I. Forward Chaining
II. Backward Chaining
63
FORWARD CHAINING
□Step 1: Start from the already stated facts, and then,
subsequently choose the facts that do not have any
implications at all.
□Step 2: Now, those facts that can be inferred from available
facts with satisfied premises.
□Step 3: In step 3, check the given statement that needs to be
checked and check whether it is satisfied with the substitution
which infers all the previously stated facts. Thus we reach our goal.
64
6
5
FORWARD CHAINING EXAMPLE
66
FORWARD CHAINING
67
FORWARD CHAINING
68
BACKWARD CHAINING
□Step 1. In the first step, take the Goal Fact and from
the goal fact, we’ll derive other facts that we’ll prove
true.
□Step 2: derive other facts from goal facts that satisfy
the rules
□Step 3: At step-3, extract further fact which infers
from facts inferred in step 2.
□Step 4: Repeat the same until we get to a certain fact
that satisfies the conditions.
69
70
BACKWARD CHAINING
71
BACKWARD CHAINING
72
BACKWARD CHAINING
73
74
BACKWARD CHAINING
BACKWARD CHAINING
75
S.no Forward Chaining Backward Chaining
1 Forward chaining starts from
known facts and applies inference
rule to extract more data unit it
reaches to the goal.
Backward chaining starts from the goal and
works backward through inference rules to
find the required facts that support the goal.
2 It is a bottom-up approach It is a top-down approach
3 Forward chaining is known as
data-driven inference technique as
we reach to the goal using the
available data.
Backward chaining is known as goal-driven
technique as we start from the goal and
divide into sub-goal to extract the facts.
4 Forward chaining reasoning
applies a breadth-first search
strategy.
Backward chaining reasoning applies a
depth-first search strategy.
5 Forward chaining tests for all the
available rules
Backward chaining only tests for few
required rules.
6 Forward chaining is suitable for the
planning, monitoring, control, and
interpretation application.
Backward chaining is suitable for diagnostic,
prescription, and debugging application.
7 Forward chaining can generate an
infinite number of possible
conclusions.
Backward chaining generates a finite number
of possible conclusions.
8 Forward chaining is aimed for any
conclusion.
Backward chaining is only aimed for the
required data.
LOGIC PROGRAMMING
∙ Logic programming is based on FOPL.
∙ Clause in logic programming is special
form of formula.
∙ Program in logic programming is a collection of
clauses.
∙ Queries are solved using resolution principle.
∙ A clause in logic programming is represented in a
clausal notation as
A1, …, Ak ← B1,…, Bt ,
where Aj are positive literals and Bk are negative literals.
77
78
FOPL
LOGIC PROGRAMMING - PROLOG
• Prolog is a declarative programming language based on
logic.
• A Prolog program is a list of facts.
• There are various predicates and functions
• supplied to support I/O, graphics, etc.
• Instead of CNF, prolog uses an implicative
• normal form: A Ù B Ù ... Ù C Þ D
79
80
PROLOG
:
□Only Horn sentences are acceptable
□The occur-check is omitted from the unification:
unsound
test ← P(x, x) P(x, f(x))
□Backward chaining with depth-first search:
incomplete
P(x, y) ← Q(x, y) P(x, x)
Q(x, y) ← Q(y, x)
81
82
Special case: Horn clauses
• Horn clauses are implications with only positive literals
• x1 AND x2 AND x4 => x3 AND x6
• TRUE => x1
• Try to figure out whether some xj is entailed
• Simply follow the implications (modus ponens) as far as you
can, see if you can reach xj
• xj is entailed if and only if it can be reached (can set
everything that is not reached to false)
• Can implement this more efficiently by maintaining, for each
implication, a count of how many of the left-hand side
variables have been reached
Ontological Engineering
• What is Ontological Engineering?
Ontology refers to organizing everything in the world (complex
domain) into hierarchy of categories. Representing the abstract
concepts such as Actions,Time,Physical Objects,and Beliefs
with respect to complex domains such as shopping on the
internet or controlling a robot in a changing environment is
called Ontological
CATEGORIES AND OBJECTS
The organization of objects into categories is a vital part of
knowledge representation. Although interaction with the world
takes place at the level of individual objects, much reasoning takes
place at the level of categories.
Categories play a role in predictions about objects
• Based on perceived properties
•Categories can be represented in two ways by
• first-order logid (FOL)
• Predicates: apple(x)
• Reification of categories into objects: apples
•Category is considered as set of its
members(Relation=Inheritance).
• For eg: All instance of food are edible, fruit is a subclass
offood and apples is a subclass of fruit then an apple is edible.
•
Actions, Situations, and Events
Actions are logical terms such as Forward and Turn (Right). F
now, we will assume that the environment contains only on
agent. (If there is more than one, an additional argument can b
inserted to say which agent is doing the action.)
Situations are logical terms consisting of the initial situation
(usually called So) and all situations that are generated by
applying an action to a situation. The function Result(a, s)
(sometimes called Do) names the situation that results when
action a is executed in situation s. Figure 10.2 illustrates this
idea.
Unit III  Knowledge Representation in AI   K.Sundar,AP/CSE,VEC
Agent can now reason about the beliefs of agents.
Turning a proposition into an object is called reification.
Technically, the property of being able to substitute a term
freely for an equal term is
called referential transparency.
There are two ways to achieve this.
O The first is to use a different form of logic called modal
logic, in which propositional
attitudes such as Believes and Knows become modal operators
that are referentially
opaque. This approach is covered in the historical notes
section.
Knowledge and belief
The relation between believing and knowing has been
studied extensively in philosophy. It is commonly
said that knowledge is justified true belief
.Knowledge, time, and action Actions can have
knowledge preconditions and knowledge effects.
Plans to gather and use information are often
represented using a shorthand notation called runtime
variables, Plans to gather and use information are
often represented using a shorthand notation called
runtime variables.
Reasoning Systems for Categories
 Semantic networks
 Visualize knowledge-base
 Efficient algorithms for category membership
inference
 Description logics
 Formal language for constructing and
combining category definitions
 Efficient algorithms to decide subset and
superset relationships between categories.
Semantic Networks
• Semantic networks are capable of
representing individual objects,categories
of objects,and relation among objects.
Objects or Category names are
represented in ovals and are connected
by labeled arcs.
• Semantic network example
Unit III  Knowledge Representation in AI   K.Sundar,AP/CSE,VEC
Default reasoning
This is a very common form of non-monotonic
reasoning. Here We want to draw conclusions
based on what is most likely to be true.
Non-Monotonic logic.
Default logic
This is basically an extension of first-order predicate
logic to include a modal operator, M. The purpose of this
is to allow for consistency.
For example: : plays_instrument(x) (and) improvises(x)
→ jazz_musician(x)
states that for all x is x plays an instrument and if the fact
that x can improvise is consistent with all other knowledge
then we can conclude that x is a jazz musician.
Truth Maintenance Systems
(TMS)
Many inferences have default status rather
than being absolutely certain.
• Inferred facts can be wrong and need to
be retracted (new info) and it is called as
belief revision.
Types of TMS
1)Justification-Based Truth Maintenance Systems (JTMS)
▪This is a simple TMS in that it does not know anything about
the structure of the assertions themselves.
▪Each supported belief (assertion) in has a justification.
▪Each justification has two parts:
An IN-List -- which supports beliefs held.
An OUT-List -- which supports beliefs not held.
▪An assertion is connected to its justification by an arrow.One
assertion can
feed another justification thus creating the network.Assertions may
be labelled with a belief status.
Fig: A JTMS Assertion
2)Logic-Based Truth Maintenance Systems (LTMS)
Similar to JTMS except:
 Nodes (assertions) assume no relationships among them except ones
explicitly stated in justifications.
 JTMS can represent P and ¬P simultaneously. An LTMS would throw a
contradiction here.
 If this happens network has to be reconstructed.
3)Assumption-Based Truth Maintenance Systems (ATMS)
 JTMS and LTMS pursue a single line of reasoning at a time and backtrack
(dependency- directed) when needed -- depth first search.
 ATMS maintain alternative paths in parallel -- breadth-first search
 Backtracking is avoided at the expense of maintaining multiple contexts.

More Related Content

PPTX
Artificial Intelligence Notes Unit 3
PPTX
Semantic net in AI
PPT
INTRODUCTION TO LISP
PDF
Functions and modules in python
PPTX
Advanced topics in artificial neural networks
PPTX
Java program structure
PPTX
knowledge representation using rules
PPTX
Convolutional Neural Networks
Artificial Intelligence Notes Unit 3
Semantic net in AI
INTRODUCTION TO LISP
Functions and modules in python
Advanced topics in artificial neural networks
Java program structure
knowledge representation using rules
Convolutional Neural Networks

What's hot (20)

PPTX
Scalar expressions and control structures in perl
PPTX
Analysis and Design of Algorithms
PPTX
Polymorphism in c++(ppt)
PPTX
Pointers in C Programming
PPTX
List in Python
PPTX
Recurrent Neural Network
PPTX
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
PDF
Python functions
PPT
Classical Planning
PPT
screen output and keyboard input in js
PPTX
Set data structure
PDF
Algorithms and how to write an algorithms
PPTX
Design and Analysis of Algorithms.pptx
PPTX
Nested loops
PPTX
PUSH DOWN AUTOMATA VS TURING MACHINE
PPTX
Feedforward neural network
PPTX
PPTX
Looping statements in C
PPT
Chapter 5 Syntax Directed Translation
PPTX
State space search
Scalar expressions and control structures in perl
Analysis and Design of Algorithms
Polymorphism in c++(ppt)
Pointers in C Programming
List in Python
Recurrent Neural Network
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Python functions
Classical Planning
screen output and keyboard input in js
Set data structure
Algorithms and how to write an algorithms
Design and Analysis of Algorithms.pptx
Nested loops
PUSH DOWN AUTOMATA VS TURING MACHINE
Feedforward neural network
Looping statements in C
Chapter 5 Syntax Directed Translation
State space search
Ad

Similar to Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC (20)

PPT
L03 ai - knowledge representation using logic
PPT
Propositional And First-Order Logic
PPTX
P, NP and NP-Complete, Theory of NP-Completeness V2
PPT
Logic agent
PDF
PPT
9.class-notesr9.ppt
PPTX
Unit 1-logic
PDF
Lecture 3 qualtifed rules of inference
PPTX
Discrete structures & optimization unit 1
DOCX
Algorithmic foundations.docx
PDF
unit-3.pdf SRM MATHS DISCREATE MATHS 2024
PPT
chapter9.ppt
PPT
Discrete Mathematics - All chapters
PDF
Course notes1
PPT
Discrete Math Lecture 02: First Order Logic
PDF
dma_ppt.pdf
PPTX
1004_theorem_proving_2018.pptx on the to
PPSX
Logical arguments and its computer applications.
PPT
firstorder_predicate_logic_resolution.ppt
L03 ai - knowledge representation using logic
Propositional And First-Order Logic
P, NP and NP-Complete, Theory of NP-Completeness V2
Logic agent
9.class-notesr9.ppt
Unit 1-logic
Lecture 3 qualtifed rules of inference
Discrete structures & optimization unit 1
Algorithmic foundations.docx
unit-3.pdf SRM MATHS DISCREATE MATHS 2024
chapter9.ppt
Discrete Mathematics - All chapters
Course notes1
Discrete Math Lecture 02: First Order Logic
dma_ppt.pdf
1004_theorem_proving_2018.pptx on the to
Logical arguments and its computer applications.
firstorder_predicate_logic_resolution.ppt
Ad

Recently uploaded (20)

PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
web development for engineering and engineering
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
PPT on Performance Review to get promotions
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Geodesy 1.pptx...............................................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
web development for engineering and engineering
Model Code of Practice - Construction Work - 21102022 .pdf
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
Mechanical Engineering MATERIALS Selection
Arduino robotics embedded978-1-4302-3184-4.pdf
PPT on Performance Review to get promotions
CYBER-CRIMES AND SECURITY A guide to understanding
bas. eng. economics group 4 presentation 1.pptx
Construction Project Organization Group 2.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Geodesy 1.pptx...............................................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Foundation to blockchain - A guide to Blockchain Tech
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CH1 Production IntroductoryConcepts.pptx
Structs to JSON How Go Powers REST APIs.pdf

Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC

  • 1. 19CS308T: Artificial Intelligence UNIT-III KNOWLEDGE REPRESENTATION Faculty:Mr.K.Sundar
  • 2. Syllabus • First Order Predicate Logic – Prolog Programming – Unification – Forward Chaining-Backward Chaining – Resolution – Knowledge Representation – Ontological Engineering-Categories and Objects – Events – Mental Events and Mental Objects – Reasoning Systems for Categories – Reasoning with Default Information. • Case study : Sets, King Domain,
  • 4. KNOWLEDGE REPRESENTATION □Symbolic logic □Power of representation □Formal language: syntax, semantics □Conceptualization + representation in a language □Inference rules
  • 5. PROPOSITIONAL LOGIC ⚫Repesented in Formal language Syntax □ A well-formed formula (wff) in propositional logic is: (1)An atom is a wff (2)If P is a wff, then ~P is a wff. (3)If P and Q are wffs then P∧Q, P∨Q, P→Q & P↔Q are wffs. (4)The set of all wffs can be generated by repeatedly applying rules (1)..(3). 3 4
  • 6. PROPOSITIONAL LOGIC: SYNTAX □Propositional logic is the simplest logic □The proposition symbols S1, S2 etc are sentences ⚫If S is a sentence, ¬S is a sentence (negation) ⚫If S1 and S2 are sentences, S1 ∧ S2 is a sentence (conjunction) ⚫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 S1 and S2 are sentences, S1 ⇔ S2 is a sentence (biconditional)
  • 7. PROPOSITIONAL LOGIC: SEMANTICS Each model specifies true/false for each proposition symbol E.g. With these symbols, 8 possible models, can be enumerated automatically. Rules for evaluating truth with respect to a model m: ¬S is true iff S is false S1 ∧ S2is true iff S1 is true and S2 is true S1 ∨ S2 is true iff S1is true or S2 is true S1 ⇒ S2is true iff S1 is false or S2 is true i.e., is false iff S1 is true and S2 is false 1 S1 ⇔ S2 is true iff S ⇒S2 is true and 2 5 6
  • 8. TRUTH TABLES FOR CONNECTIVES
  • 9. LOGICAL EQUIVALENCE • □ Two sentences are logically equivalent} iff true in same models • : α ≡ ß iff α╞ β and β╞ α
  • 10. VALIDITY AND SATISFIABILITY 7 A sentence is valid if it is true in all models, e.g., True, A ∨¬A, A ⇒ A, (A ∧ (A ⇒ B)) ⇒ B Validity is connected to inference via the Deduction Theorem: KB ╞ α if and only if (KB ⇒ α) is valid A sentence is satisfiable if it is true in some model e.g., A∨ B, C A sentence is unsatisfiable if it is true in no models e.g., A∧¬A Satisfiability is connected to inference via the following: KB ╞ α if and only if (KB ∧¬α) is unsatisfiable 8
  • 11. INFERENCE RULES □ Modus Ponens □ Chain rule □ AND introduction □ Transposition
  • 12. 9 Soundness of resolution inference rule: li ∨… ∨ lk, m1 ∨ … ∨ mn li ∨ … ∨ li-1 ∨ li+1 ∨ … ∨ lk ∨ m1 ∨ … ∨ mj-1 ∨ mj+1 ∨... ∨ mn li, mi – contradictory 10 RESOLUTION
  • 13. CNF, DNF □Conjunctive normal form (CNF) F1 … ∧Fn, ∧Fi , i=1,n □Disjunctive normal form (DNF) F1 ∨ … ∨Fn, Fi , i=1,n 11 CONVERSION TO CLAUSE FORM 1.Convert all the propositions of KB to clause form (S). 2.Negate α and convert it to clause form. Add it to S. 3.Repeat until either a contradiction is found or no progress can be made. a. Select two clauses (α ∨ ¬P) and ( γ ∨ P). b. Add the resolvent (α ∨ γ) to S. 12
  • 14. WUMPUS WORLD 13 ❖We must explore a cave consisting of rooms connected by passageways. ❖Lurking somewhere in the cave is a beast (the wumpus) that eats anyone who enters his room. ❖Some rooms contain bottomless pits, but another contains gold. 14
  • 16. CONVERSION TO CNF • B1,1 ⇔ (P1,2 ∨ P2,1) 1. Eliminate ⇔, replacing α ⇔ β with (α ⇒ β)∧(β ⇒ α). • (B1,1 ⇒ (P1,2 ∨ P2,1)) ∧ ((P1,2 ∨ P2,1) ⇒ B1,1) 2. Eliminate ⇒, replacing α ⇒ β with ¬α∨ β. • (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ (¬(P1,2 ∨ P2,1) ∨ B1,1) 3. Move ¬ inwards using de Morgan's rules and double-negation: • (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ ((¬P1,2 ∧ ¬P2,1) ∨ B1,1) 4. Apply distributive law (∧ over ∨) and flatten: • (¬B1,1 ∨ P1,2 ∨ P2,1) ∧ (¬P1,2 ∨ B1,1) ∧ (¬P2,1 ∨ B1,1)
  • 17. 17 PROS AND CONS OF PROPOSITIONAL LOGIC ☺ Propositional logic is declarative ⚫Propositional logic allows ⚫partial/disjunctive/negated information ☺ Meaning in propositional logic is context- Independent ⚫(unlike natural language, where meaning depends on context) ☹ Propositional logic has very limited expressive Power ⚫(unlike natural language) 18
  • 18. □Whereas propositional logic assumes the world contains facts, □first-order logic (like natural language) assumes the world contains ⚫Objects: people, houses, numbers, colors, baseball games, wars, … ⚫Relations: round, prime, brother of, bigger than, part of, comes between, … ⚫Functions: Gt(), Lt(), Age=Curr-DOB… 20 FIRST ORDER PREDICATE LOGIC
  • 19. • It has three more logical notions as compared to PL. • – Terms, Predicates and Quantifiers ● Term –a constant (single individual or concept i.e.,5, john etc.), –a variable that stands for different individuals –n-place function f(t1, …, tn) where t1, …, tn are terms. –A function is a mapping that maps n terms to a term. ● Predicate –a relation that maps n terms to a truth value true (T) or false (F). ● Quantifiers –Universal or existential quantifiers i.e. ∀ and ∃ used in –conjunction with variables. • 19 PREDICATE LOGIC
  • 20. UNIVERSAL QUANTIFICATION □∀x P(x) □Example: “Everyone at UNC is smart” ∀x At(x,UNC) ⇒ Smart(x) □Roughly speaking, equivalent to the conjunction of all possible instantiations of the variable: At(John, UNC) ⇒ Smart(John) ∧ ... At(Richard,UNC) ⇒ Smart(Richard) ∧ ... □∀x P(x) is true in a model m iff P(x) is true with x being each possible object in the model 21 22
  • 21. EXISTENTIAL QUANTIFICATION □ ∃x P(x) □ Example: “Someone at UNC is smart” • ∃x At(x,UNC) ∧ Smart(x) □ Roughly speaking, equivalent to the disjunction of all possible instantiations: • [At(John,UNC) ∧ Smart(John)] ∨ • [At(Richard,UNC) ∧ Smart(Richard)] ∨ … □ ∃x P(x) is true in a model m iff P(x) is true with x being some possible object in the model
  • 22. PROPERTIES OF QUANTIFIERS □∀x ∀y is the same as ∀y ∀x □∃x ∃y is the same as ∃y ∃x □∃x ∀y is not the same as ∀y ∃x “There is a person who loves everyone” ∃x ∀y Loves(x,y) “Everyone is loved by at least one person” ∀y ∃x Loves(x,y) □Quantifier duality: each quantifier can be expressed using the other with the help of negation ∀x Likes(x,IceCream) ¬∃x ¬Likes(x,IceCream) ∃x Likes(x,Broccoli) ¬∀x ¬Likes(x,Broccoli) 23 24
  • 24. SUBSTITUTION □ Substitution of variables by ground terms: • SUBST({g/v},P) ⚫ Result of SUBST({Harry/x, Sally/y}, Loves(x,y)): Loves(Harry,Sally) ⚫ Result of SUBST({John/x}, King(x) ∧ Greedy(x) ⇒ Evil(x)): King(John) ∧ Greedy(John) ⇒ Evil(John)
  • 25. INFERENCE RULES ▪ Modus Ponens ▪Substitution ▪Chaining ▪Transposition ▪AND elimination (AE) ▪ AND introduction (AI) ▪ Universal Instantiation (UI) ▪ Existential Instantiation (EI) ▪ Resolution 25 26
  • 26. GENERALIZED MODUS PONENS (GMP) p1', p2', … , pn', ( p1 ∧ p2 ∧ … ∧ pn ⇒q) Subst(θ,q) where pi'θ = pi θ for all i □GMP used with KB of definite clauses (positive literal) □All variables assumed universally quantified 27 28
  • 27. UNIVERSAL INSTANTIATION (UI) • □ A universally quantified sentence entails every instantiation of it: ∀v P(v) SUBST({g/v}, P(v)) • for any variable v and ground term g □ E.g., ∀x King(x) ∧ Greedy(x) ⇒ Evil(x) yields: King(John) ∧ Greedy(John) ⇒ Evil(John) King(Richard) ∧ Greedy(Richard) ⇒ Evil(Richard) King(Father(John)) ∧ Greedy(Father(John)) ⇒ Evil(Father(John))
  • 28. EXISTENTIAL INSTANTIATION (EI) □An existentially quantified sentence entails the instantiation of that sentence with a new constant: ∃v P(v) SUBST({C/v}, P(v)) for any sentence P, variable v, and constant C that does not appear elsewhere in the knowledge base □E.g., ∃x Crown(x) ∧ OnHead(x,John) yields: Crown(C1) ∧ OnHead(C1,John) provided C1 is a new constant symbol, called a Skolem constant 29 SUBST(θ,q) is Evil(John) 30
  • 29. GENERALIZED MODUS PONENS (GMP) • p1', p2', … , pn', (p1 ∧ p2 ∧ … ∧ pn ⇒q) • such that SUBST(θ, pi')= SUBST(θ, pi) for all I • SUBST(θ,q) Used with definite clauses (exactly one positive literal) □ All variables assumed universally quantified □ Example: • p1' is King(John) p1 is King(x) p2' is Greedy(y) p2 is Greedy(x) θ is {x/John,y/John} • q is Evil(x)
  • 30. EXAMPLE KNOWLEDGE BASE □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 Colonel West, who is American. □Prove that Col. West is a criminal 31 32
  • 31. EXAMPLE KNOWLEDGE BASE • It is a crime for an American to sell weapons to hostile nations: • ∀ x ∀ y ∀ z American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x) • Nono has some missiles • ∃y Owns(Nono,y) ∧ Missile(y) Owns(Nono,M1) Missile(M1) • All of its missiles were sold to it by Colonel West • ∀y Missile(y) ∧ Owns(Nono,y) ⇒ Sells(West,y,Nono) Missile(M1) ∧ Owns(Nono, M1) ⇒ • Sells(West, M1,Nono) • West is American • American(West) • The country Nono is an enemy of America Enemy(Nono,America) General KW Missiles are weapons: • ∀y Missile(y) ⇒ Weapon(y) Missile(M1) ⇒ • Weapon(M1) • An enemy of America counts as “hostile”: • ∀z Enemy(z,America) ⇒ Hostile(z) Enemy(Nono,America) ⇒ Hostile(Nono)
  • 32. USING PREDICATE LOGIC 1. 8. 1.Marcus was a man. 2.Marcus was a Pompeian. 3.All Pompeians were Romans. 4.Caesar was a ruler. 5.All Pompeians were either loyal to Caesar or hated him. 6.Every one is loyal to someone. 7.People only try to assassinate rulers they are not loyal to. Marcus tried to assassinate Caesar. 33 34 1.
  • 33. 1.Marcus was a man. man(Marcus) 2.Marcus was a Pompeian. Pompeian(Marcus) 3.All Pompeians were Romans. ∀x: Pompeian(x) → Roman(x) 4.Caesar was a ruler. ruler(Caesar) 5.All Pompeians were either loyal to Caesar or hated him. inclusive-or ∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar) exclusive-or ∀x: Roman(x) → (loyalto(x, Caesar) ∧ ¬hate(x, Caesar)) ∨(¬loyalto(x, Caesar) ∧ hate(x, Caesar)) USING PREDICATE LOGIC
  • 34. USING PREDICATE LOGIC 6. Every one is loyal to someone. ∀x: ∃y: loyalto(x, y) ∃y: ∀x: loyalto(x, y) 39 7. 7.People only try to assassinate rulers they are not loyal to. 40 ∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y) → ¬loyalto(x, y) 8.Marcus tried to assassinate Caesar. tryassassinate(Marcus, Caesar) Was Marcus loyal to Caesar? man(Marcus) ruler(Caesar)tryassassinate(Marcus, Caesar) ⇓ ∀x: man(x) → person(x) ¬loyalto(Marcus, Caesar)
  • 35. RESOLUTION REFUTATION IN PREDICATE LOGIC ●Resolution method is used to test unsatisfiability of a set S of clauses in Predicate Logic. ●It is an extension of resolution method for PL. ●The resolution principle basically checks whether empty clause is contained or derived from S. ●Resolution for the clauses containing no variables is very simple and is similar to PL. ●It becomes complicated when clauses contain variables. ●In such case, two complementary literals are resolved after proper substitutions so that both the literals have same arguments.
  • 36. RESOLUTION The basic ideas KB |= α ⇔ KB ∧ ¬α |= false (α ∨ ¬β) ∧ ( γ ∨ β) ⇒ (α ∨ γ) 47 RESOLUTION: FOL VERSION p1 ∨ ··· ∨ pk, q1 ∨ ··· ∨ qn such that UNIFY(pi, ¬qj) = θ SUBST(θ, p1 ∨ ··· ∨ pi-1 ∨ pi+1 ∨ ··· ∨ pk ∨ q1 ∨ ··· ∨ qj-1 ∨ qj+1 ∨ ··· ∨ qn) □ Apply resolution steps to CNF(KB ∧ ¬α); complete for FOL 48
  • 37. CONVERSION TO CLAUSE FORM 4. 5. 6. 7. 8. 9. 1.Eliminate →. 2.Reduce the scope of each ¬ to a single term. 3. Standardize variables so that each quantifier binds a unique variable. 4.Move all quantifiers to the left without changing their relative order. 5.Eliminate ∃ (Skolemization). 6.Drop ∀. 7.Convert the formula into a conjunction of disjuncts. Create a separate clause corresponding to each conjunct. 8.Standardize apart the variables in the set of obtained clauses. 49 50 1. 2. 3.
  • 38. CONVERSION TO CLAUSE FORM • Eliminate →. P → Q ≡ ¬P ∨ Q • Reduce the scope of each ¬ to a single term. ¬(P ∨ Q) ≡ ¬P ∧ ¬Q ¬(P ∧ Q) ≡ ¬P ∨ ¬Q ¬∀x: P ≡ ∃x: ¬P ¬∃x: p ≡ ∀x: ¬P ¬¬ P ≡ P • Standardize variables so that each quantifier binds a unique variable • (∀x: P(x)) ∨ (∃x: Q(x)) ≡ (∀x: P(x)) ∨ (∃y: Q(y))
  • 39. CONVERSION TO CLAUSE FORM 4. Move all quantifiers to the left without changing their relative order. (∀x: P(x)) ∨ (∃y: Q(y)) ≡ ∀x: ∃y: (P(x) ∨ (Q(y)) Eliminate ∃ (Skolemization). 5. ∃x: P(x) ≡ P(c) Skolem constant ∀x: ∃y P(x, y) ≡ ∀x: P(x, f(x)) Skolem function 6. 7. Drop ∀. ∀x: P(x) ≡ P(x) Convert the formula into a conjunction of disjuncts. (P ∧ Q) ∨ R ≡ (P ∨ R) ∧ (Q ∨ R) 8.Create a separate clause corresponding to each conjunct. 9.Standardize apart the variables in the set of obtained clauses. 52
  • 40. EXAMPLE KNOWLEDGE BASE CONTD. .. . it is a crime for an American to sell weapons to hostile nations: American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x) ¬(American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ) ∨ Criminal(x) ¬American(x) ∨ ¬ Weapon(y) ∨ ¬ Sells(x,y,z) ∨ ¬ Hostile(z) )∨ Criminal(x) Nono … has some missiles, i.e., ∃x Owns(Nono,x) ∧ Missile(x): Owns(Nono,M1) ∧ Missile(M1) Owns(Nono,M1) , Missile(M1) … all of its missiles were sold to it by Colonel West Missile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono) ¬(Missile(x) ∧ Owns(Nono,x) )∨ Sells(West,x,Nono) ¬Missile(x) ∨ ¬ Owns(Nono,x) ∨ Sells(West,x,Nono) Missiles are weapons: ¬ Missile(x) ∨ Weapon(x) An enemy of America counts as "hostile“: Enemy(x,America) ⇒ Hostile(x) ¬Enemy(x,America) ∨ Hostile(x) 53 54
  • 42. EXAMPLE 1. 8. 1. Marcus was a man. 2.Marcus was a Pompeian. 3.All Pompeians were Romans. 4.Caesar was a ruler. 5.All Pompeians were either loyal to Caesar or hated him. 6.Every one is loyal to someone. 7.People only try to assassinate rulers they are not loyal to. Marcus tried to assassinate Caesar. 55 56 6. 7.
  • 43. EXAMPLE 1. Man(Marcus). 2. Pompeian(Marcus). 3. ∀x: Pompeian(x) → Roman(x). 4. ruler(Caesar). 5.∀x: Roman(x) → loyalto(x, Caesar) ∨ hate(x, Caesar). 6.∀x: ∃y: loyalto(x, y). 7.∀x: ∀y: person(x) ∧ ruler(y) ∧ tryassassinate(x, y) → ¬loyalto(x, y). 8. tryassassinate(Marcus, Caesar).
  • 46. • Unification: • UNIFY(p, q) = unifier θ where SUBST(θ, p) = SUBST(θ, q) RESOLUTION IN PREDICATE LOGIC
  • 47. RESOLUTION IN PREDICATE LOGIC Unification: ∀x: knows(John, x) → hates(John, x) knows(John, Jane) ∀y: knows(y, Leonid) ∀y: knows(y, mother(y)) ∀x: knows(x, Elizabeth) UNIFY(knows(John, x), knows(John, Jane)) = {Jane/x} UNIFY(knows(John, x), knows(y, Leonid)) = {Leonid/x, John/y} UNIFY(knows(John, x), knows(y, mother(y))) = {John/y, mother(John)/x} UNIFY(knows(John, x), knows(x, Elizabeth)) = FAIL 61 RESOLUTION IN PREDICATE LOGIC Unification: Most general unifier UNIFY(knows(John, x), knows(y, z)) = {John/y, John/x, John/z} = {John/y, Jane/x, Jane/z} = {John/y, v/x, v/z} 62
  • 48. CHAINING □To predict outcomes using the given pool of knowledge. □Knowledge base is given and using logical rules and reasoning, one has to predict the outcome. □These problems are usually solved using Inference Engines, □Utilize their two special modes: I. Forward Chaining II. Backward Chaining 63 FORWARD CHAINING □Step 1: Start from the already stated facts, and then, subsequently choose the facts that do not have any implications at all. □Step 2: Now, those facts that can be inferred from available facts with satisfied premises. □Step 3: In step 3, check the given statement that needs to be checked and check whether it is satisfied with the substitution which infers all the previously stated facts. Thus we reach our goal. 64
  • 51. BACKWARD CHAINING □Step 1. In the first step, take the Goal Fact and from the goal fact, we’ll derive other facts that we’ll prove true. □Step 2: derive other facts from goal facts that satisfy the rules □Step 3: At step-3, extract further fact which infers from facts inferred in step 2. □Step 4: Repeat the same until we get to a certain fact that satisfies the conditions. 69 70
  • 56. S.no Forward Chaining Backward Chaining 1 Forward chaining starts from known facts and applies inference rule to extract more data unit it reaches to the goal. Backward chaining starts from the goal and works backward through inference rules to find the required facts that support the goal. 2 It is a bottom-up approach It is a top-down approach 3 Forward chaining is known as data-driven inference technique as we reach to the goal using the available data. Backward chaining is known as goal-driven technique as we start from the goal and divide into sub-goal to extract the facts. 4 Forward chaining reasoning applies a breadth-first search strategy. Backward chaining reasoning applies a depth-first search strategy. 5 Forward chaining tests for all the available rules Backward chaining only tests for few required rules. 6 Forward chaining is suitable for the planning, monitoring, control, and interpretation application. Backward chaining is suitable for diagnostic, prescription, and debugging application. 7 Forward chaining can generate an infinite number of possible conclusions. Backward chaining generates a finite number of possible conclusions. 8 Forward chaining is aimed for any conclusion. Backward chaining is only aimed for the required data.
  • 57. LOGIC PROGRAMMING ∙ Logic programming is based on FOPL. ∙ Clause in logic programming is special form of formula. ∙ Program in logic programming is a collection of clauses. ∙ Queries are solved using resolution principle. ∙ A clause in logic programming is represented in a clausal notation as A1, …, Ak ← B1,…, Bt , where Aj are positive literals and Bk are negative literals. 77 78 FOPL
  • 58. LOGIC PROGRAMMING - PROLOG • Prolog is a declarative programming language based on logic. • A Prolog program is a list of facts. • There are various predicates and functions • supplied to support I/O, graphics, etc. • Instead of CNF, prolog uses an implicative • normal form: A Ù B Ù ... Ù C Þ D
  • 59. 79 80
  • 60. PROLOG : □Only Horn sentences are acceptable □The occur-check is omitted from the unification: unsound test ← P(x, x) P(x, f(x)) □Backward chaining with depth-first search: incomplete P(x, y) ← Q(x, y) P(x, x) Q(x, y) ← Q(y, x) 81 82
  • 61. Special case: Horn clauses • Horn clauses are implications with only positive literals • x1 AND x2 AND x4 => x3 AND x6 • TRUE => x1 • Try to figure out whether some xj is entailed • Simply follow the implications (modus ponens) as far as you can, see if you can reach xj • xj is entailed if and only if it can be reached (can set everything that is not reached to false) • Can implement this more efficiently by maintaining, for each implication, a count of how many of the left-hand side variables have been reached
  • 62. Ontological Engineering • What is Ontological Engineering? Ontology refers to organizing everything in the world (complex domain) into hierarchy of categories. Representing the abstract concepts such as Actions,Time,Physical Objects,and Beliefs with respect to complex domains such as shopping on the internet or controlling a robot in a changing environment is called Ontological
  • 63. CATEGORIES AND OBJECTS The organization of objects into categories is a vital part of knowledge representation. Although interaction with the world takes place at the level of individual objects, much reasoning takes place at the level of categories. Categories play a role in predictions about objects • Based on perceived properties •Categories can be represented in two ways by • first-order logid (FOL) • Predicates: apple(x) • Reification of categories into objects: apples •Category is considered as set of its members(Relation=Inheritance). • For eg: All instance of food are edible, fruit is a subclass offood and apples is a subclass of fruit then an apple is edible. •
  • 64. Actions, Situations, and Events Actions are logical terms such as Forward and Turn (Right). F now, we will assume that the environment contains only on agent. (If there is more than one, an additional argument can b inserted to say which agent is doing the action.) Situations are logical terms consisting of the initial situation (usually called So) and all situations that are generated by applying an action to a situation. The function Result(a, s) (sometimes called Do) names the situation that results when action a is executed in situation s. Figure 10.2 illustrates this idea.
  • 66. Agent can now reason about the beliefs of agents. Turning a proposition into an object is called reification. Technically, the property of being able to substitute a term freely for an equal term is called referential transparency. There are two ways to achieve this. O The first is to use a different form of logic called modal logic, in which propositional attitudes such as Believes and Knows become modal operators that are referentially opaque. This approach is covered in the historical notes section.
  • 67. Knowledge and belief The relation between believing and knowing has been studied extensively in philosophy. It is commonly said that knowledge is justified true belief .Knowledge, time, and action Actions can have knowledge preconditions and knowledge effects. Plans to gather and use information are often represented using a shorthand notation called runtime variables, Plans to gather and use information are often represented using a shorthand notation called runtime variables.
  • 68. Reasoning Systems for Categories  Semantic networks  Visualize knowledge-base  Efficient algorithms for category membership inference  Description logics  Formal language for constructing and combining category definitions  Efficient algorithms to decide subset and superset relationships between categories.
  • 69. Semantic Networks • Semantic networks are capable of representing individual objects,categories of objects,and relation among objects. Objects or Category names are represented in ovals and are connected by labeled arcs. • Semantic network example
  • 71. Default reasoning This is a very common form of non-monotonic reasoning. Here We want to draw conclusions based on what is most likely to be true. Non-Monotonic logic. Default logic This is basically an extension of first-order predicate logic to include a modal operator, M. The purpose of this is to allow for consistency. For example: : plays_instrument(x) (and) improvises(x) → jazz_musician(x) states that for all x is x plays an instrument and if the fact that x can improvise is consistent with all other knowledge then we can conclude that x is a jazz musician.
  • 72. Truth Maintenance Systems (TMS) Many inferences have default status rather than being absolutely certain. • Inferred facts can be wrong and need to be retracted (new info) and it is called as belief revision.
  • 73. Types of TMS 1)Justification-Based Truth Maintenance Systems (JTMS) ▪This is a simple TMS in that it does not know anything about the structure of the assertions themselves. ▪Each supported belief (assertion) in has a justification. ▪Each justification has two parts: An IN-List -- which supports beliefs held. An OUT-List -- which supports beliefs not held. ▪An assertion is connected to its justification by an arrow.One assertion can feed another justification thus creating the network.Assertions may be labelled with a belief status.
  • 74. Fig: A JTMS Assertion
  • 75. 2)Logic-Based Truth Maintenance Systems (LTMS) Similar to JTMS except:  Nodes (assertions) assume no relationships among them except ones explicitly stated in justifications.  JTMS can represent P and ¬P simultaneously. An LTMS would throw a contradiction here.  If this happens network has to be reconstructed. 3)Assumption-Based Truth Maintenance Systems (ATMS)  JTMS and LTMS pursue a single line of reasoning at a time and backtrack (dependency- directed) when needed -- depth first search.  ATMS maintain alternative paths in parallel -- breadth-first search  Backtracking is avoided at the expense of maintaining multiple contexts.