cs 510 lecture 5: logic and representationgreenie/cs510/cs510-18-05.pdf · – inference: deriving...
TRANSCRIPT
![Page 1: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/1.jpg)
CS 510 Lecture 5: Logic and Representation
Rachel GreenstadtNovember 5, 2018
![Page 2: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/2.jpg)
Project Proposals
• Grades are in place
• If you want to change your project:
• Send me email
• With your final paper, submit a one page description of how what you’ve done is different than your proposal
![Page 3: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/3.jpg)
Midterm Stats
• Mean 150
• Median 150
• Std Dev 26.4
![Page 4: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/4.jpg)
Some Review
• Agents should always act rationally, regardless of the task environment.
![Page 5: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/5.jpg)
Overview
• Knowledge Bases
• Propositional logic
![Page 6: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/6.jpg)
Knowledge Bases
• Knowledge base = set of sentences in a formal language
• Declarative approach to building an agent - TELL it what it needs to know
• Then it ASKs itself what to do, answers follow from knowledge base
• “Building a model of the world” part from Lecture 1
• BDI is one paradigm for this
![Page 7: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/7.jpg)
Knowledge-based agent
The agent must be able to:Represent states, actions, etcIncorporate new perceptsUpdate internal representation of the worldDeduce hidden properties of the worldDeduce appropriate actions
![Page 8: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/8.jpg)
Breeze Breeze
Breeze
BreezeBreeze
Stench
Stench
Breeze
PIT
PIT
PIT
1 2 3 4
1
2
3
4
START
Gold
Stench
![Page 9: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/9.jpg)
Logic
• Logics : formal languages for representing information
• Syntax defines the sentences in the language
• Semantics define the “meaning” of sentences
![Page 10: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/10.jpg)
Types of Logic• Logics are characterized by what they commit to as primitives
• Ontological commitment - What exists?
• Facts, objects, times, beliefs?
![Page 11: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/11.jpg)
Entailment
• Knowledge Base KB entails a sentence α if and only if
• α is true in all worlds where KB is true
• E.g. , the KB containing “the Giants won” and “the Reds won” entails “either the Giants won or the Reds won”
KB = α
![Page 12: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/12.jpg)
Inference
• KB|-iα : sentence α can be derived from KB by procedure i
• Soundness : i is sound if whenever KB|-iα it is also true that KB =α
• Completeness: i is complete if whenever KB =α, it is also true that KB|-iα
![Page 13: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/13.jpg)
Propositional Logic: Syntax
• Propositional logic is the simplest logic – illustrates basic ideas
• The proposition symbols P1, P2 etc are sentences
![Page 14: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/14.jpg)
Propositional Logic: Semantics
![Page 15: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/15.jpg)
Inference: Enumeration Method
![Page 16: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/16.jpg)
Enumeration Solution
![Page 17: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/17.jpg)
Normal Forms
![Page 18: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/18.jpg)
Inference Rules for Propositional Logic
![Page 19: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/19.jpg)
Forward chaining• Idea: fire any rule whose premises are satisfied in the KB,
– add its conclusion to the KB, until query is found
![Page 20: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/20.jpg)
Proof of completeness• FC derives every atomic sentence that is entailed
by KB
1. FC reaches a fixed point where no new atomic sentences are derived
2. Consider the final state as a model m, assigning true/false to symbols
3. Every clause in the original KB is true in m
a1 ∧ … ∧ ak ⇒ b
4. Hence m is a model of KB
![Page 21: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/21.jpg)
Backward chainingIdea: 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 subgoal
1. has already been proved true, or
2. has already failed
![Page 22: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/22.jpg)
Forward vs. backward chaining• FC is data-driven, 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
![Page 23: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/23.jpg)
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
– soundness: derivations produce only entailed sentences
– completeness: derivations can produce all entailed sentences
• Resolution is complete for propositional logicForward, backward chaining are linear-time, complete for Horn clauses
![Page 24: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/24.jpg)
Limits on Propositional Logic
• B1,1 iff (P1,2 v P 2,1) vs “Squares adjacent to pits are breezy”
• But natural language has drawbacks for representation (ambiguity without context)
![Page 25: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/25.jpg)
First Order Logic
• Objects (like Propositional logic) - people, houses, numbers, theories, colors, wars, centuries
• Relations
• Unary (properties like red, round, prime, multistoried)
• n-ary : brother-of, bigger than, inside, is part of, has color, occurred after, owns, comes between
• Functions (1 to 1) : father of, best friend, third inning of, one more than
• Facts about some or all of the objects
![Page 26: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/26.jpg)
First order logic syntax
![Page 27: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/27.jpg)
First order logic syntax
![Page 28: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/28.jpg)
Truth in First Order Logic (Semantics)
![Page 29: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/29.jpg)
Making plans with logic
![Page 30: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/30.jpg)
Suggested Exercises
• Chapter 7 [7.2,7.10, 7.12]
• Chapter 8 [8.2, 8.6]
![Page 31: CS 510 Lecture 5: Logic and Representationgreenie/cs510/CS510-18-05.pdf · – inference: deriving sentences from other sentences – soundness: derivations produce only entailed](https://reader033.vdocument.in/reader033/viewer/2022060910/60a4b8e6f27dc043bc5f8fe5/html5/thumbnails/31.jpg)
Readings next week
• Nilesh Dalvi, Pedro Domingos, Mausam Sumit, Sanghai Deepak Verma. Adversarial Classification. in Proceedings of the Tenth International Conference on Knowledge Discovery and Data Mining (KDD), 2004.