I'm trying to understand the ZFC axioms, and I understand most of them except the axiom of regularity.
$$\forall x[\exists a(a\in x) \Rightarrow \exists y(y\in x \wedge \neg\exists z(z\in y \wedge z\in x))]$$
From what I understand, it is saying that, for all non-empty sets that have a set for an element, the set does not share any elements with the original set and the element of the set. However, wouldn't that make the natural number construction of 2 impossible because:
$$2 = \{ 0, 1 \} = \{ 0, \{ 0 \} \}$$
If we choose $x = 2$ and we choose the element $\{ 0 \}$ to be our $y$. There does exist an element $z$ which is in both sets, more precisely $0$. $$0 \in 2 \, \land \, 0 \in \{ 0 \}$$ What am I missing? Thanks!
Let's make a ridiculous version of your mistake.
"Theorem". All sets are empty.
"Proof". Let $A$ be a set, if it is not empty, then there is a subset of $A$ which is not empty as well. Consider $\varnothing$ as a subset of $A$. It is empty, therefore $A$ is empty. $\square$
When we say $\exists y$, we are not asking you to choose one $y$ and test it against the formula. We are asking you to go through all possible $y$'s until you find one that matches, and only when you've exhausted all of the possible $y$'s, you can say that this is false.
In the case of $\{\varnothing,\{\varnothing\}\}$, setting $y=\{\varnothing\}$ is not enough. You also need to test $\varnothing$ itself. Which, of course, is a suitable witness.
(Since we use the term "witness", let me make a real-life metaphor to your situation. There had been a crime, and you're asking for witnesses. You choose one carefully selected old person who is deaf, blind, mute, and wasn't in the area at the time of the alleged crime. Asking them if they saw anything, they tell you that they didn't. You conclude that there are no witnesses to corroborate the crime.)