How to write a predicate that means "There is exactly one student in at most one class". This was a question in my discrete math 1 exam but I don't quite remember my answer and everyone seems to disagree with each other so I thought I'd ask what the correct answer is.
Let $C(x,y)$ mean "student $x$ is in class $y$".
 A: The sentence as written is ambiguous. It could mean, "There is exactly one student, and she is in at most one class," or it could mean, "There is at most one class satisfying the condition that there is exactly one student in the class." Those are logically distinct sentences. (This might explain why everyone seems to disagree with each other on how to write the predicate.)
Let $Sx$ be  "$x$ is a student," $Kx$ be "$x$ is a class," and $Cxy$ as  you mentioned.
To help, we will review the following phrases:
"There are zero students" -- $\neg(\exists x)(Sx)$
"There is exactly one student" -- $(\exists x)(Sx \wedge (\forall y)(Sy \implies y = x))$
"There is at most one student" -- "There are zero students" $\vee$ "There is exactly one student" -- $\neg(\exists x)(Sx) \vee (\exists x)(Sx \wedge (\forall y)(Sy \implies y = x))$
Okay, using those as references for the number parts, let's try the two interpretations I gave above.
"There is exactly one student, and she is in at most one class."
$(\exists x)(Sx \wedge (\forall y)(Sy \implies y = x) \wedge 
(\neg(\exists y)(Ky \wedge Cxy)\vee (\exists y)((Ky \wedge Cxy) \wedge (\forall z)((Kz \wedge Cxz) \implies z = y)))$
"There is at most one class satisfying the condition that there is exactly one student in the class."
$\neg(\exists x)(Kx \wedge (\exists y)((Sy \wedge Cyx) \wedge (\forall z)((Sz\wedge Czx) \implies z = y))) \vee (\exists x)(Kx \wedge (\exists y)((Sy \wedge Cyx) \wedge (\forall z)((Sz\wedge Czx) \implies z = y)) \wedge (\forall w)(Kw \wedge (\exists y)((Sy \wedge Cyw) \wedge (\forall z)((Sz\wedge Czw) \implies z = y)) \implies w=x))$
