Write, test, and document a program that determines the satisfiability of a set of propositional Horn clauses by forward chaining and that runs in linear time, relative to the size of the input. Use the following data structures: (a) a global variable STACK containing a list of atoms known to be true, but waiting to be propagated forward; (b) for each clause, an atom CONCLUSION, which is the positive literal appearing in the clause (or NIL if the clause contains only negative literals), and a number REMAINING, which is the number of atoms appearing negatively in the clause that are not yet known to be true; (c) for each atom, a flag VISITED indicating whether or not the atom has been propagated forward, and a list ON-CLAUSES of all the clauses where the atom appears negatively. You may assume the input is in suitable form. Include in the documentation an argument as to why your program runs in linear time. (If you choose to use LISP property lists for your data structures, you may assume that it takes constant time to go from an atom to any of its properties.)
#Sales Offer!| Get upto 25% Off: