SlideShare a Scribd company logo
Artificial
Intelligence
Knowledge Representation and
Learning
28-11-2022 KNOWLEDGE REPRESENTATION - AI 1
Contents
Knowledge-based agents
Wumpus world
Logic in general - models and entailment
Propositional (Boolean) logic
Equivalence, validity, satisfiability
Inference rules and theorem proving
▪ Forward chaining
▪ Backward chaining
▪ Resolution
28-11-2022 KNOWLEDGE REPRESENTATION - AI 2
Logical Agents
Humans can know “things” and “reason”
Representation: How are things stored?
Reasoning: How is the knowledge used?
• To solve a problem…
• To generate more knowledge…
• Knowledge and reasoning are important to artificial agents because they
enable successful behaviors difficult to achieve otherwise
– Useful in partially observable environments
28-11-2022 KNOWLEDGE REPRESENTATION - AI 3
“Logical AI:
The idea is that an agent can represent knowledge of its world,
its goals and the current situation by sentences in logic and decide
what to do by inferring that a certain action or course of action is
appropriate to achieve its goals.”
Logical Agents
28-11-2022 KNOWLEDGE REPRESENTATION - AI 4
Knowledge Base
28-11-2022 KNOWLEDGE REPRESENTATION - AI 5
Knowledge-Based Agents
Central component of a Knowledge-Based Agent is a Knowledge-Base
A set of sentences in a formal language
Sentences are expressed using a knowledge representation language
Two generic functions:
– TELL - add new sentences (facts) to the KB • “Tell it what it needs
to know”
– ASK - query what is known from the KB • “Ask what to do next”
28-11-2022 KNOWLEDGE REPRESENTATION - AI 6
A simple knowledge-based agent
28-11-2022 KNOWLEDGE REPRESENTATION - AI 7
The Wumpus World environment
The Wumpus computer game
The agent explores a cave consisting of rooms
connected by passageways
Lurking somewhere in the cave is the Wumpus, a beast
that eats any agent that enters its room
Some rooms contain bottomless pits that trap any agent
that wanders into the room
The Wumpus can fall into a pit too, so avoids them
Occasionally, there is a heap of gold in a room.
The goal is to collect the gold and exit the world without
being eaten
28-11-2022 KNOWLEDGE REPRESENTATION - AI 8
AIMA’s Wumpus World
The agent always starts in the field
[1,1]
Agent’s task is to find the gold, return
to the field [1,1] and climb out of the
cave
28-11-2022 KNOWLEDGE REPRESENTATION - AI 9
The Hunter’s first step
¬W
¬W
Since the agent is alive and perceives neither
a breeze nor a stench at [1,1], it knows that
[1,1] and its neighbors are OK
Moving to [2,1] is a safe move that reveals a
breeze but no stench, implying that the Wumpus
is not adjacent but that one or more pits are
28-11-2022 KNOWLEDGE REPRESENTATION - AI 10
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 11
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 12
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
Exploring a wumpus world
28-11-2022 KNOWLEDGE REPRESENTATION - AI 13
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 14
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 15
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 16
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 17
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
28-11-2022 KNOWLEDGE REPRESENTATION - AI 18
Exploring a wumpus world
A agent
B breeze
G glitter
OK safe cell
P pit
S stench
W wumpus
P?
P?
In each case where the agent draws a conclusion from the available
Information, that conclusion is guaranteed to be correct if the available
Information is correct…
This is a fundamental property of logical reasoning
28-11-2022 KNOWLEDGE REPRESENTATION - AI 19
Performance Measure: Performance measure is the unit to define the success
of an agent. Performance varies with agents based on their different precepts.
Environment: Environment is the surrounding of an agent at every instant. It
keeps changing with time if the agent is set in motion.
Actuator: An actuator is a part of the agent that delivers the output of action to
the environment.
Sensor: Sensors are the receptive parts of an agent that takes in the input for
the agent.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 20
28-11-2022 KNOWLEDGE REPRESENTATION - AI 21
Logic as a KR language
Propositional Logic
First Order
Higher Order
Modal
Fuzzy
Logic
Multi-valued
Logic
Probabilistic
Logic
Temporal Non-monotonic
Logic
28-11-2022 KNOWLEDGE REPRESENTATION - AI 22
Logics
Logics are formal languages for representing information such that conclusions
can be drawn
Syntax defines the sentences in the language
Semantics define the "meaning" of sentences; define truth of a sentence in a
world
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
28-11-2022 KNOWLEDGE REPRESENTATION - AI 23
Inference and Entailment
Inference is a procedure that allows new sentences to be derived from a
knowledge base.
Understanding inference and entailment: think of
Set of all consequences of a KB as a haystack
α as the needle
Entailment is like the needle being in the haystack
Inference is like finding it
28-11-2022 KNOWLEDGE REPRESENTATION - AI 24
Inference and Entailment
28-11-2022 KNOWLEDGE REPRESENTATION - AI 25
Propositional Logic
Propositional logic (PL) is the simplest logic.
• Syntax of PL: defines the allowable sentences or propositions.
• Definition (Proposition): A proposition is a declarative statement (True or False).
A fact, like “the Sun is hot.” The Sun cannot be both hot and not hot at the
same time. This declarative statement could also be referred to as a proposition.
• Atomic proposition: single proposition symbol. Each symbol is a proposition.
Notation: upper case letters and may contain subscripts.
• Compound proposition: constructed from from atomic propositions using parentheses and
logical connectives.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 26
Atomic Proposition
Examples of atomic propositions:
2+2=4 is a true proposition
W1,3 is a proposition. It is true if there is a Wumpus in [1,3]
“If there is a stench in [1,2] then there is a Wumpus in [1,3]”
is a proposition
“How are you?” or “Hello!” are not propositions. In general,
statement that are questions, commands, or opinions are not
propositions.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 27
Examples of compound/complex propositions
Let p, p1, and p2 be propositions
• Negation ¬p is also a proposition. A literal is either an atomic proposition or
its negation. E.g., W1,3 is a positive literal, and ¬W1,3 is a negative literal.
• Conjunction p1 ∧ p2. E.g., W1,3 ∧ P3,1
• Disjunction p1 ∨ p2 E.g., W1,3 ∨ P3,1
• Implication p1 → p2. E.g., W1,3 ∧ P3,1 → ¬W2,2
• If and only if p1 ↔ p2. E.g., W1,3 ↔ ¬W2,2
28-11-2022 KNOWLEDGE REPRESENTATION - AI 28
Truth Table
The semantics define the rules to determine the truth of a sentence.
• Semantics can be specified by truth tables.
• Boolean values domain: T,F , n-tuple: (x1, x2, ..., xn)
• Operator on n-tuples : g(x1 = v1, x2 = v2, ..., xn = vn)
• A truth table defines an operator g on n- tuples by specifying a boolean value for each
tuple.
• Number of rows in a truth table? R = 2n
28-11-2022 KNOWLEDGE REPRESENTATION - AI 29
Building Propositions
Negation Conjunction
Disjunction Implication
If and only if
Exclusive OR
28-11-2022 KNOWLEDGE REPRESENTATION - AI 30
Logical Equivalence
Two propositions p and q are logically equivalent if and only if the columns in
the truth table giving their truth values agree.
• We write this as p ⇔ q or p ≡ q.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 31
Tautology and contradiction
• Tautology is a proposition which is always true
• Contradiction is a proposition which is always false
• Contingency is a proposition which is neither a tautology or a contradiction
28-11-2022 KNOWLEDGE REPRESENTATION - AI 32
Contrapositive and Inverse
Given an implication p → q
• The converse is: q → p
• The contrapositive is: ¬q →
¬p
• The inverse is: ¬p → ¬q
Conditional statement: “If it is raining, then the grass is wet.”
The first step is to identify the hypothesis and conclusion
statements. Hypothesis, p: it is raining
Conclusion, q: grass is wet
Converse statement would be: “If the grass is wet, then it is
raining.”
Inverse statement would be: “If it is NOT raining, then the grass is
NOT wet.”
Contrapositive statement would be: “If the grass is NOT wet, then it
is NOT raining.”
28-11-2022 KNOWLEDGE REPRESENTATION - AI 33
Inference (Modus Ponens)
28-11-2022 KNOWLEDGE REPRESENTATION - AI 34
Modus Tollens
28-11-2022 KNOWLEDGE REPRESENTATION - AI 35
And Elimination, Unit Resolution
28-11-2022 KNOWLEDGE REPRESENTATION - AI 36
Wumpus world – Knowledge Base
Atomic propositions
28-11-2022 KNOWLEDGE REPRESENTATION - AI 37
Wumpus world – Knowledge Base
28-11-2022 KNOWLEDGE REPRESENTATION - AI 38
28-11-2022 KNOWLEDGE REPRESENTATION - AI 39
28-11-2022 KNOWLEDGE REPRESENTATION - AI 40
Propositional Rules
Room[1,1], room does not have
wumpus(¬ W11), no stench (¬S11), no
Pit(¬P11), no breeze(¬B11), no gold
(¬G11), visited (V11), and the room is
Safe(OK11).
28-11-2022 KNOWLEDGE REPRESENTATION - AI 41
Inference
Prove that wumpus is in the room (1, 3) using propositional rules which have
been derived for the wumpus world and using inference rule.
•Apply Modus Ponens with ¬S11 and R1:
28-11-2022 KNOWLEDGE REPRESENTATION - AI 42
Inference
Apply And-Elimination Rule:
After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21, we will get
three statements:
¬ W11, ¬ W12, and ¬W21.
•Apply Modus Ponens to ¬S21
, and R2:
Now we will apply Modus Ponens to ¬S21
and R2 which is ¬S21
→ ¬ W21
∧¬
W22
∧ ¬ W31
, which will give the Output as ¬ W21
∧ ¬ W22
∧¬ W31
28-11-2022 KNOWLEDGE REPRESENTATION - AI 43
Inference
•Apply And -Elimination rule:
Now again apply And-elimination rule to ¬ W21
∧ ¬ W22
∧¬ W31
, We will get
three statements:
¬ W21
, ¬ W22
, and ¬ W31
.
•Apply MP to S12
and R4:
Apply Modus Ponens to S12
and R4
which is S12
→ W13
∨. W12
∨. W22
∨.W11
,
we will get the output as W13
∨ W12
∨ W22
∨.W11
.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 44
Inference
•Apply Unit resolution on W13
∨ W12
∨ W22
∨W11
and ¬ W11
:
After applying Unit resolution formula on W13
∨ W12
∨ W22
∨W11
and ¬
W11
we will get W13
∨ W12
∨ W22
.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 45
Inference
•Apply Unit resolution on W13
∨ W12
∨ W22
and ¬ W22
:
After applying Unit resolution on W13
∨ W12
∨ W22
, and ¬W22
, we will get W13
∨ W12
as
output.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 46
Inference
•Apply Unit Resolution on W13
∨ W12
and ¬ W12
:
After Applying Unit resolution on W13
∨ W12
and ¬ W12
, we will get W13
as an output, hence it
is proved that the Wumpus is in the room [1, 3].
28-11-2022 KNOWLEDGE REPRESENTATION - AI 47
28-11-2022 KNOWLEDGE REPRESENTATION - AI 48
Demerit of Propositional Logic
Propositional logic can only represent the facts, which are either true or false.
PL is not sufficient to represent the complex sentences or natural language
statements.
The propositional logic has very limited expressive power.
Consider the following sentence, which we cannot represent using PL logic.
•"Some humans are intelligent", or
•"Sachin likes cricket."
28-11-2022 KNOWLEDGE REPRESENTATION - AI 49
First-Order Logic (FOL)
It is an extension to propositional logic.
FOL is sufficiently expressive to represent the natural language statements in a
concise way.
First-order logic is also known as Predicate logic or First-order predicate logic.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 50
First-order Logic
First-order logic (FOL) models the world in
terms of
◦Objects, which are things with individual
identities
◦Properties of objects that distinguish them
from other objects
◦Relations that hold among sets of objects
◦Functions, which are a subset of relations
where there is only one “value” for any
given “input”
Examples:
Objects: Students, lectures…
Relations: Brother-of,
bigger-than, outside..
Properties: blue, oval, even,
large, ...
Functions: father-of,
best-friend, second-half,
one-more-than ...
28-11-2022 KNOWLEDGE REPRESENTATION - AI 51
Basic Element in FOL
28-11-2022 KNOWLEDGE REPRESENTATION - AI 52
Atomic Sentences in FOL
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.
Atomic sentences are represented as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences:
Complex sentences are made by combining atomic sentences using
connectives.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 53
Parts of FOL
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.
Consider the statement: "x is an integer.", it consists
of two parts, the first part x is the subject of the
statement and second part "is an integer," is known as
a predicate.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 54
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).
28-11-2022 KNOWLEDGE REPRESENTATION - AI 55
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.
If x is a variable, then ∀x is read as:
•For all x
•For each x
•For every x.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 56
Universal Quantifier
Example: All man drink coffee.
Let a variable x which refers to a man so all x can be represented in UOD as below:
It will be read as: There are all x where x is a
man who drink coffee.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 57
Existential Quantifier
Existential quantifiers are the type of quantifiers, which 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.
If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be
read as:
28-11-2022 KNOWLEDGE REPRESENTATION - AI 58
Existential Quantifier
It will be read as: There are some x where x is a
boy who is intelligent.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 59
FOL
Points to remember:
The main connective for universal quantifier ∀ is implication →.
The main connective for existential quantifier ∃ is and ∧.
Properties of Quantifiers:
In universal quantifier, ∀x∀y is similar to ∀y∀x.
In Existential quantifier, ∃x∃y is similar to ∃y∃x.
∃x∀y is not similar to ∀y∃x.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 60
Examples of FOL
1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).
2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).
3. Some boys play cricket.
In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since
there are some boys so we will use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).
28-11-2022 KNOWLEDGE REPRESENTATION - AI 61
Examples of FOL
4. Not all students like both Mathematics and Science.
In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following
representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].
5. Only one student failed in Mathematics.
In this question, the predicate is "failed(x, y)," where x= student, and y=
subject.
Since there is only one student who failed in Mathematics, so we will use
following representation for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧
student(y) → ¬failed (x, Mathematics)].
28-11-2022 KNOWLEDGE REPRESENTATION - AI 62
Free and Bound Variable
There are two types of variables in First-order logic which are given below:
Free Variable: A variable is said to be a free variable in a formula if it occurs outside
the scope of the quantifier.
Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.
Bound Variable: A variable is said to be a bound variable in a formula if it occurs within
the scope of the quantifier.
Example: ∀x [A (x) B( y)], here x and y are the bound variables.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 63
Unification
The process of finding a substitution for predicate parameters is called
unification.
We need to know:
◦that 2 literals can be matched.
◦the substitution is that makes the literals identical.
There is a simple algorithm called the unification algorithm that does this.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 64
The Unification Algorithm
28-11-2022 KNOWLEDGE REPRESENTATION - AI 65
Unification Example
Let Ψ1
= King(x), Ψ2
= King(John),
Substitution θ = {John/x} is a unifier for these
atoms and applying this substitution, and both
expressions will be identical.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 66
Unification Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 67
Conditions for Unification:
Following are some basic conditions for unification:
•Predicate symbol must be same, atoms or expression with different predicate
symbol can never be unified.
•Number of Arguments in both expressions must be identical.
•Unification will fail if there are two similar variables present in the same
expression.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 68
Resolution
Resolution is a single inference rule which can efficiently operate on
the conjunctive normal form or clausal form.
Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 69
Steps for resolution
28-11-2022 KNOWLEDGE REPRESENTATION - AI 70
Resolution- Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 71
28-11-2022 KNOWLEDGE REPRESENTATION - AI 72
28-11-2022 KNOWLEDGE REPRESENTATION - AI 73
28-11-2022 KNOWLEDGE REPRESENTATION - AI 74
Step-3: Negate the statement to be
proved
In this statement, we will apply negation to
the conclusion statements, which will be
written as ¬likes(John, Peanuts)
28-11-2022 KNOWLEDGE REPRESENTATION - AI 75
Inference engine
The inference engine is the component of the intelligent system in artificial intelligence, which
applies logical rules to the knowledge base to infer new information from known facts.
Inference engine commonly proceeds in two modes, which are:
Forward chaining
Backward chaining
28-11-2022 KNOWLEDGE REPRESENTATION - AI 76
Forward Chaining
Forward chaining is a form of reasoning which start with atomic
sentences in the knowledge base and applies inference rules (Modus
Ponens) in the forward direction to extract more data until a goal is
reached.
The Forward-chaining algorithm starts from known facts, triggers all
rules whose premises are satisfied, and add their conclusion to the
known facts. This process repeats until the problem is solved.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 77
Forward Chaining
Given a new fact, generate all consequences
Assumes all rules are of the form
◦C1 and C2 and C3 and…. --> Result
Each rule & binding generates a new fact
This new fact will “trigger” other rules
Keep going until the desired fact is generated
(Semi-decidable as is FOL in general)
28-11-2022 KNOWLEDGE REPRESENTATION - AI 78
FC: 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 America, has some missiles, and all of its missiles were sold to it by Col. West,
who is an American.
Prove that Col. West is a criminal.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 79
FC: Example Knowledge Base
…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)
Nono…has some missiles
∃x Owns(Nono, x) ∧ Missiles(x)
Owns(Nono, M1
) and Missle(M1
)
…all of its missiles were sold to it by Col. West
∀x Missle(x) ∧ Owns(Nono, x) ⇒ Sells( West, x, Nono)
Missiles are weapons
Missle(x) ⇒ Weapon(x)
28-11-2022 KNOWLEDGE REPRESENTATION - AI 80
FC: Example Knowledge Base
An enemy of America counts as “hostile”
Enemy( x, America ) ⇒ Hostile(x)
Col. West who is an American
American( Col. West )
The country Nono, an enemy of America
Enemy(Nono, America)
28-11-2022 KNOWLEDGE REPRESENTATION - AI 81
FC: Example Knowledge Base
28-11-2022 KNOWLEDGE REPRESENTATION - AI 82
FC: Example Knowledge Base
28-11-2022 KNOWLEDGE REPRESENTATION - AI 83
FC: Example Knowledge Base
28-11-2022 KNOWLEDGE REPRESENTATION - AI 84
Backward Chaining
Consider the item to be proven a goal
Find a rule whose head is the goal (and bindings)
Apply bindings to the body, and prove these (subgoals) in turn
If you prove all the subgoals, increasing the binding set as you go,
you will prove the item.
28-11-2022 KNOWLEDGE REPRESENTATION - AI 85
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 86
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 87
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 88
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 89
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 90
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 91
Backward Chaining Example
28-11-2022 KNOWLEDGE REPRESENTATION - AI 92

