0% found this document useful (0 votes)
146 views98 pages

Unit-3 Knowledge Representation

Uploaded by

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

Unit-3 Knowledge Representation

Uploaded by

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

Artificial Intelligence (KCS-071)

4th year (Semester – VII)


Session – 2023- 24
Unit – III
Lecture – 1
Manoj Mishra
Asst. Prof.
CSE Dept.
UCER, Prayagraj
KNOWLEDGE REPRESENTATION:TOPICS

First order Predicate Logic

Prolog Programming, Unification

Forward Chaining, Backward Chaining, Resolution

Knowledge Representation

Ontological Engineering, categories and objects, events

Mental event and mental objects


Reasoning system for categories

Reasoning with default Information.


Knowledge Representation
• Knowledge Representation (KR) is an area of
artificial intelligence research aimed at
representing knowledge in symbols to facilitate
inferencing from those knowledge elements,
creating new elements of knowledge.
• The KR can be made to be independent of the
underlying knowledge model or knowledge base
system (KBS) such as a semantic network.

A.I., KCS-071, Manoj Mishra 3


Knowledge Representation
• The primary component of a knowledge-
based agent is its knowledge-base.
– A knowledge-base is a set of sentences.
– Each sentence is expressed in a language called
the knowledge representation language.
– Sentences represent some assertions about the
world.
– There must be mechanisms to derive new
sentences from old ones. This process is known as
inferencing or reasoning.

A.I., KCS-071, Manoj Mishra 4


Knowledge Representation
– Inference must obey the primary requirement that
the new sentences should follow logically from
the previous ones.
– Logic is the primary vehicle for representing and
reasoning about knowledge.
– The advantage of using formal logic as a language
of AI is that it is precise and definite.

A.I., KCS-071, Manoj Mishra 5


Knowledge Representation
• A logic consists of two parts – a language and a method
of reasoning.
• The logical language, in turn, has two aspects, syntax
and semantics.
• Thus to specify or define a particular logic, one needs
to specify three things.
– Syntax: Syntax specifies the symbols in the
language and how they can be combined to form
sentences. Hence, facts about the world are represented
as sentences in logic. It is the atomic symbols of the logical
language, and the rules for constructing well-formed, non-
atomic expressions (symbol structures) of the logic.

A.I., KCS-071, Manoj Mishra 6


Knowledge Representation
– Semantics: It is the meaning of the atomic
symbols of the logic, and the rules for
determining the meanings of non-atomic expressions
of the logic. It specifies what facts in the world a
sentence refers to. A fact is a claim about the world,
and may be true or false.
– Syntactic Inference Method: The rules for
determining a subset of
logical expressions, called theorems of the logic. It
refers to mechanical method for computing (deriving)
new (true) sentences from existing ones.

A.I., KCS-071, Manoj Mishra 7


Characteristics of Knowledge
Representation (KR)
• A good knowledge representation covers six
basic characteristics:
– Coverage – which means the KR covers a
breadth and depth of information.
Without a wide coverage, the KR cannot
determine anything or resolve ambiguities.
– Understandable by humans – KR is viewed as a
natural language,
so the logic should flow freely. It should have
simple primitives that combine in complex forms.

A.I., KCS-071, Manoj Mishra 8


Characteristics of Knowledge
Representation (KR)
– Consistency - By being consistent, the KR can
eliminate redundant or conflicting
knowledge.
– Efficient
– Easiness – for modifying and updating.
– Supports the intelligent activity - which uses the
knowledge base.

A.I., KCS-071, Manoj Mishra 9


Artificial Intelligence (KCS-071)
4th year (Semester – VII)
Session – 2023 - 24
Unit – III
Lecture – 2
Manoj Mishra
Asst. Prof.
CSE Dept.
UCER, Prayagraj
Propositional Logic
• Propositional logic is concerned with
propositions and their interrelationships.
• A proposition is a possible condition of the
world about which we want to say something.
• The condition need not be true in order for us
to talk about it.
• In fact, we might want to say that it is false or
that it is true if some other proposition is true.

A.I., KCS-071, Manoj Mishra 11


Propositional Logic
• In propositional logic, there are two types of
sentences:
– Simple sentences: Simple sentences express
“atomic” propositions about
the world.
– Compound sentences: Compound sentences
express logical
relationships between the simpler sentences of
which they are composed.

A.I., KCS-071, Manoj Mishra 12


Propositional Logic
• There are six types of compound sentences,
viz., negations(¬), conjunctions(˄),
disjunctions(˅), implications(→),
reductions(←) and equivalences(↔).
• Operator precedence: ¬
˄
˅
→←↔
The above is the hierarchy of precedence of operators.

A.I., KCS-071, Manoj Mishra 13


Propositional Logic
• An interpretation for propositional logic is a mapping
assigning a truth value to each of the simple sentences
of the language.
• The assignment shown below is an example of
interpretation ‘i’ on a particular logical language.
pi = true
qi = false
ri = true
• We say that the interpretation ‘i’ satisfies a sentence if
and only if it is true under that interpretation.

