Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

The Formal definition of Unified Colors Technique
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku
View previous topic :: View next topic  
Author Message
TheSpaniard

Joined: 28 Aug 2006
Posts: 20
:
Location: Spain

Items
PostPosted: Sat Sep 02, 2006 9:39 pm    Post subject: The Formal definition of Unified Colors Technique Reply with quote

This is the Formal definition of Expanded Colors technique (since now on, in this post, "X-Colors"). As we will see later, it is a generalisation, better: the Unification of both Colors and Multicolors techniques, and even goes beyond both of them.

Terminology: (I thing it is the most commonly used by Sudoku players).

House: Every set of cells that must contain one and only one of the digits 1 to 9. Rows, Column and a boxes are houses.
Peer (of one cell): All the cells that share a house with this given cell.
Conjugate (pair of cells) on one digit: Two and only two cells of one house that are the only possibilities to hold that digit in the whole house.
Candidate: Every different digit a cell can contain satisfying all the constraints of the given position.

Definition of the technique (the algorithm used):

Step 1) Once selected one digit candidates, select one pair of conjugate cells, and colour them with two alternate colors (namely, color "A" and color "B").

Step 2) If one of these two cells, coloured "A", is conjugate of another cell, then colour this new cell with the opposite colour (color "B").
This process is recursive, and ends when all the chain of conjugates are alternatively coloured "A" or "B".

Step 3) If all but one and only one cell (called the "Exception Cell") of all the candidates in a house are peers of cells coloured with the same color "A", then colour the Exception cell with the same color "A".
This process is recursive, and ends when you cannot find any more cells to colour.
(IMPORTANT: If as result of this process you colour "A" one cell that has a conjugate not been coloured "A" or "B" until then, YOU CAN NOT COLOUR THIS NEW CELL WITH THE OPPOSITE COLOR. This is made in steps 1 and 2, but we are now in step 3).

Step 4) Once marked "A"-"B" all possible cells in the position:

Step 4.1) If one cell has two or more peers coloured with both colors ("A" AND "B"), you can safely exclude this cell as a candidate for the digit.

Step 4.2) If two or more cells of the same house are coloured with the same color "A", then you can conclude that THE OTHER COLOR "B" IS TRUE.


That's enough to define the whole technique. Here are the "True"/"False" implications:

i) If one cell coloured "A" is identified as "True", then all cells coloured with the same color "A" are True.
ii) If one cell coloured "A" is identified as "False", then all cells coloured with the Opposite Color "B" are True.

Please note that these two assertions DOES NOT IMPLY that if "A" is true, then "B" is False, and viceversa. This sentence is only true when dealing exclusively with conjugates, and in that case, it is irrelevant, because trueing the cells colured "A" will immediatly eliminate candidates in peer cells, included the coloured "B".


Its relation with the standard Color and Multicolor techniques is the following:

Definitions:
Let's define the function Colors(x,z), that means that, given a position x, the standard Colors technique will find the solution z.
Let's define the function Multicolors(x,z), that means that, given a position x, the standard MultiColors technique will find the solution z.
And let's define the function X-Colors(x,z), that means that, given a position x, the X-Colors technique as defined in the Steps 1 to 4 of this post will find the solution z.

Then:
a) For All x, Colors(x,z) implies X-Colors(x-z), or, that is the same: (Not Colors(x,z)) Or X-Colors(x,z).
b) For All x, Multicolors(x,z) implies X-Colors(x,z), or, that is the same: (Not MultiColors(x,z)) Or X-Colors(x,z).
c) It exist some x where (Not Colors(x,z)) And (Not MultiColors(x,z)) And X-Colors(x,z).

That means that every possible solution that can be found using Colors or Multicolors can be found too with X-Colors (sentences a and b), but there are some positions where X-Colors finds a solution that neither Colors not MultiColors can not (sentence c).
Some of this new solutions mentioned in sentence c (maybe all of them, I don't konw) can be found too using other different techniques. It is irrelevant for the definition of the tecnique.

The implications of this new definition on Sudoku Solving are:
1) This technique is easy to understand, use and spot by humans. More or less, same difficulty to spot than Standard Colors. That is my only interest: solving Sudokus by humans.
Of course, probably it should ease the programming of computer Sudoku Solvers, but it is at the choice of the programmers.
2) Only uses two colors, avoiding the confusion originated by the use of four or more colors in Multicolors.
3) It is more powerful than the sum of both Colors and Multicolors, though it can find solutions in more positions.


