1. Home
  2. Explore
  3. Computer Science
  4. Theory of Computation

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Theory of Computation

Theory of Computation and Its Connections to Neuroscience

1. The Role of Theoretical Computer Science

Theoretical computer science (TCS) studies the fundamental limits and possibilities of computation. It is not primarily concerned with building particular machines or software systems; instead, it asks questions such as:

  • What does it mean for something to be computable?

  • Which problems can be solved algorithmically?

  • How efficiently can they be solved?

  • Which problems are impossible or impractical?

  • How can machines learn from data or interaction?

  • How can computational ideas illuminate other sciences, including neuroscience and biology?

A useful way to understand TCS is as a kind of cultural anthropology of computation. Like the study of a human culture, this involves learning:

  • The field’s language and concepts

  • Its historical development

  • Its characteristic methods

  • Its assumptions and worldview

  • The problems that its practitioners consider fundamental

TCS has repeatedly interacted productively with other disciplines, including:

  • Quantum physics

  • Evolutionary biology

  • Economics and game theory

  • Machine learning and artificial intelligence

  • Neuroscience

These interactions can change how researchers in both fields understand their own subjects. Computer science contributes concepts such as algorithms, randomness, complexity, learning, and computational limits; other sciences provide new problems, mechanisms, and models.


2. The Historical Foundations of Computation

Alan Turing and the Definition of Computation

In 1936, Alan Turing introduced the abstract machine now known as the Turing machine. Turing did not initially invent it to build a practical computer. He created it to address a foundational mathematical question:

Can mathematical reasoning be automated?

This question arose in the context of work by Kurt Gödel. Gödel had shown that sufficiently powerful formal mathematical systems are incomplete: there are true mathematical statements that cannot be proved within the system. However, incompleteness did not by itself answer whether the mathematical procedures that people could carry out were mechanically automatable.

Turing’s machine provided a precise, minimal definition of computation. It consists conceptually of:

  • A tape divided into cells

  • A read/write head

  • A finite set of internal states

  • Rules specifying what to do based on the current state and tape symbol

Despite its simplicity, the model captures the essential behavior of general-purpose computation.

Why Computation Had to Be Defined

Before Turing, mathematicians used procedures and calculations without having fully formalized what “computation” meant. This distinction reveals an important principle in the philosophy of science:

Defining a process becomes especially important when one wants to prove that some instances of the process are impossible.

If the goal is merely to show that a task can be performed, one may demonstrate a procedure without defining all possible procedures. To prove that no procedure can solve a problem, however, the boundaries of “procedure” or “computation” must first be made precise.

The Turing machine allowed mathematicians to characterize the entire class of effectively computable procedures and reason about its limits.

Universality: Minimal Mechanisms Can Perform Arbitrarily Many Tasks

One of Turing’s most important insights was universality. A universal machine can simulate any other machine when given an appropriate description or program.

This leads to the broader principle:

Universality: A very simple system can perform an enormous range of tasks if it can be supplied with the right instructions.

A general-purpose computer does not need a separate physical mechanism for every task. Instead, the task is represented as software or a bit stream. The same hardware can therefore perform calculations, control communication, process images, run games, or train models.

Universality has analogues outside computer science:

  • In evolution, a simple set of mechanisms can generate diverse adaptations.

  • In learning, a general system can acquire many specialized behaviors.

  • In biology, simple local rules can produce highly complex global patterns.

Universality therefore connects computation to the ideas of software, programmability, and learning.

Unsolvable Problems

Turing also proved that some precisely stated computational problems are unsolvable. The most famous example is the halting problem:

Given an arbitrary program and its input, determine whether the program eventually stops or runs forever.

No algorithm can correctly answer this question for every possible program and input.

This result is surprising because the problem is easy to state and appears to involve only the behavior of a program. Yet no universal program can solve it. A proof can be constructed using self-reference: if a hypothetical halting detector existed, one could build a program that behaves in a way that contradicts the detector’s prediction.

The unsolvability of the halting problem implies that there is no general algorithm that can always determine:

  • Whether an arbitrary program is correct

  • Whether it will produce any output

  • Whether it contains a virus

  • Whether it will terminate

  • Whether it will enter an infinite loop

These limitations are not merely practical difficulties. They are mathematical impossibilities.

