0% found this document useful (0 votes)
10 views134 pages

6CS4 AI Unit-3@Zammers

The document discusses knowledge-based systems (KBS) in artificial intelligence, highlighting their architecture, applications, and limitations. It explains the role of propositional and first-order logic in knowledge representation, detailing their syntax, semantics, and quantifiers. Additionally, it introduces situation calculus as a formalism for reasoning about dynamic domains and planning.

Uploaded by

mehtajinesh977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views134 pages

6CS4 AI Unit-3@Zammers

The document discusses knowledge-based systems (KBS) in artificial intelligence, highlighting their architecture, applications, and limitations. It explains the role of propositional and first-order logic in knowledge representation, detailing their syntax, semantics, and quantifiers. Additionally, it introduces situation calculus as a formalism for reasoning about dynamic domains and planning.

Uploaded by

mehtajinesh977
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 134

ARTIFICIAL INTELLIGENCE

(6CS4-05)

Unit III
Knowledge & Reasoning
BUILDING A
KNOWLEDGE
BASE
INTRODUCTION

A knowledge-based system (KBS) is a form of


artificial intelligence (AI) that aims to capture the
knowledge of human experts to support decision-making.
Examples of knowledge-based systems include
expert systems, which are so called because of their
reliance on human expertise.
Architecture

The typical architecture of a knowledge-based system, which


informs its problem-solving method, includes a knowledge
base and an inference engine. The knowledge base contains a
collection of information in a given field -- medical
diagnosis, for example. The inference engine deduces
insights from the information housed in the knowledge base.
Knowledge-based systems also include an interface through
which users query the system and interact with it.
Architecture
Where knowledge-based systems are used

Over the years, knowledge-based systems have been developed for


a number of applications. MYCIN, for example, was an early
knowledge-based system created to help doctors diagnose diseases.
Healthcare has remained an important market for knowledge-based
systems, which are now referred to as
clinical decision-support systems in the health sciences context.
Knowledge-based systems have also been employed in applications
as diverse as avalanche path analysis, industrial equipment fault
diagnosis and cash management.
Knowledge-based systems and artificial
intelligence

While a subset of artificial intelligence, classical knowledge-based systems


differ in approach to some of the newer developments in AI.
Daniel Dennett, a philosopher and cognitive scientist, in his 2017 book, From
Bacteria to Bach and Back, cited a strategy shift from early AI, characterized
by "top-down-organized, bureaucratically efficient know-it-all" systems to
systems that harness Big Data and "statistical pattern-finding techniques"
such as data-mining and deep learning in a more bottom-up approach.
Examples of AI following the latter approach include neural network
systems, a type of deep-learning technology that concentrates on signal
processing and pattern recognition problems such as facial recognition.
Building a Knowledge Base in Artificial
Intelligence

There are three components that make up a knowledge base


system that uses AI:
The actual knowledge stored in the system.
The inference engine, or “brain” of the system that applies
rules to the knowledge base to derive answers from it.
The user interface that agents and/or customers use to find
and extract relevant knowledge within the system.
Limitations

•Despite progress in machine learning, knowledge based systems still


haven’t reached a point where they can “think” like a human (i.e.,
common sense).
•Since decisions are made based on logical conditions and assertions, AI
knowledge base systems are inflexible and often difficult to manipulate.
•Knowledge bases can only offer solutions based on the data and
information stored within them. They do not interact with other sources.
That brings up the question of whether they’re truly offering the “best”
response.
PROPOSITIONAL
LOGIC
Propositional logic in Artificial intelligence

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.
Following are some basic facts about
propositional logic:
•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:
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 fa
ct.
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",


Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.
Assignment:
1. “ would you like to have tea or coffee? 2.
Logical Connectives:
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:
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:
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.
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
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: Associativity: Identity element:
P∧ Q= Q ∧ P, or (P ∧ Q) ∧ R= P ∧ (Q ∧ P ∧ True = P,
P ∨ Q = Q ∨ P. R), P ∨ True= True.
(P ∨ Q) ∨ R= P ∨ (Q ∨
R)

