this is a homework for theory of computation.