Some examples (they are the same than in previous posts).
I have to say that I haven't learnt how to use fixed-pitch fonts like Courier in this forum to avoid the horrible impression of what it follows... my apologies. I have published the same info in
http://www.sudoku.org.uk/discus/messages/2/2441.html?1157232862
where I could easily attach some images with the three examples.
1)
Code:
 *-----------*
 |..5|4..|..7|
 |.4.|87.|..5|
 |187|.56|4.2|
 |---+---+---|
 |2..|718|564|
 |816|524|973|
 |754|..3|..1|
 |---+---+---|
 |.7.|.85|146|
 |5.1|.49|7.8|
 |4.8|1.7|.59|
 *-----------*


Looking to candidate "3", and marking colors (Green, Blue) using steps 1,2, we have:


Code:
 *-------------------------------*
 | 3  3  -  | - *3G -  | 3  3  - |
 | 3  -  3  | -  -  -  | 3  3  - |
 | -  -  -  |*3B -  -  | - *3G - |
 |----------+----------+---------|
 | -  3  3  | -  -  -  | -  -  - |
 | -  -  -  | -  -  -  | -  -  - |
 | -  -  -  | -  -  -  | -  -  - |
 |----------+----------+---------|
 | 3  -  3  | 3  -  -  | -  -  - |
 | -  3  -  | 3  -  -  | - *3X - |
 | -  3  -  | - *3B -  | 3  -  - |
 *-------------------------------*


In this example, look at the cell R9C5 (Blue). If we look now at box 9, we see that has only two cells (R8C8, R9C7), that incidentally are conjugate, but they doesn't form part of the conjugate chain marked blue-green: R9C2 avoids it. Now, applying Step 3, we see that the only cell in box 9 that is not a peer of the Blue cell R9C5 is R8C8 (marked "X"). Then, the candidates R1C8 and R2C8 are peers of two cells (R3C8 and R8C8) marked blue and green, so "3" can be safely removed from these cells.
The same reasoning can be easily made to remove R9C2.

In the same position, Multicolors would find the same exclusions. In the next example, it cannot.You will need other kind of techniques to find it (David P.Bird has noted that Turbot Fish will have the same effects here):

2)

Code:
 *-----------*
 |14.|.8.|.9.|
 |..8|.42|1.6|
 |...|3..|4.8|
 |---+---+---|
 |..1|...|6.9|
 |..9|.2.|8..|
 |4.6|...|3..|
 |---+---+---|
 |9.7|..4|...|
 |8.4|13.|9..|
 |.1.|.9.|..4|
 *-----------*


Looking to the candidate "7", we have:


Code:
 *-------------------------------*
 | -  -  -  | 7  - *7Y | 7G -  7 |
 | 7  7  -  | 7  -  -  | -  7  - |
 | 7  7  -  | -  7  7  | -  7  - |
 |----------+----------+---------|
 | 7  7  -  | 7  7  7  | -  7  - |
 | 7  7  -  | 7  -  7  | -  7  7 |
 | -  7  -  | 7  7  7  | -  7  7 |
 |----------+----------+---------|
 | -  -  -  | -  -  -  | -  -  - |
 | -  -  -  | -  - *7X | -  7  7 |
 | -  -  -  | 7  -  7  | 7B 7  - |
 *-------------------------------*


In this position there is only one pair of conjugate cells (R1C7 and R9C7, that are the only cells with candidate 7 in column 7; there are not any other conjugate pair in "7's" in this position). So, both Colors and multicolors are unuseful here.
Applying then the step 3 makes R8C6 (marked with the "X" in the diagram) marked with the same color than R9C7 (Blue), due to the fact that all the rest of the cells of its box are peers of R9C7. Then, step 3 allows us to mark R8C6 Blue.
You can then safely exclude candidate 7 from R1C6 (marked with "Y").


3) One more example, taken from SudoCue.net "Daily Nightmare" of Aug 25th.
(Thank you, Ruud, for that excellent excellent excellent page and software).

After initial cleaning (exclusions, hidden singles, naked triples, colors and so), we arrive to this position:

Code:
 *-----------*
 |276|9..|..1|
 |8..|..1|76.|
 |.31|..7|..2|
 |---+---+---|
 |.9.|..2|..6|
 |...|...|...|
 |6..|3..|.5.|
 |---+---+---|
 |7..|8.6|.9.|
 |.62|5..|8.4|
 |18.|..4|6..|
 *-----------*


Looking to candidate "3", we then mark Blue-Green using steps 1,2:

Code:
 *--------------------------------*
 | -  -  -  | -  3  3B | 3  3  -  |
 | -  -  -  | -  3  -  | -  - *3X |
 | -  -  -  | -  -  -  | -  -  -  |
 |----------+----------+----------|
 | 3  -  3  | -  -  -  | 3  -  -  |
 | 3  -  3  | -  -  -  | 3  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 |----------+----------+----------|
 | -  -  3  | -  -  -  | -  - *3X |
 | 3B -  -  | -  -  3G | -  -  -  |
 | -  -  3  | -  3B -  | -  3  3  |
 *--------------------------------*


In this position, Simple Sudoku says "No hint available". (Thank you, Angus, for your excellent excellent excellent program to help Solving Sudokus to human beens).

Applying step 3: R2C9 (marked with an X) IS Blue, because is the only remaining cell of its box not been a peer of R1C6 (Blue).
R7C9 (marked with an X too) IS BLUE, because is the only remaining cell of its box not been a peer of R9C5 (Blue).
We then have two Blue cells in the same column (C9), so THE CANDIDATE GREEN IS TRUE. Therefore, R8C6 is a "3".
Remember; at this point you CANNOT EXCLUDE the blue cells; you can only assure that Green cells are true. In fact, R1C6, R8C1 and R9C8 disappear when setting 3 in R8C6. Neither R2C9 nor R7C9 are affected. They can be both false or only one of them: we don't know that at this point and cannot make any assumption on it (in fact in this puzzle one of them is a 3, it is irrelevant). We then uncolour these two cells, and continue solving the puzzle as always.



Buenos dias y espero que este post haya sido de utilidad.

Best regards
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Sun Sep 03, 2006 1:21 am    Post subject: Reply with quote

Hi again TheSpaniard.

While the techniques you've described have been discussed elsewhere, your definitions or rules above are the perhaps the clearest (or most systematic) I've seen documented so far. Having said that, I do think you need to more clearly differentiate between strong conjugate links and weak links (which have been documented at length and are widely accepted terms) as per Ruud's post here: http://www.setbb.com/sudoku/viewtopic.php?p=6588&mforum=sudoku#6588 . That should eliminate any residual confusion about you current colouring descriptions.

Also, I've edited you post and put your grids in code blocks which I think makes them much easier to view.
Back to top
View user's profile Send private message Visit poster's website
TheSpaniard

Joined: 28 Aug 2006
Posts: 20
:
Location: Spain

Items
PostPosted: Sun Sep 03, 2006 4:47 pm    Post subject: Reply with quote

Thank you, Angus, both for the reply, and your comments, and for editing my post. I am dumb, really, I must take a course of HTML, but I have time problems...

Angus: One of the things that happen with this definition of Colors is that it does not matter what happens to conjugates. If after colouring cells with steps 1,2,3, you find the conditions cited in 4.1 or 4.2, then you proceed as mentioned, and it does not matter what happens with conjugates. At least I think so...

I am aware that X-Colors break with a well stated tradition until now, that is that blue-green are as ying-yang, if one is true the other is false and viceversa. Using X-Color technique it changes. Sometimes they are true, sometimes it is not (like in real world, things are not usually black and white, they are all grey, clearer or darker) Well, life is change....

Thank you again.
Back to top
View user's profile Send private message
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 10:12 am    Post subject: Reply with quote

Most excellent addition to human solving methods...

I have successfully applied it to several (previously awkward) puzzles with good results. However, I ran into a serious problem in the following (partially solved) puzzle...
Code:
 *-----------------------------------------------------------*
 | 6     3     29    | 5     129   4     | 8     7     12    |
 | 1     258   258   | 6     28    7     | 3     4     9     |
 | 4     78    789   | 123   89    123   | 5     12    6     |
 |-------------------+-------------------+-------------------|
 | 9     1     45    | 8     347   35    | 2     6     347   |
 | 7     248   248   | 12    6     123   | 9     5     134   |
 | 25    6     3     | 127   2457  9     | 17    8     147   |
 |-------------------+-------------------+-------------------|
 | 8     27    1     | 237   237   6     | 4     9     5     |
 | 3     2457  2457  | 9     27    15    | 6     12    8     |
 | 25    9     6     | 4     15    8     | 17    3     27    |
 *-----------------------------------------------------------*

