Exam Review Part 2 - cs 344

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

Precedence of operators in Regular Expressions

*, o, U

Definition of a CFG

A 4-tuple (V,Sigma,R,S) 1. V is a finite set called the variables; 2. Sigma is a finite set, disjoint from V, called the terminals; 3. R is a finite set of rules, with each rule being a pair of a variable and a string of variables and terminals; 4. S is an element of V called the start variable.

Definition of Accept

A TM accepts an input string iff, for this input, sooner or later it enters the accept state. Otherwise the string is considered rejected.

Definition of Decider

A Turing machine is said to be a decider iff it halts for every input.

String over Sigma

A finite sequence of symbols from sigma

Alphabet

A finite set of objects called the symbols of the alpabet.

Definitions of computing, computability, and the graph of a function

A function g: Sigma*-> Sigma* is said to be computable, iff there is a TMO M such that for every input w is in Sigma* M returns the output u with u=g(w). In this case we say that M computes g. The graph of such a function is the language {(w,u) | w is in Sigma*, u=g(w)}

Show that PATH is in P

A polynomial time algorithm M for PATH works as follows: On input <G,s,t>, where G is a directed graph with nodes s and t, 1. Place a mark on node s 2. Repeat until no additional nodes are marked: 3. Scan all edges of G. If an edge (a,b) is found going from a marked node a to an unmarked node b, mark node b. 4. if t is marked, accept. Otherwise, reject

Definition of Oracle Turing Machine

An oracle Turing machine (OTM) is a modified Turing machine that has the additional capability of querying an oracle. An oracle for a language B is an external device that is capable of reporting whether any string w is a member of B.

Prove HALT TM is undecidable

Assume, for a contradiction, that HALT TM is decidable. I.e. there is a TM R that decides HALT TM. Construct the following TM S: S = "On input <M,w>, an encoding of a TM M and a string w: 1. Run R on input <M,w>. 2. If R rejects, reject. 3. If R accepts, simulate M on w until it halts. 4. If M has accepted, accept; if M has rejected, reject." If M works forever on w, what will S do on <M,w>? Explicitly Reject If M accepts w, what will S do on input <M,w>? Accept If M explicitly rejects w, what will S do on <M,w>? Explicitly Reject Thus, S decides the language, which is impossible

Prove that the Complement of Atm (NOT Atm) is unrecognizable

Atm = {<M,w> | M is a TM and M accepts string w} NOT Atm = {<M,w> | M is a TM and M does not accept string w} Suppose, for a contradiction, that NOT Atm is Turing-recognizable. That is, there is a TM U that recognizes NOT Atm. Thus: U recognizes Atm (slide 4.2.a) NOT U recognizes NOT Atm Let M = "On input w: 1. Run both U and NOT U on input w in parallel; 2. If U accepts, accept; if NOT U accepts, reject." It can be seen that M decides ATM, which is impossible

Prove every t(n) multitape Turing Machine has an equivalent O(t^2 (n)) time single tape TM

Convert a multitape TM M into an equivalent single tape TM S that simulates M The simulation of each step of M takes O(k) steps in S, where k is the length of the active content of the tape of S specifically, S makes two passes through its tape; a pass may require shifting, which still takes O(k) steps). How big can k be? Not bigger than the number of steps M takes, multiplied by the (constant) number c of tapes. That is, k <= ct(n)). Thus, S makes O(t(n)) passes through the active part of its tape, and each pass takes (at most) O(t(n)) steps. Hence the complexity of S is O(t(n)) x O(t(n)) = O(t^2 (n)).

Prove Let t(n) be a function, where t(n)>=n. Then every t(n) time single-tape nondeterministic TM has an equivalent 2^(O(t(n))) time single-tape TM.

Convert a nondeterministic TM N into an equivalent deterministic TM D that simulates N by searching N's nondeterministic computation tree. Each branch of that tree has length at most t(n), and thus constructing and searching it takes O(t(n)) steps. And the number of branches is b^(O(t(n))), where b is the maximum number of legal choices given by N's transition function. But b<=2c for some constant c. So, the number of branches is in fact 2^(cO(t(n)))=2^(O(t(n))). Thus, the overall number of steps is O(t(n)) x 2^(O(t(n))) = 2^(O(t(n))).

