In "Mathematical Logic" by Chiswell and Hodges, there is the following exercise (3.5.3):
You forgot whether the logic class is at 11 or 12. Your friend certainly knows which; but sometimes they tell the truth and at other times they deliberately lie, and you know that they will do one of these but you do not know which. What should you ask them?
There is also the following hint:
Let $p$ be the statement that your friend is telling the truth, and let $q$ be the statement that the lecture is at 11. You want to ask your friend whether a certain formula $\phi$ is true, where $\phi$ is chosen so that they will answer 'Yes' if and only if the lecture is at 11. The truth table of $\phi$ will be that of $q$ if $p$ is true, and that of $(\lnot q)$ if $p$ is false. Find an appropriate $\phi$ which contains both $p$ and $q$.
I think one answer to this problem, in English, is "Would you say 'Yes' if I asked you if class is at 11 today?" but I am having trouble answering this question with a truth table and coming up with a $\phi$ that uses the $p$ and $q$ that the authors specified.
What is a $\phi$ that will work, and is there a systematic way to find it (because right now I am pretty much using trial and error, which feels like the least clever way to do it)?
Just follow the hint, we can denote $\phi \equiv f(p, q)$. Since there are just two variables, let's just write down the truth table by enumerating all four possibilities,
We can double check the ground truth values assigned to $\phi$: it is true in two cases:
Therefore, we can conclude that you may just ask your friend $\phi \equiv (p \land q) \lor (\lnot p \land \lnot q)$, another way is to write it as $\lnot (p\ XOR\ q)$.