# Review questions and problems

The review questions test your understanding of the successive steps of the proof —
the answer is hidden under the button. The problems are marked by difficulty (★ — routine,
★★ — require an idea, ★★★ — challenge) and with 💻 if they require computation. The numbering of
lemmas and theorems refers to {doc}`r2_dowod`.

## Review questions

**1.** What is the input of the identity problem: a function or an expression? Why does this
distinction matter?

```{admonition} Answer
:class: dropdown
An expression — a finite tree that an algorithm can read. A function is an infinite object.
Different expressions may denote the same function (e.g., $\sin^2x+\cos^2x$ and $1$), and the question concerns
the function. Undecidability lives precisely in the passage from notation to meaning.
```

**2.** Does Richardson's theorem imply that a computer cannot verify the identity
$\sin^2x+\cos^2x=1$?

```{admonition} Answer
:class: dropdown
No. The theorem says that there is no **single** algorithm that is correct for **all** expressions
in the class. Specific identities (and huge subclasses) are decided by a computer without difficulty; SymPy
simplifies $\sin^2x+\cos^2x$ to $1$.
```

**3.** Why does the language need a periodic function? What happens if we allow only
polynomials?

```{admonition} Answer
:class: dropdown
The equation $\sin(\pi x)=0$ defines the set $\mathbb Z$, and through it arithmetic and Hilbert's
tenth problem enter the real numbers. For polynomials alone, the sign problem (and even
arbitrary sentences with quantifiers) is decidable — Tarski's theorem.
```

**4.** What are the weights $k_i^4$ in the penalty $f$ for? What would happen without them?

```{admonition} Answer
:class: dropdown
They control the change of $P^2$ when a point is rounded to the nearest lattice point, in places where
the derivatives of $P^2$ are large. Without weights, a small residual does not force an integer zero — Example 3.1:
$P_N(x)=Nx-1$ has no root in $\mathbb N$, while the unweighted residual attains $\sin^2(\pi/N)\to0$.
```

**5.** Why, in Theorem 3.4, do we round to the nearest **natural** number rather than the nearest
integer? Where does this matter?

```{admonition} Answer
:class: dropdown
The polynomial $P$ contains powers $2^{x_i}$, which are integers only for $x_i\in\mathbb N$. For
nonnegative $x_i$ the nearest integer is a natural number, so property (P2) applies.
That is why we first prove the theorem on the set $[0,\infty)^n$ and then substitute squares.
```

**6.** Where exactly in the proof do we use the fact that $P$ takes integer
values?

```{admonition} Answer
:class: dropdown
Only in the last step of Theorem 3.4: $0\le P(a,\mathbf m)^2<1$ and $P(a,\mathbf m)\in\mathbb Z$
give $P(a,\mathbf m)=0$. All the rest of the proof is analysis.
```

**7.** Why does the rounding theorem concern the inequality $f\le1$ and not just the equation
$f=0$?

```{admonition} Answer
:class: dropdown
Because later we substitute a dense curve, which yields arbitrarily **small** values, but not necessarily
zeros. A gap is needed: either there is a zero, or $f>1$ everywhere.
```

**8.** Does the curve $\Gamma_n$ pass through every point of $\mathbb R^n$? Is that needed?

```{admonition} Answer
:class: dropdown
No — its image has measure zero (Remark 4.6). It is not needed: it suffices that the curve enters every
neighborhood, because the strict inequality $F<c$ holds on a whole neighborhood (Lemma 5.1).
```

**9.** Why in Lemma 4.2 do we require $g(w)=b$ **exactly**, not just approximately?

```{admonition} Answer
:class: dropdown
So that the induction in Theorem 4.4 works without accumulating errors: the successive coordinates are
iterates of the very steep function $g$, so even a small error in $g(w)$ would be
enormously amplified. An approximation would also suffice (by the continuity of $\Gamma_n$), but with an astronomically small tolerance. Exact equality reproduces the entire “tail” of the curve without error.
```

**10.** For $a\in U$, must the function $G_a$ have a zero?

```{admonition} Answer
:class: dropdown
Not necessarily: we only know that $\inf G_a=0$ (arbitrarily small values). The curve may miss the zero
of the function $F(a,\cdot)$. The threshold $1$ is enough for the proof.
```

**11.** Where in the proof is the absolute value needed, and why can't it simply be omitted?

```{admonition} Answer
:class: dropdown
In part (B): $B_a=|A_a|-A_a$ is identically zero exactly when $A_a\ge0$.
An analytic function that vanishes on an interval vanishes everywhere, so in the language $\mathcal A_1$
we cannot build such a “plateau of zeros” — this proof does not give undecidability of the identity problem
without absolute value.
```

