Ai_upload_by_pk

advertisement
Artificial Intelligence
-
Mehul Mahrishi
References
 Artificial Intelligence- Rich & Knight
 Artificial Intelligence – A Mordern Approach
 Russell & Norvig
What is AI?
Turing Test (1950)
 The computer is interrogated by a human by a teletype
 It passes if the human cannot tell if there is a computer
or human at the other end.
Sufficiency: The Chinese Room Argument
Basic Building block of AI
 Ability to solve problems
 Search: Efficient Trial-and-Error
 Enormous Computational Complexity
 Space time trade-offs
 Use of Domain Knowledge - Heuristics
Linear
Programming
Heuristic
Search
Integral
Programming
Till 1995 computation became free
Dynamic
Programming
Evolutionary
Algorithms
Knowledge and Deduction
 How to store and retrieve knowledge?
 How to interpret facts and rules, and able to deduce?
 The gap between knowledge and realization.
 Logics of knowledge
Knowledge
Based
Systems
Expert
Systems
Automated
Theorem
Provers
Knowledge base may be huge
Between 1990-2000 storage became free
Formal
Verification
Ability to Learn
 Can we learn to solve the problem better?
 Learning the answers
 Learning the rules of the game
 Learning to plan
• Belief Networks
•Perceptions and Neural Networks
Human
Computer
Interaction
What then is AI?
Automated Problem Solving
Machine Learning
Logic and Deduction
Computer
Vision
NLP
Robotics
Definitions of AI
 What to look at:
 Thought process/reasoning vs behavior
 How to measure performance:
 Human like Performance vs Ideal Performance
AI Approaches
Thought/Reasoning
Think like humans
(Turing Test)
Systems that thinks rationally
(Laws of thought/Logic)
Human-like
Performance
Ideal Performance
(rationality)
(Cognitive Science)
Acts like humans
Behavior
(Rational Agents)
Acts rationally
Typical AI problems
 Intelligent entities (or Agents) need to be able to do
both “mundane” and “expert” tasks:
 Mundane tasks




Planning route, activity
Recognizing people, objects
Communicating (through natural language)
Navigating through streets
 Expert tasks
Medical Diagnosis
Mathematical Problem solving
What’s easy and what’s hard?

It has been easier to mechanize many of high level tasks we usually associate with
“intelligence” in people




Symbolic Integration
Proving theorems
Playing chess
Medical diagnosis
 It has been hard to mechanize tasks that lots of us can do
•Team work
AI Examples
 Autonomous Land Vehicle in Neural Networks
Deep Blue Chess Program
Machine Translation
 US military is giving a simpler one-way translation
device a test in Iraq….they are using the Phraselator
to communicate with injured Iraqis, prisoners of war,
travelers at checkpoint etc.
 Carnegie Mellon is working on Speechlator for use in
doctor-patient interviews
 Problem Solving by Search
Agents & Environment
Actions
Environment
Agent
Percepts
Examples of Agents
 Humans
 Eyes, ears, skin, taste buds, etc. for sensors
 Hands, fingers, legs, mouth for effectors
 Robots
Camera, infrared etc. are sensors
Grippers, wheels, light, speakers etc. for actuators
 Software agent (softbot)
Functions as sensors
Function as actuators
 Each state is an abstract representation of the agent’s
environment. It is an abstraction that denotes a
configuration of the agent.
 Initial State: The description of the starting
configuration of the agent.
 An Action/operator takes the agent from one state to
another. A state can have number of successor states
 A Plan is a sequence of actions
 A goal is a description of a set of desirable states.
 Path Cost: path
positive number
Path cost = sum of step costs
 Problem formulation means choosing a relevant set of
states to consider, and a feasible set of operators for
moving from one state to another.
 Search is the process of imagining sequences of
operators applied to the initial state, and checking
which sequence reaches a goal state.
State Space
 S: the full set of states
 s0 : the initial state
 A: S-S set of operators
 G: the set of final states
 Search Problem:
 Find the sequence of action
Which transforms the agent
From the initial state to goal
state
State Space Search
 Basic Search Problem:
 Given:




{ S, s, A, G } where
S is the set of states
S is the start state
A is the set of state transition operators
G is the set of goal states
To find a sequence of state transitions leading from s to a goal
state.
Outline of a search algorithm
1. Initialize:
set OPEN = {s}
2. Fail:
If OPEN = {}, terminate with failure
Check the current state
3. Select: state, n, from OPEN Execute allowable actions to move to the next state
4. Terminate:
If new state is the solution state then terminate else repeat
If n ε G, terminate with success
Example State Space
Tower of Hanoi
 Consider the following problem
 We have 3 pegs and 3 disks
 Operators: One may move the
