*,*,单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,人工智能原理,2010,年春季 广西大学 计算机学院,Dr.Ou,逻辑智能体,Logical Agents,(知识,推理),Chapter 7,1,“,Thinking Rationally”,Computational models of human“thought”processes,Computational models of human behavior,Computational systems that“think”rationally,Computational systems that behave rationally,2,逻辑智能体,逻辑(基于知识)智能体,Logic(Knowledge-Based)agents,通用知识,当前的感知,在决定动作前推理,(infer),出当前状态的隐含状况,这在部分可观察环境中至关重要,3,要点,基于知识的智能体,Knowledge-based agents,怪兽世界,Wumpus,world,逻辑,Logic in general,命题逻辑与一阶逻辑,Propositional and first-order logic,推理,合法,等价,可满足,模式推理,Reasoning patterns,归结,Resolution,前向/后向链,Forward/backward chaining,4,知识和推理,Knowledge&Reasoning,知识库,knowledge base(KB):,智能体所知道的一系列知识,根据,推理的规则,(,rules of inference),由旧的事实推出新事实,逻辑,Logic,表示知识,并进行推理,5,知识库,Knowledge Base,知识库,:,一系列,语句,以一种,知识表示语言,的格式,来,表示(有关世界的)断言,基于知识的智能体,:,Tell,it what it needs to know.,Ask,it what to do,应遵循,推理的规则,由知识库得到答案,tell,ask,6,通用的基于知识智能体,Generic KB-Based Agent,7,基于知识智能体的特性,能够,:,表示状态和动作,综合新的感知,更新关于世界的内部认识,推导出世界的隐含性质,推导出适合的动作,8,Mine Sweeper,Design a logical agent to play minesweeper,9,PEAS Analysis Mine Sweeper,Performance measure,+1 for each mine correctly identified,-1 for incorrectly identifying a mine,-1000 for selecting a location containing a mine,+1000 for identifying all mines.,Environment,9 x 9 board,each square has a mine with probability 0.1,Actuators,Agent can mark a location as containing a mine,can mark a location as unknown,or select a location for viewing,Sensors,Agent can sense the number of mines surrounding adjacent locations,Agent knows number of mines remaining,10,怪兽问题,Wumpus,World,怪兽,Wumpus,11,怪兽问题的,PEAS,描述,P,erformance,measure,性能度量,gold:+1000,death:-1000,-1 per step,-10 for using the arrow,E,nvironment,环境,Squares adjacent to,wumpus,are,smelly,Squares adjacent to pit are,breezy,Glitter,iff,gold is in the same square,Shooting kills,wumpus,if you are facing it.It,screams,Shooting uses up the only arrow,Grabbing picks up gold if in same square,Releasing drops the gold in same square,You,bump,if you walk into a wall,S,ensors,传感,:,Stench,Breeze,Glitter,Bump,Scream,A,ctuators,执行,:,Left turn,Right turn,Forward,Grab,Release,Shoot,12,Wumpus,world,的特征,Fully,Observable,No only,local,perception,Deterministic,Yes outcomes exactly specified,Episodic,No things we do have an impact.,Static,Yes,Wumpus,and Pits do not move,Discrete,Yes,Single-agent,Yes,Wumpus,is essentially a natural feature,13,Exploring the,Wumpus,World,The KB initially contains the rules of the environment.,1,1 The first percept is,none,none,none,none,none,Move to safe cell e.g.2,1,2,1 Breeze indicates that there is a pit in 2,2 or 3,1,Return to 1,1 to try next safe cell,14,Exploring the,Wumpus,World,1,2,Stench in cell:,wumpus,is in 1,3 or 2,2YET not in 1,1,Thus,not in 2,2 or stench would have been detected in 2,1,Thus,wumpus,is in 1,3,Thus,2,2 is safe because of lack of breeze in 1,2,Thus,pit in 3,1,Move to next safe cell 2,2,15,Exploring the,Wumpus,World,2,2,Detect nothing Move to unvisited safe cell e.g.2,3,2,3 Detect glitter,smell,breeze,Thus,pick up gold,Thus,pit in 3,3 or 2,4,16,What is a logic?,一种格式化的语言,语法,Syntax,怎样的表达是合法的,语义,Semantics,一个合法的表达式表示什么样的意义,逻辑中每一条语句的真值都对应着世界里的一种可能,例如算数语言,X+2=y is a sentence,x2+y is not a sentence,X+2=y is true in a world where x=7 and y=1,X+2=y is false in a world where x=0 and y=6,17,蕴涵,Entailment,蕴涵,Entailment,意味着一个东西,跟随,另外一个东西,:,KB,知识库,KB,蕴涵,语句,当且仅当,KB,为真的,所有,情况里,也为真,例如 一条语句的知识库,KB“the Giants won and the Reds won”,蕴涵“,The Giants won”.,又如,x+y,=4,蕴涵 4=,x+y,蕴涵其实就是语句之间基于,语义,的一种关系,18,模型,models,逻辑学家的就是以,模型,的方式来进行思维的,如果,在,m,中为真,则,m,是语句,的一个,模型,M(,),表示语句,的所有模型的集合,则,KB ,iff,M(KB),M(,),例如,KB=Giants won and Reds won,=Giants won,19,怪兽问题里的蕴涵,Entailment in the,wumpus,world,为说明方便,对,Wumpus,world,进行简化,只考虑有关陷阱的模型,下图为探测到方格,1,1,什么都没有,然后向右到方格,2,1,,感知到,2,1,有微风之后的情形,20,Wumpus,models I,All possible models(exactly 8)in this reduced,Wumpus,world.,Pit,Breeze,21,Wumpus,models II,KB=,怪兽世界的规则,由感知得到的观察,22,Wumpus,models III,1,=“1,2 is safe”,KB ,1,通过,模型检验,(,model checking),得证,23,Wumpus,models IV,2,=2,2 is safe,KB,2,24,推理过程,Inference Procedures,KB,i,即 语句,通过过程,i,从,KB,导出,可靠,Soundness,:,只要,KB,i,就有,KB,为真,则称,i,是,可靠,的,(推理不会出错,但不一定能够导出所有的正确结论,),完备,Completeness,:,只要,KB,就有,KB,i,为真,则称,i,是完备的,(所有的正确结论都会被导出,但是可能会导出一些多余的错误结论,),25,语义透视图,当知识库,KB,为真时,由一个可靠的推理过程导出的,语句,也一定是为真的,26,命题逻辑,:,语法,命题逻辑是最简单的逻辑,命题符号,P,1,P,2,等,表示语句,If S is a sentence,S is a sentence (,negation,),If S,1,and S,2,are sentences,S,1,S,2,is a sentence(,conjunction,),If S,1,and S,2,are sentences,S,1,S,2,is a sentence(,disjunction,),If S,1,and S,2,are sentences,S,1,S,2,is a sentence(,implication,),If S,1,and S,2,are sentences,S,1,S,2,is a sentence(,biconditional,),27,命题逻辑:,语义,Each model/world specifies true or false for each proposition symbol,E.g.P,1,2,P,2,2,P,3,1,falsetruefalse,With these symbols,8 possible models,can be enumerated automatically.,Rules for evaluating truth with respect to a model,m,:,Sis true,iff,S is false,S,1,S,2,is true,iff,S,1,is true,and,S,2,is true,S,1,S,2,is true,iff,S,1,is true,or,S,2,is true