Prove that every multitape TM M has an equivalent single-tape TM S.

Copy the contents of each tape in M onto the single tape of S, marking the boundaries between the tapes with a special character. Modify S so that it can move between the boundaries easily.

Prove that if a language A is mapping reducible to a language B and B is recognizable, then A is recognizable

DB is a Turing Machine that recognizes B and f is a reduction from A to B. A Turing Machine DA recognizes A DA = "on input w: 1. compute f(w) 2. run DB on input f(w) and do whatever DB does"

The 3 parts in defining a CFG

Define the smallest thing Split it up into parts combine

What happens if you get to final state but still ahve stuff leftover?

Don't accept,

Show that RELPRIME is in P

E = "On input <x,y>, where x and y are natural numbers, x>y: 1. Repeat until y=0. 2. Assign x <- x mod y. 3. Exchange x and y. 4. Output x." R = "On input <x,y>, where x and y are natural numbers: 1. Swap x and y if necessary so that x>y. 2. Run E on <x,y>. 3. If the result is 1, accept. Otherwise reject.

Show that the Atm is Turing reducible to HALT TM

For every TM M with input string w, consider the TM M*, which takes input <M,w> M* = "on input <M,w> 1. simulate M on w 2. if M reaches accept, accept 3. if M reaches reject, enter an infinite loop f is the computable function through which f(<M,w>) = <M*,w> Therefore, <M,w> is in Atm iff f(<M,w>) is HALT TM

Define a mapping reduction of the acceptance problem Atm to the halting problem HALT TM

For every TM M, let M* be the following TM: M* = "On input x: 1. Run M on x. 2. If M accepts, accept. 3. If M rejects, enter an infinite loop." Thus: If M accepts input x, then M* accepts x If M explicitly rejects x, then M* never halts on x If M never halts on x, then M*never halts on x To summarize, M accepts x iff M* halts on x Let then f be the function defined by f(<M,w>)=<M*,w>. Is f computable? Yes Obviously <M,w> is in ATM iff f(<M,w>) is in HALT TM i.e. f is a mapping reduction of Atm to HALT TM So, since ATM is undecidable, HALT TM is undecidable as well.

Pumping lemma for Context free grammars

For every context-free language L, there is a number p, such that for every string s, which is in L, whose length is at least p, there are strings u, v, x, y, z, such that s = uvxyz and the following conditions are satisfied: 1.) for every i >= 0, uv^ixy^iz is in L; 2.) |vy| > 0; 3.) |vxy| <= p.

Pumping Lemma for Regular Expressions

For every regular language L, there is a number p, such that for every string s, which is in L, whose length is at least p, there are strings x, y, z, such that s = xyz and the following conditions are satisfied: 1.) for every i >= 0, xy^iz is in L; 2.) |y| > 0; 3.) |xy| <= p.

Prove that the halting problem is recognizable

HALT TM = {<M,w>| M is a TM and M halts on input w} the TM U (universal Turing Machine) recognizes HALT TM: U= "On input <M,w>, where M is a TM and w is a string: 1. Simulate M on input w 2. if M enters accept state, accept if M enters reject state, accept

Prove that CLIQUE is in NP

Here is a polynomial time NTM N deciding CLIQUE: N = "On input <G,k>: 1. Nondeterministically select a subset c of k nodes of G. 2. Test whether G contains all edges connecting nodes n c. 3. If yes, accept; otherwise reject."

Prove that SUBSET-SUM is in NP

Here is a polynomial time NTM N deciding SUBSET-SUM: N = "On input <S,t>: 1. Nondeterministically select a subset c of S. 2. Test whether the elements of c sum up to t. 3. If yes, accept; otherwise reject."

Definition of Star

L* = {x1...xk | k >= 0 and each xi is in L}

Definition of Union

L1 U L2 = {x | x is in L1 or x is in L2}

Definition of Concatenation

L1 o L2 = {xy | x is in L1 and y is in L2}

Definition of Turing Reducibility

Language A is Turing reducible to language B, written A<=TB, iff A is decidable relative to B.

Definition of Decidable Relative

Language A is decidable relative to language B iff there is an OTM with an oracle for B that decides A.

