Formal Language & Automata Theory Exam
Formal Language & Automata Theory Exam
The Church-Turing thesis posits that any function which can be computed by a mechanical process can also be computed by a Turing machine, providing a foundational notion of what it means to compute. Its implications on NP-complete problems are profound as it suggests that these problems, which are solvable by a non-deterministic polynomial-time Turing machine, cannot, for now, be efficiently solved (i.e., in polynomial time) by a deterministic Turing machine; if one NP-complete problem is resolved efficiently, all of them can be, leading to insight into the central P vs NP question, an unsolved problem in computer science .
To design a PDA for the language {wcw^T | w={a, b}*}, the machine first pushes each symbol of the string w onto its stack until the midpoint character 'c' is reached. Upon reading 'c', the PDA shifts to a state where it pops a symbol from the stack each time it reads a corresponding symbol in the reversed segment w^T on the input tape. The PDA accepts the string if, upon consuming the whole input, the stack is empty and the input has been fully processed. This ensures that for every input character before 'c', a matching character is present after 'c' .
Ambiguity in grammar refers to a situation where a single string can be generated by a grammar in more than one way, leading to multiple parse trees. This can occur when different sequences of production rule applications result in the same terminal string. An example of an ambiguous grammar is one that describes arithmetic expressions, such as S -> S + S | S * S | (S) | a. The string 'a + a * a' can be parsed in two different ways, either interpreting the expression as '(a + a) * a' or 'a + (a * a)', thereby demonstrating its ambiguity .
A Pushdown Automaton (PDA) is typically used instead of a Finite Automaton (FA) where the language requires more computational power to be described, specifically when the language includes nested structures. Examples include balanced parentheses expressions or languages requiring memory of unbounded size such as L = {0^n 1^n | n ≥ 1}. PDAs utilize a stack memory which allows them to store an unbounded number of symbols and recall them as needed, providing necessary context-sensitive parsing capabilities unattainable by FAs .
Type-2 grammars, known as context-free grammars, are defined by production rules that substitute a single non-terminal symbol with a sequence of terminals and/or non-terminals. They are more expressive than Type-3 grammars, which are regular grammars that have rules restricted to a single non-terminal on the left side and a terminal possibly followed by a single non-terminal on the right side. This restriction makes Type-3 grammars less powerful, unable to describe languages requiring recursive deeper structures, such as nested parentheses, which Type-2 grammars can handle effectively .
Null productions (productions that derive an empty string ε) and unit productions (productions where a non-terminal maps directly to another non-terminal) can complicate the parsing process. Their elimination is significant for converting grammars into normal forms like Chomsky Normal Form (CNF), which require simplification of the production rules. Managing these involves rewriting the grammar such that these productions do not exist; typically, we introduce alternative rules or auxiliary variables to maintain the language expressed without directly using null or unit operations. This aids in the efficient parsing and simplification required for theoretical analysis and practical applications .
Designing a Turing Machine for the language {0^n 1^n | n ≥ 1} involves creating states that will ensure each '0' is paired with a '1'. Initially, the machine scans from left to right to replace the first '0' found with a special marker (such as 'X'), then it searches for the nearest '1', replacing it with another special marker (such as 'Y'). This process repeats by returning to the start of the tape, each time moving a '0' to an 'X' and its corresponding '1' to a 'Y', until all '0's and '1's are marked. If, at the end of this process, equal numbers of 'X's and 'Y's exist and no unmatched '0's or '1's remain, the string is accepted .
To prove the identity P + PQ*Q = a*bQ*, we first express P in terms of its components: P = b + aa*b. By substituting this back into the expression, we consider separate cases: P represents sequences which are either 'b' or of the form 'aa*b', and Q can essentially be any regular expression extending strings. Hence, by concatenating P and Q, we address scenarios of sequence builds starting from this formal setting. The identity holds by considering how concatenation and union operate distributively over string sets, maintaining the underlying logic of pattern formation while matching introduced expressions on both sides .
The key differences between a DFA and an NDFA lie in their state transition mechanisms. In a DFA, for each state and input symbol, there is exactly one transition to a subsequent state. This means that the DFA does not allow for any ambiguity regarding the state transition process. In contrast, an NDFA can have zero, one, or multiple transitions for a given state and input symbol which allows it to handle multiple possibilities for state transition simultaneously . Furthermore, an NDFA can include epsilon transitions which allow it to change states without consuming any input symbols, while a DFA cannot include such transitions.
To convert a Moore machine into a Mealy machine, each state in the Moore machine is represented by an equivalent state-output combination in the Mealy machine. In a Moore machine, outputs depend solely on the current state, while in a Mealy machine, outputs depend on both the state and input. The conversion involves modifying the output function so that it associates the appropriate outputs with each input-state pair in the Mealy machine. An example is to consider a Moore machine with states that emit outputs based on their current state; the equivalent Mealy machine will have transitions that combine the state and current input for output determination .