Distributive: DE Morgan's Law: Double-negation elimination:


P∧ (Q ∨ R) = (P ∧ Q) ∨ ¬ (P ∧ Q) = (¬P) ∨ (¬Q) ¬ (¬P) = P.
(P ∧ R). ¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
P ∨ (Q ∧ R) = (P ∨ Q)
∧ (P ∨ R).
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
Introduction

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.
"Some humans are intelligent", or
"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:

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

•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:
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, which
binds two atoms together in a statement.
First-order logic statements

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

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


For all x
For each x
For every x.

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

∀x man(x) → drink (x, 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.
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.
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).
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:
1. 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.
Free and Bound Variables:
2. 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.
SITUATION
CALCULAS
Introduction

The situation calculus is a logic formalism designed for


representing and reasoning about dynamical domains. It
was first introduced by John McCarthy in 1963.
What is Situation Calculus

Situation calculus is used for planning by asking for a


situation in which a goal is true. Answer extraction is
used to find a situation in which the goal is true. This
situation can be interpreted as a sequence of actions for
the agent to perform.
Overview

The situation calculus represents changing scenarios as a


set of first-order logic formulae.
The basic elements of the calculus are:
The actions that can be performed in the world
The fluents that describe the state of the world
The situations
A domain is formalized by a number of formulae,
namely:

•Action precondition axioms, one for each action


•Successor state axioms, one for each fluent
•Axioms describing the world in various situations
•The foundational axioms of the situation calculus
example

A simple robot world will be modeled as a running example.


In this world there is a single robot and several inanimate
objects. The world is laid out according to a grid so that
locations can be specified in terms of {\displaystyle
(x,y)} coordinate points. It is possible for the robot to move
around the world, and to pick up and drop items. Some
items may be too heavy for the robot to pick up, or fragile
so that they break when they are dropped. The robot also has
the ability to repair any broken items that it is holding.
Elements
•The main elements of the situation calculus are the
actions, fluents and the situations.
• A number of objects are also typically involved in the
description of the world.
• The situation calculus is based on a sorted domain with
three sorts: actions, situations, and objects, where the
objects include everything that is not an action or a situation.
•Variables of each sort can be used. While actions,
situations, and objects are elements of the domain, the
fluents are modeled as either predicates or functions.
Actions

The actions form a sort of the domain.


Variables of sort action can be used.
Actions can be quantified.
In the example robot world, possible action terms would be {\
displaystyle move(x,y)} to model the robot moving to a new
location {\displaystyle (x,y)}, and {\displaystyle
pickup(o)} to model the robot picking up an object o. A special
predicate Poss is used to indicate when an action is executable.
Situations

•In the situation calculus, a dynamic world is modeled as


progressing through a series of situations as a result of various
actions being performed within the world.
•A situation represents a history of action occurrences. In the
Reiter version of the situation calculus described here, a situation
does not represent a state, contrarily to the literal meaning of the
term and contrarily to the original definition by McCarthy and
Hayes. This point has been summarized by Reiter as follows:
Situations
A situation is a finite sequence of actions. Period. It's not a
state, it's not a snapshot, it's a history.[2]
The situation before any actions have been performed is typically
denoted {\displaystyle S_{0}} and called the initial situation.
The new situation resulting from the performance of an action is
denoted using the function symbol do (Some other references[
which?]
also use result).
This function symbol has a situation and an action as arguments,
and a situation as a result, the latter being the situation that
results from performing the given action in the given situation.
Fluents

Statements whose truth value may change are modeled


by relational fluents, predicates which take a situation as
their final argument. Also possible are functional fluents,
functions which take a situation as their final argument
and return a situation-dependent value. Fluents may be
thought of as "properties of the world"'.
Fluents

