>>24
I'll try to explain it in a different way.
Imagine you're the judge. You know is that A, B and C are one knight, one knave and one spy, but you don't know which one is which. Each defendant comes and makes a statement. You (the judge) hear their statements, so you know what each of them said. What happens next depends on what was said. A couple of examples:
Case 1
Suppose A said "C is a knave", B said "A is a knave," and C said "B is a knave." There are three different ways this could have happened:
A is the knight, B is the spy, C is the knave;
A is the knave, B is the knight, C is the spy;
A is the spy, B is the knave, C is the knight.
So how do you (the judge) tell which one of the possibilities above is the truth? You can't. Your trial fails and the spy gets away.
Case 2
Suppose A says "C is the spy," B says "A is a knight," and C says "B is a knave."
In this case, if A is the knight, C must be the spy, because the knight only speaks the truth, and B must be the knave, since he's the only one left. However, this would lead to a contradiction, as B, the knave, who never tells the truth, said that A is the knight, which is true. Therefore, A must not be the knight.
If A is the knave, C must be the knight, since A must lie. This leads to another contradiction, as the knight is saying the spy is a knave, which is a lie. So A can't be the knave either.
If A is the spy, then B must be the knave, as he is lying, and C is the knight. Now every statement fits. Since this is the only possibility that would lead to those statements, you (the judge) can conclude that A is the spy.
--
Now, imagine you're the logician. From what you (the logician) have been initially told, you have to consider 18 such cases, including the 2 examples above. However, you know that the judge was able to find the spy, so you can eliminate every case that would result in the trial failing, like case 1.
Once you find out which cases have a unique solution and which don't, you will be one baby step away from finding the spy yourself.