topmost disk on any needle to
the topmost position to
any other needle.
A
C, A
B, A
C, B
A, C
B, A
B, C
B
8 Queens problem
 Placing 8 queens on a chess board, so that no queens
are in the same row or in the same diagonal
 Formulation-I




A state is any arrangement of 0 to 8 queens on board
Initial state: 0 queens on the board
Operator: Add a queen in any square
Goal: 8 queens on board, none
attacked
 Formulation –II
 A state is any arrangement of 0 to 8 queens with none
attacked
 Initial State: All queens are at column 1
 Operator: Change the position of any
one queen
 Goal: 8 queens on the board
 Formulation – III
 A state is any arrangement of 8 queens, one in each
column
 Initial state: 0 queen on board
 Operator: Add a queen to
(K+1)th row so that none are
attacked.
 Goal: 8 queens on the board
Explicit vs Implicit State Space
 The state space may be explicitly represented
 Typically it is implicitly represented and generated
when required.
 The agent knows:
 The initial state
 The operators
 An operator is a function which “expands” a node
Compute the successor node(s)
Search Frameworks
 State Space Search
 Uninformed / Blind Search
 Informed / Heuristic Search
• Problem Reduction Search
•Game Tree Search
•Advances
Memory bounded Search
Multi objective Search
Learning How to search
Missionaries and Cannibals
 Three missionaries and 3 cannibals are on one side of
a river, along with a boat that can hold one or two
people. Find a way to get everyone on the other side,
without ever leaving a group of missionaries
outnumbered by cannibals
State Space for Missionaries
and Cannibals Problem
 State: <M,C,B>
 M: no. of missionaries on the left bank
 C:. No. of cannibals on the left bank
 B:. Position of the boat: L or R
 Initial State: <3,3,L>
 Goal State: <0,0,R>
 Operators: <M,C>
 Possible operators:
 <1,0>, <2,0>, <1,1>, <0,1>, <0,2>
Find a Path
 Shortest path
 Any path
 Blind Search
 BFS (Breadth First)
 DFS (Depth First)
Search Tree
 List all possible paths
 Eliminate cycles from path
 Result: A search tree
Search Tree- Terminologies
 Root node
 Leaf Node
 Ancestor/Descendent
 Branching Factor
 Complete path/Partial Path
Recall the basic search Algo.
1. Initialize:
set OPEN = {s}
2. Fail:
If OPEN = {}, terminate with failure
Check the current state
3. Select: state, n, from OPEN Execute allowable actions to move to the next state
4. Terminate:
If new state is the solution state then terminate else repeat
If n ε G, terminate with success
For BFS, OPEN will act as a Queue i.e. FIFO
For DFS, OPEN will act as stack i.e. LIFO
Depth-First Iterative
Deepening (DFID)
 First do DFS to depth 0 (i.e. treat start node as having
no successors), then, if no solution found, do DFS to
depth 1, etc.
Until solution found
do
DFS with depth cutoff c
C=c+1
Combines DFS space efficiency and BFS completeness
Example: DFID
 A depth first search method:
ABDFEABDFE…..infinite, never see
C and G.
DFID method:
0: A
1: ABCE
2. ABDFCGEF
Assignment
 Given a full 5-lt jug and an empty 2lt jug, the goal is to
fill the 2lt jug with exactly 1lt of water. You may use the
following state space formulation.
 State = (X,Y), where X is the number of lts of water in 5lt
jug and Y is for 2lts jug.
 Initial state = (5,0)
 Goal state = (*,1)
Create the search tree. Discuss which strategy is
appropriate for this problem.
Informed search
 Notion of Heuristics
 Heuristics use domain specific knowledge to estimate the
quality or potential of partial solutions.
 Examples:
• Manhattan distance heuristic for 8 puzzle
• Minimum spanning tree heuristic for TSP
The informed search Problem
 Given : {S, s, A, G, h} where





S is a set of states
S is the initial state
A set of actions/operators
G is the set of goal state
H() is a heuristic function estimating the distance to a goal
 Problem is to find “ A min cost sequence of transactions to a goal
state”
Algorithm A*
 Initialize: set OPEN={s}, CLOSED = {},
 g(s) =0, f(s) = h(s)

Fail : If OPEN = {}, Terminate & fail

Select : select the minimum cost state, n, from OPEN, save it in
CLOSED,

