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

AI Unit 3

This is the class notes we have got this artificial intelligence notes

Uploaded by

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

AI Unit 3

This is the class notes we have got this artificial intelligence notes

Uploaded by

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

Artificial Intelligence

Unit 3

Knowledge Representation

Components of Knowledge

The knowledge that needs to be presented in artificial intelligence systems can include:

Object: Objects surround humans constantly. Hence, the information regarding those
objects is essential and must be considered a knowledge type. For example, pianos have
white and black keys, cars have wheels, buses need drivers, planes need pilots, etc.

Events: Numerous events are constantly taking place in the real world. And human
perception is based on events. AI needs to have events knowledge to take action. Some
events are famines, the advancement of societies, wars, disasters, achievements, and
more.

Performance: This knowledge deals with humans’ certain actions in various situations. It
represents the behavior side of knowledge which is quite essential for AI to understand.

Meta knowledge: For instance, if we look around the world and sum up all the knowledge
out there, we see it is mostly divided into three categories:

 What we already know


 What we know is basically things we do not know completely
 What we do not know yet

Meta knowledge deals with the first one, i.e, what we know and lets AI perceive the same.

Facts: This knowledge is based on the factual description of our world. For example, the
earth is not flat but also not round; our sun has a voracious appetite, and more.

Knowledge-base: The knowledge base is the main component of human intelligence. This
refers to a group of relevant data or information on any field, description, and more. For
example, a knowledge base on designing a car model.

Connection Between Knowledge Representation and AI

Knowledge plays an essential role in intelligence. It is also responsible for the creation of
artificial intelligence. When it is needed to express intelligent behavior in the AI agents, it
plays a necessary role. An agent is unable to function accurately when it lacks experience
or knowledge of certain inputs.

For example, if you want to interact with a person but are unable to understand the
language, it is obvious that you can’t respond well and deliver any action. This works the
same for agents’ intelligent behavior. AI needs to have enough knowledge to carry out the
functionality as a decision-maker discovers the environment and applies the required
knowledge. However, AI can’t exhibit intellectual behavior without the components of
knowledge.

Types of Knowledge

Declarative knowledge: It represents the objects, concepts, and facts that help you
describe the whole world around you. Thus, it shares the description of something and
expresses in a declarative sentences.

Procedural Knowledge: Procedural knowledge is less compared to declarative knowledge.


It is also known as imperative knowledge, which is used by mobile robots. It’s for declaring
the accomplishment of something. For example, with just a map of a building, mobile
robots can make their own plan. Mobile robots can plan to attack or perform navigation.
Moreover, procedural knowledge is directly applied to the task that, includes rules,
procedures, agendas, strategies, and more.

Meta Knowledge: In the field of artificial intelligence, pre-defined knowledge is known as


meta-knowledge. For example, the study of tagging, learning, planning, etc., falls under
this type of knowledge.

This model changes its behavior with time and utilizes other specifications. A system
engineer or knowledge engineer utilizes various forms of meta-knowledge, such as
accuracy, assessment, purpose, source, life span, reliability, justification, completeness,
consistency, applicability, and disambiguation.

Heuristic Knowledge: This knowledge, which is also known as shallow knowledge, follows
the thumb rule principle. Hence, it is highly efficient in the process of reasoning as it can
solve issues based on past records or problems that are compiled by experts. However, it
gathers experiences of past problems and provides a better knowledge-based approach to
specify problems and take action.

Structural Knowledge: Structural knowledge is the most simple and basic knowledge
that is used and applied in solving complex problems. It tries to find an effective solution
by finding the relationship between objects and concepts. In addition, it describes the
relationship between multiple concepts, like part of, kind of, or grouping of something.

Approaches to knowledge representation:

There are mainly four approaches to knowledge representation, which are given below:

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

3. Inferential knowledge:

 Inferential knowledge approach represents knowledge in the form of formal logics.


 This approach can be used to derive more facts.
 It guaranteed correctness.

Example: Let's suppose there are two statements:

1. Marcus is a man
2. All men are mortal

Then it can represent as;

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

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

Propositional logic (PL):

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

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

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

Example:

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

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

Compound proposition: Compound propositions are constructed by combining simpler


or atomic propositions, using parenthesis and logical connectives.

Example:

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

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

Logical Connectives:

Logical connectives are used to connect two simpler propositions or representing a


sentence logically. We can create compound propositions with the help of logical
connectives. There are mainly five connectives, which are given as follows:

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


literal or negative literal.

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.

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",

so we can write it as P ∨ Q.

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

Limitations of Propositional logic:

 We cannot represent relations like ALL, some, or none with propositional logic.
Example:

All the girls are intelligent.

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.

First-Order logic:

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


an extension to propositional logic.

FOL is sufficiently expressive to represent the natural language statements in a concise


way.

First-order logic is also known as Predicate logic or First-order predicate logic. First-
order logic is a powerful language that develops information about the objects in a more
easy way and can also express the relationship between those objects.

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

As a natural language, first-order logic also has two main parts:

 Syntax
 Semantics

