logic-intro[1]

# logic-intro[1] - Logic Intro CPS 170 Ron Parr...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Logic Intro CPS 170 Ron Parr Historical Perspec8ve I •  Logic was one of the classical founda8ons of AI •  Dream: A Knowledge ­Based agent –  Tell the agent facts –  Agent uses rules of inference to deduce consequences –  Example: prolog •  Dis8nc8on between data and program •  Embodied in ﬁeld of “Expert Systems” 1 Example: Minesweeper •  How do you play minesweeper? •  How would you program a machine to do it? –  Hacking –  Search –  Logic •  Logic approach –  Tell the system of rules of minesweeper –  System uses logic to make the best moves What is logic, really? •  Syntax: Rules for construc8ng valid sentences •  Seman8cs: Relate syntax to the real world 2 Entailment •  Aim: Rule for genera8ng (or tes8ng) new sentences that are necessarily true •  The truth of sentence may depend upon the interpreta,on of the sentence Interpreta8ons •  An interpreta8on is a way of matching up objects in the universe with symbols in a sentence (or database). •  A sentence may be true in one interpreta8on, but false in another •  A necessarily true sentence is true in all interpreta8ons (perhaps given some premises in our KB) 3 Examples •  Premises (facts in our database): –  (X or Y) –  Not X –  Conclude: Y is necessarily true •  Premises –  If P then Q –  Q –  Conclude: P is not necessarily true (though might be true in some interpreta8ons) Soundness & Completeness •  A (set of) rule(s) of inference is sound if it generates only sentences that are entailed by the knowledge base, i.e., only necessary truths •  A (set of) rule(s) of inference is complete if it can generate all necessary truths •  Can we have one w/o the other? 4 Historical Perspec8ve II •  Things that are not true necessarily but s8ll true are some8mes said to be “con8ngent,” “accidental,” or “synthe8c,” truths. •  A deep understanding of this dis8nc8on evolved through thousands of years of philosophy and mathema8cs •  Arguably one of the most important intellectual accomplishments of mankind –  Basis of mathema8c proofs –  Provides a rigorous procedure for verifying statements Proposi8onal Logic •  Proposi8onal logic is the simplest logic •  All sentences are composed of –  Atoms –  Nega8on –  Disjunc8on, conjunc8on (or, and) –  Condi8onal, bicondi8onals •  Atoms can map to any proposi,on about the universe (depending upon the interpreta8on) 5 Checking Validity •  Classic method for checking validity: truth table •  Enumerate all possible values (t/f) of atomic elements of a sentence (P ∨ H ) ¬H P Horizontal line separates premises from conclusion •  Enumerate all 4 (or more) combina8ons € Inference Rules •  Inference rules are (typically) sound methods of genera8ng new sentences given a set of previous sentences •  Inference rules save us the trouble of genera8ng truth tables all of the 8me 6 Inference Rules I •  Modus Ponens " # \$, " \$ •  And ­Elimina8on ! "" # "# # … # " " "# !! !! ! Inference Rules II •  And ­Introduc8on " " , " # ,…, " " !! !" " # " # # … # " " ! •  Or ­Introduc8on ! "" !! !" " # " # # … # " # ! ! 7 Inference Rules III •  Double Nega8on Elimina8on ¬¬" " •  Unit Resolu8on ! " # \$, ¬\$ " ! Resolu8on α ∨ β, ¬β ∨ γ α ∨γ Resolu8on is perhaps the most important inference rule! € Why? Resolu8on is both sound and complete! 8 Complexity of Inference •  What is the complexity of exhaustsively verifying the validity of a sentence with n literals (variables)? "" !! •  Special Case: Horn Logic –  Horn clauses are disjunc8ons with at most one posi8ve literal ! –  Equivalent to " " " " … " "# # \$ " # !! !! ! Remember De Morgan’s Law? •  not(P and Q) = (not P) or (not Q) •  not(P or Q) = (not P) and (not Q) •  Surprisingly, no rela8onship to Captain Morgan 9 Implica8ons and Horn Clauses •  If P then Q –  Same as: (not (P and (not Q)) –  Same as: (not P) or Q –  …and this is horn! •  If (P1 and P2 and … Pn) then Q –  –  –  –  Same as: (not ((P1 and P2 and … Pn) and (not Q)) Same as: not (P1 and P2 and … Pn) or Q Same as: ((not P1) or (not P2) or … (not Pn) or Q) …and this is horn! Horn Clause Inference •  Horn clause inference is polynomial – Why? –  Every sentence establishes exactly one new fact –  Can add every possible new fact implied by our KB in n passes over our database •  What types of things are easy to represent with horn clauses? –  Diagnos8c rules –  “Expert Systems” 10 Shortcomings of Horn Clauses •  Suppose you want to say, “If you have a runny nose and fever, then you have a cold or the ﬂu.” •  If (runny_nose and fever) then (cold or ﬂu) •  But this isn’t a horn clause: (not runny_nose) or (not fever) or (cold) or (ﬂu) •  Does adding two separate horn clauses work? –  (not runny_nose) or (not fever) or (cold) –  (not runny_nose) or (not fever) or (ﬂu) Proposi8onal Logic Conclusion •  Logic gives formal rules for reasoning •  Necessarily true = true in all interpreta8ons •  Contrast with CSPs: Sa8sﬁable = true in some, but not necessarily all interpreta8ons •  Sound inference rules generate only necessary truths •  Resolu8on is a sound and complete inference rule •  Inference with a horn KB is poly 8me 11 ...
View Full Document

Ask a homework question - tutors are online