propositional and first order logic
play

Propositional and First-Order Logic Last time: Chapter 7.47.8, - PDF document

11/21/18 Todays Class Propositional and First-Order Logic Last time: Chapter 7.47.8, 8.18.3, 8.5 Moral: never say things like the schedule wont change again out loud Bayesian learning to be rescheduled This


  1. 11/21/18 Today’s Class Propositional and First-Order Logic • Last time: Chapter 7.4–7.8, 8.1–8.3, 8.5 • Moral: never say things like “the schedule won’t change again” out loud • Bayesian learning to be rescheduled • This time: • A few notes on HW4 • Propositional logic and formal representations Material from Dr. Marie desJardin, and Dr. Tim Oates, Some material adopted from notes by Andreas Geyer- Schulz and Chuck Dyer A Few Notes on HW4 Designing a Heuristic • Agent does not know coordinates of goal! • Easiest way: play! • Searching for goal, not just for a path to a known spot • Beam search = greedy search with limited frontier • Greedy search explores “best thing on frontier” next • “Best” given by a heuristic: heuristic(state) à “goodness” • Designing a good heuristic is key • For this problem, it will not be a simple heuristic • What factors play into this decision? Distance, terrain, ..? Designing a Heuristic Designing a Heuristic • Easiest way: play! • Easiest way: play! • Which way? • Choice: south • Why? • Why: heading towards largest contiguous unexplored area All images from Dream Quest by Peter Whalen All images from Dream Quest by Peter Whalen 1

  2. 11/21/18 Designing a Heuristic Designing a Heuristic • Easiest way: play! • Easiest way: play! • South again • Starting to regret • What are we leaving that one taking into unexplored corner account? block • Should have built that into heuristic All images from Dream Quest by Peter Whalen All images from Dream Quest by Peter Whalen Last Tuesday: KB Agents Logic Roadmap • Propositional logic • Knowledge-based agents • Problems with propositional logic • Agents have knowledge about the world, own state, etc. • First-order logic • Knowledge is stored in a Knowledge Base (KB) • Properties, relations, functions, quantifiers, … • Formally represented statements • Terms, sentences, wffs, axioms, theories, proofs, … • If it’s something the agent knows, it’s in the KB • Extensions to first-order logic • Add: New discoveries, new sensor data, new conclusions • Logical agents • Delete: Old (discovered to be outdated) facts • Reflex agents • Representing change: situation calculus, frame problem • Agents can reason over knowledge in the KB • Preferences on actions • Goal-based agents • But how is it represented and reasoned over? Big Ideas in Logic Propositional Logic • Logic is a great knowledge representation language for many AI problems • Propositional logic: simple foundation, fine for many AI problems Chapter 7.4-7.8 • First order logic (FOL): much more expressive KR language, more commonly used in AI • Many variations on classical logics are used: Horn logic, higher order logic, three-valued logic, probabilistic logics, etc. 12 Material from Dr. Tim Oates 2

  3. 11/21/18 Propositional Logic Syntax Propositional Logic (PL) • Logical constants : true, false • A simple language useful for showing key ideas and definitions • Propositional symbols : P, Q, S, ... ( atomic sentences ) • Parentheses : ( … ) • User defines a set of propositional symbols • E.g., P and Q • Sentences are built with connectives : ∧ ...and [conjunction] • User defines the semantics (meaning) of each ∨ ...or [disjunction] ⇒ ...implies [implication / conditional] propositional symbol: ⇔ ..is equivalent [biconditional] • P=“ It’s hot” ¬ ...not [negation] • Q= “It’s humid” • Literal : atomic sentence or negated atomic sentence 14 15 PL Sentences Examples of PL Sentences • (P ∧ Q) → R • A sentence (or well formed formula ) is: “If it is hot and humid, then it is raining” • Any symbol is a sentence • Q → P • If S is a sentence, then ¬ S is a sentence “If it is humid, then it is hot” • If S is a sentence, then (S) is a sentence • Q • If S and T are sentences, then so are (S ∨ T), (S ∧ “It is humid.” T), (S → T), and (S ↔ T) • We’re free to choose better symbols, e.g.: Ho = “It is hot” • A sentence is created by any (finite) number of Hu = “It is humid” applications of these rules R = “It is raining” 17 Some Terms Model for a KB • Let the KB be [P ∧ Q → R, Q → P] • The meaning, or semantics , of a sentence determines PQR {T|F} its interpretation • What are the possible models? ✓ FFF • Given the truth values of all symbols in a sentence, it FFT ✓ • Consider all possible assignments can be evaluated to determine its truth value ( True or of {T|F} to P, Q and R and check ✘ FTF truth tables False ) FTT ✘ ✓ TFF • A model for a KB is a possible world— an P: it's hot ✓ TFT assignment of truth values to propositional symbols Q: it's humid ✘ TTF that makes each sentence in KB True R: it's raining ✓ TTT • E.g.: it is both hot and humid. 18 3

  4. 11/21/18 Model for a KB More Terms • Let the KB be [P ∧ Q → R, Q → P, Q] • Valid sentence or tautology : True under all PQR {T|F} interpretations, no matter the semantics or what the • What are the possible models? ✘ FFF world is actually like. FFT ✘ • Consider all possible assignments • “It’s raining or it’s not raining.” of {T|F} to P, Q and R and check ✘ FTF • Inconsistent sentence or contradiction : False under all truth tables FTT ✘ interpretations. The world is never like what it describes. ✘ TFF P: it's hot • R is true in every • “It’s raining and it’s not raining.” ✘ TFT model of the KB Q: it's humid • P entails Q (P ⊨ Q): whenever P is True, so is Q. • This KB entails that ✘ TTF R: it's raining R is True In other words, all models of P are also models of Q. ✓ TTT 21 Truth Tables On “implies”: P → Q • Truth tables are used to define logical connectives • And to determine when a complex sentence is true • → is a logical connective given the values of the symbols in it • So P → Q is a logical sentence and has a truth Truth tables for the five logical connec4ves value, i.e., is either true or false • If we add this sentence to a KB, it can be used by an inference rule, Modes Ponens , to derive/ infer/prove Q if P is also in the KB Example of a truth table used for a complex sentence • Given a KB where P=True and Q=True, we can also derive/infer/prove that P → Q is True P → Q P → Q • When is P → Q true? Check all that apply • When is P → Q true? Check all that apply ✔ q P=Q=true q P=Q=true ✔ q P=Q=false q P=Q=false q P=true, Q=false q P=true, Q=false ✔ q P=false, Q=true q P=false, Q=true • We can get this from the truth table for → • In FOL, it’s hard to prove a conditional true • Consider proving prime(x) → odd(x) 4

  5. 11/21/18 Inference Rules Sound Rules of Inference • Logical inference creates new sentences that • Here are some examples of sound rules of inference logically follow from a set of sentences (the KB) • A rule is sound if its conclusion is true when the premise is true • An inference rule is sound if every sentence • Each can be shown to be sound using a truth table produced when operating on a KB logically follows from the KB RULE PREMISE CONCLUSION • I.e., inference rule does not create contradictions Modus Ponens A, A → B B And Introduction A, B A ∧ B • An inference rule is complete if it can produce every And Elimination A ∧ B A expression that logically follows from (is entailed by) Double Negation ¬¬ A A the KB Unit Resolution A ∨ B, ¬ B A • Note the analogy to complete search algorithms Resolution A ∨ B, ¬ B ∨ C A ∨ C 27 29 Resolution Resolution • Resolution is an rule producing a new clause • A KB is a set of sentences all of which are true, implied by two clauses containing complementary i.e., a conjunction of sentences literals • Literal: atomic symbol or its negation, i.e., P, ~P • To use resolution, put KB into conjunctive normal • Amazingly, this is the only interference rule needed form (CNF) where each is a disjunction of to build a sound & complete theorem prover literals (positive or negative atoms) • Based on proof by contradiction and usually called resolution refutation • Every KB can be put into CNF • Rewrite sentences using standard tautologies The resolution rule was discovered by Alan Robinson (CS, U. of Syracuse) in the mid 1960s • P → Q ≡ ¬ P ∨ Q Resolution Example Proving Things Tautologies (A → B) ↔ ( ¬ A ∨ B) • Proof: a sequence of sentences, where each is a premise • KB: [P → Q , Q → R ∧ S] (i.e., a given) or is derived from earlier sentences in the (A ∨ (B ∧ C)) ↔ (A ∨ B) ∧ (A ∨ C) • KB: [P → Q , Q → R, Q → S ] proof by an inference rule • KB in CNF: [ ¬ P ∨ Q , ¬ Q ∨ R , ¬ Q ∨ S] • Last sentence is the theorem (aka goal or query) that we want to prove • Resolve KB[0] and KB[1] producing: ¬ P ∨ R (i.e., P → R) 1 Hu premise It’s humid 2 Hu → Ho premise If it’s humid, it’s hot • Resolve KB[0] and KB[2] producing: 3 Ho modus ponens (1,2) It’s hot ¬ P ∨ S (i.e., P → S) 4 (Ho ∧ Hu) → R premise If it’s hot and humid, it’s raining • New KB: [ ¬ P ∨ Q , ¬ Q ∨ R, ¬ Q ∨ S, ¬ P ∨ R, ¬ P ∨ S] 5 Ho ∧ Hu and introduction It is hot and humid 6 R modus ponens (4,5) It is raining 5

Recommend


More recommend