0% found this document useful (0 votes)
43 views

Unit 3 - 1 - Knowledge Representation

Knowledge-based agents use a knowledge base and inference system to represent knowledge about the world. The knowledge base stores facts and the inference system derives new facts. The agent perceives the environment, the inference engine uses the knowledge base to decide on actions, and learning updates the knowledge base. Common approaches to knowledge representation include simple relations, inheritance hierarchies, and inferential knowledge represented through predicate logic.

Uploaded by

Yash Solanki
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)
43 views

Unit 3 - 1 - Knowledge Representation

Knowledge-based agents use a knowledge base and inference system to represent knowledge about the world. The knowledge base stores facts and the inference system derives new facts. The agent perceives the environment, the inference engine uses the knowledge base to decide on actions, and learning updates the knowledge base. Common approaches to knowledge representation include simple relations, inheritance hierarchies, and inferential knowledge represented through predicate logic.

Uploaded by

Yash Solanki
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/ 23

Knowledge Representation

Knowledge-Based Agent in Artificial intelligence

Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and


situations.

o An intelligent agent needs knowledge about the real world for taking decisions
and reasoning to act efficiently.
o Knowledge-based agents are those agents who have the capability of maintaining an
internal state of knowledge, reason over that knowledge, update their knowledge after
observations and take actions. These agents can represent the world with some formal
representation and act intelligently.
o Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system.

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

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


o An agent Should be able to incorporate new percepts
o An agent can update the internal representation of the world
o An agent can deduce the internal representation of the world

1
o An agent can deduce appropriate actions.

The architecture of knowledge-based agent:

The above diagram is representing a generalized architecture for a knowledge-based agent. The
knowledge-based agent (KBA) take input from the environment by perceiving the environment.
The input is taken by the inference engine of the agent and which also communicate with KB to
decide as per the knowledge store in KB. The learning element of KBA regularly updates the KB
by learning new knowledge.

Knowledge base: Knowledge-base is a central component of a knowledge-based agent, it is also


known as KB. It is a collection of sentences (here 'sentence' is a technical term and it is not identical
to sentence in English). These sentences are expressed in a language which is called a knowledge
representation language. The Knowledge-base of KBA stores fact about the world.

Why use a knowledge base?

Knowledge-base is required for updating knowledge for an agent to learn with experiences and
take action as per the knowledge.

Inference system

Inference means deriving new sentences from old. Inference system allows us to add a new
sentence to the knowledge base. A sentence is a proposition about the world. Inference system
applies logical rules to the KB to deduce new information.

2
Inference system generates new facts so that an agent can update the KB. An inference system
works mainly in two rules which are given as:

o Forward chaining
o Backward chaining

Operations Performed by KBA

Following are three operations which are performed by KBA in order to show the intelligent
behavior:

1. TELL: This operation tells the knowledge base what it perceives from the environment.
2. ASK: This operation asks the knowledge base what action it should perform.
3. Perform: It performs the selected action.

KNOWLEDGE REPRESENTATION:-
 For the purpose of solving complex problems cencountered in AI, we need both a large
amount of knowledge and some mechanism for manipulating that knowledge to create
solutions to new problems.
 A variety of ways of representing knowledge (facts) have been exploited in AI programs.
In all variety of knowledge representations , we deal with two kinds of entities.
A. Facts: Truths in some relevant world. These are the things we want to represent.
B. Representations of facts in some chosen formalism : these are things we will
actually be able to manipulate.
 One way to think of structuring these entities is at two levels :
(a) the knowledge level, at which facts are described, and
(b) the symbol level, at which representations of objects at the knowledge level are
defined in terms of symbols that can be manipulated by programs.

Representations and Mappings


 Knowledge and Representation are two distinct entities. They play central but
distinguishable roles in the intelligent system.
 Knowledge is a description of the world. It determines a system’s competence by what it
knows.
 Moreover, Representation is the way knowledge is encoded. It defines a system’s
performance in doing something.
 Different types of knowledge require different kinds of representation.

3
 The facts and representations are linked with two-way mappings. This link is called
representation mappings. The forward representation mapping maps from facts to
representations.
 The backward representation mapping goes the other way, from representations to facts.
One common representation is natural language (particularly English) sentences.
 Regardless of the representation for facts we use in a program , we may also need to be
concerned with an English representation of those facts in order to facilitate getting
information into and out of the system.
 We need mapping functions from English sentences to the representation we actually use
and from it back to sentences.

4
Framework of Knowledge Representation
 The computer requires a well-defined problem description to process and provide a
welldefined acceptable solution.
 Moreover, To collect fragments of knowledge we need first to formulate a description in
our spoken language and then represent it in formal language so that computer can
understand.
 Also, The computer can then use an algorithm to compute an answer. So, This process
