Abominable T&EImmediately after guessing, Trial-and-Error (T&E) is usually considered as
the abomination in Sudoku.
But my new T&E theorem obliges us to take a closer look at it.
I first posted this theorem here:
http://forum.enjoysudoku.com/viewtopic.php?t=5591&postdays=0&postorder=asc&start=150, because I found it while I was studying nrczt-chains and their nrczt-braid generalisation, but, as I now have much more to say about it and in order to avoid a confusion between chains and braids, I think it should become an independent topic.
To keep this thread as self contained as possible, let me recall the main results and definitions.
The starting point for everything here is the above mentioned theorem, which definitely answers a very old open question:
T&E theorem: ANY ELIMINATION DONE BY T&E CAN BE DONE BY AN NRCZT-BRAID.
The full proof is given in the above thread.
Moreover, the proof shows how the braid able to do the same elimination can be obtained constructively from the trace of the T&E procedure.
Corollary: ANY PUZZLE SOLVABLE BY T&E IS SOLVABLE BY NRCZT-BRAIDS.
As nrczt-braids are perfectly respectable patterns, this theorem means that the usual opposition between T&E and pattern-based solutions is very tenuous - but it keeps some reality, as we shall see later.
Let me recall the general definition of T&E (parameterised by a resolution theory T, i.e. by a fixed set of resolution rules):
Definition: Given a resolution theory T (i.e. a set of resolution rules) and a candidate z, T&E(T, z) is the following resolution technique:
- start an auxiliary grid by copying the current PM; in this auxiliary grid, delete z as a candidate and add it as a decided value; apply to this auxiliary PM all the rules in T until quiescence;
- if a contradiction is thus obtained in this auxiliary PM, then eliminate z from the original one; if no contradiction is obtained, then merely go back to the original PM.I think this is what everyone means by "using T&E(T) to eliminate candidate z".
Notice that no "guessing" is allowed: if a solution is found in the auxiliary PM, it is merely forgotten.
If T = ECP + NS + HS (Elementary Constraint Propagation rules + rules for Singles), then we put
T&E = T&E(ECP+NS+HS).
Definition: Given a resolution theory T, T&E(T) is the following resolution technique (this is only conceptual, any implementation should optimise this):
a) define phase = 1;
b) apply all the rules in T;
c) set changed-PM = false; mark all the remaining candidates as "not tried";
d) if there is at least one "not-tried" candidate, then choose any of them, say z; apply T&E(T, z); if it eliminates z, then set changed-PM = true and apply all the rules in T, otherwise un-mark z; in both cases, goto d;
e) if there is no not-tried candidate:
----------- if changed-PM = true, then set phase = phase +1 and goto c);
----------- if changed-PM = false, then stop.
Said otherwise, repeat T&E(T, z) for all the candidates z, as long as any one remains, until quiescence.Notice that this procedure allows considering the same candidate z several times.
This is reasonable, because any elimination of another candidate z' by T&E(T, z') may entail a new possibility of a contradiction appearing in a new application of T&E(T, z).
This is also necessary if one wants the result of this procedure to be independent of the order in which the candidates are tried.
To be complete, let me recall also the general definition of an nrczt-braid:
Definition: an nrczt-braid of length n for a target z is a sequence of candidates L1, R1, L2, R2, .... Ln-1, Rn-1, Ln, alternatively called left-linking and right-linking, such that:
- for any 1<= k <= n, Lk is nrc-linked to the target or to a previous right-linking candidate (some Ri, for i < k);
- for any 1 <= k < n, Lk and Rk are in some well defined rc, rn, cn or bn cell (which entails they are nrc-linked) such that each of the other candidates in this cell is nrc-linked to the target or to a previous right-linking candidate; Rk itself is not nrc-linked to any of these;
- in at least one of the four rc, rn, cn or bn cells containing Ln, each of the other candidates is nrc-linked to the target or to a previous right-linking candidate.
and the associated:
nrczt-braid elimination theorem: given an nrczt-braid, its target can be eliminated.Proof: exactly the same as for nrczt-whips, following the total ordering of the candidates, until the last left-linking candidate, with no compatible right-linking one, is reached. The proof shows progressively that, if the target was true, then all the left-linking candidates would be false and all the right-linking candidates would be true.
The purpose of this thread is to explore some consequences of the above T&E theorem and of some of its extensions (part of which are already mentioned in the above thread).