**12.** Is the problem “is $A(x)<0$ for some $x$?” semi-decidable? And the problem “is
$A\equiv0$?”

```{admonition} Answer
:class: dropdown
The first — yes (Proposition 10.1: we search rational points with certified
approximations). The second — no: its complement (“$A\not\equiv0$”) is semi-decidable, so
if it were semi-decidable itself, it would be decidable (Post's theorem), contrary to Theorem 7.1.
```

**13.** How does the identity problem differ from the constant problem?

```{admonition} Answer
:class: dropdown
Identity: an expression with a variable, the question $\forall t\ A(t)=0$ — undecidable. Constants:
an expression without variables, the question $c=0$ — status unknown (decidable for
exponential-logarithmic constants if Schanuel's conjecture is true).
```

**14.** In the reduction, what must be computable, and what merely has to exist?

```{admonition} Answer
:class: dropdown
The transformation $a\mapsto G_a$ (and further $A_a$, $B_a$, $J_a$) must be computable — these are operations
on expression trees. The points $\mathbf m$, $\mathbf u_0$, $t_0$, roots and minima exist
only in the correctness proof; the algorithm never computes them.
```

**15.** Why in Lemma 2.1 is the majorant of a constant $c$ equal to $c^2+2$ rather than $|c|+2$, as in Richardson's paper?

```{admonition} Answer
:class: dropdown
For the constants of the grammar ($q$, $\pi$, $\log2$), $|c|+2$ would also work, since their sign is known. The rule
$c^2+2$, however, is purely syntactic and also works for any variable-free subexpression
treated as a constant, e.g., $\pi-\frac{22}{7}$, whose sign the algorithm need not be able to determine.
```

**16.** What role does $\log2$ play in the original theorem? Is it necessary?

```{admonition} Answer
:class: dropdown
It is used to write $2^x=\exp(x\log2)$ in the polynomial from the Davis–Putnam–Robinson theorem.
After Matiyasevich's theorem an ordinary polynomial suffices, so $\exp$ and $\log2$ are unnecessary (§11).
```

**17.** Why does the threshold $\frac12$, rather than $1$, appear in the integration part?

```{admonition} Answer
:class: dropdown
We need an interval on which the switch $S_a$ is **exactly** equal to $1$, and this requires
$G_a\le\frac12$. For this, “$G_a<1$ somewhere” is not enough — we need the full information
$\inf G_a=0$ from Theorem 5.3.
```

**18.** Does Richardson's theorem contradict the existence of the Risch algorithm (integration in
finite terms)?

```{admonition} Answer
:class: dropdown
No. The Risch algorithm decides whether the integral of a function from suitable differential fields is elementary,
**assuming** that zero can be recognized in those fields. Richardson shows
that for the language with $\sin$ (on the whole line) and absolute value there is no such test; for constants the problem
is open.
```

**19.** A numerical program in `float64` returned $G_a(t)\approx0.5$. Do we now know that $a\in U$?

```{admonition} Answer
:class: dropdown
Only if the computation is **certified** (e.g., by interval arithmetic with an upper
bound $<1$). Then yes, since $G_a(t)<1\Rightarrow a\in U$. An ordinary `float` can be wrong,
especially since the witnesses lie at huge $t$ (see the example in §5 of {doc}`r2_dowod`).
```

**20.** Why do we define the curve $\Gamma_n$ for $n\ge2$?

```{admonition} Answer
:class: dropdown
For $n=1$ the formula would give $\Gamma_1(t)=t$, and the image $(M,\infty)$ is not dense in $\mathbb R$.
The number of variables can always be increased with “dummy” variables, so the assumption $n\ge2$ costs nothing.
```

## Problems

**1.** ★ Prove the inequalities from Lemma 2.1: $|c|<c^2+2$ for $c\in\mathbb R$ and
$|z|+1<z^2+2$. What are the smallest values of the differences?

**2.** ★ 💻 Build by hand the majorant from Lemma 2.1 for $A(x,y)=x\sin y-e^{x}$, and then check
the result with the function `majoranta` from {doc}`r2_dowod` and with a randomized test of the inequality
$|A(\mathbf z+\boldsymbol\eta)|<M_A(\mathbf z)$.

**3.** ★ Extend Lemma 2.1 to the language with absolute value: propose a rule for $M_{|A|}$ and prove it.
Why does Lemma 2.3 (differentiation) not extend, and why does the proof require the polynomial
$P$ to be analytic?

**4.** ★★ Prove in full the variant with squares (Remark 3.5):
$f_{\mathrm{alt}}=(n+1)^2\bigl[P^2+\sum_i\sin^2(\pi x_i)k_i^2\bigr]$ also yields a gap.