A.I., KCS-071, Manoj Mishra 14


Validity, Satisfiability, Unsatisfiability,
Contingent
• Valid: A sentence is valid if and only if it is
satisfied by every interpretation. The
following sentence is valid.
p ˅ ¬p
• Satisfiable: A sentence is satisfiable if and
only if it is satisfied by at least one
interpretation.
A sentence is falsifiable if and only
if there is at least one interpretation that makes it
false.
A.I., KCS-071, Manoj Mishra 15
Validity, Satisfiability, Unsatisfiability,
Contingent
• Unsatisfiable: A sentence is unsatisfiable if
and only if it is not satisfied by
any interpretation. The following sentence is
unsatisfiable.
p ˄ ¬p
• Contingent: A sentence is contingent if and
only if it is both satisfiable and
falsifiable, i.e., it is neither valid nor
unsatisfiable.

A.I., KCS-071, Manoj Mishra 16


Artificial Intelligence (KCS-071)
4th year (Semester – VII)
Session – 2023 - 24
Unit – III
Lecture – 3
Manoj Mishra
Asst. Prof.
CSE Dept.
UCER, Prayagraj
Predicate Logic
• A predicate is a verb phrase template that
describes property of objects, or a relationship
among objects represented by the variables.
• The propositional logic is not powerful enough
to represent all types of assertions that are
used in computer science and mathematics, or
to express certain types of relationship
between propositions such as equivalence.

A.I., KCS-071, Manoj Mishra 18


Predicate Logic
• To cope up with deficiencies of propositional logic, two
new features are introduced: predicates and
quantifiers.
– For ex., the sentence “The car Tom is driving is blue”, “The
sky is blue” and “The cover of this book is blue” come from
the template “is blue”. The phrase “is blue” is a predicate
and it describes the property of being blue.
– Predicates are often given a name. For ex., “B” can be used
to represent the predicate “is blue” among others. If we
adopt B as the name for the predicate “is blue”, sentences
that assert an object “is blue” can be represented as B(x)
where ‘x’ represents an arbitrary object. B(x) reads as “x is
blue”.

A.I., KCS-071, Manoj Mishra 19


Representing facts with predicate
logic
• Let us consider a specific example of representing
knowledge using predicate logic.
• Let us consider the following sentences.
1) Marcus was a man.
2) Marcus was a Pompeian.
3) All Pompeians were Romans.
4) Caesar was a ruler.
5) All Romans were either loyal to Caesar or hated him.
6) Everyone is loyal to someone.
7) People only try to assassinate rulers they are not loyal to.
8) Marcus tried to assassinate Caesar.
9) All men are people.

A.I., KCS-071, Manoj Mishra 20


Representing facts with predicate
logic
• These can be represented in predicate logic as follows:
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)
9) ɏx : man(x) → person(x)

A.I., KCS-071, Manoj Mishra 21


Representing facts with predicate
logic
• Now, suppose that we want to use these
statements to answer the question
“Was Marcus loyal to Caesar?”
• It seems that using 7 and 8, we should be able
to prove that “Marcus was not loyal to
Caesar”.
• Now let’s produce a formal proof, reasoning
backward from the desired goal.

A.I., KCS-071, Manoj Mishra 22


Representing facts with predicate
logic
¬loyalto(Marcus, Caesar)
↑ (7, substitution)
person(Marcus) ˄ ruler(Caesar) ˄ tryassassinate(Marcus, Caesar)
↑ (4)
person(Marcus) ˄ tryassassinate(Marcus, Caesar)
↑ (8)
person(Marcus)
↑ (9)
man(Marcus)
↑ (1)
Nil

Since the answer obtained is nil, so the given set of predicates


satisfy the desired goal.
Hence, Marcus was not loyal to Caesar.
A.I., KCS-071, Manoj Mishra
(proved) 23
Representing facts with predicate
logic
• From this simple example, we see that three important
issues must be addressed in the process of converting
English sentences into logical statements and then
using those statements to deduce new ones:
– Many English sentences are ambiguous (for ex., 5, 6 and 7
above). Choosing the correct interpretation may be
difficult.
– There is often a choice of how to represent knowledge.
Simple representations are desirable, but they may
exclude certain kinds of reasoning.
– Even in very simple situations, a set of sentences is unlikely
to contain all the information necessary to reason about
the topic at hand.

A.I., KCS-071, Manoj Mishra 24


Artificial Intelligence (KCS-071)
4th year (Semester – VII)
Session – 2023 - 24
Unit – III
Lecture – 4
Manoj Mishra
Asst. Prof.
CSE Dept.
UCER, Prayagraj
Representing facts with predicate
logic
• An additional problem arises in situations where
we do not know in advance which statements to
deduce.
• In the example just presented, the object was to
answer the question “Was Marcus loyal to
Caesar?”
• How would a program decide whether to prove
loyalto(Marcus, Caesar)
or ¬loyalto(Marcus, Caesar)

