Artificial Intelligence RT804 Prof. Shoby B Mathew Department of Information Technology Caarmel Engineering College Perunadu, Kerala Teaching notes available at: http://www.shobymathew.com 2 What is Artificial Intelligence? 3 What is AI? A broad field that means different things to different people Defining “artificial” is easy but no broad consensus in precise, concrete terms for “intelligence”: exclusive province of human being? natural phenomenon exhibited by living organisms? an arbitrarily specified set of abilities? other definitions?? 4 Artificial Artificial – usually has a negative connotation (synthetic – i.e. man made) e.g. artificial flower : look …maybe feel no smell no 5 Artificial artificial motion planes trains automobiles artificial light electric light candles Kerosene lamp natural motion walking horse natural light sunlight 6 What is Intelligence? Is there a “holistic” definition for intelligence? We might list elements of intelligence: understanding, reasoning, problem solving, learning, common sense, generalizing, inference, analogy, recall, intuition, emotion, self-awareness 7 What is Intelligence? • Intelligence: “ability to learn, understand and think” (Oxford dictionary) Intelligence might be defined broadly as facility at solving problems “Intelligence is the ability to learn, to deal with different situations, to acquire, understand, and apply knowledge and to analyze and reason.” Varying kinds and degrees of intelligence occur in people, many animals and some machines. 8 What is Artificial Intelligence (AI)? • A.I. is the study of how to make computers do things at which, at the moment, people are better. • It is the science and engineering of making intelligent machines, especially intelligent computer programs • Artificial Intelligence is the science of making machines do things that would require intelligence if done by man. • Artificial Intelligence is concerned with the design of intelligence in an artificial device. 9 What is AI ?...contd. The term was coined by John McCarthy in 1956. There are two ideas in the definition. 1. Intelligence 2. artificial device 10 John McCarthy (Born 1927) in 2006 What is AI? Thinking humanly Thinking rationally Acting humanly Acting rationally 11 AI Definitions Definitions organized into four categories The exciting new effort to make computers think … machines with minds, in the full and literal sense. The study of the computations that make it possible to perceive, reason, and act. [Winston, [Haugeland 85]. 1992] The study of how to make computers do things at which, at the moment, people are better. [Rich & The branch of computer science that is concerned with the automation of intelligent behavior. [Luger Knight, 1991] and Stubblefield, 1993] 12 Areas of Study Computer Science – algorithms, data representations, programs to test theories Psychology – theories of mind, memory, learning, experiments with human and animal intelligence Philosophy – mind/body problem, study of logic Linguistics – study of language (syntax, semantics) Neurology/Biology – study of the brain (both human and animal), study of memory, learning Engineering – many AI domains are in engineering disciplines Mathematics – many algorithms are mathematical in nature (neural networks, statistical approaches) 13 System with Intelligence There are two possibilities: – A system with intelligence is expected to behave as intelligently as a human – A system with intelligence is expected to behave in the best possible manner 14 Turing Test Alan Turing's 1950 article Computing Machinery and Intelligence discussed conditions for considering a machine to be intelligent. He argued that if the machine could successfully pretend to be human to a knowledgeable observer then you certainly should consider it intelligent. He stated that a computer would deserves to be called intelligent if it could deceive a human into believing that it was human. Considered as the basic test for intelligence 15 Turing Test Mathematician Alan Turing devised a test for defining artificial intelligence: an interrogator poses questions to two entities, a human and a computer If the interrogator cannot tell which is the human and which is the computer, then the computer passes the Turing Test and should be considered intelligent Turing Test – a test for machine intelligence 16 Turing Test 17 Turing Test 18 Eliza Person: Men are all alike. Eliza: In what way? Person: They’re always bugging us about something or other. Eliza: Can you think of a specific example? Person: Well, my boyfriend made me come here. Eliza: You’re boyfriend made you come here? Person: He says I’m depressed much of the time. Eliza: I am sorry to hear you are depressed. Person: It is true, I am unhappy. Eliza: Do you think coming here will help you not to be unhappy? Person: I need some help, that much seems certain. Eliza: What would it mean to you if you got some help? Person: Perhaps I could learn to get along with my mother. Eliza: Tell me more about your family. Eliza consists of a series of rules (if-then statements) sample syntactic manipulations: <X> me <Y> <X> you <Y>? I like <Y> Why do you like <Y>? <X> are like <Y> In what way? <X> {mother | father | brother | sister} Tell me more about your family <X> Can you think of a specific example? Eliza had no understanding of the text input or its own responses try a non-sensical sentence, you will get a non-sensical response! 19 What can AI systems do? Today’s AI systems have been able to achieve limited success in some of these tasks. Face recognition (Computer vision ) Vehicles that are mostly autonomous ( Robotics ) Simple machine translation (Natural language processing) Medical diagnosis in a narrow domain (Expert systems ) Recognizing several thousand words continuous speech (Speech Understanding ) AI systems can play at the Grand Master level in chess (Games) 20 What can AI systems NOT do yet? Understand natural language robustly (e.g., read and understand articles in a newspaper) Surf the web Interpret an arbitrary visual scene Learn a natural language 21 Applications of AI • Computer beats human in a chess game. • Computer-human conversation using speech recognition. • Expert system controls a spacecraft. • • • • Robot can walk on stairs and hold a cup of water. Language translation for webpages. Home appliances use fuzzy logic ...... 22 Applications of AI Search engines Science Medicine/ Diagnosis Labor Appliances Games What else? 23 Some Task Domains of AI Mundane tasks Formal Tasks Perception (Vision, Speech) Natural language (Understanding, Generation, Translation) Commonsense reasoning Robot control Games (Chess, checkers) Mathematics (Geometry, logic, integral calculus) Expert tasks Engineering (design, fault finding, manufacturing planning) Scientific analysis Medical diagnosis Financial analysis 24 AI Problems Mundane tasks correspond to the following AI problems areas: Planning : The ability to decide on a good sequence of actions to achieve our goals Vision : The ability to make sense of what we see Robotics: The ability to move and act in the world, possibly responding to new perceptions Natural Language: The ability to communicate with others in any human language Mundane tasks are generally much harder to automate 25 To Build an Intelligent System Why? To solve a particular problem We need to do four things Define the problem precisely Analyze the problem Isolate and represent the task knowledge that is necessary to solve the problem Choose the best problem-solving techniques and apply it to the particular problem 26 Problem Solving through AI Problem: It is the question which is to be solved For solving a problem it needs to be precisely defined Problem definition means, defining the start goal, goal state, other valid states and transitions 27 Problem Solving through AI The method of solving problem through AI involves the process of defining the search space, deciding start and goal states and then finding the path from start state to goal state through search space 28 Production rules The movement from start state to goal state is guided by set of rules specifically designed for that particular problem (sometimes called production rules) The production rules are nothing but valid moves described by the problems 29 Search Space & Search Search space: It is the complete set of states including start and goal states, where the answer of the problem is to be searched Search: It is the process of finding the solution in search space. The input to search space algorithm is problem and output is solution in form of action sequences 30 Well defined problem A problem description has three major components. Initial state, final state, space including transition function or path function. A path cost function assigns some numeric value to each path that indicates the goodness of that path. Sometimes a problem may have additional component in form of heuristic information 31 Solution of the problem A solution of the problem is a path from initial state to goal state. The movement from start states to goal states is guided by transition rules. Among all the solutions, whichever solution has least path cost is called optimal solution 32 Method of solving problems through AI techniques It involves the process of defining the search space, deciding about start and goal state and then finding a path from start state to goal state through search space The search techniques are methods which are used to find a way from start to goal state 33 Defining the problem as a state space search Problem solving = Searching for a goal state The state space representation forms the basis of most of the AI problems Search is a very important process in the solution of hard problems for which no more direct techniques are available. 34 State Space Search 1. Define a state space that contains all the possible configurations of the relevant objects. 2. Specify the initial states. 3. Specify the goal states. 4. Specify a set of rules: - What are unstated assumptions? - How general should the rules be? - How much knowledge for solutions should be in the rules? 35 Famous Problems for Illustrating AI Concepts Water Jug Problem Chess Problem Tic-Tac-Toe 8-Puzzle Problem 8-Queens Problem Tower of Hanoi Problem Traveling Salesperson Problem Magic Square Monkey and Bananas problem Missionaries and Cannibals problem Cryptarithmetic 36 State Space Search: Water Jug Problem “You are given two jugs, a 4-gallon (litre) one and a 3-gallon (litre) one. Neither has any measuring markers on it. There is a pump (tap) that can be used to fill the jugs with water. How can you get exactly 2 litres of water into 4-litre jug.” 37 State Space Search: Water Jug Problem • State: (x, y) i.e Where X is gallons of water in 4 gallon jug & y is gallons of water in 3 gallon jug • x = 0, 1, 2, 3, or 4 • Start state: (0, 0). y = 0, 1, 2, 3 • Goal state: (2, n) for any n. • Attempting to end up in a goal state. 38 Production rules for Water Jug Problem (x, y) if x 4 (4, y) 2. (x, y) if y 3 (x, 3) 3. (x, y) if x 0 (x - d, y) 4. (x, y) if y 0 (x, y - d) 1. 39 Production rules for Water Jug Problem 5. (x, y) if x 0 (0, y) 6. (x, y) if y 0 (x, 0) 7. (x, y) (4, y - (4 - x)) if x y 4, y 0 8. (x, y) (x - (3 - y), 3) if x y 3, x 0 40 Production rules for Water Jug Problem 9. (x, y) (x y, 0) if x y 4, y 0 10.(x, y) (0, x y) if x y 3, x 0 11.(0, 2) (2, 0) 12.(2, y) (0, y) 41 Production rules for Water Jug Problem 42 Production rules for Water Jug Problem 43 State Space Search: Water Jug Problem 1. Current state = (0, 0) 2. Loop until reaching the goal state (2, 0) - Apply a rule whose left side matches the current state - Set the new current state to be the resulting state (0, 0) (0, 3) (3, 0) (3, 3) (4, 2) (0, 2) (2, 0) 44 One Solution to the Water jug Problem 45 State Space Search: Water Jug Problem The role of the condition in the left side of a rule restrict the application of the rule more efficient 1. (x, y) if x 4 (4, y) 2. (x, y) if y 3 (x, 3) 46 State Space Search: Water Jug Problem Special-purpose rules to capture special-case knowledge that can be used at some stage in solving a problem 11.(0, 2) (2, 0) 12.(2, y) (0, y) 47 Partial Search Tree of Water Jug Problem (0, 0) (4, 0) (4, 3) (0, 0) (0, 3) (1, 3) (4, 3) (0, 0) (3, 0) 48 Formal Description of the Problem: Summary Define a state space that contains all the possible configurations of the relevant objects. Specify one or more states within that space that describe possible situations from which the problem solving process may start (initial state) Specify one or more states that would be acceptable as solutions to the problem. (goal states) Specify a set of rules that describe the actions (operations) available. 49 Problem Solving: Chess Game playing Game playing is considered an intelligent human activity. Games of perfect information are really just search problems 50 Problem Solving: Chess Number of possible unique chess games is 10120. In 1957, artificial intelligence pioneers Herbert Simon and Allen Newell predicted that a computer would beat a human at chess within 10 years. BELLE, a chess program by Ken Thompson and Joe Condon, became the first computer to be awarded the title of US chess master, in 1983. BELLE didn’t try to do what a human would do. Instead, BELLE took advantage of what computers do well. In May 1997, IBM's Deep Blue Supercomputer played a fascinating match with the reigning World Chess Champion, Garry Kasparov and won 3 ½ to 2 ½ 51 Defining chess problem as State Space search • State space is a set of legal positions. • Starting at the initial state. • Using the set of rules to move from one state to another. • Attempting to end up in a goal state. • Define the problem of playing chess as a problem of moving around in a state space, where each state corresponds to a legal position of the board 52 Defining chess problem as State Space search • Each position can be described by an 8-by-8 array. • Initial position is the game opening position. • Goal position is any position in which the opponent does not have a legal move and his or her king is under attack. • Legal moves can be described by a set of rules: - Left sides are matched against the current state. - Right sides describe the new resulting state. 53 Cryptarithmetic Consider an arithmetic problem represented by letters, as shown below: SEND DONALD +MORE +GERALD ----------------------MONEY ROBERT Assign a decimal digit to each of the letters in such a way that the answer to the problem is correct. If the same letter occurs more than once, it must be assigned the same digit each time. No two different letters may be assigned the same digit. 54 Tic-Tac-Toe - Game Trees Tic-tac-toe x x 1 ply x x o x o x o x x o o x 1 move o x o x o 55 Tic-Tac-Toe - Game Trees x o x ox o win lose x o x x ox o x o x x ox o o x o x x ox o x o x o x ox x o x o x x o x x ox o ox oo x o x o x x ox x oo x o x o ox x xo x o x ox x o x o x ox x oo x o x o ox x o x o x o ox x x o draw x o x ox o x o x o x x ox o x o 56