Computer Science’s Awareness of Its Own Limits

Computer science was therefore born with a clear understanding of its limitations. It did not first develop an optimistic theory of unlimited progress and only later encounter boundaries. Its foundational theory immediately established that some tasks cannot be automated.

This has shaped the field’s attitude toward difficult problems. When a problem seems extremely difficult, computer scientists ask two different questions:

  1. Is the problem merely hard with current methods?

  2. Is the problem fundamentally impossible to solve algorithmically?

The distinction between unsolvability and computational intractability is essential:

  • An unsolvable problem has no algorithm that always solves it.

  • An intractable problem may be solvable in principle but requires too much time or computational resources to be practical.


3. Von Neumann and the Beginning of Modern Computers

Approximately a decade after Turing’s work, John von Neumann was deeply influenced by these ideas. He helped define the architecture of the modern stored-program computer and participated in the construction of an actual machine.

The stored-program concept separates:

  • The physical machine

  • The instructions it executes

  • The data on which those instructions operate

This architecture made universality practical. A single machine could perform many tasks by changing its stored program rather than rebuilding the hardware.

The combination of:

  • Turing’s abstract theory of computation

  • Von Neumann’s computer architecture

  • Engineering advances in electronics

created the foundation of modern computer science and information technology.


4. The Development and Impact of Computer Science

For much of its early history, computer science was intensely focused on the computer itself. Researchers addressed major engineering problems, including:

  • Operating systems

  • Compilers

  • Databases

  • Machine learning

  • Computer-chip design and layout

  • Computer graphics

  • Communication networks

  • User interfaces

  • The Internet

Many of these problems were initially extremely difficult. Early operating systems and compilers could require many person-years of development. Over time, they became manageable enough to serve as projects in university courses.

The Internet transformed the role of the computer. People increasingly stopped thinking primarily about the machine as an isolated device and began experiencing it as a gateway to a global network of information and communication.

The resulting information technology has changed:

  • Communication

  • Commerce

  • Education

  • Entertainment

  • Scientific research

  • Social relationships

  • Access to information

Two major forces were especially important in producing this transformation:

  1. Moore’s Law

  2. Fast algorithms


5. Moore’s Law and the Importance of Algorithms

Moore’s Law

Moore’s Law describes the long-running trend that computing capability approximately doubled on a regular schedule, historically around every year and a half to two years.

This trend was not simply a law of nature. It was also a social and economic phenomenon involving the interaction of:

  • Scientific knowledge

  • Engineering competition

  • Business planning

  • Consumer demand

  • Societal adoption

Once the expectation of continual improvement became established, companies and industries organized their development plans around it. Falling behind the expected growth curve created competitive pressure to find new technical solutions.

Even when traditional forms of Moore’s Law began to slow, researchers continued looking for ways to maintain computational progress through:

  • New hardware designs

  • Parallelism

  • Specialized processors

  • Improved architectures

  • More efficient algorithms

Why Hardware Improvements Are Not Enough

Faster hardware does not automatically make every problem practical. The algorithm must also use the additional computational power efficiently.

Suppose a computer becomes dramatically faster. If an algorithm requires exponential time, the improvement may provide little practical benefit. For example, if the input size increases by only a modest amount, an exponential algorithm may become unusable despite substantial hardware advances.

This gives a central principle:

Hardware progress produces practical gains only when paired with efficient algorithms.

Algorithms translate raw computational capability into useful applications. They determine whether faster processors can actually solve larger or more complex problems.


6. Algorithms and Matrix Multiplication

A standard example in algorithmic thinking is multiplying two n×nn \times nn×n matrices.

The Classical Algorithm

The ordinary matrix multiplication algorithm computes each of the n2n^2n2 entries in the product matrix. Each entry requires combining nnn products, so the total number of arithmetic operations grows on the order of:

O(n3)O(n^3)O(n3)

The exact operation count depends on the details of what is counted, but asymptotic notation focuses on the dominant growth rate rather than constant factors.

The notation O(n3)O(n^3)O(n3) means that, for sufficiently large nnn, the running time is bounded above by a constant multiple of n3n^3n3.

The Search for Faster Algorithms

A recurring question in computer science is:

Can a familiar computation be performed faster than the obvious method?

