CSE355 Final :(
L(R1*)^rev =
(L(R1)^rev)*
I want to prove that the language {w ∈ {a, b}* : w is a palindrome} is not regular. Which of the following are good choices of a string to pick to show we cannot pump it?
(a^p)bb(a^p).
What is the smallest number of states that a TM could have?
2.
What is the powerset construction about?
Converting an NFA to a DFA.
In the conversion of a PDA with n states to a CFG, the number of STATES created (without doing any simplifications) is:
Impossible to classify without more information.
L(R1 U R2)^rev =
L(R1)^rev U L(R2)^rev
L(R1 o R2)^rev =
L(R2)^rev L(R1)^rev
Can qaccept = qreject in a TM?
No.
Suppose a PDA pushes, but doesn't pop, on every transition. Then the language of the PDA is..?
Regular, since it behaves exactly like an NFA.
The pumping lemma for CFLs writes a long enough string in the language in five parts uvxyz and requires that |vy| ≥1. This requirement can be enforced because in the proof of the pumping lemma:
The grammar has no epsilon rules except perhaps from the start variable.
Suppose we augmented our definition of a TM to include moving right 5 tape cells in a single transition. Then the class of languages ordinary TMs recognize is the same as this augmented model. True or false?
True.
Every TM's starting configuration is..?
Unique.
The question "Does a given DFA accept a given input" is decidable. True or false?
Yes, this is ADFA.
∅* = ?
{ epsilon }
The set of non-context-free languages is closed under?
Apparently nothing?
Let L be a regular language. How many DFAs have language L?
Infinite.
Can a DFA have 0 states?
No since q0 ∈ Q.
How many start states can a DFA have?
1.
In the conversion algorithm as described in class, that converts a CFG into a PDA with the same language, how many final states were in the resulting PDA?
1.
If you have a CFG that is in a CNF, how do calculate how many derivations it'll take to derive a particular string?
2(string length)-1.
Consider the regular expression (ab U baa)*. Consider the NFA that is produced from this regular expression by the algorithm described in class. Without simplifying the NFA, how many states does the NFA have?
AB has 4 states, BAA has 6 states, the union of this adds in an extra state in the beginning for epsilon transitions + 1, the star of this adds a final state for epsilon transition + 1 = 12.
I want to prove that the language {w ∈ {a, b}* : w is a palindrome} is not regular. Which of the following are good choices of a string to pick to show we cannot pump it? Which of the following is a bad choice of string..? [not pictured 2 long]
All of the above are in fact good choices of strings. Good strings = strings able to derive contradiction.
If I have an algorithm that, given two DFAs decides whether or not they have the same language. Then I also have...?
An algorithm, given two regular expressions, decides whether or not they have the same language.
A grammar is context free if all it's productions has form..?
CAPITAL -> sequence non capitals and CAPITALS
What are decidable languages closed under?
Complement, Union, Intersection, Star. Basically what the regular languages are closed under.
PDAs always start computation with an _______ stack.
Empty.
Call a PDA pop-friendly if it can only push, but not pop, on each transition. Then, every PDA can be converted into a pop-friendly PDA with the same language.
False because that's basically an NFA lol
Every non-regular language is infinite. True or False?
False.
Context-free languages are closed under...?
Intersection with regular languages.
My friend still does not understand Chomsky Normal Form (indeed he insists on calling it Chompsky Normal Form). He thinks that every rule that has two symbols on the RHS must have exactly one variable and one terminal rather than just two variables (otherwise he has the definition right). His version is not suitable because
It generates all regular languages and some others, but not all of the CFLs.
How do you convert something into Chomsky normal form?
Make sure that start variable doesn't appear on RHS -> Remove all ε rules -> Remove unit rules (nonterminal going to single nonterminal) -> No mixing terminals and nonterminals on RHS -> Make sure that if anything on the RHS has length 3, create new variable to fix it
Can a Turing Machine have a choice as to whether to move right or left on a given transition?
No, they are deterministic.
Suppose we are given an NFA with δ(q0, ε) = {q1}, δ(q0, a) = {q2}, δ(q1, ε) = {q1}, δ(q2, ε) = {q3}, δ(q3, a) = {q1}, δ(q3, ε) = {q4}. What is E({q0, q2})?
So this notation is supposed to dictate all the things that q0 and q2 go to via ε transitions. Also include themselves. {q0, q1, q2, q3).
My friend is confused about the meaning of ambiguous as described in class. What is the meaning of ambiguous?
Some string in the grammar's language have at least 2 different parse trees (or at least 2 LEFTMOST derivations)
Which of the following is always true about DFA D = (Q, Σ, δ, q0, F)?
Suppose δ(q0, 0) = q1, δ(q1, 0) = q0, and q1 ∈ F. Then D accepts every string entirely consisting of 0's with odd length
The grammar ({S}, {a}, {S -> aS | SS | ε }, S) is a context-free grammar. True or false? Is it in CNF?
True but it is not in CNF.
Every CFL can be recognized by a Turing machine. True or false?
True but not vice versa.
Every decidable language is recognizable, true or false?
True.
Closure under intersection and complementation imply closure under union. True or false?
True. "IC -> U" to help memorize
What are regular languages closed under?
Union, intersection, concatenation, complement, star, reverse, prefix, etc.
What do we do with the resulting N when we star operation them?
We add a new start state (that is also a accepting state) and ε transition it to the old start state. Accepting states also are directed to point at the old start state via ε transition.
What do we do with the resulting N when we concatenate N1 and N2?
We change the accepting states in N1 to regular states and have them ε transition to N2's start states.
What do we do with the resulting N when we union N1 and N2?
We create a new start state that ε transitions into the previous start states.
Suppose I have a CFG, and can guarantee that the longest right-hand side of any rule in the grammar is at most 5 (i.e., variables + terminals), and there are n rules. I want to convert this to an equivalent PDA as described in class. Which of the following is the best upper bound on the number of states that will be in this PDA?
We only need 5n+4 but since that's not in the multiple choice, we 5n+5.
What is the meaning of the statement q2 = δ(q0, a)?
When reading an a in state q0, the next state is q2.
Is every regular language and CFL decidable?
Yes but not vice versa.
Suppose that we have a given fixed string s = s1...sn with each si ∈ Σ. I want to recognize the langauge {w ∈ Σ* : s is a substring of w}. There exists an NFA with x states to recognize this language. What is the smallest possible value of x?
n + 1. We must have n transitions for each character so there must be n + 1 states.
If a DPDA has the transition δ(q, a, x) = (q', y) with a ∈ Σ, x ∈ Γ, then it can also have the transition:
δ(q, epsilon, y) = (q', x) provided x != y and y ∈ Γ.
What is the smallest number of tape symbols that a TM with nonempty input alphabet could have?
2. Since the input alphabet is nonempty, there is at least one. But since the blank symbol is in the tape alphabet but not the input alphabet, we can have 2 symbols
Suppose that I have 2 DFAs and have 7 and 6 states respectively, and 3 and 4 final states respectively. If I built the product DFA for the UNION of their languages. How many final states will the resulting DFA have?
3 * 6 = 18. 4 * 7 = 28. 18 + 28 - (3 * 4) = 34.
Suppose that I have 2 DFAs and have 7 and 6 states respectively, and 3 and 4 final states respectively. If I built the product DFA for the INTERSECTION if their languages. How many final states will the resulting DFA have?
4 * 3 = 12.
Total function is defined as...?
A function that has a defined value for all possible input values.
The set of non-regular languages is closed under which of the following operations?
Complement.
Suppose a PDA pops, but doesn't push, on every transition. Then the language of the PDA is..?
Context free and regular since it can never execute a transition like this.
Stacks have been getting very expensive lately! I want to limit the stack size of a PDA to be at most 25 to save cost; call the machines that have this property RPDAs. This model works exactly as a normal PDA does, but if the stack has height 25 and on the next transition does not pop and does push, the computation immediately stops. What is the relation between the class of languages PDAs recognize and those that RPDAs recognize?
Every language a RPDA recognizes, a PDA also recognizes, but not vice versa.
Suppose we have a DFA D = (Q, Σ, δ, q0, F) and know that D accepts every string. What can we infer about D?
Every reachable state from q0 is a final state.
My Turing Machine is broken! It can only move left, at most, 5 times in the course of computation on any input! Consider all TMs that have this property. What languages do they recognize?
Exactly the regular languages because there are finitely many possibilities of what can happen here
If a regular language L has the property that L = L U L, then L is finite. True or false + explain.
False because think of Σ*.
The number of states in a PDA can be 0. True or false?
False since q0 ∈ Q, Q cannot be empty.
If a language is not context-free, then every subset of it is also not context-free.
False.
The alphabet of a DFA must have cardinality at least 1. True or false?
False.
We say that a state qj is unreachable from state qi if there does not exist a path from qi to qj. Suppose I have 2 DFAs, both with unreachable states from the start state. If we perform the product construction on these DFAs, then the resulting DFA will have no unreachable states from its start state. T or F?
False.
Closure under intersection and union imply closure under complementation. True or false?
False. "IU -> C" to help memorize
Let A, B, C be any regular expressions. Then A(B ∪ C) = (A ∪ B)(A ∪ C). True or false?
False. A(B U C) = AB ∪ AC.
PDAs always end computation with an empty stack, true or false?
False. The stack isn't required to be empty to accept.
If a language is context-free, then every subset of it is also context-free. True or false?
False. Σ* is an example.
If a regular expression is star-free then L(R) is...?
Finite.
My friend believes that we can convert a DFA into an equivalent PDA as follows: everything remains the same as the DFA except for every transition labelled a in the DFA, we augment the transition to be a,ε → ε between the same pair of states. Is his idea correct?
His idea is correct because DFAs are just PDAs that ignore its stack
How can you tell if a language is not context-free?
If there are more than 1 comparison like 0<=n<=m<=s.
My friend is interested in computations of machines, and wants to see if he can find a "repeating" pattern during such a computation. Formally, observe the language {#w1#w2...#wk# : wi ∈ {0, 1}(, and for some i != j, wi = wj}. My friend believes that this language is context-free. Is it?
It is not context-free because the string #0p1p#0p1p # pumps out of the language and therefore shows the necessary contradiction.
My friend does not like the conversion process from an NFA to DFA, as it takes too long. He wants to, given two NFAs N1 and N2, to produce an NFA for L(N1) ∩ L(N2). Since he is in a hurry he wants to make an NFA for their intersection with |Q1| x |Q2| states. His method to produce an NFA N is as follows: [not pictured 2 long]
It is true because one can observe computations in the original two machines and see that if one existed for them, then one exists for the new machine (and vice versa).
What does the pumping lemma do?
It proves by contradiction that a language is not regular.
Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages to create L(D). If L(D1) = ∅...then what is true about the result L(D)?
L(D) = L (D2).
The pumping lemma for CFLs writes a long enough string in the language in five parts uvxyz and requires that |vxy|≤ p. This requirement can be enforced because in the proof of the pumping lemma we chose a repeated variable on a ...?
Longest root to leaf path that is furthest from the root.
A regular expression is productive if it does not contain the symbol ∅ anywhere in the expression. Call the complexity of a regular expression R, c(R), to be the number of operators appearing in the expression. For example, c(a ∪ a) = 1, c((a ∪ b)*) = 2. My friend thinks that if R is a productive regular expression, then there exists a w ∈ L(R) with |w| <= c(R) + 1. Is my friend correct?
My friend is correct because we can look at the definition of regular expressions and define c(R) in terms of those.
Suppose I perform the product construction on two DFAs D1, D2 to get a DFA with language L(D1) ∩ L(D2). However, I forgot to mention that I needed L(D1) ∪ instead. My friend says that I will need to perform the product construction again to get what I am looking for. Is my friend correct, and why/why not?
My friend is not correct because what we want complement[complement(L(D1)) ∩ complement(L(D2))] and regular languages are closed under complement.
A configuration of the machine might have infinite length because the tape is infinite in a TM. Is this true?
No.
If R is a union-free regular expression, then is L(R) finite?
No.
Suppose I have a CFG (not necessarily in CNF) and a string of length 5 in its language. What can I tell about a derivation of this string in the grammar?
Nothing cause the # of derivations can be infinite since it's not in CNF.
In the conversion of a PDA with n states to a CFG, the number of VARIABLES created (without doing any simplifications) is:
O(n^2) but not a constant independent of n.
What is Q in (Q, Σ, δ, q0, F)?
Q describes all the states such as Q0, Q1, etc.
In a DPDA, suppose we allow only transitions that can do only one of pop, push, and read. To break up a transition that does all three we should:
Read then pop then push
The sharing of two languages L1, L2 is the set of all strings that are in both or neither of L1 and L2. If L1 and L2 are regular, then the sharing of L1 and L2 is...?
Regular. Since regular languages are closed under intersection, union, and complement
What step can be skipped when converting a regular grammar to a CNF. EMPHASIS ON REGULAAAAR
Step 5 (since regular grammars have longest length 2).
Consider the DFA used in the proof of the pumping lemma: we chose a string long enough so that it is accepted by the DFA and repeats a state. What if such a string happens to not exist for this DFA?
The DFA's language must be finite.
Suppose that we have an NFA and a input string. How many computations, not necessarily accepting, are there of the machine on that string?
The answer depends on the machine and string.
What is Σ in (Q, Σ, δ, q0, F)?
The inputs such as 0, 1, etc.
For some reason, my friend doesn't like odd numbers. Suppose he want every accepting computation of every string to consist of an even number of transitions; call machines that have this property EPDAs. If a computation enters an accept state and has read all of the input, the machine may still not accept because there possibly have been an odd number of transitions applied. What is the relation between the class of languages PDAs recognize and those that EPDAs recognize?
They are exactly the same.
Transitions that read a character off the input are very tiresome, so we want to allow "breaks" between them. I want every accepting computation of every string to consist of at least 1 ε transition between each character read from the input (I'm not worried about what happens on the stack here). Call these machines HPDAs. What is the relation between the class of languages PDAs recognize and those that HPDAs recognize?
They are exactly the same.
For any regular language L, there is an NFA with exactly 1 final state with language L. True or false.
True.
If L is not context-free, F is a finite language with empty intersection with L, and L' = L U F, then L' is also not context free.
True.
In the formal definition of a PDA, we cannot swap the order of push and pop in the transition function; we must allow popping before pushing, instead of pushing before popping. True or false?
True.
Suppose I have an algorithm to test if a given CFG accepts some input. Therefore, I also have an algorithm to test if a given PDA accepts some input.
True.
Suppose a PDA pushes or pops, but doesn't do both or neither, on every transition. Then the language of the PDA is context-free, but not necessarily regular. True or false?
True.
The language {ww: w ∈ Σ*} with |Σ| > 2 is not regular. True or False?
True.
When an NFA M is converted to a DFA M', only adding states as needed, M' may have more, fewer, or the same states than M does. T or F?
True.
Every regular language is a context-free language?
True. BUT NOT VICE VERSA.
Call a PDA strict if it can only do exactly one of its push or pop operations on each transitions. Then, every PDA can be converted into a strict PDA with the same language. True or false?
True. For the transitions that neither push nor pop, you basically just create a new state to push an arbitrary symbol and then ya pop it.
Do MSNFAs recognize the same languages as NFAs? If so, why?
Yes because we can add an extra start state with ε transitions to all the old start states to get an NFA with the same language.
Can a DFA have 0 final states?
Yes! It doesn't necessarily have to accept or reject as it can be a transducer.