この計算の正式な定義について説明してください


7

私はTAOCPをもう一度攻撃しようとしています。真剣に取り組むのに苦労しているボリュームの文字通りの重さを考えると。TAOCP 1のKnuthによる書き込み、8ページ、基本概念::

しましょう A有限の文字セットであること。しましょうA すべての文字列のセットである A (すべての順序付けされたシーケンスのセット バツ1x1 バツ2x2 ... バツxn どこ 0n0 そして バツjxj にあります A ために 1j1jn)。アイデアは、計算の状態をエンコードして、A。さあNN 非負の整数であり、Q(状態)はすべての集合 σj(σ,j)、 どこ σσ にあります A jは整数です 0jN0jN; させるI (入力)Qのサブセット j=0j=0 そしてましょう ΩΩ (出力)のサブセットになる j=Nj=N。もしθθ そして σσ 文字列です A、私たちはそれを言う θθ で発生します σσ もし σσ 形をしています αθωαθω 文字列用 αα そして ωω。定義を完了するには、ff 文字列で定義される次のタイプの関数であること θjθjφjϕj と整数 ajajbjbj ために 0jN0jN

  • fσj=σajf((σ,j))=(σ,aj) もし θjθj 発生しない σσ
  • fσj=αψjωbjf((σ,j))=(αψjω,bj) もし αα は可能な最短の文字列です σ=αθjωσ=αθjω
  • fσN=σNf((σ,N))=(σ,N)

コンピューターサイエンティストではないので、通路全体を把握するのに苦労します。私はオペコードのシステムの背後にあるアイデアをちょっと理解しましたが、理解するのに効果的に進んでいません。主な問題は、効果的な読み方がわからないことだと思います。

上記の文章を理解して理解できるように説明し、これらのステートメントを解釈するロジックを理解するための戦略を教えてもらえますか?


次に、主張された引用にコメントを含めないでください。本が手元にない人を混乱させます。-.-私の答えがお役に立てば幸い
ラファエル

@Raphael:引用は本から逐語的です。Iとオメガの記号の括弧内に説明を追加しました
Stefano Borini

@SteanoBorini:しかし、それは「説明」ではなく、間違っています。元のテキストを読んで、あなたがしたのと同じ結論に至る方法を私は理解していますが、それでもまだ役に立ちません。何かを引用してコメントを追加する場合は、そのようにマークを付けて、人々が塩の粒でそれをとることができるようにしてください。
ラファエル

ここにはコンテキストがありません:どの計算とどの状態ですか?
reinierpost 2014

回答:


8

一部のコンテキストが欠落しているため、Knuthがどのようなことを試みているのかわかりませんが、チューリングマシンをこのように解釈する方法を次に示します。おそらく、それは何が起こっているのかを理解するのに役立ちます。一般に、コンセプトを把握するための良い方法は、それをいじることです。プログラミングパラダイムの場合、それはプログラムを書くことを意味します。この場合、私は書く方法が表示されます任意のプログラムを。

チューリングマシンのテープに記号があるとします。 {01ε}{0,1,ϵ} (どこ εϵ 「空」を表します)、頭の位置を表すもう1つの記号を追加します HH。あなたの状態は次の形式のペアになりますqα(q,α)、 どこ qq チューリングマシンの状態であり、 α{014}α{0,,14}。また、F0(F,0)NN 最終状態。

(空ではない)入力時 バツx、あなたの出発点は Hバツs0(Hx,(s,0))、 どこ ss is the starting state. The difficult part is to encode states. Suppose that at state qq, upon reading input xx, you replace it with a(q,x)a(q,x), move in direction D(q,x){L,R}D(q,x){L,R}, and switch to state σ(q,x)σ(q,x). For the θθs, we have θq,0=0H0,θq,1=0H1,θq,2=0Hϵ,θq,3=1H0,θq,4=1H1,θq,5=1Hϵ,θq,6=ϵH0θq,7=ϵH1,θq,8=ϵHϵ,θq,9=H0,θq,10=H1,θq,11=Hϵ,θq,12=0H,θq,13=1H,θq,14=ϵH.

