CS 456 Automata

¡Supera tus tareas y exámenes ahora con Quizwiz!

The Dyck language is regular

False

Known to be P-space, but not known to be NP.

The puzzle Rush Hour

Let F(0) = 1, and let F(n) = 2^F (n−1) for n > 0. Then F is recursive

True

Let L be the language over Σ = {a, b, c, d} consisting of all strings of the form a^n b^m c^p d^q , where 0 ≤ n ≤ q and 0 ≤ m ≤ p. Then L is a context-free language.

True

NC

examples: The language of all monotone increasing sequences of arabic numerals for positive integers. (For example, "1,5,23,41,200,201" is a member of that language.) The language accepted by a given DFA. The set of all configurations of the game "Nim" from which the first player can force a win. The context-free grammar membership problem.

Give a definition of NP-complete language.

i. L1 is in the class N P-time, and ii. For any language L2 in the class N P-time, there is a polynomial time reduction of L1 to L2.

Describe the language L generated by the following context-free grammar where {a, b} is the set of terminals, {S} is the set of variables, S is the start symbol, and the productions are as follows: 1. S → aSb 2. S → aS 3. S → λ

{a^n b^m : 0 ≤ m ≤ n}

An undecidable language is necessarily NP-complete.

False

Commercially available parsers cannot use the LALR technique, since most modern programming languages are not context-free.

False

Every NFA is a DFA.

False

Every bounded function from integers to integers is Turing-computable. (We say that f is bounded if there is some B such that |f(n)| ≤ B for all n.)

False

Every context-free grammar can be parsed by some deterministic top-down parser.

False

Every function that can be mathematically defined is recursive.

False

Every language accepted by an NPDA is accepted by some DPDA.

False

Every subset of a regular language is regular.

False

For any deterministic finite automaton, there is always a unique minimal non-deterministic finite automaton equivalent to it.

False

Given any context-free grammar G and any string w ∈ L(G), there is always a unique leftmost derivation of w using G.

False

The equivalence problem for context-free grammars is decidable.

False

The intersection of any two context-free languages is context-free

False

The intersection of any two context-free languages is context-free.

False

The language of all binary strings which are the binary numerals for prime numbers is context-free.

False

The language of all palindromes over {0, 1} is inherently ambiguous.

False

The language of all regular expressions over the binary alphabet is a regular language.

False

There is a PDA that accepts the language consisting of all C++ programs.

False

What class of machines accepts the class of context free languages?

Push-down automata.

Let L be the language over Σ = {a, b} consisting of all strings of the form a^n b^n for n ≥ 1. Give a Chomsky Normal Form grammar for L.

S → AB S → AT T → SB A → a B → b

Give a general grammar for the language { a^ (2^n) }

S → LaR L → LD Da → aaD DR → R L → ε R → ε

We say a binary string w over is balanced if w has the same number of 1's as 0's. Let L be the set of balanced binary strings. Give a context-free grammar for L. S → SS S → aSb S → bSa S → λ

Simple Answer: S → 0S1S | 1S0S | ε. This grammar is ambiguous. unambiguous grammar S → 0A1S | 1B0S | ε A → 0A1A | ε B → 1B0B | ε OR S → aAbS S → bBaS S → λ A → aAbA A → λ B → bBaB B → λ

Every DFA is an NFA.

True

Every regular language is context-free.

True

What does it mean to say that a language can be recursively enumerated in canonical order? What is the class of languages that can be so enumerated?

We say that a language L can be enumerated in canonical order if there is some machine that outputs a (possibly infinite) sequence of strings so that the strings that are output are the strings that belong to L, and that the strings are output in canonical order. If w1 and w2 are strings, we say that w1 comes before w2 in canonical order if either w1 is shorter than w2, or w1 and w2 have the same length and w1 comes before w2 in lexical order.

Give a definition of a decidable language

We say that a language L over an alphabet Σ is decidable if there is a machine M which has two possible outputs, 0 and 1, such that a computation of M with any input string w over Σ halts, and the output is 1 if w ∈ L,and is 0 if w /∈ L.

Give a definition of the language class NP-time

A language L is in the class NP-time if there is some NTM (non-deterministic Turing machine) M and some integer k such that for any string w ∈ L, there is a computation of M with input w which halts in at most |w| k steps, and for any string w /∈ L, there is no halting computation of M with input w.