illustrated as,

The steps are:


 The informal formalism of the problem takes place first.
 It then represented formally and the computer produces an output.
 This output can then represented in an informally described solution that user understands
or checks for consistency. The Problem solving requires,
 Formal knowledge representation, and
 Moreover, Conversion of informal knowledge to a formal knowledge that is the
conversion

5
Approaches to Knowledge Representation
A good knowledge representation enables fast and accurate access to knowledge and
understanding of the content.
A knowledge representation system should have following properties.
1. Representational Adequacy(Acceptability)
 The ability to represent all kinds of knowledge that are needed in that domain.
2. Inferential Adequacy
 Also, The ability to manipulate the representational structures to derive new structures
corresponding to new knowledge inferred from old.
3. Inferential Efficiency
 The ability to incorporate additional information into the knowledge structure that can
be used to focus the attention of the inference mechanisms in the most promising
direction.
4. Acquisitional Efficiency
 Moreover, The ability to acquire new knowledge using automatic methods wherever
possible rather than reliance on human intervention.

1. Simple relational knowledge:

o 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.
o This approach of knowledge representation is famous in database systems where the
relationship between different entities is represented.
o This approach has little opportunity for inference.

Example: The following is the simple relational knowledge representation.

Player Weight Age

Player1 65 23

Player2 58 18

Player3 75 24

6
2. Inheritable knowledge:

Here the knowledge elements inherit attributes from their parents.


 The knowledge embodied in the design hierarchies found in the functional, physical and
process domains.
 Within the hierarchy, elements inherit attributes from their parents, but in many cases, not all
attributes of the parent elements prescribed to the child elements.
 Also, The inheritance is a powerful form of inference, but not adequate.

 Moreover, The basic KR (Knowledge Representation) needs to augment with inference


mechanism.
 Property inheritance: The objects or elements of specific classes inherit attributes and values
from more general classes.
 So, The classes organized in a generalized hierarchy.
 Boxed nodes — objects and values of attributes of objects.
 Arrows — the point from object to its value.

7
3.Inferential Knowledge
 This knowledge generates new information from the given information.

 This new information does not require further data gathering form source but does require
analysis of the given information to generate new knowledge.
 Example: given a set of relations and values, one may infer other values or relations. A
predicate logic (a mathematical deduction) used to infer from a set of attributes. Moreover,
Inference through predicate logic uses a set of logical operations to relate individual data.
 Represent knowledge as formal logic: All dogs have tails ∀x: dog(x) → hastail(x)
 Advantages:
 A set of strict rules.
 Can use to derive more facts.
 Also, Truths of new statements can be verified.
 Guaranteed correctness.

 So, Many inference procedures available to implement standard rules of logic popular in AI
systems. e.g Automated theorem proving.

o Example: Let's suppose there are two statements:


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

man(Marcus)
∀x = man (x) ----------> mortal (x)s

4.Procedural Knowledge

o Procedural knowledge approach uses small programs and codes which describes how to do
specific things, and how to proceed.
o In this approach, one important rule is used which is If-Then rule.
o In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
o We can easily represent heuristic or domain-specific knowledge using this approach.
o But it is not necessary that we can represent all cases in this approach.

8
Propositional logic in Artificial intelligence
Propositional logic is a fundamental part of artificial intelligence and computer science. It is a
branch of mathematical logic that deals with the study of propositions, their truth values, and the
logical relationships that exist between them. Propositional logic forms the basis for many AI
systems, including expert systems, rule-based systems, and natural language processing.

 Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions.
 A proposition is a declarative statement which is either true or false. It is a technique of
knowledge representation in logical and mathematical form.

Example:

a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.

Following are some basic facts about propositional logic:

o Propositional logic is also called Boolean logic as it works on 0 and 1.


o In propositional logic, we use symbolic variables to represent the logic, and we can use any
symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
o Propositions can be either true or false, but it cannot be both.
o Propositional logic consists of an object, relations or function, and logical connectives.
o These connectives are also called logical operators.
o The propositions and connectives are the basic elements of the propositional logic.
o Connectives can be said as a logical operator which connects two sentences.
o A proposition formula which is always true is called tautology, and it is also called a valid
sentence.
o A proposition formula which is always false is called Contradiction.
o Statements which are questions, commands, or opinions are not propositions such as
"Where is Rohini", "How are you", "What is your name", are not propositions.

9
Syntax of propositional logic:

The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:

Atomic Propositions

Compound propositions

Atomic Proposition: Atomic propositions are the simple propositions. It consists of a single
proposition symbol. These are the sentences which must be either true or false.

Example:

a) 2+2 is 4, it is an atomic proposition as it is a true fact.

b) "The Sun is cold" is also a proposition as it is a false fact.

Compound proposition: Compound propositions are constructed by combining simpler or atomic


propositions, using parenthesis and logical connectives.

Example:

a) "It is raining today, and street is wet."


b) "Ankit is a doctor, and his clinic is in Mumbai."

Logical Connectives:

Logical connectives are used to connect two simpler propositions or representing a sentence
logically. We can create compound propositions with the help of logical connectives. There are
mainly five connectives, which are given as follows:

1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either Positive


literal or negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,

10
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called disjunction,
where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Engineer, so we can write it as P ∨ Q.
4. Implication: A sentence such as P → Q, is called an implication. Implications are also
known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I am
breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.

Following is the summarized table for Propositional Logic Connectives:

Truth Table:

In propositional logic, we need to know the truth values of propositions in all possible scenarios.
We can combine all the possible combination with logical connectives, and the representation of
these combinations in a tabular format is called Truth table. Following are the truth table for all
logical connectives:

11
12
Logical equivalence:

Logical equivalence is one of the features of propositional logic. Two propositions are said to be
logically equivalent if and only if the columns in the truth table are identical to each other.

Let's take two propositions A and B, so for logical equivalence, we can write it as A⇔B. In below
truth table we can see that column for ¬A∨ B and A→B, are identical hence A is Equivalent to B

Properties of Operators:

o Commutativity:
o P∧ Q= Q ∧ P, or
o P ∨ Q = Q ∨ P.
o Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
o Identity element:
o P ∧ True = P,
o P ∨ True= True.
o Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
o DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
o Double-negation elimination:
o ¬ (¬P) = P.

13
Limitations of Propositional logic:

o We cannot represent relations like ALL, some, or none with propositional logic. Example:
a. All the girls are intelligent.
b. Some apples are sweet.
o Propositional logic has limited expressive power: Propositional logic is limited in its
ability to represent complex relationships between objects or concepts. It can only express
simple propositional statements with binary truth values (true/false). This makes it difficult
to represent concepts such as uncertainty, ambiguity, and vagueness.
o Difficulty with recursive structures: Propositional logic struggles to represent recursive
structures, such as lists or trees, which are common in many AI applications. Recursive
structures require a more expressive language, such as first-order logic or higher-order
logic.

14
First-Order Logic in Artificial intelligence

In the topic of Propositional logic, we have seen that how to represent statements using
propositional logic. But unfortunately, in propositional logic, we 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.

o "Some humans are intelligent", or


o "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some more powerful
logic, such as first-order logic.

First-Order logic:

o First-order logic is another way of knowledge representation in artificial intelligence. It is


an extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language statements in a concise
way.
o First-order logic is also known as Predicate logic or First-order predicate logic. 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.
o 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:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
o 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
o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
a. Syntax
b. Semantics

15
Syntax of First-Order logic:

The syntax of FOL determines which collection of symbols is a logical expression in first-order
logic. The basic syntactic elements of first-order logic are symbols. We write statements in short-
hand notation in FOL.

Basic Elements of First-order logic:

Following are the basic elements of FOL syntax:

Constant 1, 2, A, John, Mumbai, cat

Variables x, y, z, a, b,....

Predicates Brother, Father, >

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃

Atomic sentences:

o 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.
o We can represent atomic sentences as Predicate (term1, term2, ......, term n).

Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).


Chinky is a cat: => cat (Chinky).

Complex Sentences:

o Complex sentences are made by combining atomic sentences using connectives.

16
First-order logic statements can be divided into two parts:

o Subject: Subject is the main part of the statement.


o 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.

Quantifiers in First-order logic:

o A quantifier is a language element which generates quantification, and quantification


specifies the quantity of specimen in the universe of discourse.
o 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:
a. Universal Quantifier, (for all, everyone, everything)
b. Existential quantifier, (for some, at least one).

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.

Note: In universal quantifier we use implication "→".

If x is a variable, then ∀x is read as:

o For all x
o For each x
o For every x.

17
Example:

All man drink coffee.

Let a variable x which refers to a cat so all x can be represented in UOD as below:

∀x man(x) → drink (x, coffee).

It will be read as: There are all x where x is a man who drink coffee.

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.

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).

If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:

o There exists a 'x.'


o For some 'x.'
o For at least one 'x.'

Example:

Some boys are intelligent.

∃x: boys(x) ∧ intelligent(x)

It will be read as: There are some x where x is a boy who is intelligent.

Points to remember:

o The main connective for universal quantifier ∀ is implication →.


o The main connective for existential quantifier ∃ is and ∧.

Properties of Quantifiers:

o In universal quantifier, ∀x∀y is similar to ∀y∀x.

18
o In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o ∃x∀y is not similar to ∀y∃x.

