(1) We first show that ⋆ is associative. This can be done through the following lemma.
Lemma 1. fX⋆Y=fX∘fY.
Proof. Note that
fX⋆Y(N)=N−(X⋆Y)=(N−X)−fX(Y)=fX(N)−fX(Y)=fX(N−Y)=fX(fY(N))
This means that the functions fX⋆Y and fX∘fY are strictly increasing functions with the same range. This forces that the two must be the same. □.
The lemma implies associativity since
N−((A⋆B)⋆C)=f(A⋆B)⋆C(N)=fA(fB(fC(N)))=fA⋆(B⋆C)(N)=N−(A⋆(B⋆C)),
so (A⋆B)⋆C=A⋆(B⋆C).
(2) Due to the associativity, let us define X∗k=X⋆X⋆⋯⋆X, where X appears k times on the RHS. Our goal is to show that A∗b=B∗a. This can be obtained through the following lemma:
Lemma 2. If X⋆Y=Y⋆X and ∣X∣=∣Y∣, then X=Y.
If Lemma 2 holds, then due to the fact that
(i) ∣A∗b∣=ab=∣B∗a∣;
(ii) Since A⋆B=B⋆A, by Lemma 1, we have A∗b⋆B∗a=B∗a⋆A∗b.
So by Lemma 2, we have A∗b=B∗a.
Hence, it remains to prove Lemma 2. Assume X=Y. Let s be the largest number in exactly one of X and Y; WLOG we assume s∈X−Y. The number fX(s) counts the s-th number not in X, which implies that
fX(s)=s+∣X∩{1,2,…,fX(s)}∣.(1)
Since fX(s)≥s, we have that
{fX(s)+1,fX(s)+2,…,}∩X={fX(s)+1,fX(s)+2,…}∩Y,
which, together with the assumption that ∣X∣=∣Y∣, gives
∣X∩{1,2,…,fX(s)}∣=∣Y∩{1,2,…,fX(s)}∣.(2)
Now, consider the equation
t−∣Y∩{1,2,…,t}∣=s.
This equation is satisfied only when t∈[fY(s),fY(s+1)), because the left hand side counts the number of elements up to t that are not in Y. We have that the value t=fX(s) satisfies the above equation because of (1) and (2). Furthermore, since fX(s)∈/X and fX(s)≥s,
we have that fX(s)∈/Y due to the maximality of s. Thus, by the above discussion, we must have fX(s)=fY(s).
Finally, we arrive at a contradiction. The value fX(s) is neither in X nor in fX(Y), because s is not in Y by assumption. Thus, fX(s)∈/X⋆Y. However, since s∈X, we have fY(s)∈Y⋆X, a contradiction.