There exists a community, one of whose members is a barber.

This barber operated under an unusual rule: his task was to shave every man in the community who did not shave himself, and only those men.

Who shaves the barber?

If he does not shave himself, then he must shave himself.

But if he shaves himself, he must not shave himself.

Analysis

This is an application of Russell's Paradox.

Let $\mathbb U$ be the set of all the men of the community.

Thus $\mathbb U$ is considered to be the universe.

Let $S: \mathbb U \to \left\{{T, F}\right\}$ be the propositional function:

$\forall x \in \mathbb U: S \left({x}\right) \iff x \text { is shaved by$x$}$

Let $b \in \mathbb U$ be the barber.

Let $B: \mathbb U \to \left\{{T, F}\right\}$ be the propositional function:

$\forall x \in \mathbb U: B \left({x}\right) \iff x \text { is shaved by$b$}$

The initial premises can be coded:

$(1): \quad \forall x \in \mathbb U: \left({\neg S \left({x}\right)}\right) \iff B \left({x}\right)$
$(2): \quad B \left({b}\right) \iff S \left({b}\right)$

Hence:

$S \left({b}\right) \iff B \left({b}\right) \iff \left({\neg S \left({b}\right)}\right)$

and so from Biconditional is Transitive:

$S \left({b}\right) \iff \left({\neg S \left({b}\right)}\right)$

So from either case there derives a contradiction.

Thus the initial premises are contradictory and cannot both hold.

$\blacksquare$

Resolution

Let the every condition above be relaxed, and rewrite it as:

his task was that he may shave only men in the community who did not shave themselves.

The initial premises can be coded:

$(1): \quad \forall x \in \mathbb U: B \left({x}\right) \implies \left({\neg S \left({x}\right)}\right)$
$(2): \quad B \left({b}\right) \iff S \left({b}\right)$

Thus it is not the case that:

$\left({\neg S \left({x}\right)}\right) \implies B \left({x}\right)$

However, from $B \left({b}\right) \iff S \left({b}\right)$ this then means that $\neg B \left({b}\right)$.

So at least one person in the community is not shaven by $b$ at all, the barber himself necessarily being one such.

This of course does not preclude the possibility that some other person, who is not the barber, may also shave people.

These may or may not include the barber, who may retain his beard.

$\blacksquare$