**Unformatted text preview: **Lecture 6: Propositional Logic ICS 171, Summer 2000 AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 1 Outline Knowledge bases Logic in general Propositional logic Normal forms Inference rules AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 2 Knowledge bases Inference engine Knowledge base domain-independent algorithms domain-specific content Knowledge base = set of sentences in a formal language Allows an agent to reason about the world, deduce hidden properties and determine appropriate actions. Example: KB = fMike comes to the party; If Cathy comes to the party then Becky comes; If Cathy doesn't come then Mike won't come to the partyg Agent should be able to deduce that Becky comes to the party. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 3 Logic in general Logics are formal languages for representing information such that conclusions can be drawn Components of logic: Syntax de nes how we can make sentences in the language. Semantics de nes how the sentences re ect meaning in the real world. Inference Procedures specify how we can derive new sentences from our existing sentences. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 4 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? Language Propositional logic First-order logic Temporal logic Probability theory Fuzzy logic Ontological Commitment facts facts, objects, relations facts, objects, relations, times facts degree of truth Epistemological Commitment true false unknown true false unknown true false unknown degree of belief 0. . . 1 degree of belief 0. . . 1 We will look at propositional logic, rst-order logic also known as predicate logic and probability theory. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 5 Propositional logic: Syntax Symbols: Logical constants: True, False Propositional symbols: P , Q, R, : : : Connectives: ^ and _ or : not implies , equivalent Parentheses: AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 6 Syntax cont. The proposition symbols P , Q, R, etc. are sentences If S is a sentence, :S is a sentence If S1 and S2 is a sentence, S1 ^ S2 is a sentence If S1 and S2 is a sentence, S1 _ S2 is a sentence If S1 and S2 is a sentence, S1 If S1 and S2 is a sentence, S1 , S2 is a sentence S2 is a sentence AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 7 Propositional logic: Semantics Each propositional statement is a fact which can be true or false. Example: A means It is hot" B means It is sunny" C means It is raining" The user de nes what the propositional symbols mean. A model of the world speci es true false for each propositional symbol. E.g. A B C the world True True False It is sunny and hot but it is not raining False False True It is raining and it is not sunny nor hot AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 8 Propositional logic: Semantics Rules for evaluating truth with respect to a model m: :S is true i S is false S1 ^ S2 is true i S1 is true and S2 S1 _ S2 is true i S1 is true or S2 S1 S2 is true i S1 is false or S2 i.e., is false i S1 is true and S2 S1 , S2 is true i S1 S2 is true and S2 S1 Order of operations: :, ^, _, , , is true is true is true is false is true AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 9 Truth Table De nitions We can de ne the meaning of the logical connectives explicitly with a truth table: P Q P P Q P Q P F F T T F T F T : T T F F ^ F F F T _ F T T T T T F T Q P , T F F T Q AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 10 Semantics of Implication What does P Q mean? If P is true, then I am claiming that Q is true. If P is false then I make no claim. Also known as if-then rules Example: if it rains then I will get wet W Important: P R Q is equivalent to P Q : _ AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 11 Representing Knowledge in Propositional Logic Example: KB = fMike comes to the party; If Cathy comes to the party then Becky comes; If Cathy doesn't come then Mike won't come to the partyg Let M represent Mike comes to the party. C represent Cathy comes to the party. B represent Becky comes to the party. KB = M , C B , C M f : : g AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 12 Entailment KB j = Knowledge base KB entails sentence if and only if is true whenever all sentences in the KB are true. Alternatively: If the KB is true then must be true as well. E.g., the KB containing the Giants won" and the Reds won" entails Either the Giants won or the Reds won" E.g., our knowledge base KB = fM ; C B ; :C :M g entails B Why? AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 13 Models In propositional logic models can be thought of as a truth assignment to the literals that make the sentence true, e.g. what are the models of a sentence C B ? Let M be the set of all models of x x x x x x x x xx x x x x x x x x x x x x x x x x x x x xx x x x x x x x x x x x x x x x Then KB j= if and only if M KB M E.g. KB = Giants won and Reds won = Giants won M( ) M(KB) x AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 14 Inference KB `i = sentence i can be derived from KB by procedure i Soundness: i is sound if whenever KB ` , it is also true that KB j= Completeness: i is complete if whenever KB j= , it is also true that KB ` i Preview: we will de ne a logic rst-order logic which is expressive enough to say almost anything of interest, and for which there exists a sound and complete inference procedure. That is, the procedure will answer any question whose answer follows from what is known by the KB . AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 15 Sound and Unsound Inference Modus Ponens sound A If it is raining then Ann puts the top up on her convertible. It is raining. Therefore Ann puts the top up on her convertible. Abduction unsound B; B A A If it is raining then Ann puts the top up on her convertible. Ann put the top up on her convertible. Therefore it is raining. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 16 B; A B Propositional inference: Enumeration method A B and KB = A C Is it the case that KB = ? Let = _ _ j ^ B _ : C Check all possible models| must be true wherever KB is true A False False False False True True True True B False False True True False False True True C A C B False True False True False True False True _ _ : C KB AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 17 Propositional inference: Solution A False False False False True True True True B False False True True False False True True C False True False True False True False True A C False True False True True True True True _ B C True False True True True False True True _ : KB False False False True True False True True False False True True True True True True We just proved that an inference rule called resolution is sound. More on this later. Note: Truth table inference is very expensive. For n propositional symbols we need to look at 2 entries! n AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 18 Normal forms Other approaches to inference use syntactic operations on sentences, often expressed in standardized forms Conjunctive Normal Form CNF|universal conjunction of disjunctions of literals | E.g., A _ :B ^ B _ : clauses C D z _ : Horn Form restricted conjunction of Horn clauses clauses with 1 positive literal E.g., A _ :B ^ B _ :C _ :D Often written as set of implications: B A and C ^ D B AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 19 Validity and Satis ability A sentence is valid if it is true in all models e.g., A _ :A, A A, A ^ A B B Validity is connected to inference via the Deduction Theorem: KB j= if and only if KB is valid A sentence is satis able if it is true in some model e.g., A _ B , C A sentence is unsatis able if it is true in no models e.g., A ^ :A Satis ability is connected to inference via the following: KB j= if and only if KB ^ : is unsatis able i.e. Prove by contradiction AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 20 Proof methods Proof methods divide into roughly two kinds: Model checking truth table enumeration sound and complete for propositional Application of inference rules Legitimate sound generation of new sentences from old Proof = a sequence of inference rule applications Note: We can use inference rules as operators in a standard search algorithm. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 21 Inference rules for propositional logic Resolution for CNF: complete for propositional logic _ ; : _ _ Intuition: cannot be both true and false, therefore one of the other disjuncts must be true in one of the premises. Modus Ponens for Horn Form: complete for Horn KBs 1 ;:::; ; n 1 ^ ^ n More inference rules exist, e.g. AND-introduction, AND-elimination etc., they are more straightforward, incomplete in general but sound. See page 172 of course text. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 22 Exercise: Prove Modus Ponens is sound Prove the modus ponens rule: P is sound using truth tables. F F T T Q; Q P or in CNF form : P _ Q; Q P P Q F T F T : P : P Q _ KB Is Q true everywhere KB is true? AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 23 The Party Problem Example: KB = fMike comes to the party; If Cathy comes to the party then Becky comes; If Cathy doesn't come then Mike won't come to the partyg Let M represent Mike comes to the party. C represent Cathy comes to the party. B represent Becky comes to the party. KB = M , C B , C M f : : g Note: statements in the KB are implicitly connected by ^ AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 24 The Party Problem KB = f M , C B , :C :M g Convert to CNF 1. M 2. :C _ B 3. C _ :M Use resolution to combine 3 and 2. C _ : Add result to the KB 4. :M _ B M; C B M B : _ : _ AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 25 The Party Problem Use unit resolution to combine 1 and 4. : Since we derived B with a sound proof procedure we can infer that KB j= B or that Becky comes to the party. M B; B _ M AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 26 Converting Sentences to CNF 1. eliminate implications: recall that P Q is equivalent to :P 2. move : inwards: :P _ Q becomes :P ^ :Q :P ^ Q becomes :P _ :Q ::P becomes P 3. Distribute ^ over _: a ^ b _ c becomes a _ c ^ b _ c 4. Flatten nested conjunctions: a _ b _ c becomes a _ b _ c a ^ b ^ c becomes a ^ b ^ c Reminder: de Morgan's laws state that : : _ Q P Q = P P Q = P _ ^ : : ^ : _ : Q Q ICS 171, Summer 2000 27 AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. Limitations of Propositional Logic Propositional logic is extremely simple, hence it has limited expressive power and thus it is di cult to represent statements concerning objects and relations. Example: How do we use propositional logic to represent fAll people are mortalg To do so we would need to have a separate proposition for each person living on Earth claiming that she or he is mortal. f Mortal Pete, Mortal Jessica, Mortal John, and so ong This results in a huge number of propositions and thus causes problems with inference. We will look at a more expressive logic: predicate or rst-order logic. It allows us to reason about objects, their properties and their relations. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 28 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 Propositional logic su ces for some of these tasks Truth table method is sound and complete for propositional logic. Resolution for CNF is sound and complete for propositional logic. Modus Ponens is sound and complete for Horn knowledge bases. AIMA Slides c Stuart Russell and Peter Norvig, 1998. Modi ed for ICS 171, Summer 2000. ICS 171, Summer 2000 29 ...

View
Full Document