I have a boolean formula: (x_{1} or x_{2}) and (x_{3} or x_{4}) and ..... and (x_{2r-1} or x_{2r}), where x_{i} belongs to the set: {p_{1}, p_{2}, ... p_{99} , ~p_{1}, ~p_{2}, ... ~p_{99} } and I have to determine if for some values of x_{i} given formula can be true.

I know that it is in general computationally difficult. But is there any quite fast way I can do this particular problem? So far I've tried backtracking - that is in recursion I substitude every possible value (0 or 1 so not many) for every possible variable and every variable, which hasn't got value yet, is trivially true. Before I go deeper into recursion I chceck the formula (even when not every variable has got a value) and if it is false, I don't go deeper. But it is too slow. Any ideas? I would be very grateful for help.

有帮助吗?

解决方案

If you only have two variables per OR clause, then you have 2-SAT, which has a linear-time solution.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top