SlideShare una empresa de Scribd logo
1 de 41
CS344 : Introduction to Artificial
Intelligence
Pushpak Bhattacharyya
CSE Dept.,
IIT Bombay
Lecture 15- Robotic Knowledge
Representation and Inferencing; Prolog
A planning agent



An agent interacts with the world via perception and actions
Perception involves sensing the world and assessing the
situation









creating some internal representation of the world

Actions are what the agent does in the domain. Planning
involves reasoning about actions that the agent intends to carry
out
Planning is the reasoning side of acting
This reasoning involves the representation of the world that the
agent has, as also the representation of its actions.
Hard constraints where the objectives have to be achieved
completely for success
The objectives could also be soft constraints, or preferences, to
be achieved as much as possible
Interaction with static domain








The agent has complete information of the domain
(perception is perfect), actions are instantaneous and
their effects are deterministic.
The agent knows the world completely, and it can
take all facts into account while planning.
The fact that actions are instantaneous implies that
there is no notion of time, but only of sequencing of
actions.
The effects of actions are deterministic, and therefore
the agent knows what the world will be like after each
action.
Two kinds of planning


Projection into the future




The planner searches through the possible
combination of actions to find the plan that
will work

Memory based planning



looking into the past
The agent can retrieve a plan from its
memory
Planning
•Definition : Planning is arranging a sequence of
actions to achieve a goal.
•Uses core areas of AI like searching and reasoning &
•Is the core for areas like NLP, Computer Vision.
•Robotics

Kinematics (ME)
Planning (CSE)

•Examples : Navigation , Manoeuvring, Language
Processing (Generation)
Language & Planning
• Non-linguistic representation for sentences.
agent
I

see

object
movie

•Sentence generation
•Word order determination (Syntax planning)
E.g. I see movie ( English)
I movie see (Intermediate Language)
STRIPS
•Stanford Research Institute Problem Solver (1970s)
•Planning system for a robotics project : SHAKEY (by
Nilsson et.al.)
•Knowledge Representation : First Order Logic.
•Algorithm : Forward chaining on rules.
•Any search procedure : Finds a path from start to goal.
•Forward Chaining : Data-driven inferencing
•Backward Chaining : Goal-driven
Forward & Backward Chaining
•Rule : man(x)  mortal(x)
•Data : man(Shakespeare)
To prove : mortal(Shakespeare)
•Forward Chaining:
man(Shakespeare) matches LHS of Rule.
X = Shakespeare
⇒ mortal( Shakespeare) added
-Forward Chaining used by design expert systems
•Backward Chaining: uses RHS matching
- Used by diagnostic expert systems
Example : Blocks World
•STRIPS : A planning system – Has rules with
precondition deletion list and addition list
Robot
hand

C
A

A
B
C

B
START

Sequence of actions :
1. Grab C
2. Pickup C
3. Place on table C
4. Grab B
5. Pickup B

Robot
hand

GOAL

6.
7.
8.
9.

Stack B on C
Grab A
Pickup A
Stack A on B
Example : Blocks World
•Fundamental Problem :
The frame problem in AI is concerned with the question
of what piece of knowledge is relevant to the situation.
•Fundamental Assumption : Closed world assumption
If something is not asserted in the knowledge base, it is
assumed to be false.
(Also called “Negation by failure”)
Example : Blocks World
•STRIPS : A planning system – Has rules with
precondition deletion list and addition list
Robot
hand

C
A

B
START

on(B, table)
on(A, table)
on(C, A)
hand empty
clear(C)
clear(B)

A
B
C
GOAL

on(C, table)
on(B, C)
on(A, B)
hand empty
clear(A)

Robot
hand
Rules
•R1 : pickup(x)
Precondition & Deletion List : hand empty,
on(x,table), clear(x)
Add List : holding(x)
•R2 : putdown(x)
Precondition & Deletion List : holding(x)
Add List : hand empty, on(x,table), clear(x)
Rules
•R3 : stack(x,y)
Precondition & Deletion List :holding(x), clear(y)
Add List : on(x,y), clear(x)
•R4 : unstack(x,y)
Precondition & Deletion List : on(x,y), clear(x)
Add List : holding(x), clear(y)
Plan for the block world problem
• For the given problem, Start  Goal can be achieved
by the following sequence :
1. Unstack(C,A)
2. Putdown(C)
3. Pickup(B)
4. Stack(B,C)
5. Pickup(A)
6. Stack(A,B)
• Execution of a plan: achieved through a data structure
called Triangular Table.
Triangular Table
on(C,A)
1 clear(C)
hand empty unstack(C,A)
holding(C)

