What happens if a player makes an illegal move and nobody notices? What happens if a player makes an illegal move (i.e. a realistic case could be, he castles after he already moved the King), but none of the player notices, and the game goes on and on for a lot of moves? Is the final result to be taken as valid? On another note, what happens if a player, after some moves, realizes that, say, move 10 was illegal, and could not be made?
The FIDE laws of chess state:


  If during a game it is found that an illegal move, including failing
  to meet the requirements of the promotion of a pawn or capturing the
  opponent’s king, has been completed, the position immediately before
  the irregularity shall be reinstated. If the position immediately
  before the irregularity cannot be determined the game shall continue
  from the last identifiable position prior to the irregularity. The
  clocks shall be adjusted according to Article 6.13. The Articles 4.3
  and 4.6 apply to the move replacing the illegal move. The game shall
  then continue from this reinstated position.


So basically the game should be reverted to before that move, using the game record.

Edit: These are for standard play. Other time controls have different rules, and although most national federations basically just apply the FIDE rules, they can sometimes be different.