Define Mapping Reduction and Mapping Reducibility

Let A and B be languages over an alphabet Sigma. We say that A is mapping reducible to B, written A<=mB, if there is a computable function f: Sigma*->Sigma* such that, for every w is in Sigma*, w is in A iff f(w) is in B. The function f is called a mapping reduction of A to B.

Prove If A<=mB and B is decidable, then A is decidable.

Let DB be a decider for B and f be a reduction from A to B. We describe a decider DA for A as follows. DA= "On input w: 1. Compute f(w). 2. Run DB on input f(w) and do whatever DB does."

Definition of Halting Problem

Let HALT TM = {<M,w> | M is a TM and M halts on input w}

Definitions of Running Time and Time Complexity

Let M be a deterministic TM that halts for every input. The running time or time complexity of M is the function f: N->N, where f(n) is the maximum number of steps that M uses on any input of length n. If f(n) is the time complexity of M, we say that M runs in time f(n), or that M is an f(n) time machine.

Definition of time complexity for nondeterministic machines

Let M be a nondeterministic TM that is a decider (meaning that, on every input, each branch of computation halts). The running time or time complexity of M is the function f: N->N, where f(n) is the maximum number of steps that M uses on any branch of its computation on any input of length n.

Definition of Asymptotic Upper Bound

Let f and g be functions f,g: N->R+. Say that f(n) = O(g(n)) iff positive integers c and n0 exists such that for every integer n>=n0, f(n) Less than or equal to cg(n). When f(n) = O(g(n)), we say that g(n) is an asymptotic upper bound for f(n).

Definition of acceptance for a Finite State Automata M

M accepts the string u1 u2 ... un iff there is a sequence r1, r2, ..., rn, rn+1 of states such that: r1=s ri+1 = delta(ri,ui), for each i with 1<= i <= n rn+1 is in F

Definitions of NP, coNP, EXPTIME

NP is the class of languages decided by some nondeterministic polynomial time Turing machine. coNP = {L | L is the complement of some language in NP} EXPTIME = TIME(2^(n^(1))) U TIME(2^(n^(2))) U TIME(2^(n^(3))) U ...

Definition of the class of languages P

P is the class of languages that are decidable in polynomial time on a deterministic (single-tape) TM. In other words, P = TIME(n^1) U TIME(n^2) U TIME(n^3) U TIME(n^4) U ...

Show the nonregularity of B = {0n1n | n>=0}

Proof by contradiction: Assume B is regular. Let then p be its pumping length. Select w is in B with |w| >= p. By the pumping lemma, w=xyz and y can be pumped, so that we must also have xyyz is in B. Case 1: y only has 0s. But then xyyz has more 0s than 1s and is not in B. Case 2: y only has 1s. But then xyyz has more 1s than 0s and is not in B. Case 3: y has both 0s and 1s. But then xyyz has a 1 followed by a 0 and is not in B. All cases lead to contradiction, therefore B is not regular

Show the nonregularity of F = { ww | w is in {0,1}* }

Proof by contradiction: Assume F is regular. Let then p be its pumping length. Observe that 0p10p1 is in F. By the pumping lemma, 0p10p1 =xyz and y can be pumped. By Condition 3, |xy|<=p. Therefore, y is entirely in the first 0p. Pumping y would produce a string that has only 0s is the first half, and two 1s in the second half. Obviously this string cannot be in F, which contradicts with the pumping lemma.

Prove a language is Turing recognizable iff it is enumerable.

Proof of if: Suppose E enumerates L. Construct a TM M that works as follows: M = "On input w: 1. Simulate E. Every time E prints a new string, compare it with w. 2. If w is ever printed, accept." Proof of only if: Suppose M recognizes L. Let s1,s2,s3,... be the lexicographic list of all strings over the alphabet of L. Construct an enumerator E that works as follows: E = " 1. Repeat the following for i=1,2,3,... 2. Simulate M for i steps on each of the inputs s1,s2,...,si. 3. If any computations accept, print out the corresponding sj."

Definition of a regular expression

R is a Regular Expression (RE) iff R is one of the following: 1. a, where a is a symbol of the alphabet 2. The Empty Set 3. The Null Set 4. (R1)U(R2), where R1 and R2 are RE 5. (R1) o (R2), where R1 and R2 are RE 6. (R1)*, where R1 is a RE

