Artificial Intelligence Propositional logic
Propositional Logic: Syntax Syntax of propositional logic defines allowable sentences Atomic sentences consists of a single proposition symbol Each symbol stands for proposition that can be or False Symbols of propositional logic Propositional symbols: P, Q, Logical constants:, False Making complex sentences Logical connectives of symbols:,,,, Also have parentheses to enclose each sentence: ( ) Sentences will be used for inference/problemsolving 2
Propositional Logic: Syntax, False, S 1, S 2, are sentences If S is a sentence, S is a sentence Not (negation) S 1 S 2 is a sentence, also (S 1 S 2 ) And (conjunction) S 1 S 2 is a sentence Or (disjunction) S 1 S 2 is a sentence Implies (conditional) S 1 S 2 is a sentence Equivalence (biconditional) 3
Propositional Logic: Semantics Semantics defines the rules for determining the truth of a sentence (wrt a particular model) Sis true iff S is false S 1 S 2 S 1 S 2 S 1 S 2 S 1 S 2 is true iff S 1 is true and S 2 is true is true iff S 1 is true or S 2 is true is true iff S 1 is false or S 2 is true (is false iff S 1 is true and S 2 is false) (if S 1 is true, then claiming that S 2 is true, otherwise make no claim) is true iff S 1 S 2 is true and S 2 S 1 is true (S 1 same as S 2 ) 4
Semantics in Truth Table Form P Q P P Q P Q P Q P Q False False False False False False False False False False False False False 5
Propositional Inference: Enumeration Method Truth tables can test for valid sentences under all possible interpretations in all possible worlds For a given sentence, make a truth table Columns as the combinations of propositions in the sentence Rows with all possible truth values for proposition symbols If sentence true in every row, then valid 6
Propositional Inference: Enumeration Method Test ((P H) H ) P P H P H H (P H) H False False False False False False False False False False ((P H) H ) P 7
Practice Test (P H) (P H) 8
Simple Wumpus Knowledge Base For simplicity, only deal with the pits Choose vocabulary Let P i,j be if there is a pit in [i,j] Let B i,j be if there is a breeze in [i,j] KB sentences FACT: There is no pit in [1,1] R 1 : P 1,1 RULE: There is breeze in adjacent neighbor of pit R 2 : B 1,1 (P 1,2 P 2,1 ) Need rule for R 3 : B 2,1 (P 1,1 P 2,2 P 3,1 ) each square! 9
Wumpus Environment Given knowledge base Include percepts as move through environment (online) Need to deduce what to do Derive chains of conclusions that lead to the desired goal Use inference rules α β Inference rule: α derives β Knowing α is true, then β must also be true 10
Inference Rules for Prop. Logic Modus Ponens From implication and premise of implication, can infer conclusion α β, α β 11
Inference Rules for Prop. Logic And-Elimination From conjunction, can infer any of the conjuncts 12
Inference Rules for Prop. Logic And-Introduction From list of sentences, can infer their conjunction 13
Inference Rules for Prop. Logic Or-Introduction From sentence, can infer its disjunction with anything else 14
Inference Rules for Prop. Logic Double-Negation Elimination From doubly negated sentence, can infer a positive sentence αα αα 15
Inference Rules for Prop. Logic Unit Resolution From disjunction, if one of the disjuncts is false, can infer the other is true α β, β α 16
Inference Rules for Prop. Logic Resolution Most difficult because β cannot be both true and false One of the other disjuncts must be true in one of the premises (implication is transitive) α β, β γ α γ Either: ββ OR ββ αα ββ, ββ ββ γγ, ββ OR αα γγ αα OR γγ 17 Valid!
Monotonicity A logic is monotonic if when add new sentences to KB, all sentences entailed by original KB are still entailed by the new larger KB 18
TASK: Find the Wumpus Can we infer that the Wumpus is in cell (1,3), given our percepts and environment rules? A = agent B = breeze 4 = safe square S = stench 3 W! V = visited W = wumpus 2 A S 1 B V V PIT 1 2 3 4 19
Wumpus Knowledge Base Percept sentences (facts) at this point S 1,1 B 1,1 S 2,1 B 2,1 S 1,2 B 1,2 2 A S 1 V V B 1 2 20
Environment Rules R 1 : S 1,1 W 1,1 W 1,2 W 2,1 3 W? 2 A S 1 1 2 3 21
Environment Rules R 2 : S 2,1 W 1,1 W 2,1 W 2,2 W 3,1 3 W? 2 A S 1 1 2 3 22
Environment Rules R 3 : S 1,2 W 1,1 W 1,2 W 2,2 W 1,3 3 W? 2 A S 1 1 2 3 23
Environment Rules R 4 : S 1,2 W 1,3 W 1,2 W 2,2 W 1,1 3 W? 2 A S 1 1 2 3 24
Conclude W 1,3? Does the Wumpus reside in square (1,3)? In other words, can we infer W 1,3 from our knowledge base? 25
Conclude W 1,3 (Step #1) Modus Ponens α β, α β R 1 : S 1,1 W 1,1 W 1,2 W 2,1 Percept: S 1,1 Infer W 1,1 W 1,2 W 2,1 26
Conclude W 1,3 (Step #2) And-Elimination α 1 α 2 α n α i W 1,1 W 1,2 W 2,1 Infer W 1,1 W 1,2 W 2,1 27
Conclude W 1,3 (Step #3) Modus Ponens α β, α β R 2 : S 2,1 W 1,1 W 2,1 W 2,2 W 3,1 Percept: S 2,1 Infer W 1,1 W 2,1 W 2,2 W 3,1 And-Elimination α 1 α 2 α n α i W 1,1 W 2,1 W 2,2 W 3,1 28
Conclude W 1,3 (Step #4) Modus Ponens α β, α β R 4 : S 1,2 W 1,3 W 1,2 W 2,2 W 1,1 Percept: S 1,2 Infer W 1,3 W 1,2 W 2,2 W 1,1 29
Conclude W 1,3 (Step #5) Unit Resolution α β, β α W 1,3 W 1,2 W 2,2 W 1,1 from Step #4 W 1,1 from Step #2 Infer W 1,3 W 1,2 W 2,2 30
Conclude W 1,3 (Step #6) Unit Resolution α β, β α W 1,3 W 1,2 W 2,2 from Step #5 W 2,2 from Step #3 Infer W 1,3 W 1,2 31
Conclude W 1,3 (Step #7) Unit Resolution α β, β α W 1,3 W 1,2 from Step #6 W 1,2 from Step #2 Infer W 1,3 The wumpus is in cell 1,3!!! 32
Wumpus in W 1,3 3 W! 2 A S 1 1 2 3 33
Summary Propositional logic commits to existence of facts about the world being represented Simple syntax and semantics Proof methods Truth table Inference rules Modus Ponens And-Elimination And/Or-Introduction Double-Negation Elimination Unit Resolution Resolution Propositional logic quickly becomes impractical 34