CSE 355 Final Exam

Ace your homework & exams now with Quizwiz!

Suppose that I have two DFAs and have 5 and 4 states respectively, and 2 and 3 final states respectively. The number of final states in the product DFA for the union of their languages is

17

What is the smallest number of states that a TM could have?

2 - since q_accept is not equal to q_reject, there must be at least two. Note there is nothing to prohibit q0 from being either state

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 two DFAs and have 5 and 4 states respectively, and 2 and 3 final states respectively. The number of states in the product DFA for the intersection of their languages is

20

Suppose I have a CFG, and can guarentee that the longest right hand side of any rule in the gammer is at most 5 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

5n + 5

Suppose that a Turing Machine is run on an input. Which of the following is false?

A configuration of the machine must have infinite length because the tape is infinite True answers: - Infinitely many configurations of the machine can occur - If a configuration of the machine arises twice in a computation on this input, the machine enters an infinite loop - every configuration contains exactly one state of the machine - configurations are used to define the language that the machine recognizes

The statement ANFA <= ADFA means

ANFA reduces to ADFA

Non-regular languages are closed under

Complement

Under what operations are recognizable languages NOT closed

Complement

My friend does not believe the fact that ATM is undecidable because he says that he can tell whether his program is in an infinite loop on a given input. Suppose that my friend has a specific program M and a specific input w. He defines the language L = {0} if M halts on input w and L = {1} if M goes into an infinite loop on input w. Then L is

Decidable because L is regular

Under what operations are decidable languages NOT closed

Decidable languages are closed under all of the following: a) Complement - swap q_accept and q_reject b) Union - run both machines and accept if either says accept, otherwise reject c) Intersection - similar to union d) Star - for all possible decomposition of the input, run all decomposition on the decider, and accept if at least one decomposition has all of its parts be accepted. Otherwise, reject

Consider the problem of determining, from a given PDA, whether the PDA has infinite language or not. Is this decidable? Why or why not?

Decidable: because of the pumping lemma for CFLs

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 recognizes, but not vice versa

In the conversion algorithm described in class, that coverts a CFG to a PDA with the same language, how many final states were in the resulting PDA?

Exactly 1

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-freindly PDA with the same language.

False

If a language is not context-free, then every subset of it is also not context free

False - Any non-context-free language is a counterexample (in fact, this is always false)

The language {a^i b^j c^k : 0 <= i <= j <= k} is context free

False - Choose 0^p 1^p 2^p and pump accordingly. Pump down if either v or y contains a 2. But in all other cases, we can pump up to get out of the language

Every decidable language is a CFL

False - Many counterexamples, including {0^n 1^n 2^n : n >= 0}

Suppose a PDA pops, but doesn't push on every transition. Then the language of the PDA is context-free, but not necessarily regular.

False - The PDA can never execute a transition. Therefore, its language is either empty set or empty string and it is regular in both cases

Suppose a PDA pushes, but doesn't pop on every transition. Then the language of the PDA is context-free but not necessarily regular

False - The PDA might as well ignore its stack since it cannot inspect the stack. Therefore its language is always regular since it behaves like an NFA.

The language {w ∈ {a, b}* : the number of occurrences of ab in w is the same as that of ba in w} is not regular

False - This language is another way of asking that w starts and ends with the same character, or is epsilon, and one can make a DFA for that

PDAs always end computation with an empty stack

False - by definition

If a language is context-free, then every subset of it is also context-free

False - sigma star is a counter example

The number of states in PDA can be 0

False - since q0 is in Q, Q cannot be empty

Every language that a Turing Machine can recognize is a CFL

False - we made TM for 0^n 1^n 2^n : n >= 0 in class

SUBPDA = {<M1, M2> | M1 and M2 are PDAs and L(M1) is a subset of L(M2)} is decidable

False -ALLCFG (and hence ALLPDA) is undecidable. We make a decider for ALLPDA using supposed decider D for SUBPDA as follows: on input a PDA M, first construct a PDA P that accepts sigma star, and feed <P,M> to D. The answer that D gives is what the decider for ALLPDA would say.

There is a language that is decidable and its complement is not decidable

False -Decidable languages have closure under complement

The problem of whether a given TM has at least 355 string in its language or not is decidable

False -Rice's Theorem

Rice's theorem states that many languages are not recognizable

False -Should be "not decidable"

A Turing Machine can have a choice as to whether to move right or left on a given transition

False -TMs are deterministic

There is an enumerator that has a language that is not recognizable

False -We showed in class that enumerable and recognizable languages are equivalent

The problem of determining whether a TM has at least 7 states is undecidable

False -this is decidable

My friend believes that we can convert a DFA except for every transition labelled a in the DFA, we augment the transition to be a, eps -> eps between the same pair of states. Is his idea correct?

His idea is correct because DFAs are just PDAs that ignore the stack

In the conversion of a PDA with n states to a CFG, the number of rules created (without doing any simplifications) is

Impossible to classify without more info

Let L be a regular language. How many DFAs have language L?

Infinitely Many

Randomness is very useful, but normal TMs don't have this property. So, let a Random Turing Machine (RTM) be a machine model like a normal TM where each transition has a certain probability of being executed. For a given state, and given tape symbol, there may be several possible transitions that can be executed; but the sum of their probabilities is always 1, and only one of those transitions is executed (and the transition is picked randomly based on the probabilities of the transitions). For example, we could have two transitions from the same state on the same tape symbol read, one with probability 0.7 and the other with 0.3; the first will be executed with 70% probability, and the other with 30%. Of course, if we feed the input to the machine several times, the answer of whether it accepts or not may change each time. We say that a string is accepted by an RTM if there is at least one computation that accepts that string, and the language being the set of all strings that are accepted by the RTM. How do the languages that RTMs recognize compare to that of the standard model?

It is equivalent because we can create a TM for all possible choices of each transition being present or absent, and run all machines simultaneously (and we accept if and only if at least one of the machines accepts)

I have a Turing Machine variant called the End Jumper - the model is exactly the same as a normal TM, except that a special instruction (in addition to L and R) that moves the tape head, in a single transition, to the cell directly after the last non-blank cell on the tape. How does this variant compare to usual Turing Machines.

It is equivalent because we can mark the furthest right non-blank cell on the tape and maintain it through the course of computation

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 not equal to j, wi = wj} My friend believes this language is context-free. Is it?

It is not context free because #0^p 1^p # 0^p 1^p # pumps out of the language

Which of the following statements is correct about the language {0^i 1^(i+j) 2^j : i, j ≥ 0}?

It is not regular, but it is context free

My Turing Machine is broken (again)! It is never allowed to move past the end of where the input is! this of it as a tape that has two ends, instead of one (as is in the standard model). Consider all TMs that have this property. What languages do they recognize

It's not exactly the CFLs because {0^n 1^n 2^n : n ≥ 0} is recognized by a TM in this model. We get all of the CFLs as well (CFG in CNF?). However, we do not get all of the decidable languages. Define the language A = {<B> | B is a TM in this model and <B> is not in L(B)} Suppose A were decided by a machine M in this model. If <M> ∈ L(M), then <M> ∈ A, proving that <M> is not in L(M). If <M> is not in L(M), then <M> is not in A, proving that <M> ∈ L(M). Since a contradiction is reached, A is not decided by any TM in this model. This may seem like a contradiction for normal TMs. However, we can decide A as follows: if the tape head ever moves past the end of where the input is, reject. Suppose there are q states, k tape symbols, and the input was of length n. The total number of configurations is kqk^n. If on the (kqk^n + 1)-th transition the machine has not accepted or rejected yet, it has repeated a configuration, and hence is in an infinite loop. Therefore, we can decide the acceptance problem for this model.

The set of non-context free languages is closed under which of the following

NONE (none of complement, union, intersection, or concat)

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, the derivations can be arbitrarily large or even infinite

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 - we always make exactly n^2 states

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

Consider the CFG used in the proof of the pumping lemma. We chose a string long enough so that it is accepted by the CFG and repeats a variable. What if such a string does not exist for this CFG?

The CFG's language must be infinite

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 does not exist for this DFA?

The DFA's language must be finite

Suppose I have a CFG in CNF and a string of length 5 in its language. What can I tell about a derivation of this string in the grammar?

The derivation involves exactly 9 applications - 2n - 1 derivations in CNF

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

Anaconda corporation has announced a new product that, when given a Python program P has input, can determine whether P can go into an infinite loop on any input. Which of the following is true?

Their product does not work because Turing Machines can be converted to Python programs

For some reason, my friend doesn't like odd numbers. Suppose he wants 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 epsilon-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

Call a PDA strict if it can do exactly one of its push or pop operations on each transition. Then, every PDA can be converted into a strict PDA with the same language.

True

Call a regular expression star-free if it does not contain any occurrences of the * operation. If R is a star-free regular expression, then L(R) is finite

True

Context-free languages are closed under intersection with regular languages

True

FINITEDFA = {<M> | M is a DFA with finite language} is decidable

True

The language {w ∈ {a, b}* : the number of occurrences of a in w is the same as that of b in w} is not regular

True

The language {ww : w ∈ Σ*} with |Σ| ≥ 2 is not regular

True

The question "Does a given DFA accept a given input" is decidable

True - ADFA

Suppose I want to convert a regular grammar into CNF. Because we start with a regular grammar, one of the 5 steps of the CNF algorithm can be skipped

True - It turns out we can skip Step 5 (breaking up long RHSes) since the longest rule in a regular grammar has at most two variables/terminals on the RHS.

The language {a^i b^j : 0 <= i <= j <= 2i } is context free

True - One can make a CFG for it by appending the rule S -> aaSb to the grammar for {a^n b^n : n >= 0}. This ensures that the number of bs is at least the number of a's but at most twice.

Suppose I have an algorithm to test if a given CFG accepts some input. Therefore, I have an algorithm to test if a given PDA accepts some input

True - PDAs can be converted to CFGs

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 - Suppose L' were context-free. Then we can rewrite the statement as L = L = L'\F, only on the assumption that L, F have empty intersection. Now, since F is finite, it is regular. So L'\F = L intersect (complement of F) is context free. But L is not context free.

Every decidable language is recognizable

True - by definition

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

True - by definition

PDAs always start computation with an empty stack

True - by definition

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 - like a step-conversion from a PDA to a CFG, so it is true

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 mondel

True - to simulate a "5-right" transition, just add 5 consecutive transitions that move right

Every CFL is decidable

True - we can convert to a CFG in CNF, and use the algorithm outlined in class

Every regular language is decidable

True - we can simulate a DFA using a TM

There is a language that is recognizable and its complement is not recognizable

True -ATM is an example

Every TM's starting configuration is unique

True -By referring to a "configuration" by definition this refers to some input string w. Since TM's starting state is defined, and the input string is defined, there is exactly 1 starting configuration.

The problem of determining whether a TM accepts at least 7 strings is undecidable

True -Rice's theorem

Every CFL can be recognized by a Turing Machine

True -Convert the CFG for the language into CNF -try all 2n-1 derivations of the input string -If any are the input string itself, accept

There is a recognizer that has an undecidable language

True (ATM)

My friend is curious about the language L = {<M> : M is a TM and accepts 3 strings}. Is this language decidable? Why or why not?

Undecidable: We can construct a decider for ATM assuming a decider for this language - this can be done using Rice's Theorem

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

For a given TM and input, consider the language of accepting computation histories of that TM on that input. Then this language is a) Decidable because in all cases this language is finite b) Decidable because we can simulate the TM until it halts c) Undecidable because it we can find out if this language is empty or not, we can solve the acceptance problem for TMs d) Undecidable because determining computation histories is undecidable, so accepting computation histories is also undecidable e) None of the above

a) Decidable because in all cases this language is finite

The acceptance problem for LBAs is a) Decidable because we can detect an infinite loop in a finite amount of time b) Decidable because there cannot actually be an infinite loop in an LBA c) Undecidable because this is just the acceptance problem for TMs but for a restricted class of them d) Undecidable because we can reduce from the emptiness problem for LBAs which is undecidable e) None of the above

a) Decidable because we can detect an infinite loop in a finite amount of time

My Turing Machine is broken! It can only move left, at lost, 5 times in the course of computation on any input! Consider all TMs that have this property. What languages do they recognize?

a) Exactly the regular languages - There are finitely many possibilities of what can happen here (in terms of moving left), so we model each as a state with transitions according to what character was read moving left

I want to prove that the language {w ∈ {a, b}* : w is a palindrome} is not regular. Which is a good string to pick?

a^p b b a^p

On input string w ∈ Σ*, the number of computations of an NFA (Q, Σ, δ, q0, F) is always

at least 1 if the NFA accepts w

The problem of deciding whether a given TM accepts some string of length 5 is a) Undecidable because if a decider existed, then one can decide whether or not a DFA has an empty language b) Undecidable because of Rice's Theorem c) Decidable because we can just test all strings of length 5 simultaneously and see if any accept d) Decidable because we can decide it using a decider for the acceptance problem for LBAs e) None of the above is true

b) Undecidable because of Rice's Theorem

My friend wants to apply Rice's theorem to the language {<M> : M accepts epsilon and has at least 5 states}. I note that he cannot apply Rice's theorem for this language. What is the reason why he cannot?

b) because this language is not a property of the language of TMs

A generalized NFA, or GNFA

can have transitions labelled with ∅ or ∅*

(empty set)* = empty set

false - (empty set)* = empty string (epsilon)

If DFA M = (Q, Σ, δ, q0, F) accepts the input string w on Σ* with |w| = n, a computation of M on w

is a sequence of exactly n + 1 states

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 CFLs

If NFA M = (Q, Σ, δ, q0, F) accepts the input string w on Σ* with |w| = n, a computation of M on w

may be a sequence of any integer number of states that is at least n + 1

{a^n b^m : n > m ≥ 0} is

not regular because a^(p+1)b^p cannot be pumped

The pumping lemma for regular languages can be proved by

showing that a DFA computation must repeat a state.

Regular operations

star, union, concat

For an NFA M = (Q, Σ, δ, q0, F) and a subset S ⊆ Q, which of the following is not always true about the ε closure E(S)?

there is no ε transition from a state not in E(S) to a state in E(S)

Every non-regular language is infinite

true

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 ∈ Γ


Related study sets

Chapter 12 Some Lesson from Capital Market

View Set

Social Media Marketing Final Study Guide

View Set

Unit 3 - Chapter 4: Color Theory and Application

View Set

Chapter 23: Question 61 + all true and false

View Set

Enrichment Activity 26; The Cost of War

View Set

conceptual questions physics exam 3

View Set