• 沒有找到結果。

Undergraduate Course ELEMENTS OF COMPUTATION THEORY College of Computer Science

N/A
N/A
Protected

Academic year: 2021

Share "Undergraduate Course ELEMENTS OF COMPUTATION THEORY College of Computer Science"

Copied!
4
0
0

加載中.... (立即查看全文)

全文

(1)

Undergraduate Course ELEMENTS OF COMPUTATION THEORY College of Computer Science

Chapter 4 ZHEJIANG UNIVERSITY

Fall-Winter, 2014

P 191

4.1.2 Let M = (K,

, δ, s, {h}), where K = {q 0 , q 1 , q 2 , h },

= {a, b, ⊔, ◃}, s = q 0 , and δ is given by the following table (the transitions on ◃ are δ(q, ◃) = (q, ◃), and are omitted).

q σ δ(q, σ) q 0 a (q 1 , ←) q 0 b (q 0 , →) q 0 ⊔ (q 0 , →) q 1 a (q 1 , ←) q 1 b (q 2 , →) q 1 ⊔ (q 1 , ←) q 2 a (q 2 , →) q 2 b (q 2 , →) q 2 ⊔ (h, ⊔)

(a) Trace the computation of M starting from the configuration (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba).

(b) Describe informally what M does when started in q 0 on any square of a tape.

Solution:

(a) (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba) ⊢ M (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 0 , ◃abb ⊔bb ⊔ ⊔ ⊔ aba)

M (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 0 , ◃abb ⊔ bb⊔ ⊔ ⊔aba)

M (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 0 , ◃abb ⊔ bb ⊔ ⊔⊔aba)

M (q 0 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 1 , ◃abb ⊔ bb ⊔ ⊔⊔aba)

M (q 1 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 1 , ◃abb ⊔ bb⊔ ⊔ ⊔aba)

M (q 1 , ◃abb ⊔ bb ⊔ ⊔ ⊔ aba)

M (q 2 , ◃abb ⊔ bb⊔ ⊔ ⊔aba)

M (h, ◃abb ⊔ bb⊔ ⊔ ⊔aba)

(b) M scans right until it finds an a, then left until it finds a b, then right again until it

finds a ⊔, and then halts.

(2)

4.1.7 Design and write out in full a Turing machine that scans to the right until it finds two consecutive a’s and then halts. The alphabet of the Turing Machine should be {a, b, ⊔, ◃} .

Solution:

K = {q 0 , q 1 , h },

= {a, b, ⊔, ◃}, s = q 0 , H = {h}, δ is given by the following table:.

q σ δ(q, σ) q 0 a (q 1 , →) q 0 b (q 0 , →) q 0 ⊔ (q 0 , →) q 0 (q 0 , →) q 1 a (h, a) q 1 b (q 0 , →) q 1 ⊔ (q 0 , →) q 1 (q 0 , →)

4.1.10 Explain what this machine does.

> R −−−→

a ̸=⊔ R −−−→

b ̸=⊔ R aR b

Solution:

This machine scans to right, remembering the first and the second nonblank symbols (respectively a and b) it encounters. It then continues to the right, writing a in the first blank it encounters, and b in the second.

P 200

4.2.2 Present Turing machines that decide the following languages over {a, b}.

(a) (b) {e}

(d) {a}

Solution:

(3)

4.2.4 (a) Given an example of a TM with one halting state that does not compute a function from strings to strings.

(b) Given an example of a TM with two halting states, y and n, that does not decide a language.

(c) Can you given an example of a TM with one halting state that does not semidecide a language

Solution:

(c) On each input, a TM either halts or does not. The language semidecided by TM M is simply the set of input strings on which M halts. No Turing can fail to semidecide some language.

P 232

4.6.2 Find grammars that generate the following languages:

(a) {ww : w ∈ {a, b} } (b) {a 2

n

: n ≥ 0} (c) {a n

2

: n ≥ 0}

Solution:

(a) V = {a, b, A, B, S, T, U, [, ], $, x}

Σ = {a, b}

R = {S → [T ] T → xT x T → $U U x → AaU U x → BbU xA → Ax xB → Bx [A → a[

[B → b[

[$ → e

U ] → e}

(4)

(b) V = {a, S, M, $}

Σ = {a}

R = {S → T a$

T → T M T → e M a → aaM M $ → $

$ → e}

(c) V = {a, S, T, B, C, $}

Σ = {a}

R = {S → $T $ T → BT C T → e BC → CaB

$C$ → $ B$ → $

$ → e}

P 242

4.7.2 Show the following functions are primitive recursive:

(a) f actoria(n) = n!

(b) gcd(m, n), the greast comon divisor of m and n

Solution:

(a) f actoria(n) is the function defined recursively by g(0) = 1 and h(m, r) = (m + 1) · r

(b) gcd(m, n) =

{ n, rem(m, n) = 0,

gcd(n, rem(m, n)), otherwise

參考文獻

相關文件

• As the binary quadratic programming program is NP-hard in general, identifying polynomially solvable subclasses of binary quadratic programming problems not only offers the-

When we know that a relation R is a partial order on a set A, we can eliminate the loops at the vertices of its digraph .Since R is also transitive , having the edges (1, 2) and (2,

Should an employer find it necessary to continue the employment of the Class A Foreign Worker(s), the employer shall, within four (4) months prior to the expiration of the

Write the following problem on the board: “What is the area of the largest rectangle that can be inscribed in a circle of radius 4?” Have one half of the class try to solve this

A cylindrical glass of radius r and height L is filled with water and then tilted until the water remaining in the glass exactly covers its base.. (a) Determine a way to “slice”

As with all poetry, is-poems are a little more complicated than it looks. You need to write down all your associations and ideas and then just select a few, adding the

17-1 Diffraction and the Wave Theory of Light 17-2 Diffraction by a single slit.. 17-3 Diffraction by a Circular Aperture 17-4

Each unit in hidden layer receives only a portion of total errors and these errors then feedback to the input layer.. Go to step 4 until the error is