I'm implementing a DPLL algorithm in C++ as described in wikipedia:
function DPLL(Φ)
if Φ is a consistent set of literals
then return true;
if Φ contains an empty clause
then return false;
for every unit clause l in Φ
Φ ← unit-propagate(l, Φ);
for every literal l that occurs pure in Φ
Φ ← pure-literal-assign(l, Φ);
l ← choose-literal(Φ);
return DPLL(Φ ∧ l) or DPLL(Φ ∧ not(l));
but having an awful performance. In this step:
return DPLL(Φ ∧ l) or DPLL(Φ ∧ not(l));
currently I'm trying to avoid creating copies of Φ
but instead adding l
or not(l)
to the one and only copy of Φ
and remove them when/if DPLL()
's return false
. This seems to break the algorithm giving wrong results (UNSATISFIABLE
even though the set is SATISFIABLE
).
Any suggestions on how to avoid explicit copies in this step?