For matrix multiplication, many mathematicians initially believed that the cubic bound was unavoidable. Volker Strassen disproved this belief by developing a faster algorithm.

Strassen’s Algorithm

Strassen’s key insight was to multiply 2×22 \times 22×2 matrices using seven multiplications instead of the eight required by the direct method. Although the alternative method uses more additions, reducing the number of recursive multiplications is advantageous.

The method applies recursively:

  1. Divide a large matrix into four blocks.

  2. Treat the blocks as entries of a 2×22 \times 22×2 matrix.

  3. Use the seven-multiplication method on those blocks.

  4. Continue recursively until the blocks are small enough for direct multiplication.

This produces a running time of approximately:

O(nlog⁡27)O\left(n^{\log_2 7}\right)O(nlog2​7)

Since log⁡27≈2.81\log_2 7 \approx 2.81log2​7≈2.81, this is asymptotically faster than O(n3)O(n^3)O(n3).

Strassen’s result demonstrated that seemingly obvious lower bounds can be wrong. It also showed the power of:

  • Recursion

  • Decomposition into subproblems

  • Reusing intermediate computations

  • Reducing the number of expensive operations

Later work produced further improvements, although matrix multiplication remains an active research area.

Lower Bounds and Randomized Proofs

The study of matrix multiplication also illustrates the difficulty of proving lower bounds—claims that no algorithm can solve a problem faster than a specified rate.

Some lower-bound questions remained unresolved for decades. In certain cases, randomness and the probabilistic method provided simpler proofs. This leads into the important role that randomness plays in theoretical computer science.


7. Randomness in Computer Science

Theoretical computer scientists treat randomness not merely as noise or uncertainty, but as a useful computational resource.

Randomization: The deliberate use of random choices within an algorithm or proof.

Randomness can be useful even when the desired result must be highly reliable. In some situations, flipping a coin is the most systematic and dependable action available.

Randomized Algorithms

A randomized algorithm makes random choices during execution. Its performance may be analyzed in terms of:

  • Expected running time

  • Probability of obtaining the correct answer

  • Probability of encountering a bad outcome

  • Performance against worst-case inputs

Randomization is especially useful in two major ways.

7.1 Protecting Against Bad Inputs

An algorithm can perform poorly on specially arranged inputs. If an adversary knows exactly how the algorithm behaves, the adversary may construct inputs that trigger its worst case.

Randomization makes the algorithm’s behavior less predictable. The input may still be bad, but the random choices prevent the adversary from reliably forcing the worst behavior.

Quicksort is a standard example. Its performance depends heavily on the choice of pivot. Randomly selecting pivots makes it unlikely that an adversarially arranged input will repeatedly produce extremely unbalanced partitions.

Randomization therefore acts as a defense against:

  • Worst-case input structure

  • Adversarial behavior

  • Predictable algorithmic weaknesses

7.2 Testing Competing Hypotheses by Sampling

Random sampling can distinguish between two competing hypotheses. Instead of examining an entire enormous object, an algorithm tests randomly selected pieces of evidence.

This is useful when:

  • One hypothesis has a property that almost all random samples should satisfy.

  • The alternative hypothesis is likely to produce a violation.

  • A small probability of error is acceptable.

Repeated independent tests can reduce the error probability dramatically.


8. Randomized Primality Testing

Consider a very large integer NNN, perhaps one with hundreds of digits. The question is whether NNN is prime.

Directly factoring NNN may be difficult, but testing primality can be much easier.

Fermat’s Theorem

For a prime number NNN and an integer aaa relatively prime to NNN, Fermat’s theorem implies:

aN−1≡1(modN)a^{N-1} \equiv 1 \pmod NaN−1≡1(modN)

Equivalently, in a related form:

aN≡a(modN)a^N \equiv a \pmod NaN≡a(modN)

A primality test chooses random values of aaa and checks whether the congruence holds.

  • If the test fails, NNN is definitely composite.

  • If the test passes, NNN is treated as probably prime, and additional tests can be performed.

For many composite numbers, a large fraction of possible values of aaa reveal the compositeness. Repeating the test makes the probability of mistakenly accepting a composite number extremely small.

Error Probability

If one independent test has a bounded probability of detecting compositeness, then repeating the test kkk times can reduce the probability of error exponentially. A typical bound has the form:

Pr⁡(error)≤2−k\Pr(\text{error}) \leq 2^{-k}Pr(error)≤2−k

Thus, after 100 suitably independent tests, the error probability may be on the order of:

2−1002^{-100}2−100

This is far smaller than many physical risks encountered by a computer during operation. For practical engineering, demanding absolute certainty may be less rational than accepting an astronomically small error probability.

Randomized Versus Deterministic Testing

Primality testing can also be performed deterministically. However, the deterministic algorithm may require significantly more computation than a randomized test.

This illustrates a common trade-off:

  • Randomized methods may be much faster while offering extremely high confidence.

  • Deterministic methods may guarantee correctness but require greater computational resources.

Randomness is therefore not necessarily a relaxation of rigorous reasoning. It can be a carefully quantified method of obtaining reliable results.


9. Random Graphs

A classical model of a random graph was developed by Paul Erdős and Alfréd Rényi.

Erdős–Rényi Model

To construct a simple undirected random graph:

  1. Begin with nnn nodes.

  2. Consider every possible pair of nodes.

  3. Add an edge between each pair independently with probability ppp.

For example, if n=2,000n = 2{,}000n=2,000 and p=0.01p = 0.01p=0.01, each possible pair receives an independent 1% chance of being connected.

The resulting graph is random, but its large-scale properties can often be predicted with high confidence.

Typical Properties

For appropriate values of nnn and ppp, one can predict properties such as:

  • Whether the graph is connected

  • Whether it has multiple disjoint paths between pairs of nodes

  • Its approximate number of triangles

  • Its diameter, meaning the maximum shortest-path distance

  • Whether it contains certain cliques

  • Whether it has strong expansion properties

A graph’s diameter is the greatest distance between any two nodes, where distance is measured by the length of the shortest connecting path. A small diameter corresponds to a “small-world” structure.

An expander graph is highly connected in the sense that separating a substantial part of the graph requires cutting many edges or removing many nodes. It is difficult to isolate a large region cheaply.

The important lesson is that a random graph can be understood statistically even without observing its exact individual edges. The model provides detailed predictions about the graph’s structure.

Relevance to Neuroscience

The brain is not simply an Erdős–Rényi random graph. Neural networks have structure, including:

  • Spatial organization

  • Specialized regions

  • Nonuniform connection probabilities

  • Hierarchical organization

  • Motifs and modularity

Nevertheless, random graph models can serve as useful baselines. They allow researchers to ask which properties of a biological network are more organized than would be expected by chance.


10. Primality Versus Factoring

A striking computational contrast is the difference between:

  • Testing whether a number is prime

  • Finding the number’s prime factors

Primality Testing

Primality testing is computationally manageable. Efficient algorithms can determine whether a large number is prime.

Factoring

Factoring asks for the decomposition:

N=p1e1p2e2⋯pkekN = p_1^{e_1}p_2^{e_2}\cdots p_k^{e_k}N=p1e1​​p2e2​​⋯pkek​​

where the pip_ipi​ are prime numbers.

The best classical factoring algorithms are much slower than the best primality tests. No efficient general-purpose classical factoring algorithm is currently known.

Cryptographic Importance

Modern cryptography has historically relied on this asymmetry:

It is easy to multiply large prime numbers, and relatively easy to test whether a number is prime, but difficult to recover the factors of their product.

A public key can therefore contain a large composite number, while the private key depends on its hidden factorization.

This is an example of complexity as a resource. Computational difficulty can be useful rather than merely inconvenient. Cryptographic systems use hard problems to protect information.

Factoring is not generally treated as an NP-complete problem. Its difficulty is important, but it belongs to a different part of complexity theory from the canonical NP-complete problems.


11. Computational Complexity

Computational complexity studies the resources required to solve problems, especially:

  • Time

  • Memory

  • Communication

  • Randomness

  • Approximation quality

The central distinction discussed is between polynomial-time and exponential-time computation.

Polynomial-Time Problems

A problem is informally considered efficiently solvable if its running time is bounded by a polynomial in the input size, such as:

O(n),O(n2),O(n3),O(n2.55)O(n), \quad O(n^2), \quad O(n^3), \quad O(n^{2.55})O(n),O(n2),O(n3),O(n2.55)

Polynomial growth can still be substantial, but it is generally much more manageable than exponential growth.