2
3 on(B,table)

hand empty
clear(C)

4
5

putdown(C)

on(A,table)

pickup(B)
holding(B)

clear(A)

stack(B,C)
hand empty

6

clear(B)
on(C,table)

7
0

1

2

pickup(A)
holding(A)

on(B,C)

3

4

stack(A,B)
on(A,B)
clear(A)

5

6
Triangular Table
•
•
•
•
•
•

For n operations in the plan, there are :
• (n+1) rows : 1  n+1
• (n+1) columns : 0  n
At the end of the ith row, place the ith component of the plan.
The row entries for the ith step contain the pre-conditions for the
ith operation.
The column entries for the jth column contain the add list for the
rule on the top.
The <i,j> th cell (where 1 ≤ i ≤ n+1 and 0≤ j ≤ n) contain the preconditions for the ith operation that are added by the jth operation.
The first column indicates the starting state and the last row
indicates the goal state.
Search in case of planning
Start


Ex: Blocks world

Pickup(B)
S1




Unstack(C,A)
S2

Triangular table leads
to some amount of fault-tolerance in the robot
NOT ALLOWED

C
A

B
START

A

B

C

A
C

B

WRONG
MOVE
Resilience in Planning






After a wrong operation, can the robot come back
to the right path ?
i.e. after performing a wrong operation, if the
system again goes towards the goal, then it has
resilience w.r.t. that operation
Advanced planning strategies
 Hierarchical planning
 Probabilistic planning
 Constraint satisfaction
Prolog Programming
Introduction



PROgramming in LOGic
Emphasis on what rather than how
Problem in Declarative Form

Logic Machine

Basic Machine
Prolog’s strong and weak
points





Assists thinking in terms of objects and
entities
Not good for number crunching
Useful applications of Prolog in





Expert Systems (Knowledge
Representation and Inferencing)
Natural Language Processing
Relational Databases
A Typical Prolog program
Compute_length ([],0).
Compute_length ([Head|Tail], Length):Compute_length (Tail,Tail_length),
Length is Tail_length+1.
High level explanation:
The length of a list is 1 plus the length of the
tail of the list, obtained by removing the first
element of the list.
This is a declarative description of the
computation.
Fundamentals
(absolute basics for writing Prolog
Programs)
Facts


John likes Mary










like(john,mary)

Names of relationship and objects must begin
with a lower-case letter.
Relationship is written first (typically the
predicate of the sentence).
Objects are written separated by commas
and are enclosed by a pair of round brackets.
The full stop character ‘.’ must come at the
end of a fact.
More facts

Predicate

Interpretation

valuable(gold)

Gold is valuable.

owns(john,gold)

John owns gold.

father(john,mary)

John is the father of
Mary
John gives the book to
Mary

gives (john,book,mary)
Questions


Questions based on facts



Answered by matching

Two facts match if their predicates are same
(spelt the same way) and the arguments each
are same.


If matched, prolog answers yes, else no.



No does not mean falsity.
Prolog does theorem proving





When a question is asked, prolog tries
to match transitively.
When no match is found, answer is no.
This means not provable from the given
facts.
Variables


Always begin with a capital letter





?- likes (john,X).
?- likes (john, Something).

But not


?- likes (john,something)
Example of usage of variable
Facts:

likes(john,flowers).
likes(john,mary).
likes(paul,mary).

Question:
?- likes(john,X)
Answer:

X=flowers and wait
;
mary
;
no
Conjunctions



Use ‘,’ and pronounce it as and.
Example


Facts:







likes(mary,food).
likes(mary,tea).
likes(john,tea).
likes(john,mary)

?


likes(mary,X),likes(john,X).
Meaning is anything liked by Mary also liked by John?
Backtracking (an inherent property of
prolog programming)
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)

1. First goal succeeds. X=food
2. Satisfy likes(john,food)
Backtracking (continued)
Returning to a marked place and trying to resatisfy is
called Backtracking
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)

1. Second goal fails
2. Return to marked place
and try to resatisfy the first goal
Backtracking (continued)
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)

