1 / 29

Logic

Logic. Introduction to Artificial Intelligence CS440/ECE448 Lecture 9 SECOND HOMEWORK DUE MONDAY. Last lecture. Nondeterministic games Logic The Wumpus world Entailment Today Logic Entailment and inference Propositional logic: Syntax and semantics Inference rules Reading

lucie
Download Presentation

Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logic Introduction to Artificial Intelligence CS440/ECE448 Lecture 9 SECOND HOMEWORK DUE MONDAY

  2. Last lecture • Nondeterministic games • Logic • The Wumpus world • Entailment Today • Logic • Entailment and inference • Propositional logic: Syntax and semantics • Inference rules Reading • Chapters 7 and 8

  3. Minimax for nondeterministic games • For min node, compute min of children. • For chance node, compute weighted average of children. • For max node, compute max of children. 3

  4. Function MINIMAX-VALUE (state, game) returns a utility value If TERMINAL-TEST[game](state) then return UTILITY[game](state) else if MAX is to move in state then return the highest MINIMAX-VALUE of Successors[state] else return the lowest MINIMAX-VALUE of Successors[state] Function EXPECTIMINIMAX-VALUE (state, game) returns a utility value If TERMINAL-TEST[game](state) then return UTILITY[game](state) else ifstate is a chance node then return average of EXPECTIMINMAX-VALUE of Successors(state) else if MAX is to move in state then return the highest EXPECTIMINIMAX-VALUE of Successors[state] else return the lowest EXPECTIMINIMAX-VALUE of Successors[state]

  5. Logic

  6. Knowledge bases Inference Engine Knowledge Base Domain-independent knowledge Domain-specific content • Knowledge base = set of sentences in a formal language. • Declarative approach to building an agent or other system: • Tell it what it needs to know • Alternative is a learning approach, but we will do that later. • Answers should follow from the KB. • Agents or systems 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.

  7. Goals: Get gold back to the start without entering it or wumpus square. Percepts: Breeze, Glitter, Smell. Actions: Left turn, Right turn, Forward, Grab, Release, Shoot. Environment Squares adjacent to wumpus are smelly. Squares adjacent to pit are breezy. Glitter if and only if gold is in the same square. Shooting kills the wumpus if you are facing it. Shooting uses up the only arrow. Grabbing picks up the gold if in the same square. Releasing drops the gold in the same square. The Wumpus World

  8. Logic in general • Logicsare 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. • For example, the language of arithmetic • x + 2  y is a sentence. • x + y > is not a sentence. • x + 2  yis true iff the number x+2 is no less than the number y. • x + 2  yis true in a world where x = 7, y =1. • x + 2  y is false in a world where x = 0, y= 6.

  9. Types of logic • Logics are characterized by what they commit to as ``primitives'' • Ontological commitment: what exists - facts? objects? time? beliefs? • Epistemological commitment: what states of knowledge?

  10. Entail Sentences KB Semantics Follows Facts Facts Entailment Sentences  Logical Representation Semantics World A knowledge base is a collection of sentences. An entailed sentence is true, given that the old sentences in the knowledge base are true.

  11. Potential models of the Wumpus world A model is an instance of the world. A model of a set of sentences is an instance of the world where these sentences are true.

  12. Entailment

  13. Entailment again

  14. Inference • A knowledge base is a collection of sentences. • Knowledge base KB entails sentence  if and only if  is true whenever KB is true (i.e. all sentences in KB are true). • An inference procedure i can do two things: • Given KB, generate new sentence  purported to be entailed by KB. • Given KB and , report whether or not  is entailed by KB. • A sound inference procedure only produces entailed sentences. • Every entailed sentence can be generated by a complete inference procedure.

  15. Propositional logic: Syntax • Propositional logic is the simplest logic. • Logical constants TRUE and FALSE are sentences. • Proposition symbols P1, P2 etc. are sentences. • Symbols P1 and negated symbols  P1 are called literals. • If S is a sentence,  S is a sentence (NOT). • If S1 and S2 is a sentence, S1  S2 is a sentence (AND). • If S1 and S2 is a sentence, S1  S2 is a sentence (OR). • If S1 and S2 is a sentence, S1  S2 is a sentence (Implies). • If S1 and S2 is a sentence, S1  S2 is a sentence (Equivalent).

  16. Order of Precedence From highest to lowest: parenthesis ( Sentence ) NOT  AND  OR  Implies  Equivalent 

  17. Model of P  Q Propositional logic: Semantics Most sentences are sometimes true. P  Q Some sentences are always true (valid). P  P Some sentences are never true (unsatisfiable). P  P

  18. Propositional logic: Semantics Implication: P  Q “If P is True, then Q is true; otherwise I’m making no claims about the truth of Q.” (Or: P  Q is equivalent to Q) Under this definition, the following statement is true Pigs_fly  Everyone_gets_an_A Since “Pigs_Fly” is false, the statement is true irrespective of the truth of “Everyone_gets_an_A”. [Or is it? Correct inference only when “Pigs_Fly” is known to be false.]

  19. Propositional Inference: Enumeration Method • Let    and KB = (  C)  B  C) • Is it the case that KB  ? • Check all possible models --  must be true whenever KB is true

  20. Propositional Inference: Enumeration Method • Let    and KB = (  C)  B  C) • Is it the case that KB  ? • Check all possible models --  must be true whenever KB is true

  21. KB  Propositional Inference: Enumeration Method • Let    and KB = (  C)  B  C) • Is it the case that KB  ? • Check all possible models --  must be true whenever KB is true

  22. Propositional Logic: Proof methods • Model checking • Truth table enumeration (sound and complete for propositional logic). • 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.

  23. Inference rules An inference rule is sound if the conclusion is true in all cases where the premises are true.  Premise _____  Conclusion

  24. An Inference Rule: Modus Ponens • From an implication and the premise of the implication, you can infer the conclusion.    Premise ___________  Conclusion • An inference rule is sound if the conclusion is true in all cases where the premises are true.

  25. An Inference Rule: And - Elimination • From a conjunction, you can infer any of the conjuncts. 1 2 … n Premise _______________ i Conclusion • An inference rule is sound if the conclusion is true in all cases where the premises are true.

  26. And-Introduction & Double Negation • And-Introduction 1, 2, …, n Premise _______________ 1 2 … n Conclusion • Double Negation Premise _______  Conclusion

  27. Knowledge Base in Wumpus World Percept Sentences S1,1 B1,1 S2,1 B2,1 S1,2 B1,2 … Environment Knowledge (can be written before any sensing) R1: S1,1 W1,1 W2,1 W1,2 R2: S2,1 W1,1 W2,1 W2,2 W3,1 R3: B1,1  P1,1 P2,1 P1,2 R4: B2,1  P1,1 P2,1  P2,2  P3,1 R5: B1,2  P1,1 P1,2  P2,2  P1,3 ... Si,j: Stench in cell i,j Bi,j: Breeze in cell i,j Wi,j: Wumpus in cell i,j

  28. Inference in Wumpus World Some inferences: Apply Modus Ponens to R1 Add to KB W1,1 W2,1 W1,2 Apply to this AND-Elimination Add to KB W1,1 W2,1 W1,2 Initial KB Percept Sentences S1,1 B1,1 S2,1 B2,1 S1,2 B1,2 … Environment Knowledge R1: S1,1 W1,1 W2,1 W1,2 R2: S2,1 W1,1 W2,1 W2,2 W3,1 R3: B1,1  P1,1 P2,1 P1,2 R4: B2,1  P1,1 P2,1  P2,2  P3,1 R5: B1,2  P1,1 P1,2  P2,2  P1,3 ...

  29. Summary of Propositional Logic • 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. • Truth table method is sound and complete for propositional logic. • Cumbersome in Wumpus world.

More Related