Implementation level

Remember to have "M on input w: 1. check if it is in the form if not then reject 2. Mark everything 3. Check if everything is marked, if not then reject, else accept

Grammar ending with something/ starting with somehting Odd grammar

S -> Bb B-> ~~ S->bB B->~~ S->SSS

Definition of Cartesian Product for sets S and T

S X T={(s,t) | s is in S and t is in T}

Prove every nondeterministic TM has an equivalent deterministic TM.

Simulate every possible branch of computation in a breadth-first manner.

Context Free language closed under

Star • Concatenation Union No intersect or complement

Prove that Th(N,+,x) is unrecognizable

Suppose a TM M recognizes Th(N,+, x). Construct a TM D: D = "On input A, and arithmetic sentence, 1. Run M on both A and NOT A in parallel. 2. If M accepts A, accept; if M accepts NOT A, reject" Obviously D decides Th(N,+, *) , which is a contradiction

Prove the Universal Turing Machine is undecidable

Suppose, for a contradiction, that ATM is decidable. That is, there is a TM H that decides ATM. Thus, that machine H behaves as follows: H(<M,w>)= accept if M accepts w reject if M does not accept w Using H as a subroutine, we can construct the following TM D: D = "On input <M>, where M is a TM: 1. Run H on input <M,<M>>. 2. Do the opposite of what H does. That is, if H accepts, reject, and if H rejects, accept." Thus, D(<M>)= accept if M does not accept <M> reject if M accepts <M> But then D(<D>) = accept if D does not accept <D> reject if D accepts <D> contradiction! To summarize: H accepts <M,w> exactly when M accepts w. D rejects <M> exactly when M accepts M. D rejects <D> exactly when D accepts <D>.

Prove that if a language L and its complement NOT L are both recognizable, then L is decidable

The Turing Machine U recognizes the language L The Turing Machine NOT U recognizes the language NOT L let M = "on input w: 1. run U and NOT U on input w in parallel 2. if U reaches its accept state, accept if NOT U reaches its accept state, reject therefore, M decides L

Prove the Universal Turing Machine is recognizable

The following TM U, called the universal TM, recognizes ATM: U = "On input <M,w>, where M is a TM and w is a string: 1. Simulate M on input w. 2. If M ever enters its accept state, accept; if M ever enters its reject state, reject."

What is the variable, temrinal , start

The start is the first thing, Variables include the start state Terminal is the end thing. Terminal does not include empty sttring

Languages of PDA can include what

They can include expressions such as Union, Star ex. {b^n(aUb) ^n | n>=0 }

Regular languages closed under

Union • Intersection • Complement • Star • Concatenation

How to show context free

You can create a CFG from it

Formal definition of a finite automaton

a 5-tuple (Q, Sigma, delta, s, F) Q -> finite set called the states Sigma -> finite set called the alphabet delta -> function of the type Q X Sigma -> Q called the transition function s -> an element of Q called the start state F -> a subset of Q called the set of accept states

Each CFG needs what in it to end it

an empty string

Remeber language is in what notation and what do you need to include with it

include an n and define it, also include set otation

What does the stack not need to be for PDA

it doesnt need to be empty when reaching final state, but the input does need to

REMEMBER what does a^0 b^0 represent

it represents empty, not 1

What is the format for pop and push

push is the very last thing, pop is the middle thing , read is the first thing

L(M), a.k.a., The language recognized by M

the set all strings that the machine M accepts

Church turing

they defined what an algorithm was


Conjuntos de estudio relacionados

ACCT Chapter 9 Plant and Intangible Assets

View Set

2nd half: Sect 2: WA Business Skills & Procedures

View Set

Interpersonal Communications Exam 3

View Set

생활 스페인어 중간 (문장)

View Set

Immuno exam - 1,2,3,4,5 (allt saman)

View Set

PHSC : Information Literacy Quiz

View Set

Important days, date, and numbers

View Set

Milestone 1, Chapter 5: Carbohydrates

View Set

second finance midterm conceptual questions

View Set

Human Physiology Practice Questions

View Set