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

AI Unit-2

Uploaded by

SURIYA VARSHAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

AI Unit-2

Uploaded by

SURIYA VARSHAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

• AI agents deal with knowledge (data)


 Facts (believe & observe knowledge)
 Procedures (how to knowledge)
 Meaning (relate & define knowledge)
•Right representation is crucial
 Early realisation in AI
 Wrong choice can lead to project failure
 Active research area
• For certain problem solving techniques
 „Best‟ representation already known
 Often a requirement of the technique
 Or a requirement of the programming language (e.g. Prolog)
•Examples
 First order theorem proving… first order logic
 Inductive logic programming… logic programs
 Neural networks learning… neural networks
•Some general representation schemes
 Suitable for many different (and new) AI applicatio
o What is Knowledge .How it is represented in AI.
Some General Representations:
1.Logical Representations
2. Production Rules
3. Semantic Networks
• Conceptual graphs, frames
4. Description Logics

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

are brass instruments.


2. Events - Actions that occur in our world. e.g. Steve Vai played the guitar in Frank
Zappa's Band.
3. Performance - A behavior like playing the guitar involves knowledge about how to do
things.
4. Meta-knowledge- Knowledge about what we know. e.g. Bobrow's Robot who plan's a
trip. It knows that it can read street signs along the way to find out where it is.

a. Mapping between facts and representations

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.

We can structure these entities at two levels

 The knowledge level - at which facts are described


 The symbol level - at which representations of objects are defined in terms of symbols that
can be manipulated in programs

Figure: Mapping between facts and representations

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:

: dog(x) hasatail(x) We can then deduce:

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.

b. Intelligents agents should have following things

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

 Reasoning - Infer facts from existing data.

If a system on only knows:

Miles Davis is a Jazz Musician.

All Jazz Musicians can play their instruments well.


If things like Is Miles Davis a Jazz Musician? or Can Jazz Musicians play their instruments
well? are asked then the answer is readily obtained from the data structures and procedures.

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.

– First order predicate logic


– Objects described can be unique or variables to stand for a unique object
"All students are poor" ForAll(S) [student(S) -> poor(S)]

Here S can be replaced by many different unique

students.This makes programs much more compact:

eg. ForAll(A,B)[brother(A,B) -> brother (B,A)]

Q. Knowledge-Based Agent in Artificial intelligence

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

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

 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:

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


 An agent Should be able to incorporate new percepts
 An agent can update the internal representation of the world
 An agent can deduce the internal representation of the world
 An agent can deduce appropriate actions.
III YR /VI SEM Page 4
ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

Inference system generates new facts so that an agent can update the KB.

Various levels of knowledge-based agent:

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

III YR /VI SEM Page 5


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

Approaches to designing a knowledge-based agent:

There are mainly two approaches to build a knowledge-based agent:

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.

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

Following are the kind of knowledge which needs to be represented in AI systems:

 Object: All the facts about objects in our world domain. E.g., Guitars contains strings, trumpets are brass
instruments.
 Events: Events are the actions which occur in our world.
III YR /VI SEM Page 6
ITT63 ARTIFICIAL INTELLIGENCE UNIT II

 Performance: It describe behavior which involves knowledge about how to do things.


 Meta-knowledge: It is knowledge about what we know.
 Facts: Facts are the truths about the real world and what we represent.
 Knowledge-Base: The central component of the knowledge-based agents is the knowledge base. It is represented
as KB. The Knowledgebase is a group of the Sentences (Here, sentences are used as a technical term and not
identical with the English language).

Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and situations.
Following are the types of knowledge in artificial intelligence:

Q. Types of knowledge

Following are the various 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 declarativesentences.
 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 filed or subject.


 Heuristic knowledge is rules of thumb based on previous experiences, awareness of approaches, and
which are good to work but not guaranteed.

III YR /VI SEM Page 7


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

5. Structural knowledge:

 Structural knowledge is basic knowledge to problem-solving.


 It describes relationships between various concepts such as kind of, part of, and grouping of something.
 It describes the relationship that exists between concepts or objects.

Q. The relation between knowledge and intelligence:

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.

