quiz 3 next time: search algorithms and results (see prior Lecture notes). np-completeness def: deterministic stochastic random closed system open system closed => deterministic SAT matrices 3 Lisp questions. given a set of logic sentences: they are: a "tautology" if true in all worlds a "contradiction" or absurdity, if true of no worlds satisfiable, if true of at least one world. (a "world" is a a binding of true false to the variables). SATISFIABILITY =========================================================================== Problem 1: ~(E implies F) and (F or (D implies ~E)). Is this satisfiable? In conjunctive normal form: (E) and (~F) and (F or ~D or ~E). (use relationship p implies q to reduce to. ~p or q, use De Morgans laws and others.) In boolean matrix (with *s) form: (rows are clauses, columns are variables) DEF --- *1* **0 001 Problem 2: ~((D&E) implies F) and (F or (D implies ~E)). Is this satisfiable? In conjunctive normal form: (D) and (E) and (~F) and F or ~D or ~E. DEF --- 1** *1* **0 001 Satisfiability question is whether or not we can find a row of 0 and 1 that matches every other row in one or more places. In problem 1, YES:010. In problem 2: NO. -------------------------------------------------------- Satisfibility in Lisp. assumes input is in form ( (0 0 * 1) (1 1 0 0) (* * 0 0) (* * 1 0)) etc. and goal is to construct a list of 0 and 1 that matches each input list in at least 1 place. (defun snoc (x l) (reverse (cons x (reverse l)))) (defun sat (l sofar) ;assumes l is not initially nil (cond ((null l) sofar) ((null (car l)) nil) (t (or (sat (bind 0 l) (snoc 0 sofar)) (sat (bind 1 l) (snoc 1 sofar)))))) (defun bind (x l) (remove 'hit (mapcar #'(lambda (y) (if (equal (car y) x) 'hit (cdr y))) l))) Above function is correct! But, alas, is exponential in worst case. Complete means: If a proof exists we can find it. KNOWLEDGE REPRESENTATION: Variable-Free Propositional Logic Decidable but NP-complete Complete: Resolution, Truth Tables Variable-Based Predicate Logic Semi-Decidable = first order logic = predicate calculus (also Godel-Incomplete may be things that are obviously true but not provable) Can't decide for an arbitrary statement whether it is true, false or undeterminable. (but if I tell you that it is "T or F" you can determine which and prove it.) Complexity is exponential or higher. we will be learning 3 proof methods: resolution (see text) sat matrices (as above) egs (the wild thing we did in class - will be discussed in future)