Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Problem Solving Representational Methods Formal Methods • Propositional Logic • Predicate Logic CS 331 Dr M M Awais 1 Problem Solving Propositional Logic • • • • • Represent FACTS only Is declarative in nature Can infer the truth value of fact only Context free Compositional: Can combine facts CS 331 Dr M M Awais 2 Problem Solving Propositional Logic • Symbols P,Q,R,S …….. • Truth Symbols True (T), False (F) • Connectives ^ (and), v (or), (Implication), (Equality, equivalence) (not) Statements (Propositions) could be true/false FACTS are also called Atomic Proposition CS 331 Dr M M Awais 3 Problem Solving Are same Truth Table P P Q Q PvQ P T T F F T T T F F T F F F T T F T T F F T T T T CS 331 Dr M M Awais Q 4 Problem Solving Possible Sentences (Well Formed Formulas-WFF) • P^Q • PvQ • P Q Conjuncts Disjuncts P=Premise/Antecedent Q=conclusion/Consequent • P • (P v Q) = ( P Q) Inter conversion CS 331 Dr M M Awais 5 Problem Solving Propositional logic: Syntax • Propositional logic is the simplest logic – illustrates basic ideas • The proposition symbols P1, P2 etc are sentences – – – – – If S is a sentence, S is a sentence (negation) If S1 and S2 are sentences, S1 S2 is a sentence (conjunction) If S1 and S2 are sentences, S1 S2 is a sentence (disjunction) If S1 and S2 are sentences, S1 S2 is a sentence (implication) If S1 and S2 are sentences, S1 S2 is a sentence (biconditional) CS 331 Dr M M Awais 6 Problem Solving Propositional logic: Semantics Each model specifies true/false for each proposition symbol E.g. P1,2 false P2,2 true P3,1 false With these symbols, 8 possible models, can be enumerated automatically. Rules for evaluating truth with respect to a model m: S S1 S2 S1 S2 S1 S2 i.e., S1 S2 is true iff S is false is true iff S1 is true and S2 is true is true iff S1is true or S2 is true is true iff S1 is false or S2 is true is false iffS1 is true and S2 is false is true iff S1S2 is true and S2S1 is true CS 331 Dr M M Awais Simple recursive process evaluates an arbitrary sentence, e.g., 7 Problem Solving Laws of Propositional Expressions • Demorgan’s Law (P v Q)=( P ^ Q) • Distributive Law P v (Q ^ R) = (P v Q) ^ (P v R) • Commutative Law P ^ Q= Q ^ P • Associative Law (P ^ Q) ^ R=P ^ (Q ^ R) • Contrapositive Law P Q= Q P CS 331 Dr M M Awais 8 Problem Solving Inferencing • If simple facts are known to be true one can find the truth value for the expressions • Thus INTERPRETATIONS can be done. • Interpretation is the assignment of truth values to the sentences Symbols T/F Mapping CS 331 Dr M M Awais 9 Problem Solving Expressions for KR • • • • • • • Fact 1: Ali likes cars P Fact 2: Ali drives cars Q P v Q : Ali likes cars or drives cars P ^ Q : Ali likes cars and drives cars Q : Ali does not like cars P Q: If Ali likes cars then he drives cars P Q: ????? – Above and vice versa CS 331 Dr M M Awais 10 Problem Solving Implicative Statements • P Q: If Ali likes cars then he drives cars • If P is FALSE and Q is TRUE, it means: • ALI DOESNOT LIKE CARS BUT STILL HE DRIVES THEM • Truth Table: P Q T T F F T F F T P T T F T Q (of our interest) (bizarre) CS 331 Dr M M Awais 11 Problem Solving Model • Model:If a sentence “S” is satisfied under a given interpretation “I” for all possible variables bindings (values) then I is a model of S • Satisfy: If S maps to T (true) under an interpretation I then I satisfy S (interpretation that makes the sentence true) CS 331 Dr M M Awais 12 Problem Solving Definitions • Logically Follows: X logically follows from a set of predicate calculus expressions S if every interpretation that satisfy S also satisfy X (X F S) • Satisfiable: S is satisfiable iff there exists an interpretation and variable assignments that satisfy it CS 331 Dr M M Awais 13 Problem Solving SFX S: All birds fly S: Sparrow is bird X: Sparrow flies All humans are mortal Shahid is a human Shahid is mortal All students at LUMS are hardworking Farooq is a student at LUMS Farooq is a hard working student CS 331 Dr M M Awais 14 Problem Solving Definitions • Inconsistent: If a set of expressions are not satisfiable • Valid: If any expression has a value T for all possible interpertations • Sound: If an expression logically follows from another expression then the inferential rule is sound • Complete: When inferential rule produces every expression that logically follows a particular expression CS 331 Dr M M Awais 15 Problem Solving Logic in general • Logics are 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 CS 331 Dr M M Awais 16 Problem Solving Validity and satisfiability VALID A sentence is valid if it is true in all models, e.g., True, A A, A A, (A (A B)) B SATISFIABLE A sentence is satisfiable if it is true in some model e.g., A B UNSATISFIABLE A sentence is unsatisfiable if it is true in no models e.g., A A CS 331 Dr M M Awais 17 Problem Solving Example: Wumpus World • Performance measure – gold +1000, death -1000 – -1 per step, -10 for using the arrow • Environment • – – – – – – – – – – Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Glitter iff gold is in the same square Shooting kills wumpus if you are facing it Shooting uses up the only arrow CS 331 Dr M M Awais 18 Problem Solving Wumpus world characterization • • • • • • • • • Fully Observable Deterministic Episodic Static Discrete CS 331 Dr M M Awais 19 Problem Solving Wumpus world characterization • • • • • • • • • Fully Observable No – only local perception Deterministic Yes – outcomes exactly specified Episodic No – sequential at the level of actions Static Yes – Wumpus and Pits do not move Discrete Yes CS 331 Dr M M Awais 20 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 21 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 22 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 23 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 24 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 25 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 26 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 27 Problem Solving Exploring a wumpus world CS 331 Dr M M Awais 28 Problem Solving Finding wumpus world 4 If Wumpus is in [1,3], 3 W 2 How can we prove it using Propositional logic 1 1 CS 331 Dr M M Awais 2 3 4 29 Problem Solving Finding wumpus world 4 Knowledge base Contains: ~S1,1 ~B1,1 ~S2,1 B2,1 S1,2 B1,2 3 W 2 1 1 CS 331 Dr M M Awais 2 3 4 30 Problem Solving Finding wumpus world 4 Rules: R1: ~ S1,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 R2: R3: 3 W 2 s ~ S2,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 1 S1,2 W1,3 V W1,2 V W2,2 V ~W1,1 1 2 3 4 Assumption: The square with wumpus is also smelly CS 331 Dr M M Awais 31 Problem Solving Inference rules in PL , • Modus Ponens • And-elimination: from a conjuction any conjunction can be inferred: • Resolution: Unit resolution when l3 is empty CS 331 Dr M M Awais 32 Problem Solving 4 Proof of W presence Knowledge base Contains: ~ S1,1 ~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S1,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 R2: ~ S2,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 R3: S1,2 W1,3 V W1,2 V W2,2 V ~W1,1 Modus Ponen on W 2 1 1 2 3 4 Results: ~W1,1 ~W1,2 ~W2,1 R1: ~ S1,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 And Elimination: ~W1,1 ~W1,2 ~W2,1 3 CS 331 Dr M M Awais 33 Problem Solving 4 Proof of W presence Knowledge base Contains: ~ S1,1 ~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S1,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 R2: ~ S2,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 R3: S1,2 W1,3 V W1,2 V W2,2 V ~W1,1 Modus Ponen on R2: ~ S2,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 And Elimination: ~W1,1 ~W2,1 ~W2,2 ~W3,1 CS 331 Dr M M Awais 3 W 2 1 1 2 3 4 Results: ~W1,1 ~W1,2 ~W2,1 ~W1,1 ~W2,1 ~W2,2 ~W3,1 34 Problem Solving Proof of W presence Knowledge base Contains: ~ S1,1 ~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S1,1 ~W1,1 ^ ~W1,2 ^ ~W2,1 R2: ~ S2,1 ~W1,1 ^ ~W2,1 ^ ~W2,2 ^ ~W3,1 R3: S1,2 W1,3 V W1,2 V W2,2 V W1,1 Modus Ponen on R3: S1,2 W1,3 V W1,2 V W2,2 V W1,1 W1,3 V W1,2 V W2,2 V W1,1 Unit Resolution: Alpha:W1,3 V W1,2 V W2,2 and Beta: W1,1 W1,3 V W1,2 V W2,2 Unit Resolution again with : W1,2 and W2,2 CS 331 Dr M M Awais W1,3 4 3 W 2 1 1 2 3 ~W1,1 ~W2,1 ~W2,2 ~W3,1 W1,3 4 Results: ~W1,1 ~W1,2 ~W2,1 Simply drop all facts that can create conflict 35 Problem Solving Pros and cons of propositional logic Propositional logic is declarative Propositional logic allows partial/disjunctive/negated information – (unlike most data structures and databases) Propositional logic is compositional: – meaning of (B P ) is derived from meaning of B and of P Meaning in propositional logic is context-independent – (unlike natural language, where meaning depends on context) Propositional logic has very limited expressive power – (unlike natural language) – E.g., cannot say “Music cause disturbance to all neighbors“ • except by writing one sentence for each neighbor • CS 331 Dr M M Awais 36