Atrificial Intelligence, Lecture notes of Artificial Intelligence

Informed Search, Uninformed Search, heuristic Search, Local Optimization algorithm

Typology: Lecture notes

2017/2018

Uploaded on 02/19/2018

harrie-prasad
harrie-prasad 🇮🇳

4

(1)

1 document

1 / 47

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS6659 ARTIFICIAL INTELLIGENCE
1
UNIT I
INTRODUCTION TO Al AND PRODUCTION SYSTEMS
CHAPTER - 1
What is Artificial Intelligence?
1. INTELLIGENCE
The capacity to learn and solve problems.
In particular,
the ability to solve novel problems (i.e solve new problems)
the ability to act rationally (i.e act based on reason)
the ability to act like humans
1.1 What is involved in intelligence?
• Ability to interact with the real world
to perceive, understand, and act
e.g., speech recognition and understanding and synthesis
e.g., image understanding
e.g., ability to take actions, have an effect
• Reasoning and Planning
modeling the external world, given input
solving new problems, planning, and making decisions
ability to deal with unexpected problems, uncertainties
• Learning and Adaptation
we are continuously learning and adapting
our internal models are always being ―updated‖
• e.g., a baby learning to categorize and recognize animals
2. ARTIFICIAL INTELLIGENCE
It is the study of how to make computers do things at which, at the moment, people are better.
The term AI is defined by each author in own ways which falls into 4 categories
1. The system that think like humans.
2. System that act like humans.
3. Systems that think rationally.
4. Systems that act rationally.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f

Partial preview of the text

Download Atrificial Intelligence and more Lecture notes Artificial Intelligence in PDF only on Docsity!

CS6659 – ARTIFICIAL INTELLIGENCE

UNIT I

INTRODUCTION TO Al AND PRODUCTION SYSTEMS

CHAPTER - 1

What is Artificial Intelligence?

1. INTELLIGENCE

 The capacity to learn and solve problems.  In particular,

 the ability to solve novel problems (i.e solve new problems)  the ability to act rationally (i.e act based on reason)  the ability to act like humans

1.1 What is involved in intelligence?

- Ability to interact with the real world - to perceive, understand, and act - e.g., speech recognition and understanding and synthesis - e.g., image understanding - e.g., ability to take actions, have an effect - Reasoning and Planning - modeling the external world, given input - solving new problems, planning, and making decisions - ability to deal with unexpected problems, uncertainties - Learning and Adaptation - we are continuously learning and adapting - our internal models are always being ―updated‖ - e.g., a baby learning to categorize and recognize animals 2. ARTIFICIAL INTELLIGENCE

It is the study of how to make computers do things at which, at the moment, people are better.

The term AI is defined by each author in own ways which falls into 4 categories

  1. The system that think like humans.
  2. System that act like humans.
  3. Systems that think rationally.
  4. Systems that act rationally.

CS6659 – ARTIFICIAL INTELLIGENCE

2.1 SOME DEFINITIONS OF AI

Building systems that think like humans ―The exciting new effort to make computers think … machines with minds, in the full and literal sense‖ -- Haugeland, 1985 ―The automation of activities that we associate with human thinking, … such as decision-making, problem solving, learning, …‖ -- Bellman, 1978

Building systems that act like humans ―The art of creating machines that perform functions that require intelligence when performed by people‖ -- Kurzweil, 1990 ―The study of how to make computers do things at which, at the moment, people are better‖ -- Rich and Knight, 1991

Building systems that think rationally ―The study of mental faculties through the use of computational models‖ -- Charniak and McDermott, 1985 ―The study of the computations that make it possible to perceive, reason, and act‖ -Winston, 1992

Building systems that act rationally ―A field of study that seeks to explain and emulate intelligent behavior in terms of computational processes‖ -- Schalkoff, 1990 ―The branch of computer science that is concerned with the automation of intelligent behavior‖ -- Luger and Stubblefield, 1993

2.1.1. Acting Humanly: The Turing Test Approach

 Test proposed by Alan Turing in 1950  The computer is asked questions by a human interrogator.

The computer passes the test if a human interrogator, after posing some written questions, cannot tell whether the written responses come from a person or not. Programming a computer to pass, the computer need to possess the following capabilities:

Natural language processing to enable it to communicate successfully in English.

Knowledge representation to store what it knows or hears