Terminate : If n is the element of G, terminate with success and return
f(n)
 Expand : For each successor, m of n
 If m is in [OPEN union CLOSED]
 set g{m} = min { g{m}, g{n} + c{n,m}}
 Set f{m} = g{m} + h{m}
 If m is not in [OPEN union CLOSED]
 Set g{m} = g{m} + c{n,m}
 Set f{m} = g{m} + h{m}
 Insert m in OPEN
Results on A*
 A heuristic is called admissible if it always underestimated, that is , we always have h(n) <= f*(n)
Where f*(n) is the minimum distance to a goal state from
state n.
 For finite state spaces, A* always terminates.
 If A1 and A2 are two versions of A* such that A2 is
more informed that A1, then A1 expands at least as
many states as A2.
 If we are given two or more admissible heuristics, then
we can take their max to get a stronger admissible
heuristic.
Monotone Heuristic
 An admissible heuristic function, h(n), is monotonic if
for every
 h(n) –h(m) <= c(n,m)

If the monotone restriction is satisfied, then A* has already
found an optimal path to the state it selects for expansion
Pathmax
 Convert a non-monotonic heuristic to a monotonic one:
 During generation of the successor, m of n we set:
 h’(m) = max {h(m), h(n) – c(n,m)}
and use h’(m) as the heuristic at m.
Iterative Deepening A* (IDA*)
 Set C = f(s)
 Perform DFBB with cut-off C
 Expand a state, n , only if its f-value is less than or equal
to C
 If a goal is selected for expansion then return C and
terminate
 Update C to the minimum f-value which exceeded C
among states which were examined and Go to Step 2
Best first Search
 Generalization of breadth first search.
 Priority queue of nodes to be explored.
 Cost function f(n) applied to each node.
Algorithm
 Let OPEN be a priority queue containing the initial state
 If OPEN = {} return failure
 S = remove-first(OPEN)
 If s is a goal
 Then return the path from initial state to node
 Else generate all successors of node and
 Put the newly generated node into OPEN according to their f
value
 END
Greedy Search
 Idea : Expand node with the smallest estimated cost to
reach the goal.
 Use heuristic function f(n) = h(n)
 Not optimal
 Incomplete
Problem Reduction Search
 AND/OR Graph
 Game Trees
Problem Reduction Search
 Planning how best to solve a problem that can be
recursively decomposed into sub-problems in multiple
ways.
 Matrix multiplication problem
 Tower of Hanoi
 Blocks World Problems
 Theorem proving problems
Problem 1
 A1…….An
 Find out the product of these n matrices.
 ((A1A2)A3)A4
 ((A1A2) (A3A4))
 Let A1 = n*m
 A2 = m*k
 Cost = |A1A2| = n*m*k
Formulation
 AND/OR Graph
 An OR node represents a choice between possible
decompositions
 An AND node represents a given decomposition

Game Trees


Max node represents the choice of my opponent
Min represents my choice
The AND/OR graph search
problem
 Problem Definition:
 Given : [G,s,T] where




G: Implicitly specified AND/OR graph
S: Start node
T: set of terminal nodes
H(n): heuristic function estimating the cost of solving the
sub problem at n
 To find A minimum cost solution tree
AO* Algorithm
 Initialize:
Set G* = {s}, f{s} = h{s}
if s € T, label s as SOLVED
Terminate : if s is SOLVED, then Terminate
Select:
Select a non-terminal leaf-node n from the marked sub-tree
Expand : Make explicit the successors of n
For each new successor, m :
Set f(m) = h(m)
If m is terminal, label m as SOLVED
Cost Revision: Call cost-revision(n)
 Cost Revision Call cost-revision(n)
Create Z = {n}
if z {} return
select a node m from Z such that m has no
descendants in Z
If m is an AND node with successors r1, r2…rk:
Set f(m) = ∑ [ f(ri) + c (m, ri) ]
Mark the edge to each successor of m
If each successor is labeled SOLVED, then label m as
SOLVED




If m is an OR node with successors r1,r2…rk:
Set f(m) = min {f(ri) + c(m, ri)}
Mark the edge to the best successor of m
If the marked successor is labeled SOLVED, then label m as
SOLVED
 If the cost or label of m has changed, then insert those
parents of m into Z for which m is a marked successor
Shallow and Deep Pruning
Root
Root
A
10
10
B
14
F
C
Shallow Cut-off
D
G
Deep Cut-off
5
E
Alpha-Beta Pruning
 Alpha Bound of J :
 The max current value of all max ancestors of J
 Exploration of min node, J is stopped when its value equals or
falls below alpha.
 In a min node we update beta.
 Beta Bound of J :
