CS156
Chris Pollett
Oct 23, 2017
Consider the Horn program:
a. /* lines end with a period, a rule without a tail is called a fact */ b:- a. c:-b. d:- a, b.
?- ['~/Desktop/horn_example.pl'].
?- a. true. ?- d. true.
d:-d. c:-b. b:-c.followed by a query ?- d or a query ?- b would result in an infinite loop.
e :- not(a). f :- false.
Which of the following is true?
function DPLL-Satisfiable?(s) returns true or false inputs: s a sentence in propositional logic clauses := the set of clauses in the CNF representation of s symbols := a list of the propositional symbols in s return DPLL(clauses, symbols, {}) function DPLL(clauses, symbols, model) returns true or false if every clause in clauses is true in model then return true if some clause in clauses is false in model then return false P, value := FIND-PURE-SYMBOL(symbols, clauses, model) if P is non-null then return DPLL(clauses, symbols - P, model ∪ {P=value}) P, value := FIND-UNIT-CLAUSE(clauses, model) if P is non-null then return DPLL(clauses, symbols - P, model ∪ {P=value}) P := FIRST(symbols); //symbols is a list, this get the first element in the list into P rest = REST(symbols); //all the elements in the list excluding the first element return DPLL(clauses, rest, model ∪ {P=true}) or DPLL(clauses, rest, model ∪ {P=false})
Variables: x, y, z, ... -> range over sets. Example: x might be an element in a set of colors. Constants: a, b, c, ... Example: Fixed values from a set, 0, "Bob" Functions: f, g, h, ... Example: x + y is a function Predicates: `P`, `Q`, `R` ... These take inputs and output true/false. Example, x=7 is a predicate.