Automated reasoning to use the stored information to answer questions and to draw new conclusions.

Machine learning to adapt to new circumstances and to detect and extrapolate patterns.

To pass the complete Turing Test, the computer will need

 Computer vision to perceive the objects, and

 Robotics to manipulate objects and move about.

CS6659 – ARTIFICIAL INTELLIGENCE

  • 1955-65: ―great enthusiasm‖
    • Newell and Simon: GPS, general problem solver
    • Gelertner: Geometry Theorem Prover
    • McCarthy: invention of LISP
  • 1966—73: Reality dawns
    • Realization that many AI problems are intractable
    • Limitations of existing neural network methods identified
      • Neural network research almost disappears
  • 1969—85: Adding domain knowledge
    • Development of knowledge-based systems
    • Success of rule-based expert systems,
      • E.g., DENDRAL, MYCIN
      • But were brittle and did not scale well in practice
  • 1986-- Rise of machine learning
    • Neural networks return to popularity
    • Major advances in machine learning algorithms and applications
  • 1990-- Role of uncertainty
    • Bayesian networks as a knowledge representation framework
  • 1995--AI as Science
    • Integration of learning, reasoning, knowledge representation
    • AI methods used in vision, language, data mining, etc

3.1 AI Technique

AI technique is a method that exploits knowledge that should be represented in such a way that:

  • The knowledge captures generalizations. In other words, it is not necessary to represent separately each individual situation. Instead, situations that share important properties are grouped together. If knowledge does not have this property, inordinate amounts of memory and updating will be required. So we usually call something without this property "data" rather than knowledge.
  • It can be understood by people who must provide it. Although for many programs, the bulk of the data can be acquired automatically (for example, by taking readings from a variety of

CS6659 – ARTIFICIAL INTELLIGENCE

instruments), in many AI domains, most of the knowledge a program has must ultimately be provided by people in terms they understand.

- It can easily be modified to correct errors and to reflect changes in the world and in our world view.

  • It can be used in a great many situations even if it is not totally accurate or complete.
  • It can be used to help overcome its own sheer bulk by helping to narrow the range of possibilities that must usually be considered.

Although AI techniques must be designed in keeping with these constraints imposed by AI problems, there is some degree of independence between problems and problem-solving techniques. It is possible to solve AI problems without using AI techniques (although, as we suggested above, those solutions are not likely to be very good).

Tic-Tac-Toe

Solution 1

Data Structure:

Elements of vector:

 0 : Empty

 1 : X  2: O

 The vector is a ternary number

 Store inside the program a move-table (lookup table):

 #Elements in the table: 19683 (=3^9 )

 Element = A vector which describes the most suitable move from the current game-board

CS6659 – ARTIFICIAL INTELLIGENCE

Function Library:

  1. Make2:

 Return a location on a game-board.

IF (board[5] = 2)

RETURN 5; //the center cell.

ELSE

RETURN any cell that is not at the board‘s corner;

// (cell: 2,4,6,8)

 Let P represent for X or O

 can_win(P) :

 P has filled already at least two cells on a straight line (horizontal, vertical, or diagonal)  cannot_win(P) = NOT(can_win(P))

  1. Posswin(P):

IF (cannot_win(P))

RETURN 0;

ELSE

RETURN index to the empty cell on the line of

can_win(P)

 Let odd numbers are turns of X

 Let even numbers are turns of O

CS6659 – ARTIFICIAL INTELLIGENCE

  1. Go(n): make a move.

IF odd(turn) THEN // for X

Board[n] = 3 ELSE // for O

Board[n] = 5

turn = turn + 1

Algorithm:

  1. Turn = 1: (X moves)

Go(1) //make a move at the left-top cell

  1. Turn = 2: (O moves)

IF board[5] is empty THEN

Go(5)

ELSE Go(1)

  1. Turn = 3: (X moves)

IF board[9] is empty THEN

Go(9)

ELSE

Go(3).

  1. Turn = 4: (O moves)

IF Posswin(X) <> 0 THEN

Go(Posswin(X))

//Prevent the opponent to win ELSE Go(Make2)

  1. Turn = 5: (X moves)

IF Posswin(X) <> 0 THEN

Go(Posswin(X))

//Win for X.

ELSE IF Posswin(O) <> THEN

CS6659 – ARTIFICIAL INTELLIGENCE

Comments:

  1. Require much more time to consider all possible moves.
  2. Could be extended to handle more complicated games.

CHAPTER - 2

PROBLEMS, PROBLEM SPACES AND SEARCH

2. FORMULATING PROBLEMS

Problem formulation is the process of deciding what actions and states to consider, given a goal

Formulate Goal, Formulate problem

Search

Execute

CS6659 – ARTIFICIAL INTELLIGENCE

2.1 WELL-DEFINED PROBLEMS AND SOLUTIONS

A problem can be defined formally by four components:

  1. Initial state
  2. Successor function
  3. Goal test
  4. Path cost
  5. Initial State

The starting state which agent knows itself.

1. Successor Function

 A description of the possible actions available to the agent.

 State x, successor – FN (x) returns a set of < action, successor> ordered pairs, where each action is a legal action in a state x and each successor is a state that can be reached from x by applying that action.

2.1 State Space

The set of all possible states reachable from the initial state by any sequence of actions. The initial state and successor function defines the state space. The state space forms a graph in which nodes are state and axis between the nodes are action.

2.2 Path

A path in the state space is a sequence of state connected by a sequence of actions.

2. Goal Test

Test to determine whether the given state is the goal state. If there is an explicit set of possible goal states, then we can whether any one of the goal state is reached or not.

Example : In chess, the goal is to reach a state called ―checkmate‖ where the opponent‘s king is under attack and can‘t escape.

3. Path cost

A function that assigns a numeric cost to each path. The cost of a path can be described as the sum of the costs of the individual actions along that path.

Step cost of taking an action ‗a‘ to go from one state ‗x‘ to state ‗y‘ is denoted by C(x,a,y)

C-Cost , x,y- states , Action , Step costs are non-negative

These 4 elements are gathered into a data structure that is given as input to problem solving algorithm. A solution quality is measured by path cost function. An optimal solution has lowest path cost among all solutions.

CS6659 – ARTIFICIAL INTELLIGENCE

  • Formula n2n states
  • Initial State
  • Any one of 8 states
  • Successor Function
  • Legal states that result from three actions (Left, Right, Absorb)
  • Goal Test
  • All squares are clean
  • Path Cost
  • Number of steps (each step costs a value of 1)

Fig 1.2 Vacuum World

CS6659 – ARTIFICIAL INTELLIGENCE

Fig: 1.3 State Space for the Vacuum World

State Space for the Vacuum World

Labels on Arcs denote L: Left, R: Right, S: Suck

Example 2: Playing chess

Initial State: Described as an 8 X 8 array where each positions contains a symbol standing for the appropriate piece in the official chess position.

Successor function: The legal states that results from set of rules.

They can be described easily by as a set of rules consisting of two parts: a left side that serves as a pattern to be matched against the current board position and a right side that describes the changes to be made to the board position to reflect the move. An example is shown in the following figure.

Fig 1.4:The legal states that results from set of rules

However if we write rules like the one above, we have to write a very large number of them since there has to be a separate set of rule for each of them roughly 10^120 possible board positions.

Practical difficulties to implement large number of rules,

  1. It will take too long to implement large number of rules and could not be done without mistakes.
  2. No program could easily handle all those rules and storing it possess serious difficulties.

CS6659 – ARTIFICIAL INTELLIGENCE

  1. (x, y) →(0, y) Empty the 4-gallon jug on the

If x >0 ground

  1. (x, y) →(x, 0) Empty the 3-gallon jug on the If y >0 ground
  2. (x, y) →(4, y −(4 −x)) Pour water from the 3-gallon jug

If x +y ≥4,y >0 into the 4-gallon jug until the

4-gallon jug is full

  1. (x, y) →(x −(3 −y), 3) Pour water from the 4-gallon jug

If x +y ≥3,x >0 into the 3-gallon jug until the 3-gallon jug is full

  1. (x, y) →(x +y, 0) Pour all the water from the 3-gallon

If x +y ≤4,y >0 jug into the 4-gallon jug

  1. (x, y) →(0, x +y) Pour all the water from the 4-gallon

If x +y ≤3,x >0 jug into the 3-gallon jug

  1. (0, 2) →(2, 0) Pour the 2 gallons from the 3-gallon

Jug into the 4-gallon jug

  1. (2, y) →(0, y) Empty the 2 gallons in the 4-gallon

Jug on the ground