Q.Approaches to knowledge representation:

There are mainly four approaches to knowledge representation, which are givenbelow:

1. Simple relational knowledge:

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

Example: The following is the simple relational knowledge representation.

Player Weight Age


Player1 65 23
Player2 58 18
Player3 75 24

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

 In this approach, we apply inheritance property.


 Elements inherit values from other members of a class.
 This approach contains inheritable knowledge which shows a relation between instance and class, and it is called
instance relation.
 Every individual frame can represent the collection of attributes and its value.
 In this approach, objects and values are represented in Boxed nodes.
 We use Arrows which point from objects to their values.
 Example:

Procedural knowledge:

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

Requirements for knowledge Representation system:

A good knowledge representation system must possess the following properties.

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.

Q. Techniques of knowledge representation

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

III YR /VI SEM Page 10


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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 categorised into mainly two logics:

1. Propositional Logics
2. Predicate logics

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:

1. IS-A relation (Inheritance)


2. Kind-of-relation

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.

III YR /VI SEM Page 11


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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

example of a frame for a book


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

Production Rules

Production rules system consist of (condition, action) pairs which mean, "If condition then action". It has
mainly three parts:

 The set of production rules


 Working Memory
 The recognize-act-cycle

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

Q. The issues in Knowledge Representation

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?

III YR /VI SEM Page 12


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

4. How should sets of objects be represented?


5. Given a large amount of knowledge stored in a database, how can relevant parts be accessed
when they are needed?

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.

B. Relationships among Attributes:

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

band(John Zorn,Naked City)

This can be treated as John Zorn plays in the band Naked City or John Zorn's band is
NakedCity.

Another representation is band = Naked City

band-members = John Zorn, Bill Frissell, Fred Frith, Joey Barron,

D. Existence in an isa hierarchy:

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.

E. Techniques for reasoning about values:

III YR /VI SEM Page 13


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

F. Single valued attributes :

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.

G. Choosing the granularity of representation:

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.

If Tom feeds a dog then it could become:

feeds(tom, dog)

If Tom gives the dog a bone like:

gives(tom, dog,bone) Are these the same?

In any sense does giving an object food constitute

feeding?If give(x, food) feed(x) then we are making

progress.

But we need to add certain inferential rules.

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.

III YR /VI SEM Page 14


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

Obviously there is a potential storage problem and the underlying question must be what level of
comprehension is needed.

III YR /VI SEM Page 15


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

H. Representing set of objects:


It is important to be able to represent sets of objects for several reasons. One is that there are some
properties that are true of sets that are not true of the individual members of a set.

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.

I. Finding the right structure as needed:


In order to have access to the right structure for describing a particular situation, it is necessary to
solveall of the following problems.
 How to perform an initial selection of the most appropriate structure.
 How to fill in appropriate details from the current situation.
 How to find a better structure if the one chosen initially turns out not to be appropriate.
 What to do if none of the available structures is appropriate.
 When to create and remember a new structure.

J. Selecting an initial structure


The selecting candidate knowledge structures to match a particular problem solving situation is a
hardproblem, there are several ways in which it can be done. Three important approaches are the
following.
 Index the structures directly by the significant English words that can be used to describe them.
 Consider each major concept as a pointer to all of the structures in which it might be involved.
 Locate one major clue in the problem description and use it to select an initial structure.
K. Revising the choice when necessary
Once the candidate knowledge structure is detected, we must attempt to do a detailed match of it to
the problem at hand. Depending on the representation we are using the details of the matching
process will vary.
When the process runs into a snag, though, it is often not necessary to abandon the effort and start
over.Rather there are a variety of things that can be done. The following things can be done:
 Select the fragments of the current structure that do correspond to the situation and match them
against candidate alternatives.
 Make an excuse for the current structure's failure and continue to use it.
 Refer to specific stored links between structures to suggest new directions in which to explore.

Q. Propositional logic in Artificial intelligence

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

III YR /VI SEM Page 16


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

design namely

 Hardware design
 Software design

These are based on mathematical logic called formal logic.

