1. Lecture 1. How does a computer do mathematics?#
Date and room: see Harmonogram (in Polish).
Lecture materials
Slides (reveal.js) — the
Skey opens the speaker notes,Escthe slide overview.Interactive applets — including One example, three worlds, Anatomy of a floating-point number, and Expression tree.
Peano Lab — a small, readable “Lean for Peano arithmetic” that runs in the browser.
Every chapter of this book is a Jupyter notebook: use the download icon (at the top of the page) to get the
.ipynbfile and run it in VS Code.
What this lecture is about
A computer can “do mathematics” in three fundamentally different ways, and the whole course will move between them:
Numerics |
Symbolic computation (CAS) |
Formal proof |
|
|---|---|---|---|
objects |
machine numbers (e.g., |
exact expressions: \(\tfrac{1}{3}\), \(\sqrt{2}\), \(x^2+1\) |
theorems and proofs |
result |
an approximation |
a transformed expression |
a proof checked by the kernel |
guarantee |
rounding error, often unknown |
trust in the implementation of the algorithms |
trust in a small kernel |
tools |
Python, C, NumPy |
SymPy, SageMath, Mathematica, Maple |
Peano Lab, Lean, Rocq, Isabelle |
In this first meeting we get to know our working tools and, in outline, how each of the three “worlds” works. Our running example is the formula \(1 + 2 + \dots + n = \tfrac{n(n+1)}{2}\): we will check it numerically (as with a calculator), symbolically (a CAS produces the formula — but that is only a pseudo-proof), and formally (a proof by induction in Heyting arithmetic, checked by the Peano Lab kernel; the language of this theory has no summation symbol, so in it we prove that \(n(n+1)/2\) is a natural number, and we prove the formula itself in Lean).
Outline
Working environment: VS Code, Python, Jupyter, SymPy, and SageMath — VS Code, Python, Jupyter, SymPy, SageMath; how to set up your computer for the labs.
Python for mathematicians: first steps — Python as a mathematician’s language: numbers, types, lists, functions, loops.
How does a computer algebra system work? — expression trees, canonical forms, the zero problem (Richardson’s theorem), branches and assumptions, the algorithms “under the hood.”
Computation, verification, proof — what it means to compute, to verify, and to prove: floating-point arithmetic, patterns that break, the Schwartz–Zippel randomized test, Peano Lab and Lean.
On the slides, section 3 and the Rump example, interval arithmetic and the pyramid of trust from section 4 belong to Lecture 2.
After this lecture you will be able to
run a Jupyter notebook in VS Code with your own Python environment and SymPy installed;
explain how a numerical result, a symbolic result, and a formal proof differ — and what guarantee each of them gives;
give an example in which a numerical computation leads to a wrong conclusion;
describe how a CAS represents an expression (as a tree) and why “simplify” cannot always succeed;
read a short proof by induction in Peano Lab and say what exactly the kernel checks.
Before the labs
Install VS Code, Python (version 3.12 or newer), and the packages sympy numpy matplotlib ipykernel following
the section Working environment: VS Code, Python, Jupyter, SymPy, and SageMath. Problem sets: Lab 1: VS Code, Jupyter, and Python as a mathematician’s calculator
and Lab 2: SymPy and SageMath — first symbolic computations.