**5.** ★★ 💻 For $n=2$, find the number $s_0>1$ from Remark 3.6 (the largest you can) and
prove that $\varphi(s_0)<1$. What is the meaning of $s_0$ in the case $a\notin U$?

**6.** ★★ Can $g(t)=t\sin t^3$ be replaced by $t\sin t^2$ in the Richardson curve?
Analyze the proof of Lemma 4.2: compare the change of the phase with the admissible change of $h$ on
the same interval. (Hint: for the phase $t^k$, the ratio of the derivatives of the phase and of $h$
behaves like $k\,t^{k-1}/t$.)

**7.** ★★ Fill in the details of Remark 4.6: prove that the image of $\Gamma_2$ has Lebesgue measure
zero in $\mathbb R^2$ and yet is dense.

**8.** ★★ Show that the problem “is $A\ge0$ everywhere?” for $A\in\mathcal A_1$ is not
semi-decidable. (Hint: Proposition 10.1 and Post's theorem.)

**9.** ★★ **Existence of a zero.** Prove that there is no algorithm that, given
$A\in\mathcal A_1$, decides whether $A$ has a zero. Hint: show that for every $a$ there is a
point at which $G_a>1$ — estimate $F(a,\mathbf u)$ at points with $u_1^2=\frac12$ and use
density — and then apply the intermediate value theorem to $G_a-1$. (Cf. Wang, 1974.)

**10.** ★★ Prove that the relation “$A\not\equiv B$” for $A,B\in\mathcal B_1$ is
semi-decidable, while the relation “$A\equiv B$” is not.

**11.** ★★ Decidability for polynomials in one variable without Tarski's theorem:
show that $p\in\mathbb Q[x]$ takes a negative value if and only if it has a negative
leading coefficient, odd degree, or a real root of odd multiplicity.
Describe an algorithm (Sturm sequences) and implement it in SymPy (`sp.sturm`, `sp.sqf_list`). 💻

**12.** ★★ 💻 Check Lemma A.1 from {doc}`r3_dodatki` numerically for all
$1\le a,b\le 6$: compute $k$, $M$, $q$, $s$ and confirm the equivalence.

**13.** ★★ 💻 Reproduce the construction from Lemma 4.2 for the target $(a,b)=(0,100)$ and $\delta=10^{-3}$.
Estimate how many digits of precision are needed for the computation of $g(w)$ to be reliable, and check this
by changing `mp.mp.dps`.

**14.** ★★★ 💻 For the toy equation $x_1^2+x_2^2=5$ from §5, find a point $t$ at which
$G(t)<\frac12$ (such a point is needed in the integration part). How should $\delta$ be chosen? How
large is $t$, and what precision is needed?

**15.** ★★★ Prove Lemma B.4 from {doc}`r3_dodatki` for the language with the square root
instead of the absolute value (the details of the remark after Corollary B.5).

**16.** ★★★ Show that the function $\dfrac{\sin x}{x}$ (extended by the value $1$ at zero) has no
elementary antiderivative. Hint: the criterion for $f\,e^{g}$ from Conrad's notes
(consider $e^{ix}/x$) and an analogue of Lemma B.3.

**17.** ★★★ Read Laczkovich's paper (2003) and explain what replaces the condition
$\sin(\pi x)=0$, given that the language has no $\pi$.

## Topics for further exploration

* **Dense curves versus space-filling curves.** Compare the Richardson curve (dense, of measure zero, endless)
  with the Hilbert curve (a continuous **surjection** of a segment onto a square; see the course *Obliczenia
  matematyczne wspierane komputerowo* (in Polish), the chapter on the Hilbert curve). What does each of them give
  in dimension-reduction proofs?
* **Hunting for zeros that a CAS cannot see.** Collect identities that SymPy's `simplify`
  cannot handle (nested radicals, branches of the logarithm, Ramanujan's identities)
  and classify the reasons for the failures.
* **The constant problem and Schanuel's conjecture.** Present the algorithm from Richardson's paper (1997)
  and explain exactly where the conjecture is needed.
* **Hilbert's tenth problem.** Based on Davis's article (1973), explain why the
  relation $c=a^b$ is Diophantine (the Pell equation).
* **Formalization in Lean.** Formalize Lemma 3.3 ($2d\le\sin(\pi d)$ on
  $[0,\tfrac12]$) or Lemma 4.1 in Lean 4 + Mathlib. Which facts about the sine are already in Mathlib?
* **Decidable subclasses.** Implement a sign test for multivariate polynomials on
  small examples (cylindrical algebraic decomposition in Sage/Mathematica) and compare it with our
  semi-deciding interval procedure.