A.I, KCS-071, Manoj Mishra 26


Representing facts with predicate
logic
• There are several things it could do.
– It could abandon the strategy we have outlined of
reasoning backward from a proposed truth to the
axioms and instead try to reason forward and see
which answer it gets to. The problem with this
approach is that, in general, the branching factor
going forward from the axioms is so great that it
would probably not get to either answer in any
reasonable amount of time.

A.I, KCS-071, Manoj Mishra 27


Representing facts with predicate
logic
– A second thing it could do is use some sort of heuristic
rules for deciding which answer is more likely and
then try to prove that one first. If it fails to find a proof
after some reasonable amount of effort, it can try the
other answer.
– Another thing it could do is simply try to prove both
answers simultaneously and stop when one effort is
successful. Even here, however, if there is not enough
information available to answer the question with
certainty, the program may never halt.
– A fourth strategy is to try both to prove one another
and to disprove it, and to use information gained in
one of the processes to guide the other.

A.I, KCS-071, Manoj Mishra 28


Representing facts with predicate
logic
• Let us try another example
“Did Marcus hate Caesar?”
• Now, let us try to prove “Marcus hated Caesar”

hate(Marcus, Caesar)
↑(5, substitution)
Roman(Marcus) ˄ ¬loyalto(Marcus, Caesar)
↑(3, substitution)
Pompeian(Marcus) ˄ ¬loyalto(Marcus, Caesar)
↑(2)

A.I, KCS-071, Manoj Mishra 29


Representing facts with predicate
logic
¬loyalto(Marcus, Caesar)
↑ (7, substitution)
person(Marcus) ˄ ruler(Caesar) ˄ tryassassinate(Marcus, Caesar)
↑ (4)
person(Marcus) ˄ tryassassinate(Marcus, Caesar)
↑ (8)
person(Marcus)
↑ (9)
man(Marcus)
↑ (1)
Nil

Since the answer obtained is nil, so the given set of predicates


satisfy the desired goal.
Hence, Marcus hated Caesar. (proved)
A.I, KCS-071, Manoj Mishra 30
Computable functions and predicates
• Suppose we want to express simple facts, such
as greater-than and less-than relationships,
which is shown as below.
gt(1,0) lt(0,1)
gt(2,1) lt(1,2)
gt(3,2) lt(2,3)
• Such relationships representation are called as
computable predicates. These predicates
evaluate rules and return true or false.
A.I, KCS-071, Manoj Mishra 31
Computable functions and predicates
• Let us consider the following set of facts, again
involving Marcus:
1) Marcus was a man.
2) Marcus was a Pompeian.
3) Marcus was born in 40 A.D.
4) All men are mortal.
5) All Pompeians died when the volcano erupted in 79 A.D.
6) No mortal lives longer than 150 years.
7) It is now 1991.
8) Alive means not dead.
9) If someone dies, then he is dead at all later times.

A.I, KCS-071, Manoj Mishra 32


Computable functions and predicates
• These can be represented in predicate logic as follows:
1) man(Marcus)
2) Pompeian(Marcus)
3) born(Marcus, 40)
4) ɏx : man(x) → mortal(x)
5) erupted(volcano, 79) ˄ ɏx : [Pompeian(x) →
died(x, 79)]
6) ɏx : ɏt1 : ɏt2 : mortal(x) ˄ born(x, t1) ˄ gt(t2 – t1, 150)
→ dead(x, t2)
7) now = 1991
8) ɏx : ɏt : [alive(x, t) → ¬dead(x, t)] ˄ [¬dead(x, t) → alive(x, t)]
9) ɏx : ɏt1 : ɏt2 : died(x, t1) ˄ gt(t2, t1) → dead(x, t2)

A.I, KCS-071, Manoj Mishra 33


Computable functions and predicates
• Now let’s attempt to answer the question
“Is Marcus alive?”
• Now, let us try to prove “Marcus is not alive”.
¬alive(Marcus, now)
↑ (8, substitution)
dead(Marcus, now)
↑ (9, substitution)
died(Marcus, t1) ˄ gt(now, t1)
↑ (5, substitution)
Pompeian(Marcus) ˄ gt(now, 79)
↑ (2)
gt(now, 79)
` ↑ (7, substitute equals)
gt(1991, 79)
↑ (compute gt)
Nil
Since the answer obtained is nil, so the given set of predicates satisfy the desired
goal.
A.I, KCS-071, Manoj Mishra 34
Hence, Marcus is not alive. (proved)
Computable functions and predicates
• Another way of proving that “Marcus is not alive”.
¬alive(Marcus, now)
↑ (8, substitution)
dead(Marcus, now)
↑ (6, substitution)
mortal(Marcus) ˄ born(Marcus, t1) ˄ gt(now – t1, 150)
↑ (4, substitution)
man(Marcus) ˄ born(Marcus, t1) ˄ gt(now – t1, 150)
↑ (1)
born(Marcus, t1) ˄ gt(now – t1, 150)
↑ (3)
gt(now – 40, 150)
` ↑ (7, substitute equals)
gt(1991 – 40, 150)
↑ (compute minus)
gt(1951, 150)
↑ (compute gt)
Nil
Since the answer obtained is nil, so the given set of predicates satisfy the desired goal.
Hence, Marcus is not alive. (proved)