Examples include:

  • Addition

  • Multiplication

  • Finding shortest paths

  • Testing graph connectivity

  • Ordinary two-sided matching

  • Certain forms of pattern matching

Exponential-Time Problems

An exhaustive algorithm may require examining a number of possibilities such as:

2n2^n2n

or another exponential function. This becomes impractical rapidly as nnn increases.

Examples discussed include:

  • Number partitioning

  • Three-way matching

  • Large clique detection

  • Set cover

The distinction is not always obvious from the problem statement. A small change in the structure of a problem can move it from polynomial-time solvable to apparently exponential-time difficult.


12. Examples of Easy and Hard Problems

Number Partitioning

Given a collection of numbers, the task is to divide them into two groups with equal or nearly equal sums.

For example, one might want to divide financial balances equally between two people.

The problem can be solved by exhaustive search, but the number of possible partitions grows exponentially. Approximation algorithms may work well for many practical instances, even though the exact worst-case problem is difficult.

Two-Way Matching

Matching members of one group with members of another group can be solved efficiently. Examples include:

  • Matching students with projects

  • Matching workers with jobs

  • Matching boys and girls in a simplified abstract model

Efficient matching algorithms run in polynomial time. The lecture cited an algorithm with a running time around:

O(n2.55)O(n^{2.55})O(n2.55)

The exact exponent is less important than the fact that the problem is polynomial-time solvable.

Three-Way Matching

Suppose the task is to form compatible triples consisting of:

  • One person from the first group

  • One person from the second group

  • One person or object from a third group

Compatibility constraints may specify which triples are allowed.

Unlike ordinary two-way matching, three-way matching is generally computationally hard. Adding a third dimension creates a combinatorial explosion.

This distinction has practical analogues. Pairing two kinds of entities may be manageable, while simultaneously matching three kinds of entities can become extremely difficult.

Graph Distance

Given a social network, determining whether one person is within a certain number of connections from another can be done efficiently. Computing distances in a graph can often be performed in linear or near-linear time.

Clique Detection

A clique is a set of nodes in which every pair is connected. Asking whether a graph contains a clique of a specified size is computationally difficult.

For example:

Are there 60 people in a social network who are all mutual friends?

This problem is difficult even though checking a proposed clique is easy.

Set Cover

In the set cover problem, one is given a collection of sets and must choose as few sets as possible so that their union covers every required element.

A verbal example is:

Given a collection of words, choose as few words as possible so that every letter of the alphabet appears in at least one chosen word.

Set cover is a fundamental hard problem with applications in:

  • Sensor placement

  • Resource allocation

  • Scheduling

  • Document summarization

  • Network design

  • Experimental design


13. Reductions and NP-Completeness

Reductions

A reduction transforms one problem into another. If problem AAA can be efficiently transformed into problem BBB, then an efficient algorithm for BBB would provide an efficient algorithm for AAA.

This allows researchers to compare the difficulty of apparently unrelated problems.

For example, a reduction might show that:

  • A solver for number partitioning could also solve three-way matching.

  • A solver for one difficult combinatorial problem could be adapted to solve many others.

The transformation itself must be efficient. Otherwise, it would not establish a meaningful relationship between the problems.

Arithmetization Example

A three-way matching instance can be represented using sparse zero-one vectors. Each possible triple is encoded as a vector containing three ones:

  • One coordinate for the first participant

  • One coordinate for the second participant

  • One coordinate for the third participant

The remaining coordinates are zero.

This encoding converts a combinatorial selection problem into an algebraic or numerical problem. A suitable algorithm for the numerical problem could then be used to solve the matching problem.

This is an example of arithmetization: representing logical or combinatorial structure through arithmetic objects.

The Complexity Class P

The class P consists of decision problems solvable in polynomial time by a deterministic algorithm.

A decision problem has a yes/no answer, such as:

  • Is this graph connected?

  • Does this number satisfy a property?

  • Does this network contain a clique of size kkk?

The Complexity Class NP

The class NP consists of decision problems for which a proposed solution can be verified in polynomial time.

For example, if someone claims that a graph contains a clique of size kkk, a verifier can check all pairs in the proposed set efficiently. Finding the clique may be difficult, but checking a candidate is easy.

The lecture also described NP informally as problems solvable by exhaustive search over exponentially many candidate solutions. More precisely, NP is defined by efficient verification, although exhaustive search provides a general method for solving such problems in exponential time.

NP-Complete Problems

An NP-complete problem has two properties:

  1. It belongs to NP.

  2. Every problem in NP can be reduced to it in polynomial time.

Thus, NP-complete problems are the hardest problems within NP under polynomial-time reductions.

If any NP-complete problem had a polynomial-time algorithm, then every problem in NP would have one.

The P Versus NP Question

The central question is:

P=?NP\mathrm{P} \stackrel{?}{=} \mathrm{NP}P=?NP

Most researchers believe that:

P≠NP\mathrm{P} \neq \mathrm{NP}P=NP

If P=NP\mathrm{P} = \mathrm{NP}P=NP, many problems currently regarded as computationally difficult would become efficiently solvable. This would have profound consequences for:

  • Optimization

  • Cryptography

  • Scheduling

  • Scientific modeling

  • Automated reasoning

  • Logistics

  • Artificial intelligence

If P≠NP\mathrm{P} \neq \mathrm{NP}P=NP, it would establish that some efficiently verifiable problems cannot be efficiently solved in general.

SAT and the First NP-Complete Problem

The Boolean satisfiability problem, or SAT, asks whether there exists an assignment of truth values that makes a Boolean formula true.

For example, a formula involving variables x1,x2,…,xnx_1,x_2,\ldots,x_nx1​,x2​,…,xn​ may contain logical operations such as AND, OR, and NOT. SAT asks whether some assignment satisfies the entire formula.

In 1971, Stephen Cook proved that SAT is NP-complete. This result provided the starting point for proving many other problems NP-complete:

  1. Begin with SAT.

  2. Reduce SAT to a new problem.

  3. Conclude that the new problem is at least as hard as SAT.

  4. If the new problem also belongs to NP, it is NP-complete.

Thousands of problems have since been shown to be NP-complete.


14. What NP-Completeness Means in Practice

NP-completeness does not mean that a problem should never be studied or that every real-world instance is impossible to solve.

It means that no efficient algorithm is known for solving all instances, and that a general efficient solution would resolve the P versus NP question.

Practical responses to an NP-complete problem include:

  • Approximation algorithms

  • Heuristics

  • Special-case algorithms

  • Randomized methods

  • Parameterized algorithms

  • Average-case analysis

  • Algorithms that work well on typical data

  • Exact algorithms for small instances

Worst-case hardness and practical difficulty are not identical. Some NP-complete problems are easy on most naturally occurring instances, while hard instances may be rare or difficult to construct.

Thus, complexity theory is best viewed as a diagnostic and organizational tool. It helps researchers determine:

  • Which formulations are likely to be solvable efficiently

  • Which instances are genuinely difficult

  • Which approximations are possible

  • Which aspects of a problem create the difficulty

  • Whether a proposed breakthrough would have extraordinary consequences

NP-completeness prevents researchers from expecting a simple, universally effective algorithm without strong evidence.


15. Approximation and the PCP Theorem

Many applications do not require a perfectly optimal answer. They may accept a solution within a specified tolerance.

This changes the computational question from:

Can the exact optimum be found efficiently?

to:

Can a sufficiently good approximation be found efficiently?

The PCP theorem, developed in the early 1990s, provides a deep connection between efficient verification and approximation hardness. Together with later results, it shows that some problems cannot even be approximated beyond certain guarantees unless major complexity-theoretic assumptions fail.

For example:

  • Some forms of number partitioning can be approximated effectively.

  • Certain clique problems remain hard even to approximate closely.

This creates a more refined classification of problems. Instead of merely labeling a problem “easy” or “NP-complete,” one can ask:

  • How accurately can it be approximated?

  • What approximation ratio is achievable?

  • Is there a threshold beyond which approximation becomes impossible?

  • Does the problem have a fully polynomial approximation scheme?

Approximation complexity is particularly relevant to biological and neural problems, where exact optimization may be unrealistic and near-optimal solutions may be sufficient.


16. Worst-Case, Average-Case, and Real-World Complexity

Worst-case complexity examines the most difficult possible input of a given size. This provides mathematically robust guarantees but may not describe typical data.