θq,0θq,3θq,6θq,9θq,12=0H0,=1H0,=ϵH0=H0,=0H,θq,1θq,4θq,7θq,10θq,13=0H1,=1H1,=ϵH1,=H1,=1H,θq,2θq,5θq,8θq,11θq,14=0Hϵ,=1Hϵ,=ϵHϵ,=Hϵ,=ϵH.
For the aas, we have aq,i=(q,i+1)aq,i=(q,i+1) for i<14i<14, and aq,14=(q,14)aq,14=(q,14), though we should never really get that far. For the bbs, we have bq,0=bq,3=bq,6=bq,9=(σ(q,0),0),bq,1=bq,4=bq,7=bq,10=(σ(q,1),0),bq,2=bq,5=bq,8=bq,11=bq,12=bq,13=bq,14=(σ(q,ϵ),0).
bq,0=bq,3=bq,6=bq,9=(σ(q,0),0),bq,1=bq,4=bq,7=bq,10=(σ(q,1),0),bq,2=bq,5=bq,8=bq,11=bq,12=bq,13=bq,14=(σ(q,ϵ),0).
Now it remains to determine the ψψs. Let a0=a(q,0)a0=a(q,0). If D(q,0)=LD(q,0)=L then ψq,0=H0a0,ψq,3=H1a0,ψq,6=ψq,9=Hϵa0.
ψq,0=H0a0,ψq,3=H1a0,ψq,6=ψq,9=Hϵa0.
If D(q,0)=RD(q,0)=R then ψq,0=0a0H,ψq,3=1a0H,ψq,6=ϵa0H,ψq,9=a0Hϵ.
ψq,0=0a0H,ψq,3=1a0H,ψq,6=ϵa0H,ψq,9=a0Hϵ.
Next, let a1=a(q,1)a1=a(q,1). If D(q,1)=LD(q,1)=L then ψq,1=H0a1,ψq,4=H1a1,ψq,7=ψq,10=Hϵa1.
ψq,1=H0a1,ψq,4=H1a1,ψq,7=ψq,10=Hϵa1.
If D(q,1)=RD(q,1)=R then ψq,1=0a1H,ψq,4=1a1H,ψq,7=ϵa1H,ψq,10=a1Hϵ.
ψq,1=0a1H,ψq,4=1a1H,ψq,7=ϵa1H,ψq,10=a1Hϵ.
Finally, let aϵ=a(q,ϵ)aϵ=a(q,ϵ). If D(q,ϵ)=LD(q,ϵ)=L then ψq,2=H0aϵ,ψq,5=H1aϵ,ψq,8=ψq,11=Hϵaϵ,ψq,12=H0aϵ,ψq,13=H1aϵ,ψq,14=Hϵaϵ.
ψq,2ψq,12=H0aϵ,=H0aϵ,ψq,5ψq,13=H1aϵ,=H1aϵ,ψq,8ψq,14=ψq,11=Hϵaϵ,=Hϵaϵ.
If D(q,ϵ)=RD(q,ϵ)=R then ψq,2=0aϵH,ψq,5=1aϵH,ψq,8=ϵaϵH,ψq,11=aϵHϵ,ψq,12=0aϵH,ψq,13=1aϵH,ψq,14=ϵaϵH.
ψq,2ψq,12=0aϵH,=0aϵH,ψq,5ψq,13=1aϵH,=1aϵH,ψq,8ψq,14=ϵaϵH,=ϵaϵH.ψq,11=aϵHϵ,

Now apply ff repeatedly until you get stuck. If you follow the construction, you will see that we have simulated the running of the Turing machine.


