Skip to Content
深入理解運算原理|從簡單的機器到無所不能的程式
book

深入理解運算原理|從簡單的機器到無所不能的程式

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
148
|
5
決定論
設計成決定論的特定圖靈機,則必須遵守和決定論下推自動機相同的限制(請見第 116
頁的『決定論』),然而這次我們不必擔心自由移動,因為圖靈機沒有這種機制。
圖靈機下個動作的選擇,是根據它的目前狀態和目前在它磁帶頭下的字元,因此決定論
機器對狀態和字元的每種組合只能有一條規則(『無矛盾』規則),這是為了防止它下一
個動作有任何的模糊。為了簡單起見,我們將放寬『無遺漏』規則,正如我們在 DPDA
所做的,並且假設若無適用規則,機器可以進入絕對的停止狀態,而非堅持每種可能的
狀況它都必須有對應的規則。
模擬物
我們已經清楚瞭解決定論圖靈機應該如何運作,現在讓我們建置 Ruby 模擬物以便觀察
它的實際運作。
1 步是實作圖靈機磁帶。雖然這項實作物很明顯的必須儲存那些寫入磁帶的字元,但
是也需要記住磁帶頭目前的位置,才能讓模擬的機器可以讀取目前字元、在目前位置寫
入新字元,並且將磁帶頭左右移動而到達其他位置。
完成這件工作的簡潔方式是將磁帶分成 3 個獨立的部分(磁帶頭左側的所有字元、磁帶
頭底下的單一字元、磁帶頭右側的所有字元),並且分別儲存每個部分。這會讓它很容
易就能讀取和寫入目前字元,而在這 3 個部分之間隨意移動就能移動磁帶頭;例如向右
移動一個方塊,意謂著目前字元會變成磁帶頭左側的最後一個字元,而且磁帶頭右側的
1 個字元會變成目前的字元。
我們的實作物也必須維持磁帶無限長並填滿空白方塊的錯覺,但所幸為此我們不需要無
限大的資料結構。在任何指定時刻可以讀取的唯一磁帶位置,是在磁帶頭底下,因此只 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JSON實務手冊

JSON實務手冊

Tom Marrs

Publisher Resources

ISBN: 9789864766000