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

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

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
286
|
8
相當隱約且又高度敏感;如果將迴圈裡的
n = n - 1
陳述式改成
n = n - 2
,程式只會在
輸入長度為偶數時停止。知道 Ruby 和數值的所有事實,以及如何相互串連事實而對這
種程式做出準確決定,都需要大型且複雜的停機核對器。
根本的難題是很難預測程式不需實際執行而會完成什麼。以
#evaluate
行程式來瞭解它是否停止的確非常有吸引力,但這並不好:如果程式不停
止,
#evaluate
將會永遠執行,但無論我們等待多久,都無法從
#halts?
到答案。任何可靠的停止檢測演算法,都必須找到一種能在有限時間內以
檢閱和分析程式本文產生最終確定答案的作法(而非只是執行和等待)。
絕對無法運作的狀況
好的,所以我們的直覺告訴我們
#halts?
將難以正確實作,但並不一定意謂著停機問
題就是無法決定。事實證明只要給予足夠的努力和才能,許多困難的問題(例如編寫
#evaluate
)都就可以迎刃而解;如果停機問題是無法決定的,那就意謂著編寫
#halts?
不僅是極端困難,而且根本
不可能
我們怎麼知道適當的
#halts?
實作物不可能存在?如果這只是工程問題,為什麼我們不
將諸多的程式開發人員對著它丟過去,並在最後提出解決方案呢?
難以置信
讓我們暫時假裝停機問題是可以決定的。在這個虛構的世界,可以編寫出完整的
#halts?
實作物,因此呼叫
halts?(program, input)
勢必回到任何
program
input
true
false
的答案,而且如果在標準輸入以
input
執行它,這個答案必能正確預測 ...
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