AI Unit-2
AI Unit-2
Artificial Intelligence
UNIT II
KNOWLEDGE AND REASONING – I (9 Hrs)
Knowledge Representation: Knowledge Representation-Knowledge based Agents - Propositional
Logic-Predicate Logic-Unification and Lifting - Forward Chaining-Backward Chaining –
Representing Knowledge using Rules-Semantic Networks - Frame Systems
Q. knowledge Representation:
• Knowledge is a theoretical or practical understanding of a subject or a domain. Knowledge
is also the sum of what is currently known, and apparently knowledge is power. Those who
possess knowledge are called experts.
• Anyone can be considered a domain expert if he or she has deep knowledge (of both facts and
rules) and strong practical experience in a particular domain. The area of the domain may be
limited. In general, an expert is a skilful person who can do things other people cannot.
Let us first consider what kinds of knowledge might need to be represented in AI systems:
1. Objects -Facts about objects in our world domain. e.g. Guitars have strings, trumpets
III YR /VI SEM Page 1
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
Thus in solving problems in AI we must represent knowledge and there are two entities to deal with:
Facts - truths about the real world and what we represent. This can be regarded as
theknowledge level.
Representation - which we manipulate. This can be regarded as the symbol level of the facts
since we usually define the representation in terms of symbols that can be manipulated by
programs.
English or natural language is an obvious way of representing and handling facts. Logic
enables us to consider the following fact: spot is a dog as dog(spot) We could then infer that all
dogs have tails with:
hasatail(Spot)
Using an appropriate backward mapping function the English sentence Spot has a tail can be
generated.The available functions are not always one to one but rather are many to many which is a
characteristic of English representations. The sentences All dogs have tails and every dog has a tail
III YR /VI SEM Page 2
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
both say that each dog has a tail but the first could say that each dog has more than one tail try
substituting teeth for tails. When an AI program manipulates the internal representation of facts
these new representations should also be interpretable as new representations of facts.
Using Knowledge- We have briefly mentioned where knowledge is used in AI systems. Let us
consider a little further to what applications and how knowledge may be used.
Learning – (Acquiring knowledge) This is more than simply adding new facts to a knowledge
base. New data may have to be classified prior to storage for easy retrieval, etc. Interaction and
inference with existing facts to avoid redundancy and replication in the knowledge and also so
that facts can be updated.
Retrieval - The representation scheme used can have a critical effect on the efficiency of the
method. Humans are very good at it.
However a question like Can Miles Davis play his instrument well? requires reasoning.
The above are all related. For example, it is fairly obvious that learning and reasoning involve
retrieval etc.
The natural language reasoning requires inferring hidden state, namely, the intention of the speaker.
When we say, "One of the wheel of the car is flat.", we know that it has three wheels left. Humans
can cope with virtually infinite variety of utterances using a finite store of commonsense
knowledge.
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: The atomic symbols of the logical language, and the rules for constructing well-
formed, non-atomic expressions (symbol structures) of the logic.
Semantics: The meanings of the atomic symbols of the logic, and the rules for determining the
III YR /VI SEM Page 3
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
meanings of non-atomic expressions of the logic. It specifies what facts in the world a sentence
refers to. Hence, also specifies how you assign a truth value to a sentence based on its meaning
in the world.
Facts are claims about the world that are True or False, whereas a representation is an
expression (sentence) in some language that can be encoded in a computer program and stands
for the objects and relations in the world.
There are a number of logical systems with different syntax and semantics. We list below a few.
– Propositional logic
– All objects described are fixed or unique
"John is a student" student(john) Here John refers to one unique person.
An intelligent agent needs knowledge about the real world for taking decisions and reasoning to act efficiently.
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.
Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system.
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.
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.
Inference system generates new facts so that an agent can update the KB.
A knowledge-based agent can be viewed at different levels which are given below:
1. Knowledge level
Knowledge level is the first level of knowledge-based agent, and in this level, we need to specify what the agent
knows, and what the agent goals are. With these specifications, we can fix its behavior. For example, suppose an
automated taxi agent needs to go from a station A to station B, and he knows the way from A to B, so this comes
at the knowledge level.
2. Logical level:
At this level, we understand that how the knowledge representation of knowledge is stored. At this level,
sentences are encoded into different logics. At the logical level, an encoding of knowledge into logical sentences
occurs. At the logical level we can expect to the automated taxi agent to reach to the destination B.
3. Implementation level:
This is the physical representation of logic and knowledge. At the implementation level agent perform actions as
per logical and knowledge level. At this level, an automated taxi agent actually implement his knowledge and
logic so that he can reach to the destination.
1. 1. Declarative approach: We can create a knowledge-based agent by initializing with an empty knowledge base
and telling the agent all the sentences with which we want to start with. This approach is called Declarative
approach.
2. 2. Procedural approach: In the procedural approach, we directly encode desired behavior as a program code.
Which means we just need to write a program that already encodes the desired behavior or agent.
However, in the real world, a successful agent can be built by combining both declarative and procedural
approaches, and declarative knowledge can often be compiled into more efficient procedural code.
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. 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 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.
III YR /VI SEM Page 6
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and situations.
Following are the types of knowledge in artificial intelligence:
Q. Types of knowledge
1. Declarative Knowledge:
2. Procedural Knowledge
3. Meta-knowledge:
4. Heuristic knowledge:
5. Structural knowledge:
Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial intelligence.
Knowledge plays an important role in demonstrating intelligent behavior in AI agents. An agent is only able to
accurately act on some input when he has some knowledge or experience about that input.
Let's suppose if you met some person who is speaking in a language which you don't know, then how you will
able to act on that. The same thing applies to the intelligent behavior of the agents.
In the below diagram, there is one decision maker which act by sensing the environment and using knowledge.
But if the knowledge part will not present then, it cannot display intelligent behavior.
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent behavior:
Perception
Learning
Knowledge Representation and Reasoning
Planning
Execution
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent behavior:
Perception
III YR /VI SEM Page 8
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
Learning
Knowledge Representation and Reasoning
Planning
Execution
The above diagram is showing how an AI system can interact with the real world and what components help it to show
intelligence. AI system has Perception component by which it retrieves information from its environment. It can be visual,
audio or another form of sensory input. The learning component is responsible for learning from data captured by
Perception comportment. In the complete cycle, the main components are knowledge representation and Reasoning. These
two components are involved in showing the intelligence in machine-like humans. These two components are independent
with each other but also coupled together. The planning and execution depend on analysis of Knowledge representation
and reasoning.
There are mainly four approaches to knowledge representation, which are givenbelow:
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.
2. 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.
III YR /VI SEM Page 9
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
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.
1. 1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.
2. 2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to produce new knowledge
corresponding to existing structure.
3. 3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most productive directions by storing
appropriate guides.
4. 4. Acquisitional efficiency- The ability to acquire the new knowledge easily using automatic methods.
There are mainly four ways of knowledge representation which are given as follows:
1. Logical Representation
2. Semantic Network Representation
3. Frame Representation
4. Production Rules
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.
1. Propositional Logics
2. Predicate logics
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.
Example: Following are some statements which we need to represent in the form of nodes and arcs.
Statements:
1. Jerry is a cat.
2. Jerry is a mammal
3. Jerry is owned by Priya.
4. Jerry is brown colored.
5. All Mammals are animal.
. 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.
Production Rules
Production rules system consist of (condition, action) pairs which mean, "If condition then action". It has
mainly three parts:
n 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).
Overall issues
Below are listed issues that should be raised when using a knowledge representation technique:
1. Are any attributes of objects so basic that they occur in almost every problem domain?
2. Are there any important relationships that exist among attributes of objects?
3. At what level should knowledge be represented? Is there a good set of primitives into which all
knowledge can be broken down?
We will see each of these questions briefly in the next five sections.
A. Important Attributes
Are there any attributes that occur in many different types of problem? There are two instance and
isa and each is important because each supports property inheritance.
The attributes that we use to describe objects are themselves entities that we represent. What
properties do they have independent of the specific knowledge they encode? There are four such
properties that deserve are mentioned below.
1. Inverses.
2. Existence in an isa hierarchy.
3. Techniques for reasoning about values.
4. Single valued attributes.
C. Inverses
What about the relationship between the attributes of an object, such as, inverses, existence,
techniques for reasoning about values and single valued attributes. We can consider an example of
an inverse in
This can be treated as John Zorn plays in the band Naked City or John Zorn's band is
NakedCity.
Just as there are classes of objects and specialized subsets of those classes, there are attributes and
specialization of attributes. Consider for example: the attribute height. In the case of attributes they
support inheriting information about such things as constraints on the values that the attribute can
have and mechanisms for computing those values.
Sometimes values of attributes are specified explicitly when a knowledge base is created. Several
kindsof information can play a role in this reasoning including:
1. Information about the type of value- for (eg): the value of height must be a number measure in a
unit of length.
2. Constraints on the value, often stated in terms of related entities- for (eg): the age of the person
cannot be greater than the age of either of that person’s parents.
3. Rules for computing the values when it is needed.
4. Rules that describe actions that should be taken if a value ever becomes known.
A specific but very useful kind of attribute is one that is guaranteed to take a unique value. For
example: a baseball player can, at any one time, have only a single height and be a member of only
one team.
At what level should the knowledge be represented and what are the primitives. Choosing the
Granularity of Representation Primitives are fundamental concepts such as holding, seeing, playing
and as English is a very rich language with over half a million words it is clear we will find
difficulty in deciding upon which words to choose as our primitives in a series of situations.
feeds(tom, dog)
progress.
In the famous program on relationships Louise is Bill's cousin How do we represent this? louise =
daughter (brother or sister (father or mother( bill))) Suppose it is Chris then we do not know if it is
Chris as a male or female and then son applies as well.
Clearly the separate levels of understanding require different levels of primitives and these need
many rules to link together apparently similar primitives.
Obviously there is a potential storage problem and the underlying question must be what level of
comprehension is needed.
Example: Consider the assertions that are being made in the sentences “There are more sheep than
people in Australia” and “English speakers can be found all over the world.” The only way to
represent the facts described in these sentences is to attach assertions to the sets representing
people, sheep, and English speakers, since, for example, no single English speaker can be found all
over the world. The other reason that it is important to be able to represent sets of objects is that if a
property is true of all elements of a set, then it is more efficient to associate objects is that if a
property is true of all elements of a set.
Logic: The logic plays an important role in the design of almost all the systems in engineering and
sciences. Designing the present days computer is complex task. This design involves two types of
design namely
Hardware design
Software design
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.
d) 5 is a prime number.
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:
Example:
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:
Precedence of connectives:
Just like arithmetic operators, there is a precedence order for propositional connectors or logical operators. This
order should be followed while evaluating a propositional problem. Following is the list of the precedence order
for operators:
Precedence Operators
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:
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:
Commutativity:
o P∧ Q= Q ∧ P, or
o P ∨ Q = Q ∨ P.
Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
Identity element:
o P ∧ True = P,
o P ∨ True= True.
Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
Double-negation elimination:
o ¬ (¬P) = P.
We cannot represent relations like ALL, some, or none with propositional logic. Example:
1. All the girls are intelligent.
2. Some apples are sweet.
Propositional logic has limited expressive power.
In propositional logic, we cannot describe statements in terms of their properties or logical relationships.
• In artificial intelligence, we need intelligent computers which can create new logic from old logic or by evidence,
so generating the conclusions from evidence and facts is termed as Inference.
•
• Inference rules:
• Inference rules are the templates for generating valid arguments. Inference rules are applied to derive proofs in
artificial intelligence, and the proof is a sequence of the conclusion that leads to the desired goal.
•
• Following are some terminologies related to inference rules:
• Implication: It is one of the logical connectives which can be represented as P → Q. It is a Boolean expression.
• Converse: The converse of implication, which means the right-hand side proposition goes to the left-hand side
and vice-versa. It can be written as Q → P.
• Contrapositive: The negation of converse is termed as contrapositive, and it can be represented as ¬ Q → ¬ P.
• Inverse: The negation of implication is called inverse. It can be represented as ¬ P → ¬ Q.
• From the above term some of the compound statements are equivalent to each other, which we can prove using
truth table:
• Hence from the above truth table, we can prove that P → Q is equivalent to ¬ Q → ¬ P, and Q→ P is equivalent to
¬P→¬Q
a. Modus Ponens: This rule is also called rule of detachment. Symbolically it iswritten as
[p∧(p→q)] →q
Or
P
p→q
Solution: The above statements can be specified in the form of logical implication if the
followingpropositional symbols are assigned to statements:
p= rajini is preparing food in
kitchenq= rajini is playing violin
r= rajini is learning music
now, the argument can be expressed in the form of a propositional formula:
p∧((p→ ¬q) ∧(¬q→¬r)] →¬r
the above wff can also be represented in the tabular form along with inference as follows
p
p→¬q
¬q→¬r
pq
p∧q ( p and q can be wriiten as p∧q)
¬p
“if the auditorium was not available or there were examinations, then the music programme was
postponed. If the music programme gets postponed, then a new date was announced. No new date was
III YR /VI SEM Page 22
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
Solution: Let us assume that following are symbols for the statements (propositions) in the above
argument.
P= auditorium was available
Q= there were examination
R= music programme was postponed
S= new date was announced
The statements can be expressed in the form of logical expressions given as follows.
(¬p∨q) →r
r→s
¬s
Q. Wumpus game
• The Wumpus world is a simple world example to illustrate the worth of a knowledge-based agent and to represent
knowledge representation.
• It was inspired by a video game Hunt the Wumpus by Gregory Yob in 1973.
• The Wumpus world is a cave which has 4/4 rooms connected with passageways.
• So there are total 16 rooms which are connected with each other.
• We have a knowledge-based agent who will go forward in this world.
• The cave has a room with a beast which is called Wumpus, who eats anyone who enters the room
• The Wumpus can be shot by the agent, but the agent has a single arrow.
• In the Wumpus world, there are some Pits rooms which are bottomless, and if agent falls in Pits, then he will be
stuck there forever.
• The exciting thing with this cave is that in one room there is a possibility of finding a heap of gold.
• So the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten by Wumpus
•
• The agent will get a reward if he comes out with gold, and he will get a penalty if eaten by Wumpus or falls in the
pit.
• Following is a sample diagram for representing the Wumpus world.
• It is showing some rooms with Pits, one room with Wumpus and one agent at (1, 1) square location of the world.
• There are also some components which can help the agent to navigate the cave. These components are given
III YR /VI SEM Page 23
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
as follows:
• The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
• The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will perceive the breeze.
• There will be glitter in the room if and only if the room has gold.
• The Wumpus can be killed by the agent if the agent is facing to it, and Wumpus will emit a horrible scream which
can be heard anywhere in the cave.
Sensors:
• The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally).
• The agent will perceive breeze if he is in the room directly adjacent to the Pit.
• The agent will perceive the glitter in the room where the gold is present.
• The agent will perceive the bump if he walks into a wall.
• When the Wumpus is shot, it emits a horrible scream which can be perceived anywhere in the cave.
• These percepts can be represented as five element list, in which we will have different indicators for each sensor.
• Example if agent perceives stench, breeze, but no glitter, no bump, and no scream then it can be represented as:
[Stench, Breeze, None, None, None].
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, ......
Basic idea: The word “predicate” means to declare or affirm concerning the subject of a preposition. For
example, in the sentence, “He was a king”, “king” is a predicate noun. Let us consider the following two
statements represented as proposition.
the above representations in predicate form shows that there is some common feature is s(R)and
s(K), because both have common predicate, i.e student. If all the students in a class are to be
represented using this form, we use a variable for student name. Therefore, the statements, “x is a
student” can be represented in predicate form as s(x).
There exists
Implies
Not
Or
And
Let the expressions – fatherof(Rohit), and motherof(Rohit), be functions and their values are “Rajan”
and “Sheela” respectively. Using above expressions, the predicate.
Spouse(Rajan, Sheela),
Can be written
as spouse (fatherof(Rohit), motherof(Rohit)).
A function may have any number of objects, called arity of the functions. For example, if Rohit
andRajini are brother-sisters, then the functions.
We briefly mentioned how logic can be used to represent simple facts in the last lecture. Here we
will highlight major principles involved in knowledge representation. In particular predicate logic
will be met in other knowledge representation schemes and reasoning methods.
Symbols used the following standard logic symbols we use in this course are:
Let’s first explore the use of propositional logic as a way of representing the sort of world
knowledge that an AI system might need. Propositional logic is appealing because it is simple to
deal with and a decision procedure for it exists. Suppose we want to represent the obvious fact
stated by the classical sentence.
It is raining.
RAINING
It is sunny
SUNNY
sunny.RAINING SUNNY
Let’s now explore the use of predicate logic as a way of representing knowledge by looking
at aspecific example. Consider the following set of sentences.
The facts described by these sentences can be represented as a set of wff’s in predicate logic as
follows:
Man(Marcus)
This representation captures the critical fact of marcus being a man. It fails to capture some
ofthe information in the english sentence, namely the notion of past tense.
III YR /VI SEM Page 29
ITT63 ARTIFICIAL INTELLIGENCE UNIT II
Pompeian(marcus)
x: pompeians(x) Roman(x)
ruler(Casear)
Here we ignore the fact that proper names are often not references to unique individuals,
since many people share the same name. Sometimes deciding which of several people of the
same name being referred to in a particular statement may require a fair amount of
knowledge and reasoning.
In English the word “or” sometimes means the logical inclusive or and sometimes means the
logical exclusive or (XOR). Here we have used the inclusive interpretation. Some people argue
however that this English sentence is really stating an, exclusive or. To express that, we would have
to write.
“x is human implies x is
mortal.” “Socrates is human.”
When represented in predicate form, these
become:h(x) →m(x), and
h(S)
the above two wffs have some resemblance to the premises required for the inference rule of modus
ponens. To generalize the implication, the variable x applicable for the entire human domain is
quantified using quantying operator called universal quantifier. Above statements can be
modified asfollows after incorporating the effect of quantifiers.
Terms: First order logic has sentence, but it also has terms which represents objects. Constant
symbols, variables and function symbols are used to build terms and quantifiers and predicate
symbols are usedto build sentences.
׀Quantifier variable,….sentence
׀7 sentence
(׀sentence).
(Term,…)Term Term
׀constant
׀variable
Connective
=>׀∨׀𝖠׀Quantifier ׀
QUANTIFIERS:
Quantifiers are used to express properties of entire collection of objects, rather than represent the
object by names. FOL contains two standard quantifiers,
# Universal quantifier ( )
# Existential quantifier (
UNIVERSAL QUANTIFIERS:
Universe.
Examples:
That is, all the cats in the universe belongs to the type of mammals and hence the variable X may
bereplaced by any of the cat name (object, Name)
Examples:
Spot is a cat
Spot is a
mammalCat
(spot) Mammal
(spot)
cat.
Existential Quantifiers:
universe.
Example:
X sister ( cat(X)
That is, the spot’s sister is a cat, implies spot is also a cat and hence X may be replaced by, sister
ofspot, if it exists.
Example:
Felix is a cat.
Felix is a sister of
spotCat (Felix)
NESTED QUANTIFIERS:
Example:
Y loves (X, Y)
Y X loves (X, Y)
The two Quantifiers ( and ) are actually connected with each other through negation.
Example:
The De Morgan rules for quantified and unquantified sentences are as follows,
# Quantified sentences:
X7P ≡ 7 XP
7 XP ≡ X7P
XP ≡ 7 X 7P
XP ≡ 7 X 7P
#Unquantified sentence:
7(P𝖠Q) ≡ 7P ∨ 7Q
7P 𝖠 7Q ≡ 7(P∨Q)
P 𝖠 Q ≡ 7(7P ∨
7Q)P∨ Q ≡ 7(7P 𝖠
7Q)
Q. Inference rules
All the inference rules applicable for propositional logic also apply for predicate logic. However,
due to introduction of quantifiers, additional inference rules are there for the expressions using
quantifiers. These are given below.
Example Problems:
z (k(z) →f(z))
We can arrive to formal proof for the above using following steps.
STEPS Justification
1. x (k(x) →m(x)) Given the premise
2. k(a) →m(a) By rule of universal instantiation on (1)
3. y (m(y) →f(y)) Given the premise
4. m(a) →f(a) By rule of universal instantiation on (3)
5. k(a) →f(a) By rule of syllogism using (2) and (4)
6. z (k(z) →f(z)) By rule of universal generalization on (5)
Hence it is proved.
Q. Unification:
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
Unification Algorithm:
Step. 1: If Ψ1 or Ψ2 is a variable or constant, then:
a) If Ψ1 or Ψ2 are identical, then return NIL.
b) Else if Ψ1is a variable,
a. then if Ψ1 occurs in Ψ2, then return FAILURE
b. Else return { (Ψ2/ Ψ1)}.
c) Else if Ψ2 is a variable,
If Ψ2 occurs in Ψ1 then return FAILURE,
Else return {( Ψ1/ Ψ2)}.
d) Else return FAILURE.
Step.2: If the initial Predicate symbol in Ψ1 and Ψ2 are not same, then return FAILURE.
Step. 3: IF Ψ1 and Ψ2 have a different number of arguments, then return FAILURE.
Step. 4: Set Substitution set(SUBST) to NIL.
Step. 5: For i=1 to the number of elements in Ψ1. a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2,
III YR /VI SEM Page 39
ITT63 ARTIFICIAL INTELLIGENCE UNIT 1
Properties of Forward-Chaining:
It is a down-up approach, as it moves from bottom to top.
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.
Forward-chaining approach is also called as data-driven as we reach to the goal using available data.
Forward -chaining approach is commonly used in the expert system, such as CLIPS, business, and production rule
systems.
Example:
"As per the law, it is a crime for an American to sell weapons to hostile nations. Country A, an enemy of America,
has some missiles, and all the missiles were sold to it by Robert, who is an American citizen."
Prove that "Robert is criminal."
To solve the above problem, first, we will convert all the above facts into first-order definite clauses, and then we will use
a forward-chaining algorithm to reach the goal.
Facts Conversion into FOL:
It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r are variables)
It can be written in two definite clauses by using Existential Instantiation, introducing new Constant T1.
Owns(A, T1) ......(2)
Missile(T1) .......(3)
All of the missiles were sold to country A by Robert.
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
Step-2:
At the second step, we will see those facts which infer from available facts and with satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Rule-(2) and (3) are already added.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which infers from the conjunction of
Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which infers from Rule-(7).
Step-3:
At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1, r/A}, so we can add
Criminal(Robert) which infers all the available facts. And hence we reached our goal statement.
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:
It is known as a top-down approach.
Backward-chaining is based on modus ponens inference rule.
In backward chaining, the goal is broken into sub-goal or sub-goals to prove the facts true.
It is called a goal-driven approach, as a list of goals decides which rules are selected and used.
Backward -chaining algorithm is used in game theory, automated theorem proving tools, inference engines, proof
assistants, and various AI applications.
The backward-chaining method mostly used a depth-first search strategy for proof.
Example:
In backward-chaining, we will use the same above example, and will rewrite all the rules.
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
Owns(A, T1) ........(2)
Missile(T1)
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
Missile(p) → Weapons (p) .......(5)
Enemy(p, America) →Hostile(p) ........(6)
Enemy (A, America) .........(7)
American(Robert). ..........(8)
Backward-Chaining proof:
In Backward chaining, we will start with our goal predicate, which is Criminal(Robert), and then infer further rules.
Step-1:
At the first step, we will take the goal fact. And from the goal fact, we will infer other facts, and at last, we will prove
those facts true. So our goal fact is "Robert is Criminal," so following is the predicate of it.
Step-2:
At the second step, we will infer other facts form goal fact which satisfies the rules. So as we can see in Rule-1, the
goal predicate Criminal (Robert) is present with substitution {Robert/P}. So we will add all the conjunctive facts
below the first level and will replace p with Robert.
Here we can see American (Robert) is a fact, so it is proved here.
Step-3:t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it satisfies Rule-(5).
Weapon (q) is also true with the substitution of a constant T1 at q.
Step-4:
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r) which satisfies the Rule- 4, with
the substitution of A in place of r. So these two statements are proved here.
Step-5:
At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which satisfies Rule- 6. And hence all the statements
are proved true using backward chaining
Frames are more structured form of packaging knowledge, - used for representing objects, concepts etc.
Frames are organized into hierarchies or network of frames.
Lower level frames can inherit information from upper level frames in network.
Nodes are connected using links viz.,
→ subc (links two class frames, one of which is subclass of other e.g., science_faculty class is ako of faculty
class),
→ is_a (connects a particular instance of a class frame e.g., Renuka is_a science_faculty)
→ a_part_of (connects two class frames one of which is contained in other e.g., faculty
class is_part_of department class).
→ Property link of semantic net is replaced by SLOT fields.
A frame may have any number of slots needed for describing object. e.g.,
- faculty frame may have name, age, address, qualification etc as slot names.
Each frame includes two basic element : slots and facets.
- Each slot may contain one or more facets (called fillers) which may take many forms such as :
⇒value (value of the slot),
⇒default (default value of the slot),
⇒range (indicates the range of integer or enumerated values, a slot can have),
⇒demons (procedural attachments such as if_needed, if_deleted, if_added etc.) and
⇒other (may contain rules, other frames, semantic net or any type of other information).
Description of Frames
Each frame represent either a class or an instance.
Class frame represents a general concept whereas instance frame represents a specific occurrence of the class
instance.
Class frame generally have default values which can be redefined at lower levels.
If class frame has actual value facet then decedent frames can not modify that value.
Value remains unchanged for subclasses and instances.
Inheritance in Frames
Suppose we want to know nationality or phone of an instance-frame13.