What is a polynomial time verifier of a language?

A polynomial time verify for a language L is a machine M such that there is some k such that if M is input two strings, w and c, M will output M(w, c), which is either 0 or 1, within |w|^k steps, and such that if w ∈ L there is some c, called a witness for w, such that M(w, c) = 1, and such that M(w, c) = 0 for all c if w /∈ L.

Use the pumping lemma to prove that the language L = {a^nb^n : n ≥ 0} is not regular.

Assume L is regular. Let p be a pumping length of L. Let w = a^p b^p . Then there exist strings x, y, z such that i. w = xyz, ii. |y| ≥ 1, iii. |xy| ≤ p, iv. for any integer i > 0, xy^iz ∈ L. By (ii) |y| = k for some k > 0. By (i) and (iii) xy contains no b, hence y contains to b. By (iv) xy^0z = a^ (p−k) b^p ∈ L, contradition because p − k not equal to p. Thus L is not regular.

Find a P-time reduction of 3-CNF-SAT to the independent set problem.

Consider a Boolean expression E in 3-CNF form. That is, Exp is the conjunction of k clauses: Exp = C1 ∗C2 ∗· · · Ck, where each clause is the disjunction of three terms: Ci = (ti,1 + ti,2 + ti,3) for each i, where each term is a Boolean variable or the negation of a Boolean variable Let G = (V, E) be the graph where V is the set of vertices vi,ℓ for 1 ≤ i ≤ k and 1 ≤ ℓ ≤ 3. There is thus a 1-1 correspondence between terms of Exp and vertices of G. We let E = {vi,ℓ, vj,m : i = j or ti,ℓ contradicts tj,m}. Let Qi = {vi,1, vi,2, vi,3}, the 3-clique corresponding to the clause Ci . Then (G, k) is an instance of the independent set problem. If G has an independent set I of size k, I must contain exactly one vertex in each Qi . The terms corresponding to the members of I cannot contradict each other. Thus, we can assign a Boolean value to each of those terms. Any variables which are not used for any of the selected terms are assigned true, and thus Exp is satisfied by that assignment. Conversely, any satisfying assignment for Exp causes one term of each Ci to be true. The corresponding set of vertices of G must be independent, since those terms cannot contradict each other, and there are k of them since there is one in each Qi .

Find a P-time reduction of the subset sum problem to the partition problem

Consider an instance of the subset sum problem, which consists of a sequence x1, . . . xm and a number S. That instance has a solution if and only if there is some subsequence of {xi} m i=1 whose sum is S. Let X = Σm i=1 xi . If S = 1/2 X we are done, since the terms of the sequence can be partitioned into those in the subsequence and those not; each set has total weight S. If S > 1/2 X, let xm+1 = 2S − X. Then 2S is the sum of the sequence {xi} m+1 i=1 xi . That sequence can be partitioned into two subsequences with equal totals if and only if it has a subsequence whose total is S. The complement of such a subsequence also has total S. One of those subsequences does ot contain xm+1, and that one is a solution to the instance of the subset sum problem. If S < 1/2X, let xm+1 = X − 2S. Then 2(X − S) is the sum of the sequence {xi} m+1 i=1 xi . That sequence can be partitioned into two subsequences with equal totals if and only if it has a subsequence whose total is X − S. The complement of such a subsequence also has total X − S. One of those subsequences, say Y , contains xm+1. Delete xm+1 from Y to obtain a subsequence of the original sequence of weight X − S − (X − 2S) = S.

What class of machines accepts the class of regular languages?

Deterministic or non-deterministic finite state automata. ie finite automata, DFA"S or NFA's

If a language has an ambiguous context-free grammar, then it is is not accepted by any deterministic push-down automaton.

False

If a language has an unambiguous context-free grammar, then it is is accepted by some deterministic push-down automaton.

False

Let L be the language over Σ = {a, b, c} consisting of all strings of the form a^n b^n c^n, where n ≥ 0. Then L is a context-free language.

False

Let L be the language over Σ = {a, b} consisting of all strings of the form a^m b^n, where m ≥ n. Then L is a regular language.

False

No language which has an ambiguous context-free grammar can be accepted by a DPDA.

False

The boolean satisfiability problem is undecidable.

False

The class of languages accepted by non-deterministic push-down automata is the same as the class of languages accepted by deterministic push-down automata.

False

The complement of every context-free language is context-free.

