He, having had a few drinks, pulls out his wallet and bets you. The secret of the trick is parity . The number of mouth-up glasses is either even or odd. In the game you must turn over two glasses simultaneously and therefore the parity, either odd or even of the number of mouth-up glasses does not change. He can't win.
Permutations also have a parity which is changed by a transposition .
A transposition is a permutation which exchanges the place of two objects whilst leaving all the other objects unmoved. An important fact is that any permutation on n objects can be done with a series of transpositions. It is a further fact that if it can be done in an even number of permutations then it can't be done in an odd number and vice versa. Every permutation is equivalent to a product of transpositions. A simple way to see this is to think of how you might reorder a dozen eggs in an egg carton.