240 likes | 454 Views
CSC 423 ARTIFICIAL INTELLIGENCE. LOGICAL AGENTS. Introduction. This chapter introduces knowledge-based agents. The concepts that we discuss—the representation of knowledge and the reasoning processes that bring knowledge to life—are central to the entire field of artificial intelligence.
E N D
CSC 423ARTIFICIAL INTELLIGENCE LOGICAL AGENTS
Introduction This chapter introduces knowledge-based agents. The concepts that we discuss—the representationof knowledge and the reasoning processes that bring knowledge to life—are centralto the entire field of artificial intelligence. Humans, it seems, know things and do reasoning.Knowledge and reasoning are alsoimportant for artificial agents because they enable successful behaviors that would be veryhard to achieve otherwise. We have seen that knowledge of action outcomes enablesproblemsolvingagents to perform well in complex environments. 2
Introduction (Cont) Knowledge and reasoning also play a crucial role in dealing with partially observableenvironments. A knowledge-based agent can combine general knowledge with current perceptsto infer hidden aspects of the current state prior to selecting actions. For example, aphysician diagnoses a patient—that is, infers a disease state that is not directly observable—prior to choosing a treatment. Some of the knowledge that the physician uses in the form ofrules learned from textbooks and teachers, and some is in the form of patterns of associationthat the physician may not be able to consciously describe. If its inside the physician’s head,it counts as knowledge. 3
KNOWLEDGE-BASED AGENTS The central component of a knowledge-based agent is its knowledge base, or KB. Informally, a knowledge base is a set of sentences. (Here “sentence” is used as a technical term. It isrelated but is not identical to the sentences of English and other natural languages.) Each sentenceis expressed in a language called a knowledge representation language and represents some assertion about the world. There must be a way to add new sentences to the knowledge base and a way to querywhat is known. The standard names for these tasks are TELL and ASK, respectively. Bothtasks may involve inference—that is, deriving new sentences from old. In logical agents,which are the main subject of study in this chapter, inference must obey the fundamentalrequirement that when one ASKs a question of the knowledge base, the answer should followfrom what has been told (or rather, TELLed) to the knowledge base previously. 4
A GENETIC KNOWLEDGE-BASED AGENTS Shows the outline of a knowledge-based agent program. Like all our agents,it takes a percept as input and returns an action. The agent maintains a knowledge base, KB,which may initially contain some background knowledge. Each time the agent program iscalled, it does two things. First, it TELLs the knowledge base what it perceives. Second,it ASKs the knowledge base what action it should perform. In the process of answeringthis query, extensive reasoning may be done about the current state of the world, about theoutcomes of possible action sequences, and so on. Once the action is chosen, the agentrecords its choice with TELL and executes the action. The second TELL is necessary to letthe knowledge base know that the hypothetical action has actually been executed. 5
A GENETIC KNOWLEDGE-BASED AGENTS (Cont) The details of the representation language are hidden inside two functions that implementthe interface between the sensors and actuators and the core representation and reasoningsystem. MAKE-PERCEPT-SENTENCE takes a percept and a time and returns a sentenceasserting that the agent perceived the percept at the given time. MAKE-ACTION-QUERYtakes a time as input and returns a sentence that asks what action should be performed atthat time. The details of the inference mechanisms are hidden inside TELL and ASK. 6
The Wumpus World The wumpus world is a cave consisting of rooms connected by passageways. Lurking somewherein the cave is the wumpus, a beast that eats anyone who enters its room. The wumpuscan be shot by an agent, but the agent has only one arrow. Although the wumpus world is rather tame by modern computergame standards, it makes an excellent testbed environment for intelligent agents. 7
The Wumpus World (Cont) In the cave of rooms there is also one static wumpus (a beast)and a heap of gold, in addition rooms can contain bottomless pits The agent’s possible actions are Move forward one square at a time, Turn left or right by 90°, Pick up the gold by grabbing, and Shooting one single arrow in the direction it is facing 8
Logic A logic must also define the semantics of the language. Loosely speaking, semanticshas to do with the “meaning” of sentences. In logic, the definition is more precise. Thesemantics of the language defines the truth of each sentence with respect to each possible. For example, the usual semantics adopted for arithmetic specifies that the sentence“x + y =4” is true in a world where x is 2 and y is 2, but false in a world where x is 1and y is 1. In standard logics, every sentence must be either true or false in each possibleworld—there is no “in between.” 9
Sementic Draw a semantic net representing the following information. Mr. Bloggs collects cars. Cars are, of course, a type of vehicle and arenormally propelled by an engine. All those that Mr. Bloggs owns were madebefore 1970. He has a smart black Austin A4, with polished chromework, anda rather battered blue Mini, with very rusty chromework. He also has a sleekblack Jaguar, with leather seats. 10
PROPOSITIONAL LOGIC: A VERY SIMPLE LOGIC Propositional logic is also called Boolean logic, after the logician George Boole. The syntax of propositional logic defines the allowable sentences. The atomic sentences—the indivisible syntactic elements—consist of a single proposition symbol. Each such symbol stands for a proposition that can be true or false. 12
PROPOSITIONAL LOGIC: A VERY SIMPLE LOGIC (Cont) NOT: If S1 is a sentence, then ¬S1 is a sentence (negation) AND: If S1, S2 are sentences, then S1 S2 is a sentence (conjunction) OR: If S1, S2 are sentences, then S1 S2 is a sentence (disjunction) IMPLIES: If S1, S2 are sentences, then S1 S2 is a sentence (implication) IF and only F: If S1, S2 are sentences, then S1 S2 is a sentence (biconditional) 13
A BNF (Backus–Naur Form) grammar of sentences in propositional logic 14
Truth Table 15
Equivalence The first concept is logical equivalence: two sentences and are logically equivalentf they are true in the same set of models. We write this as α β. For example, we can easily show (using truth tables) that P ^ Q and Q ^ P are logically equivalent. They play much the same role in logic as arithmetic identities do in ordinary mathematics. An alternative definition of equivalence is as follows: for any two sentences and α and β (Recall that |= means entailment.) 16
Validity 17
Satisfiability Many problems in computer science are really satisfiability problems. For example, allthe constraint satisfaction problems are essentially asking whether the constraintsare satisfiable by some assignment. With appropriate transformations, search problems canalso be solved by checking satisfiability. Validity and satisfiability are of course connected: 18
Conjunctive Normal Form (CNF) The resolution rule applies only to disjunctions of literals, so it would seem to be relevant onlyto knowledge bases and queries consisting of such disjunctions. How, then, can it lead to acomplete inference procedure for all of propositional logic? The answer is that every sentenceof propositional logic is logically equivalent to a conjunction of disjunctions of literals. Asentence expressed as a conjunction of disjunctions of literals is said to be in conjunctivenormal form or CNF. 21
Inference-Based Agent and the Circuit-Based AgentComparison The inference-based agent and the circuit-based agent represent the declarative and proceduralextremes in agent design. They can be compared along several dimensions: Conciseness: The circuit-based agent, unlike the inference-based agent, need not haveseparate copies of its “knowledge” for every time step. Instead, it refers only to thecurrent and previous time steps. Both agents need copies of the “physics” (expressedas sentences or circuits) for every square and therefore do not scale well to larger environments.In environments with many objects related in complex ways, the numberof propositions will swamp any propositional agent. Such environments require the expressivepower of first-order logic. Propositional agents of both kindsare also poorly suited for expressing or solving the problem of finding a path to a nearbysafe square. Computational efficiency: In the worst case, inference can take time exponential in thenumber of symbols, whereas evaluating a circuit takes time linear in the size of thecircuit. 22
Inference-Based Agent and the Circuit-Based AgentComparison (Cont) Completeness: We suggested earlier that the circuit-based agent might be incompletebecause of the acyclicity restriction. The reasons for incompleteness are actually morefundamental. First, remember that a circuit executes in time linear in the circuit size.This means that, for some environments, a circuit that is complete (i.e., one that computesthe truth value of every determinable proposition) must be exponentially largerthan the inference-based agent’s KB. Otherwise, we would have a way to solve thepropositional entailment problem in less than exponential time, which is very unlikely.A second reason is the nature of the internal state of the agent. The inference-basedagent remembers every percept and knows, either implicitly or explicitly, every sentencethat follows from the percepts and initial KB.The circuit-based agent, on theother hand, forgets all previous percepts and remembers just the individual propositionsstored in registers. 23
Inference-Based Agent and the Circuit-Based AgentComparison (Cont) Ease of construction: This is a very important issue about which it is hard to be precise.Certainly, this author found it much easier to state the “physics” declaratively, whereasdevising small, acyclic, not-too-incomplete circuits for direct detection of pits seemedquite difficult. 24