In the example, the fluent {\displaystyle {\textit {isCarrying}}


(o,s)} can be used to indicate that the robot is carrying a particular
object in a particular situation. If the robot initially carries
nothing, {\displaystyle {\textit {isCarrying}}(Ball,S_{0})} is
false while {\displaystyle {\textit {isCarrying}}
(Ball,do(pickup(Ball),S_{0}))} is true. The location of the robot
can be modeled using a functional fluent {\displaystyle
location(s)} which returns the location {\displaystyle (x,y)} of the
robot in a particular situation.
Fluents

In the example, the fluent {\displaystyle {\textit {isCarrying}}


(o,s)} can be used to indicate that the robot is carrying a particular
object in a particular situation. If the robot initially carries
nothing, {\displaystyle {\textit {isCarrying}}(Ball,S_{0})} is
false while {\displaystyle {\textit {isCarrying}}
(Ball,do(pickup(Ball),S_{0}))} is true. The location of the robot
can be modeled using a functional fluent {\displaystyle
location(s)} which returns the location {\displaystyle (x,y)} of the
robot in a particular situation.
Regression
Regression is a mechanism for proving consequences in
the situation calculus. It is based on expressing a formula
containing the situation {\displaystyle do(a,s)} in terms of
a formula containing the action a and the situation s, but
not the situation {\displaystyle do(a,s)}. By iterating this
procedure, one can end up with an equivalent formula
containing only the initial situation S_0. Proving
consequences is supposedly simpler from this formula
than from the original one.
Example

GOLOG is a logic programming language based on the


situation calculus
THEOREM
PROVING IN FIRST
ORDER LOGIC
Introduction
•Resolution in FOL
Resolution is a theorem proving technique that proceeds
by building refutation proofs, i.e., proofs by
contradictions.
It was invented by a Mathematician John Alan Robinson
in the year 1965.
Introduction
•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 or clausal
form.
What is clause and CNF?

Clause: Disjunction of literals (an atomic sentence) is


called a clause. It is also known as a unit clause.

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

To better understand all the above steps, we will take an


example in which we will apply resolution.
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.
Step-4: Draw Resolution graph:
Hence the negation of the conclusion has been proved as
a complete contradiction with the given set of statements.
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.
PLANNING
IN AI
INTRODUCTION

•Planning is an important part of Artificial Intelligence


which deals with the tasks and domains of a particular
problem. Planning is considered the logical side of acting.

•Everything we humans do is with a definite goal in mind,


and all our actions are oriented towards achieving our goal.
Similarly, Planning is also done for Artificial Intelligence.
What is planning in AI?

Planning in artificial intelligence is about decision-


making actions performed by robots or computer
programs to achieve a specific goal.

Execution of the plan is about choosing a sequence of


tasks with a high probability of accomplishing a specific
task.
For example,

Planning is required to reach a particular destination. It is


necessary to find the best route in Planning, but the tasks
to be done at a particular time and why they are done are
also very important.
What is a Plan?

We require domain description, task specification, and goal


description for any planning system. A plan is considered a
sequence of actions, and each action has its preconditions
that must be satisfied before it can act and some effects that
can be positive or negative.
So, we have Forward State Space Planning
(FSSP) and Backward State Space Planning (BSSP) at
the basic level.
1. Forward State Space Planning (FSSP)

FSSP behaves in the same way as forwarding state-space


search. It says that given an initial state S in any domain,
we perform some necessary actions and obtain a new state
S' (which also contains some new terms), called a
progression. It continues until we reach the target position.
Action should be taken in this matter.
Disadvantage: Large branching factor
Advantage: The algorithm is Sound
2. Backward State Space Planning (BSSP)

BSSP behaves similarly to backward state-space search. In this, we move


from the target state g to the sub-goal g, tracing the previous action to achieve
that goal. This process is called regression (going back to the previous goal or
sub-goal). These sub-goals should also be checked for consistency. The action
should be relevant in this case.
Disadvantages: not sound algorithm (sometimes inconsistency can be found)
Advantage: Small branching factor (much smaller than FSSP)
So for an efficient planning system, we need to combine the features of FSSP
and BSSP, which gives rise to target stack planning which will be discussed in
the next article.
Components of the planning system

The plan includes the following important steps:


Choose the best rule to apply the next rule based on the best
available guess.
Apply the chosen rule to calculate the new problem condition.
Find out when a solution has been found.
Detect dead ends so they can be discarded and direct system
effort in more useful directions.
Find out when a near-perfect solution is found.
Target stack plan

It is one of the most important planning algorithms used


by STRIPS.
Stacks are used in algorithms to capture the action and
complete the target. A knowledge base is used to hold the
current situation and actions.
A target stack is similar to a node in a search tree, where
branches are created with a choice of action.
The important steps of the algorithm are
mentioned below:

Start by pushing the original target onto the stack. Repeat


this until the pile is empty. If the stack top is a mixed
target, push its unsatisfied sub-targets onto the stack.
If the stack top is a single unsatisfied target, replace it
with action and push the action precondition to the stack
to satisfy the condition.
Non-linear Planning
This Planning is used to set a goal stack and is included in
the search space of all possible sub-goal orderings. It
handles the goal interactions by the interleaving method.
Advantages of non-Linear Planning
Non-linear Planning may be an optimal solution
concerning planning length (depending on the search
strategy used). Disadvantages of Nonlinear Planning
It takes a larger search space since all possible goal
orderings are considered.
PARTIAL ORDER
PLANNING IN AI
INTRODUCTION
Any algorithm that can place two actions into a plan without specifying which comes first
is called as Partial Order Planning.
Partial Order Planning works on several sub-goals independently & solves them with
several sub-plans & thereafter combines them.

With Partial Order Planning, problems can be decomposed so it can work well with non-
cooperative environments. Thus, it is a plan which specifies all actions that need to be
taken, but only specifies the order between actions when necessary.

It uses a least commitment strategy.


It consists of two states: “start” & “finish” where,

Start: No preconditions & Effects are initial states.


Finish: No effects & Preconditions are goals.
Partial Order Planning for Wearing a Shoe

Here, the partial order planner for wearing a shoe combines


two actions sequences:

LeftSock & LeftShoe:


Wearing the LeftSock is a precondition for wearing the
LeftShoe.
RightSock & RightShoe:
Wearing the RightSock is a precondition for wearing the
RightShoe.
Partial Order Planning as a search problem:

A partial-order plan consists of four components:


1. Set of actions:
They form the steps of the plans.
Actions which can be performed, to achieve a goal are
stored in set of actions component.
Eg: Set of actions = { Start, RightSock, RightShoe,
LeftSock, LeftShoe, Finish }
2. Set of ordering preconditions:

They are ordering constraints i.e. without performing


action “x” we cannot perform “y”.
Eg: Set of ordering = { RightSock < RightShoe; LeftSock
< LeftShoe } i.e to wear a shoe, first a sock has to be
worn.
3. Set of casual links:

It specifies which actions meet which preconditions of


other actions.
It provides a link from outcome of one step to precondition
of another.
Eg: Set of casual links = { RightSock -> RightSockOn ->
RightShoe, LeftSock -> LeftSockOn -> LeftShoe,
RightShoe -> RightShoeOn -> Finish, LeftShoe ->
LeftShoeOn -> Finish }
4. Set of open preconditions:

It specifies which preconditions are not fulfilled by any


action in the partial order plan.
A plan is a solution if the set of open preconditions is
empty.
Advantages of Partial Order Planning:

•Solves a huge state space problem in only a few steps.


•Least commitment strategy means that search only occurs in places where sub-
plans interact & delays the choice during the search.
•Causal links used in this planner allows to recognize when to abandon a
unworkable plan without wasting time exploring irrelevant parts.
•The solution for partial order planning is a complete, consistent plan.

