Decision Problems for Automata and Grammars