understood: nothing. Not your fault. Thank you anyway :(

3
"We are missing some context." It's: we should have some precise description of what we mean by a 'method of computation'; here's one given by A.A. Markov; there are other equivalent ones, such as Turing machines.
rgrig

6

Let us break it down bit by bit. First of all, remember what Knuth wrote on page 7:

Let us formally define a computational method to be a quadruple (Q,I,Ω,f)(Q,I,Ω,f), in which QQ is a set containing subsets II and ΩΩ, and ff is a function from QQ into itself. [...] The four quantities QQ, II, ΩΩ, ff are intended to represent repectively the state of the computation, the input, the output, and the computational rule.

This is the outline. You have to read "represent" as "contain"; QQ is going to contain states (some of which are in II, some are in ΩΩ) and ff is going to be a transition function between states; think of it as a program.

Let AA be a finite set of letters. Let AA be the set of all strings in AA (the set of all ordered sequences x1x1 x2x2 ... xnxn where n0n0 and xjxj is in AA for 1jn1jn).

This is just a reiteration of what AA is. See also here.

The idea is to encode the states of the computation so that they are represented by strings of AA.

This is probably the key sentence. We are talking about computations, that is execution sequences of some (programming language) statements which manipulate some state, which can be thought of as values in memory cells, or valuations of variables. Knuth says here that he wants to encode these states in an abstract way, namely as word over some alphabet.

Example: Consider a program that uses (at most) kk variables, each of which stores an integer. That is, a state is given by the tuple of values (x1,,xk)(x1,,xk) where xkxk is the (current) value of the kk-th variable. In order to encode states of this form in a formal language, we can choose A={0,1,#}A={0,1,#} with ## a separator. Now model such a state by #¯x1##¯xk##x1¯¯¯¯¯##xk¯¯¯¯¯# where ¯xixi¯¯¯¯¯ is the binary encoding of xixi.

Specifically, (3,5,0)(3,5,0) would be #11#101#0##11#101#0#.

Now let NN be a non-negative integer and Q be the set of all (σ,j)(σ,j), where σσ is in AA and j is an integer 0jN0jN; let II be the subset of Q with j=0j=0 and let ΩΩ be the subset with j=Nj=N.

You misquoted there (bad Stefano!); the parentheses are not in the original text, and they were misleading (see above). Knuth defines QQ here as the set of all possible states (σAσA) at all possible places in the computation (jj can be understood as program counter). Therefore, QQ contains all statement-indexed states any computation of the algorithm given by ff can assume. By definition, we start with program counter 00 and end in NN, thus states indexed 00 are input states and those indexed NN are output states.

If θθ and σσ are strings in AA, we say that θθ occurs in σσ if σσ has the form αθωαθω for strings αα and ωω.

I hope that this is clear; it is just a (re)definition of substrings.

To complete our definition, let ff be a function of the following type, defined by the strings θjθj, ϕjϕj and the integers ajaj, bjbj for 0jN0jN:

  • f((σ,j))=(σ,aj)f((σ,j))=(σ,aj) if θjθj does not occur in σσ
  • f((σ,j))=(αψjω,bj)f((σ,j))=(αψjω,bj) if αα is the shortest possible string for which σ=αθjωσ=αθjω
  • f((σ,N))=(σ,N)f((σ,N))=(σ,N)

This is a a small programming language; if you fix θj,ψj,aj,bjθj,ψj,aj,bj, you have a program. On program counter jj, ff replaces the left-most occurrence θjθj in the state with ψjψj and goes to statement bjbj. If there is no θjθj in the current state, it goes to statement ajaj. The program loops if statement NN is reached, modelling termination.

On the upper half of page 8, there is a more concrete example of a "program" ff. Keep in mind that Knuth is going to use assembly language later on; this informs how he looks at programs (atomic statements connected by jumps).


1
Now I got a bit better understanding of what is going on. However, two things are still not clear and I would really appreciate if you could expand your answer. First, θj,ψj,aj,bj - what are these strings and numbers? What do they represent? If I understand correctly, aj and bj represent the step number or command counter for state j+1. But I am not sure what θj,ψj strings mean. Can you explain what do you mean by " if you fix θj,ψj,aj,bj, you have a program"? Or rather, how would I fix it for some example?
Georgy Bolyuba

@GeorgyBolyuba: You are right about ajaj and bjbj. The program's state is a string σσ and a "program counter" jj. θjθj and ψjψj are used to modify that state (see second case of ff). They can have all kinds of shapes; it really depends on how you encode state as a string. See the book for an example.
Raphael

5

That text describes the following (Python) pseudocode:

subs = a list of string pairs  
As = a list of integers  
Bs = a list of integers

def f(state, pc):  
  if pc == N: return (state, pc)  
  if state.find(subs[pc][0]) != -1:  
    return (state.replace(subs[pc][0],subs[pc][1],1), Bs[pc])  
  else:  
    return (state,As[pc])  

The function f is presumably going to be applied repeatedly.

The last three bullet points is all you really need once you understand the notations. All that comes before is a bit analogous to explaining how Python works before giving the Python code.


Ah ok, it's a Turing machine.
Stefano Borini

1
Rather, it is a different model of computation with the same power as a Turing machine.
Yuval Filmus

Well, three lines below your quote Knuth says that this is equivalent to Turing machines, so presumably you already knew this when you asked. I thought you were asking for help with the notation. Now I have no idea what is it that you wanted to ask.
rgrig
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.