1. First goal succeeds again, X=tea
2. Attempt to satisfy the likes(john,tea)
Backtracking (continued)
likes(mary,X),likes(john,X)
likes(mary,food)
likes(mary,tea)
likes(john,tea)
likes(john,mary)

1. Second goal also suceeds
2. Prolog notifies success and waits for a reply
Rules




Statements about objects and their
relationships
Expess


If-then conditions





Generalizations





I use an umbrella if there is a rain
use(i, umbrella) :- occur(rain).
All men are mortal
mortal(X) :- man(X).

Definitions



An animal is a bird if it has feathers
bird(X) :- animal(X), has_feather(X).
Syntax




<head> :- <body>
Read ‘:-’ as ‘if’.
E.G.






likes(john,X) :- likes(X,cricket).
“John likes X if X likes cricket”.
i.e., “John likes anyone who likes cricket”.

Rules always end with ‘.’.
Another Example
sister_of (X,Y):- female (X),
parents (X, M, F),
parents (Y, M, F).
X is a sister of Y is
X is a female and
X and Y have same parents
Question Answering in presence
of rules


Facts







male (ram).
male (shyam).
female (sita).
female (gita).
parents (shyam, gita, ram).
parents (sita, gita, ram).
Question Answering: Y/N type: is sita the
sister of shyam?
?- sister_of (sita, shyam)

female(sita)

parents(sita,M,F)

parents(shyam,M,F)

parents(shyam,gita,ram)
parents(sita,gita,ram)
success
Question Answering: wh-type: whose
sister is sita?
?- ?- sister_of (sita, X)

female(sita)

parents(sita,M,F)

parents(Y,M,F)

parents(Y,gita,ram)
parents(sita,gita,ram)
parents(shyam,gita,ram)
Success
Y=shyam
Exercise
1. From the above it is possible for
somebody to be her own sister. How
can this be prevented?

Más contenido relacionado

Similar a Cs344 lect15-robotic-knowledge-inferencing-prolog-11feb08

Cs221 lecture7-fall11
Cs221 lecture7-fall11Cs221 lecture7-fall11
Cs221 lecture7-fall11darwinrlo
 
CS1017-unitIV.pdf
CS1017-unitIV.pdfCS1017-unitIV.pdf
CS1017-unitIV.pdfSaswatSeth
 
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...oxwocs
 
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...Numenta
 
cps270_planning.ppt
cps270_planning.pptcps270_planning.ppt
cps270_planning.pptprasath r
 
Unit 5 Introduction to Planning and ANN.pptx
Unit 5 Introduction to Planning and ANN.pptxUnit 5 Introduction to Planning and ANN.pptx
Unit 5 Introduction to Planning and ANN.pptxDrYogeshDeshmukh1
 
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxRuchitaMaaran
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)Nitesh Singh
 
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAI
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAIDeep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAI
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAIJack Clark
 
mlrev.ppt
mlrev.pptmlrev.ppt
mlrev.pptbutest
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculusRajendran
 
Abductive commonsense reasoning
Abductive commonsense reasoningAbductive commonsense reasoning
Abductive commonsense reasoningSan Kim
 
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdfAmirMohamedNabilSale
 

Similar a Cs344 lect15-robotic-knowledge-inferencing-prolog-11feb08 (20)

Cs221 lecture7-fall11
Cs221 lecture7-fall11Cs221 lecture7-fall11
Cs221 lecture7-fall11
 
CS1017-unitIV.pdf
CS1017-unitIV.pdfCS1017-unitIV.pdf
CS1017-unitIV.pdf
 
AI_Planning.pdf
AI_Planning.pdfAI_Planning.pdf
AI_Planning.pdf
 
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...
Sheila Mcllraith: Of Programs, Plans, and Automata: 101 things you can do wit...
 
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...
Brains@Bay Meetup: The Increasing Role of Sensorimotor Experience in Artifici...
 
cps270_planning.ppt
cps270_planning.pptcps270_planning.ppt
cps270_planning.ppt
 
Prolog
PrologProlog
Prolog
 
Unit 5 Introduction to Planning and ANN.pptx
Unit 5 Introduction to Planning and ANN.pptxUnit 5 Introduction to Planning and ANN.pptx
Unit 5 Introduction to Planning and ANN.pptx
 
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptxARTIFICIAL INTELLIGENCE---UNIT 4.pptx
ARTIFICIAL INTELLIGENCE---UNIT 4.pptx
 
