プリンキピア

第3章データ構造とアルゴリズム

3.6 Computer Science Theory3.6 コンピューターサイエンスの理論

Learning Objectives学習目標
By the end of this section, you will be able to:
この節を終えると、次のことができるようになる。
• Understand the models and limits of computing
・計算のモデルと限界を理解する。
• Relate Turing machines to algorithms
・チューリングマシンとアルゴリズムを関連付ける。
• Describe complexity classes
・計算量クラスを説明する。
• Interpret NP-completeness
・NP完全性を理解する。
• Differentiate between P and NP
・PとNPを区別する。
Throughout this chapter, we have introduced several techniques and canonical case studies for the design and analysis of algorithms—oftentimes focusing on the ideas and details behind individual algorithms. But the study of algorithms is more than just the study of individual algorithms, algorithm design, or even algorithm analysis.
英語のヒント
本章では、アルゴリズムの設計と解析について、いくつかの技法や標準的な事例を紹介し、個々のアルゴリズムの背後にある考え方や詳細に注目してきた。しかし、アルゴリズムの研究は、個々のアルゴリズムやその設計、さらにはその解析を研究するだけにとどまらない。

Models of Computation計算モデル

Computers include basic algorithms for solving problems like adding, subtracting, or comparing two numbers. Computers, owing to their roots in calculators, are optimized to solve these problems; these basic algorithms are constant-time operations. What programming offers is the ability to define our own algorithms that can be used to solve more complex problems, such as searching, sorting, and hashing. Unfortunately, these programmed algorithms are not as fast as basic operations. We have even seen certain problems deal with a combinatorial explosion in the number of potential solutions. For many of these problems, the best-known algorithms do not do much better than brute-force, which takes exponential time.
英語のヒント
コンピューターは、2つの数の加算、減算、比較などの問題を解く基本的なアルゴリズムを備える。計算機を起源とするため、こうした問題を解くように最適化されており、これらの基本アルゴリズムは定数時間の操作である。プログラミングが可能にするのは、探索、整列、ハッシュ法など、より複雑な問題を解く独自のアルゴリズムの定義である。残念ながら、プログラムで作るこれらのアルゴリズムは、基本操作ほど速くない。解候補の数が組合せ爆発を起こす問題も見てきた。こうした多くの問題では、知られている最良のアルゴリズムでも、指数時間を要する総当たり法と比べて、それほど大きく改善していない。
In the bigger picture, computer science engages the central question of how humans can encode intelligence. Our discussion of algorithm design grounded the activity in problem modeling, the process of encoding a complex real-world phenomenon or problem in a more abstract or simple form. How is problem modeling constrained by the model of computation, or the rules of the underlying computer that executes an algorithm? Why are certain problems challenging for computers to execute?
英語のヒント
もっと大きく捉えると、コンピューターサイエンスは、人間が知性をどう符号化できるかという中心的な問いに取り組む。アルゴリズム設計の議論では、その活動を問題のモデル化に基づくものとした。これは、現実世界の複雑な現象や問題を、より抽象的、あるいは単純な形に符号化する過程である。問題のモデル化は、計算モデル、すなわちアルゴリズムを実行するコンピューターの根本的な規則によって、どのように制約されるだろうか。ある種の問題の実行が、コンピューターにとって難しいのはなぜだろうか。
Combinatorial explosion poses a problem for computer algorithms because our model of computation assumes computers only have a single thread of execution and only execute one basic operation on each step. If we overturn some part of this assumption, either by creating computers with multiple processors or by creating more sophisticated operations, then it might be possible to deal with combinatorial explosion. Almost all of today’s computer hardware, ranging from massive supercomputers to handheld smartphones, rely at least to some degree on expanding the model of computation to compute solutions to problems more efficiently. Even so, much of today’s computer hardware still relies on the same fundamental programming assumptions: that there are variables to represent data and arithmetic or logical operations.
英語のヒント
組合せ爆発がコンピューターのアルゴリズムにとって問題になるのは、計算モデルが、実行のスレッドは1本しかなく、各ステップでは基本操作を1つしか行わないと仮定するためである。複数のプロセッサーを持つコンピューターや、より高度な操作を作って、この仮定の一部を覆せば、組合せ爆発に対処できるかもしれない。今日のほぼすべてのコンピューターハードウェアは、巨大なスーパーコンピューターから手持ちのスマートフォンまで、多かれ少なかれ、計算モデルを拡張して問題の解をより効率よく計算することに頼っている。それでも、その多くは、データを表す変数と、算術演算や論理演算があるという、同じ基本的なプログラミングの仮定に依存している。

Turing Machinesチューリングマシン

