Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Chapter ComputableScarcity

Definition
ChapterComputableScarcity

by leonardopedro · Oct 1, 2026 · Mathlib 0df444a (Lean v4.33.1)

definitionsformalizationtimepiece

Formal definitions for the timepiece Lean 4 formalization (source chapter BookProof/ChapterComputableScarcity.lean): generated def bundle for ChapterComputableScarcity. See BookProof/ChapterComputableScarcity.lean for full context.

Definition code
import Mathlib


/-!
# Chapter "Aligned deep learning as a random sampling method", §4 — almost all
functions are not computable, not even approximately

Source: `book.tex`, chapter *"Aligned deep learning as a random sampling
method"*, §*"4. Why deep neural networks do not overfit"* (line ~9999):

> *"Under reasonable assumptions, almost all functions are not computable not
> even approximately.  Thus, Machine Learning works because the functions we are
> approximating are in fact probability distributions …"*

The self-contained mathematical content of that sentence is a counting /
diagonalization statement about the functions `ℕ → ℕ`:

* there are only **countably many** computable functions, because every
  computable function is described by one of the countably many programs;
* there are **uncountably many** functions, so "almost all" of them (all but a
  countable set) are not computable;
* and this is not repaired by allowing approximations: there is a single
  function that differs from **every** computable function at infinitely many
  arguments, hence no computable function eventually agrees with it.

## Deliverables

* `evalTotal` — the total function computed by a program (a `Nat.Partrec.Code`),
  undefined values being read as `0`;
* `exists_code_of_computable` — every computable `f : ℕ → ℕ` is `evalTotal c` for
  some program `c`;
* `countable_computable` — **countably many computable functions**;
* `exists_infinitely_often_ne` — **diagonalization**: for every sequence `e` of
  functions there is a function differing from each `e k` at infinitely many
  arguments;
* `uncountable_natFun` — there are uncountably many functions `ℕ → ℕ`;
* `exists_differs_infinitely_often_from_all_computable` — **the book's claim**:
  some function differs from *every* computable function at infinitely many
  arguments;
* `exists_not_eventually_eq_computable` — the "not even approximately" form: no
  computable function eventually agrees with that function;
* `exists_not_computable` — in particular non-computable functions exist.
-/

namespace BookProof.ComputableScarcity

open Nat.Partrec

open Classical in
/-- The total function computed by the program `c`: the value of `c` on `n` when
`c` halts on `n`, and `0` otherwise.  Reading the partial function this way loses
no generality here, because a program computing a *total* function halts
everywhere. -/
noncomputable def evalTotal (c : Code) (n : ℕ) : ℕ :=
  if h : (c.eval n).Dom then (c.eval n).get h else 0















end BookProof.ComputableScarcity
Source
https://github.com/leonardopedro/timepiece/blob/61595bc/BookProof/ChapterComputableScarcity.lean

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me