Syntax of First-Order logic:

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

Basic Elements of First-order logic:

Following are the basic elements of FOL syntax:

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

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

Predicates Brother, Father, >,....

Function sqrt, LeftLegOf, ....

Connectives ∧, ∨, ¬, ⇒, ⇔

Equality ==

Quantifier ∀, ∃

Atomic sentences:

Atomic sentences are the most basic sentences of first-order logic. These sentences are
formed from a predicate symbol followed by a parenthesis with a sequence of terms.

We can represent atomic sentences as Predicate (term1, term2, ......, term n).
Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).

Complex Sentences:

Complex sentences are made by combining atomic sentences using connectives.

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

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


 Predicate: A predicate can be defined as a relation/function, which binds two atoms
together in a statement.

Consider the statement: "x is an integer.", it consists of two parts, the first part x is the
subject of the statement and second part "is an integer," is known as a predicate.

Quantifiers in First-order logic:

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


specifies the quantity of specimen in the universe of discourse.

These are the symbols that permit to determine or identify the range and scope of the
variable in the logical expression. There are two types of quantifier:

 Universal Quantifier, (for all, everyone, everything)


 Existential quantifier, (for some, at least one).

Universal Quantifier:

Universal quantifier is a symbol of logical representation, which specifies that the


statement within its range is true for everything or every instance of a particular thing.

The Universal quantifier is represented by a symbol ∀, which resembles an inverted A.

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

 For all x
 For each x
 For every x.
Example:

All man drink coffee.

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

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

Existential Quantifier:

Existential quantifiers are the type of quantifiers, which express that the statement within
its scope is true for at least one instance of something.

It is denoted by the logical operator ∃, which resembles as inverted E. When it is used with
a predicate variable then it is called as an existential quantifier.

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

 There exists a 'x.'


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

Example:

Some boys are intelligent.


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

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

Resolution Principle:

Resolution is a theorem proving technique that proceeds by building refutation proofs,


i.e., proofs by contradictions.

Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive
normal form

Conjunctive Normal Form: A sentence represented as a conjunction of clauses is said to


be conjunctive normal form or CNF.

Steps for Resolution:

 Conversion of facts into first-order logic.


 Convert FOL statements into CNF
 Negate the statement which needs to prove (proof by contradiction)
 Draw resolution graph (unification).
Steps for converting FOL into CNF

 Eliminate all implication (→) and rewrite


 Move negation (¬)inwards and rewrite
 Rename variables or standardize variables
 Eliminate existential instantiation quantifier by elimination.
 Drop Universal quantifiers.
 Distribute conjunction ^ over disjunction ¬.

Example:

John likes all kind of food.

Apple and vegetable are food

Anything anyone eats and not killed is food.

Anil eats peanuts and still alive

Harry eats everything that Anil eats.

Prove by resolution that: John likes peanuts.

Step-1: Conversion of Facts into FOL

In the first step we will convert all the given statements into its first order logic.

Step-2: Conversion of FOL into CNF

In First order logic resolution, it is required to convert the FOL into CNF as CNF form
makes easier for resolution proofs.
Eliminate all implication (→) and rewrite

∀x ¬ food(x) V likes(John, x)

food(Apple) Λ food(vegetables)

∀x ∀y ¬ [eats(x, y) Λ ¬ killed(x)] V food(y)

eats (Anil, Peanuts) Λ alive(Anil)

∀x ¬ eats(Anil, x) V eats(Harry, x)

∀x¬ [¬ killed(x) ] V alive(x)

∀x ¬ alive(x) V ¬ killed(x)

likes(John, Peanuts).

Move negation (¬)inwards and rewrite

∀x ¬ food(x) V likes(John, x)

food(Apple) Λ food(vegetables)

∀x ∀y ¬ eats(x, y) V killed(x) V food(y)

eats (Anil, Peanuts) Λ alive(Anil)

∀x ¬ eats(Anil, x) V eats(Harry, x)

∀x ¬killed(x) V alive(x)

∀x ¬ alive(x) V ¬ killed(x)

likes(John, Peanuts).

Rename variables or standardize variables

∀x ¬ food(x) V likes(John, x)

food(Apple) Λ food(vegetables)

∀y ∀z ¬ eats(y, z) V killed(y) V food(z)

eats (Anil, Peanuts) Λ alive(Anil)

∀w¬ eats(Anil, w) V eats(Harry, w)

∀g ¬killed(g) ] V alive(g)

∀k ¬ alive(k) V ¬ killed(k)
likes(John, Peanuts).

Eliminate existential instantiation quantifier by elimination.

In this step, we will eliminate existential quantifier ∃, and this process is known
as Skolemization. But in this example problem since there is no existential quantifier so
all the statements will remain same in this step.

Drop Universal quantifiers.

In this step we will drop all universal quantifier since all the statements are not implicitly
quantified so we don't need it.

¬ food(x) V likes(John, x)

food(Apple)

food(vegetables)

¬ eats(y, z) V killed(y) V food(z)

