# Theory of Computation: Question Set – 12

#### What is the pumping lemma for regular languages, and how is it used to prove that a language is not regular?

The pumping lemma for regular languages is a property that all regular languages must satisfy. It states that for any regular language L, there exists a pumping length p such that any string s in L with length greater than or equal to p can be decomposed as s = xyz, where |y| > 0 and |xy| ≤ p, and the strings xyiz are also in L for all i ≥ 0. If a language fails the pumping lemma, then it cannot be a regular language.

#### What is the Myhill-Nerode theorem, and how is it used to determine if a language is regular?

The Myhill-Nerode theorem is a method for determining if a language is regular by examining the set of distinguishable strings. Two strings x and y are distinguishable if there exists a string z such that exactly one of the strings xz or yz is in the language. The theorem states that a language is regular if and only if the set of distinguishable strings is finite.

#### Can a finite automaton recognize the language {w | w contains an even number of 0s or an odd number of 1s}? If so, how can it be constructed?

Yes, a finite automaton can recognize the language {w | w contains an even number of 0s or an odd number of 1s}. The automaton can have two states, one for when an even number of 0s have been seen and another for when an odd number of 1s have been seen. The initial state is the one for even 0s, and transitions are made based on the input symbol. For example, on input symbol 0, the automaton transitions from the even 0s state to the odd 1s state.

#### Can a finite automaton recognize the language {w | w is a palindrome}? If so, how can it be constructed?

Yes, a finite automaton can recognize the language {w | w is a palindrome}. The automaton can have a state for each possible length of a palindrome, and the transitions can be based on the input symbols. For example, if the automaton is in the state for palindromes of length 3 and the input symbol is a, it transitions to the state for palindromes of length 4.

#### What is the difference between an accept-by-final-state and an accept-by-empty-stack automaton?

An accept-by-final-state automaton is a finite automaton that accepts a language by having one or more final states that indicate whether a string is in the language. An accept-by-empty-stack automaton is a pushdown automaton that accepts a language by having an empty stack at the end of the input string. Accept-by-final-state automata are a subset of accept-by-empty-stack automata, as pushdown automata can recognize languages that cannot be recognized by finite automata.

#### What is the difference between a regular language and a context-free language?

A regular language is a language that can be recognized by a finite automaton or a regular expression, while a context-free language is a language that can be recognized by a pushdown automaton or a context-free grammar. Context-free languages are more expressive than regular languages and can recognize more complex patterns, such as nested structures.

#### How can a nondeterministic finite automaton be converted to an equivalent deterministic finite automaton?

A nondeterministic finite automaton can be converted to an equivalent deterministic finite automaton using the subset construction. The idea is to represent each subset of states of the NFA as a single state in the DFA, and to compute the transitions of the DFA based on the transitions of the NFA.

#### Can a nondeterministic finite automaton recognize any language that a deterministic finite automaton can recognize?

Yes, a nondeterministic finite automaton can recognize any language that a deterministic finite automaton can recognize. This is known as the equivalence of DFAs and NFAs.