common lisp programming
$10 USD
Paid on delivery
to help solve for instances of 3-SAT.\r\n1. We consider a particular assignment of truth values to our given variables a state in a search graph. We will represent a state in Lisp as a list of pairs. Each pair is a list containing the variable name (a symbol in Lisp) and its corresponding truth value t (true) or nil (false). Write a function eval-var that returns the value associated with a particular variable:\r\n(defun eval-var (var state)\r\n...\r\n)\r\nFor example\r\n> (setf *state* \'((a nil) (b t) (c t) (d nil)))\r\n(A NIL) (B T) (C T) (D NIL))\r\n> (eval-var \'b *state*)\r\nT\r\n> (eval-var \'d *state*)\r\nNIL\r\n2. We will represent a single clause in Lisp as a list of 3 elements. Each element is either a single variable name (i.e., an atom) or a list containing the symbol not followed by a variable name. Write the function eval-clause that\r\nevaluates a clause (i.e., returns t or nil) for a given variables state:\r\n(defun eval-clause (clause state)\r\n...\r\n)\r\nFor example\r\n> *state*\r\n((A NIL) (B T) (C T) (D NIL))\r\n> (setf *clause* \'(a (not b) c))\r\n(A (NOT B) C)\r\n> (eval-clause *clause* *state*)\r\nT\r\n3. Write a function unsat-clauses that returns all the unsatisfied clauses in an expressions for a given state:\r\n(defun unsat-clauses (clauses state)\r\n...\r\n)\r\nFor example\r\n> *state*\r\n((A NIL) (B T) (C T) (D NIL))\r\n> *clauses*\r\n((A (NOT B) C) (A (NOT B) (NOT C)) (A (NOT B) D))\r\n> (unsat-clauses *clauses* *state*)\r\n((A (NOT B) (NOT C)) (A (NOT B) D))
Project ID: #9050251