The min current value of all min ancestors of J
Exploration of a max node, J, is stopped when its value equals or
exceeds beta
In max node we update alpha
 In both min and max node s, we return when α≥β
Constraint Satisfaction
Problem
 MEANS-ENDS ANALYSIS
 The idea is to solve the problem by decomposing a big problem





into smaller sub-problems and solving each sub-problem.
It is a process which detects the differences between the current
and goal state.
Once the difference is isolated, an appropriate operator is selected
to reduce this difference.
Like other problems Means-Ends analysis relies on a set of rules
that transform one problem state to another.
The rule is :
 Left side -> Condition that must be met (preconditions)
 Right Side - > State change by application of the rule
A separate data structure called a Difference table indexes the rules by the
difference.
Example: given a Robot and the problem is to move a large desk with two things on it from one room to another.

Rules:
Operator
Preconditions
Results
PUSH (obj, loc)
At(robot, obj)
At( obj, loc)
Large(obj)
At(robot, loc)
Clear(obj)
Armempty
CARRY(obj, loc)
At (robot, obj)
At(obj, loc)
Small(obj)
At(robot, loc)
WALK(loc)
None
At(robot, loc)
PICKUP(obj)
At(robot, obj)
Holding(obj)
PUTDOWN(obj)
Holding(obj)
!holding(obj)
PLACE(obj1, obj2)
At(robot, obj2) &
holding(obj1)
Difference Table
PUSH
Move
Object
Move
Robot
Clear
Object
*
CARRY
WALK PICKUP PUTDOWN
*
*
*
Get
Object
on
Object
*
Get Arm
empty
Be
Holding
Object
PLACE
*
*
*
KNOWLEDGE BASED
SYSTEMS
 LOGIC & DEDUCTION
 COMBINATION OF SEARCH & DEDUCTION
Knowledge and Reasoning
 Representation, Reasoning and Logic
 Propositional Logic
 First-Order Logic
 Inference in first-order logic
 Generalized Modus Ponens
 Forward and Backward Chaining
 Resolution
 Logical Reasoning Systems
Wumpus World
The WUMPUS World Evviornment
 Adjacent means Left, Right, Top and Bottom
 Stench: In squares containing and adjacent to wumpus
 Breeze: In square adjacent to pit
 There can be one wumpus, one gold, and many pits. Agent
starts from bottom left square of the grid.
 The agent dies if it enters a square containing a pit or a
wumpus
 The agent can shoot the wumpus along a straight line.
 The agent has only one arrow.
Logic
 A formal system for describing states of affairs,
consisting of:
 Syntax: describes how to make sentences, and
 Semantics: Describes the relation between the sentences
and the states of affairs.
 A proof theory – A set of rules for deducing the
entailments of a set of sentences
 Improper definition of logic, or an incorrect proof theory
can result in absurd reasoning
Language
What exists
Belief of agent
Prepositional Logic
Facts
T/F/Unknown
First-order Logic
Facts, Objects,
Relations
T/F/Unknown
Temporal Logic
Facts, Objects,
Relations, Times
T/F/Unknown
Probability Theory
Facts
Degree of belief [0…1]
Fuzzy Logic
Degree of truth
Degree of belief [0…1]
Propositional Logic
 Given a set of atomic propositions AP
 Sentence -> Atom | Complexsentence
 Atom -> True | False | AP
 Complexsentence -> (sentence)
| sentence Connective Sentence
| ⌐sentence
• Connectives -> ^ | v | ˂=˃ | =>
Inference Rules
 Modus Ponens or implication elimination
α =>β , α
β
 Unit Resolution
α v β, ⌐ β
α
α β, ⌐ β γ
α, γ
and many other rules…
Automated Reasoning
 If the unicorn is mythical, then it is immortal, but if it is
not mythical then it is a mortal mammal.
 If the unicorn is either immortal or mammal, then it is
horned.
 The unicorn is magical if it is horned.
 Can we prove that the unicorn is mythical? Magical?
Horned?
Modeling in propositions
 Propositions:
 Umyth: Unicorn is mythical
 Umort: Unicorn is mortal
 Umam: Unicorn is mammal
 Umag: Unicorn is magical
 Uhorn: Unicorn is horned
1. Umyth => ⌐ Umort
2. ⌐ Umyth => Umort ^ Umam
3. Umam v ⌐ Umort => Uhorn
4. Uhorn => Umag
5. (1) & (2) => ⌐ Umort v [Umort ^ Umam]
6. (5) & (3) => Uhorn
7. (6) & (4) => Umag
Download