eats (Anil, Peanuts)

alive(Anil)

¬ eats(Anil, w) V eats(Harry, w)

killed(g) V alive(g)

¬ alive(k) V ¬ killed(k)

likes(John, Peanuts).

Distribute conjunction ∧ over disjunction ¬.

This step will not make any change in this problem.

Step-3: Negate the statement to be proved

In this statement, we will apply negation to the conclusion statements, which will be
written as ¬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:
Explanation of Resolution graph:

In the first step of resolution graph, ¬likes(John, Peanuts) , and likes(John, x) get
resolved(canceled) by substitution of {Peanuts/x}, and we are left with ¬ food(Peanuts)

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

In the fourth step of the resolution graph, Killed(Anil) and ¬ killed(k) get resolve by
substitution {Anil/k}, and we are left with ¬ alive(Anil) .

In the last step of the resolution graph ¬ alive(Anil) and alive(Anil) get resolved.

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.
Let Ψ1 and Ψ2 be two atomic sentences and 𝜎 be a unifier such that, Ψ1𝜎 = Ψ2𝜎, then it
can be expressed as UNIFY(Ψ1, Ψ2).

Example: Find the MGU for Unify{King(x), King(John)}

Let Ψ1 = King(x), Ψ2 = King(John),

Substitution θ = {John/x} is a unifier for these atoms and applying this substitution, and
both expressions will be identical.

The UNIFY algorithm is used for unification, which takes two atomic sentences and
returns a unifier for those sentences (If any exist).

Unification is a key component of all first-order inference algorithms.

It returns fail if the expressions do not match with each other.

The substitution variables are called Most General Unifier or MGU.

E.g. Let's say there are two different expressions, P(x, y), and P(a, f(z)).

In this example, we need to make both above statements identical to each other. For this,
we will perform the substitution.

P(x, y)......... (i)

P(a, f(z))......... (ii)

Substitute x with a, and y with f(z) in the first expression, and it will be represented
as a/x and f(z)/y.

With both the substitutions, the first expression will be identical to the second expression
and the substitution set will be: [a/x, f(z)/y].

Conditions for Unification:

 Predicate symbol must be same, atoms or expression with different predicate symbol
can never be unified.
 Number of Arguments in both expressions must be identical.
 Unification will fail if there are two similar variables present in the same expression.

Find the MGU of {p(f(a), g(Y)) and p(X, X)}

Sol: S0 => Here, Ψ1 = p(f(a), g(Y)), and Ψ2 = p(X, X)

SUBST θ= {f(a) / X}
S1 => Ψ1 = p(f(a), g(Y)), and Ψ2 = p(f(a), f(a))

SUBST θ= {f(a) / g(y)}, Unification failed

Find the MGU of {p(b, X, f(g(Z))) and p(Z, f(Y), f(Y))}

Here, Ψ1 = p(b, X, f(g(Z))) , and Ψ2 = p(Z, f(Y), f(Y))

S0 => { p(b, X, f(g(Z))); p(Z, f(Y), f(Y))}

SUBST θ={b/Z}

S1 => { p(b, X, f(g(b))); p(b, f(Y), f(Y))}

SUBST θ={f(Y) /X}

S2 => { p(b, f(Y), f(g(b))); p(b, f(Y), f(Y))}

SUBST θ= {g(b) /Y}

S2 => { p(b, f(g(b)), f(g(b)); p(b, f(g(b)), f(g(b))} Unified Successfully.

And Unifier = { b/Z, f(Y) /X , g(b) /Y}.

Semantic Net

Semantic networks are alternative of predicate logic for knowledge representation. In


Semantic networks, we can represent our knowledge in the form of graphical networks.
This network consists of nodes representing objects and arcs which describe the
relationship between those objects. Semantic networks can categorize the object in
different forms and can also link those objects. Semantic networks are easy to understand
and can be easily extended.

This representation consist of mainly two types of relations:

 IS-A relation (Inheritance)


 Kind-of-relation

Example: Following are some statements which we need to represent in the form of nodes
and arcs.

Statements:

a. Jerry is a cat.
b. Jerry is a mammal
c. Jerry is owned by Priya.
d. Jerry is brown coloured.
e. All Mammals are animal.

In the above diagram, we have represented the different type of knowledge in the form of
nodes and arcs. Each object is connected with another object by some relation.

Disadvantages of Semantic representation:

 Semantic networks take more computational time at runtime as we need to traverse


the complete network tree to answer some questions. It might be possible in the
worst case scenario that after traversing the entire tree, we find that the solution
does not exist in this network.
 Semantic networks try to model human-like memory (Which has 1015 neurons and
links) to store the information, but in practice, it is not possible to build such a vast
semantic network.
 These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
 Semantic networks do not have any standard definition for the link names.
 These networks are not intelligent and depend on the creator of the system.

Advantages of Semantic network:

 Semantic networks are a natural representation of knowledge.


 Semantic networks convey meaning in a transparent manner.
 These networks are simple and easily understandable.

You might also like