Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 541: Artificial Intelligence Lecture IV: Logic Agent and First Order Logic.

Similar presentations


Presentation on theme: "CS 541: Artificial Intelligence Lecture IV: Logic Agent and First Order Logic."— Presentation transcript:

1 CS 541: Artificial Intelligence Lecture IV: Logic Agent and First Order Logic

2 Announcement  CA Office Hour: 3:00pm-4:00pm, Lieb 319.  Homework assignment should be checked at Moodle.

3 Schedule WeekDateTopicReadingHomework** 108/29/2012Introduction & Intelligent AgentCh 1 & 2N/A 209/05/2012Search: search strategy and heuristic searchCh 3 & 4sHW1 (Search) 309/12/2012Search: Constraint Satisfaction & Adversarial SearchCh 4s & 5 & 6 Teaming Due 409/19/2012Logic: Logic Agent & First Order LogicCh 7 & 8sHW1 due, Midterm Project (Game) 509/26/2012Logic: Inference on First Order LogicCh 8s & 9 610/03/2012 No class 7 10/10/2012Uncertainty and Bayesian Network Ch 13 & Ch14s HW2 (Logic) 8 10/17/2012 Midterm Presentation Midterm Project Due 9 10/24/2012Inference in Baysian NetworkCh 14sHW2 Due, HW3 (Probabilistic Reasoning) 10 10/31/2012Probabilistic Reasoning over TimeCh 15 11 11/07/2012Machine Learning HW3 due, 1211/14/2012Markov Decision ProcessCh 18 & 20HW4 (Probabilistic Reasoning Over Time) 1311/21/2012 No class Ch 16 1411/29/2012Reinforcement learningCh 21HW4 due 1512/05/2012Final Project Presentation Final Project Due

4 Re-cap Lecture III  Constraint Satisfaction Problem  Constraint satisfaction problem (CSP) examples  Backtracking search for CSPs  Problem structure and problem decomposition  Local search for CSPs  Adversarial Search and Games  Games  Perfect play  Minimax decisions  α - β pruning  Resource limits and approximate evaluation  Games of chance  Games of imperfect information

5 Logic Agent Lecture IV: Part I

6 Outline  Knowledge-based agents  Wumpus world  Logic in general—models and entailment  Propositional (Boolean) logic  Equivalence, validity, satisfiability  Inference rules and theorem proving  Forward chaining  Backward chaining  Resolution

7 Knowledge bases  Knowledge base  Set of sentences in a formal language  Declarative approach to building an agent (or other system)  T ELL it what is needs to know  Then it can A SK itself what to do  Answers should follow from the KB  Agents can be viewed at the knowledge level  i.e., what they know, regardless of how implemented  Or at the implementation level  i.e., data structures in KB and algorithms that manipulate them

8 A simple knowledge-based agent  The agent must be able to:  Represent states, actions, etc.  Incorporate new percepts  Update internal representations of the world  Deduce hidden properties of the world  Deduce appropriate actions

9 Wumpus world PEAS description  Performance measure  Gold +1000; Death -1000  -1 per step; -10 for using the arrow  Environment  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  Grabbing picks up gold if in same square  Releasing drops the gold in same square  Actuators  Left turn, right turn, forward, grab, release, shoot  Sensors  Breeze, glitter, smell

10 Wumpus world characterization  Observable??  No, only local perception  Deterministic??  Yes, outcomes exactly specified  Episodic??  No, sequential at the level of actions  Static??  Wumpus and pits do not move  Discrete??  Yes  Single-agent??  Yes, Wumpus is essentially a natural feature

11 Exploring a wumpus world

12

13

14

15

16

17

18

19 Other tight spots  Breeze in (1,2) and (2, 1)  No safe actions  Smell in (1,1)  Cannot move  Can use a strategy of coercion  Shoot straight ahead  Wumpus was there  dead  safe  Wumpus wasn’t there  safe

20 Logic in general  Logics are formal languages for representing information  Such that conclusions can be drawn  Syntax defines the sentences in the language  Semantics define the “meaning” of sentences  i.e., define truth of a sentence in a world  E.g., the language of arithematics  x+2≥y is a sentence; x2+2> is not a sentence  x+2≥y is true iff the number x+2 is no less than the number y  x+2≥y is true in a world where x=7, y=1  x+2≥y is false in a world where x=0, y=6

21 Entailment

22 Models

23 Entailment in the wumpus world  Situation after detecting nothing in [1,1], moving right, breeze in [2,1]  Consider possible models for ?s assuming only pits  3 Boolean choices  8 possible models

24 Wumpus models

25  KB=wumpus-world rules+observations

26 Wumpus models

27  KB=wumpus-world rules+observations

28 Wumpus models

29 Inference

30 Propositional logic: Syntax

31 Propositional logic: Semantics

32 Truth tables for connectives

