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

Ai Unit 3 Notes

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

Ai Unit 3 Notes

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

lOMoARcPSD|44893945

AI Unit 3 notes

Computer Science and Engineering (University of Solapur)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Sasi Prabha Singaravelu ([email protected])
lOMoARcPSD|44893945

3. Knowledge Representation and Reasoning

Human beings are good at understanding, reasoning and


interpreting knowledge. And using this knowledge, they are able to perform various
actions in the real world. But how machines do all these things comes under
knowledge representation and reasoning. Hence we can describe Knowledge
representation as following:

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

o Object: All the facts about objects in our world domain. E.g., Guitars contains
strings, trumpets are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do
things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o 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

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

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:

Types of knowledge

1. Declarative Knowledge:

o Declarative knowledge is to know about something.


o It includes concepts, facts, and objects.
o It is also called descriptive knowledge and expressed in declarative sentences.
o It is simpler than procedural language.

2. Procedural Knowledge

o It is also known as imperative knowledge.


o Procedural knowledge is a type of knowledge which is responsible for knowing
how to do something.
o It can be directly applied to any task.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

o It includes rules, strategies, procedures, agendas, etc.


o Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:

o Knowledge about the other types of knowledge is called Meta-knowledge.

4. Heuristic knowledge:

o Heuristic knowledge is representing knowledge of some experts in a field or


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

5. Structural knowledge:

o Structural knowledge is basic knowledge to problem-solving.


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

Propositional logic in Artificial intelligence

Propositional logic (PL) is the simplest form of logic where all the statements are made by
representation in propositions. A proposition is a declarative statement which is either true or
false. It is a technique of knowledge logical and mathematical form.

Example:
1. a) It is Sunday.
2. b) The Sun rises from West (False proposition)
3. c) 3+3= 7(False proposition)
4. d) 5 is a prime number.

Following are some basic facts about propositional logic:

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


o 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.
Downloaded by Sasi Prabha Singaravelu ([email protected])
lOMoARcPSD|44893945

o Propositions can be either true or false, but it cannot be both.


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

a. Atomic Propositions
b. Compound propositions

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

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


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

o Compound proposition: Compound propositions are constructed by combining


simpler or atomic propositions, using parenthesis and logical connectives.

Example:

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

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

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


Logical Connectives:

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


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

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


Positive literal or negative literal.
2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a
conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧ Q.
3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called
disjunction,where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
4. Implication: A sentence such as P → Q, is called an implication. Implications
are also known as if-then rules. It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet, so it is represented as P → Q
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence,
example If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.

Following is the summarized table for Propositional Logic


Connectives:

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

Truth Table:

In propositional logic, we need to know the truth values of propositions in all possible
scenarios. We can combine all the possible combination with logical connectives, and
the representation of these combinations in a tabular format is called Truth table.
Following are the truth table for all logical connectives:

Truth table with three propositions:


We can build a proposition composing three propositions P, Q, and R. This truth table
is made-up of 8n Tuples as we have taken three proposition symbols.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

Properties of Operators:
o Commutativity:
o P∧ Q= Q ∧ P, or
o P ∨ Q = Q ∨ P.
o Associativity:
o (P ∧ Q) ∧ R= P ∧ (Q ∧ R),
o (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
o Identity element:
o P ∧ True = P,
o P ∨ True= True.
o Distributive:
o P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
o P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
o DE Morgan's Law:
o ¬ (P ∧ Q) = (¬P) ∨ (¬Q)
o ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
o Double-negation elimination:
o ¬ (¬P) = P.

Limitations of Propositional logic:


o We cannot represent relations like ALL, some, or none with propositional logic.
Example:
a. All the girls are intelligent.
b. Some apples are sweet.
Downloaded by Sasi Prabha Singaravelu ([email protected])
lOMoARcPSD|44893945

Propositional logic has limited expressive power.


In propositional logic, we cannot describe statements in terms of their properties or
logical relationships.

First-Order Logic in Artificial intelligence


In the topic of Propositional logic, we have seen that how to represent statements using
propositional logic. But unfortunately, 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.

o "Some humans are intelligent", or


o "Sachin likes cricket."

To represent the above statements, PL logic is not sufficient, so we required some


more powerful logic, such as first-order logic.

First-Order logic:
o First-order logic is another way of knowledge representation in artificial
intelligence. It is an extension to propositional logic.
o FOL is sufficiently expressive to represent the natural language statements in a
concise way.
o 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.
o 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:
o Objects: A, B, people, numbers, colors, wars, theories, squares, pits,
wumpus, ......
o 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

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

o Function: Father of, best friend, third inning of, end of, ......
o As a natural language, first-order logic also has two main parts:
a. Syntax
b. 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.

Atomic sentences:
o 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.
o 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:
o Complex sentences are made by combining atomic sentences using connectives.

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

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


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

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.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

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:
o 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.
o 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:
o Complex sentences are made by combining atomic sentences using connectives.

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

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


o Predicate: A predicate can be defined as a relation, 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.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

Quantifiers in First-order logic:


o A quantifier is a language element which generates quantification, and
quantification specifies the quantity of specimen in the universe of discourse.
o 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:
a. Universal Quantifier, (for all, everyone, everything)
b. 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.

Note: In universal quantifier we use implication "→".

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

o For all x
o For each x
o For every x.

Example:
All man drink coffee.

Let a variable x which refers to a cat so all x can be represented in UOD as below:

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

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

Note: In Existential quantifier we always use AND or Conjunction symbol (∧).

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

o There exists a 'x.'


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

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

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

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

Points to remember:
o The main connective for universal quantifier ∀ is implication →.
o The main connective for existential quantifier ∃ is and ∧.

Properties of Quantifiers:
o In universal quantifier, ∀x∀y is similar to ∀y∀x.
o In Existential quantifier, ∃x∃y is similar to ∃y∃x.
o ∃x∀y is not similar to ∀y∃x.

Some Examples of FOL using quantifier:

1. All birds fly.


In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).

