Each of A and B is a real nxn matrix with:

- A+B = I (identity) and:
- rank(A)+rank(B) = n

Does each of those identities always hold?

- A
^{2} = A
- B
^{2} = B
- AB = BA = 0

If so, prove it.

Otherwise, provide a counterexample.

Sylvester's Rank Inequality states that if matrix A is m by n and matrix B is n by p, then rank(A)+rank(B) <= rank(A*B) + n.

We are given rank(A)+rank(B) = n, therefore rank(A*B) = 0. The only matricies with rank 0 are the zero matricies, therefore Identity 3, AB=BA=0, is true.

Then to prove the other two identities, we can create some equalities for A^2 - B^2 and A^2 + B^2:

A^2 - B^2 = (A+B) * (A-B) = I * (A-B) = A - B

A^2 - B^2 = A - B

A+B = I = I^2 = (A+B)^2 = A^2 + AB + BA + B^2 = A^2 + B^2

A^2 + B^2 = A + B

Add the two simplified identities:

(A^2 - B^2) + (A^2 + B^2) = (A - B) + (A + B)

2A^2 = 2A

A^2 = A

This proves Identity 1. Identity 2 is proved similarly with B^2 - A^2 = B - A and A^2 + B^2 = A + B.