The problem:
We have a quadratic black and white screen of indefinite size, the pixels can be either on or off. Use the following predicate symbol:
$P(x,y)$: the pixel on row number $x$ and column $y$ is on.
(We assume that both rows and columns are numbered $0,1,\dots$). Express the following statements as closed formulas:
a) Some pixels on the main diagonal are lit.
Answer: $\quad ∃x(P(x,x))$
b) At least one pixel is lit on each row.
Answer: $\quad ∀x ∃y(P(x,y))$
c) All pixels are lit in at least one column.
Answer: $\quad ∃y ∀x(P(x,y))$
d) A maximum of one pixel is lit on each row.
Answer: $\quad ∀x[¬∃y(P(x,y)) ∨ ∃y(P(x,y)) ∧ ∃z∃y(P(x,z) → z=y)]$
e) There is at least one row where exactly 1 pixel is lit.
Answer: $\quad ∃x[∃y(P(x,y)) ∧ ∃z∃y(P(x,z)→ z=y)]$
I'm new at this and I'm not sure if my answers are correct, and d) and e) confuse me the most. Am I on the right track? How do you show 'exactly 1' in e)?
You're doing great, but yes, just some small problems with both d and e, as you suspected (which is in and of itself a good sign as well that you're well on the way to mastering the language of logic!)
OK, for d) you have:
$\quad ∀x[¬∃y(P(x,y)) ∨ ∃y(P(x,y)) ∧ ∃z∃y(P(x,z) → z=y)]$
Again, the basic idea is good: in every row you either have no or exactly one pixel lit. However, when you say $\exists y (P(x,y) \land \exists z \exists y(P(x,z) \to z=y))$ you are saying": there is a pixel $y$ lit in row $x$, and there are two pixels for which is true that (if $z$ is a pixel lit in row $x$, then $y$ and $z$ are the same). There are two problems with this:
First, you want to make sure that the second pixel $z$ is equal to the first lit pixel $y$ ... rather than some object, period. That is, either use:
$\exists y (P(x,y) \land \exists z (P(x,z) \to z=y))$ (still not good, see below!)
or use:
$\exists y \exists z ((P(x,y) \land (P(x,z)) \to z=y))$ (still not good, see below!)
Second: instead of using existentials, you have to use universals: you don;t want to claim that there are two pixels such that if they are both lit then they are the same), because that can easily be satisfied by picking pixels for $y$ and 4z$ that are not lit in the first place. So instead, use:
$\exists y (P(x,y) \land \forall z (P(x,z) \to z=y))$
or (more efficient, though probably a little less intuitive):
$\exists y \forall z (P(x,z) \leftrightarrow z=y))$
Finally, here is a way to say that there is at most one pixel without making an explicit distinction between having no pixels or exactly one pixel:
$\forall y \forall z ((P(x,y) \land P(x,z)) \to z=y)$
So, for d) you could simply do:
$\forall x \forall y \forall z ((P(x,y) \land P(x,z)) \to z=y)$