Other approaches include:

  • Average-case complexity: performance under a specified input distribution

  • Smoothed analysis: performance after small random perturbations of inputs

  • Instance-based analysis: identifying which structural properties make an instance easy or hard

  • Parameterized complexity: measuring difficulty with respect to a special parameter

  • Distributional learning theory: analyzing performance over data distributions

This distinction matters in neuroscience and machine learning because naturally occurring data may occupy only a small and structured part of the full mathematical input space.

Theoretical computer science can therefore help identify why particular real-world problems are easy, even when their unrestricted worst-case versions are hard.


17. Learning in Computer Science

Learning is a central concept across neuroscience, biology, artificial intelligence, and computer science. Computer scientists study learning by asking:

  • What information is available to the learner?

  • What assumptions are made about the environment?

  • What counts as success?

  • How much data is needed?

  • How much computation is needed?

  • Can performance be guaranteed without knowing the data distribution?

The lecture distinguishes several forms of learning, including:

  • Supervised learning

  • Unsupervised learning

  • Online learning

  • Learning in adversarial environments

The focus here is on supervised and online learning.


18. Online Learning and the Expert Problem

The Basic Setup

Suppose a decision-maker consults six experts each day. Each expert gives advice about an investment or prediction.

Every morning:

  1. The decision-maker observes the available experts.

  2. One expert is selected.

  3. The selected expert’s outcome is realized.

  4. The decision-maker observes the results.

  5. The process repeats the next day.

Each outcome may yield a reward or loss. The decision-maker’s goal is not necessarily to predict the future perfectly. Instead, the goal is to perform nearly as well as the best expert in hindsight.

Adversarial Outcomes

The outcomes need not come from a known probability distribution. They may be adversarial.

An adversarial environment is one in which:

  • There is no assumed prior distribution.

  • The sequence of outcomes may be highly irregular.

  • An opponent may choose outcomes to reduce the learner’s performance.

  • The opponent can react to the learner’s past behavior.

The learner is therefore judged by comparison with the best expert after the entire sequence has been observed.

This framework appears in:

  • Finance

  • Game theory

  • Artificial intelligence

  • Online recommendation

  • Adaptive control

  • Portfolio selection

  • Network routing

Regret

The learner’s regret is the difference between the reward achieved by the best fixed expert and the reward achieved by the learner.

If the learner’s average regret approaches zero as the number of rounds grows, the learner is performing nearly as well as the best expert even without knowing in advance which expert that will be.


19. The Multiplicative Weights Algorithm

The multiplicative weights algorithm maintains a probability distribution over experts.

Basic Procedure

Suppose there are nnn experts.

  1. Start with equal weight for every expert: $$ w_i = 1 $$ or equivalently assign probability: $$ p_i = \frac{1}{n} $$

  2. On each round, select experts according to the current probability distribution.

  3. Observe the rewards or losses.

  4. Increase the weights of experts that performed well.

  5. Decrease the weights of experts that performed poorly.

  6. Normalize the weights so that they form a probability distribution.

For a loss-based formulation, an update can be written as:

wi(t+1)=wi(t)e−ηℓi(t)w_i^{(t+1)} = w_i^{(t)}e^{-\eta \ell_i^{(t)}}wi(t+1)​=wi(t)​e−ηℓi(t)​

where:

  • wi(t)w_i^{(t)}wi(t)​ is expert iii’s weight at time ttt

  • ℓi(t)\ell_i^{(t)}ℓi(t)​ is the loss of expert iii

  • η\etaη is a small learning rate

The probability of selecting expert iii is then:

pi(t)=wi(t)∑jwj(t)p_i^{(t)} = \frac{w_i^{(t)}}{\sum_j w_j^{(t)}}pi(t)​=∑j​wj(t)​wi(t)​​

In a reward-based version, better rewards receive multiplicative increases instead.

Performance Guarantee

With an appropriate learning rate, the algorithm’s average regret is bounded on the order of:

O(log⁡nT)O\left(\sqrt{\frac{\log n}{T}}\right)O(Tlogn​​)

where:

  • nnn is the number of experts

  • TTT is the number of rounds

As TTT grows, the average difference between the learner and the best expert decreases. In a long sequence of several thousand days, the learner can remain only a small amount behind the best expert per day.

