Try doing some basic maths questions in the Lean Theorem Prover. Functions, real numbers, equivalence relations and groups. Click on README.md and then on "Open in CoCalc with one click".
License: APACHE
Maths in Lean : p-adic numbers
The construction of ℝ using Cauchy sequences of rationals can be generalized to any absolute value on ℚ. For any prime p, the completion of ℚ with repsect to the p-adic norm creates a field ℚ_p and a ring ℤ_p.
padic_norm.leandefines the p-adic valuationℤ → ℕ, extends it toℚ, and definespadic_norm {p} : prime p → ℚ → ℚ. Note that this does not lead to a useful instance ofhas_normsincepcannot be inferred from the input, and it is not a norm for compositep.padic_normis shown to be a non-archimedean absolute value.Fix
pand[prime p].padic_rationals.leandefinesℚ_[p]as the Cauchy completion ofℚwrtpadic_norm pusing the same mechanisms asdata/real/basic.lean. It is immediately a field. The norm lifts topadic_norm_e : ℚ_[p] → ℚ, which is cast toℝand gives us anormed_fieldinstance.ℚ_[p]is shown to be Cauchy complete.padic_integers.leandefinesℤ_[p]as the subtype{x : ℚ_[p] \\ ∥x∥ ≤ 1}. It instantiateslocal_ringandnormed_ringand is Cauchy complete.hensel.leanproves Hensel's lemma overℤ_[p], described by Gouvêa (1997) as the "most important algebraic property of the p-adic numbers." ForF : polynomial ℤ_[p]anda : ℤ_[p]with∥F.eval a∥ < ∥F.derivative.eval a∥^2, then there exists a uniquezsuch thatF.eval z = 0 ∧ ∥z - a∥ < ∥F.derivative.eval a∥; furthermore,∥F.derivative.eval z∥ = ∥F.derivative.eval a∥. The proof is an adaptation of a writeup by Keith Conrad and uses Newton's method to construct a sequence inℤ_[p]converging to the unique solution.