A.I, KCS-071, Manoj Mishra 35


ARTIFICIAL INTELLIGENCE
Artificial Intelligence(AI)

UNIT-3
KNOWLEDGE
REPRESENTATION

Manoj Mishra (Asst. Professor)


Department of Computer Science & Engineering
United College of Engineering & Research,
Prayagraj
KNOWLEDGE REPRESENTATION

•Knowledge representation and reasoning (KR, KRR) is the part of


Artificial intelligence which concerned with AI agents thinking and how
thinking contributes to intelligent behavior of agents.

•It is responsible for representing information about the real world so that
a computer can understand and can utilize this knowledge to solve the
complex real world problems such as diagnosis a medical condition or
communicating with humans in natural language.

•It is also a way which describes how we can represent knowledge in


artificial intelligence. Knowledge representation is not just storing data
into some database, but it also enables an intelligent machine to learn
from that knowledge and experiences so that it can behave intelligently
like a human.
Following are the kind of knowledge which needs to be represented in
AI systems:

Object: All the facts about objects in our world domain. E.g., Guitars
contains strings, trumpets are brass instruments.

Events: Events are the actions which occur in our world.

Performance: It describe behavior which involves knowledge about


how to do things.

Meta-knowledge: It is knowledge about what we know.


Facts: Facts are the truths about the real world and what we
represent.

Knowledge-Base: The central component of the knowledge-


based agents is the knowledge base. It is represented as KB.
The Knowledgebase is a group of the Sentences (Here,
sentences are used as a technical term and not identical with
the English language).

Knowledge: Knowledge is awareness or familiarity gained by


experiences of facts, data, and situations. Following are the
types of knowledge in artificial intelligence:
Types of knowledge:

Declarative Knowledge:
•Declarative knowledge is to know about something.
•It includes concepts, facts, and objects.
•It is also called descriptive knowledge and expressed in declarative
sentences.
•It is simpler than procedural language.

2. Procedural Knowledge
•It is also known as imperative knowledge.
•Procedural knowledge is a type of knowledge which is responsible for
knowing how to do something.
•It can be directly applied to any task.
•It includes rules, strategies, procedures, agendas, etc.
•Procedural knowledge depends on the task on which it can be applied.
Meta-knowledge:
Knowledge about the other types of knowledge is called Meta-knowledge.

4. Heuristic knowledge:
•Heuristic knowledge is representing knowledge of some experts in a filed
or subject.
•Heuristic knowledge is rules of thumb based on previous experiences,
awareness of approaches, and which are good to work but not guaranteed.

5. Structural knowledge:
•Structural knowledge is basic knowledge to problem-solving.
•It describes relationships between various concepts such as kind of, part of,
and grouping of something.
•It describes the relationship that exists between concepts or objects.
Approaches to knowledge representation:

Simple relational knowledge:


It is the simplest way of storing facts which uses the relational method, and
each fact about a set of the object is set out systematically in columns.
This approach of knowledge representation is famous in database systems
where the relationship between different entities is represented.

This approach has little opportunity for inference.


Inheritable knowledge:

•In the inheritable knowledge approach, all data must be stored into a hierarchy
of classes.
•All classes should be arranged in a generalized form or a hierarchal manner. In
this approach, we apply inheritance property. Elements inherit values from
other members of a class.
•This approach contains inheritable knowledge which shows a relation between
instance and class, and it is called instance relation.
•Every individual frame can represent the collection of attributes and its value.
In this approach, objects and values are represented in Boxed nodes.
•We use Arrows which point from objects to their values.
Inferential knowledge:
•Inferential knowledge approach represents knowledge in the form
of formal logics.
•This approach can be used to derive more facts.
•It guaranteed correctness.

Example: Let's suppose there are two statements:


Marcus is a man
All men are mortal
Then it can represent as;

man(Marcus)
∀x = man (x) ----------> mortal (x)s
Procedural knowledge:
•Procedural knowledge approach uses small programs and codes
which describes how to do specific things, and how to proceed.

•In this approach, one important rule is used which is If-Then rule.

•In this knowledge, we can use various coding languages such as


LISP language and Prolog language.

•We can easily represent heuristic or domain-specific knowledge


using this approach. But it is not necessary that we can represent all
cases in this approach.
Requirements for knowledge Representation system:

1. Representational Accuracy:
KR system should have the ability to represent all kind of required
knowledge.

