Theory of Computation Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Show that, if L_1 and L_2 are any two regular languages, then (L_1)^(c)L_2 is also a regular language.

(Approach 2, using closure properties) We proved in Lecture 4 that FA-recognizable languages are closed under complement, and in Lecture 5 that FA-recognizable languages are exactly equivalent to regular languages; therefore, we can deduce that (L_1)^c is regular. Because L_2 is also regular, (L_1) c^L_2 is the concatenation of two regular languages. We proved in Lecture 3 that regular languages are closed under complement, and so (L_1)^cL_2 must be regular

Flip card to see photo of problem: Give the solution for the following strings: (a) 0 (b) 00 (c) 000 (d) 000000

(a) q_1 → q_2 → q_accept (b) q_1 → q_2 → q_3 → q_5 → q_5 → q_2 → q_2 → q_accept (c) q_1 → q_2 → q_3 → q_4 → q_reject (d) q_1 → q_2 → q_3 → q_4 → q_3 → q_4 → q_3 → q_5 → q_5 → q_5 → q_5 → q_5 → q_5 → q_2 → q_2 → q_3 → q_3 → q_4 → q_4 → q_reject

Can a Turing Machine's head ever stay in the same location for two steps back to back?

Two possible interpretations: (a) Assuming a tape that is infinite in both directions: the transition function requires that the TM move either LEFT or RIGHT on the tape during each transition, and so the TM can never stay in the same place. (b) Assuming a tape that is infinite only in one direction: if the TM is on the first tape square and it tries to move LEFT, it will stay in place instead of falling off the tape.

For each of the following Regular Expressions (REs) on the alphabet Σ = [a, b, c], identify one word that is in the language recognized by the RE, and one word that is not in the language (a + b)/*/(b + c)/*/

We might describe this language as "any string containing any combination of the three letters {a, b, c}, where no a appears after the first c" In examples: {∈, a, b, c, ab, ba, bc, cb, ac, abb, abc, bac, acc, etc.} Out examples: {abca, cbba, etc.}

Give a regular expression for each of the following languages. In all cases, the alphabet is Σ = {0, 1}. {w ∈ Σ* | w has an odd number of 0s}

1*0(01*0 + 1)*

The pigeonhole principle is the following somewhat intuitive observation: If you have n pigeons in k pigeonholes and if n > k, then there is at least one pigeonhole that contains more than one pigeon. Even though this observation seems obvious, it's a good idea to prove it. Prove the pigeonhole principle using a proof by contradiction.

Assume that there is at most one pigeon in each of the k holes. If we count up the number of pigeons across all the holes, we have at most k pigeons (if all the holes are filled). However, we are given that n > k. Thus, we haven't accounted for (n − k) > 0 pigeons, and so we arrive at a contradiction: at least one hole must contain more than one pigeon if all n pigeons are to fit.

Consider the following language: COMPOSITE_TM = { <M,w> | M is a TM and M halts on w in n = ab steps for some integers a, b} What is the smallest class that contains this language (finite, regular, context-free, decidable, recognizable, or unrecognizable)? Prove it.

At first glance, this problem feels a lot like UNDER_10 from Lecture 12 (which we showed was decidable). However, the key difference here is that with UNDER_10 we knew in advance how many steps we needed to run before we could make a decision. Here, the value of n is unknown until M halts on w, at which point we would then make an additional check to determine if n was composite. This implies that we would need to be able to determine first whether or not M halts on w: equivalent to HALT, which we know is undecidable but recognizable.

Give a regular expression for each of the following languages. In all cases, the alphabet is Σ = {0, 1}. {w ∈ Σ ∗ | w contains at least two 0s or exactly two 1s}

