Download presentation
Presentation is loading. Please wait.
1
1 Problem Solving CS 331 Dr M M Awais Representational Methods Formal Methods Propositional Logic Predicate Logic
2
2 Problem Solving CS 331 Dr M M Awais Propositional Logic Represent FACTS only Is declarative in nature Can infer the truth value of fact only Context free Compositional: Can combine facts
3
3 Problem Solving CS 331 Dr M M Awais Propositional Logic SymbolsP,Q,R,S …….. Truth SymbolsTrue (T), False (F) Connectives ^ (and), v (or), (Implication), (Equality, equivalence) (not) Statements (Propositions) could be true/false FACTS are also called Atomic Proposition
4
4 Problem Solving CS 331 Dr M M Awais Truth Table PQ P Q P v Q P Q TTFFTT TFFTFF FTTFTT FFTTTT Are same
5
5 Problem Solving CS 331 Dr M M Awais Possible Sentences (Well Formed Formulas-WFF) P ^ QConjuncts P v QDisjuncts P QP=Premise/Antecedent Q=conclusion/Consequent P (P v Q) = ( P Q)Inter conversion
6
6 Problem Solving CS 331 Dr M M Awais Propositional logic: Syntax Propositional logic is the simplest logic – illustrates basic ideas The proposition symbols P 1, P 2 etc are sentences –If S is a sentence, S is a sentence (negation) –If S 1 and S 2 are sentences, S 1 S 2 is a sentence (conjunction) –If S 1 and S 2 are sentences, S 1 S 2 is a sentence (disjunction) –If S 1 and S 2 are sentences, S 1 S 2 is a sentence (implication) –If S 1 and S 2 are sentences, S 1 S 2 is a sentence (biconditional)
7
7 Problem Solving CS 331 Dr M M Awais Propositional logic: Semantics Each model specifies true/false for each proposition symbol E.g. P 1,2 P 2,2 P 3,1 falsetruefalse With these symbols, 8 possible models, can be enumerated automatically. Rules for evaluating truth with respect to a model m: Sis true iff S is false S 1 S 2 is true iff S 1 is true and S 2 is true S 1 S 2 is true iff S 1 is true or S 2 is true S 1 S 2 is true iffS 1 is false orS 2 is true i.e., is false iffS 1 is true andS 2 is false S 1 S 2 is true iffS 1 S 2 is true and S 2 S 1 is true Simple recursive process evaluates an arbitrary sentence, e.g., P 1,2 (P 2,2 P 3,1 ) = true (true false) = true true = true
8
8 Problem Solving CS 331 Dr M M Awais 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
9
9 Problem Solving CS 331 Dr M M Awais 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 SymbolsT/F Mapping
10
10 Problem Solving CS 331 Dr M M Awais Expressions for KR Fact 1: Ali likes carsP Fact 2: Ali drives carsQ 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
11
11 Problem Solving CS 331 Dr M M Awais 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: PQP Q TTT FFT (of our interest) TFF FTT ( bizarre )
12
12 Problem Solving CS 331 Dr M M Awais 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)
13
13 Problem Solving CS 331 Dr M M Awais 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
14
14 Problem Solving CS 331 Dr M M Awais S F X 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
15
15 Problem Solving CS 331 Dr M M Awais 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
16
16 Problem Solving CS 331 Dr M M Awais 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
17
17 Problem Solving CS 331 Dr M M Awais 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
18
18 Problem Solving CS 331 Dr M M Awais 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 –Grabbing picks up gold if in same square –Releasing drops the gold in same square Sensors: Stench, Breeze, Glitter, Bump, Scream Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot
19
19 Problem Solving CS 331 Dr M M Awais Wumpus world characterization Fully Observable Deterministic Episodic Static Discrete Single-agent?
20
20 Problem Solving CS 331 Dr M M Awais 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 Single-agent? Yes – Wumpus is essentially a natural feature
21
21 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
22
22 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
23
23 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
24
24 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
25
25 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
26
26 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
27
27 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
28
28 Problem Solving CS 331 Dr M M Awais Exploring a wumpus world
29
29 Problem Solving CS 331 Dr M M Awais Finding wumpus world W 43214321 1 2 3 4 If Wumpus is in [1,3], How can we prove it using Propositional logic
30
30 Problem Solving CS 331 Dr M M Awais Finding wumpus world W 43214321 1 2 3 4 Knowledge base Contains: ~S1,1~B1,1 ~S2,1 B2,1 S1,2 B1,2
31
31 Problem Solving CS 331 Dr M M Awais Finding wumpus world W 43214321 1 2 3 4 Rules: R1: ~ S 1,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 R2: ~ S 2,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 R3: S 1,2 W 1,3 V W 1,2 V W 2,2 V ~W 1,1 Assumption: The square with wumpus is also smelly s
32
32 Problem Solving CS 331 Dr M M Awais Inference rules in PL Modus Ponens And-elimination: from a conjuction any conjunction can be inferred: Resolution: Unit resolution when l 3 is empty
33
33 Problem Solving CS 331 Dr M M Awais Proof of W presence W 43214321 1 2 3 4 Knowledge base Contains: ~ S1,1~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S 1,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 R2: ~ S 2,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 R3: S 1,2 W 1,3 V W 1,2 V W 2,2 V ~W 1,1 Modus Ponen on R1: ~ S 1,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 And Elimination: ~W 1,1 ~W 1,2 ~W 2,1 Results: ~W 1,1 ~W 1,2 ~W 2,1
34
34 Problem Solving CS 331 Dr M M Awais Proof of W presence W 43214321 1 2 3 4 Knowledge base Contains: ~ S1,1~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S 1,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 R2: ~ S 2,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 R3: S 1,2 W 1,3 V W 1,2 V W 2,2 V ~W 1,1 Modus Ponen on R2: ~ S 2,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 And Elimination: ~W 1,1 ~W 2,1 ~W 2,2 ~W 3,1 Results: ~W 1,1 ~W 1,2 ~W 2,1 ~W 1,1 ~W 2,1 ~W 2,2 ~W 3,1
35
35 Problem Solving CS 331 Dr M M Awais Proof of W presence W 43214321 1 2 3 4 Knowledge base Contains: ~ S1,1~B1,1 ~S2,1 B2,1 S1,2 B1,2 Rules: R1: ~ S 1,1 ~W 1,1 ^ ~W 1,2 ^ ~W 2,1 R2: ~ S 2,1 ~W 1,1 ^ ~W 2,1 ^ ~W 2,2 ^ ~W 3,1 R3: S 1,2 W 1,3 V W 1,2 V W 2,2 V W 1,1 Modus Ponen on R3: S 1,2 W 1,3 V W 1,2 V W 2,2 V W 1,1 W 1,3 V W 1,2 V W 2,2 V W 1,1 Unit Resolution: Alpha:W 1,3 V W 1,2 V W 2,2 and Beta: W 1,1 W 1,3 V W 1,2 V W 2,2 Unit Resolution again with : W 1,2 and W 2,2 W 1,3 Results: ~W 1,1 ~W 1,2 ~W 2,1 ~W1,1 ~W2,1 ~W2,2 ~W3,1 W 1,3 Simply drop all facts that can create conflict
36
36 Problem Solving CS 331 Dr M M Awais 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.