The guarantee is remarkable because it holds without:

  • Knowing which expert is best

  • Knowing the distribution of outcomes

  • Assuming the experts behave consistently

  • Assuming the environment is cooperative

Broad Applications

The same basic strategy has appeared independently in several fields:

  • Economics

  • Financial mathematics

  • Game theory

  • Artificial intelligence

  • Online prediction

  • Machine learning

In machine learning, related multiplicative-weight ideas support algorithms such as AdaBoost, which combines weak predictors into a stronger predictor.

The method also applies to:

  • Convex optimization

  • Network congestion control

  • Resource allocation

  • Portfolio selection

  • Learning in games

  • Adaptive decision-making

Its influence comes from the combination of:

  • Simplicity

  • Robustness

  • Minimal assumptions

  • Strong theoretical guarantees

  • Broad applicability

The method demonstrates that a very simple update rule can solve problems across many domains.


20. Evolution, Biology, and Computation

Computer science has engaged productively with biology through areas such as:

  • Computational biology

  • Evolutionary computation

  • Genome analysis

  • Protein folding

  • Population dynamics

  • Biological information processing

A key question is whether biological adaptation is merely a form of local gradient search. In gradient descent, a system repeatedly makes small changes that improve an objective function.

Evolution can sometimes resemble this process, but it also includes mechanisms that do not fit a simple gradient picture:

  • Recombination

  • Competition among populations

  • Neutral variation

  • Population-level exploration

  • Historical constraints

  • Interactions among multiple evolving entities

Algorithms resembling multiplicative weights can model populations in which successful types increase their representation while unsuccessful types decline. Such models connect:

  • Evolutionary dynamics

  • Game theory

  • Learning algorithms

  • Competition among strategies

  • Adaptation under changing environments

The broader lesson is that computational ideas can describe biological processes without reducing biology to a simple engineering optimization problem.


21. Theoretical Computer Science and Neuroscience

The lecture’s broader aim is to expose neuroscientists to the conceptual framework of TCS and to encourage computer scientists to learn from neuroscience.

Potential points of connection include:

  • Neural computation

  • Learning algorithms

  • Randomness in biological systems

  • Network structure

  • Complexity of neural problems

  • Evolution of cognitive mechanisms

  • Distributed computation

  • Approximate inference

  • Algorithmic descriptions of brain function

However, theoretical tools must be chosen carefully. A worst-case complexity result may not directly predict the behavior of a biological system. Conversely, biological systems may motivate new models of computation that differ from conventional digital algorithms.

The most productive interaction requires identifying the right computational questions:

  • What is the relevant input?

  • What is the output?

  • What resources are available?

  • What counts as an acceptable approximation?

  • What information is local or global?

  • Is the environment stochastic, adversarial, or structured?

  • What is the appropriate notion of efficiency?

The purpose of theory is not always to solve the original problem directly. Often its most important contribution is to determine which formulation captures the real scientific question.

A central role of theory is to identify the right problem, the right assumptions, and the right notion of success.


22. Major Lessons

  • Computation must be defined precisely when its limits are being studied.

  • Turing machines provided a minimal formal model of computation.

  • Universality shows that a simple machine can perform many tasks when supplied with suitable software.

  • Some problems, such as the halting problem, are mathematically unsolvable.

  • Efficient algorithms are necessary for hardware improvements such as Moore’s Law to produce practical benefits.

  • Randomness can protect algorithms from adversarial inputs and help test competing hypotheses.

  • Randomized primality testing illustrates how extremely small error probabilities can be acceptable in rigorous engineering.

  • Random graph models predict global structure from simple local probability rules.

  • Primality testing is easy while factoring remains difficult, a distinction central to classical cryptography.

  • P contains problems solvable in polynomial time; NP contains problems whose solutions can be verified in polynomial time.

  • NP-complete problems are the hardest problems in NP under polynomial-time reductions.

  • NP-completeness is a theoretical guide, not a claim that every practical instance is hopeless.

  • Approximation theory and the PCP theorem refine the study of hard problems by asking how accurately they can be solved.

  • Multiplicative weights allows online learners to approach the performance of the best expert without knowing which expert is best in advance.

  • Computational theory can contribute to neuroscience and biology by clarifying algorithms, limits, learning mechanisms, randomness, and network structure.

  • The deepest scientific contribution of TCS may be learning how to ask the right computational question.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent