I will refer to the spirits with their response values to true/unknown/false -- for instance, YNY is the fire spirit.
Assuming that they can parse arbitrarily complicated questions, I can do this in
a single question!
I ask everyone:
Is at least one of the following two statements true?
(1) You would answer the same to "Does 1+1=2?" and "Does 1+1=3?", and I have a pet cat.
(2) One of the following two statements is true, but not both:
(2a) You are NNY, NYY, or NYN.
(2b) If you followed the following strategy, you would be assigned "yes": [...]
(I will fill in (2b) later.)
What does this do?
The actual information we're trying to get is in (2b). The rest of the question is "processing" that information in a way that causes each spirit, besides the two constant ones, to follow the strategy correctly.
Statements (2) and (2a) flip the result of (2b) only for the second half of the spirits.
Statements (1) and (1a) convert "false" to "unknown", but only for YNY and NYN.
This means that every spirit is "fed" an input that makes them say the actual answer to (2b):
Now, if we give them the strategy, they will follow it - we just have to make them tell us the thief!
So, what is the magical strategy we need to fill in?
First, before the question, we need to line everyone up in a circle.
If the thief is YYY, the spirit to its left says "yes". (If that one is NNN, then the spirit 2 to its left says "yes" instead.) The rest say "no".
Similarly, if the thief is NNN, the spirit to its left says "no" (or if that's not possible, the spirit two to the left does), and the others say "yes".
(These two cases work even with interference by the other constant-output spirit.)
- If YYY is not directly opposite the thief, then the thief and the spirit opposite YYY say "yes"; the rest say "no".
- Otherwise, the thief and the spirit directly opposite NNN both say "no"; the rest say "yes".
The result of this strategy is that:
If the split is 2 of one answer and 6 of the other, the two will be either adjacent or separated by one; either way, the one on the right is the thief.
Otherwise, the split is 3 of one answer and 5 of the other; the less common answer will have exactly two respondents facing each other, and the thief is the third one.