UNIT 2 AI
UNIT 2 AI
Representation
The importance of knowledge
representation
Contrary to the beliefs of early workers in AI, experience has shown that
Intelligent Systems cannot achieve anything useful unless they contain a large
amount of real-world - probably domain-specific - knowledge.
Humans almost always tackle difficult real-world problems by using their
resources of knowledge - "experience", "training" etc.
This raises the problem of how knowledge can be represented inside a computer,
in such a way that an AI program can manipulate it.
Definition and importance of knowledge
What is knowledge representation?
Humans are best at understanding, reasoning, and interpreting knowledge.
Human knows things, which is knowledge and as per their knowledge they perform various actions in
the real world.
But how machines do all these things comes under knowledge representation and
reasoning.
Hence we can describe Knowledge representation as following:
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.
What kind of knowledge to
Represent:
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).
Categories of knowledge
Knowledge can be categorized into two major types:
• Tacit knowledge
• Explicit knowledge
Tacit knowledge is the knowledge which exists within a
human being. It does correspond to informal or implicit
type of knowledge. It is quite difficult to articulate
formally and is also difficult to communicate and share.
Explicit knowledge is the knowledge which exists outside
a human being. It corresponds to formal type of
knowledge. It is easier to articulate compared to tacit
knowledge and is easier to share, store or even process.
Types of knowledge
1. 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.
3. 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 field 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.
The relation between knowledge and intelligence:
Knowledge module is KB
Control Module is Inference Engine
The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
1. Atomic Propositions
2. 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,
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 Doctor, 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.
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:
Truth table for 3 propositions
Precedence of connectives
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction(AND)
Fourth Precedence Disjunction(OR)
Fifth Precedence Implication
Six Precedence Biconditional
Note: For better understanding use parenthesis to make sure of the correct
interpretations. Such as ¬R∨ Q, It can be interpreted as (¬R) ∨ Q.
Logical Equivalence
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,.... An individual constant represents a specific object
and is notated a, b, c,….
Variables .... An individual variable represents any object and notated x, y, z,
….
Predicates Brother, Father, .... A predicate symbol represents a predicate for
objects and is notated P(x, y), Q(z),…, where P and Q are predicate symbols.
Function sqrt, .... A functional symbol represents a relation between or among
objects and is notated f(x, y), g(z, w),…. Here the functional symbol g shows the
relationship between z and w
Connectives ∧, ∨, ¬, ⇒, ⇔A logical symbol represents an operation on predicate
symbols and is notated ↔, ~,→,∨, or ∧
Equality ==
Quantifier ∀, ∃
Predicate sentences
Atomic sentences
Complex Sentences
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.
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:
Complex sentences are made by combining atomic sentences using connectives.
First-order logic statements can be divided into two parts:
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:
The main connective for universal quantifier ∀ is implication →
For all x
For each x
For every x.
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 ∃ x is read as: •The main connective for existential quantifier ∃ is and ∧.
For some x
For one x
Ex1. Some boys are intelligent
∃x: boys(x) ∧ intelligent(x)
Ex2. Some cats are white color
∃ x: cats(x)^ white(x,color)
Some boys are intelligent
A ⇒ B, and A ⇔ B 1. ¬P
2. P ∧ Q
Example translating English to WFF 3. P ∨ Q
4. P ∧ ¬Q (note: “but” becomes
1.Maxi doesn’t like cat “and”)
2. Maxi likes cat and likes dog 5. P ⇒ ¬Q
3. Maxi likes cat or dog
The rule-based method of knowledge representation uses IF-THEN rules (sometimes called
conditionaction rules) to specify the knowledge.
All the rules for a particular problem form the rules-base, and the knowledge-base
comprises three components: the list of rules in the rules-base; the list of known facts in
the facts-base; and an inferencing system, which processes the rules to derive new facts
via some form of reasoning.
A rule consists of an IF part which is a set of conditions (called the antecedents) that must
be met before the rule is said to ‘fire’ so that the set of actions in the THEN part (called
the consequents) are executed.
For example, for Rule R1 in Table, if the condition ‘animal has hair’ is met–that is, there is a
known fact in the knowledge base that the animal being classified has hair, then the rule is
fired,and the action is to add a further fact ‘species is mammal’ to the knowledge-base.
There may be multiple conditions in the IF part of the rule.For example, Rule R4 has three
conditions that must be met before it can be fired.
These conditions are separated by the AND keyword, and therefore these conditions are
called ‘conjunctions’. If they were separated by the OR keyword, they would be called
‘disjunctions’.
Representation using Structured
Knowledge
Representing knowledge using logical formalism, like predicate logic, has several advantages. They can be combined with
powerful inference mechanisms like resolution, which makes reasoning with facts easy. But using logical formalism complex
structures of the world, objects and their relationships, events, sequences of events etc. can not be described easily.
A good system for the representation of structured knowledge in a particular domain should posses the following four properties:
(i) Representational Adequacy:- The ability to represent all kinds of knowledge that are needed in that domain.
(ii) Inferential Adequacy :- The ability to manipulate the represented structure and infer new structures.
(iii) Inferential Efficiency:- The ability to incorporate additional information into the knowledge structure that will aid the
inference mechanisms.
(iv) Acquisitional Efficiency :- The ability to acquire new information easily, either by direct insertion or by program control.
Objectives of any AI should be
Frames and scripts are used very extensively in a variety of AI programs. Before selecting any
specific knowledge representation structure, the following issues have to be considered.
(i) The basis properties of objects , if any, which are common to every problem domain must
be identified and handled appropriately.
(iii) Mechanisms must be devised to access relevant parts in a large knowledge base.
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
1. 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.
Syntax semantics
• It decides how we can convert • Semantics are the rules which we
legal sentence in logic can interpret the sentence in the
• It determines which symbol we can logic
use in knowledge representation
• it assigns a meaning to each
• Also how to write those symbols sentence.
2. 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.
Another example
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.
3. 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.
Example 2
Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and his age is 25, he
lives in city London, and the country is England. So following is the frame representation for this:
Slots Filter
Name Peter
Profession Doctor
Age 25
Marital status Single
Weight 78
Example: 1
Slots Filters
Title Artificial Intelligence
Genre Computer Science
Author Peter Norvig
Edition Third Edition
Year 1996
Page 1152
Frame Representation…..
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.
Associative network
An associate memory network refers to a content addressable memory
structure that associates a relationship between the set of input
patterns and output patterns. A content addressable memory structure
is a kind of memory structure that enables the recollection of data based
on the intensity of similarity between the input pattern and the patterns
stored in the memory.
Let's understand this concept with an example:
The figure given below illustrates a memory
containing the names of various people. If
the given memory is content addressable,
the incorrect string "Albert Einstein" as a key
is sufficient to recover the correct name
"Albert Einstein."