2. Every man respects his parent.


In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

3. Some boys play cricket.


In this question, the predicate is "play(x, y)," where x= boys, and y= game. Since there
are some boys so we will use ∃, and it will be represented as:
∃x boys(x) → play(x, cricket).

4. Not all students like both Mathematics and Science.


In this question, the predicate is "like(x, y)," where x= student, and y= subject.
Since there are not all students, so we will use ∀ with negation, so following
representation for this:
¬∀ (x) [ student(x) → like(x, Mathematics) ∧ like(x, Science)].

5. Only one student failed in Mathematics.


In this question, the predicate is "failed(x, y)," where x= student, and y= subject.
Since there is only one student who failed in Mathematics, so we will use following
representation for this:
∃(x) [ student(x) → failed (x, Mathematics) ∧∀ (y) [¬(x==y) ∧ student(y)
→ ¬failed (x, Mathematics)].

Free and Bound Variables:


The quantifiers interact with variables which appear in a suitable way. There are two
types of variables in First-order logic which are given below:

Free Variable: A variable is said to be a free variable in a formula if it occurs outside


the scope of the quantifier.

Example: ∀x ∃(y)[P (x, y, z)], where z is a free variable.

Bound Variable: A variable is said to be a bound variable in a formula if it occurs


within the scope of the quantifier.

Example: ∀x [A (x) B( y)], here x and y are the bound variables.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

Situation Calculus

The situation calculus is a logical language for representing changes. The Situation
Calculus is a logic formalism designed for representing and reasoning about dynamical
domains.

In First-Order Logic, sentences are either true or false and stay that way. Nothing is
corresponding to any sort of change.

Situation Calculus represents changing scenarios as a set of FOL formulae.

Situation Calculus :
Basic Elements

Actions that can be performed in the world

Actions can be quantified

Fluents that describe the state of the world

Situations represent a history of action occurrences

A dynamic world is modeled as progressing through a series of situations as a result of


various actions being performed within the world

A finite sequence of actions

A situation is not a state, but a history

A domain is encoded in FOL by three kind of formulae

Action precondition axioms and action effects axioms

Successor state axioms, one for each fluent

The foundational axioms of the situation calculus

The robot is in the kitchen.

in(robot, kitchen)

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

He walks into the living room.

in(robot, livingRoom)

in(robot,kitchen,2:02pm)

in(robot,livingRoom,2:17pm)

But what if you are not sure when it was?

We can do something simpler than rely on time stamps…

The Situation Calculus is a logic formalism for representing and reasoning about
dynamic domains.

The basic concepts in the situation calculus are situations, actions and
fluent. Briefly, actions are what make the dynamic world change from one situation to
another when performed by agents. Fluents are situation-dependent functions used to
describe the effects of actions.

There are two kinds of them, relational fluents and functional fluent .

The former have only two values: true or false, while the latter can take a range of values.

For instance, one may have a relational fluent called handempty which is true in a situation
if the robot’s hand is not holding anything. We may need a relation like this in a robot
domain.

One may also have a functional fluent called battery-level whose value in a situation is an
integer between 0 and 100 denoting the total battery power remaining on one’s laptop
computer.

To describe a dynamic domain in the situation calculus, one has to decide on the set of
actions available for the agents to perform, and the set of fluents needed to describe the
changes these actions will have on the world.

For example, consider the classic blocks world where some blocks of equal size can be
arranged into a set of towers on a table. The set of actions in this domain depends on what
the imaginary agent can do. If we imagine the agent to be a one-handed robot that can be
Downloaded by Sasi Prabha Singaravelu ([email protected])
lOMoARcPSD|44893945

directed to grasp any block that is on the top of a tower, and either add it to the top of
another tower or put it down on the table to make a new tower, then we can have the
following actions .

stack(x, y)—put block x on block y, provided the robot is holding x, and y is clear, i.e. there
is no other block on it;

• unstack(x, y)—pick up block x from block y, provided the robot’s hand is empty, x is on
y, and x is clear;

• putdown(x)—put block x down on the table, provided the robot is holding x;

• pickup(x)—pick up block x from the table, provided the robot’s hand is empty, x is on the
table and clear.

To describe the effects of these actions, we can use the following relational fluents:

• handempty—true in a situation if the robot’s hand is empty;

• holding(x)—true in a situation if the robot’s hand is holding block x;

• on(x, y)—true in a situation if block x is on block y;

• ontable(x)—true in a situation if block x is on the table;

• clear(x)—true in a situation if block x is the top block of a tower, i.e. the robot is not
holding it, and there is no other block on it.

If, however, the agent in this world can move a block from a clear position to another clear
position, then we only need the following action:

• move(x, y)—move block x to position y, provided that block x is clear to move, where a
position is either a block or the table.

To summarize, the situation calculus is a first-order language with the following special
sorts: situation, action, and fluent (for relational fluents). There could be other sorts, some of
them domain dependent like block for blocks in the blocks world or loc for locations in
logistics domain, and others domain independent like truth for truth values.

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

For now we assume the following special domain independent predicates and functions:

• Holds(p, s)—fluent p is true in situation s;

• do(a, s)—the situation that results from performing action a in situation s;

• Poss(a, s)—action a is executable in situation s.

We can now axiomatize our first blocks world domain with the following first-order
sentences (all free variables are assumed to be universally quantified):

Poss(stack(x, y), s) ≡ holding(x, s) ∧ clear(y, s),

Poss(unstack(x, y), s) ≡ on(x, y, s) ∧ clear(x, s) ∧ handempty(s),

Poss(pickup(x), s) ≡ ontable(x, s) ∧ clear(x, s) ∧ handempty(s),

Poss(putdown(x), s) ≡ holding(x, s),

Description logics

Description logics. A description logic is used to describe classes, properties, and


individuals. One of the main ideas behind a description logic is to separate
 a terminological knowledge base that describes the terminology, which should
remain constant as the domain being modeled changes, and
 an assertional knowledge base that describes what is true in some domain at
some point in time.

Usually, the terminological knowledge base is defined at the design time of the
system and defines the ontology, and it only changes as the meaning of the vocabulary
changes, which should be rare.
The assertional knowledge base usually contains the knowledge that is situation-
specific and is only known at run time.
It is typical to use triples to define the assertional knowledge base and a language such
as OWL Web Ontology Language to define the terminological knowledge base.
OWL describes domains in terms of the following:

Downloaded by Sasi Prabha Singaravelu ([email protected])


lOMoARcPSD|44893945

 Individuals are things in the world that is being described (e.g., a particular
house or a particular booking may be individuals).
 Classes are sets of individuals. A class is the set of all real or potential things
that would be in that class. For example, the class "House" may be the set of all
things that would be classified as a house, not just those houses that exist in the
domain of interest.
 Properties are used to describe individuals. A datatype property has values
that are primitive data types, such as integers or strings. For example,
"streetName" may be a datatype property between a street and string. An object
property has values that are other individuals. For example, "nextTo" may be a
property between two houses, and "onStreet" may be a property between a house
and a street.
In philosophy, ontology is the study of what exists. In AI, an ontology is a specification of

the meanings of the symbols in an information system.

Default Reasoning

Default reasoning occurs whenever the evidence available to


the reasoner does not guarantee the truth of the conclusion being drawn; that is, does not
deductively force the reasoner to draw the conclusion under consideration. For example,
from the statements ‘Most linguists speak more than three languages’ and ‘Kim is a
linguist’, one might draw the conclusion, by default, ‘Kim speaks more than three
languages’. Subsequent information may force the reasoner to withdraw that conclusion;
default reasoning is also termed non-monotonic, because the sentences held true at time 1
may not be true at time 2. We will call "Most linguists speak more than three languages" a
default rule.

Default reasoning is a form of nonmonotonic reasoning where plausible conclusions are


inferred based on general rules which may have exceptions (defaults). It is nonmonotonic in
the sense that additional information may force us to withdraw earlier conclusions

Downloaded by Sasi Prabha Singaravelu ([email protected])

You might also like