Assume that the number of variables N and the number of clauses K are equal. Find an algorithm that returns the number of different ways to satisfy the clauses.
I read that SAT is related to Independent Sets.
Assume that the number of variables N and the number of clauses K are equal. Find an algorithm that returns the number of different ways to satisfy the clauses.
I read that SAT is related to Independent Sets.
A function with N
variables has a truth-table with 2^N
rows. Each row corresponds to one minterm which can be either a solution or not.
A clause with N
variables excludes exactly one of the minterm as part of the solutions. That is the minterm which consists of all inverted variables of the clause.
Provided, the K
clauses are all different,
the number of solutions is 2^N - K
Example:
The K=3
clauses with N=3
variables:
A or B or C
!A or B or C
A or B or !C
The truth-table for three inputs:
A B C output
0 0 0 0 // excluded by A or B or C
0 0 1 0 // excluded by A or B or !C
0 1 0 1
0 1 1 1
1 0 0 0 // excluded by !A or B or C
1 0 1 1
1 1 0 1
1 1 1 1
Five of the possible eight terms remain true. Thus, the example has 2^3 - 3 = 5 solutions.