False

The complement of every recursively enumerable language is recursively enumerable.

False

The question of whether a given Turing Machine halts with empty input is decidable.

False

State the pumping lemma for regular languages

For any regular language L there is a pumping length p such that for any w ∈ L such that barred ≥ p there exist strings x, y, z such that the following conditions hold 1. w = xyz 2. |xy| ≤ p 3. |y| ≥ 1 4. for any i ≥ 0 xy^iz ∈ L

What does it mean to say that machines M1 and M2 are equivalent?

It means that if M1 and M2 are given the same input, they will give the same output.

Give the definition of a polynomial time reduction of a language L1 to another language L2.

Let Σi be the alphabet of Li , for each i. A polynomial time reduction of L1 to L2 is a function R : Σ∗1 → Σ 2 2 such that there is a constant k and machine M where, for any w ∈ Σ ∗1 i. M computes R(w) in at most |w|^k steps, and ii. R(w) ∈ L2 if and only if w ∈ L1

Prove that every recursively enumerable language is accepted by some Turing machine.

Proof: Let M be a machine which enumerates L, and let wi be the i th string written by M. The following program accepts L: read w; for(i = 1, true, i + +) if (w = wi) halt; By the Church-Turing thesis, there is a Turing Machine which emulates the program and hence accepts L.

Prove that every language accepted by a Turing machine is recursively enumerable

Proof: Let Σ be the alphabet of L. Let wi be the i th string of Σ∗ in the canonical order. The following program enumerates L: for(t = 1, true, t + +) for(i = 1, i ≤ t, i + +) if (M accepts wi withn t steps) write wi ; If wi ∈/ L, it is not accepted by M and hence will never be written. If wi ∈ L, then wi will be accepted by M in some finite number of steps, say T steps. Let t = max i, T. Then wi will be written during the t th iteration of the outer loop.

Prove that the halting problem is undecidable

Recall that <M> is a string which names a TM M, and that HALT = {<M>w : M halts with input w} We define the diagonal language Ld = {<M> : <M><M> ∈/ HALT}. Claim: Ld is not decidable. The proof of the claim is by contradiction. Assume that Ld is decidable. Then Ld is accepted by some TM Md. Then, for any TM M, <M> ∈ Ld ⇐⇒ <M><M> ∈/ HALT by definition of Ld (1) <M> ∈ Ld ⇐⇒ <M><M> ∈ HALT by definition of Md (2) <Md> ∈ Ld ⇐⇒ <Md><Md> ∈/ HALT by universal instantiation of (1) (3) <Md> ∈ Ld ⇐⇒ <Md><Md> ∈ HALT by universal instantiation of (2) (4) Since Md exists, equations (3) and (4) contradict each other. We conclude that Ld is not decidable. We now reduce Ld to the complement of HALT. Let R(<M>) = <M><M> for every Turing machine M. R is a reduction of Ld to the complement of HALT. Since Ld is not decidable, the complement of HALT is not decidable. Since the complement of any decidable language is decidable, HALT is not decidable.

Give a Chomsky Normal Form grammar for the language of all palindromes over the alphabet {a, b}.

S → XA | Y B | AA | BB | a | b | ε X → AT Y → BT T → XA | Y B | AA | BB | a | b A → a B → b

Consider the context-free grammar G, with start symbol S and productions as follows: S → s S → bLn S → iS S → iSeS L → ǫ L → LS Prove that G is ambiguous by giving two different leftmost derivations for some string.

S ⇒ iSeS ⇒ iiSeS ⇒ iiseS ⇒ iises S ⇒ iS ⇒ iiSeS ⇒ iiseS ⇒ iises

Co-RE, but not recursive.

The diagonal language. The context-free grammar equivalence problem.

Neither RE nor co-RE.

The set of all ordered pairs of positive numerals (<n>,<m>) : m = β(n), where β is the busy beaver function.

For each of the following languages, state whether the language is regular, context-free but not regular, context-sensitive but not context-free, or not context-sensitive.

The set of all strings over the alphabet {a, b} of the form a^n b^ m. Regular The set of all strings over the alphabet {a, b} of the form a^n b^n. CF not Regular The set of all strings over the alphabet {a, b, c} of the form a^n b^n c^n. CS not CF The set of all strings over the alphabet {a, b, c} which are not of the form a^n b^n c^n. CF not Regular The set of all strings over the alphabet {a} of the form a^(n^2) . not CS

