Theory Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The set of languages decided by a pushdown automata (PDA) is called what?

Context Free Languages

How do you show a problem is NP-Hard?

Give a reduction from another NP-Hard problem.

What does it mean to "verify" a problem?

Given a potential solution, check if it's correct

Give an example of a context-free language that can be recognized by a NPDA but not a deterministic PDA

𝐿={𝑤𝑤^𝑅|𝑤∈{0,1}∗}

What are the three "reporting" behaviors of Turing machines? What three results can happen from running a Turing machine?

1) Accept and halt 2) Reject and halt 3) Run forever (implicit reject)

A particular language decided by some FSA is called what?

A context free language NOT context free languages

When can a CFG be considered "ambiguous"?

If there is at least 1 string that can be generated by at least 2 different parse trees

What's the point of categorizing languages?

Indicates limits on resources needed to compute by Turing Machines relative to input size Space = number of cells required on the tape Time = number of transitions required by machine

If A is NP and A reduces to B in polynomial time, then B is what?

NP-Hard

Is ALL_TM a recognizable language? All_TM = {<M>, | L(M) = sigma star}

No

P is a _______ of NP

P is a proper subset of NP

To prove a language is undecidable using reductions, how can you do this?

Take HALT_TM, the machine that describes all input pairs in which a machine halts on input To show HALT_TM is undecidable, show A_TM (undecidable) isn't harder than HALT_TM We want to use a solver for HALT_TM to build a solver for A_TM A_TM reduces to HALT_TM

Any deterministic TM is already a __________

non-deterministic TM

How do you decide A_TM with Halt_TM?

1) Assume HALT_TM is decidable 2) Some TM R can decide HALT_TM 3) Use R to build a machine D that decides A_TM - Call R on <M,w> - If R rejects, M doesn't halt (reject) - If R accepts, M halts - Call M on w, respond equivalently Any TM the decides HALT_TM could be used to build a TM that decides A_TM (impossible), thus no TM exists that can decide HALT_TM

Prove 2-SAT is solvable in polynomial time

1) Create implications for each clause (A OR B) - If A = 0, B must be 1 --> (A' -> B) - Vice versa --> ('B -> A) 2) Create implication graph - For each clause (A OR B), add edge(A' -> B) and edge (B' -> A) - 1 Node for each variable, 1 for each complement - m Edges, where m is the # of clauses 3) If edge (X -> X') AND edge(X' -> X) exist, the CNF formula is unsatisfiable

How can we try to figure out if P = NP?

1) Identify problems at least as "hard" as NP 2) If any of these "hard" problems can be solved in polynomial time, then all NP problems can be solved in polynomial time

What two conditions must be met for a pushdown automata to accept?

1) The entire input has been read 2) There is at least one "path" in a final state with an empty stack

What do Turing machine transitions look like? From one state to the next

1) read current state 2) read symbol on tape 3) write symbol to current location in tape 4) Move location on tape left or right 5) move to next state

Finite State automaton accepts the "language" of the machine, or the set of all strings it accepts. What type of machine does this make a FSA?

A decider

If A reduces to B, then what does this say about the difficulty to solve A and B?

A is not harder to solve than B It does NOT mean B is equally as hard as A (A = B) because there may be an easier way to solve A

A language is generated by some context free grammar if and only if what occurs?

A language must be decided by some pushdown automata if it can be created by context free grammar

Using a solver for B to solve A shows A is not harder than B. What does this say about the reduction?

A reduces to B

Why are all regular languages context free?

Because if we choose not to use the stack in a PDA, the PDA is just an NFA

What two ways to we categorize languages?

By the type of machine to express the language (DFA, NFA, PDA, CFG, TM, etc) By the amount of resources a TM needs

What is context free grammar and how can it generate strings?

CFG gives a list of substitution rules you can apply to generate strings Any string that can be generated by some sequence of the substitutions is in the language of that grammar

How do context free grammars relate to context free languages?

CFGs describe CFLs

Give an example of a CFL and a non-CFL

CFL (see picture): w = w^R ww^R Non-CFL: a^n b^n c^n {ww | w in sigma star}

What are decision problems? What is the output?

Checks if there is a solution Output is true/false Ex: Can all these boxes fit in the trunk of my car?

Context free languages are closed under what operations and not closed under what operations?

Closed under: - Union - Concatenation - Kleene Star - Intersection with regular languages Not closed under: - Complementation - Intersection with other context free languages

Closure properties of recognizable languages?

Closed under: - Union - Intersection - Concatenation - Kleene Star Not closed under: - Complement

How can you prove a language is undecidable?

Closure properties of decidable languages Reduction

Recognizable languages are not closed under which operation

Complement

Closure properties of regular languages?

Complement Intersection Union Difference Concatenation Reversal

Which operation(s) (is/are) closed under decidable languages but not under recognizable ones?

Complementation

Given an enumerator for a language, how can you build a recognizer?

Create a TM that for input w, it will accept w if it belongs to the language Each time the enumerator prints a string, check if it's w. If is is, accept

Give an example of a language that's decidable, a language that's recognizable but not decidable, and an example of a language that is not recognizable.

Decidable Language of unary Fibonacci numbers L = {1^n | n is a Fibonacci number} Recognizable but not decidable ATM ={<M,w> | M is a TM and M accepts w} Not recognizable Lall = {< M > | L(M) = Σ∗}

How do tape transitions work on a TM when it is non-deterministic?

Each non-deterministic move on the tap spawns another independent "thread" (a copy of the tape) All current "threads" are simulated in parallel

What are search problems? What is the output?

Find a solution Output is complex Ex: Show me how to make these boxes fit in the trunk of my car

If I can decide the language, how can I lexicographically enumerate it?

First try deciding the empty string. If accepted, print it. Next try the next string. If accepted, print it.

Given a recognizer for a language, how can you build an enumerator?

First try recognizing the empty string. If accepted, print it. Next try the next string. If that's accepted, print it.

Difference between L^* and L^+ (star and plus sign exponents on a language)

For 0^+, it would need to have at least 1 zero, so {0, 00, 000,...} For 0^*, it would also contain the null character, so {empty, 0, 00, 000, ...} Difference is that * includes null symbol

If you can enumerate in order, how can you decide a string?

For each string that's printed, accept if it is w If it is lexicographically greater than w, reject

How do you show a problem belongs to NP?

Give a polynomial time verifier

What are verification problems? What is the output?

Given a potential solution, is it valid? Output is true/false Ex: Will the boxes fit in the trunk of your car if you load them like this?

How to show the acceptance problem is undecidable?

Given: Turing machine M, string w. Determine: Does M accept the input w? Create another TM to simulate M A_TM(M,w) Assume M_acc is a decider for A_TM Consider another TM, M', which receives as input a TM description of M If <M,M> is in A_TM, then M' will reject. Else it accepts (reverse output) Consider M'(M') If it accepts, then by definition M'(M') will reject If it rejects, then by definition M'(M') will accept CONTRADICTION --> M_acc cannot exist

Why is the set of recognizable languages countable?

How many TMs are there? Each TM have description, which is a string If it's a set of strings, it's a subset of sigma star (which is countable) Since the set of all TMs is countable, the set of recognizable languages is countable

Why does a reduction from an NP-Complete to another problem B show that problem B is NP-Hard?

If A is NP (or NP-Complete), and A reduces to B, then B is NP-Hard by definition

Is the intersection of a context-free language and a non-context-free language sometimes, always, or never context-free

If the non-context free language is a regular language, then the intersection is context-free. Else, not context-free

Use a reduction from 3-SAT to verify 3-colorability in polynomial time

In order to reduce 3SAT to 3COLOR, we need to somehow make a graph that is 3-colorable iff some 3-CNF formula φ is satisfiable 1) For each (x OR y OR z) clause, make an OR circuit 2) Create new vertices (all different colors) for the base, true, and false 3) Connect base, true and false to each other 4) Connect base to all variables. Connect all variables to their complements

What do pushdown automata transitions look like? From one state to the next