Propositional logic (PL):

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:

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


 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.
 Propositions can be either true or false, but it cannot be both.
 Propositional logic consists of an object, relations or function, and logical connectives.
 These connectives are also called logical operators.
 The propositions and connectives are the basic elements of the propositional logic.
 Connectives can be said as a logical operator which connects two sentences.
 A proposition formula which is always true is called tautology, and it is also called a valid sentence.
 A proposition formula which is always false is called Contradiction.
 A proposition formula which has both true and false values is called
 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.

Syntax of propositional logic:

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.

III YR /VI SEM Page 17


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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:

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


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

Following is the summarized table for Propositional Logic Connectives:

III YR /VI SEM Page 18


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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

III YR /VI SEM Page 19


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

Limitations of Propositional logic:

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

Q. Rules of Inference in Artificial intelligence


• Inference:
III YR /VI SEM Page 20
ITT63 ARTIFICIAL INTELLIGENCE UNIT II

• 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

Q. Types of Inference rules:-

a. Modus Ponens: This rule is also called rule of detachment. Symbolically it iswritten as
[p∧(p→q)] →q
Or
P
p→q

q ( p and p implies q can be written as q)


b. Modus Tollens: The inference rule of modus tollens is a logical implicationspecified
by [(p→q) ∧¬q] →¬p
Which can be written as
p→q
¬q

¬p (p implies q and negation q can be written as negation p)

c. Law of syllogism: This rule of inference is expressed by the logical implication:


[(p→q) ∧(q→r)] →(p→r)
It can also be expressed in tabular form
as:p→q
q→r

III YR /VI SEM Page 21


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

p→r (p implies q and q implies r can be written as p implies r)

Example: Prove whether the following argument is valid, contradiction or satisfied.


“rajini is preparing food in kitchen. If rajini is preparing food in kitchen then she is not playing
violin. If she is not playing violin, then she is not learning music. Therefore, rajini is not learning
music.”

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

¬r (p and p implies negation q and negation q implies negation r can be


as ¬r)
To prove this logical implication, we carry out following steps.
1. p already specified as premise
2. p→¬q already specified as premise
3. ¬q→¬r already specified as premise
4. p→¬r by law of syllogism using 2 and 3 above
5. ¬r by modus ponnens rule, using 1 and 4
d. Rule of Conjunction: This rule states that if p and q are individually true
statements, then the composite p∧q is a true statements, i.e
[p∧q] →p∧q
or

pq
p∧q ( p and q can be wriiten as p∧q)

e. Rule of Disjunctive Syllogism: It id defined as a logical implication given as follows.


[(p∨q) ∧¬p] →q
Or
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

announced. Therefore, auditorium was available.”

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

p ( all 3 premise can be written as


p)the logical implication for the above expression can be expressed as follows:
(((¬p∨q) →r) ∧( r→s) ∧¬s) →p

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.

PEAS description of Wumpus world


• To explain the Wumpus world we have given PEAS description as below:
Performance measure:
• +1000 reward points if the agent comes out of the cave with the gold.
• -1000 points penalty for being eaten by the Wumpus or falling into the pit.
• -1 for each action, and -10 for using an arrow.
• The game ends if either agent dies or came out of the cave.
Environment:
• A 4*4 grid of rooms.
• The agent initially in room square [1, 1], facing toward the right.
• Location of Wumpus and gold are chosen randomly except the first square [1,1].
• Each square of the cave can be a pit with probability 0.2 except the first square.
Actuators:
• Left turn,
• Right turn
• Move forward
• Grab
• Release
• Shoot.

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

Exploring the Wumpus world:

III YR /VI SEM Page 24


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

• Agent's second Step:


• Now agent needs to move forward, so it will either move to [1, 2], or [2,1].
• Let's suppose agent moves to the room [2, 1], at this room agent perceives some breeze which means Pit is around
this room.
• The pit can be in [3, 1], or [2,2], so we will add symbol P? to say that, is this Pit room?
• Now agent will stop and think and will not make any harmful move.
• The agent will go back to the [1, 1] room.
• The room [1,1], and [2,1] are visited by the agent, so we will use symbol V to represent the visited squares.