More Related Content

PDF
AI22L520wwwwwwwwwwwwwwwwwwwwwwwwwww16.pdf
PPT
lecture7.ppt
PPT
lecture8.ppt
PDF
Knowledge based agent
PPT
AI Lecture 6 (logical agents)
PPT
Logic agent
PPT
Lecture 01.ppt
AI22L520wwwwwwwwwwwwwwwwwwwwwwwwwww16.pdf
lecture7.ppt
lecture8.ppt
Knowledge based agent
AI Lecture 6 (logical agents)
Logic agent
Lecture 01.ppt

Similar to Artificial intelligence knowledge representation and learning (20)

PDF
Theoretical and Practical Aspects of Knowledge Representation and Reasoning
PDF
LOGIC-AND-CRITICAL-THINKING-MDH-PDFDrive-.pdf
PPT
Jarrar.lecture notes.aai.2011s.ch7.p logic
PDF
PPT
CS 223-B L9 Odddddddddddddddddddpticadddl Flodzdzdsw.ppt
PPT
Probability theory
PDF
P versus NP
PDF
dma_ppt.pdf
PPT
CS4700-Logic notes for artificial intelligence and machine learning
PPT
PPT
Discrete Mathematics - All chapters
PPT
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
PPTX
Let’s get started with with discrete math.pptx
PDF
PPT
Introduction to Logic Spring 2007 Introduction to Discrete Structures.ppt
PDF
1.3.2 Inductive and Deductive Reasoning
PDF
PPT
Ch01-1.ppt
PPT
Ch01-1.ppt
PDF
Risk and Risk Aversion FM
Theoretical and Practical Aspects of Knowledge Representation and Reasoning
LOGIC-AND-CRITICAL-THINKING-MDH-PDFDrive-.pdf
Jarrar.lecture notes.aai.2011s.ch7.p logic
CS 223-B L9 Odddddddddddddddddddpticadddl Flodzdzdsw.ppt
Probability theory
P versus NP
dma_ppt.pdf
CS4700-Logic notes for artificial intelligence and machine learning
Discrete Mathematics - All chapters
Unit III Knowledge Representation in AI K.Sundar,AP/CSE,VEC
Let’s get started with with discrete math.pptx
Introduction to Logic Spring 2007 Introduction to Discrete Structures.ppt
1.3.2 Inductive and Deductive Reasoning
Ch01-1.ppt
Ch01-1.ppt
Risk and Risk Aversion FM
Ad

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
UNIT 4 Total Quality Management .pptx
PPT
introduction to datamining and warehousing
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPTX
Sustainable Sites - Green Building Construction
DOCX
573137875-Attendance-Management-System-original
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
Artificial Intelligence
PPTX
Geodesy 1.pptx...............................................
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
Well-logging-methods_new................
PPTX
Fundamentals of Mechanical Engineering.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
UNIT 4 Total Quality Management .pptx
introduction to datamining and warehousing
Foundation to blockchain - A guide to Blockchain Tech
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Sustainable Sites - Green Building Construction
573137875-Attendance-Management-System-original
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Automation-in-Manufacturing-Chapter-Introduction.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Artificial Intelligence
Geodesy 1.pptx...............................................
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
III.4.1.2_The_Space_Environment.p pdffdf
Well-logging-methods_new................
Fundamentals of Mechanical Engineering.pptx
Ad

