Professional Documents
Culture Documents
Module 2 AI
Module 2 AI
Artificial Intelligent
Module 2
By- Chandan Sharma
A2305219668 , 6CSE11Y
ASET, Amity University, Noida
Amity School of Engineering & Technology
Knowledge
• Knowledge is the body of facts and principles.
• Knowledge can be language, concepts, procedures, rules, ideas,
abstractions, places, customs, and so on.
• Study of knowledge is called Epistemology.
Amity School of Engineering & Technology
Types of knowledge
• Following are the various
types of knowledge:
1. Declarative Knowledge
2. Procedural Knowledge
3. Meta-knowledge
4. Heuristic knowledge
5. Structural knowledge
Amity School of Engineering & Technology
Types of knowledge(Cont..)
Declarative knowledge
• Declarative knowledge is passive knowledge in the form of statements of facts about the
world.
• For example, mark statement of a student is declarative knowledge.
Procedural Knowledge
• It is also known as imperative knowledge.
• Procedural knowledge is a type of knowledge which is responsible for knowing how to do
something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures, agendas, etc.
• Procedural knowledge depends on the task on which it can be applied.
Meta-knowledge:
• Knowledge about the other types of knowledge is called Meta-knowledge.
• Metaknowledge is knowledge about knowledge
Amity School of Engineering & Technology
Types of knowledge(Cont..)
Heuristic knowledge
• Heuristics knowledge are rules of thumb or tricks.
• Heuristic knowledge is used to make judgments and also to simplify solution of
problems. It is acquired through experience.
• An expert uses his knowledge that he has gathered due to his experience and
learning.
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.
Amity School of Engineering & Technology
KNOWLEDGE REPRESENTATION
• To solve problems in artificial intelligence requires large amount of knowledge
and some mechanism that knowledge to create solutions to new problem.
• A variety of knowledge facts have been exploited in AI programs.
• Hence we are dealing with two different kinds of entities such as:
• Facts: - It is truth in some relevant world. These are the things we want to
represent.
• Representations of facts in some chosen formalism: - These are the things we
will actually be able to manipulate.
Amity School of Engineering & Technology
KNOWLEDGE REPRESENTATION
A knowledge representation is a study of ways of how knowledge is actually
represented and how effectively it resembles the representation of knowledge
inhuman brain.
• A knowledge representation system should provide ways of representing
complex
knowledge.
How to represent the knowledge in a machine?
• The Language is needed to represent the knowledge . There must be a method
to
use this knowledge.
• Syntax and semantic must be well defined in order to represent the language.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
1. Important Attributes
2. Relationships among Attributes.
3. Choosing the granularity of Representation.
4. Representing Sets of Objects.
5. Finding the Right structures as Needed
Amity School of Engineering & Technology
Propositional Logic
• Propositional Logic is one of the representation schemes.
• It is the combination of Proposition + Logic
Proposition
• Propositions are elementary atomic sentences.
• Propositions may be either true or false but may take on other value.
• There are two kinds of proposition
• Simple
• Compound
• Some examples of simple propositions are
• John has two children.
• It is raining.
• People live on earth.
• mango is yellow.
Amity School of Engineering & Technology
Propositional Logic
• 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 Contingency
• 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.
Amity School of Engineering & Technology
Propositional Logic
Connectives Truth Table
Amity School of Engineering & Technology
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
Amity School of Engineering & Technology
Conditions:
Amity School of Engineering & Technology
Syntax of FOPL
• Constants, variables, and functions are referred to as terms.
• Predicates are referred to as atomic formulas or atoms.
• When we want to refer to an atom or its negation, we often use the
word literal.
• In addition to above symbols, left and right parentheses , square
brackets, braces, and the period are used for punctuation in symbolic
representation.
Amity School of Engineering & Technology
Predicate logic
• A predicate logic is a formal system that uses variables and quantifiers ( ∀ , ∃ , ∃ ! ) to formulate
propositions. The first of these, predicate logic, involves using standard forms of logical symbolism which
have been familiar to philosophers and mathematicians for many decades.
• propositions that can either be false or true. Those propositions can be combined
(∧,∨,⇒,⇔,¬∧,∨,⇒,⇔,¬ and more, but all others can be represented by those logical connectives).
• A predicate logic is a formal system that uses variables and quantifiers (∀∀, ∃∃, ∃!∃!) to formulate
propositions.
• SUBJECT: - The subject is that about which something is said.
• PREDICATE:- The predicate is the part of the preposition which denotes that what is affirmed or denied
about the subject.
• COPULA:- The copula is that part of the preposition which denotes the relations between the subject and
the predicate.
Amity School of Engineering & Technology
Predicate logic(cont..)
• As for example:
• MAN IS CULTURED
SUBJECT -> MAN
PREDICATE-> CULTURED
COPULA-> IS
• A predicate is a
function p:X→{true,false}p:X→{true,false} where XX is any set.
Amity School of Engineering & Technology
Practice
Amity School of Engineering & Technology
Horn clause
Horn clause is a logical formula of a particular rule-like form which gives it useful
properties for use in logic programming, formal specification, and model theory.
Horn clauses are named for the logician Alfred Horn,
A Horn clause is a clause (a disjunction of literals) with at most one positive, i.e.
unnegated, literal.
Conversely, a disjunction of literals with at most one negated literal is called a dual-Horn
clause.
A Horn clause with exactly one positive literal is a definite clause; a definite clause with
no negative literals is sometimes called a fact; and a Horn clause without a positive literal
is sometimes called a goal clause
Amity School of Engineering & Technology
Resolution
Resolution is a rule of inference leading to a refutation theorem-proving technique for sentences in
propositional logic and first-order logic. In other words, iteratively applying the resolution rule in a
suitable way allows for telling whether a propositional formula is satisfiable and for proving that a
first-order formula is unsatisfiable. Attempting to prove a satisfiable first-order formula as
unsatisfiable may result in a nonterminating computation; this problem doesn't occur in
propositional logic.
The resolution rule for first-order logic is simply a lifted version of the propositional rule.
Resolution can resolve two clauses if they contain complementary literals, which are assumed to be
standardized apart so that they share no variables.
Resolution Principle
• Given two clauses C1and C2 with no variables in common, if there is
aliteral l1, in C1
and which is a complement of a literal l2 in C2 , both l1 and l2 are deleted
and a disjuncted C is formed the remaining reduced clauses. The new
clauses C is called the resolve of C1
and C2
• Resolution is the process of generating these resolvents from the set of
clauses.
• Example: (¬AVB) and (AVC)
We can write
BV
Amity School of Engineering & Technology
Example of Resolution
• Consider the following clauses:-
P:AV B V D
Q: ¬A V B V D
R: ¬B V D
Solution
P : A V B V D (Given in the problem)
Q : ~A V B V D (Given in the problem)
S : B V D (Resolvent of P and Q)
R : ~B V D (Given in the problem)
T : D (Resolvent of R and S)
Amity School of Engineering & Technology
Example :
Amity School of Engineering & Technology
Solution:
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Example:
• To better understand all the above steps, we will take an example
in which we will apply resolution.
1.John likes all kind of food.
2.Apple and vegetable are food
3.Anything anyone eats and not killed is food.
4.Anil eats peanuts and still alive
5.Harry eats everything that Anil eats.
¬likes(John, Peanuts)
Step-4: Draw Resolution graph:
Now in this step, we will
solve the problem by
resolution tree using
substitution. For the above
problem, it will be given as
follows: Hence the negation of the
conclusion has been proved as a
complete contradiction with the
given set of statements.
Amity School of Engineering & Technology
•In the second step of the resolution graph, ¬ food(Peanuts) , and food(z) get resolved (canceled) by
substitution of { Peanuts/z}, and we are left with ¬ eats(y, Peanuts) V killed(y) .
•In the third step of the resolution graph, ¬ eats(y, Peanuts) and eats (Anil, Peanuts) get resolved by
substitution {Anil/y}, and we are left with Killed(Anil) .
Questions
Amity School of Engineering & Technology
Example for resolution of Predicate logic.
Amity School of Engineering & Technology
Solution
Amity School of Engineering & Technology
Solution(Cont..)
Amity School of Engineering & Technology
Practice
Question: What do you understand by instance and is a relationship . Solve the
problem using predicate logic.
• Marcus was a man.
• Marcus was a pompean.
• Marcus was born in 40 A.D
• All men are mortal.
• All pompean died when the volcano erupted in 79 A.D
• No mortal lives longer than 50 years
• It is now 2004
• Alive means not dead
• If someone dies, then he is dead at all latter times and prove that Marcus is
died.
Amity School of Engineering & Technology
Functions and Predicates
Soln:
(1) man(Marcus
(2) Pompeian(Marcus)
(3) born(Marcus, 40)
(4) x man(x) mortal(x)
(5) erupted(volcano, 79)
(6) x Pompeian(x) died(x,79)
(7) x t1 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) now = 2007
alive(Marcus, now)
Amity School of Engineering & Technology
Functions and Predicates - Filling in the Blanks
(1) man(Marcus)
(2) Pompeian(Marcus)
(3) born(Marcus, 40)
(4) x man(x) mortal(x)
(5) erupted(volcano, 79)
(6) x Pompeian(x) died(x,79)
(7) x t2 t2 mortal(x) born(x, t1) gt(t2-t1, 150) dead(x,t2)
(8) now = 2007
(9a) x t alive(x, t) dead(x, t)
(9b) x t dead(x,t) alive(x, t)
(10) x t2 t2 died(x, t1) gt(t2, t1) dead(x, t2)
alive(Marcus, now)
Amity School of Engineering & Technology
Showing that Marcus is Not Alive
alive(Marcus, now)
(9a) (Marcus/x) (now/t)
dead(Marcus, now)
(10)(Marcus/x)(now/t2) (7) (Marcus/x)(now/t2)
T T
Amity School of Engineering & Technology
Solution:
First we will convert it into FOPL (First order predicate logic)
i. Raman only likes easy courses.
∀ x: easy(x) → likes(raman,x)
ii. Computer Science courses are hard.
∀ x: computer science(x) → ¬easy(x)
iii. All the courses in Arts Department are easy.
∀ x: arts(x) → easy(x)
iv. ART101 is a course in Arts”.
arts(ART101)
The conclusion is encoded as likes(raman , x).
Amity School of Engineering & Technology
Solution conti...
First we put our premises in the clause form and the negation of
conclusion
to our set of clauses (we use numbers in parentheses to number the
clauses):
i. ¬easy(x) V likes(raman,x)
ii.¬computer science(x) V ¬easy(x)
iii.¬arts(x) V easy(x)
iv.arts(AR101)
v.¬likes(raman, x)
Amity School of Engineering & Technology
7 ¬arts(x) 3, 6
8 NIL 4, 7; x=ART101
Amity School of Engineering & Technology
Semantic
Semantic Network Representation
networks are alternative of predicate logic for
knowledge representation.
In Semantic networks, we can represent our knowledge in the
form of graphical networks.
This network consists of nodes representing objects and arcs
which describe the relationship between those objects.
Semantic networks can categorize the object in different
forms and can also link those objects.
Semantic networks are easy to understand and can be easily
extended.
This representation consist of mainly two types of relations:
IS-A relation (Inheritance)
Kind-of-relation
Statements:
Jerry is a cat.
Jerry is a mammal
Jerry is owned by Priya.
Jerry is brown colored.
Amity School of Engineering & Technology
Semantic Network(Cont..)
• A semantic net (or semantic network) is a knowledge representation technique
used for propositional information.
• So it is also called a propositional net. Semantic nets convey meaning. They are
two dimensional representations of knowledge.
• Mathematically a semantic net can be defined as a labelled directed graph.
• Semantic nets consist of nodes, links (edges) and link labels.
• In the semantic network diagram, nodes appear as circles or ellipses or
rectangles to represent objects such as physical objects, concepts or
situations.
• Links appear as arrows to express the relationships between objects, and link
labels specify particular relations.
• Relationships provide the basic structure for organizing knowledge. The objects
and relations involved need not be so concrete. As nodes are associated with other
nodes semantic nets are also referred to as associative nets.
Semantic Net Cont..
Amity School of Engineering & Technology
Semantic Network(Cont..)
• In this figure all the objects are within ovals and
connected using labelled arcs.
• Note that there is a link
between Jill and FemalePersons with
label MemberOf.
• Simlarly there is a MemberOf link
between Jack and MalePersons and SisterOf link
between Jill and Jack.
• The MemberOf link between Jill and
FemalePersons indicates that Jill belongs to the
category of female persons.
Amity School of Engineering & Technology
ADVANTAGES OF SEMANTIC NETS
• Semantic nets have the ability to represent default values for categories.
• In the above figure Jack has one leg while he is a person and all persons have two legs.
So persons have two legs has only default status which can be overridden by a specific
value.
• Semantic networks are a natural representation of knowledge.
• Semantic networks convey meaning in a transparent manner.
• These networks are simple and easily understandable.
Amity School of Engineering & Technology
EXAMPLE:
Amity School of Engineering & Technology
Exercises
• Try to represent the following two sentences into the appropriate semantic
network diagram:
Solution 1
• isa(person, mammal), instance(Mike-Hall, person), team(Mike-Hall, Cardiff)
mammal
is_a
is_a
Solution 2
• John gave Mary the book
Gave Book
Action Instance
Patient
Mary
Amity School of Engineering & Technology
Partitioned Nets
• A partitioned semantic net is a semantic net
which can be divided into one or more
networks for the description of an individual
network.
• The main idea of partitioning is to allow
groups, nodes, and arcs to be bundled
together into units called spaces, spaces are
the fundamental entities in partitioned
network on the same level as nodes and arcs.
• Every node and every arc of the network
belongs to one or more spaces.
• Some spaces are used to encode background
information or generic relations.
Amity School of Engineering & Technology
S1
is_a S1
is_a is_a is_a
form
G agent patient
D B P
Amity School of Engineering & Technology
SA
General
Statement dog bite postman
is_a S1
is_a is_a is_a
form
G agent patient
D B P
Amity School of Engineering & Technology
Partitioned Semantic Networks(Cont..)
• Suppose that we now want to look at the statement:
• "Every dog in town has bitten the postman"
SA
dog
ako
General
Statement town dog bite postman
is_a S1
is_a is_a is_a
form
G agent patient
D B P
Exercises
• Try to represent the following two sentences into the
appropriate semantic network diagram:
object
space
pizza tasty
is_a is_a
object has property
Amity School of Engineering & Technology
form
S1 is_a
form S2 is_a is_a
GS2 exists receiver
p1 l1
s1 agent
Amity School of Engineering & Technology
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.
Slots Filters
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 Title Artificial Intelligence
and sizes. Slots have names and values which are called facets.
A frame is also known as slot-filter knowledge representation in
Genre Computer Science
artificial intelligence.
Frames – semantic net with properties
• Frame: a knowledge representation technique which attempts to Author Peter Norvig
Page 1152
Amity School of Engineering & Technology
Frame Representation(cont..)
• A frame is an artificial intelligence data structure used to divide knowledge into
substructures by representing "stereotyped situations." Frames are the primary data
structure used in artificial intelligence frame language.
• Frames are also an extensive part of knowledge representation and reasoning schemes.
Frames were originally derived from semantic networks and are therefore part of structure
based knowledge representations.
• According to Russell and Norvig's "Artificial Intelligence, A Modern Approach,"
structural representations assemble "...facts about particular object and event types and
arrange the types into a large taxonomic hierarchy analogous to a biological taxonomy.“
The frame contains information on how to use the frame, what to expect next, and what to do
when these expectations are not met. Some information in the frame is generally unchanged
while other information, stored in "terminals,” usually change. Different frames may share
the same terminals.
Amity School of Engineering & Technology
Frame
Three components of a frame
Representation(cont..)
•frame name
•attributes (slots)
•values (fillers: list of values, range,
string, etc.)
Each piece of information about a particular frame is held in a slot. The information can
contain:
•Facts or Data
Values (called facets)
•Procedures (also called procedural attachments)
IF-NEEDED : deferred evaluation
IF-ADDED : updates linked information
•Default Values
For Data
For Procedures
Other Frames or Subframe
Amity School of Engineering & Technology
Frame Representation(cont..)
• Frames provide a convenient structure for representing objects that are typical to a
stereotypical situations.
• Frame is a type of schema used in many AI applications including vision and
natural language processing.
• The situations to represent may be visual scenes, structure of complex physical objects, etc.
Frames are also useful for representing commonsense knowledge.
• As frames allow nodes to have structures they can be regarded as three-dimensional
representations of knowledge.
• A frame is similar to a record structure and corresponding to the fields and values are slots
and slot fillers. Basically it is a group of slots and fillers that defines a stereotypical object.
• A single frame is not much useful. Frame systems usually have collection of frames
connected to each other. Value of an attribute of one frame may be another frame.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Frame Representation(cont..)
A frame for a book is given below.
Slots Fillers
publisher Thomson
title Expert Systems
author Giarratano
edition Third
year 1998
pages 600
The above example is simple one but most of the frames are
complex. Moreover with filler slots and inheritance provided by
frames powerful knowledge representation systems can be built.
Frames can represent either generic or frame. Following is the
example for generic frame.
Amity School of Engineering & Technology
Example Mammal
subclass: Animal
warm_blooded: yes
Elephant
subclass: Mammal
* colour: grey
* size: large
Clyde
instance: Elephant
color: pink
owner: Fred
Amity School of Engineering & Technology
Owner:
instance: Slot
single_valued: no
range: Person
Fred:
instance: Person
occupation: Elephant-
breeder
Amity School of Engineering & Technology
Inheritance Frame
Amity School of Engineering & Technology
Advantages of Frames
• Makes programming easier by grouping related knowledge
• Easily understood by non-developers
• Expressive power
• Easy to set up slots for new properties and relations
• Easy to include default information and detect missing values
Amity School of Engineering & Technology
Disadvantages of Frames
• No standards (slot-filler values)
• More of a general methodology than a specific representation:
• Frame for a class-room will be different for a professor and for a
maintenance worker
• No associated reasoning/inference mechanisms
Amity School of Engineering & Technology
Procedure Vs Declarative Knowledge
Procedure Knowledge Declarative Knowledge
•The procedural knowledge technique •Declarative knowledge is to
gives the complete satisfaction what know about something.
data is needed and how to get it. •It includes concepts, facts, and
• Hence procedural knowledge objects.
specifies what to do when. •It is also called descriptive
•Procedural knowledge represented in knowledge and expressed in
program in many ways. declarative sentences.
• The procedural knowledge •It is simpler than procedural
technique gives the complete language.
satisfaction what data is needed and
how to get it.
Amity School of Engineering & Technology
Reasoning
• Reasoning is the ability to assess things rationally by applying logic based on new or existing
information when making a decision or solving a problem.
• Reasoning allows you to weigh the benefits and disadvantages of two or more courses of action
before choosing the one with the most benefit or the one that suits your needs.
• Following types of reasoning :
1. Deductive reasoning
2. Inductive reasoning
3. Analogical reasoning
4. Abductive reasoning
5. Cause-and-effect reasoning
6. Critical thinking
7. De-compositional reasoning
Amity School of Engineering & Technology
•Sometimes, if you have some particular goal (to test some hypothesis), then backward chaining
will be much more efficient.
•However, sometimes backward chaining can be very wasteful - there may be many possible ways
of trying to prove something, and you may have to try almost all of them before you find one that
works.
•Forward chaining may be better if you have lots of things you want to prove when you have a
small set of initial facts.
• Backward chaining may be better if you are trying to prove a single fact, given a large set of
initial facts.
Amity School of Engineering & Technology