Let’s walk a bit through Sudoku solution by DNF expansion in this way. 9 by 9 is quite large; let’s consider a simpler 4 by 4.
The puzzle we’ll solve is this one:
? ? | 2 ?
2 ? | ? 1
----+----
3 ? | ? 4
? 4 | ? ?
We begin by encoding thing as a Boolean formula. We’ll use 4 * 4 * 2 variables: each row and each column has a value, which (in our convenient 4-ary rather than 9-ary case) we can directly encode with two bits: 01 for 1, 10 for 2, 11 for 3, and 00 for 4. So our 32 variables will be Row[sub]j[/sub]Col[sub]k[/sub]Bit[sub]b[/sub] where j and k range from 1 through 4, and b ranges from 1 (for the lower order bit) through 2 (for the higher order bit). [This is slightly different from the X[sub]i, j, k[/sub] variables you propose in post 76, but only in that we use a more efficient 2 bit encoding of our 4 possible values, instead the 4 bit encoding 1: 1000, 2: 0100, 3: 0010, 4: 0001]
I will write & for AND, v for OR, and ~ for NOT.
For convenience, I will write such things as “Row[sub]j[/sub]Col[sub]k[/sub] = 1” as shorthand for “Row[sub]j[/sub]Col[sub]k[/sub]Bit[sub]1[/sub] = 1 & ~ Row[sub]j[/sub]Col[sub]k[/sub]Bit[sub]2[/sub]” (i.e., we’ve encoded the value 1, with 1 as its lower-order bit and 0 as its higher-order bit, in the two bits for grid point (j, k)), etc.
What is the formula that encodes whether we have a valid Sudoku board? Well, it’s the conjunction of the following (4 + 4 + 4) * 4 = 48 constraints:
[ul]
[li]Row[sub]1[/sub]Col[sub]1[/sub] = 1 v Row[sub]1[/sub]Col[sub]2[/sub] = 1 v Row[sub]1[/sub]Col[sub]3[/sub] = 1 v Row[sub]1[/sub]Col[sub]4[/sub] = 1 (“The first row contains a 1”)[/li][li]Row[sub]1[/sub]Col[sub]1[/sub] = 2 v Row[sub]1[/sub]Col[sub]2[/sub] = 2 v Row[sub]1[/sub]Col[sub]3[/sub] = 2 v Row[sub]1[/sub]Col[sub]4[/sub] = 2 (“The first row contains a 2”)[/li][li]Row[sub]1[/sub]Col[sub]1[/sub] = 3 v Row[sub]1[/sub]Col[sub]2[/sub] = 3 v Row[sub]1[/sub]Col[sub]3[/sub] = 3 v Row[sub]1[/sub]Col[sub]4[/sub] = 3 (“The first row contains a 3”)[/li][li]Row[sub]1[/sub]Col[sub]1[/sub] = 4 v Row[sub]1[/sub]Col[sub]2[/sub] = 4 v Row[sub]1[/sub]Col[sub]3[/sub] = 4 v Row[sub]1[/sub]Col[sub]4[/sub] = 4 (“The first row contains a 4”)[/li][li]Etc. through all the ways to say “This row/column/block contains this value”[/li][/ul]
What happens when we multiply all these constraints together and expand out into DNF form?
We get, surely you will agree with me ftg, the disjunction (i.e., ORing together) of 288 terms, one term for each valid 4 by 4 Sudoku board. One of these terms, for instance is “Row[sub]1[/sub]Col[sub]1[/sub] = 3 & Row[sub]1[/sub]Col[sub]2[/sub] = 1 & Row[sub]1[/sub]Col[sub]3[/sub] = 2 & Row[sub]1[/sub]Col[sub]4[/sub] = 4 & Row[sub]2[/sub]Col[sub]1[/sub] = 2 & Row[sub]2[/sub]Col[sub]2[/sub] = 3 & Row[sub]2[/sub]Col[sub]3[/sub] = 4 & Row[sub]2[/sub]Col[sub]4[/sub] = 1 &
Row[sub]3[/sub]Col[sub]1[/sub] = 4 & Row[sub]3[/sub]Col[sub]2[/sub] = 2 &
Row[sub]3[/sub]Col[sub]3[/sub] = 1 & Row[sub]3[/sub]Col[sub]4[/sub] = 3 &
Row[sub]4[/sub]Col[sub]1[/sub] = 1 & Row[sub]4[/sub]Col[sub]2[/sub] = 3 & Row[sub]4[/sub]Col[sub]3[/sub] = 4 & Row[sub]4[/sub]Col[sub]4[/sub] = 2”, corresponding to that particular 4 by 4 Sudoku board. There are 287 other such terms as well.
Is this not what we would get by multiplying out these constraints, ftg? Is it not indeed the case that we will get a formula with precisely one term for each and every possible Sudoku board?
And then, what next? Oh, we have some more constraints to multiply in, because we were supposed to solve this particular board:
? ? | 2 ?
2 ? | ? 1
----+----
3 ? | ? 4
? 4 | ? ?
So we multiply in the constraint “Row[sub]1[/sub]Col[sub]3[/sub] = 2”. Out of our 288 terms, some are incompatible with this, and multiply with this to yield Falsehood, and thus disappear. The others are compatible with this, already containing it as a factor, and thus remain unchanged after we multiply it in. So we now reduce to a 72 term disjunctive formula, precisely one term for each and every possible Sudoku board with a 2 at row 1, column 3. Yes? You will agree with me that this is what we get, ftg? Next we multiply in the constraint “Row[sub]2[/sub]Col[sub]1[/sub] = 2”, and walk through these 72 terms, getting rid of the ones who have a 2 at location (2, 1) and keeping the rest. Etc., etc.
Finally, in the end, we end up with a single term, corresponding to our solution.
But how do we get there? We first enumerate all 288 possible 4 by 4 Sudoku grids. Then we go through them, one by one, and get rid of all the ones without a 2 at (1, 3), then get rid of all the remaining ones without a 2 at (2, 1), then get rid of all the remaining ones without a 1 at (2, 4), then get rid of all the remaining ones without a 3 at (3, 1), etc., etc. We go through all 288 possible 4 by 4 Sudoku grids and see which, if any of them, are compatible with our puzzle, and in this way find all its solutions.
This is precisely what happens, right? We go through all 288 possible 4 by 4 Sudoku grids and see which, if any of them, are compatible with our puzzle, and in this way find all its solutions.
Ok. Going through all 288 possible 4 by 4 Sudoku grids and seeing which, if any of them, are compatible with our puzzle, and in this way finding all its solutions, is disciplined, mechanical, and logically rigorous. I won’t dispute that. As to whether it’s the sort of thing “trial and error” is meant to denote, well, I’ll leave that to the reader.