Input symbol, popped symbol, pushed symbol Because there's a stack

How can you convert multiple tapes in a Turing machine to just one?

Interlace multiple tapes into a single one Tape transitions updates R/W head positions on all "virtual tapes"

What is the acceptance problem?

Is it computable to determine whether a given TM accepts a given string? No, and we can prove it's undecidable (and will in another question)

Why does it matter that lambda calculus and Turing machines are equivalent?

It means anything we can do in hardware, we can also do in software. Vice versa CPU is a universal Turing machine, and we can use lambda calculus (programming languages) to write algorithms

Is it bad if a Turing machine runs forever? When would it be bad? When is it expected?

It's bad in programs like: - calculator, an ATM machine, CS2150 homework It's expected in programs like: - operating systems, browsers, space equipment, plane electronics

All context free languages can be decided by a Java program using only _____ memory?

Linear - relative to length of word

Is this problem P, NP, NP-Complete, or NP-Hard: Is there a set of no-adjacent nodes in a graph of size k?

NP Verify it in polynomial time Given V vertices and E edges 1) check that it's of size k - O(V) 2) check that it's an independent set - O(V^2)

NP-Complete problems are the intersection of what?

NP and NP-Hard

What is the 3-SAT problem? Is it P, NP, NP-Complete, or NP-Hard?

NP-Complete Given a 3-CNF formula (a or b or c) and (a or NOT b or c), is there an assignment of true/false to each variable so that the formula is true?

NP-Complete definition (in terms of sets and relation to NP and NP-Hard)

NP-Complete = NP Union NP-Hard

A pushdown automata is a finite automaton that can do what?

Optionally write to an unbounded stack

What if P = NP? What does it even mean?

P = NP means if we can verify solutions efficiently, we can solve them efficiently as well

An enumerator for a language L is a TM which does what?

Prints all strings in L onto its tape

What is the meaning of P and NP?

Problems solvable in polynomial time (P) Problems solvable in non-deterministic polynomial time (NP)

How do you show COHALT_TM is non-recognizable? COHALT = {<M,w> | M does not halt on w}

Reduce COHALT to ALL_TM Use a recognizer for ALL_TM to recognize COHALT Given a COHALT instance (<M,w>), build a new machine M' such that L(M') = sigma star if and only if M(w) runs forever As the recognizer for ALL_TM if

How can you prove graph 3-colorability is NP-complete?

Reduction from 3-SAT Construct a colorability "OR gate" for (x or y or z) Do this for every clause (x or y or z) Add a node for true, false, 3rd color Connect True,false, starting node in a triangle Connect each node to its complement and 3rd color

Converting a FSA to grammar results in _____, while converting a PDA to grammar results in ______

Regular grammar Context-free grammar

How do you show a problem is NP-Complete?

Show it belongs to NP - Give a polynomial time verifier Show it is NP-Hard - Give a reduction from another NP-Hard problem

Sigma star union with anything is what?

Sigma star

Is the intersection of a context-free language and a non-context-free language sometimes, always, or never context-free?

Sometimes. If the non-context-free language is a regular language, than the intersection will be-context free.

Give a compelling reason that non-deterministic PDAs cannot be converted to deterministic PDAs as we could with FSAs.

The set of languages that can be accepted by DPDA is not equal to NPDA There are context-free languages which cannot be accepted by a DPDA

Why is the set of unrecognizable languages larger than the set of recognizable languages?

The set of recognizable languages is countable If you subtract this set from the uncountable powerset of sigma star, you will have an uncountable number of unrecognizable languages.

When is a language not regular?

There is no DFA/NFA which accepts the strings in the language You cannot write a regular expression to describe exactly the strings in the language

In a pushdown automata, what's the difference between the stack alphabet and the input alphabet?

They are mutually exclusive. Stack alphabet are symbols that are pushed/popped from stack. Input alphabet is all the symbols that can be read from the string

We can have one Turing machine which can simulate any other Turing machine. Why is this useful?

Turing machines are meant to be a model for all computers Allows us to have one machine that we've built to simulate any other machine we describe

