In common understanding a virgin is someone who has never had sex. But how is this established?

Many consider an intact hymen as a mark of virginity. But the hymen can tear for several other reasons, and so this is a really problematic way of knowing is someone is a virgin. 

In fact there is no real way of identifying virginity!

Because what is sex? Is it penovaginal sex? In which case homosexuals remain virgins for life? That doesn't sound right! Is it when someone hasn't experienced an orgasm? Or is it someone who has had no physical intimacy at all?

Defining who a virgin is, is a near impossible task for all these reasons. It's a category that is extremely fuzzy, because sex means different things to different people.