33 Wumpus world sentences

34 Truth tables for inference

35 Inference by enumeration

36 Logical equivalence

37 Validity and satisfiability

38 Proof methods  Proof methods divide into (roughly) two kinds:  Application of inference rules  Legitimate (sound) generation of new sentences from old  Proof = a sequence of inference rule applications  Can use inference rules as operators in a standard search algorithm  Typically require translation of sentences into a norm form  Model checking  Truth table enumeration (always exponential in n)  Improved backtracking, e.g., Davis-Putnam-Logemann-Loveland (DPLL)  Heurisitc search in model space (sound but incomplete)  E.g., min-conflicts-like hill-climbing algorithms

39 Forward and backward chaining

40  Idea: fire any rule whose premises are satisfied in the KB, add its conclusion to the KB, until query is found Forward chaining

41 Forward chaining algorithm

42 Forward chaining example

43

44

45

46

47

48

49

50 Proof of completeness

51 Backward chaining  Idea: work backwards from the query q:  To prove q by BC, check if q is known already, or, prove by BC all premises of some rule concluding q  Avoid loops: check if new subgoal is already on the goal stack  Avoid repeated work: check if new sub goal  Has already been proven true, or  Has already failed

52 Backward chaining example

53

54

55

56

57

58

59

60

61

62

63 Forward vs. backward chaining  FC is data-driven, cf. automatic, unconscious processing  E.g., object recognition, routine decisions  May do lots of work that is irrelevant to the goal  BC is goal-driven, appropriate for problem-solving  E.g., where are my keys? How do I get into a PhD program?  Complexity of BC can be much less than linear in size of KB

64 Resolution

65 Conversion to CNF

66 Resolution algorithm

67 Resolution example

68 Summary  Logical agents apply inference to a knowledge base to derive new information and make decisions  Basic concepts of logic:  Syntax: formal structure of sentences  Semantics: truth of sentences wrt models  Entailment: necessary truth of one sentence given another  Inference: deriving sentences from other sentences  Soundess: derivations produce only entailed sentences  Completeness: derivations can produce all entailed sentences  Wumpus world requires the ability to represent partial and negated information, reason by cases, etc.  Forward, backward chaining are linear-time, complete for Horn clauses  Resolution is complete for propositional logic  Propositional logic lacks expressive power

69 First-order Logic Lecture IV: Part II

70 Outline  Why first-order logic (FOL)?  Syntax and semantics of FOL  Fun with sentences  Wumpus world in FOL

71 Pros and cons of propositional logic

72 First-order logic  Whereas propositional logic assumes world contains facts,  First-order logic (like natural language) assumes that the world contains  Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games, wars, centuries …  Relations: red, round, bogus, prime, multistoried…, brother of, bigger than, inside, part of, has color, occurred after, owns, comes between, …  Functions: father of, best friend, third inning of, one more than, end of…

73 Logics in general

74 Syntax of FOL: Basic elements

75 Atomic sentences  Atomic sentence = predicate(term 1, …, term n )  Or term 1 =term 2  Term=function(term 1,…,term n ) or constant or variable  E.g., Brother(King John, RichardTheLinonHeart)  >(Length(LeftLegOf(Richard))), Length(LeftLegOf(KingJohn)))

76 Complex sentences

77 Truth in first-order logic

78 Models for FOL: example

79 Truth example  Consider the interpretation in which  Richard  Richard the Lionheart  John  the evil King John  Brother  The brotherhood relation  Under this interpretation, Brother(Richard, John) is true, just in case Richard the Liohheart and the evil King John are in the brotherhood relation in the model

80 Models of FOL: lots!  Entailment in propositional logic can be computed by enumerating models  We can enumerate the FOL models for a given KB vocabulary, i.e.,  For each number of domain elements n from 1 to ∞  For each k-ary predicate P k in the vocabulary  For each possible k-ary relation on n objects  For each constant symbol C in the vocabulary  For each choice of referent for C from n Objects …  Computing entailment by enumerating FOL models is not easy!

81 Universal quantification

82 A common mistake to avoid

83 Existential quantification

84 Another common mistake to avoid

85 Properties of quantifiers

86 Fun with sentences

87 Equality

88 Interacting with FOL KBs

89 Knowledge base for the wumpus world

90 Deducing hidden properties

91 Keeping track of change

92 Describing actions I

93 Describing actions II

94 Making plans

95 Making plans: A better way

96 Summary  First-order logic:  Objects and relations are semantic primitives  Syntax: constants, functions, predicates, equality, quantiers  Increased expressive power: sufficient to define wumpus world  Situation calculus:  Conventions for describing actions and change in FOL  Can formulate planning as inference on a situation calculus KB


Download ppt "CS 541: Artificial Intelligence Lecture IV: Logic Agent and First Order Logic."

Similar presentations


Ads by Google