Logical feasibility - algorithm

I have a logical 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 this formula can be given for some x_ {i} values.

I know that this is generally difficult to calculate. But is there any pretty quick way to solve this particular problem? So far I have tried to backtrack - that is, in recursion, I substitute all possible values ​​(0 or 1 so small) for each possible variable, and each variable that does not yet have a value is trivially true. Before I delve into recursion, I correct the formula (even if not every variable has a value), and if it is false, I do not go deep. But it is too slow. Any ideas? I would be very grateful for the help.

+6
source share
1 answer

If you have only two variables in the OR clause, you have a 2-SAT that has a linear time solution.

+5
source

Source: https://habr.com/ru/post/919862/


All Articles