Logic programming (1)
Logic programming (1)Logic programming (1)
Logic programming (1)
 
RPT_AI-06_A_Planning Intro.ppt
RPT_AI-06_A_Planning Intro.pptRPT_AI-06_A_Planning Intro.ppt
RPT_AI-06_A_Planning Intro.ppt
 
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAI
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAIDeep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAI
Deep Reinforcement Learning Through Policy Optimization, John Schulman, OpenAI
 
mlrev.ppt
mlrev.pptmlrev.ppt
mlrev.ppt
 
artficial intelligence
artficial intelligenceartficial intelligence
artficial intelligence
 
ppt
pptppt
ppt
 
ppt
pptppt
ppt
 
Predicate calculus
Predicate calculusPredicate calculus
Predicate calculus
 
Abductive commonsense reasoning
Abductive commonsense reasoningAbductive commonsense reasoning
Abductive commonsense reasoning
 
PROLOG: Introduction To Prolog
PROLOG: Introduction To PrologPROLOG: Introduction To Prolog
PROLOG: Introduction To Prolog
 
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
 

Más de Praveen Kumar (20)

Summer2014 internship
Summer2014 internshipSummer2014 internship
Summer2014 internship
 
Summer+training 2
Summer+training 2Summer+training 2
Summer+training 2
 
Summer+training
Summer+trainingSummer+training
Summer+training
 
Solutions1.1
Solutions1.1Solutions1.1
Solutions1.1
 
Slides15
Slides15Slides15
Slides15
 
Scribed lec8
Scribed lec8Scribed lec8
Scribed lec8
 
Scholarship sc st
Scholarship sc stScholarship sc st
Scholarship sc st
 
Networks 2
Networks 2Networks 2
Networks 2
 
Mithfh lecturenotes 9
Mithfh lecturenotes 9Mithfh lecturenotes 9
Mithfh lecturenotes 9
 
Mcs student
Mcs studentMcs student
Mcs student
 
Math350 hw2solutions
Math350 hw2solutionsMath350 hw2solutions
Math350 hw2solutions
 
Matching
MatchingMatching
Matching
 
Line circle draw
Line circle drawLine circle draw
Line circle draw
 
Lecture3
Lecture3Lecture3
Lecture3
 
Lec2 state space
Lec2 state spaceLec2 state space
Lec2 state space
 
Graphtheory
GraphtheoryGraphtheory
Graphtheory
 
Graphics display-devicesmod-1
Graphics display-devicesmod-1Graphics display-devicesmod-1
Graphics display-devicesmod-1
 
Games.4
Games.4Games.4
Games.4
 
Dda line-algorithm
Dda line-algorithmDda line-algorithm
Dda line-algorithm
 
Cse3461.c.signal encoding.09 04-2012
Cse3461.c.signal encoding.09 04-2012Cse3461.c.signal encoding.09 04-2012
Cse3461.c.signal encoding.09 04-2012
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 

Último (20)

Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 

