Artificial Intelligence Fall 2008 Frank Hadlock Definitions of AI • The study of representation and search through which intelligent activity can be enacted on a mechanical device. • The study of problems at which human beings are currently more adept than computers at solving and the translation and improvement of human solutions into forms which can be implemented on a computer. Physical symbol system hypothesis The physical symbol system hypothesis (PSSH), first formulated by Newell and Simon in their Turing Award paper,1 states that “a physical symbol system [such as a digital computer, for example] has the necessary and sufficient means for intelligent action.” The hypothesis implies that computers, when we provide them with the appropriate symbol-processing programs, will be capable of intelligent action. It also implies, as Newell and Simon wrote, that “the symbolic behavior of man arises because he has the characteristics of a physical symbol system.” History – – – – – – – Graph theory & state space representation (Euler) Boolean algebra – propositional calculus (Boole) Predicate calculus – (Frege) Descartes Discourse Turing’s Test Physical Symbol System Hypothesis Connectionism Discourse - Descartes If there were machines which bore a resemblance to our bodies and imitated our actions as closely as possible for all practical purposes, we should still have two very certain means of recognizing that they were not real men. The first is that they could never use words, or put together signs, as we do in order to declare our thoughts to others. For we can certainly conceive of a machine so constructed that it utters words, and even utters words that correspond to bodily actions causing a change in its organs. … But it is not conceivable that such a machine should produce different arrangements of words so as to give an appropriately meaningful answer to whatever is said in its presence, as the dullest of men can do. Secondly, even though some machines might do some things as well as we do them, or perhaps even better, they would inevitably fail in others, which would reveal that they are acting not from understanding, but only from the disposition of their organs. For whereas reason is a universal instrument, which can be used in all kinds of situations, these organs need some particular action; hence it is for all practical purposes impossible for a machine to have enough different organs to make it act in all the contingencies of life in the way in which our reason makes us act. (Translation by Robert Stoothoff) Turing Test The Turing test is a proposal for a test of a machine's ability to demonstrate intelligence. Described by Alan Turing in the 1950 paper "Computing Machinery and Intelligence," it proceeds as follows: a human judge engages in a natural language conversation with one human and one machine, each of which try to appear human; if the judge cannot reliably tell which is which, then the machine is said to pass the test. In order to test the machine's intelligence rather than its ability to render words into audio, the conversation is limited to a text-only channel such as a computer keyboard and screen (Turing originally suggested a teletype machine, one of the few text-only communication systems available in 1950). AI Application Areas • • • • • • • • • • Game Playing Automated Reasoning Expert Systems Natural Language Understanding Modeling Human Performance Planning and Robotics Languages for AI (Clips, Lisp and Prolog) Machine Learning Neural nets and Genetic Algorithms Intelligent Agents Game Playing and State Space Search Board games can be represented by a usually large but finite set of board configurations or states. The squares of Tic Tac Toe can be numbered 1..9 and each configuration as a sequence over {H,C,B} where many of the 39 cannot occur because of order of play. A state BCBBBBBBB may be followed by any of eight states obtained by replacing any of the eight Bs by an H. BBBBBBBBB is the initial state and any state with a row or column or diagonal consisting of all Cs is a winning state for the Computer. If the computer can find a path from start to winning state, the path corresponds to a win for the computer and finding such a path constitutes an example of artificial intelligence. Graph theory: The city of Königsberg •The city is divided by a river. There are two islands at the river. The first island is connected by two bridges to both riverbanks and is also connected by a bridge to the other island. The second island two bridges each connecting to one riverbank. •Question: Is there a walk around the city that crosses each bridge exactly once? •Swiss mathematician Leonhard Euler invented graph theory to solve this problem. The city of Königsberg Graph of the Königsberg bridge system Euler Circuits • A graph has an Euler circuit iff it is connected and every vertex is of even degree. • Necessity – Euler circuit enters a vertex each time on a new edge and leaves the vertex on a new edge. So vertex has degree 2 * number of times on circuit • Sufficiency – Pick starting vertex and traverse graph, each time picking new edge. Can only be blocked at start. Either have Euler circuit or can pick vertex with unused edge on circuit and build subtour starting with it. Splice subtour in. Eventually will have used all edges once. State space search • Represented by a four-tuple [N,A,S,GD], where: •N is the problem space • A is the set of arcs (or links) between nodes. These correspond to the operators. • S is a nonempty subset of N. It represents the start state(s) of the problem. State Space Search continued • GD is a nonempty subset of N. It represents the goal state(s) of the problem. The states in GD are described using either: a measurable property of the states a property of the path developed in the search (a solution path is a path from node S to a node in GD ) The 8-puzzle problem as state space search • states: possible board positions • operators: one for sliding each square in each of four directions, or, better, one for moving the blank square in each of four directions • initial state: some given board position • goal state: some given board position •Note: the “solution” is not interesting here, we need the path. Eight Puzzle 1 4 7 5 8 3 1 4 3 6 7 6 2 2 5 8 State space of the 8-puzzle generated by “move blank” operations Traveling salesperson problem as state space search •The salesperson has n cities to visit and must then return home. Find the shortest path to travel. • state space: • operators: • initial state: • goal state: Automated Reasoning and Theorem Proving Logic systems began with Propositional Calculus in which declarative statements with a truth value of true or false are represented by P,Q,R, etc and combined with logic operators Or, And, Not, If. A sentence such as “Bill must take CSC 2020” is represented by letter P and is true or false. Propositional Calculus was extended to Predicate Calculus by adding Predicates (relations), variables, and quantifiers (For All and There Exists). A sentence such as “Every CS major must take CSC 2020” is represented by “(For All X)( CSMajor(X) MustTake( CSC2020 ))” Given some facts expressed in either Propositional or Predicate Calculus, new facts or knowledge is inferred by inference rules such as modus ponens or resolution. If the computer can find a path from given facts to a new theorem, the path corresponds to a proof and finding such a path constitutes an example of artificial intelligence Propositional Logic • A declarative statement such as “Bill is a CS student” has a truth value of T or F and is denoted by P (a truth variable) • Propositions may be combined with logical operators and the composite statement has value as shown below. P Q is true if either P or Q are true and false if both are false P Q is true if both P and Q are true and false if either is false. ¬ P is true if P is false and false if P is true P Q is true if P and Q have the same truth value and false if their values differ – P Q is false if P is true and Q is false and true otherwise. – – – – • A tautology is always true. – P Q ¬ P Q is a tautology. – P (Q R) (P Q) (P R) is a tautology. Rules of Inference • P , P Q then Q - modus ponens • ¬ Q, P Q then ¬ P - modus tollens Expert Systems General problem solving has been attempted in AI but without success. Instead, systems have been developed which specialize in domain-specific knowledge such as medicine. People who work in these areas are called domain experts and solve problems by using domain-specific rules which are applied to facts or knowledge in the knowledge base. General problem classes solvable by expert systems (which replace the domain experts) are diagnostic problems (backward chaining) and design or configuration problems (forward chaining). When a path is found from a condition backward to a set of facts causing the condition (or vise versa), the path corresponds to a diagnosis (or design) and finding such a path constitutes an example of artificial intelligence Natural Language Understanding & Semantics Translation from text in one natural language to another requires more than vocabulary substitution because of the inherent ambiguity of natural languages. To resolve this ambiguity requires contextual knowledge in the form of a world model. As an example, a punctuation symbol “,” can have the meaning of a list separator, or be used in place of “then”, or be used to delimit a dangling modifier. Another example is the transaltion of “hydraulic ram” in English into the Russian equivalent of “water goat”. In this last example, a world model would say that there is such an animal as a “water buffalo” but not a “water goat”. Translation usually involves syntactic analysis followed by semantic analysis and a translation path from source to target constitutes an example of artificial intelligence Modeling Human Performance Much of artificial intelligence is concerned with duplicating or surpassing human ingenuity on the computer with no concern with how humans perform. Cognitive modeling is concerned with using computers to determine human performance. Computer based tutoring is an example which has been applied to tutoring algebra students to solve word problems. Cognitive modeling systems such as ACT model human performance with rules or productions. The tutor interacts with the student by posing a problem and then posing questions, attempting to guide the student to a correct solution. By examining the responses, the tutor either poses another question corresponding to a correct step in the solution, or diagnoses an incorrect “buggy” rule being used by the student. In this case, the tutor reverts back to a previous concept needed in the correct solution. A path from problem statement to any intermediate state constitutes an example of artificial intelligence Planning and Robotics Discussion of planning and robotics here is confined to motion planning in two dimensions. A basic assumption in this discussion is that the Euclidean coordinates are available for the position of the robot, of obstacles, and of goals. Motion planning is accomplished by working with the state space of positions where positions are connected by an edge if there is no intervening obstacle. A path from initial position to a goal position is a solution to the problem of motion planning that constitutes an example of artificial intelligence. Cognitive AlgebraTutors • • • • • • • • • • • Algebra class may be less difficult and a bit more fun these days, thanks to research on how human cognition works. Developed over two decades by psychologist John Anderson, the Adaptive Character of Thought (ACT-R) theory is a framework for understanding how we think about and attack problems, including math equations. The theory reflects our understanding o human cognition based on numerous facts derived from psychological experiments. ACT-R suggests that complex cognition arises from an interaction of procedural and declarative knowledge. Declarative knowledge is a fairly direct encoding of facts (such as Washington, DC is the capital of the United States, 5 + 3 =8); procedural knowledge is a fairly direct encoding of how we do things (such how to drive or how to perform addition). According to the ACT-R theory, the power of human cognition depends on how people combine these two types of knowledge. Significance The ACT-R theory provides insights into how students learn new skills and concepts, and, in doing so allows teachers to see where students may need extra practice to master the new work. Practical Application Dr. Anderson and colleagues at Carnegie Mellon University have used this research to develop cognitive tutors, computer-tutoring programs that incorporate the ACT-R theory in the teaching of algebra, geometry and integrated math. The tutors are based on cognitive models that take the form of computer simulations that are capable of solving the types of problems that students are asked to solve. The tutors incorporate the declarative and procedural knowledge imbedded in the instruction and monitor students’ problem solving to determine what the students know and don’t know. This allows instruction to be directed at what still needs to be mastered and helps insure that students’ learning time is spent in a more efficient manner. Students work on a concept until it is fully understood. Students who are having conceptual problems will be drilled on in that area, while those who have mastered the concept move on to other areas. The most widely used cognitive tutor program – now known as Carnegie Learning’s Cognitive Tutor - combines software-based, individualized computer lessons with collaborative, real-world problem-solving activities. The program now serves more than 150,000 students in most of the nation’s largest school districts. Field studies have shown dramatic student achievement gains where the program is in use. In 2003, the U.S. Department of Defense Schools awarded a contract that will use Cognitive Tutor mathematics curricula in its 224 public schools in 21 districts located in 14 foreign countries, seven states, Guam and Puerto Rico. These schools have approximately 8,800 teachers serving 106,000 students. Cited Research Anderson, J. R. (1983). The architecture of cognition. Cambridge: MA: Harvard University Press. Anderson, J. R. (1993). Rules of the Mind. Hillsdale, NJ: Erlbaum. Lisp Lisp is the first language used in Artificial Intelligence and is structured so that a list is either data or a function call. In the case of a function call, Lisp uses prefix notation which means that the first list item is the name of the function and the remaining items are the arguments. Lisp indicates variables by a question mark. To illustrate – – (forall ?x (implies (cs_student ?x) (must_take ?x data_structures) ) ) (cs_student bill) Would yield – (must_take bill data_structures) Prolog Prolog is a logic programming language based on predicate logic. Prolog uses capital letters for variables and lowercase letters for predicates and constants and reverses the order for implication. Instead of writing P Q, Prolog orders implication as Q :- P. A comma is used to separate arguments and for conjunction with a period marking the end of a sentence. To illustrate, – cs_student(bill). – must_take(data_structures, X ) :- cs_student(X) The first sentence asserts a fact that “bill” is a cs_student while the second sentence asserts that any cs_student must take data structures. Prolog is launched by a goal such as – :- must_take(data_structures,Y) which would return – must_take(data_structures , bill) CLIPS Clips organizes knowledge by using named fact templates consisting of named slots. An example is the PAY template with slots for hours and pay rate. The deffacts statement creates initial facts accolrding to selected templates. An example is the payroll statement which assigns an initial fact of 44 hours and of a rate of $8 / hour. Fact List (deftemplate pay (slot hours)(slot rate)) (deffacts payroll ( pay (hours 44)(rate 8)) (status incomplete) ) CLIPS Clips infers new knowledge by using named rule templates consisting of an antecedent which must match facts in the fact list and a consequent which adds or modifies facts. Fact List Rule List (defrule calculate_basic ?p <- (pay (hours ?h)(rate ?r)) (test (<= ?h 40)) => (assert (basic_pay (* ?h ?r))) (retract ?p) ) CLIPS Rule List (deftemplate pay (slot hours)(slot rate)) (deffacts payroll ( pay (hours 44)(rate 8)) (status incomplete) ) Rule List (defrule calculate_basic ?p <- (pay (hours ?h)(rate ?r)) (test (<= ?h 40)) => (assert (basic_pay (* ?h ?r))) (retract ?p) ) (defrule calculate_overtime (pay (hours ?h)(rate ?r)) (test (> ?h 40)) (status incomplete) => (assert (overtime (* (- ?h 40) (* ?r 1.5)))) ) (defrule calculate_regular (pay (hours ?h)(rate ?r)) (status incomplete) (test (> ?h 40)) => (assert (regular (* 40 ?r) )) ) (defrule calculate_adjustedgross (regular ?r) (overtime ?o) (status incomplete) => (assert (adjusted_gross (+ ?r ?o))) (assert (status done)) ) Neural Nets An artificial neuron consists of inputs xi , I = 1..n, which have a value of 0 or 1. Each input xi can collect a value from the environment or from the output of another neuron and an associated weight wi. A neuron is activated if the sum of the weighted inputs wixi exceeds a threshold function f. The neuron outputs a 1 if activated and otherwise outputs a 0. Two sets of points in 2 dimensional space are linearly separable if they can be separated by a straight line. In this case, the points can be classified by a single neuron which outputs a 0 for points on one side of the line and a 1 for points on the other side. This classification is an example of artificial intelligence. The point sets classified by a logical Or gate and those classified by a logical And gate are linearly separable but not those classified by an Exclusive Or. Genetic Algorithms Genetic algorithms are based on a biological metaphor of evolving solutions to a problem. The solutions are strings over some alphabet and are referred to as genes. Given an initial population P0, each member gene is evaluated by a fitness function specific to the problem For example, for the knapsack function, the gene might be a list of object indices to be included and the fitness might be the wasted space in the knapsack. Members are selected based on fitness and offspring are created using crossover and mutation operators to form the next population. The process halts after so many populations and the most fit member of the final population is selected as the solution to the problem Representation and Search • Representation of Problem Information – Propositional & Predicate Logic – Semantic networks – State Space • • • • set of problem states along with transitions between states and a set of start states and goal states. a path from start to goal is a solution • Search – Techniques for finding a solution Eight Puzzle • Representation – The squares of the eight puzzle can be represented by integers 1 .. 8 and 9 represents empty square. • A state of the puzzle is a permutation of 1..9 where 1st three represent top row, 2nd three represent middle row, and 3rd three represent bottom row. Eight puzzle transitions • An eight puzzle transition consists of moving a square numbered 1..8 into the adjacent vacant square which can only be done if it is adjacent to the numbered square. • Representation of a board configuration is a permutation of 1..9 where 9 represents vacant square. Example – 132496758 represents 1st row 132, 2nd row 4 blnk 6, 3rd row 748. • Since the blank is in the middle position, 3 can be moved down, or 4 to the right, or 6 to the left, or 5 moved up. • These transitions make 132496758 have neighbors 192436758, 132946758, 132469758, and 132456798. Knowledge Representation • Essential to artificial intelligence are methods of representing knowledge. Besides propositional and predicate logic, a number of other methods have been developed, including: – Semantic Networks – Conceptual Dependencies – Scripts – Frames Semantic Networks • Models meaning of language: – Nodes correspond to word concepts – Arcs are labeled with a property name or relationship and link a node (word concept) with another (value of property). • Quillian (1967) introduced semantic networks while others (Simmons -1973, Brachman-1979, Schank-1979) have extended the model. Semantic Networks Standardization of Relationships • Standardization of relationships for representing knowledge expressed in language • focuses on case relations between verbs and nouns in sentence (Fillmore ’68, Simmons ’73) • Prepositions or articles indicate relationship between verb and noun : – – – – Agent : entity performing the action Object : entity acted upon Instrument : entity used in performing the action Etc. Conceptual Dependencies Set of Primitive Actions • Standardization of relations led to axiomatic approach to build semantic model for representing meaning of language Four Primitive Concept Classes ACTS - Actions PPs – Objects (Picture producers) AAs – Modifiers of actions (Action Aiders) PAs – Modifiers of objects (picture aiders) Each Action is assumed to reduce to one or more of the primitive ACTs ATRANS – transfer relationship (give) PTRANS – transfer physical location (go) PROPEL MOVE GRASP INGEST EXPEL MTRANS MBUILD CONC SPEAK ATTEND Building Complex Conceptual Dependencies Conceptual Dependency PP ACT PP PA ACT O PP ACT R PP PP Semantics An actor acts Object has attribute Indicates object of action Indicates the receipt And donor of An Action Example John PTRANS … John ran John height John is tall John Propel O cart John pushes the cart John ATRANS R John Mary John took the book from Mary Scripts . • Scripts formalize stereotyped sequences of events • • A script for a restaurant differs from one for a “fast food” model. The components of a script are – Entry conditions which must be true for script to be activated – Termination conditions which are true when script is terminated. – Props or object which support the script. The script for a restaurant would include table and cash register props. – Roles are the actions that individual participants must perform. The waiter takes orders, the customer eats and pays bill. – Scenes break the script into subsequences which • Are sequential in occurerence • Provide alternatives (if condition A then Scene1 elsce Scene2) Frames • Frames formalize stereotyped entities and actions. • Frames have labeled slots with slot contents an object or action and slot labels are the role played by the slot filler in relation to the central entity of action. • A frame is like a record that contains information relevant to stereotyped action or entity: – Frame Identification – Relationship to other frames (part-of, caused-by) – Slots • • • • • Label indicating relationship to central slot Requirements for slot filler Procedural information to construct or manipulate slot contents Default Contents Slot contents Frame Examples Case Frame representation of “Mary fixed the chair with glue” Action Fix Agent Mary Object Chair Instrument Glue Time past Conceptual Graphs A Network Language • A conceptual graph is a refinement of semantic networks. • A conceptual graph is bipartite with one class of nodes representing word concepts and the other class of nodes representing relations. • Arcs go from concept class nodes to relation class nodes and vise vesa. Conceptual Graph Examples Flies is unary relation or predicate flies bird Color is a binary relation dog color brown Parents is a ternary relation mother child mary agent parents give father object recipient Mary gave john a book book john