HackerTube 中文?
The limits of programming languages →

What can a language express, and what can it guarantee?

Factorial can be written without naming the function. That trick raises a harder question: if every program must terminate, can unrestricted recursion be allowed? Take that distinction into slides, libraries and language extensions.

Questions in this reading · 10
  1. Can anonymous functions recurse and still guarantee termination?
  2. Can presentation slides perform general computation?
  3. Can libraries grow a language?
  4. Does concise array notation make a language easy to extend?
  5. What does a recursive call leave behind?
  6. When does an argument about rules become a physical conjecture?
  7. Does knowing the rule give you the millionth step?
  8. Why did the branch we skipped start recursing?
  9. What changes when “this program” becomes “every program”?
  10. Two cut branches, one successor to evaluate

Can anonymous functions recurse and still guarantee termination?

Weirich derives a fixed-point combinator so a function can recur without a name. Wadler approaches the same operator from the other direction. Adding unrestricted recursion gives up the termination guarantee of the simply typed calculus.

Compare original passages and timestamps · 2
the function y calculates the fixpoint of an improver function.
Ruby Conf 12 - Y Not- Adventures in Functional Programming by Jim Weirich · ▶ 46:27–47:02
not using What's called the fixo operator that is unlimited General recursion
"Propositions as Types" by Philip Wadler · ▶ 21:59–22:07

Can presentation slides perform general computation?

Compare a deliberately minimal interpreter with a surprising construction inside slides. The decisive question is which operations the system can express.

Compare original passages and timestamps · 2
you only need these three lines that's turn complete actually
William Byrd on "The Most Beautiful Program Ever Written" [PWL NYC] · ▶ 44:35–44:43
essentially imitate any transition function of any other touring machine
On The Turing Completeness of PowerPoint (SIGBOVIK) · ▶ 4:07–4:17

Can libraries grow a language?

If libraries can express new abstractions in ordinary code, the core language can grow through its users. Compare the facilities needed to make those extensions feel native.

Compare original passages and timestamps · 2
the new words defined by a library should look just like the primitives
Growing a Language, by Guy Steele · ▶ 23:25–23:32
the idea is that distributed programming should just be a library
"Unison: a new distributed programming language" by Paul Chiusano · ▶ 36:04–36:12

Does concise array notation make a language easy to extend?

Array operations can express a great deal in a few symbols. Integrating a new operation into the language raises a separate question about its rules and conventions.

Compare original passages and timestamps · 2
you'll notice that it contains no explicit loops and no temporary variables
Conway's Game Of Life in APL · ▶ 3:11–3:29
new words defined by the user do not look like language primitives at all.
Growing a Language, by Guy Steele · ▶ 20:13–20:18

What does a recursive call leave behind?

Work through 3+2 on paper. One definition leaves an instruction to add one after a call returns; another moves one unit between two running arguments. Both can call themselves, but only the first builds up pending increments. Fibonacci adds a different cost: separate branches can ask for the same F(k). Memoization turns later requests into lookups while preserving the dependencies of the first computation. Try drawing two diagrams, one for pending work and another for distinct subproblems.

Passages and timestamps · 2
There's nothing special about the fact that the definition is recursive that leads to a recursive process.
Lecture 1B | MIT 6.001 Structure and Interpretation, 1986 · ▶ 30:37–30:46
So I count how many different subproblems do I need to do?
Lecture 19: Dynamic Programming I: Fibonacci, Shortest Paths · ▶ 22:42–22:45

When does an argument about rules become a physical conjecture?

Penrose distinguishes following rules from understanding why they yield truths. Later he suggests gravity might alter the description of quantum mechanics. Even if the first passage motivates a mathematical question, the second still needs independent physical tests. The two timestamps mark a change in the subject of the argument; taken together they do not prove that a program cannot be conscious.

Passages and timestamps · 2
understanding why the rules give you truths enables you to transcend the rules.
Roger Penrose: Physics of Consciousness and the Infinite Universe | Lex Fridman Podcast #85 · ▶ 23:38–23:45
gravity affects the structure of quantum mechanics too.
Roger Penrose: Physics of Consciousness and the Infinite Universe | Lex Fridman Podcast #85 · ▶ 53:21–53:24

Does knowing the rule give you the millionth step?

Rule 30 has a short update rule. Wolfram recalls running it to discover the unexpected pattern that grows from a simple start. In another interview he sharpens the question: specify an output at step one million. Can most intermediate work be skipped? Running the rule supplies an answer. The intricate picture neither constructs a shortcut nor proves that none exists. If you spot a pattern, name the columns and initial states it predicts, then try positions that did not help you guess it.

Passages and timestamps · 4
from very simple initial conditions, it makes really complicated behavior
Stephen Wolfram: Cellular Automata, Computation, and Physics | Lex Fridman Podcast #89 · ▶ 94:00–94:06
no intuition, just experimental science
Stephen Wolfram: Cellular Automata, Computation, and Physics | Lex Fridman Podcast #89 · ▶ 95:23–95:26
you can run it for a million steps
Stephen Wolfram: Complexity and the Fabric of Reality | Lex Fridman Podcast #234 · ▶ 8:15–8:17
I don't have to go through anything like that computational effort
Stephen Wolfram: Complexity and the Fabric of Reality | Lex Fridman Podcast #234 · ▶ 8:26–8:29

Why did the branch we skipped start recursing?

Turn an if into an ordinary selection function. On the left put the answer for the base case and on the right put one more recursive call. In David Beazley’s Python demo both arguments are evaluated before selection, so recursion has already started. Wrap each computation in a function and invoke only the chosen one. A print at the start of each branch reveals the different work performed by two expressions that seem to make the same decision.

Passages and timestamps · 2
it goes down both paths. And it turns out that the second path just explodes in infinite recursion
David Beazley - Lambda Calculus from the Ground Up - PyCon 2019 · ▶ 158:20–158:30
you're basically delaying the calculation to some later point in time
David Beazley - Lambda Calculus from the Ground Up - PyCon 2019 · ▶ 159:35–159:45

What changes when “this program” becomes “every program”?

Bernstein describes a verification task that succeeds: inspect the actual machine code emitted for a sort and establish the specified property for that implementation. This removes one assumption about the compiler. The halting problem ranges over arbitrary programs and inputs. Assume a decider that always answers, build a program that does the opposite of the prediction and feed it its own description. Either answer defeats itself. Name the program, the property and the range of inputs before comparing these two results.

Passages and timestamps · 3
verification isn't going to rely on some compiler being correct.
35C3 - The year in post-quantum crypto · ▶ 60:38–60:43
I make it loop forever without ever stopping
Turing & The Halting Problem - Computerphile · ▶ 4:16–4:19
Either way we get a contradiction
Turing & The Halting Problem - Computerphile · ▶ 5:17–5:22

Two cut branches, one successor to evaluate

Different cuts in Hackenbush can leave equivalent positions. Evaluating successors recursively then permits reuse. The equivalence must preserve whose turn it is and which options each side has. Merging pictures merely because they look alike could remove the move that decides the game.

Passages and timestamps · 2
these two one positions are essentially identical
HACKENBUSH: a window to a new world of math · ▶ 29:23–29:26
another huge perk of our recursive definitions
HACKENBUSH: a window to a new world of math · ▶ 33:10–33:14

Try it on your own example

Before adding an expressive feature, name one guarantee it might cost you.