Σ/*/0Σ/*/0Σ* + 0/*/10/*/10/*/

Prove that the language PAL = {w ∈ {0, 1}* : w = w^R} is not regular. Hint: use the Pumping Lemma

BEFORE IMAGE: Suppose that PAL is a regular language. Let N be the constant selected by the Pumping Lemma, and consider the string w = 0^N10^N . Note that w ∈ P AL since w = w^R, and |w| = 2N + 1 ≥ p, so the Pumping Lemma will hold. Thus, we can split the string w into 3 parts w = xyz satisfying the following conditions: AFTER IMAGE: This contradiction implies that P AL must be a nonregular language.

Show that if L is a regular language, then: L^R = {w^R | w ∈ L and w_R is the word w written in reverse} is also a regular language (i.e. regular languages are closed under reversal). Hint: try induction!

Because L is regular, there must exist some regular expression E that expresses it. We will prove that L^R is also regular by demonstrating (by induction) how to reverse the regular expression E to produce E^R, a regular expression that matches L^R.

Give a regular expression for each of the following languages. In all cases, the alphabet is Σ = {0, 1}. {w ∈ Σ ∗ | w ends in a double letter (00 or 11)}

Σ*(00 + 11)

Draw FAs that recognize each of the following languages using the specified number of states. In all cases, the alphabet is Σ = {0, 1}. And convert the FA to a regular expression. {w ∈ Σ* | w ends with 00} using three states.

Σ*00

Determine whether each of the following is true or false. If it is true, prove it. If it is false, give a counterexample. Every prime number is odd.

FALSE: 2 is an even prime number.

Determine whether each of the following is true or false. If it is true, prove it. If it is false, give a counterexample. If x and y are integers with x < y, then there is an integer z such that x < z < y.

FALSE: if x and y are consecutive integers, by definition there does not exist an integer value that lies between them.

Recall the protocol for playing roulette-by-phone by which our gambler Alice commits herself to a color x ∈ {blue, yellow} without revealing x to her adversary Bob: Alice first chooses two large random prime numbers P and Q, one of which ends in a 7 if and only if x = blue. She then computes their product N = P Q and sends N to Bob, but keeps the factors P and Q to herself. To reveal the value of x later, Alice sends P and Q to Bob, whereupon he checks: (i) the value x encoded by P, Q (i.e. x = blue if P or Q ends in 7, otherwise x = yellow) (ii) P and Q are indeed prime numbers, and (iii) P Q = N. Suppose Bob forgets to check that P and Q are prime. Does the protocol still work correctly, and if not, what can go wrong?

If Bob forgets to check that P and Q are prime, Alice could cheat in the following way: instead of selecting two primes she selects three primes A, B, C where A ends in 1, B ends in 3, and C ends in 7. She falsely claims to have selected a color, and sends the product ABC to Bob. After Bob spins the wheel and announces the winning color, only then does Alice make her selection: is the winning color is blue, she sends AB and C to Bob for validation. Because C ends in 7 and AB ends in 3, Bob believes that her bet was blue. If instead the winning color is yellow, Alice sends over A and BC. Because neither A nor BC ends in 7, Bob believes that her bet was yellow. Thus, Alice wins in either case.

Draw FAs that recognize each of the following languages using the specified number of states. In all cases, the alphabet is Σ = {0, 1}. And convert the FA to a regular expression. {w ∈ Σ* | w contains at least two 0s, or exactly two 1s} using six states.

Σ*01*0Σ* + 0*10*10*

Show that any language L containing only finitely many strings is regular.

Let L be a finite language, and consider any word w = σ_i ...σ_k ∈ L. We can define a regular expression that accepts w simply by using the letters σ_i ...σ_k concatenated together with no parentheses, +, or * (in other words, any finite string is a RE that matches only itself ). We generate such a RE for each word w ∈ L, and we then combine these RE using the + operator. Because regular expressions are closed under union, this is a regular expression that recognizes exactly L. Example: the regular expression that recognizes the language L = {100, 01110, 101010} is 100 + 01110 + 101010. This procedure only works for finite languages, because regular expressions cannot be infinitely long

Can a Turing Machine contain just a single state?

No. A TM must contain at least two states, because q_accept can't equal q_reject. Additionally, because landing in either of these states immediately halts the computation, a third start state would be necessary in order for the TM to read any input.

Can the tape alphabet Γ be the same as the input alphabet?

Nope - Γ always contains the blank symbol, but the input alphabet Σ cannot contain this symbol. If the blank symbol were included in the input alphabet, the TM would never know when the input actually ends!

For each of the following Regular Expressions (REs) on the alphabet Σ = [a, b, c], identify one word that is in the language recognized by the RE, and one word that is not in the language a + bc*

Note: order of operations dictates that * is resolved before + We might describe this language as "any string that is either a single a, or a single b followed by zero or more cs" In examples: {a, b, bc, bcc, bccc, etc.} Out examples: {∈, c, ac, abc, etc.}

Draw FAs that recognize each of the following languages using the specified number of states. In all cases, the alphabet is Σ = {0, 1}. And convert the FA to a regular expression. {w ∈ Σ* | w contains the substring 0101} using five states.

Σ*0101Σ*

Determine whether each of the following is true or false. If it is true, prove it. If it is false, give a counterexample. Every prime number greater than 2 is odd.

TRUE. By contradiction - let p be an even prime number greater than 2. All even numbers are divisible by 2, and so p is divisible by 2. Thus, p has at least one factor, which contradicts the assertion that p was prime.

For each of the following Regular Expressions (REs) on the alphabet Σ = [a, b, c], identify one word that is in the language recognized by the RE, and one word that is not in the language a/*/bbc/*/

We might describe this language as "any string that begins with zero or more as, followed by exactly two b's, followed by zero or more c's" In examples: {bb, abb, bbc, abbc, aabb, abbcc, etc.} Out examples: {∈, a, c, ac, abc, abac, etc.}

For each of the following English arguments, express the argument in terms of propositional logic and determine whether the argument is valid or invalid: Theoretical computer science is awesome. Theoretical computer science is challenging. Theoretical computer science is awesome and challenging.

We start by labeling the following propositions: A = theoretical computer science is awesome B = theoretical computer science is challenging. If we accept the assertion that A = TRUE and B = TRUE, then applying the boolean operator (A ∧ B) also yields a TRUE statement. Thus, the argument is valid.

For each of the following English arguments, express the argument in terms of propositional logic and determine whether the argument is valid or invalid: On Tuesday afternoons, we either go to the library or study at home. It is Tuesday afternoon and we are not at the library. Therefore, we must be studying at home.

We start by labeling the following propositions: A = Tuesday afternoon B = go to library C = study at home The first sentence asserts that A→(B ∨ C). We are then given that the value of A = TRUE and B = FALSE. Given those values, the only way for A→(B ∨ C) to evaluate to true is for C = TRUE. The argument is valid.

For each of the following English arguments, express the argument in terms of propositional logic and determine whether the argument is valid or invalid: If there are raisins in the cookies at tea, Jordan won't eat them. If Jordan doesn't eat cookies at tea, he gets sad. Jordan is sad. Therefore, there must have been raisins in the cookies at tea.

We start by labeling the following propositions: A = raisins in the cookies B = Jordan doesn't eat the cookies C = Jordan is sad The first sentence asserts that A→B, and the second sentence asserts that B→C. We are given that the value of C = TRUE. However, the final assertion incorrectly reverses the implications in the first two sentences (i.e. C → B and B → A), and from this incorrectly infers that A = TRUE. Thus, the argument is invalid.

Can a Turing Machine ever write the blank □ symbol on its tape?

Yes. If we look at the definition of the transition function, we see that the machine can write any symbol from the tape alphabet Γ to the tape. Additionally, the blank symbol is required to be included in Γ (although it is not part of the input alphabet).


Set pelajaran terkait

Outcomes Intermediate Vocabulary Builder Unit 3 part 2

View Set

(3) INDS 111 - Refugee Health & Canada's Refugee System

View Set

Burns Chapter 22, 31, 33, 26, 28, 7, 24, 19

View Set

Rad Onc ACR Questions Lung/Thorax/Thymoma

View Set

Biology chemical reactions chapter 6 section 2&4 k

View Set