Axiom of Regularity allows for this set be an element of itself I'm new to set theory, and the axiom of regularity has been giving me some trouble. It states that every non-empty set A has an element B such that A and B are disjoint sets. Apparently, this axiom implies that a set can't be an element of itself. I've heard (and agree with) arguments like this:
Let A be a set, and apply the axiom of regularity to {A}, which is a set by the axiom of pairing. We see that there must be an element of {A} which is disjoint from {A}. Since the only element of {A} is A, it must be that A is disjoint from {A}. So, since A ∈ {A}, we cannot have A ∈ A (by the definition of disjoint).
However, let's say there's a set A = {{1, 2}, A}. It seems like this set obeys the axiom of regularity, because {1, 2} is an element of A, and {1,2} and A are disjoint sets. However, the axiom of regularity shouldn't allow A to be an element of itself. I suppose there's a flaw in my logic somewhere, and I'm hoping someone knowledgeable can show me why this isn't allowed.
 A: Just because a set appears to obey the axiom of regularity doesn't mean it actually is a set!  The axiom of regularity restricts what sets exist: if a non-empty set exists, then it has an element that is disjoint from it.  The axiom of regularity doesn't say that any putative collection which follows this rule has to actually exist as a set.
So, all you have observed is that if a set $A=\{\{1,2\},A\}$ existed, then $A$ would not be a counterexample to the axiom of regularity.  This in no way proves that such a set actually exists!  And in fact, if such a set did exist, then $\{A\}$ would be a counterexample to the axiom of regularity.  This is a contradiction, and therefore no such set $A$ exists.
A: You have learned the formal statement of the Axiom of Regularity, but you don't have a good picture of what it means. Let me try to explain it.
Let me call $A$ a bottomless family of sets if, for every set $x$ in $A,$ there is a set $y$ in $A$ such that $y\in x.$ A counterexample to the Axiom of Regularity is just a nonempty bottomless family of sets; in words, the Axiom of Regularity just says that no such family exists.
For example, suppose there is an infinite sequence $a_1,a_2,a_3,\dots$ of sets (not necessarily distinct) such that $a_{n+1}\in a_n$ for every $n,$ that is,
$$a_1\ni a_2\ni a_3\ni\dots\ni a_n\ni\dots\tag1$$
Then the set
$$A=\{a_1,a_2,a_3,\dots\}$$
is bottomless (and of course nonempty); so the Axiom of Regularity says that the set $A,$ and therefore the sequence (1), can't exist.
Note that it is the set $A,$ and not (necessarily) any of the sets $a_n,$ which is a counterexample to Regularity.
Now suppose we had a "circle of sets", say
$$a_1\in a_2\in a_3\in a_4\in a_5\in a_1\tag2$$
In this case $A=\{a_1,a_2,a_3,a_4,a_5\}$ is a nonempty bottomless family, contradicting regularity. Actually this is just a special case of (1) since we could write it as an infinite sequence:
$$a_5\ni a_4\ni a_3\ni a_2\ni a_1\ni a_5\ni a_4\ni a_3\ni a_2\ni a_1\ni a_5\ni a_4\ni\dots$$
In the very simplest case, the Axiom of Regularity tells us that no set can be an element of itself. Namely, if we had
$$a_1\in a_1\tag3$$
then (not $a_1$ but) the set $A=\{a_1\}$ would be a counterexample to Regularity.
In your example, assuming there is a set $a$ such that
$$a=\{\{1,2\},a\},\tag4$$
then we have $a\in a,$ and so the set $A=\{a\}$ is a counterexample to Regularity.
A: The problem with your argument lies right at the beginning:

However, let's say there's a set $A = \{\{1, 2\}, A\}$.

You cannot actually say this in ZFC!  ZFC only allows one to construct sets -from already-existing sets-.  In order to construct $\{\{1, 2\}, A\}$, $A$ would already have to exist, either due to an axiom or due to a prior construction.  Therefore the result must be a new set different from $A$.
A: I'm actually not very familiar with set theory, but I think I see the issue here: when working with set theory, you adopt a certain definition of "set", which entails some mathematical rules (including the axiom of regularity) that any object has to satisfy in order to be a set. An object $A$ which satisfies $A = \{\{1,2\}, A\}$ may "exist" (whatever that means), but it does not satisfy the rules of "set-hood", and therefore is not a set. Just because the notation you use to define it looks set-like, that doesn't make it a set.
I could probably make a rough analogy to the "number" $0.00\ldots1$, which is written using basically the same notation as many things which are numbers, but does not actually satisfy the rules of "number-hood".
You might also find it useful to read Define $A = \{ 1,2,A \}$, $A$ can not be a set (Axiom of regularity). Can $A$ be a "class" or a "collection" of elements., e.g. Asaf Karagila's answer which points out that the definition $A = \{\{1,2\}, A\}$ is circular. Depending on your frame of mind that might make more sense than what I've said above.
A: Let's check whether the candidate set $A=\{\{1,2\},A\}$ is a ZFC set. To qualify as such, it has to comply to all the ZFC axioms, including regularity/foundation (which determines whether a set is well-founded).
From the definition of the candidate set $A$, we infer that $A\supset \{A\}$. This means that every element of the latter is an element of the former. Thus, $A\in A$.
However, $A\in A$ violates the axiom of regularity/foundation, since it has been proven in the literature that no well-founded set is an element of itself.
Therefore, the candidate set A is not a well-founded set, which implies it is not a ZFC set. $\blacksquare$

Now, what was the flaw in the original poster's proof attempt?
It is made clear when we consider ZFC as an axiom system, not as a single axiom taken in isolation.
Let's look at the interaction between two axioms from ZFC.
The axiom schema of specification/separation/restricted comprehension/subset insures that every subset of a ZFC set is a ZFC set. That is, due to the axiom schema of specification, we are told that all the ZFC axioms automatically succeed all the way down (if ZFC is consistent).
But the original (super)set must be a ZFC set for this insurance to be provided by the axiom schema. Otherwise, no guarantees apply.
Thus, if you assume a candidate set is a ZFC set, then, when you take a look at its subsets, every subset must also be a ZFC set. Contrapositively, if at least one subset is not a ZFC set, then the superset is not a ZFC set either.
The subset$^{(a)}$ $\{A\}$ from the candidate set $A$ is not a ZFC set because $A \in A$ (which violates the axiom of regularity/foundation). The subset has the (super)set as an element. Thus, since the candidate set $A$ has a subset that does not comply to a ZFC axiom, then $A$ cannot be considered as a ZFC set, by the (contrapositive statement of the) axiom schema of specification.
If we had reasons to be assured that all the subsets of candidate set $A$ were ZFC sets, then the original poster's proof attempt would have worked. But we were not assured this to begin with. Indeed, the proof (above) showed that $A$ (which has a subset $\{A\}$) is not a ZFC set. A subset violated the axiom of regularity/foundation, thus, by the axiom schema of specification (in contrapositive form), $A$ is not a ZFC set.
Employing the axiom of regularity/foundation to prove whether a candidate set complies to it is not the most common use case; more often, we employ this axiom as an additional fact/premise to obtain an interesting consequence from sets we already know to be ZFC sets. For instance, if $b$ and $c$ are ZFC sets and $b\in c$, then, by applying the axiom of pairing and the axiom of regularity/foundation as additional facts, we have the tools we need in order to prove that $c\notin b$.
$_{(a)}$ Obtained by the implicit application of the axiom schema of specification in the proof above.
