Self identification, social classification.
Wow, that trumps biology? So do you think that a pre-op transvestite should be able to compete as a female?
The IOC have taken the position that it is unfair for males and females to compete. (and I think that's due to hormonal differences). It may or may not be unfair that other biological advantages (cf Phelps) are ignored while gender is controlled for... but that is how it is at the moment.
My sympaties to Semenya.