A benefit of logical encoding is that it allows much faster solving, such as by using logic solvers.

Examples

The map colouring problem can technically be brute-forced by a system of logical statements in propositional logic Take a very small area consisting of very few regions. For example, take an area consisting of only 3 regions (or a map of 3 states)
%%🖋 Edit in Excalidraw, and the dark exported image%% We know that we would need at most 3 colours to colour this area (since it has only 3 regions). Let’s pick Red, Green and Blue as our colours. Then, since region A must be coloured, we know that:

#tosee does it need to be xor or is the constraints enough to satisfy that we don’t get a region coloured with 2 colours at once? Similarly, we can apply this constrain to all our regions, by making sure our condition above applies to A and B and C

Then, we can start adding more constraints. We know that because and are connected, they must have different colours (by definition of the map colouring problem). Hence, we must NOT have A being red and B being red. Again, we can extend this logic to all the colours:

And to our other region-pair, B-C

Finally, combining all our logical statements, and converting them into their respective logical connectives, we get our encoding:

\land &[(\lnot\text{( is is )}) \land \lnot\text{( is is )}) \land \lnot\text{( is is )})]\ \land &[(\lnot\text{( is is )}) \land \lnot\text{( is is )}) \land \lnot\text{( is is )})]\

\end{align}

If we can satisfy this super long statement, we know our problem has a solution. In other words, if the logical encoding is satisfiable, then we know there exists a solution to the original problem. Some solutions:

  • A is red, B is blue, C is green
  • A is red , B is blue, C is red

#todo Sudoku encoding