Turing-recognizable vs Turing-decidable for a language L and Turing machine M?

Turing-recognizable: - M can run forever on an input, which is implicitly a reject Turing-decidable: - M always halts on every input

Closure properties of decidable languages?

Union Intersection Complement Reversal Pretty much everything

Decidable languages are closed under what operations?

Union Intersection Complementation Concatenation Kleene Star

Recognizable languages are closed under what operations?

Union Intersection Concatenation Kleene Star

How to use context free grammar to prove closure of a context free language? Given: CFGs for languages L_1, L_2 with start symbols S_1, S_2

Union: - Take production rules for both grammars, add S -> S_1 | S_2 Concatenation: - Take production rules for both grammars, add S -> S_1 S_2 Kleene Star: - Add to production rules of S_1, S -> empty | SS | S_1

How can you use HALT_TM to show a different TM is undecidable?

Use the TM to solve HALT_TM (contradiction) Given a TM M and input string w 1) Build a new TM M' such that L(M') returns true if M(w) halts If L(M) describes regular expressions, L(M') is regular if M(w) halts If L(M) describes finite numbers, L(M') is finite if M(w) halts idea: if I know whether or not L(M') is regular/finite (if L(M) describes regular languages or finite numbers ), then you know whether or not M(w) halted (undecidable) Write code for M': regular expressions: def M'(x) if x is not a regular expression, return true y = M(w) return true If M(w) halts, L(M') is sigma star If M(w) runs infinitely, L(M') = non regular expressions finite numbers: def M'(x): y = M(w) return true If M(w) halts, L(M') = sigma star if M(w) runs infinitely, L(M') is empty

What must be true for a Turing machine to accept?

We just have to be in the accepting state.

What must be true for a Turing machine to reject?

We just have to be in the rejecting state.

Can all DFAs be converted to NFAs? Can all NFAs be converted to DFAs?

Yes, and yes. They are equivalent.

How can you determine whether a CFG is ambiguous or not?

You can't. It's not computable

What kind of reduction do you need to make to show a problem is NP-Hard? Is there any other conditions that need to be met?

You need to reduce a NP problem to whatever problem you're showing is NP-Hard. It must be done in polynomial time.

All regular languages can be decided by a Java program using only what type of memory

constant - it's relative to the length of the word

All regular languages are also

context free (because if we choose not to use the stack, a PDA is a NFA)

Context Free Languages are equivalent to the languages describable by _______

context free grammars

A language is recognizable if and only if it has a(n) __________

enumerator An enumerator for a language L is a TM which prints all strings in L onto its tape

Which of the following is true: every DPDA can be simulated by an NPDA, but the converse doesn't hold every NPDA can be simulated by a DPDA, but the converse doesn't hld

every DPDA can be simulated by an NPDA, but the converse doesn't hold some context-free languages are not recognized by DPDA

Powerset of a set is always _____ than the set itself

larger

A language is decidable if and only if it has a(n) ____________

lexicographic enumerator A lexicographic enumerator for a language L is a TM which prints all strings in L onto its tape in lexicographic order

What does the language w = w^R describe?

palindromes

A particular language decided by some FSA is called a _________

regular language

The set of all languages decided by some FSA is called the ___________

regular languages Equivalent to the languages describable by regular expressions

P are problems we can ______ efficiently, while NP are problems we can _____ efficiently

solve, verify

If we can solve a decision version in polynomial time, we can solve what as well?

the search version Idea: Use the decider to build a solution "guess and check" one piece at a time

The powerset of the set of all strings (sigma star) is ______

uncountable because sigma star is countable and the powerset must be larger

Give three examples of non-regular languages

{a^n b^n for n being a natural number} {s | s is a palindrome} {w in sigma star | w = w^R}


संबंधित स्टडी सेट्स

Lesson & Assignment 3: HTML Tags

View Set

1. States of Matter Practice (3)

View Set

Chapter 5: Medicare Hospital Acute Inpatient Payment System

View Set

Element of Moral Philosophy FINAL

View Set

Arguments For and Against Capital Punishment

View Set