Reducing this to colouring on candidate 3 we have...
Code:
 *--------------------------------*
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | 3B -  3G | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | -  3G 3  | -  -  3  |
 | -  -  -  | -  -  3  | -  -  3  |
 | -  -  -  | -  -  -  | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | 3G 3B -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 *--------------------------------*

Examining box 6 we can see that [r5c9] is the only cell without a green peer. Thus, using rule 3, we can deduce that it must be green. Inserting this green and placing the consequential blues we arrive at...
Code:
 *--------------------------------*
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | 3B -  3G | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | -  3G 3  | -  -  3B |
 | -  -  -  | -  -  3B | -  -  3G |
 | -  -  -  | -  -  -  | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | 3G 3B -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 *--------------------------------*

It is immediately apparent that [r4c6] must not be 3 as it has both blue and green peers.

The problem is... if you solve this puzzle (by other means Wink )... [r4c6] is 3.

So... I thought I understood this technique, but I arrive at an incorrect conclusion. Can you show me where I went wrong?
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Tue Sep 05, 2006 11:15 am    Post subject: Reply with quote

Starflyer Alien wrote:
So... I thought I understood this technique, but I arrive at an incorrect conclusion. Can you show me where I went wrong?

The error arises because you continue coloring from a weakly linked cell (r5c9). This is why I think it's still important to differentiate between strong and weak links. If you color cell r5c9 'weak' green, it will stop you progressing incorrectly to color r4c9 blue. (All we can say about r5c9 is that it will be TRUE if r4c5 is TRUE.) Anyhow, you can only progress to "weakly color" cells from "strongly colored" cells.
Back to top
View user's profile Send private message Visit poster's website
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 12:42 pm    Post subject: Reply with quote

Aha! Light dawns.

Had I read the method more closely and paid attention to the section marked "IMPORTANT" I would not have made this silly mistake. Embarassed

Thanks, Angus... and double thanks for your most excellent program. Very Happy
Back to top
View user's profile Send private message
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 1:00 pm    Post subject: Reply with quote

Further Question/Clarification...

Your statement
Quote:
Anyhow, you can only progress to "weakly color" cells from "strongly colored" cells.
also implies that I can't do the following...
Code:
 *--------------------------------*
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | 3B -  3G | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | -  3G 3  | -  -  3  |
 | 3  -  -  | -  -  3  | -  -  3g |
 | 3g -  -  | -  -  -  | -  -  -  |
 |----------+----------+----------|
 | -  -  -  | 3G 3B -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 | -  -  -  | -  -  -  | -  -  -  |
 *--------------------------------*

(I have added another couple of candiate 3s purely to illustrate my question)
Strong colours are labelled G&B, weak colours are g(&b).
I read this as "if r4c5 is TRUE then r5c9 is TRUE" (on which we agree)...
and "hence r6c1 is TRUE".

Or have I gone one step too far again?
Back to top
View user's profile Send private message
angusj
Site Admin
Joined: 18 Jun 2005
Posts: 406
:

Items
PostPosted: Tue Sep 05, 2006 1:08 pm    Post subject: Reply with quote

Starflyer Alien wrote:
Your statement ... also implies that I can't do the following...

Yes, but I was wrong on one point ...

Quote:
Or have I gone one step too far again?

Yes, you're OK progressing weak conjugates as you've done - that is progressing weak greens to other weak greens or weak blues to other weak blues. You just can't progress green to a blue or vice versa. I'm a bit rusty on all this now so perhaps I ought to step out of this conversation in case I lead you astray Confused .
Back to top
View user's profile Send private message Visit poster's website
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 1:41 pm    Post subject: Reply with quote

angusj wrote:
Yes, you're OK progressing weak conjugates as you've done - that is progressing weak greens to other weak greens or weak blues to other weak blues. You just can't progress green to a blue or vice versa. I'm a bit rusty on all this now so perhaps I ought to step out of this conversation in case I lead you astray Confused .

Yes, I think that is right. We can't propagate a weak colour to the opposite colour but we can propagate a weak colour to the same weak colour. Let's wait and see if anyone contradicts us. Laughing

From now on I'm going to use G&B for strong colours and g&b for weak colours. That should prevent me making errors in propagation.

Thanks for your help Angus. Much appreciated.


Last edited by Starflyer Alien on Wed Sep 06, 2006 8:34 am; edited 1 time in total
Back to top
View user's profile Send private message
daj95376