Cs344 lect15-robotic-knowledge-inferencing-prolog-11feb08

  • 1. CS344 : Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 15- Robotic Knowledge Representation and Inferencing; Prolog
  • 2. A planning agent   An agent interacts with the world via perception and actions Perception involves sensing the world and assessing the situation       creating some internal representation of the world Actions are what the agent does in the domain. Planning involves reasoning about actions that the agent intends to carry out Planning is the reasoning side of acting This reasoning involves the representation of the world that the agent has, as also the representation of its actions. Hard constraints where the objectives have to be achieved completely for success The objectives could also be soft constraints, or preferences, to be achieved as much as possible
  • 3. Interaction with static domain     The agent has complete information of the domain (perception is perfect), actions are instantaneous and their effects are deterministic. The agent knows the world completely, and it can take all facts into account while planning. The fact that actions are instantaneous implies that there is no notion of time, but only of sequencing of actions. The effects of actions are deterministic, and therefore the agent knows what the world will be like after each action.
  • 4. Two kinds of planning  Projection into the future   The planner searches through the possible combination of actions to find the plan that will work Memory based planning   looking into the past The agent can retrieve a plan from its memory
  • 5. Planning •Definition : Planning is arranging a sequence of actions to achieve a goal. •Uses core areas of AI like searching and reasoning & •Is the core for areas like NLP, Computer Vision. •Robotics Kinematics (ME) Planning (CSE) •Examples : Navigation , Manoeuvring, Language Processing (Generation)
  • 6. Language & Planning • Non-linguistic representation for sentences. agent I see object movie •Sentence generation •Word order determination (Syntax planning) E.g. I see movie ( English) I movie see (Intermediate Language)
  • 7. STRIPS •Stanford Research Institute Problem Solver (1970s) •Planning system for a robotics project : SHAKEY (by Nilsson et.al.) •Knowledge Representation : First Order Logic. •Algorithm : Forward chaining on rules. •Any search procedure : Finds a path from start to goal. •Forward Chaining : Data-driven inferencing •Backward Chaining : Goal-driven
  • 8. Forward & Backward Chaining •Rule : man(x)  mortal(x) •Data : man(Shakespeare) To prove : mortal(Shakespeare) •Forward Chaining: man(Shakespeare) matches LHS of Rule. X = Shakespeare ⇒ mortal( Shakespeare) added -Forward Chaining used by design expert systems •Backward Chaining: uses RHS matching - Used by diagnostic expert systems
  • 9. Example : Blocks World •STRIPS : A planning system – Has rules with precondition deletion list and addition list Robot hand C A A B C B START Sequence of actions : 1. Grab C 2. Pickup C 3. Place on table C 4. Grab B 5. Pickup B Robot hand GOAL 6. 7. 8. 9. Stack B on C Grab A Pickup A Stack A on B
  • 10. Example : Blocks World •Fundamental Problem : The frame problem in AI is concerned with the question of what piece of knowledge is relevant to the situation. •Fundamental Assumption : Closed world assumption If something is not asserted in the knowledge base, it is assumed to be false. (Also called “Negation by failure”)
  • 11. Example : Blocks World •STRIPS : A planning system – Has rules with precondition deletion list and addition list Robot hand C A B START on(B, table) on(A, table) on(C, A) hand empty clear(C) clear(B) A B C GOAL on(C, table) on(B, C) on(A, B) hand empty clear(A) Robot hand
  • 12. Rules •R1 : pickup(x) Precondition & Deletion List : hand empty, on(x,table), clear(x) Add List : holding(x) •R2 : putdown(x) Precondition & Deletion List : holding(x) Add List : hand empty, on(x,table), clear(x)
  • 13. Rules •R3 : stack(x,y) Precondition & Deletion List :holding(x), clear(y) Add List : on(x,y), clear(x) •R4 : unstack(x,y) Precondition & Deletion List : on(x,y), clear(x) Add List : holding(x), clear(y)
  • 14. Plan for the block world problem • For the given problem, Start  Goal can be achieved by the following sequence : 1. Unstack(C,A) 2. Putdown(C) 3. Pickup(B) 4. Stack(B,C) 5. Pickup(A) 6. Stack(A,B) • Execution of a plan: achieved through a data structure called Triangular Table.
  • 15. Triangular Table on(C,A) 1 clear(C) hand empty unstack(C,A) holding(C) 2 3 on(B,table) hand empty clear(C) 4 5 putdown(C) on(A,table) pickup(B) holding(B) clear(A) stack(B,C) hand empty 6 clear(B) on(C,table) 7 0 1 2 pickup(A) holding(A) on(B,C) 3 4 stack(A,B) on(A,B) clear(A) 5 6
  • 16. Triangular Table • • • • • • For n operations in the plan, there are : • (n+1) rows : 1  n+1 • (n+1) columns : 0  n At the end of the ith row, place the ith component of the plan. The row entries for the ith step contain the pre-conditions for the ith operation. The column entries for the jth column contain the add list for the rule on the top. The <i,j> th cell (where 1 ≤ i ≤ n+1 and 0≤ j ≤ n) contain the preconditions for the ith operation that are added by the jth operation. The first column indicates the starting state and the last row indicates the goal state.
  • 17. Search in case of planning Start  Ex: Blocks world Pickup(B) S1   Unstack(C,A) S2 Triangular table leads to some amount of fault-tolerance in the robot NOT ALLOWED C A B START A B C A C B WRONG MOVE
  • 18. Resilience in Planning    After a wrong operation, can the robot come back to the right path ? i.e. after performing a wrong operation, if the system again goes towards the goal, then it has resilience w.r.t. that operation Advanced planning strategies  Hierarchical planning  Probabilistic planning  Constraint satisfaction
  • 20. Introduction   PROgramming in LOGic Emphasis on what rather than how Problem in Declarative Form Logic Machine Basic Machine
  • 21. Prolog’s strong and weak points    Assists thinking in terms of objects and entities Not good for number crunching Useful applications of Prolog in    Expert Systems (Knowledge Representation and Inferencing) Natural Language Processing Relational Databases
  • 22. A Typical Prolog program Compute_length ([],0). Compute_length ([Head|Tail], Length):Compute_length (Tail,Tail_length), Length is Tail_length+1. High level explanation: The length of a list is 1 plus the length of the tail of the list, obtained by removing the first element of the list. This is a declarative description of the computation.
  • 23. Fundamentals (absolute basics for writing Prolog Programs)
  • 24. Facts  John likes Mary      like(john,mary) Names of relationship and objects must begin with a lower-case letter. Relationship is written first (typically the predicate of the sentence). Objects are written separated by commas and are enclosed by a pair of round brackets. The full stop character ‘.’ must come at the end of a fact.
  • 25. More facts Predicate Interpretation valuable(gold) Gold is valuable. owns(john,gold) John owns gold. father(john,mary) John is the father of Mary John gives the book to Mary gives (john,book,mary)
  • 26. Questions  Questions based on facts  Answered by matching Two facts match if their predicates are same (spelt the same way) and the arguments each are same.  If matched, prolog answers yes, else no.  No does not mean falsity.
  • 27. Prolog does theorem proving    When a question is asked, prolog tries to match transitively. When no match is found, answer is no. This means not provable from the given facts.
  • 28. Variables  Always begin with a capital letter    ?- likes (john,X). ?- likes (john, Something). But not  ?- likes (john,something)
  • 29. Example of usage of variable Facts: likes(john,flowers). likes(john,mary). likes(paul,mary). Question: ?- likes(john,X) Answer: X=flowers and wait ; mary ; no
  • 30. Conjunctions   Use ‘,’ and pronounce it as and. Example  Facts:      likes(mary,food). likes(mary,tea). likes(john,tea). likes(john,mary) ?  likes(mary,X),likes(john,X). Meaning is anything liked by Mary also liked by John?
  • 31. Backtracking (an inherent property of prolog programming) likes(mary,X),likes(john,X) likes(mary,food) likes(mary,tea) likes(john,tea) likes(john,mary) 1. First goal succeeds. X=food 2. Satisfy likes(john,food)
  • 32. Backtracking (continued) Returning to a marked place and trying to resatisfy is called Backtracking likes(mary,X),likes(john,X) likes(mary,food) likes(mary,tea) likes(john,tea) likes(john,mary) 1. Second goal fails 2. Return to marked place and try to resatisfy the first goal
  • 35. Rules   Statements about objects and their relationships Expess  If-then conditions    Generalizations    I use an umbrella if there is a rain use(i, umbrella) :- occur(rain). All men are mortal mortal(X) :- man(X). Definitions   An animal is a bird if it has feathers bird(X) :- animal(X), has_feather(X).
  • 36. Syntax    <head> :- <body> Read ‘:-’ as ‘if’. E.G.     likes(john,X) :- likes(X,cricket). “John likes X if X likes cricket”. i.e., “John likes anyone who likes cricket”. Rules always end with ‘.’.
  • 37. Another Example sister_of (X,Y):- female (X), parents (X, M, F), parents (Y, M, F). X is a sister of Y is X is a female and X and Y have same parents
  • 38. Question Answering in presence of rules  Facts       male (ram). male (shyam). female (sita). female (gita). parents (shyam, gita, ram). parents (sita, gita, ram).
  • 39. Question Answering: Y/N type: is sita the sister of shyam? ?- sister_of (sita, shyam) female(sita) parents(sita,M,F) parents(shyam,M,F) parents(shyam,gita,ram) parents(sita,gita,ram) success
  • 40. Question Answering: wh-type: whose sister is sita? ?- ?- sister_of (sita, X) female(sita) parents(sita,M,F) parents(Y,M,F) parents(Y,gita,ram) parents(sita,gita,ram) parents(shyam,gita,ram) Success Y=shyam
  • 41. Exercise 1. From the above it is possible for somebody to be her own sister. How can this be prevented?