Some Examples of FOL using quantifier:

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).

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)].

Free and Bound Variables:

The quantifiers interact with variables which appear in a suitable way. 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.

19
Difference between Procedural Knowledge and Declarative Knowledge

The following table highlights the important differences between Procedural Knowledge and
Declarative Knowledge −

Key Procedural Knowledge Declarative Knowledge

Meaning Procedural knowledge provides the Declarative knowledge provides


knowledge of how a particular task can the basic knowledge about
be accomplished. something.

Alternate name Procedural knowledge is also termed as Declarative knowledge is also


imperative knowledge. termed as functional knowledge

Basis Procedural knowledge revolves Declarative knowledge revolves


around the "How" of the concept. around the "What" of the concept.

Communication Procedural knowledge is difficult to Declarative knowledge is easily


communicate. communicable.

Orientation Procedural knowledge is process- Declarative knowledge is data-


oriented. oriented.

Validation Validation is not very easy in procedural Validation is quite easy in


knowledge. declarative knowledge.

Debugging Debugging is not very easy in procedural Debugging is quite easy in


knowledge. declarative knowledge.

Use Procedural knowledge is less commonly Declarative knowledge is more


used. general.

Representation Procedural knowledge is represented by a Declarative knowledge is


set of rules. represented by production
systems.

20
Source Procedural knowledge is obtained from Declarative knowledge is obtained
actions, experiences, subjective insights, from principles, procedures, con
etc.
cepts, processes, etc.

Forward Chaining and backward chaining in AI

In artificial intelligence, forward and backward chaining is one of the important topics, but before
understanding forward and backward chaining lets first understand that from where these two
terms came.

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. The first
inference engine was part of the expert system. Inference engine commonly proceeds in two
modes, which are:

1. Forward chaining
2. Backward chaining

Horn Clause and Definite clause:

Horn clause and definite clause are the forms of sentences, which enables knowledge base to use
a more restricted and efficient inference algorithm. Logical inference algorithms use forward and
backward chaining approaches, which require KB in the form of the first-order definite clause.

Definite clause: A clause which is a disjunction of literals with exactly one positive literal is
known as a definite clause or strict horn clause.

Horn clause: A clause which is a disjunction of literals with at most one positive literal is known
as horn clause. Hence all the definite clauses are horn clauses.

Example: (¬ p V ¬ q V k). It has only one positive literal k.

It is equivalent to p ∧ q → k.

A. Forward Chaining

Forward chaining is also known as a forward deduction or forward reasoning method when using
an inference engine. 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.

21
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.

Properties of Forward-Chaining:

o It is a down-up approach, as it moves from bottom to top.


o It is a process of making a conclusion based on known facts or data, by starting from the
initial state and reaches the goal state.
o Forward-chaining approach is also called as data-driven as we reach to the goal using
available data.
o Forward -chaining approach is commonly used in the expert system, such as CLIPS,
business, and production rule systems.

Consider the following famous example which we will use in both approaches:

B. Backward Chaining:

Backward-chaining is also known as a backward deduction or backward reasoning method when


using an inference engine. A backward chaining algorithm is a form of reasoning, which starts
with the goal and works backward, chaining through rules to find known facts that support the
goal.

Properties of backward chaining:

o It is known as a top-down approach.


o Backward-chaining is based on modus ponens inference rule.
o In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
o It is called a goal-driven approach, as a list of goals decides which rules are selected and
used.
o Backward -chaining algorithm is used in game theory, automated theorem proving tools,
inference engines, proof assistants, and various AI applications.
o The backward-chaining method mostly used a depth-first search strategy for proof.

22
S. Forward Chaining Backward Chaining
No.

1. Forward chaining starts from known Backward chaining starts from the goal
facts and applies inference rule to and works backward through inference
extract more data unit it reaches to rules to find the required facts that
the goal. support the goal.

2. It is a bottom-up approach It is a top-down approach

3. Forward chaining is known as data- Backward chaining is known as goal-


driven inference technique as we driven technique as we start from the
reach to the goal using the available goal and divide into sub-goal to extract
data. the facts.

4. Forward chaining reasoning applies a Backward chaining reasoning applies a


breadth-first search strategy. depth-first search strategy.

5. Forward chaining tests for all the Backward chaining only tests for few
available rules required rules.

6. Forward chaining is suitable for the Backward chaining is suitable for


planning, monitoring, control, and diagnostic, prescription, and debugging
interpretation application. application.

7. Forward chaining can generate an Backward chaining generates a finite


infinite number of possible number of possible conclusions.
conclusions.

8. It operates in the forward direction. It operates in the backward direction.

9. Forward chaining is aimed for any Backward chaining is only aimed for the
conclusion. required data.

23

You might also like