In the 1800s, Charles Babbage imagined a mechanical machine—the Analytical Engine—that could automatically calculate mathematical formulas. Ada Lovelace then extrapolated that the Analytical Engine could solve more general algorithms by using loops to repeat processes and variables to represent data. Lovelace’s vision of algorithms represented a synthesis between human intuition and mathematical reasoning. In the mid-1900s, Lovelace’s ideas inspired Alan Turing to imagine a more general notion of algorithms and machines that could run those algorithms. A Turing machine is an abstract model of computation for executing any computer algorithm. A Turing machine describes computers in terms of three key ideas:
英語のヒント
1800年代、チャールズ・バベッジは、数式を自動で計算できる機械式の装置「解析機関」を構想した。続いてエイダ・ラヴレスは、処理を繰り返すループとデータを表す変数を使えば、解析機関でさらに一般的なアルゴリズムを解けると推論を広げた。ラヴレスのアルゴリズムの構想は、人間の直観と数学的推論の統合を表していた。1900年代半ば、ラヴレスの考えに刺激を受け、アラン・チューリングは、アルゴリズムと、それを実行できる機械について、より一般的な概念を構想した。チューリングマシンは、任意のコンピューターアルゴリズムを実行するための抽象的な計算モデルである。次の3つの主要な考え方によって、コンピューターを記述する。
1. a memory bank for storing data.
1. データを保存するメモリバンク。
2. an instruction table, where each instruction can either: a. store a value to the memory bank.
2. 命令表。各命令は、次のいずれかを行う。a. メモリバンクへ値を保存する。
b. retrieve a value from the memory bank. c. perform a basic operation on a value. d. set which instruction will be executed next by modifying the program counter.
b. メモリバンクから値を取得する。c. 値に基本操作を行う。d. プログラムカウンターを変更し、次に実行する命令を設定する。
3. a program counter that keeps track of the current instruction in the instruction table.
英語のヒント
3. 命令表の現在の命令を追跡するプログラムカウンター。
A Turing machine executes a computer algorithm by following each instruction specified by the program counter. An algorithm can use these basic operations to compute the sum of 1 and 1.
英語のヒント
チューリングマシンは、プログラムカウンターが指定する各命令に従って、コンピューターのアルゴリズムを実行する。アルゴリズムは、これらの基本操作で1と1の和を計算できる。
1. Store the value 1 to address A in the memory bank.
1. メモリバンクのアドレスAに値1を保存する。
2. Store the value 1 to address B in the memory bank.
2. メモリバンクのアドレスBに値1を保存する。
3. Add the values at addresses A and B and then store the result at address A.
3. アドレスAとBの値を足し、結果をアドレスAに保存する。
What makes computers useful is not just the fact that they can calculate numbers, but that they can encode logic in the instructions. Instead of just computing the sum of 1 and 1, this program continues adding 1 to a growing sum stored at address A.
英語のヒント
コンピューターを有用にしているのは、数を計算できるという事実だけではなく、命令の中に論理を組み込めることである。次のプログラムは、1と1の和を計算するだけでなく、アドレスAに保存した増え続ける合計に、1を足し続ける。
1. Store the value 1 to address A in the memory bank.
1. メモリバンクのアドレスAに値1を保存する。
2. Store the value 1 to address B in the memory bank.
2. メモリバンクのアドレスBに値1を保存する。
3. Add the values at addresses A and B and then store the result at address A.
3. アドレスAとBの値を足し、結果をアドレスAに保存する。
4. Set the program counter to execute step 3 next.
4. 次に手順3を実行するよう、プログラムカウンターを設定する。
The Turing machine abstract model of computation assumes a single thread of execution following each instruction in an algorithm. Although today’s computers are much more efficient than the first computers that realized the Turing machine, most computers still rely on the same fundamental assumptions about how to execute algorithms. The O(N)-time sequential search algorithm, though it might execute 1,000 times faster on today’s computers, still grows linearly with respect to the size of the input. An O(2N)-time brute-force algorithm, though it might execute 1,000 times faster on today’s computers, still grows exponentially with respect to the size of the input. Even as computers become faster over time, inefficient algorithms still cannot be used to solve any problems larger than a few thousand elements.
英語のヒント
チューリングマシンという抽象計算モデルは、アルゴリズムの各命令に従う、1本の実行スレッドを仮定する。今日のコンピューターは、チューリングマシンを実現した最初のコンピューターよりはるかに効率的だが、その大半は、アルゴリズムの実行方法について、今も同じ基本的な仮定に依存している。O(N)時間の逐次探索は、今日のコンピューターで1,000倍速く実行できても、入力サイズに対して線形に増える点は変わらない。O(2N)時間の総当たりアルゴリズムは、1,000倍速く実行できても、入力サイズに対して指数関数的に増える点は変わらない。時間とともにコンピューターが速くなっても、非効率なアルゴリズムでは、数千個の要素を超える規模の問題は解けないままである。