Sums and products
A sum is known modulo the gcd of the moduli; a product modulo the gcd of the cross terms — (3 + 12a)(5 + 8b) = 15 + 24a + 60b + 96ab, and gcd(24, 60, 96) = 12.
A number you only know modulo something is still a number you can compute with. "3 mod 12" is a set — every integer that leaves remainder 3 — and adding "5 mod 8" to it gives a set too: everything is 0mod4, since 4 is all the two congruences agree on. The profinite integers Z^ are what those sets approximate: a profinite integer knows its residue modulo every N at once, and an element "known modulo N" is an open ball around it.
This page follows Mathé Hertogh's thesis Computing with adèles and idèles (Leiden, 2021) and its Sage package, over Q. Three value heads carry it — ProfiniteNumber, Adele and Idele — and everything else is an existing head that learned to take them.
ProfiniteNumber(x, m) is the coset x+mZ^. It normalises to the representative in [0,m), and a modulus of 0 means exact, so it is just x.
A sum is known modulo the gcd of the moduli; a product modulo the gcd of the cross terms — (3 + 12a)(5 + 8b) = 15 + 24a + 60b + 96ab, and gcd(24, 60, 96) = 12.
Equality asks whether the two sets meet. That is the only honest question about values known approximately, and it is not transitive: 6 mod 20 meets 6 mod 40 and 26 mod 40, which do not meet each other.
6 mod 20 is compatible with both; the two finer values are not compatible with each other.
By the Chinese remainder theorem, knowing xmod288=25⋅32 is knowing xmod25 and xmod32 separately: Z^=∏pZp. The p-adic components are the b-adic numbers the numerals package already has, so AdicNumeral(p, z) projects, and ProfiniteNumber of a list of them glues back.
100 mod 24 is 4 mod 8 at 2 and 1 mod 3 at 3; gluing the pieces gives it back. At 5 nothing is known, so the projection declines.
Q^=Z^⊗Q allows rational values and rational moduli: 21mod597 is a perfectly good element. It is integral when some d clears it into Z^, and Numerator and Denominator split it that way.
gcd(97/5, 10) = 1/5, and 1/2 + 1/3 = 5/6 ≡ 1/30 mod 1/5. 2/3 mod 5 is (2 mod 15)/3.
FnmodM is periodic in n, so it depends only on n modulo the period. Read the other way round (Lenstra, Profinite Fibonacci numbers): knowing n modulo N pins Fn down modulo every M whose Pisano period divides N — the largest is gcd(FN,FN+1−1). So Fibonacci is a continuous function Z^→Z^, and so is LucasL.
The Pisano period of 11 is 10, so n ≡ 3 mod 10 fixes Fₙ ≡ 2 mod 11 and Lₙ ≡ 4 mod 11.
A function on Z^ has a graph in Z^2, and Hertogh draws it by laying Z^ along the unit interval by its factorial digits, φ(α)=∑idi/(i+1)! — residue classes mod k! become consecutive cells. ProfinitePlot(f, x, k) fills a cell when f maps its column class into its row class. Lenstra's theorem that Fn=n has exactly the solutions n=0,1,5 and two more in Z^ shows up where the graph crosses the diagonal.
The identity is a diagonal; Fibonacci is a fractal that keeps meeting it.
An adèle of Q adds the one place the profinite part leaves out — the real numbers — so AQ=R×Q^. Adele(r, z) is the pair; a rational sits on the diagonal, Adele(q) being q at every place, and arithmetic is componentwise.
A rational multiplies both components; adèles add componentwise.
The idèles are the units of the adèles, with a finer topology: a nonzero real and, at each prime, a nonzero p-adic that is a unit at all but finitely many. Over Q each p-component is pvu with u a unit, so Idele(r, s, [...]) keeps the valuations in one positive rational s and lists the units that are known, as p-adics known modulo pn — Hertogh's c⋅U(n). A prime not listed has an unknown unit. Idele(r, q) is principal: q itself at every prime.
7 and 1/7 are inverse. A listed component moves its valuation into the scale: 15/7 at 5 is 5 × (3/7), and 3/7 ≡ 54 mod 125.
Every idèle is an adèle — the one whose component at p is pvu — and Adele(idèle) finds the coset in Q^ that holds it. Primes with no listed unit contribute only divisibility, and at 2 even an unknown unit is odd.
At 3 the unit is 2 mod 9; at 2 it is odd: together 11 mod 18.
Every M∈GLn(Q^) factors as M=BA with B∈GLn(Z^) and A∈GLn+(Q) — the matrix form of "Q^∗=Z^∗⋅Q>0", and the step Hertogh's algorithms for Shimura reciprocity rest on. ProfiniteDecomposition(m) finds A from the Hermite normal form of the lattice M's rows span, and gives back {B,A}. It declines when M is known too coarsely for A to be determined.
The rows of [[3, 1], [1, 1]] span the lattice with Hermite form [[1, 1], [0, 2]], and B = [[3, −1], [1, 0]] is unimodular. Known only modulo 12 — a multiple of the determinant — the same A comes out, and B is known modulo 12 in its first column and 6 in its second — A⁻¹ halves it.
Hertogh's package works over any number field K: profinite completions of its ring of integers, idèles mapping to ray class groups, and — the thesis's destination — Hilbert class polynomials computed through Shimura reciprocity. All of that needs number fields, their ideals and class field theory underneath, which the engine does not have yet.