•A complete plan: Every precondition of every step is achieved by some other step.

•A consistent plan: There are no contradictions in the ordering or causal


constraints.
UNCERTAIN
KNOWLEDGE
& REASONING
Introduction
In real life, it is not always possible to determine the state of the
environment as it might not be clear. Due to partially observable or
non-deterministic environments, agents may need to handle uncertainty
and deal with:
•Uncertain data: Data that is missing, unreliable, inconsistent or noisy
•Uncertain knowledge: When the available knowledge has multiple
causes leading to multiple effects or incomplete knowledge of causality
in the domain
•Uncertain knowledge representation: The representations which
provides a restricted model of the real system, or has limited
expressiveness.
For example,
In case of Medical diagnosis consider the rule Toothache = Cavity.
This is not complete as not all patients having toothache have cavities. So we can
write a more generalized rule
Toothache = Cavity V Gum problems V Abscess…

To make this rule complete, we will have to list all the possible causes of toothache.
But this is not feasible due to:
•Laziness- It will require a lot of effort to list the complete set of antecedents and
consequents to make the rules complete.
•Theoretical ignorance- Medical science does not have complete theory for the
domain
•Practical ignorance- It might not be practical that all tests have been or can be
conducted for the patients.
Solution:

Such uncertain situations can be dealt with using


•Probability theory
•Truth Maintenance systems
•Fuzzy logic.
Probability
Probability is the degree of likeliness that an event will
occur. It provides a certain degree of belief in case of
uncertain situations.
It is defined over a set of events U and assigns value P(e)
i.e. probability of occurrence of event e in the range
[0,1].
Here each sentence is labeled with a real number in the
range of 0 to 1, 0 means the sentence is false and 1 means
it is true.
Probability
Conditional Probability or Posterior Probability is the probability of event A given
that B has already occurred.
P(A|B) = (P(B|A) * P(A)) / P(B)

For example,
P(It will rain tomorrow| It is raining today) represents conditional probability of it
raining tomorrow as it is raining today.
P(A|B) + P(NOT(A)|B) = 1
Joint probability is the probability of 2 independent events happening simultaneously
like rolling two dice or tossing two coins together.
For example, Probability of getting 2 on one dice and 6 on the other is equal to 1/36.
Joint probability has a wide use in various fields such as physics, astronomy, and comes
into play when there are two independent events. The full joint probability distribution
specifies the probability of each complete assignment of values to random variables.
Bayes Theorem
It is based on the principle that every pair of features being classified is independent of
each other.
It calculates probability P(A|B) where A is class of possible outcomes and B is given
instance which has to be classified.
P(A|B) = P(B|A) * P(A) / P(B)

Where:
P(A|B) – the probability of event A occurring, given event B has occurred
P(B|A) – the probability of event B occurring, given event A has occurred
P(A) – the probability of event A
P(B) – the probability of event B
Fuzzy logic

Fuzzy logic is a method of reasoning applied to the AI,


which resembles human reasoning. Here the word
"fuzzy" defines things that are not clear, it means the
situations where it is difficult to decide if the state is
True or False.
It involves all the possibilities that occur between Yes
and NO.
The below diagram shows the difference between
fuzzy logic and Boolean logic
Since it resembles human reasoning, hence it can
be used in neural networks.
Introduction to Reasoning with Uncertain
Knowledge:
Reasoning probably brings to mind logic puzzles, but it is something which we do every
day of our lives.
Reasoning in AI is the process by which we use the knowledge we have to draw
conclusions or infer something new about a domain of interest. It is necessary part of
what we call “intelligence”.

Without the ability to reason we are doing little more than a lookup when we use
information.

In fact, this is the difference between a standard data base system and a knowledge base.
Both have information which can be accessed in various ways but the data base, unlike
the knowledge base in the expert system, has no reasoning facilities and can therefore
answer only limited specific questions.
example
•What are the types of reasoning we come across?
• How do we know what to expect when we go on a train journey? What do
we think when our friend is annoyed with us?
•How do we know what will happen if our car has a flat battery?
•Whether we are aware of it or not, we will use a number of different
methods of reasoning, depending on the problem we are considering and the
information that we have before us.

The three everyday situations mentioned above illustrate three key types of
reasoning which we use. In the first case we know what to expect on a train
journey because of our experience of numerous other train journeys. We
infer that the new journey will share common features with the examples.
example
We are aware of the first example called induction, which can be
summarised as generalisation from cases seen to infer information about
cases unseen.
We use it frequently in learning about the world around us. For example,
every crow we see is black; therefore we infer that all crows are black. If
we think about it, such reasoning is unreliable, we can never prove our
inferences to be true, we can only prove them to be false.
Take the crow again.
To prove that all crows are black we would have to confirm that all crows
which exist, have existed or will exist are black. This is obviously not
possible. However, to disprove the statement, all we need is to produce a
single crow which is white or pink.
example

So at best we can amass evidence to support our belief that all crows are
black. In spite of its unreliability inductive reasoning is very useful and is
the basis of much of our learning. It is used particularly in machine
learning.

The second example we considered was working out why a friend is


annoyed with us, in other words trying to find an explanation for our
friend’s behaviour. It may be that this particular friend is a stickler for
punctuality and we are a few minutes late to our rendezvous. We may
therefore infer that our friend’s anger is caused by we being late.
example

This is abduction, the process of reasoning back from something to the state or event
which caused it.
Of course this too is unreliable; it may be possible that our friend is angry for some
other reason (perhaps we had promised to telephone him before coming to him but
had avoided).
Abduction can be used in cases where the knowledge is incomplete, Abduction can
provide a “best guess” given, the available evidence.

The third problem is usually solved by deduction: we have knowledge about cars
such as “if the battery is flat the headlights won’t work”; we know the battery is flat
so we can infer that the lights won’t work. This is the reasoning of standard logic.
Indeed, we would express our car problem in
terms of logic given that:

a = the battery is flat and b = the lights won’t work and


the axioms
ᗄx: a(x) → b(x)
a (my car).
example

We can deduce b the light of my car won’t work (my car).


However, we cannot deduce the inverse: that is if we
know b, we cannot deduce a; the battery of my car is flat
if the lights of my car won’t work. This is not permitted in
standard logic. If lights don’t work we may use abduction
to derive this explanation. However, it could be wrong;
there may be another explanation for the light failure (for
example, a bulb may have blown or the battery
connections may be loose).
Deduction

Deduction is probably the most familiar form of explicit reasoning.


It can be defined as the process of driving the logically necessary
conclusion from the initial premises.
For example:
Elephants are bigger than dogs
Dogs are bigger than mice
Therefore
Elephants are bigger than mice
However, it should be noted that deduction is concerned with logical
validity, not actual truth.
Consider the following example; given the facts,
can we reach the conclusion by deduction?

Some dogs are greyhounds


The greyhounds run fast
Therefore
Some dogs run fast.
The answer is no. We cannot make this deduction because we do not know that all
greyhounds are dogs. The fast dogs may therefore be the greyhounds which are
not dogs. This of course is non-sensual in terms of what we know (or more
accurately have induced) about the real world, but it is perfectly valid based on the
premises given. We should therefore be cautious: deduction (also called analogical
inference) does not always correspond to natural human (common sense)
reasoning.
BAYESIAN
NETWORK
Introduction

Bayesian networks are a broadly utilized class of


probabilistic graphical models.

A Bayesian network is a flexible, interpretable and


compact portrayal of a joint probability distribution.
They comprise 2 sections:

Parameters: The parameters comprise restrictive