Production rules for the water jug problem

Trace of steps involved in solving the water jug problem First solution

Number of Steps Rules applied 4-g jug 3-g jug

1 Initial state 0 0 2 R2 {Fill 3-g jug} 0 3 3 R7 {Pour all water from 3 to 4-g jug} 3 0 4 R2 {Fill 3-g jug} 3 3 5 R5 {Pour from 3 to 4-g jug until it is full} 4 2 6 R3 {Empty 4-gallon jug} 0 2 7 R7 {Pour all water from 3 to 4-g jug} 2 0

Goal State

CS6659 – ARTIFICIAL INTELLIGENCE

Second Solution

Number of Steps Rules applied 4-g jug 3-g jug

1 Initial state 0 0 2 R1 {Fill 4-gallon jug} 4 0 3 R6 {Pour from 4 to 3-g jug until it is full} 1 3 4 R4 {Empty 3-gallon jug} 1 0 5 R8 {Pour all water from 4 to 3-gallon jug} 0 1 6 R1 {Fill 4-gallon jug} 4 1 7 R6 {Pour from 4 to 3-g jug until it is full} 2 3 8 R4 {Empty 3-gallon jug} 2 0

Goal State

Example - 5 8-puzzle Problem

The 8-puzzle problem consists of a 3 x 3 board with eight numbered tiles and a blank space. A tile adjacent to the blank space can slide into the space. The object is to reach a specified goal state.

States: A state description specifies the location of each of the eight tiles and the blank in one of the nine squares.

Initial state: Any state can be designated as the initial state.

Successor function: This generates the legal states that result from trying the four actions (blank moves Left, Right, Up, or Down).

Goal test: This checks whether the state matches the goal configuration (Other goal configurations are possible.)

Path cost: Each step costs 1, so the path cost is the number of steps in the path.

Fig 1.5 8 Puzzle Problem

CS6659 – ARTIFICIAL INTELLIGENCE

  1. A rule applier which is the computational system that implements the control strategy and applies the rules.

In order to solve a problem

 We must first reduce it to one for which a precise statement can be given. This can be done by defining the problem‘s state space (start and goal states) and a set of operators for moving that space.

 The problem can be solved by searching for a path through the space from the initial state to a goal state.

 The process of solving the problem can be usefully modeled as a production system.

2.3.1 Control strategies

By considering control strategies we can decide which rule to apply next during the process of searching for a solution to problem.

The two requirements of good control strategy are that

It should cause motion : consider water jug problem, if we implement control strategy of starting each time at the top of the list of rules, it will never leads to solution. So we need to consider control strategy that leads to solution.

It should be systematic: choose at random from among the applicable rules. This strategy is better than the first. It causes the motion. It will lead to the solution eventually. Doing like this is not a systematic approach and it leads to useless sequence of operators several times before finding final solution.

2.3.1.1 Systematic control strategy for the water jug problem

2.3.1.1.1 Breadth First Search (Blind Search)

Let us discuss these strategies using water jug problem. These may be applied to any search problem.

 Construct a tree with the initial state as its root.

 Generate all the offspring of the root by applying each of the applicable rules to the initial state.

(0, 0)

 Now for each leaf node, generate all its successors by applying all the rules that are appropriate.

CS6659 – ARTIFICIAL INTELLIGENCE

 Continue this process until some rule produces a goal state.

Algorithm

  1. Create a variable called NODE-LIST and set it to initial state.
  2. Unit a goal state is found or NODE-LIST is empty do

a. Remove the first element from NODE-LIST and call it E. if NODE-LIST is empty, quit.

b. For each way that each rule can match the state described in E do:

i. Apply the rule to generate a new state.

ii. If the new state is a goal state, quit and return this state.

iii. Otherwise, add the new state to the end of NODE-LIST.

2.3.1.1.2 Depth First Search

Algorithm

1.If the initial state is the goal state, quit and return success.

2.Otherwise do the following until success or failure is signaled:

a. Generate a successor, E, of initial state. If there are no more successor, signal failure. b. Call depth first search, with E as the initial state.

c. If the success is returned, signal success. Otherwise continue in this loop.

Backtracking

 In this search, we pursue a single branch of the tree until it yields a solution or until a decision to terminate the path is made.

 It makes sense to terminate a path if it reaches dead-end, produces a previous state. In such a state backtracking occurs.