Axiom of Specification from Replacement and Empty Set

Theorem
The Axiom of Specification is a consequence of:
 * the Axiom of Replacement

and
 * the Axiom of the Empty Set.

Proof
Let $A$ be an arbitrary set.

Let $\map P x$ be an arbitrary propositional function.

It is to be shown that there exists a set $B$ consisting of exactly the $y \in A$ such that $\map P y$.

That is:


 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \paren {y \in A \land \map P y} }$

By Law of Excluded Middle, there are two choices:
 * $\exists y \in A : P(y)$

or:
 * $\not \exists y \in A : P(y)$

Suppose $\not \exists y \in A : P(x)$.

By Axiom of the Empty Set, take $B = \O$.

Take arbitrary $A$ and $y$.

Assume $y \in B$.

This contradicts the empty set definition.

By Rule of Explosion/Proof Rule, we have:
 * $y \in A \land \map P y$

giving:
 * $y \in B \implies \paren {y \in A \land \map P y}$

Now assume:
 * $y \in A \land \map P y$

This contradicts our assumption that:
 * $\not \exists y \in A : P(y)$

By Rule of Explosion/Proof Rule, we have:
 * $y \in B$

giving:
 * $\paren {y \in A \land \map P y} \implies y \in B$

Thus:
 * $\paren {y \in A \land \map P y} \iff y \in B$

and by Universal Generalisation and Existential Generalisation:
 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \paren {y \in A \land \map P y} }$

This shows that the axiom of specification holds when:
 * $\not \exists y \in A : P(y)$

Suppose $\exists y \in A : P(y)$.

Take some fixed $w \in A : P(w)$.

Define the propositional function $Q(x,z)$ as follows:


 * $\paren{P(x) \land z = x} \lor \paren{\neg P(x) \land z = w}$

Usually this would be written as the mapping:
 * $\map f x = \begin{cases}

x & : P(x) \\ w & : \text{otherwise} \end{cases}$

It is to be shown that $Q(x,z)$ determines a function.

That is:
 * $\forall x: \exists a: \forall z: \paren {\map Q {x, z} \iff a = z}$

Take arbitrary $x$ and $z$.

Assume that $\map Q {x, z}$, giving:


 * $\paren{P(x) \land z = x} \lor \paren{\neg P(x) \land z = w}$

By Law of Excluded Middle, there are two choices:
 * $P(x)$

or:
 * $\neg P(x)$

Suppose $P(x)$.

that:
 * $\paren{\neg P(x) \land z = w}$

Then we have the contradiction:
 * $P(x) \land \neg P(x)$

Thus we have:
 * $\neg \paren{\neg P(x) \land z = w}$

and by Modus Tollendo Ponens:
 * $\paren{P(x) \land z = x}$

Take $a=x$.

Thus, for all $z$ such that $Q(x,z)$, we have $a=x=z$, giving:
 * $\map Q {x, z} \implies a = z$

Suppose $\neg P(x)$.

that:
 * $\paren{P(x) \land z = x}$

Then we have the contradiction:
 * $P(x) \land \neg P(x)$

Thus we have:
 * $\neg \paren{P(x) \land z = x}$

and by Modus Tollendo Ponens:
 * $\paren{\neg P(x) \land z = w}$

Take $a=w$.

Thus, for all $z$ such that $Q(x,z)$, we have $a=w=z$, giving:
 * $\map Q {x, z} \implies a = z$

Thus:
 * $\map Q {x, z} \implies a = z$

follows from both $P(x)$ and $\neg P(x)$.

By Universal Generalisation and Existential Generalisation:
 * $\forall x: \exists a: \forall z: \paren {\map Q {x, z} \iff a = z}$

and $\map Q {x, y}$ determines a function.

We now have a propositional function $\map Q {x, y}$ satisfying the premise of axiom of replacement, giving:
 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \exists x \in A : \map Q {x,y}}$

By definition of $\map Q {x, y}$, we have:
 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \exists x \in A : \paren{ \paren{P(x) \land y = x} \lor \paren{\neg P(x) \land y = w}}}$

where $w \in A$ and $P(w)$.

We must show that the axiom of specification holds:
 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \paren {y \in A \land \map P y} }$

Assume $y \in B$.

By axiom of replacement, we have:
 * $\paren{P(x) \land y = x} \lor \paren{\neg P(x) \land y = w}$

for some $x \in A$.

$P(x) \land y = x$ and $x \in A$ imply $y \in A \land \map P y$.

Recalling that $w \in A$ and $P(w)$, $\neg P(x) \land y = w$ implies $y \in A \land \map P y$.

Thus:
 * $y \in B \implies \paren {y \in A \land \map P y}$

Now assume $y \in A \land \map P y$.

Then there is an $x$, namely $x=y$, such that:
 * $\exists x \in A : \paren{P(x) \land y = x}$

By Rule of Addition:
 * $\exists x \in A : \paren{ \paren{P(x) \land y = x} \lor \paren{\neg P(x) \land y = w}}$

Thus, by axiom of replacement we have $y \in B$.

Thus:
 * $\paren{y \in A \land \map P y} \implies y \in B$

This completes the biconditional:
 * $y \in B \iff \paren{y \in A \land \map P y}$

By Universal Generalisation and Existential Generalisation:
 * $\forall A: \exists B: \forall y: \paren {y \in B \iff \paren {y \in A \land \map P y} }$

This shows that the axiom of specification holds when:
 * $\exists y \in A : P(y)$

Thus, the axiom of specification holds both when
 * $\exists y \in A : P(y)$

and when
 * $\not \exists y \in A : P(y)$

completing the proof.