likelihood circulations related to every node.
Structure: The structure is a DAG (Directed Acyclic
Graph) that communicates contingent dependencies and
independencies among arbitrary factors related to nodes.
Some major Bayesian-network applications are:

System Biology
Turbo Code
Spam Filter
Image Processing
Semantic Search
Information Retrieval
Document Classification
Biomonitoring
Medicine
Gene Regulatory Network
The 4 major Bayesian analytics disciplines are:

Prescriptive analytics: Decision making under uncertainty,


decision support, cost-based decision making, and decision
automation.
Predictive analytics: Latent variable, time series, supervised or
unsupervised, and anomaly detection.
Diagnostic analytics: Reasoning, the value of information, tracing
anomalies, and troubleshooting.
Descriptive analytics: Multivariate, automated insight, anomalous
patterns, and large patterns.
Bayesian Network

Bayesian belief network is key machine innovation for


managing probabilistic occasions and to take care of a
difficulty that has a vulnerability.
Bayesian Network

example:
It could address the probabilistic connections among
symptoms and diseases. Given symptoms, the network
can be utilized to register the possibilities of the
appearance of different illnesses.
BAYES THEOREM

So how does the Bayesian-network formula really look?


In its most basic structure, we are figuring the conditional
probability signified as P(C|D) – the probability of the
occasion C happening given that D is valid. Bayes’ is
communicated with the accompanying formula:
P(C|D) = [P(D|C) * P(C)]/P(D)
BAYES THEOREM

Where,
C and D are sure events.
P(C) is the probability of occasion C happening.
P(C|D) is the conditional probability of occasion C
happening given that D has occurred.
P(D) is the probability of the occasion D happening.
P(D|C) is the conditional probability of occasion D
happening given that C has occurred.
BAYES THEOREM

The condition can likewise be switched and composed as follows to


compute the probability of occasion D happening given that C has occurred:
P(D|C) = [P(C|D) * P(D)]/P(C)
The Bayesian-network inference is the way toward computing a probability
appropriation of interest for example P (C | D=True), or P (C, D|A, B=True).
There is an enormous number of definite and uncertain inference for
Bayesian-networks algorithms. Bayes Server upholds both accurate and
rough inference with Decision Graphs, Dynamic Bayesian Networks, and
Bayesian Networks.
Bayes’ theorem
is a way to figure out conditional probability. Conditional probability is the probability
of an event happening, given that it has some relationship to one or more other events.
For example, your probability of getting a parking space is connected to the time of
day you park, where you park, and what conventions are going on at any time. Bayes’
theorem is slightly more nuanced. In a nutshell, it gives you the actual probability of
an event given information about tests.

“Events” Are different from “tests.” For example, there is a test for liver disease, but
that’s separate from the event of actually having liver disease.
Tests are flawed: just because you have a positive test does not mean you actually
have the disease. Many tests have a high false positive rate. Rare events tend to have
higher false positive rates than more common events. We’re not just talking about
medical tests here. For example, spam filtering can have high false positive rates.
Bayes’ theorem takes the test results and calculates your real probability that the test
has identified the event.
Bayes’ Theorem Example #1

You might be interested in finding out a patient’s probability of having liver disease if they
are an alcoholic. “Being an alcoholic” is the test (kind of like a litmus test) for liver disease.
A could mean the event “Patient has liver disease.” Past data tells you that 10% of patients
entering your clinic have liver disease. P(A) = 0.10.
B could mean the litmus test that “Patient is an alcoholic.” Five percent of the clinic’s
patients are alcoholics. P(B) = 0.05.
You might also know that among those patients diagnosed with liver disease, 7% are
alcoholics. This is your B|A: the probability that a patient is alcoholic, given that they have
liver disease, is 7%.
Bayes’ theorem tells you:
P(A|B) = (0.07 * 0.1)/0.05 = 0.14
In other words, if the patient is an alcoholic, their chances of having liver disease is 0.14
(14%). This is a large increase from the 10% suggested by past data. But it’s still unlikely
that any particular patient has liver disease.
Bayes’ Theorem Problems Example #2