2. Inferential Adequacy:
KR system should have ability to manipulate the representational
structures to produce new knowledge corresponding to existing
structure.

3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the
most productive directions by storing appropriate guides.

4. Acquisitional efficiency- The ability to acquire the new knowledge


easily using automatic methods.
Techniques of knowledge representation

There are mainly four ways of knowledge representation which are given as
follows:
Logical Representation
Semantic Network Representation
Frame Representation
Production Rules
Fig: Knowledge representation Technique
Logical Representation
•Logical representation is a language with some concrete rules which
deals with propositions and has no ambiguity in representation.
•Logical representation means drawing a conclusion based on various
conditions.
•This representation lays down some important communication rules.
•It consists of precisely defined syntax and semantics which supports the
sound inference.
•Each sentence can be translated into logics using syntax and semantics.

Syntax:

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

Logical representation can be categorized into mainly two logics:


Propositional Logics
Predicate logics
Advantages of logical representation:
•Logical representation enables us to do logical reasoning.
•Logical representation is the basis for the programming languages.

Disadvantages of logical Representation:


•Logical representations have some restrictions and are challenging
to work with.
•Logical representation technique may not be very natural, and
inference may not be so efficient.
•Semantic Network Representation

•Semantic networks are alternative of predicate logic for knowledge


representation. In Semantic networks, we can represent our
knowledge in the form of graphical networks.

•This network consists of nodes representing objects and arcs which


describe the relationship between those objects.

•Semantic networks can categorize the object in different forms and


can also link those objects.

•Semantic networks are easy to understand and can be easily


extended.
•This representation consist of mainly two types of relations:
•IS-A relation (Inheritance)
•Kind-of-relation

•Example: Following are some statements which we need to


represent in the form of nodes and arcs.

Statements:
•Jerry is a cat.
•Jerry is a mammal
•Jerry is owned by Priya.
•Jerry is brown colored.
•All Mammals are animal.
In the above diagram, we have represented the different type of
knowledge in the form of nodes and arcs. Each object is
connected with another object by some relation.
Drawbacks in Semantic representation:

•Semantic networks take more computational time at runtime as we


need to traverse the complete network tree to answer some
questions.
•It might be possible in the worst case scenario that after traversing
the entire tree, we find that the solution does not exist in this
network.
•Semantic networks try to model human-like memory (Which has
1015 neurons and links) to store the information, but in practice, it
is not possible to build such a vast semantic network.

•These types of representations are inadequate as they do not have


any equivalent quantifier, e.g., for all, for some, none, etc.
•Semantic networks do not have any standard definition for the
link names.

•These networks are not intelligent and depend on the creator of


the system.

.
Advantages of Semantic network:
•Semantic networks are a natural representation of knowledge.
•Semantic networks convey meaning in a transparent manner.
•These networks are simple and easily understandable
Frame Representation

A frame is a record like structure which consists of a collection of


attributes and its values to describe an entity in the world.

Frames are the AI data structure which divides knowledge into


substructures by representing stereotypes situations.

It consists of a collection of slots and slot values. These slots may


be of any type and sizes. Slots have names and values which are
called facets.

Facets: The various aspects of a slot is known as Facets. Facets are


features of frames which enable us to put constraints on the frames.
Example: IF-NEEDED facts are called when data of any
particular slot is needed. A frame may consist of any number of
slots, and a slot may include any number of facets and facets may
have any number of values. A frame is also known as slot-filter
knowledge representation in artificial intelligence.

Frames are derived from semantic networks and later evolved into
our modern-day classes and objects. A single frame is not much
useful. Frames system consist of a collection of frames which are
connected. In the frame, knowledge about an object or event can
be stored together in the knowledge base. The frame is a type of
technology which is widely used in various applications including
Natural language processing and machine visions.
Advantages of frame representation:
•The frame knowledge representation makes the programming
easier by grouping the related data.
•The frame representation is comparably flexible and used by
many applications in AI.
•It is very easy to add slots for new attribute and relations.
•It is easy to include default data and to search for missing
values.
•Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
•In frame system inference mechanism is not be easily
processed.
•Inference mechanism cannot be smoothly proceeded by frame
representation.
•Frame representation has a much generalized approach.
Production Rules

Production rules system consist of (condition, action) pairs


which mean, "If condition then action".

It has mainly three parts:


The set of production rules
Working Memory
The recognize-act-cycle

•In production rules agent checks for the condition and if the
condition exists then production rule fires and corresponding
action is carried out.
• The condition part of the rule determines which rule may be
applied to a problem. And the action part carries out the
associated problem-solving steps.
•This complete process is called a recognize-act cycle.

•The working memory contains the description of the current