• Agent's third step:


• At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2] agent perceives a stench
which means there must be a Wumpus nearby.
• But Wumpus cannot be in the room [1,1] as by rules of the game, and also not in [2,2] (Agent had not detected any
stench when he was at [2,1]).
• Therefore agent infers that Wumpus is in the room [1,3], and in current state, there is no breeze which means in
[2,2] there is no Pit and no Wumpus.
• So it is safe, and we will mark it OK, and the agent moves further in [2,2].
• Agent's fourth step:
• At room [2,2], here no stench and no breezes present so let's suppose agent decides to move to [2,3]. At room [2,3]
agent perceives glitter, so it should grab the gold and climb out of the cave.
• ¬r
Q. Predicate logic or first order logic:
• , 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.
• "Some humans are intelligent", or
• "Sachin likes cricket.
• First-order logic is another way of knowledge representation in artificial intelligence. It is an
extension to propositional logic.
• First-order logic is also known as Predicate logic or First-order predicate logic.
• First-order logic (like natural language) does not only assume that the world contains facts like
propositional logic but also assumes the following things in the world:
• Objects: A, B, people, numbers, colors, wars, theories, squares, pits, wumpus, ......
• Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation such as: the
sister of, brother of, has color, comes between
• Function: Father of, best friend, third inning of, end of, ......
• First-order logic (like natural language) does not only assume that the world contains facts like
III YR /VI SEM Page 25
ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

P= rama is a student, and


Q= Krishna is a student.
Here, symbols p and q do not show anything common between them. However, the phrase “is a
student” is Predicate, common in both sentences. In predicate logic these statements can be written
as
(First Level predicate)
isstudent(Rama) and
isstudent(Krishna)
(Second Level Predicate)
student(Rama)
student(Krishna)
(Third Level Predicate)
s(Rama),
s(Krishna),
in addition it can be represented by
s(R),
s(K),

III YR /VI SEM Page 26


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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

Predicate Formula: A general form of predicate statement is,


P(a1, a2, ........................, an)
Where p is a predicate and a1, a2,……………..,an are terms. The predicate p(a1, a2, .... , an) is called
atomic formula. A well formed formula (wff) defined in propositional calculus is also applicable
inpredicate calculus
For all

There exists

Implies

Not

Or

And

Connectives can be used in the predicate similar to those in

propositions.Let us consider the sentences given below.

“Rama is a student and Rama plays


cricket”.“Rama is a student or Rama plays
cricket”.
“Rama is a student implies that Rama plays cricket”.
“Rama is not student”.
These can be represented in the predicate forms in the same order as:
s(R) ∧p(R,C)
s(R) ∨p(R,C)
s(R) →p(R,C)
¬ s(R)
In the above predicates, p(R,C) stands for “ Rama plays Cricket”, where p is predicate for
“plays”, R for “Rama” is a subject and C for Cricket” is an object. P(R,C) is a two place predicate.
Higher place predicates are also possible. Following are some of examples.
Rajan plays cricket and basketball = p(R,C,B).
Functions:
The parameters a1,a2,…..,an in a predicate p, given below, can be constants or variables or functions.
P(a1,a2,…..,an)
Consider the following sentences:
“Rajan is father of Rohit.”
III YR /VI SEM Page 27
ITT63 ARTIFICIAL INTELLIGENCE UNIT II

“Sheela is mother of Rohit.”


“Rajan and Sheela are
spouse.”

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.

Father of Rajni and Rohit,


andMother of Rajni and
Can be written Rohit,
as,
fatherof (Rajni, Rohit)=Rajan
motherof (Rajni, Rohit)=Sheela.
Example:

III YR /VI SEM Page 28


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

“2 plus 2 is 4.” Can be written as function formula as plus(2, 2)=4


“50 divided by 10 is 5.” Can be written as function formula as divided by(50, 10)=5

Representing simple facts in logic:

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

It is raining, then it is not

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.

1. Marcus was a man


2. Marcus was a pompeian.
3. All Pompeians were romans
4. Caesar was a ruler.
5. All romans were either loyal to caesar or hated him.