Another way to look at the theorem is to say that one event follows another. Above I said “tests” and
“events”, but it’s also legitimate to think of it as the “first event” that leads to the “second event.” There’s no
one right way to do this: use the terminology that makes most sense to you.
In a particular pain clinic, 10% of patients are prescribed narcotic pain killers. Overall, five percent of the
clinic’s patients are addicted to narcotics (including pain killers and illegal substances). Out of all the people
prescribed pain pills, 8% are addicts. If a patient is an addict, what is the probability that they will be
prescribed pain pills?
Step 1: Figure out what your event “A” is from the question. That information is in the italicized part of
this particular question. The event that happens first (A) is being prescribed pain pills. That’s given as 10%.
Step 2: Figure out what your event “B” is from the question. That information is also in the italicized part
of this particular question. Event B is being an addict. That’s given as 5%.
Step 3: Figure out what the probability of event B (Step 2) given event A (Step 1). In other words, find
what (B|A) is. We want to know “Given that people are prescribed pain pills, what’s the probability they are
an addict?” That is given in the question as 8%, or .8.
Step 4: Insert your answers from Steps 1, 2 and 3 into the formula and solve.
P(A|B) = P(B|A) * P(A) / P(B) = (0.08 * 0.1)/0.05 = 0.16
The probability of an addict being prescribed pain pills is 0.16 (16%).
Example #3: the Medical Test

A slightly more complicated example involves a medical test (in this case, a
genetic test):
There are several forms of Bayes’ Theorem out there, and they are all
equivalent (they are just written in slightly different ways). In this next
equation, “X” is used in place of “B.” In addition, you’ll see some changes in
the denominator. The proof of why we can rearrange the equation like this is
beyond the scope of this article (otherwise it would be 5,000 words instead of
2,000!). However, if you come across a question involving medical tests,
you’ll likely be using this alternative formula to find the answer:
Example 3
1% of people have a certain genetic defect.90% of tests for the gene detect the defect (true positives).
9.6% of the tests are false positives.If a person gets a positive test result, what are the odds they
actually have the genetic defect?
The first step into solving Bayes’ theorem problems is to assign letters to events:
A = chance of having the faulty gene. That was given in the question as 1%. That also means the
probability of not having the gene (~A) is 99%.
X = A positive test result.
So:
P(A|X) = Probability of having the gene given a positive test result.
P(X|A) = Chance of a positive test result given that the person actually has the gene. That was given
in the question as 90%.
p(X|~A) = Chance of a positive test if the person doesn’t have the gene. That was given in the
question as 9.6%
Now we have all of the information we need to put into the equation:
P(A|X) = (.9 * .01) / (.9 * .01 + .096 * .99) = 0.0865 (8.65%).
The probability of having the faulty gene on the test is 8.65%.
Bayes’ Theorem Problems: Another Way to Look at
It.

Bayes’ theorem problems can be figured out without using the equation (although using the
equation is probably simpler). But if you can’t wrap your head around why the equation works
(or what it’s doing), here’s the non-equation solution for the same problem in #1 (the genetic test
problem) above.
Step 1: Find the probability of a true positive on the test. That equals people who actually have
the defect (1%) * true positive results (90%) = .009.
Step 2: Find the probability of a false positive on the test. That equals people who don’t have the
defect (99%) * false positive results (9.6%) = .09504.
Step 3: Figure out the probability of getting a positive result on the test. That equals the chance
of a true positive (Step 1) plus a false positive (Step 2) = .009 + .09504 = .0.10404.
Step 4: Find the probability of actually having the gene, given a positive result. Divide the
chance of having a real, positive result (Step 1) by the chance of getting any kind of positive
result (Step 3) = .009/.10404 = 0.0865 (8.65%)
THANK
YOU

You might also like