AI Unit 1
AI Unit 1
UNIT I
******
What is “Intelligence” ?
Intelligence
Is the ability to acquire, understand and apply knowledge
Intelligence embodies all of the knowledge and feats, both conscious and unconscious,
which we have acquired through study and experience
Ability to think . . . ?
Simulating the brain . . . ?
Creativity . . . ?
Ability to learn . . . ?
Being good at maths . . . ?
Playing good Chess . . . ?
Knowledge
is the awareness and understanding of facts
AI
Simple things turn out to be the hardest to automate:
o Recognising a face.
o Navigating a busy street.
o Understanding what someone says
For more complex problems, computers have trouble in understanding situations, and
adapting to new situations
AI aims to improve the machine behaviour to tackle such situations
History of AI
1943 : McCulloch & Pitts Boolean circuit model of the brain
o A simplified model of how neurons work in the brain
1949 : Hebbian learning
o Simple rule to enable neural networks to learn new behaviour
1950 : Turing test
o “Computing machinery and intelligence”
1956 : The term ‘Artificial Intelligence’ adopted
o AI researchers agreed on this term
1958 LISP invented (List processing)
o John McCarthy developed the LISP language
o Currently Prolog is familiar
1960’s Computational complexity
1970’s Early works in Expert Systems
1980’ AI becomes an industry
o First commercial ES, R1- to configure orders for DEL
1990’s AI becomes Science
1997 IBM’s Deep Blue beats Garry Kasparov at chess
o ‘ A new kind of intelligence’
Branches of AI
Natural Language processing
o Machines to communicate in any language
Knowledge representation
o To represent the facts in mathematical logic
Pattern recognition
o Comparing a scene with given pattern
Expert Systems
o Expert level competence in a particular problem domain
Combinatorial Search
o Examining large number of possibilities
Machine learning
o To adapt to new circumstances, detect and extrapolate patterns
Computer Vision
o Three dimensional view of any object
Genetic Algorithms
o Heuristic algorithms based on natural selection and genetic
Robotics
Neural networks
o Interconnected group of neurons
Applications of AI
Autonomous control, target identification in Military
Game playing Ex. chess
Speech recognition Ex. UN airlines
Understanding natural language- the domain of text
Heuristic classification-
Robotic pets
Future of AI?
Copying human intelligence, and building human-like robots
Currently, acting as surgeons, pilots, etc
Eventually society will be left with machines working at every store and humans on
every beach
Dr.Brooks prediction: by 2050 our lives will be populated with all kinds of intelligent
machines.
The Turing Test, proposed by Alan Turing (Turing, 1950), was designed to provide a
satisfactory operational definition of intelligence. Turing defined intelligent behavior as the
ability to achieve human-level performance in all cognitive tasks, sufficient to fool an
interrogator. Roughly speaking, the test he proposed is that the computer should be interrogated
by a human via a teletype, and passes the test if the interrogator cannot tell if there is a computer
or a human at the other end.
Achievements in AI
Deep Blue defeated the reigning world chess champion Garry Kasparov in 1997.
During the 1991 Gulf War, US forces deployed an AI logistics planning and scheduling
program that involved up to 50,000 vehicles, cargo, and people.
NASA's on-board autonomous planning program controlled the scheduling of operations
for a spacecraft.
Proverb solves crossword puzzles better than most humans.
Problem Formulation
Definition of the state space.
Important: only the relevant aspects → level of abstraction!
Example: moving a robot?
Definition of the actions that can change the world state.
Definition of the action costs (cost incurred when executing this action). Assumption here: ≥ 0.
Definition of the goal: world states with certain properties.
Note: The problem formulation can have a serious influence on the difficulty of finding a
solution!
Romania example
• On holiday in Romania; currently in Arad.
• Flight leaves tomorrow from Bucharest
• Formulate goal:
– be in Bucharest
• Formulate problem:
– states: various cities
– actions: drive between cities
• Find solution:
– sequence of cities, e.g., Arad, Sibiu, Fagaras, Bucharest
Problem formulation
A problem is defined by:
– An initial state, e.g. Arad
– Successor function S(X)= set of action-state pairs
• e.g. S(Arad)={<Arad Zerind, Zerind>,…}
• intial state + successor function = state space
– Goal test, can be
• Explicit, e.g. x=‘at bucharest’
• Implicit, e.g. checkmate(x)
– Path cost (additive)
• e.g. sum of distances, number of actions executed, …
• c(x,a,y) is the step cost, assumed to be >= 0
A solution is a sequence of actions from initial to goal state.
Optimal solution has the lowest path cost.
A problem solving environment is one which decides what actions and states to consider in
completing a goal.
Algorithm - Three phases:
– Formulate the problem
– Search for a solution
– Execute the solution
State space : set of all possible states that the environment can be involved.
Search phase: searching the state space to perform a sequence of actions that can change the
environment to reach the goal state.
A solution is a sequence of actions leading from the initial state to a goal state.
Problem types
• Deterministic, fully observable single-state problem
– Environment knows exactly which state it will be in; solution is a sequence
• Non-observable, known state space sensor less problem
(conformant problem)
– Environment may not sense; solution is a sequence
• Nondeterministic and/or partially observable contingency problem
– percepts provide new information about current state
– often interleave search, execution
• Unknown state space exploration problem
Goal: Cover the board completely with dominoes, each of which covers two neighbouring
squares. → Goal, state space, actions, search, . . .
Write one program that can play all (2-player, 0-sum, . . . ) games.
Describe “game” in a declarative language (based on logics).
Variables (board position/cards), operators (moves), win/loss.
Chess.
Planning
Write one program that can solve all classical search problems.
Production Systems
Production Systems: Systems that generate (produce) rules (states) to reach a solution.
A production system commonly consists of following four basic components:
1. A set of rules of the form Ci → Ai where Ci refers to starting state and Ai represents
consequent state. Also Ci the condition part and Ai is the action part.
2. One or more knowledge databases that contain whatever information is relevant for the given
problem.
3. A control strategy that ascertains the order in which the rules must be applied to the available
database.
4. A rule applier which is the computational system that implements the control strategy and
applies the rules to reach to goal (if it is possible).
Control Strategies
• How to decide which rule to apply next during searching a solution
Examples
– Breadth first search - Hill Climbing
– Depth first search - Best First search
– Back Tracking
Examples of Problems
“Toy” Problems : “Real” Problems :
• Water jug. • Schedules.
• Cannibals. • Traveling Salesman.
• 8 – Queens. • Robot navigation.
• 8 Puzzle. • Language Analysis (Parsers, Grammars).
• VLSI design.
Problem-solving agent
Four general steps in problem solving:
– Goal formulation
• What are the successful world states
– Problem formulation
• What actions and states to consider given the goal
– Search
• Determine the possible sequence of actions that lead to the states of known
values and then choosing the best sequence.
– Execute
• Given the solution perform the actions.
Example: Romania
• Space complexity:
– Idem if each node is retained in memory
– Memory requirements are a bigger problem than its execution time.
• Optimality:
– Does it always find the least-cost solution?
– In general YES unless actions have different cost.
Stochastic hill climbing does not examine all neighbors before deciding how to move. Rather, it
selects a neighbor at random, and decides (based on the amount of improvement in that
neighbor) whether to move to that neighbor or to examine another.
Note:
• Generate & Test - Exhaustive Random Search – British Museum Algorithm
• Variant of G&T based on Feedback
• In G& T, Test Procedure Yes (or) No
• Here, “Test Function is Augmented with heuristic”
• HC often used when a good heuristic Function is available & when no useful knowledge
available
• Example : To reach a place in Unfamiliar city without a map
• Consider all possible successors as “one step” from the current state on the landscape.
• At each iteration, go to
• The best successor (steepest ascent)
• Any uphill move (first choice)
• Any uphill move but steeper is more probable (stochastic)
• Simple hill climbing Better node next (No of Move longer)
• Steepest Ascent Hill Climbing Best node next (time required to select a move longer)
Basic and Steepest –fail to find the solution in the following situation
• Local maxima = no uphill step - Allow “random restart”
• Plateau = all steps equal (flat or shoulder)
• Must move to equal state to make progress, but no indication of the correct
direction
• Ridge = narrow path of maxima, but might have to go down to go up (e.g. diagonal ridge
in 4-direction space)
• Backtrack to some earlier node
• Make a big jump in some direction
• Apply two or more rules before doing the test
Note:
• Expand the node that is closest to the goal assuming it will lead to a solution quickly –
a.k.a. “Greedy Search”
o f(n) = h(n)
• Example: consider the straight-line distance heuristic hSLD
o Expand the node that appears to be closest to the goal
Example: hSLD(In(Arid)) = 366
A* Search Algorithm
Let h(n) be the heuristic function in a graph. In simple case, let it be the straight line distance
SLD from a node to destination. Let g(n) be the function depending on the distance from source
to current node. Thus f(n) = g(n) + h(n)
1.Start from source node S, determine all nodes outward from S and queue them.
2.Examine a node from queue (as generated in 1) .
If this node is desired destination node, stop and return success.
Evaluate f(n) at this node. The node with optimal f(n) gives thenext successor, term this
node as S.
3. Repeat steps 1 and 2.
Time = O(log f(n)) where h(n) is the actual distance travelled from n to goal.
A* (A star) is the most widely known form of Best-First search
– It evaluates nodes by combining g(n) and h(n)
– f(n) = g(n) + h(n)
where
• g(n) = cost so far to reach n
• h(n) = estimated cost to goal from n
• f(n) = estimated total cost of path through n
When h(n) = actual cost to goal
• Only nodes in the correct path are expanded
• Optimal solution is found
When h(n) < actual cost to goal
• Additional nodes are expanded
• Optimal solution is found
When h(n) > actual cost to goal
• Optimal solution can be overlooked
A* is optimal if it uses an admissible heuristic
– h(n) <= h*(n) the true cost from node n
– if h(n) never overestimates the cost to reach the goal
Example
– hSLD never overestimates the actual road distance
Searching And-Or graphs
The DFS and BFS strategies for OR trees and graphs can be adapted for And-Or trees.
The main difference lies in the way termination conditions are determined, since all goals
following an And node must be realized, whereas a single goal node following an Or
node will do.
A more general optimal strategy is AO* (O for ordered) algorithm.
As in the case of the A* algorithm, we use the open list to hold nodes that have been
generated but not expanded and the closed list to hold nodes that have been expanded.
The algorithm is a variation of the original given by Nilsson.
It requires that nodes traversed in the tree be labeled as solved or unsolved in the solution
process to account for And node solutions which require solutions to all successors
nodes.
A solution is found when the start node is labeled as solved.
It can be shown that AO* will always find a minimum-cost solution tree if one exists, provided
only that h*(n) ≤ h(n), and all arc costs are positive. Like A*, the efficiency depends on how
closely h* approximates h
Example: Map-Coloring
– Variables WA, NT, Q, NSW, V, SA, T
– Domains Di = {red,green,blue}
– Constraints: adjacent regions must have different colors
e.g., WA ≠ NT, or (WA,NT) in {(red,green),(red,blue),(green,red),
(green,blue),(blue,red),(blue,green)}
Constraint graph
• Binary CSP: each constraint relates two variables
• Constraint graph: nodes are variables, arcs are constraints
Varieties of constraints
• Unary constraints involve a single variable,
– e.g., SA ≠ green
• Binary constraints involve pairs of variables,
– e.g., SA ≠ WA
• Higher-order constraints involve 3 or more variables,
– e.g., cryptarithmetic column constraints
Real-world CSPs
• Assignment problems
– e.g., who teaches what class
• Timetabling problems
– e.g., which class is offered when and where?
• Transportation scheduling
• Factory scheduling
Notice that many real-world problems involve real-valued variables.
Constraint propagation
• A backtracking search is a depth-first traversal of a search tree
• A generic scheme to maintain a level of local consistency in a backtracking search is to
perform constraint propagation at each node in the search tree
– if any domain of a variable becomes empty, inconsistent so backtrack
Backtracking Example
Application areas
• scheduling • networks
• logistics • configuration
• planning • assembly line sequencing
• supply chain • cellular frequency assignment
management • airport counter and gate allocation
• rostering • airline crew scheduling
• timetabling • optimize placement of
• vehicle routing transmitters for wireless
• bioinformatics • …
Problem Characteristics
Heuristic search is a very general method applicable to a large class of problems. It encompasses
a variety of specific techniques, each of which is particularly effective for a small class of
problems. In order to choose the most appropriate method (or combination methods) for a
particular problem, it is necessary to analyze the problem along several key dimensions:
Is the problem decomposable into a set of (nearly) independent smaller or easier
subproblems?
Can solution steps be ignored or at least undone if they prove unwise?
Is the problem’s universe predictable?
Is a good solution to the problem obvious without comparison to all other possible
solutions?
Is a desired solution a state of the world or a path to a state?
Is a large amount of knowledge absolutely requires to solve the problem, or is knowledge
important only to constrain the search?
Can a computer that is simply given the problem return the solution, or will the solution
of the problem require interaction between the computer and a person?
A decomposable Problem
If the problem is not easily solvable, the integrator checks to see whether it can decompose the
problem into smaller problems. If it can, it creates those problems and calls itself recursively on
them. Using this technique of problem decomposition, we can often solve very large problems
easily.
How to extract from the entire collection of rules that can be applied at a given point? =>
Matching between current state and the precondition of the rules.
Indexing – A large number of rules => too slow to find a rule
• Use the current state as an index into rules and select the matching ones immediately
o Only works when preconditions of rules match exact board configuration
o It’s not always obvious whether a rule’s preconditions are satisfied by a particular
state.
• There’s a trade-off between the ease of writing rules (high-level descriptions) and the
simplicity of the matching process.
Indexed Organization
- While organization by content can help to reduce block transfers, an indexed organization
scheme can greatly reduce the time to determine the storage location of an item
- Indexing is accomplished by organizing the information in some way for easy access
- One way to index is by segregating knowledge into two or more groups and storing the
locations of the knowledge for each group in a smaller index file
- To build an indexed file, knowledge stored as units is first arranged sequentially by some
key value
- The key can be any chosen fields that uniquely identify the record
- A second file containing indices for the record locations is created while the sequential
knowledge file is being loaded
- Each physical block in this main file results in one entry in the index file
- The index file entries are pairs of record key values and block addresses
- The key value is the key of the first record stored in the corresponding block
- To retrieve an item of knowledge from the main file, the index file is searched to find the
desired record key and obtain the corresponding block address
- The block is then accessed using this address. Items within the block are then searched
sequentially for the desired record
- An indexed file contains a list of the entry pairs (k,b) where the values k are the keys of
the first record in each block whose starting address is b.