Problem 7
(a) *Find a simple Nondeterministic Finite Automaton (NFA) accepting ( (a \cup b)^aab ).
To construct an NFA that accepts all strings over the alphabet (\Sigma = {a, b}) ending with the suffix "aab", we can use the following design:
States:
- ( q_0 ): Start state
- ( q_1 ): After reading first 'a'
- ( q_2 ): After reading second 'a'
- ( q_3 ): After reading 'aab' (accepting state)
Transitions:
- From ( q_0 ):
- On 'a', transition to ( q_0 ) (loop back to ( q_0 )).
- On 'b', transition to ( q_0 ) (loop back to ( q_0 )).
- On 'a', transition to ( q_1 ) (start matching the suffix).
- From ( q_1 ):
- On 'a', transition to ( q_2 ) (matched 'aa').
- From ( q_2 ):
- On 'b', transition to ( q_3 ) (matched 'aab').
- From ( q_3 ):
- No outgoing transitions (accepting state).
Explanation:
- The NFA begins at ( q_0 ) and loops on 'a' and 'b', accepting any number of characters.
- When an 'a' is read, it can nondeterministically decide to transition to ( q_1 ) to begin matching the "aab" suffix.
- If "aab" is successfully read following the rules, the NFA reaches the accepting state ( q_3 ).
How to Draw the NFA on Paper:
- Draw four circles (states): Label them ( q_0 ), ( q_1 ), ( q_2 ), and ( q_3 ).
- Mark ( q_0 ) as the start state: Draw an arrow pointing to ( q_0 ) from nowhere.
- Add loops on ( q_0 ):
- Draw an arrow from ( q_0 ) back to itself labeled with 'a' and 'b'.
- Add transitions for matching 'aab':
- From ( q_0 ), draw an arrow to ( q_1 ) labeled 'a'.
- From ( q_1 ), draw an arrow to ( q_2 ) labeled 'a'.
- From ( q_2 ), draw an arrow to ( q_3 ) labeled 'b'.
- Mark ( q_3 ) as the accepting state: Draw a double circle around ( q_3 ).
(b) Convert the NFA to a Deterministic Finite Automaton (DFA) using the subset construction method.
States of the DFA:
Each state in the DFA represents a subset of NFA states. The reachable subsets from the start state are:
- ( S_0 = { q_0 } ): Start state
- ( S_1 = { q_0, q_1 } )
- ( S_2 = { q_0, q_1, q_2 } )
- ( S_3 = { q_0, q_3 } ) (accepting state because it contains ( q_3 ))
Transitions:
- From ( S_0 ):
- On 'a', go to ( S_1 ).
- On 'b', stay in ( S_0 ).
- From ( S_1 ):
- On 'a', go to ( S_2 ).
- On 'b', go to ( S_0 ).
- From ( S_2 ):
- On 'a', stay in ( S_2 ).
- On 'b', go to ( S_3 ).
- From ( S_3 ):
- On 'a', go to ( S_1 ).
- On 'b', go to ( S_0 ).
Explanation:
- We start with the singleton set ( { q_0 } ) and compute the transitions based on the NFA's transitions.
- Each DFA state represents a combination of possible NFA states the machine could be in after reading input.
- An accepting DFA state is any that includes the NFA's accepting state ( q_3 ).
How to Draw the DFA on Paper:
- Draw four circles (states): Label them ( S_0 ), ( S_1 ), ( S_2 ), and ( S_3 ).
- Mark ( S_0 ) as the start state.
- Add transitions:
- From ( S_0 ):
- Draw an arrow to ( S_1 ) labeled 'a'.
- Draw a loop back to ( S_0 ) labeled 'b'.
- From ( S_1 ):
- Draw an arrow to ( S_2 ) labeled 'a'.
- Draw an arrow back to ( S_0 ) labeled 'b'.
- From ( S_2 ):
- Draw a loop back to ( S_2 ) labeled 'a'.
- Draw an arrow to ( S_3 ) labeled 'b'.
- From ( S_3 ):
- Draw an arrow to ( S_1 ) labeled 'a'.
- Draw an arrow back to ( S_0 ) labeled 'b'.
- Mark ( S_3 ) as the accepting state: Draw a double circle around ( S_3 ).
Problem 10
Show that the language ( \text{ADD} = { x + y = z \mid x, y, z \text{ are binary integers, and } z \text{ is the sum of } x \text{ and } y } ) is not regular.
Proof by Contradiction using the Pumping Lemma:
- Assumption: Suppose, for contradiction, that ADD is a regular language.
- Pumping Lemma: Since ADD is regular, there exists a pumping length ( p \geq 1 ) such that any string ( s ) in ADD with ( |s| \geq p ) can be divided into three parts ( s = xyz ) satisfying:
- ( |xy| \leq p )
- ( |y| \geq 1 )
- For all ( i \geq 0 ), ( x y^i z \in \text{ADD} ).
- Choose a String ( s \in \text{ADD} ):
- Let ( s = 1^p + 1 = 1 0^p ).
- ( x = \underbrace{1^p}_{\text{first operand}} )
- The '+' and '=' symbols are part of the fixed format.
- ( y = 1 ) (the second operand, which is just '1')
- ( z = 1 0^p ) (the sum, representing ( 2^p ))
- Divide ( s ) into ( xyz ):
- Since ( |xy| \leq p ) and ( |y| \geq 1 ), the string ( y ) must consist of at least one '1' from the first operand.
- So ( y ) is a substring of the initial sequence of '1's.
- Pump ( y ) Down (Let ( i = 0 )):
- Remove ( y ) to get ( s' = x z ).
- The new first operand becomes ( 1^{p - |y|} ).
- The rest of ( s ) remains unchanged.
- Analyze ( s' ):
- Original equation: ( 1^p + 1 = 1 0^p ) represents ( (2^p - 1) + 1 = 2^p ).
- Pumped-down equation: ( 1^{p - |y|} + 1 = 1 0^p ) represents ( (2^{p - |y|} - 1) + 1 = 2^p ).
- Simplifies to ( 2^{p - |y|} = 2^p ), which is false unless ( |y| = 0 ), but ( |y| \geq 1 ).
- Contradiction:
- Therefore, ( s' \notin \text{ADD} ), which contradicts the pumping lemma.
- Conclusion:
- The assumption that ADD is regular must be false.
- Hence, ADD is not a regular language.
Summary:
By carefully choosing a string ( s ) in ADD and showing that pumping ( y ) violates the conditions of ADD, we conclude that ADD cannot be a regular language.