# Richardson's theorem: why a computer cannot recognize every zero

> *“No method is known for deciding whether a subelementary expression with no variables in it
> represents a number less than zero.”* — Daniel Richardson (1968)

In Lecture 1 (§{doc}`1.3 <../wyklady/w01_3_jak_dziala_cas>`) we stated that *for expressions
built from $x$, rational numbers, $\pi$, $\ln 2$, $\sin$, $\exp$ and the absolute value, there is no
algorithm that decides whether an expression is identically zero*. This chapter is a
**deep dive**: it contains a complete proof of this theorem (Daniel Richardson, *Journal of Symbolic
Logic*, 1968), all the necessary concepts from outside the course, context, and exercises.

```{admonition} Materials
:class: tip
* [Applet: one variable suffices](https://bnaskrecki.faculty.wmi.amu.edu.pl/math-comp/en/applets/richardson.html) —
  the dense curve, the lifting lemma, the role of the weights, the absolute-value trick.
* {doc}`r1_pojecia` — computability, Hilbert's tenth problem, expression languages, tools from analysis, differential algebra.
* {doc}`r2_dowod` — the complete proof with illustrations in Python.
* {doc}`r2_przyklad` — numerics says “positive everywhere” for $x^3+y^3+z^3=a$ with $a=3,4,42,114$, but the truth varies (for $a=114$ nobody knows it).
* {doc}`r3_dodatki` — powers of two; why $e^{x^2}$ has no elementary antiderivative.
* {doc}`r4_kontekst` — consequences for CAS, the boundary of decidability, the constant problem, literature.
* {doc}`r5_zadania` — 20 review questions and 17 problems.
* [Printable PDF version](https://bnaskrecki.faculty.wmi.amu.edu.pl/math-comp/en/pdf/richardson_pelny_dowod.pdf) — the whole chapter in one file: the same numbering, definitions, proof, appendices, exercises and answers.
```

## The theorem

Let $\mathcal A_1$ denote the expressions in one variable $x$ built from rational numbers, $\pi$,
$\log 2$, the operations $+,-,\cdot$ and the functions $\exp$ and $\sin$ (with arbitrary nesting), and
let $\mathcal B_1$ denote the same with the absolute value $|\cdot|$.

```{admonition} Richardson's theorem (1968)
:class: important
1. There is no algorithm that, given $A\in\mathcal A_1$, decides whether $A(x)<0$ for some $x$.
2. There is no algorithm that, given $B\in\mathcal B_1$, decides whether $B(x)=0$ for all $x$.
3. There is no algorithm that decides whether a given expression in $\mathcal B_1$ has an
   antiderivative expressible in $\mathcal B_1$.
```

The practical consequence: **there is no perfect `simplify`**. Every computer algebra
system must sometimes answer “I don't know”, get it wrong, or compute forever.

## Proof sketch in six steps

The idea: we show that if such an algorithm existed, it would solve **Hilbert's tenth problem**
— which is unsolvable. Each step transforms one question into another, equivalent one.

**Step 1. The starting point: an undecidable equation in integers.** There is a fixed polynomial
$P(y,x_1,\dots,x_n)$ (in Richardson's version, with powers $2^{x_i}$) such that no algorithm
decides whether a given number $a\in\mathbb N$ belongs to the set $U$ of those $a$ for which
the equation $P(a,\mathbf x)=0$ has a solution in natural numbers
(Davis–Putnam–Robinson 1961, Matiyasevich 1970).

**Step 2. From integers to reals: the sine detects integrality.** Since
$\sin(\pi x)=0\iff x\in\mathbb Z$, the integer solutions are the zeros of the function

$$
P^2+\sum_i\sin^2(\pi x_i).
$$

But later we will only be able to *approach* zeros, so we need more.

**Step 3. The gap: small values force an exact zero.** Richardson multiplies the sine terms
by rapidly growing **weights** $k_i$ — expressions that bound the derivatives of $P^2$ on a
neighborhood of the point:

$$
f=(n+1)^4\Bigl[P^2+\sum_i\sin^2(\pi x_i)\,k_i^4\Bigr].
$$

If $f(a,\mathbf x)\le1$ for some $\mathbf x\in[0,\infty)^n$, then $\mathbf x$ lies so close to a point $\mathbf m\in\mathbb N^n$ that
$P(a,\mathbf m)^2<1$, and since this is an integer, $P(a,\mathbf m)=0$. Hence: **either $f$ has
a zero, or $f>1$ everywhere**. (Without the weights this fails — see the example $P(x)=Nx-1$.)

**Step 4. One variable suffices.** The functions $h(t)=t\sin t$ and $g(t)=t\sin(t^3)$ run at
different “speeds”: on a short interval near a large $t$, the function $h$ barely moves, while $g$ performs full
oscillations with amplitude $\approx t$. Thanks to this, the curve

$$
\Gamma_n(t)=\bigl(h(t),\,h(g(t)),\,\dots,\,h(g^{[n-2]}(t)),\,g^{[n-1]}(t)\bigr)
$$

has a **dense** image in $\mathbb R^n$. Let $F(a,\mathbf u)=f(a,u_1^2,\dots,u_n^2)$ (the squares
remove the constraint $x_i\ge0$). Since the inequality $F<1$ is strict and holds on a whole
neighborhood, and the curve enters every neighborhood, the function of **one** variable
$G_a(t)=F\bigl(a,\Gamma_n(t)\bigr)$ satisfies: $a\in U\iff G_a(t)<1$ for some $t$.

**Step 5. The sign problem.** The expression $A_a=G_a-1$ is negative somewhere exactly when the
Diophantine equation has a solution. An algorithm for the sign would therefore solve Hilbert's problem.

**Step 6. The zero problem and the integration problem.** The absolute value turns a sign question
into an identity question: $B_a=|A_a|-A_a$ is identically zero exactly when $A_a\ge0$ everywhere. For
integration, we multiply $e^{x^2}$ (which has no elementary antiderivative) by a switch
$S_a$ that is identically zero for $a\notin U$ and, for $a\in U$, equals $1$ on some interval.

$$
\begin{aligned}
\underbrace{\exists\,\mathbf m\in\mathbb N^n\ P(a,\mathbf m)=0}_{\text{Hilbert}}
&\iff \exists\,\mathbf x\in[0,\infty)^n\ f(a,\mathbf x)\le1
\iff \exists\,t\ G_a(t)<1\\
&\iff A_a \text{ somewhere}<0
\iff B_a\not\equiv0 .
\end{aligned}
$$

```{admonition} What is an algorithm, and what merely exists?
:class: warning
The transformation $a\mapsto G_a\mapsto A_a\mapsto B_a$ consists of **operations on expression
trees** — it is an algorithm. The points where $G_a<1$ exist only in the proof; nobody has to
find them (and in practice they lie astronomically far away — in the example in §5 of the proof,
at $t\approx10^{11}$).
```

## How to read this chapter

* To understand the sketch, Lecture 1 and basic analysis suffice.
* The complete proof ({doc}`r2_dowod`) requires the concepts from {doc}`r1_pojecia`: decidability,
  reductions, Diophantine sets, the mean value theorem, density.
* Facts taken without proof: the theorems of Davis–Putnam–Robinson and of Matiyasevich (arithmetic),
  and Liouville's theorem (only in the integration part). Apart from the standard theorems of analysis
  ({doc}`r1_pojecia`, §4), everything else is proved.
* Notation and the numbering of lemmas in {doc}`r2_dowod` are matched to the original: Lemma 2.1 = *Lemma One*,
  Theorem 3.4 = *Theorem One* §1, Lemma 4.2 = *Lemmas Two* and *Three*, Theorem 4.4 = *Theorem Two*,
  §6–§8 = *Theorems One–Three* §2.

This chapter is based on Richardson's original paper and on expositions prepared by the
instructor; the computations in it are run every time the book is built.