state of problems-solving and rule can write knowledge to the
working memory. This knowledge match and may fire other
rules.
•If there is a new situation (state) generates, then multiple
production rules will be fired together, this is called conflict
set. In this situation, the agent needs to select a rule from these
sets, and it is called a conflict resolution.
Example:
IF (at bus stop AND bus arrives) THEN action (get into the bus)
IF (on the bus AND paid AND empty seat) THEN action (sit down).
IF (on bus AND unpaid) THEN action (pay charges).
IF (bus arrives at destination) THEN action (get down from the bus).
Advantages of Production rule:
The production rules are expressed in natural language.
The production rules are highly modular, so we can easily
remove, add or modify an individual rule.

Disadvantages of Production rule:


Production rule system does not exhibit any learning
capabilities, as it does not store the result of the problem
for the future uses.

During the execution of the program, many rules may be


active hence rule-based production systems are inefficient.
First-Order logic:

First-order logic is also known as Predicate logic or First-order predicate logic (FOI).
First-order logic is a powerful language that develops information about the objects in a
more easy way and can also express the relationship between those objects.

It is an extension to propositional logic.

FOL is sufficiently expressive to represent the natural language statements in a concise


way.

First-order logic (like natural language) does not only assume that the world contains
facts like propositional logic but also assumes the following things in the world:

Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation
such as: the sister of, brother of, has color, comes between
Function: Father of, best friend, third inning of, end of, ......
As a natural language, first-order logic also has two main parts: Syntax &
Semantics
What is Unification?
•Unification is a process of making two different logical atomic expressions identical by finding
a substitution. Unification depends on the substitution process.
•It takes two literals as input and makes them identical using substitution.
•Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 = Ψ2𝜎, then it can be
expressed as UNIFY(Ψ1, Ψ2).
•Example: Find the MGU for Unify{King(x), King(John)}
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.
•Substitution θ = {John/x} is a unifier for these atoms and applying this substitution,
and both expressions will be identical.
•The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).
•Unification is a key component of all first-order inference algorithms.
•It returns fail if the expressions do not match with each other.
•The substitution variables are called Most General Unifier or MGU.
•E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).
•In this example, we need to make both above statements identical to each other. For
this, we will perform the substitution.
Substitute x with a, and y with f(z) in the first expression, and it will be represented as a/x and
f(z)/y.
With both the substitutions, the first expression will be identical to the second expression and
the substitution set will be: [a/x, f(z)/y].

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.
Implementation of the Algorithm
•Step.1: Initialize the substitution set to be empty.
•Step.2: Recursively unify atomic sentences:
•Check for Identical expression match.
•If one expression is a variable vi, and the other is a term ti which does not
contain variable vi, then:
•Substitute ti / vi in the existing substitutions
•Add ti /vi to the substitution setlist.
•If both the expressions are functions, then function name must be similar, and
the number of arguments must be the same in both the expression.
Introduction to Inference in AI

•In the field of Artificial Intelligence, inference is the process


of drawing logical conclusions from available knowledge or
facts.
•Two common strategies for performing inference in AI are:
forward chaining and
backward chaining.
•These methods are used to make decisions, answer queries,
or solve problems by applying logical rules to a set of facts or
initial conditions.
Forward- Chaining & Backward- Chaining

Forward Chaining:
Forward chaining is a data-driven approach to reasoning and inference.
It starts with the available facts and uses rules and knowledge to
derive new conclusions until a desired goal or conclusion is reached.
Key Steps in Forward-Chaining:
Initialization: Start with an initial set of facts or data.
Rule Application: Apply rules and knowledge to derive new facts or
conclusions.
Conflict Resolution: If multiple rules can be applied, resolve conflicts
by selecting the most appropriate rule.
Update Knowledge Base: Add newly derived facts to the knowledge
base.
Repeat: Continue this process until the goal is achieved or no further
rules can be applied.
Example of Forward Chaining

Scenario: Diagnosis of a medical condition.


Initial Facts:
The patient has a high fever.
The patient has a sore throat.
Rules:
1- If the patient has a high fever and a sore throat, then it might be a
sign of a viral infection.
2- If the patient has a viral infection, they should rest and drink fluids.
Forward Chaining Steps:
Start with the initial facts: high fever and sore throat.
Apply rule 1: A viral infection is suggested.
Update knowledge base with the derived fact.
Apply rule 2: The patient should rest and drink fluids.

In this case, forward chaining leads to the conclusion that the patient
should rest and drink fluids as a treatment for the viral infection.
Backward Chaining

Backward chaining is a goal-driven approach to reasoning and


inference. It starts with a goal or query and works backward to
determine the sequence of facts and rules needed to satisfy that
goal.
key steps in backward chaining:

Goal Setting: Begin with a specific goal or query.


Rule Selection: Select a rule that can help achieve the goal.
Subgoal Generation: Break down the goal into subgoals or
conditions that need to be satisfied.
Recursion: Apply backward chaining recursively to satisfy subgoals.
Termination: Continue until a set of facts and rules that can satisfy
the original goal is determined.
Example of Backward Chaining

Scenario: Booking a flight.


Goal: Book a flight from New York to London.
Rules:
If you want to book a flight from City A to City B, you need to find an
available flight.
Backward Chaining Steps:
Start with the goal: Book a flight from New York to London.
Apply rule 1 to generate a subgoal: Find an available flight from New
York to London.
Apply backward chaining recursively to find available flights.

Backward chaining guides the reasoning process toward the goal of


booking a flight from New York to London by breaking it down into
subgoals.
Comparison of Forward Chaining and Backward Chaining

Control Flow: Forward chaining proceeds from known facts to goals,


while backward chaining starts with the goal and works backward to
the facts.
Goal-Oriented: Backward chaining is goal-oriented and focuses on
reaching a specific target, while forward chaining is data-driven and
may explore various conclusions.
Rule Selection: Forward chaining selects rules based on available data,
while backward chaining selects rules based on the goal.
Use Cases: Forward chaining is commonly used in expert systems and
diagnostics, while backward chaining is prevalent in decision support
systems and planning.
Efficiency: The choice between the two depends on the problem;
backward chaining can be more efficient for problems with complex
goals.
Resolution

Resolution is a fundamental and powerful inference rule used in the


field of artificial intelligence and automated reasoning. It is a technique
primarily employed in the context of propositional logic and first-order
logic for logical deduction and theorem proving. Resolution is based on
the concept of refutation, which means proving the negation of a given
statement or goal.
Resolution Principle:
To derive a new clause (a disjunction of literals), resolve two clauses by
selecting complementary literals and then removing those literals.
Here's a step-by-step explanation of the resolution process:
Clause Selection: Choose two clauses that you want to resolve. These
clauses should have at least one complementary literal, i.e., one literal
should be the negation of the other.
Resolution Operation: Apply the resolution operation by unifying the
two clauses and removing the complementary literals. This unification
process generates a resolvent, which is a new clause containing the
remaining literals.
Adding Resolvent: Add the resolvent to the set of clauses.
Repeat: Continue the process until you either derive the empty clause
(representing a contradiction) or until no more resolutions can be
performed.
Example of Resolution

Let's illustrate the resolution process with an example:


Clauses:
(A ∨ B)
(¬B ∨ C)
(¬A ∨ D)
(¬C ∨ ¬D)
Goal: Prove ¬A (i.e., show that A is false).
Resolution Steps:

1- Select clauses (1) and (3) for resolution:


(A ∨ B)
(¬A ∨ D)
2- Apply resolution with A and ¬A:
(B ∨ D)
3- Add the resolvent to the set of clauses:
(B ∨ D)
4- Select clauses (2) and (4) for resolution:
(¬B ∨ C)
(¬C ∨ ¬D)
5- Apply resolution with ¬B and ¬D:
(¬B ∨ ¬D)
Resolution Steps (Contd….)

6- Add the resolvent to the set of clauses:


(¬B ∨ ¬D)
7- Select clauses (3) and (5) for resolution:
(¬A ∨ D)
(¬B ∨ ¬D)
8- Apply resolution with D and ¬D (complementary literals):
(¬A ∨ ¬B)
9- Add the resolvent to the set of clauses:
(¬A ∨ ¬B)
10- Select clauses (1) and (9) for resolution:
(A ∨ B)
(¬A ∨ ¬B)
11- Apply resolution with A and ¬A (complementary literals):
(B ∨ ¬B)
At this point, we have derived the empty clause (B ∨ ¬B), which
represents a contradiction. Therefore, the original goal ¬A has been
proven, which means that A is false.
Key Applications of Resolution

Theorem Proving: Resolution is used in automated theorem proving to


determine the validity of a logical statement or to establish the truth
or falsehood of a given proposition.
Logic Programming: It plays a crucial role in logic programming
languages like Prolog, where it is used to evaluate logical queries and
goals.
Natural Language Processing: Resolution can be applied to natural
language processing tasks, such as semantic analysis and text
understanding, to draw inferences from textual data.
Knowledge Representation: In knowledge-based systems and expert
systems, resolution is used to deduce facts and draw conclusions
based on a knowledge base of rules and facts.
Circuit Verification: Resolution can be used to verify the correctness of
digital circuits by checking for inconsistencies and contradictions in the
circuit design.
Knowledge representation

Knowledge representation is a critical component of artificial


intelligence (AI) systems. It involves the organization and
structuring of information to enable reasoning and problem-
solving.
Approaches to Knowledge Representation:
•Object-Oriented Design
•Top-Down Design
•Bottom-Up Design
Object-Oriented Design (OOD)

Object-Oriented Design (OOD) is a software engineering methodology that has been


adapted for knowledge representation in AI. In OOD, the world is represented as a
collection of objects that interact with each other. These objects encapsulate both
data (attributes) and behavior (methods). Key concepts in OOD include:
Classes: Classes are templates for objects and define their attributes and methods.
Objects: Objects are instances of classes and represent specific entities in the world.
Inheritance: Inheritance allows for the creation of new classes based on existing ones,
promoting code reuse.
Polymorphism: Polymorphism enables different classes to be treated as instances of a
common superclass, facilitating flexibility and extensibility.
Encapsulation: Encapsulation restricts access to certain data and methods, providing
control and security.
Top-Down Design

Top-Down Design is an approach to knowledge representation that starts with a high-


level, abstract view of the world and progressively refines it into more detailed and
specific representations. The key steps in Top-Down Design are as follows:
Problem Identification: Begin by identifying the problem you want to solve or the
domain you want to model.
High-Level Abstraction: Create a high-level, abstract representation of the problem,
often using ontologies or domain-specific languages.
Decomposition: Decompose the high-level abstraction into smaller, more manageable
components.
Refinement: Refine each component, adding details and specifying relationships
between them.
Implementation: Implement the detailed representations using appropriate data
structures and programming constructs.
Top-Down Design is useful when you have a clear understanding of the problem and
can define a high-level model. It promotes a structured and organized approach to
knowledge representation.
Bottom-Up Design

Bottom-Up Design is an approach that starts with specific


observations or data and builds higher-level representations from
these details. The key steps in Bottom-Up Design are as follows:
Data Collection: Collect and analyze data, observations, or facts from
the real world or a problem domain.
Pattern Recognition: Identify patterns, relationships, and structures
within the collected data.
Generalization: Generalize from the observed patterns to create
higher-level, more abstract representations.
Inference and Abstraction: Infer additional information and abstract
concepts from the observed data.
Modeling: Create a knowledge representation based on the derived
abstractions and relationships.
Bottom-Up Design Contd..

Bottom-Up Design is useful when you have a large amount of data or


when the problem domain is not well understood. It allows you to

build a representation that emerges from the data .


Choosing the Right Approach

Top-Down Design is suitable when you have a clear


understanding of the problem and can design a high-level
model that encompasses it.
Bottom-Up Design is preferable when you have a lot of data
or when you need to discover patterns and relationships
within the data.
Hybrid Approaches can combine the strengths of both
methods by first designing a high-level abstraction and then
refining it based on data-driven insights.
Introduction to Ontological Engineering

•Ontological engineering is a discipline within artificial intelligence (AI)


and knowledge representation that focuses on designing and building
ontologies.
•An ontology is a formal and explicit specification of the concepts,
relationships, and properties within a particular domain of knowledge.
•Ontological engineering plays a critical role in AI, enabling the
representation of complex knowledge structures and the development
of reasoning systems.
Categories in Ontological Engineering:

In the context of ontological engineering, categories represent a


fundamental way of classifying and organizing objects, events, and
concepts within a domain.
Categories help in structuring knowledge, and they can be hierarchical
or have various relationships.
Different aspects of categories:
1- Objects
Objects refer to tangible entities within a domain. For example, in a
medical ontology, objects could include "patients," "diseases," or
"medications." Objects are often categorized based on their properties
and relationships.
Categories in Ontological Engineering:( Contd..)

2- Events
Events represent occurrences or happenings within a domain. In a financial
ontology, events might include "stock market crashes" or "economic recessions."
Events are usually related to the objects and concepts in the ontology.
3. Mental Events and Mental Objects
In some knowledge representations, mental events and mental objects are
included to account for cognitive and psychological aspects. Mental events can
include "thoughts" or "perceptions," while mental objects may be "beliefs" or
"emotions."
4. Reasoning Systems for Categories
Ontological engineering also involves the development of reasoning systems that
can manipulate and make inferences about categories within the ontology. These
reasoning systems rely on formal logic, rule-based reasoning, or probabilistic
methods to perform tasks such as classification, deduction, and query answering.
Default Information:

In AI and knowledge representation, default information is used to make inferences


when complete, explicit information is lacking. Default reasoning allows AI systems to
draw conclusions that are not necessarily guaranteed but are generally accepted as
plausible.
Types of Defaults
1. Presumption (Entailment)
Presumption involves assuming that if certain conditions or facts are true, a conclusion
can be presumed to be true. For example, if someone is a vegetarian (condition), you
can presume they don't eat meat (conclusion).
2. Relevance
Relevance reasoning identifies relevant information to a query or conclusion. For
instance, when asked about someone's favorite food, it's relevant to consider their
nationality.
3. Specificity
Specificity reasoning involves being more specific when making inferences. For
example, if someone is a vegetarian but loves sushi, their dietary preference may be
more specific than the general presumption.
Applications of Default Reasoning

Default reasoning is applied in various AI domains:


Expert Systems: In expert systems, default rules are used to
make educated guesses and recommendations when experts'
knowledge is incomplete.
Natural Language Processing: In natural language
understanding, default inferences are made to fill gaps in text
or speech.
Cognitive Modeling: Cognitive models use default reasoning
to simulate human-like thinking and adapt to new
information.

You might also like