Joined: 05 Feb 2006
Posts: 349
:

Items
PostPosted: Tue Sep 05, 2006 3:11 pm    Post subject: Reply with quote

Is there anything in the UCT to explain [r8c5]<>2 ???
Back to top
View user's profile Send private message
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 3:41 pm    Post subject: Reply with quote

daj95376 wrote:
Is there anything in the UCT to explain [r8c5]<>2 ???

Not that I can find ... and I tried (even before you asked!) Smile
I would like a nice formal method of deriving '[r8c5]<>2' other than asserting "[r8c5]=2" and proving a contradiction (too much like T&E).
Sadly I don't think ECT methodology will help. Crying or Very sad
Back to top
View user's profile Send private message
daj95376

Joined: 05 Feb 2006
Posts: 349
:

Items
PostPosted: Tue Sep 05, 2006 3:59 pm    Post subject: Reply with quote

Starflyer Alien wrote:
I would like a nice formal method of deriving '[r8c5]<>2' other than asserting "[r8c5]=2" and proving a contradiction (too much like T&E).
Sadly I don't think ECT methodology will help. Crying or Very sad

I believe that a Double Implication Chain will derive [r8c5]<>2. Here's a shortcut using Locked Candidates. Start with the strong link on <2> in [r38c8].

SOB automatic editing won't let me enter the DIC. I've encountered this problem before.

It doesn't help that my display is flashing like crazy from all the ad graphics. Nothing like the hard sell to impress me!!!
Back to top
View user's profile Send private message
Starflyer Alien

Joined: 05 Sep 2006
Posts: 7
:
Location: Rhyl, UK

Items
PostPosted: Tue Sep 05, 2006 4:18 pm    Post subject: Reply with quote

We're going off topic here. we should move this elsewhere...
and I'd like to see that DIC... I've tried real hard to find one for [r8c5]<>2.
There's a really nice one for [r2c2]=5,
Code:
 [r2c2]=5=[r8c2]=4=[r5c2]-4-[r4c3]-5-[r2c3]=5=[r2c2] => [r2c2]=5

but that's another story. Confused
Back to top
View user's profile Send private message
daj95376

Joined: 05 Feb 2006
Posts: 349
:

Items
PostPosted: Tue Sep 05, 2006 5:08 pm    Post subject: Reply with quote

I disabled HTML and BBcode. So, the DIC may not be pretty but it will at least list properly.

[r8c8]=2 => [r8c5]<>2

[r3c8]=2 => [r12c5]=2 => [r8c5]<>2
-or-
[r3c8]=2,[r5c6]=2,[r7c4]=2 => [r8c5]<>2

This isn't the first time a message thread has gone off-topic. It'll survive our short tangent!
Back to top
View user's profile Send private message
Mike Barker

Joined: 03 Sep 2006
Posts: 6
:

Items
PostPosted: Tue Sep 05, 2006 7:10 pm    Post subject: Reply with quote

A simple Empty rectangle gives the elimination:
Code:
Empty Row Rectangle : r3c58|r8c8 => r8c5<>2
+-----------------+-----------------+--------------+
|   6     3    29 |    5   129    4 |   8   7   12 |
|   1   258   258 |    6    28    7 |   3   4    9 |
|   4    78   789 |  123   *89  123 |   5 *12    6 |
+-----------------+-----------------+--------------+
|   9     1    45 |    8   347   35 |   2   6  347 |
|   7   248   248 |   12     6  123 |   9   5  134 |
|  25     6     3 |  127  2457    9 |  17   8  147 |
+-----------------+-----------------+--------------+
|   8    27     1 |  237   237    6 |   4   9    5 |
|   3  2457  2457 |    9   -27   15 |   6 *12    8 |
|  25     9     6 |    4    15    8 |  17   3   27 |
+-----------------+-----------------+--------------+


Spaniard, thanks for the post. I agree with your comment that when dealing with colors it is not necessary to worry about weak links, but this comment and the above example makes me wonder how different your approach is than Havard's Strong Link Approach. Here are two of your examples using a pure strong link approach. As you can see there is a lot of similarity, but where you use 2 strong links and an "X-factor", the strong link approach uses 3 strong links. There are many ways to solve a puzzle, these are two which seem similar. I'd really be interested in a case where colors was more effective/simpler than strong links.

(continued on next post - I'm having problems submitting the entire post together)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron