240 likes | 371 Views
Reasoning Algorithms in Propositional Logic. Examination will be a take-home exam; confirmation coming as soon as signed course evaluation is received in registrar’s office. Knowledge representation and reasoning. Propositions, general knowledge, facts, KB, model -> big truth table.
E N D
Reasoning Algorithmsin Propositional Logic Examination will be a take-home exam; confirmation coming as soon as signed course evaluation is received in registrar’s office
Knowledge representationand reasoning • Propositions, general knowledge, facts, KB, model -> big truth table Propositions KB: general knowledge & facts model t t f t f t f f f t t t t t t t t t t t t t t t t t t t t t t t t t t t t • The reasoning problems: • Find t/f assignment(s) model(s) where KB is true • Answering questions “entailed” by KB D Goforth - COSC 4117, fall 2006
Approaches to reasoning N propositions to satisfy KB • Search through 2N rows of truth table: goal-based search, fitness is truth of KB (SAT) • Use inference: restrict attention to relevant propositions (assumes many models satisfy the KB and many propositions might be “don’t care”) D Goforth - COSC 4117, fall 2006
Approaches to Reasoning:strategies • Search • Depth-first exhaustive search from start state of ‘empty’ truth table • Hill-climbing from random start state of true-false assignments • Inference • Forward chaining from KB to query • Backward chaining from query into KB D Goforth - COSC 4117, fall 2006
Propositional satisfiability Problem (SAT) Definition (Hoos & Stutzle, 2005) “Given a propositional formula F, the problem is to decide whether or not F is satisfiable.” F = KB (facts + general knowledge) D Goforth - COSC 4117, fall 2006
KB = (P1P2) (P2P1) (P1 P2 P3) (P2P1) (P4P3) (P5P3) t - f t t f t f f t f t f t - f etc. t t t t f Propositional satisfiability Problem (SAT) State: a vector of truth values for the n propositions State space: 2n nodes Goal state(s): KB is true (a model) e.g., n = 5, {P1,P2,P3,P4,P5} 1 b) D Goforth - COSC 4117, fall 2006
Propositional satisfiability Problem (SAT) • TT-ENTAILS is depth-first search, exhaustive, incremental • Improvement in efficiency by pruning: DPLL – p.221 • early termination • pure symbol heuristic • unit clause heuristic • WALKSAT: complete state algorithm – reduce number of false clauses by flipping propositions true<->false D Goforth - COSC 4117, fall 2006
Propositional satisfiability Problem (SAT) Answers a question: Is a sentence a true in the KB? i.e., is the sentence true in all models of the KB which are true? OR is (KBa) true? Question: (P1P5) ? KB = (P1P2) (P2P1) (P1 P2 P3) (P2P1) (P4P3) (P5P3) 1 a) f t t t t f t etc. t t t D Goforth - COSC 4117, fall 2006
1 a) at root – no truth values assigned KB,α both true? KB false P both true and false
Question: (P1P5) ? KB = (P1P2) (P2P1) (P1 P2 P3) (P2P1) (P4P3) (P5P3) f t t t t f t etc. t t t TT-ENTAILS 1 a) Propositions KB Question KB Q (P1P5) P1 P2 P3 P4 P5 (P1P2)(P2P1)(P1P2P3)(P2P1)(P4P3)(P5P3) t t t t t t t t f t t t t t t t t t f t t f t t t t … … … … f f f f f f t t t f t t t TT-ENTAILS returns true if KB Q is true for all cases; i.e., there is no row with KB true and Q false
Variations on TT-ENTAILS • For efficiency: (see p.221) • Early termination (pruning) • Pure symbol heuristic • Unit clause heuristic D Goforth - COSC 4117, fall 2006
KB = (P1P2) (P2P1) (P1 P2 P3) (P2P1) (P4P3) (P5P3) t - f t t f t f f t f t f t - f etc. t t t t f Propositional satisfiability Problem (SAT) WALKSAT, p.223 (complete state search) Checks satisfiability i.e., are there models of the KB which are true? Question: KB satisfiable? 1 b) D Goforth - COSC 4117, fall 2006
Question: KB satisfiable? KB = (P1P2) (P2P1) (P1 P2 P3) (P2P1) (P4P3) (P5P3) t - f t t f t f f t f t f t - f etc. t t t t f 1 b) WALKSAT Satisfied? y random f t f t f true Give up? y false pick random false clause Probability p flip t/f of proposition in clause that minimizes number of false clauses flip t/f of random proposition in clause
WALKSAT performance • Not guaranteed to find solution (not exhaustive like TT-ENTAILS) • More effective in practice than TT-ENTAILS, even with efficiency heuristics (DPLL) 1 b) D Goforth - COSC 4117, fall 2006
Approaches to reasoning N propositions to satisfy KB • Search through 2N rows of truth table: goal-based search, fitness is truth of KB (SAT) • Use inference: restrict attention to relevant propositions (assumes many models satisfy the KB and many propositions might be “don’t care”) D Goforth - COSC 4117, fall 2006
Inference rule: Resolution • elimination of complementary literals from sentences in CNF • (~W \/ ~Q \/ T) Λ (W \/ P) (~Q \/ T \/ P) • inference by resolution is • Sound – only infers true statements • Complete – anything entailed is derivable Part of KB New proposition D Goforth - COSC 4117, fall 2006
Resolution: Example • (P11 \/ P22 \/ P13) • ~P11 • ~P22 • resolve (P11 \/ P22 \/ P13), ~P11 (P22 \/ P13) • resolve (P22 \/ P13), ~P22 P13 (from Wumpus world) Part of KB D Goforth - COSC 4117, fall 2006
Resolution algorithm • goal-directed proof by contradiction • to prove P • assume ~P • add ~P to KB • resolve in KB till resulting sentence is • in KB (therefore P is false) • empty (therefore ~P is contradictory so P is true) D Goforth - COSC 4117, fall 2006
αleads to contradition therefore αis true αis consistent with KB so αis false Figure 7.12 p.216
Horn clause inference method 2 a) • compromise representation that is human-readable • basic of logic programming (Prolog) • uses modus ponens, not resolution • like CNF but restricted to only one positive proposition (~W \/ ~Q \/ ~S \/ T) => ~(W Λ Q Λ S) \/ T => (W Λ Q Λ S) T D Goforth - COSC 4117, fall 2006
2 a) Forward chaining inference with Horn clauses • algorithm to determine if a particular proposition is true • O(n) in size of KB!! • p. 219, Fig 7.14 D Goforth - COSC 4117, fall 2006
Reasoning by FORWARD chaining • From the known data “forward” to unknown • Doesn’t need goal – self-directed agent Figure 7.14 p.219 2 a)
Reasoning by BACKWARD chaining 2 b) • Goal-directed reasoning – question answering agent Backward (KB, Q) //answer query Q • If Q true in KB, return true • For each Horn clause (P=>Q) in KB, • If Backward (KB, P), return true • Return false D Goforth - COSC 4117, fall 2006