4 ms·
Line 16 was necessary because if unitpropagate clears out the formula then chooseLiteral will return Nothing which causes it to say a solvable formula was unsol
by gatlin 15y ago
Line 16 was necessary because if unitpropagate clears out the formula then chooseLiteral will return Nothing which causes it to say a solvable formula was unsolvable. I'd love more Haskell pointers to help though!
- nandemo 15y ago-- if formula is a null list, this clause will match: dpll (SolverState [] r) = return r -- otherwise this one will match: dpll (SolverState f r) = -- so it is never the case that null f is true here: if null f then return r And the second clause is basically the same as "dpll s =".
- gatlin 15y agoEmpirically I know this not to be the case. Take out the if statement and then run this: > solve [[1],[2]] You'll get "Nothing" when in fact the answer is [2,1]. The reason is that unitpropagate could potentially empty the list before chooseLiteral gets at it. However, I run unitpropagate first because it cuts down the search space dramatically.
- tomn 15y agoYeah, sorry about that... I totally missed the ' in "f = formula s'" and "f = record s'"! In that case, I would probably turn the whole thing into a case on "unitpropagate s", and get rid of the outer where, but my advice is clearly best taken with a pinch of salt.