The facts described by these sentences can be represented as a set of wff’s in predicate logic as
follows:

1. Marcus was a man.

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

2. Marcus was a Pompeian

Pompeian(marcus)

3. All Pompeians were romans.

x: pompeians(x) Roman(x)

4. Caesar was a ruler.

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.

5. All romans were either loyal to caesar or hated him.

x:Roman(x) loyalto(x, Caesar) V hate(x, Caesar)

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: roman(x) [(loyal to(x, Caesar) V hate(x, Caesar)) (loyalto(x,


Caesar)hate(x, Caesar))]

Variable and Quantifiers


To generalize the statement, “rama is student”, it is written as “x is student”, i.e s(X). if s(X) is
true fora single case, then we say that the expression is satisfied.
Let us consider the following statements.

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

“for all x, x is human implies that x is mortal”,


and“Socrates is human”

III YR /VI SEM Page 30


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

Now, these are rewritten in symbolic form using quantifying operator

x (h(x) →m(x)), and


h(S)
in this case the first statement x (h(x) →m(x)) is true, when the statement is found to be true for
entire range of x. because it says “for all x” or “for every x” or “for all possible values of x”, h(x)
→m(x) is true. Still, it is not possible to infer m(S), i.e “mortal Socrates”. Because the statements still
do not appear in the form such that the rule of modus ponens can be applied. The inference rule of
universal instantiation, discussed in the next section, will help in resolving this problem.

SYNTAX AND SEMANTICS of FOL:

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.

SYNTAX of FOL in BNF (Backus – Naus Form):

Sentence  Atomic sentence

‫׀‬Sentence connective sentence

‫׀‬Quantifier variable,….sentence

‫׀‬7 sentence

‫(׀‬sentence).

Atomic sentence Predicate

(Term,…)Term  Term

Term  Function (Term…)

‫׀‬constant

‫׀‬variable

Connective 

=>‫׀∨׀𝖠׀‬Quantifier  ‫׀‬

III YR /VI SEM Page 31


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

Constant  ‫ ׀‬λcon‫ ׀‬john‫׀‬

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:

General Notation: “ P” where,

P – Logical expression, X – Variable, - For all

That is, P is true for all objects X in the

Universe.

Examples:

All cats are mammals => X cat (X)  mammals(X)

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

III YR /VI SEM Page 32


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

(spot)

Cat (spot)  mammal

(spot)Spot – Name of the

cat.

Existential Quantifiers:

General Notification: X P, where

P – Logical Expression , X – Variable , - There

existThat is P is true for some object X in the

universe.

Example:

Spot has a sister who is a cat.

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)

Sister (Felix, spot)

Sister (Felix, spot)  cat (Felix).

NESTED QUANTIFIERS:

III YR /VI SEM Page 33


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

The sentences are represented using multiple quantifiers.

Example:

# For all X and all Y, if x is the parent of Y then Y is the child of X.

X, Y parent (X, Y)  child (Y, X).

# Everybody loves somebody

Y loves (X, Y)

# There is someone who is loved by everyone

Y X loves (X, Y)

Connection between and :

The two Quantifiers ( and ) are actually connected with each other through negation.

Example:

Everyone likes ice cream

X likes (X, ice cream) is equivalent to 7 X 7 likes (X, ice cream)

That is there is no one who does not like ice cream.

Ground Term or Clause: A term with no variable is called ground term.

Eg: cat (spot)

The De Morgan rules for quantified and unquantified sentences are as follows,

# Quantified sentences:

X7P ≡ 7 XP

7 XP ≡ X7P

III YR /VI SEM Page 34


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

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.

1. Rule of universal instantiation


This rules states that if a universally quantified variable in a valid sentence is replaced by a
termfrom the domain, then also the sentence is true. Thus is, if
x (h(x) →m(x))
Is true, and if x is replaced by “Socrates”. And quantifier is removed then the statement,
(h(S) →m(S))
Is still true. This rule is called as rule of universal instantiation and expressed as
x P(x)

P(a) (for all x p(x), can be written as P(a) )

2. Rule of universal generalization


If a statement p(a) is true for each element a of universe, then the universal quanitifier may be
prefixed, and x P(x) can be inferred from p(a), i.e.

P(a), for all a Є U

x P(x) ( (p(a) can be written as for all x, p(x))


3. Rule of Existential Instantiation
If x p(x) is true, and there is an element a in the universe of p, then we can infer p(a). i.e
x p(x)

III YR /VI SEM Page 35


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

P(a) for some a Є U (There existx p(x), can be written as P(a))

4. Rule of Existential Generalization


If p(a) is true for some a in the universe, then it can be inferred that x p(x) is true, i.e

P(a), for all a Є U

Example Problems:

x P(x) ( (p(a) can be written as there exist x, p(x))

Prove the validity of the following statements


“All kings are men” .................................................. (1)
“All men are falliable” ............................................... (2)
“Therefore, all kings falliable”
Solution:
The above statements could be rewritten without affecting the meanings they convey
“For all x, x is king implies that x is man”
“For all y, y is man implies that y is falliable.”
“Therefore, for all z, z is king implies that z is falliable.” The above statements
can be represented in the predicate form as follows.

x (k(x) →m(x)) ............................from (1)


y (m(y) →f(y)) ............................from(2)

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

III YR /VI SEM Page 36


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

III YR /VI SEM Page 37


ITT63 ARTIFICIAL INTELLIGENCE UNIT II

III YR /VI SEM Page 38


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

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

and put the result into S.


b) If S = failure then returns Failure
c) If S ≠ NIL then do, a. Apply S to the remainder of both L1 and L2. b. SUBST= APPEND(S, SUBST).
Step.6: Return SUBST.

Implementation of the Algorithm


 Step.1: Initialize the substitution set to be empty.
 Step.2: Recursively unify atomic sentences:
 Check for Identical expression match.
 If one expression is a variable vi, and the other is a term ti which does not contain variable vi, then:
o Substitute ti / vi in the existing substitutions
o Add ti /vi to the substitution set-list.
o If both the expressions are functions, then function name must be similar, and the number of arguments must
be the same in both the expression.

Q. Forward Chaining & Backward 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

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)

III YR /VI SEM Page 40


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)


Country A has some missiles. ?
p Owns(A, p) ∧ Missile(p).

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

Missiles are weapons.


Missile(p) → Weapons (p) .......(5)
Enemy of America is known as hostile.
Enemy(p, America) →Hostile(p) ........(6)
Country A is an enemy of America.
Enemy (A, America) .........(7)
Robert is American
American(Robert). ..........(8)

Forward chaining proof:


 Step-1:
In the first step we will start with the known facts and will choose the sentences which do not have implications, such
as: American(Robert), Enemy(A, America), Owns(A, T1), and Missile(T1). All these facts will be represented as below,

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

III YR /VI SEM Page 41


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

Hence it is proved that Robert is Criminal using forward chaining approach

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.

III YR /VI SEM Page 42


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

III YR /VI SEM Page 43


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

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

III YR /VI SEM Page 44


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

 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

III YR /VI SEM Page 45


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

Q. Representing Knowledge using Rules

III YR /VI SEM Page 46


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

III YR /VI SEM Page 47


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

III YR /VI SEM Page 48


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

III YR /VI SEM Page 49


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

III YR /VI SEM Page 50


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

Q. Knowledge Representation using Frames in Artificial


Intelligence:
Frames :

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

III YR /VI SEM Page 51


ITT63 ARTIFICIAL INTELLIGENCE UNIT 1

 These information are not given in this frame.


 Search will start from frame13 in upward direction till we get our answer or have reached root frame.
 The frame can be easily represented in prolog by choosing predicate name as frame with two arguments.
 First argument is the name of the frame and second argument is a list of slot - facet pair.

Features of Frame Representations


 Frames can support values more naturally than semantic nets (e.g. the value 25)
 Frames can be easily implemented using object-oriented programming techniques.
 Demons allow for arbitrary functions to be embedded in a representation.
 But a price is paid in terms of efficiency, generality, and modularity !
 Inheritance can be easily controlled

III YR /VI SEM Page 52

You might also like