# Context, consequences and further results

## 1. What the theorem says about computer algebra systems

Corollary 7.2 in {doc}`r2_dowod` says that for expressions with $\sin$, $\exp$, $\pi$, $\log 2$ and the absolute value
there **is no** canonical-form algorithm. Every function like `simplify` is therefore
doomed to one of two fates: either it sometimes fails to recognize zero, or it sometimes gets it wrong. CAS
designers choose the former — and use several strategies worth knowing:

1. **Subclasses with a canonical form.** Polynomials and rational functions have a canonical form
   (Lecture 1, §1.3). For exponential-logarithmic expressions, *structure theorems*
   (Risch) reduce zero recognition for functions to zero recognition for **constants**.
2. **Randomized tests.** For polynomial and algebraic identities, testing at random points
   modulo a large prime gives a probabilistic guarantee (the Schwartz–Zippel lemma, Lecture 1, §1.4).
3. **Certified numerics.** Interval arithmetic can **prove** that an expression
   is *not* zero (the interval does not contain zero) — this is how Proposition 10.1 in {doc}`r2_dowod` works.
   But it will never prove that an expression *is* zero: an interval containing zero does not rule out a very small nonzero value, and a computation at finitely many points says nothing about the others.
4. **Heuristics and the answer “I don't know”.** SymPy's `equals` method returns `None` when it cannot
   decide; `simplify` may return an unsimplified expression.

```{admonition} The lesson
:class: tip
“Nonzero” can be **established by computation**. “Equal to zero” requires a **proof**. Richardson's
theorem says that in a sufficiently rich language there is no algorithm that always finds
such a proof.
```

## 2. Why the sine? The boundary of decidability

The heart of the proof is the equivalence $\sin(\pi x)=0\iff x\in\mathbb Z$: the sine makes it possible
to **define the integers inside the real numbers**, and then arithmetic gets in,
together with its undecidability (Hilbert's tenth problem). Without periodicity
the situation is completely different:

| Language (one or several variables) | Is “$\exists x\ A(x)<0$” decidable? |
|---|---|
| polynomials with rational coefficients | **yes** — Tarski (1948/1951): the theory of real closed fields admits quantifier elimination; a practical algorithm: cylindrical algebraic decomposition (Collins, 1975) |
| polynomials and $\exp$ | **yes, if Schanuel's conjecture is true** — Macintyre and Wilkie (1996) |
| polynomials, $\sin$, $\pi$ | **no** — Richardson's construction (1968) with Matiyasevich's polynomial (1970); Caviness (1970) |
| integers, $x$, $\sin x^n$, $\sin(x\sin x^n)$ | **no** — Laczkovich (2003), without $\pi$ |

Wilkie (1996) proved that the structure $(\mathbb R,+,\cdot,<,\exp)$ is *o-minimal*: every
subset of the line definable in it is a finite union of intervals and points. In such a
structure $\mathbb Z$ cannot be defined — and that is exactly why there is hope for
decidability. The sine restricted to a compact interval is likewise “tame” (van den Dries, 1986).
Trouble arises only with the sine on the **whole** line, with its infinitely many zeros.

## 3. The constant problem and Schanuel's conjecture

Richardson noted in 1968 that it is not known whether the sign of expressions **without
variables** can be decided. The question of whether a given elementary constant (e.g., one built from rational numbers, $\pi$,
$e$, $\exp$, $\log$) equals zero remains open.

```{admonition} Schanuel's conjecture
:class: note
If the complex numbers $z_1,\dots,z_n$ are linearly independent over $\mathbb Q$, then the
transcendence degree of the field $\mathbb Q(z_1,\dots,z_n,e^{z_1},\dots,e^{z_n})$ over $\mathbb Q$ is at
least $n$.
```

The conjecture implies, among other things, the algebraic independence of $e$ and $\pi$ — today we do not even know whether
$e+\pi$ is irrational. Richardson (1997) gave an algorithm for zero recognition of
exponential-logarithmic constants that **always answers correctly when it halts** and
**always halts if Schanuel's conjecture is true**. This is a good example of how
open problems in number theory translate into questions about algorithms in CAS — e.g., the
Risch algorithm for integration in finite terms needs precisely a zero test for constants.

## 4. Further results

* **Caviness (1970)** observed that once Hilbert's tenth problem had been solved,
  $e^x$ and $\log 2$ could be removed from the theorem (see §11 in {doc}`r2_dowod`).
* **Wang (1974)** proved that the **existence of a zero** of elementary functions
  is undecidable. (A version of this result can be derived from our construction and the
  intermediate value theorem — this is Problem 9 in {doc}`r5_zadania`.)
* **Laczkovich (2003)** removed $\pi$ and restricted the use of composition: in the ring generated
  by the integers and the functions $x$, $\sin x^n$, $\sin(x\sin x^n)$ ($n=1,2,\dots$)
  it is undecidable whether a function takes a positive value and whether it has a root.
* **Richardson (1997)** — an algorithm for constants, conditional on Schanuel's conjecture (§3).

## 5. Connection with formal proofs

Proof assistants have decision procedures for **decidable** fragments of mathematics:
`ring` (identities in commutative rings — a canonical form), `linarith` and `omega`
(linear arithmetic), `norm_num` (numerical calculations), `decide` (finite checks).
Richardson's theorem explains why there is not — and cannot be — a complete tactic
“prove every identity involving $\sin$, $\exp$ and absolute value”: such proofs have to be found
(by a human, a heuristic, an AI model), and the kernel merely **checks** them. Peano Lab is
similar: Peano arithmetic is undecidable (Church, 1936), so the `auto` tactic is
necessarily incomplete.

## 6. Timeline

| Year | Event |
|---|---|
| 1900 | Hilbert poses the tenth problem: an algorithm for Diophantine equations |
| 1936 | Turing and Church: undecidability of the halting problem and of arithmetic |
| 1948/51 | Tarski: decidability of the theory of real closed fields |
| 1961 | Davis, Putnam, Robinson: semi-decidable sets are exponential Diophantine |
| 1968 | Richardson: undecidable problems for elementary functions |
| 1970 | Matiyasevich: semi-decidable sets are Diophantine; Caviness: removal of $e^x$, $\log2$ |
| 1974 | Wang: undecidability of the existence of zeros |
| 1996 | Wilkie: o-minimality of $\mathbb R_{\exp}$; Macintyre–Wilkie: decidability assuming Schanuel's conjecture |
| 1997 | Richardson: “How to recognise zero” |
| 2003 | Laczkovich: removal of $\pi$ |

## 7. Annotated bibliography

**Primary source**

* D. Richardson, *Some undecidable problems involving elementary functions of a real variable*,
  Journal of Symbolic Logic 33(4) (1968), 514–520, doi:10.2307/2271358. Seven pages; worth
  reading after this chapter — all the steps will be familiar.

**Arithmetic and computability**

* M. Davis, H. Putnam, J. Robinson, *The decision problem for exponential Diophantine
  equations*, Annals of Mathematics 74(3) (1961), 425–436, doi:10.2307/1970289.
* Yu. V. Matiyasevich, *Enumerable sets are Diophantine*, Soviet Mathematics Doklady 11 (1970),
  354–358 (original: Doklady Akademii Nauk SSSR 191 (1970), 279–282).
* M. Davis, *Hilbert's Tenth Problem is Unsolvable*, American Mathematical Monthly 80(3) (1973),
  233–269 — **the best starting point**: a complete, self-contained proof (Chauvenet
  and Steele Prizes).
* Yu. V. Matiyasevich, *Hilbert's Tenth Problem*, MIT Press 1993 — a monograph.
* J. P. Jones, *Universal Diophantine equation*, Journal of Symbolic Logic 47(3) (1982), 549–571.
* M. Sipser, *Introduction to the Theory of Computation*, Cengage — the chapters on
  decidability and reductions.
* B. Poonen, *Undecidable problems: a sampler*, in: J. Kennedy (ed.), *Interpreting Gödel*,
  Cambridge University Press 2014, 211–241; arXiv:1204.0299 — a survey of undecidability
  across different areas of mathematics, including Richardson's theorem.

**Extensions of Richardson's theorem**

* B. F. Caviness, *On canonical forms and simplification*, Journal of the ACM 17(2) (1970),
  385–396, doi:10.1145/321574.321591.
* P. S. Wang, *The undecidability of the existence of zeros of real elementary functions*,
  Journal of the ACM 21(4) (1974), 586–589, doi:10.1145/321850.321856.
* M. Laczkovich, *The removal of π from some undecidable problems involving elementary
  functions*, Proceedings of the AMS 131(7) (2003), 2235–2240, doi:10.1090/S0002-9939-02-06753-9.
* D. Richardson, *How to recognise zero*, Journal of Symbolic Computation 24 (1997), 627–645.

**Decidability and o-minimality**

* A. Tarski, *A Decision Method for Elementary Algebra and Geometry*, RAND 1948;
  2nd ed.: University of California Press 1951.
* G. E. Collins, *Quantifier elimination for real closed fields by cylindrical algebraic
  decomposition*, Lecture Notes in Computer Science 33 (1975), 134–183.
* A. J. Wilkie, *Model completeness results for expansions of the ordered field of real numbers
  by restricted Pfaffian functions and the exponential function*, Journal of the AMS 9(4)
  (1996), 1051–1094.
* A. Macintyre, A. J. Wilkie, *On the decidability of the real exponential field*, in:
  P. Odifreddi (ed.), *Kreiseliana*, A K Peters 1996, 441–467.

**Integration in finite terms**

* M. Rosenlicht, *Liouville's theorem on functions with elementary integrals*, Pacific Journal
  of Mathematics 24(1) (1968), 153–161, doi:10.2140/pjm.1968.24.153.
* B. Conrad, *Impossibility theorems for elementary integration*, notes (available on the
  author's website) — an accessible proof of Liouville's theorem and of the criterion for $f\,e^{g}$.
* M. Bronstein, *Symbolic Integration I: Transcendental Functions*, 2nd ed., Springer 2005 —
  the Risch algorithm in practice.