Every context-free grammar can be parsed by some non-deterministic top-down parser.

True

Every context-free language is in the class P-time.

True

Every language accepted by an NFA is accepted by some DFA.

True

Every language which is accepted by some non-deterministic machine is accepted by some deterministic machine.

True

Every language which is generated by a general grammar is recursively enumerable.

True

Every regular language is in the class NC

True

If L is a language accepted by some PDA, then L is generated by some context-free grammar.

True

If L1 reduces to L2 in polynomial time, and if L2 is NP, and if L1 is NP-complete, then L2 must be NP-complete.

True

If L1 reduces to L2 in polynomial time, and if L2 is NP, then L1 must be NP.

True

If a language L is generated by some context-free grammar, then L is accepted by some PDA.

True

If a string w is generated by a context-free grammar G, then w has a unique leftmost derivation if and only if it has a unique rightmost derivation.

True

If anyone ever proves that P = NP, then all one-way encoding systems will be insecure.

True

Let L be the language over Σ = {a, b} consisting of all strings of the form a^m b^n, for any m and n. Then L is a regular language.

True

Let π be the ratio of the circumference of a circle to its diameter. (That's the usual meaning of π you learned in kindergarten.) The problem of whether the n th digit of π, for a given n, is equal to a given digit is decidable.

True

The Kleene closure of every context-free language is context-free

True

The Kleene closure of every regular language is regular.

True

The class of languages accepted by non-deterministic finite automata is the same as the class of languages accepted by deterministic finite automata

True

The complement of every recursive language is recursive.

True

The complement of every regular language is regular.

True

The halting problem is recursively enumerable.

True

The intersection of any context-free language with any regular language is context-free.

True

The intersection of any two regular languages is regular.

True

The language consisting of all hexadecimal numerals for positive integers n such that n % 13 = 7 is regular.

True

The language of all binary strings which are the binary numerals for multiples of 23 is regular.

True

The language {a^m b c^n : 0 ≤ m ≤ n} is accepted by some DPDA.

True

The membership problem for context-free languages is decidable

True

The question of whether two context-free grammars generate the same language is undecidable.

True

The question of whether two regular expressions are equivalent is NP-complete.

True

The set of all binary numerals for prime numbers is in the class P.

True

The union of any two context-free languages is context-free.

True

The union of any two regular languages is regular.

True

There cannot exist any computer program that can decide whether any two C++ programs are equivalent.

True

There exists a mathematical proposition that is true, but where no proof of the proposition can exist.

True

There exists some proposition which is true but which has no proof.

True

What class of machines accepts the class of recursively enumerable languages?

Turing Machines

Known to be NP complete

examples: Primality Boolean satisfiability. The 0-1 traveling salesman problem. The clique problem. The independent set problem. The knapsack problem SAT 2-SAT 4-SAT CF grammar membership Partition Polygon placement. DFA equivalence

P but not known to be NC

examples: Primality. Primality, where the input is written in binary. The language generated by a given context-free grammar. The Boolean circuit problem Dynamic programming where all subproblems have Boolean solutions. The restricted subset sum problem where the weight of each item is an integer which does not exceed the square of the number of items.

NP and Co-NP but not known to be P.

examples: The 0/1 factoring problem, i.e. the set of all pairs of integers (n, m) such that n has a proper divisor which is at least m. (The input for an instance of this problem is the string consisting of the binary numeral for n, followed by a comma, followed by the binary numeral for m.)

RE (Recursively enumerable), but not recursive.

examples: The halting problem. The language consisting of all Pascal programs P such that P halts if given P as its input file.

Recursive, but not known to be NP.

examples: The set of all positions from which black can force a win in a game of generalized checkers. The set of all configurations of the children's game "Boxes" from which the first player can force a win. (I used to play that game as a child, and I never did figure out an optimal strategy. I don't feel bad about that anymore, now that I know the complexity class of that problem.)

__________has an unambiguous context-free grammar, but is not accepted by any DPDA

the language of all palindromes over an alphabet of size 2.


Conjuntos de estudio relacionados

Chapter 15: A few viral diseases

View Set

Species Extinction and Loss of Biodiversity

View Set

Chapter 4: Robert Fulton and the Steamboat

View Set

Chapter 56 Assessment and Management of Patients with Female Physiologic Processes

View Set