Artificial intelligence knowledge representation and learning

  • 2. Contents Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem proving ▪ Forward chaining ▪ Backward chaining ▪ Resolution 28-11-2022 KNOWLEDGE REPRESENTATION - AI 2
  • 3. Logical Agents Humans can know “things” and “reason” Representation: How are things stored? Reasoning: How is the knowledge used? • To solve a problem… • To generate more knowledge… • Knowledge and reasoning are important to artificial agents because they enable successful behaviors difficult to achieve otherwise – Useful in partially observable environments 28-11-2022 KNOWLEDGE REPRESENTATION - AI 3
  • 4. “Logical AI: The idea is that an agent can represent knowledge of its world, its goals and the current situation by sentences in logic and decide what to do by inferring that a certain action or course of action is appropriate to achieve its goals.” Logical Agents 28-11-2022 KNOWLEDGE REPRESENTATION - AI 4
  • 5. Knowledge Base 28-11-2022 KNOWLEDGE REPRESENTATION - AI 5
  • 6. Knowledge-Based Agents Central component of a Knowledge-Based Agent is a Knowledge-Base A set of sentences in a formal language Sentences are expressed using a knowledge representation language Two generic functions: – TELL - add new sentences (facts) to the KB • “Tell it what it needs to know” – ASK - query what is known from the KB • “Ask what to do next” 28-11-2022 KNOWLEDGE REPRESENTATION - AI 6
  • 7. A simple knowledge-based agent 28-11-2022 KNOWLEDGE REPRESENTATION - AI 7
  • 8. The Wumpus World environment The Wumpus computer game The agent explores a cave consisting of rooms connected by passageways Lurking somewhere in the cave is the Wumpus, a beast that eats any agent that enters its room Some rooms contain bottomless pits that trap any agent that wanders into the room The Wumpus can fall into a pit too, so avoids them Occasionally, there is a heap of gold in a room. The goal is to collect the gold and exit the world without being eaten 28-11-2022 KNOWLEDGE REPRESENTATION - AI 8
  • 9. AIMA’s Wumpus World The agent always starts in the field [1,1] Agent’s task is to find the gold, return to the field [1,1] and climb out of the cave 28-11-2022 KNOWLEDGE REPRESENTATION - AI 9
  • 10. The Hunter’s first step ¬W ¬W Since the agent is alive and perceives neither a breeze nor a stench at [1,1], it knows that [1,1] and its neighbors are OK Moving to [2,1] is a safe move that reveals a breeze but no stench, implying that the Wumpus is not adjacent but that one or more pits are 28-11-2022 KNOWLEDGE REPRESENTATION - AI 10
  • 11. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 11
  • 12. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 12
  • 13. A agent B breeze G glitter OK safe cell P pit S stench W wumpus Exploring a wumpus world 28-11-2022 KNOWLEDGE REPRESENTATION - AI 13
  • 14. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 14
  • 15. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 15
  • 16. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 16
  • 17. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 17
  • 18. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus 28-11-2022 KNOWLEDGE REPRESENTATION - AI 18
  • 19. Exploring a wumpus world A agent B breeze G glitter OK safe cell P pit S stench W wumpus P? P? In each case where the agent draws a conclusion from the available Information, that conclusion is guaranteed to be correct if the available Information is correct… This is a fundamental property of logical reasoning 28-11-2022 KNOWLEDGE REPRESENTATION - AI 19
  • 20. Performance Measure: Performance measure is the unit to define the success of an agent. Performance varies with agents based on their different precepts. Environment: Environment is the surrounding of an agent at every instant. It keeps changing with time if the agent is set in motion. Actuator: An actuator is a part of the agent that delivers the output of action to the environment. Sensor: Sensors are the receptive parts of an agent that takes in the input for the agent. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 20
  • 22. Logic as a KR language Propositional Logic First Order Higher Order Modal Fuzzy Logic Multi-valued Logic Probabilistic Logic Temporal Non-monotonic Logic 28-11-2022 KNOWLEDGE REPRESENTATION - AI 22
  • 23. Logics Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language Semantics define the "meaning" of sentences; define truth of a sentence in a world 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 28-11-2022 KNOWLEDGE REPRESENTATION - AI 23
  • 24. Inference and Entailment Inference is a procedure that allows new sentences to be derived from a knowledge base. Understanding inference and entailment: think of Set of all consequences of a KB as a haystack α as the needle Entailment is like the needle being in the haystack Inference is like finding it 28-11-2022 KNOWLEDGE REPRESENTATION - AI 24
  • 25. Inference and Entailment 28-11-2022 KNOWLEDGE REPRESENTATION - AI 25
  • 26. Propositional Logic Propositional logic (PL) is the simplest logic. • Syntax of PL: defines the allowable sentences or propositions. • Definition (Proposition): A proposition is a declarative statement (True or False). A fact, like “the Sun is hot.” The Sun cannot be both hot and not hot at the same time. This declarative statement could also be referred to as a proposition. • Atomic proposition: single proposition symbol. Each symbol is a proposition. Notation: upper case letters and may contain subscripts. • Compound proposition: constructed from from atomic propositions using parentheses and logical connectives. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 26
  • 27. Atomic Proposition Examples of atomic propositions: 2+2=4 is a true proposition W1,3 is a proposition. It is true if there is a Wumpus in [1,3] “If there is a stench in [1,2] then there is a Wumpus in [1,3]” is a proposition “How are you?” or “Hello!” are not propositions. In general, statement that are questions, commands, or opinions are not propositions. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 27
  • 28. Examples of compound/complex propositions Let p, p1, and p2 be propositions • Negation ¬p is also a proposition. A literal is either an atomic proposition or its negation. E.g., W1,3 is a positive literal, and ¬W1,3 is a negative literal. • Conjunction p1 ∧ p2. E.g., W1,3 ∧ P3,1 • Disjunction p1 ∨ p2 E.g., W1,3 ∨ P3,1 • Implication p1 → p2. E.g., W1,3 ∧ P3,1 → ¬W2,2 • If and only if p1 ↔ p2. E.g., W1,3 ↔ ¬W2,2 28-11-2022 KNOWLEDGE REPRESENTATION - AI 28
  • 29. Truth Table The semantics define the rules to determine the truth of a sentence. • Semantics can be specified by truth tables. • Boolean values domain: T,F , n-tuple: (x1, x2, ..., xn) • Operator on n-tuples : g(x1 = v1, x2 = v2, ..., xn = vn) • A truth table defines an operator g on n- tuples by specifying a boolean value for each tuple. • Number of rows in a truth table? R = 2n 28-11-2022 KNOWLEDGE REPRESENTATION - AI 29
  • 30. Building Propositions Negation Conjunction Disjunction Implication If and only if Exclusive OR 28-11-2022 KNOWLEDGE REPRESENTATION - AI 30
  • 31. Logical Equivalence Two propositions p and q are logically equivalent if and only if the columns in the truth table giving their truth values agree. • We write this as p ⇔ q or p ≡ q. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 31
  • 32. Tautology and contradiction • Tautology is a proposition which is always true • Contradiction is a proposition which is always false • Contingency is a proposition which is neither a tautology or a contradiction 28-11-2022 KNOWLEDGE REPRESENTATION - AI 32
  • 33. Contrapositive and Inverse Given an implication p → q • The converse is: q → p • The contrapositive is: ¬q → ¬p • The inverse is: ¬p → ¬q Conditional statement: “If it is raining, then the grass is wet.” The first step is to identify the hypothesis and conclusion statements. Hypothesis, p: it is raining Conclusion, q: grass is wet Converse statement would be: “If the grass is wet, then it is raining.” Inverse statement would be: “If it is NOT raining, then the grass is NOT wet.” Contrapositive statement would be: “If the grass is NOT wet, then it is NOT raining.” 28-11-2022 KNOWLEDGE REPRESENTATION - AI 33
  • 34. Inference (Modus Ponens) 28-11-2022 KNOWLEDGE REPRESENTATION - AI 34
  • 35. Modus Tollens 28-11-2022 KNOWLEDGE REPRESENTATION - AI 35
  • 36. And Elimination, Unit Resolution 28-11-2022 KNOWLEDGE REPRESENTATION - AI 36
  • 37. Wumpus world – Knowledge Base Atomic propositions 28-11-2022 KNOWLEDGE REPRESENTATION - AI 37
  • 38. Wumpus world – Knowledge Base 28-11-2022 KNOWLEDGE REPRESENTATION - AI 38
  • 41. Propositional Rules Room[1,1], room does not have wumpus(¬ W11), no stench (¬S11), no Pit(¬P11), no breeze(¬B11), no gold (¬G11), visited (V11), and the room is Safe(OK11). 28-11-2022 KNOWLEDGE REPRESENTATION - AI 41
  • 42. Inference Prove that wumpus is in the room (1, 3) using propositional rules which have been derived for the wumpus world and using inference rule. •Apply Modus Ponens with ¬S11 and R1: 28-11-2022 KNOWLEDGE REPRESENTATION - AI 42
  • 43. Inference Apply And-Elimination Rule: After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21, we will get three statements: ¬ W11, ¬ W12, and ¬W21. •Apply Modus Ponens to ¬S21 , and R2: Now we will apply Modus Ponens to ¬S21 and R2 which is ¬S21 → ¬ W21 ∧¬ W22 ∧ ¬ W31 , which will give the Output as ¬ W21 ∧ ¬ W22 ∧¬ W31 28-11-2022 KNOWLEDGE REPRESENTATION - AI 43
  • 44. Inference •Apply And -Elimination rule: Now again apply And-elimination rule to ¬ W21 ∧ ¬ W22 ∧¬ W31 , We will get three statements: ¬ W21 , ¬ W22 , and ¬ W31 . •Apply MP to S12 and R4: Apply Modus Ponens to S12 and R4 which is S12 → W13 ∨. W12 ∨. W22 ∨.W11 , we will get the output as W13 ∨ W12 ∨ W22 ∨.W11 . 28-11-2022 KNOWLEDGE REPRESENTATION - AI 44
  • 45. Inference •Apply Unit resolution on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 : After applying Unit resolution formula on W13 ∨ W12 ∨ W22 ∨W11 and ¬ W11 we will get W13 ∨ W12 ∨ W22 . 28-11-2022 KNOWLEDGE REPRESENTATION - AI 45
  • 46. Inference •Apply Unit resolution on W13 ∨ W12 ∨ W22 and ¬ W22 : After applying Unit resolution on W13 ∨ W12 ∨ W22 , and ¬W22 , we will get W13 ∨ W12 as output. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 46
  • 47. Inference •Apply Unit Resolution on W13 ∨ W12 and ¬ W12 : After Applying Unit resolution on W13 ∨ W12 and ¬ W12 , we will get W13 as an output, hence it is proved that the Wumpus is in the room [1, 3]. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 47
  • 49. Demerit of Propositional Logic Propositional logic can only represent the facts, which are either true or false. PL is not sufficient to represent the complex sentences or natural language statements. The propositional logic has very limited expressive power. Consider the following sentence, which we cannot represent using PL logic. •"Some humans are intelligent", or •"Sachin likes cricket." 28-11-2022 KNOWLEDGE REPRESENTATION - AI 49
  • 50. First-Order Logic (FOL) It is an extension to propositional logic. FOL is sufficiently expressive to represent the natural language statements in a concise way. First-order logic is also known as Predicate logic or First-order predicate logic. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 50
  • 51. First-order Logic First-order logic (FOL) models the world in terms of ◦Objects, which are things with individual identities ◦Properties of objects that distinguish them from other objects ◦Relations that hold among sets of objects ◦Functions, which are a subset of relations where there is only one “value” for any given “input” Examples: Objects: Students, lectures… Relations: Brother-of, bigger-than, outside.. Properties: blue, oval, even, large, ... Functions: father-of, best-friend, second-half, one-more-than ... 28-11-2022 KNOWLEDGE REPRESENTATION - AI 51
  • 52. Basic Element in FOL 28-11-2022 KNOWLEDGE REPRESENTATION - AI 52
  • 53. Atomic Sentences in FOL 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. Atomic sentences are represented as Predicate (term1, term2, ......, term n). Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay). Chinky is a cat: => cat (Chinky). Complex Sentences: Complex sentences are made by combining atomic sentences using connectives. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 53
  • 54. Parts of FOL 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. Consider the statement: "x is an integer.", it consists of two parts, the first part x is the subject of the statement and second part "is an integer," is known as a predicate. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 54
  • 55. 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). 28-11-2022 KNOWLEDGE REPRESENTATION - AI 55
  • 56. 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. If x is a variable, then ∀x is read as: •For all x •For each x •For every x. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 56
  • 57. Universal Quantifier Example: All man drink coffee. Let a variable x which refers to a man so all x can be represented in UOD as below: It will be read as: There are all x where x is a man who drink coffee. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 57
  • 58. Existential Quantifier Existential quantifiers are the type of quantifiers, which 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. If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as: 28-11-2022 KNOWLEDGE REPRESENTATION - AI 58
  • 59. Existential Quantifier It will be read as: There are some x where x is a boy who is intelligent. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 59
  • 60. FOL Points to remember: The main connective for universal quantifier ∀ is implication →. The main connective for existential quantifier ∃ is and ∧. Properties of Quantifiers: In universal quantifier, ∀x∀y is similar to ∀y∀x. In Existential quantifier, ∃x∃y is similar to ∃y∃x. ∃x∀y is not similar to ∀y∃x. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 60
  • 61. Examples of FOL 1. All birds fly. In this question the predicate is "fly(bird)." And since there are all birds who fly so it will be represented as follows. ∀x bird(x) →fly(x). 2. Every man respects his parent. In this question, the predicate is "respect(x, y)," where x=man, and y= parent. Since there is every man so will use ∀, and it will be represented as follows: ∀x man(x) → respects (x, parent). 3. Some boys play cricket. In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since there are some boys so we will use ∃, and it will be represented as: ∃x boys(x) → play(x, cricket). 28-11-2022 KNOWLEDGE REPRESENTATION - AI 61
  • 62. Examples of FOL 4. Not all students like both Mathematics and Science. In this question, the predicate is "like(x, y)," where x= student, and y= subject. Since there are not all students, so we will use ∀ with negation, so following representation for this: ¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)]. 5. Only one student failed in Mathematics. In this question, the predicate is "failed(x, y)," where x= student, and y= subject. Since there is only one student who failed in Mathematics, so we will use following representation for this: ∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧ student(y) → ¬failed (x, Mathematics)]. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 62
  • 63. Free and Bound Variable There are two types of variables in First-order logic which are given below: Free Variable: A variable is said to be a free variable in a formula if it occurs outside the scope of the quantifier. Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable. Bound Variable: A variable is said to be a bound variable in a formula if it occurs within the scope of the quantifier. Example: ∀x [A (x) B( y)], here x and y are the bound variables. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 63
  • 64. Unification The process of finding a substitution for predicate parameters is called unification. We need to know: ◦that 2 literals can be matched. ◦the substitution is that makes the literals identical. There is a simple algorithm called the unification algorithm that does this. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 64
  • 65. The Unification Algorithm 28-11-2022 KNOWLEDGE REPRESENTATION - AI 65
  • 66. Unification Example Let Ψ1 = King(x), Ψ2 = King(John), Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and both expressions will be identical. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 66
  • 68. Conditions for Unification: Following are some basic conditions for unification: •Predicate symbol must be same, atoms or expression with different predicate symbol can never be unified. •Number of Arguments in both expressions must be identical. •Unification will fail if there are two similar variables present in the same expression. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 68
  • 69. Resolution Resolution is a single inference rule which can efficiently operate on the conjunctive normal form or clausal form. Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 69
  • 70. Steps for resolution 28-11-2022 KNOWLEDGE REPRESENTATION - AI 70
  • 75. Step-3: Negate the statement to be proved In this statement, we will apply negation to the conclusion statements, which will be written as ¬likes(John, Peanuts) 28-11-2022 KNOWLEDGE REPRESENTATION - AI 75
  • 76. Inference engine The inference engine is the component of the intelligent system in artificial intelligence, which applies logical rules to the knowledge base to infer new information from known facts. Inference engine commonly proceeds in two modes, which are: Forward chaining Backward chaining 28-11-2022 KNOWLEDGE REPRESENTATION - AI 76
  • 77. Forward Chaining Forward chaining is a form of reasoning which start with atomic sentences in the knowledge base and applies inference rules (Modus Ponens) in the forward direction to extract more data until a goal is reached. The Forward-chaining algorithm starts from known facts, triggers all rules whose premises are satisfied, and add their conclusion to the known facts. This process repeats until the problem is solved. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 77
  • 78. Forward Chaining Given a new fact, generate all consequences Assumes all rules are of the form ◦C1 and C2 and C3 and…. --> Result Each rule & binding generates a new fact This new fact will “trigger” other rules Keep going until the desired fact is generated (Semi-decidable as is FOL in general) 28-11-2022 KNOWLEDGE REPRESENTATION - AI 78
  • 79. FC: 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 America, has some missiles, and all of its missiles were sold to it by Col. West, who is an American. Prove that Col. West is a criminal. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 79
  • 80. FC: Example Knowledge Base …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) Nono…has some missiles ∃x Owns(Nono, x) ∧ Missiles(x) Owns(Nono, M1 ) and Missle(M1 ) …all of its missiles were sold to it by Col. West ∀x Missle(x) ∧ Owns(Nono, x) ⇒ Sells( West, x, Nono) Missiles are weapons Missle(x) ⇒ Weapon(x) 28-11-2022 KNOWLEDGE REPRESENTATION - AI 80
  • 81. FC: Example Knowledge Base An enemy of America counts as “hostile” Enemy( x, America ) ⇒ Hostile(x) Col. West who is an American American( Col. West ) The country Nono, an enemy of America Enemy(Nono, America) 28-11-2022 KNOWLEDGE REPRESENTATION - AI 81
  • 82. FC: Example Knowledge Base 28-11-2022 KNOWLEDGE REPRESENTATION - AI 82
  • 83. FC: Example Knowledge Base 28-11-2022 KNOWLEDGE REPRESENTATION - AI 83
  • 84. FC: Example Knowledge Base 28-11-2022 KNOWLEDGE REPRESENTATION - AI 84
  • 85. Backward Chaining Consider the item to be proven a goal Find a rule whose head is the goal (and bindings) Apply bindings to the body, and prove these (subgoals) in turn If you prove all the subgoals, increasing the binding set as you go, you will prove the item. 28-11-2022 KNOWLEDGE REPRESENTATION - AI 85
  • 86. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 86
  • 87. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 87
  • 88. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 88
  • 89. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 89
  • 90. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 90
  • 91. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 91
  • 92. Backward Chaining Example 28-11-2022 KNOWLEDGE REPRESENTATION - AI 92