💎 Reusable layer

Reusable layer v0.15.0

82 results of the formalizations archive under stable names Formalizations.Reusable.*. Each is proved by the archive theorem it re-exposes (no proof is copied). Usage example: 82 of 82. Axioms audited, standard only: 82 of 82. API marks lemmas to import into other proofs; showcase, classical theorems to consult.

📘 New to the layer? The practical guide takes you from installing it to using every theorem, with recipes and worked examples (en castellano, PDF).

Install directly from GitHub (Reservoir indexing pending).

1 Create a project

Shell
lake +leanprover/lean4:v4.35.0 new myproject std.toml
cd myproject

Standard template, not math: the math template adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.

2 Add to lakefile.toml

TOML
[[require]]
name = "formalizations"
git = "https://github.com/karlesmarin/formalizations"
rev = "v0.15.0"

3 Import one area

Lean 4
import Formalizations.Reusable.Geometry

or the whole layer: import Formalizations.Reusable. Each page gives the area and a compiled example.

4 Fetch and check

Shell
lake update
lake lean Example.lean

lake update fetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get). lake lean Example.lean builds the imports of the file (steps 3 and 4) and checks it. If the file belongs to a lean_lib of your project, lake build <lib> does the same. Avoid a bare lake build in a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code.

formalizations 0.15.0Lean v4.35.0Mathlib f0b4c81

The project that requires it must use the same Lean and Mathlib.

Geometry

Measure Theory

Analysis

R0004 showcase reusable

Oscillation of the Airy equation

Every solution f of the Airy equation f'' = x f on ℝ has zeros unbounded below: for every M there is x < M with f x = 0.

airy_eq_zeros_unbounded_below
R0005 showcase reusable upstream candidate

Glasser's integral

For a ≥ 0 and b > 0, \(∫_{v>0}\) \(v^{-1/2}\) exp(−a/v − b v) dv = √(π/b) exp(−2√(ab)) (the modified Bessel \(K_{1/2}\) integral).

glasser_integral
R0006 API reusable upstream candidate

Product of sines

For every n ≥ 1, \(∏_{k=1}^{n−1}\) 2 sin(kπ/n) = n.

prod_two_sin_mul_pi_div
R0016 API reusable upstream candidate

The Eneström–Kakeya theorem

The Eneström–Kakeya theorem: a polynomial \(∑_{k ≤ n}\) a_k z^k with real coefficients a_0 ≥ a_1 ≥ ⋯ ≥ a_n > 0 has no zero in the open unit disc ‖z‖ < 1.

enestrom_kakeya_ne_zero
R0039 showcase reusable

Generalised Hlawka inequality (Djoković 1963; Smiley–Smiley 1964)

Generalised Hlawka inequality: for n ≥ 3 vectors of a real inner product space, with d_k the sum of the norms of all k-element subsums, d_2 + ⋯ + \(d_{n-1}\) ≤ (2^(n-2) − 1)(d_1 + d_n); n = 3 is Hlawka's ‖x+y‖+‖y+z‖+‖z+x‖ ≤ ‖x‖+‖y‖+‖z‖+‖x+y+z‖.

hlawka_generalised
R0051 showcase reusable

The Zieliński–Zych inequality

The Zieliński–Zych inequality: for every α > 0 and x ≥ 0, 0 ≤ x^α − π^α/2 + (π^α/2) cos x + α π^(α−1) sin x; the analytic core of the fractional-moment speed limit π^α ≤ 2 M_α τ^α (α = 1 is Margolus–Levitin).

zielinski_zych_inequality
R0054 showcase reusable

The Margolus–Levitin theorem

The Margolus–Levitin quantum speed limit (ℏ = 1): for a normalized population p over nonnegative energies E with mean Ebar, if the autocorrelation Σ pₙ e^(−i Eₙ τ) vanishes at τ ≥ 0, then π ≤ 2 · Ebar · τ.

margolus_levitin
R0059 showcase reusable

mandelstam_tamm_L1

For a probability distribution over real energy levels, if its autocorrelation vanishes at time τ ≥ 0, then D₁τ ≥ 1, where D₁ is the mean absolute energy deviation from the reference energy.

mandelstam_tamm_L1
R0062 API reusable upstream candidate

variance_mixture_kurtosis_identity

For independent standard normal Z and nonnegative V with finite second moment and positive mean, √V · Z has kurtosis 3 E[V²] / E[V]² and excess kurtosis 3 Var(V) / E[V]² ≥ 0.

variance_mixture_kurtosis_identity
R0073 API reusable

Euler's reflection formula

Euler’s reflection formula for 0 < x < 1: Li₂(x) + Li₂(1 − x) = π²/6 − log(x) log(1 − x).

Li₂_add_Li₂_one_sub
R0074 API reusable

Landen's identity

Landen’s identity for 0 < x < 1/2: Li₂(x) + Li₂(x/(x − 1)) = −log²(1 − x)/2.

Li₂_landen
R0075 API reusable

Duplication

Duplication for the real dilogarithm: Li₂(x²) = 2(Li₂(x) + Li₂(−x)) for |x| ≤ 1.

Li₂_sq
R0076 showcase reusable

Abel's five-term relation

Abel’s five-term relation for the Rogers dilogarithm on (0, 1): L(x) + L(y) = L(xy) + L(x(1 − y)/(1 − xy)) + L(y(1 − x)/(1 − xy)).

rogersL_fiveterm
R0077 showcase reusable

The dilogarithm at the imaginary unit

At the imaginary unit, the complex dilogarithm is Li₂(i) = −π²/48 + i G, where G is Catalan’s constant.

Li₂c_I

Polynomial

R0007 API reusable upstream candidate

Real-rootedness from sign alternation

A nonzero real polynomial of degree at most n that alternates sign at n + 1 strictly increasing points splits over ℝ (is real-rooted).

splits_of_alternating_sign
R0011 API reusable upstream candidate

Counting real roots by sign alternation

If a nonzero real polynomial takes strictly alternating signs at n + 1 strictly increasing points, it has at least n distinct real roots.

card_roots_toFinset_ge_of_alternating_sign
R0012 API reusable upstream candidate

Real-rootedness from one root per gap

A nonzero real polynomial of degree at most n with a root in each of the n open gaps between n + 1 strictly increasing points splits over ℝ.

splits_of_isRoot_mem_Ioo_of_gaps
R0013 API reusable upstream candidate

Sturm's theorem

Sturm's theorem: for squarefree p ∈ ℝ[X] and a < b with p(a), p(b) ≠ 0, the sign variations of Mathlib's Polynomial.sturmSeq p p' at a minus those at b equal the number of distinct roots of p in (a, b].

sturm_signVariations_sub_eq_card_roots
R0014 API reusable upstream candidate

The Budan–Fourier theorem

The Budan–Fourier theorem: for nonzero p ∈ ℝ[X] and a < b with p(a), p(b) ≠ 0, the number of roots of p in (a, b] counted with multiplicity is at most V(a) − V(b), with even difference, where V(x) is the number of sign variations of p, p′, …, p^(deg p) at x.

budan_fourier_card_roots_le
R0015 API reusable upstream candidate

Newton's inequalities

Newton's inequalities: for a monic real polynomial p of degree n that splits over ℝ and 1 ≤ k ≤ n − 1, e_k² · C(n,k−1) C(n,k+1) ≥ \(e_{k−1}\) \(e_{k+1}\) · C(n,k)², with e_j the elementary symmetric functions of the roots.

newton_inequality_esymm_roots
R0021 API reusable upstream candidate

Real-rootedness is stable under differentiation

If a real polynomial splits over ℝ (all its roots are real), so does its derivative.

splits_derivative
R0022 API reusable upstream candidate

Real-rootedness is stable under reversal

If a real polynomial splits over ℝ, so does its reverse (the reciprocal polynomial X^deg · p(1/X)).

splits_reverse
R0050 API reusable upstream candidate

d'Ocagne's identity for the Vieta–Fibonacci polynomials

d'Ocagne's identity for the Vieta–Fibonacci polynomials: over a commutative ring, for Mathlib's Polynomial.Chebyshev.S and all p, q : ℤ, S p · S (q−1) − S q · S (p−1) = − S (p−q−1); the case q = p+1 is S_sq_add_S_sq.

chebyshev_S_docagne

Combinatorics

R0008 showcase reusable

Pomerance's theorem on the middle binomial coefficient

For every integer k ≥ 1, the set of n with n + k dividing the central binomial coefficient C(2n, n) has asymptotic density 1.

pomerance_density_add_dvd_centralBinom
R0020 showcase reusable upstream candidate

Kirchhoff's matrix-tree theorem

Kirchhoff's matrix-tree theorem: over an integral domain, deleting the row and column of any vertex from the Laplacian (Mathlib's lapMatrix) of a finite simple graph leaves a matrix whose determinant is the number of spanning trees.

det_lapMatrix_submatrix_eq_card_spanningTrees
R0028 API reusable upstream candidate

The neighbourhood function of a set family is submodular

For an indexed family of finite sets t, the neighbourhood function s ↦ |s.biUnion t| is submodular: |N(s ∪ u)| + |N(s ∩ u)| ≤ |N(s)| + |N(u)|.

card_biUnion_submodular
R0029 API reusable upstream candidate

Tight sets of a Hall family form a lattice

Under Hall's condition |v| ≤ |v.biUnion t| for all v, the union and the intersection of two tight sets (|s.biUnion t| = |s|) are tight.

card_biUnion_union_inter_eq_of_tight
R0030 showcase reusable

Bondy's theorem on induced subsets

Bondy's theorem: if X is a nonempty finite set and F a family of at most |X| distinct finite sets, some x ∈ X can be deleted from every member of F keeping them distinct.

bondy_exists_erase_injOn
R0035 showcase reusable

Godsil–Gutman identity

Godsil–Gutman: the sum over all ±1 edge signings of the characteristic polynomials of the signed adjacency matrices is (number of signings) times the matching polynomial.

godsil_gutman
R0036 showcase reusable

Bass's determinant formula over any commutative ring

Bass's determinant formula over any commutative ring: (1-u²)^|V| det(1-uB) = (1-u²)^|E| det(1-uA+u²(D-1)) with B the Hashimoto matrix.

bass_determinant_commRing
R0040 showcase reusable

Brégman's theorem (Minc's conjecture)

Brégman's theorem (Minc's conjecture): for an n × n (0,1)-matrix A with row sums r_i, per A ≤ ∏ (r_i!)^(1/r_i); zero rows allowed (factor 1).

bregman_permanent_le
R0041 API reusable upstream candidate

De Bruijn–Erdős colouring theorem

De Bruijn–Erdős: a graph G is n-colourable iff every finite induced subgraph is n-colourable (no finiteness hypothesis on the vertex type).

colorable_iff_forall_finite_induce
R0043 showcase reusable

Bruck–Ryser–Chowla theorem

Bruck–Ryser–Chowla: if a finite projective plane of order n exists and n ≡ 1 or 2 (mod 4), then n is a sum of two squares (so no plane of order 6 or 14).

bruck_ryser_chowla
R0044 API reusable upstream candidate

Transversal matroids

For a finite family A : Fin t → Finset α, the independent finite sets of the transversal matroid presented by A are exactly the partial transversals of A (by Hall, the I with |S| ≤ \(|⋃_{x∈S}\) {i | x ∈ A i}| for all S ⊆ I).

transversalMatroid_indep
R0046 API reusable upstream candidate

Laplacian factorization

For a finite simple graph on a linearly ordered vertex type, over any ring, the oriented incidence matrix N satisfies N Nᵀ = D − A, the Laplacian (Mathlib's SimpleGraph.lapMatrix).

orientedIncMatrix_mul_transpose
R0048 showcase reusable

Singmaster's bound

Singmaster's bound: an integer a ≥ 2 occurs at most 2⌊log₂ a⌋ times in Pascal's triangle (the set of positions (n,k), k ≤ n, with C(n,k) = a is finite with at most that many elements; Singmaster states 2 + 2⌊log₂ a⌋).

ncard_choose_eq_le_two_mul_log
R0068 API reusable

Matching polynomial of a forest

The matching polynomial of a finite forest equals the characteristic polynomial of its real adjacency matrix.

matchingPoly_forest_eq_charpoly
R0069 API reusable

Heilmann–Lieb real-rootedness

Heilmann–Lieb real-rootedness: the matching polynomial of every finite simple graph splits over ℝ.

matchingPoly_splits
R0070 API reusable

Heilmann–Lieb root bound

Heilmann–Lieb: if every vertex degree is at most Δ ≥ 2, then every real root of the matching polynomial lies in [−2√(Δ−1), 2√(Δ−1)].

matchingPoly_root_bound
R0071 showcase reusable

Godsil's path-tree identity

Godsil’s path-tree identity: μ(G) μ(T−r) = μ(G−u) μ(T), where T is the path tree at u, r is its root, and deletion takes the induced graph on the remaining vertices.

godsil_pathTree_identity
R0072 showcase reusable

Godsil's moment theorem

Godsil’s moment theorem: the sum of kth powers of the complex matching roots with multiplicity counts closed tree-like walks of length k, expressed by the root entries of the path-tree adjacency matrix powers.

matchingPoly_root_power_sum_eq_pathTree_walks
R0078 API reusable

Matching polynomial derivative

The derivative of the matching polynomial equals the sum of the matching polynomials of the induced graphs obtained by deleting one vertex at a time.

matchingPoly_derivative_eq_sum_vertex_deletions
R0079 API reusable

Tree-like walks below the girth

Below the extended girth, the number of closed tree-like walks of length k equals the trace of the kth adjacency matrix power over ℕ.

treeLikeWalkCount_eq_trace_of_lt_egirth
R0080 API reusable

Hashimoto trace and non-backtracking walks

The trace of the kth Hashimoto matrix power counts closed non-backtracking walks based at darts, cast into the coefficient ring.

trace_hashimoto_pow
R0081 showcase reusable

Matching gap law

For 1 ≤ k ≤ girth + 1, the adjacency trace minus the kth power sum of the complex matching roots, counted with multiplicity, equals the Hashimoto trace.

trace_sub_matchingPoly_root_power_sum_eq_trace_hashimoto
R0082 showcase reusable

Ihara trace generating function

The series with coefficient tr(B^(k+1)) at X^k for the Hashimoto matrix B is given by differentiating Bass’s determinant identity and inverting its unit factor.

ihara_Nk_explicit

Linear Algebra

R0009 API reusable upstream candidate

Rank of a block upper-triangular matrix

Over a field, the rank of the block upper-triangular matrix [[A, B], [0, D]] is at most the number of rows of A plus the rank of D.

rank_fromBlocks_zero₂₁_le_card_add_rank
R0017 API reusable upstream candidate

Subadditivity of the rank

Over a field, rank (A + B) ≤ rank A + rank B for matrices.

matrix_rank_add_le
R0018 API reusable upstream candidate

The Cauchy–Binet formula

Cauchy–Binet: for A : m × n and B : n × m over a commutative ring (n linearly ordered), det (A B) is the sum over the |m|-subsets S of n of det A[:, S] · det B[S, :].

det_mul_eq_sum_det_submatrix_mul_det_submatrix
R0019 API reusable upstream candidate

Jacobi's formula

Jacobi's formula: for a square matrix A of polynomials over a commutative ring, derivative (det A) = trace (adjugate A · A.map derivative).

derivative_det_eq_trace_adjugate_mul
R0023 API reusable upstream candidate

Lower bound for the rank of a block upper-triangular matrix

Over a field, rank A + rank D ≤ rank of the block upper-triangular matrix fromBlocks A B 0 D.

matrix_rank_add_rank_le_rank_fromBlocks
R0024 API reusable upstream candidate

The rank of a Kronecker product is the product of the ranks

Over a field, the rank of the Kronecker product A ⊗ₖ B of two matrices is rank A · rank B.

matrix_rank_kronecker
R0025 API reusable upstream candidate

Diagonal entries of the adjugate are principal minors

For a square matrix A over a commutative ring, indexed by any finite type, adjugate A i i is the determinant of the principal submatrix obtained by deleting row and column i.

adjugate_apply_self_eq_det_principal_submatrix
R0032 API reusable upstream candidate

Alternating characteristic polynomial ⇒ positive semidefinite

A real symmetric matrix whose characteristic polynomial has coefficients alternating in sign is positive semidefinite (the polynomial rule is a corollary of Descartes' rule of signs).

posSemidef_of_charpoly_alternating
R0033 API reusable upstream candidate

A positive semidefinite matrix of rank `k` is a sum of `k` squares

The quadratic form of a real positive semidefinite matrix of rank k is a sum of exactly k squares of linear forms.

psd_quadForm_eq_sum_rank_sq
R0034 API reusable upstream candidate

Rank through the Schur complement

Over a field, a block matrix with invertible top-left block A has rank card m + rank (D - C A⁻¹ B); with A positive definite and zero Schur complement it is PSD of rank card m.

rank_fromBlocks_of_isUnit₁₁
R0037 API reusable

Sums of squares of bilinear forms under orthogonal congruence

For P_H(x, y) = (x₀² + x₁²)(y·y) + 2x₀x₁(y·Hy) over a commutative ring and DᵀD = 1, every sum-of-squares representation of P_H by bilinear forms x·(B_i y) transports to one of \(P_{DᵀHD}\) by the forms B_i D (same number of squares); signed-graph switching is D = diag(s), s_i² = 1.

biquadratic_sos_transport
R0038 API reusable upstream candidate

Integer orthonormal columns are signed unit vectors

If an integer m × n matrix A satisfies AᵀA = I, every column j is \(±e_{f(j)}\) for an injective f : n → m (signed unit vectors in distinct rows); in particular an integer vector with v·v = 1 is ±e_i. False over ℚ.

int_columns_of_transpose_mul_self
R0042 showcase reusable

Schur's bound on commutative subspaces

Schur's bound: a subspace of M_n(K) over a field K whose elements pairwise commute has dimension ≤ ⌊n²/4⌋ + 1 (sharp: R0056).

schur_commuting_finrank_le
R0047 API reusable upstream candidate

Hua's identity

Hua's identity in a division ring: for a ≠ 0, b ≠ 0 and ab ≠ 1, a − (a⁻¹ + (b⁻¹ − a)⁻¹)⁻¹ = aba.

hua_identity
R0053 API reusable upstream candidate

Newton's identity for traces

Newton's identity for traces: for a square matrix M over a commutative ring R, d/dX (charpolyRev M) = − charpolyRev M · Σₖ trace(M^(k+1)) Xᵏ in R⟦X⟧, with charpolyRev M = det(1 − X • M).

derivative_coe_charpolyRev
R0056 showcase reusable

Schur's bound is sharp

Schur's bound is sharp: for every field K and n ≥ 1 there is a subspace of M_n(K) whose elements pairwise commute, of dimension exactly ⌊n²/4⌋ + 1 (the companion of R0042).

schur_commuting_finrank_attained
R0058 API reusable upstream candidate

mul_add_mul_eq_trace_smul_add_trace_smul_fin_two

For two-by-two matrices A and B over a commutative ring, AB + BA = tr(A) B + tr(B) A + (tr(AB) − tr(A)tr(B)) I.

mul_add_mul_eq_trace_smul_add_trace_smul_fin_two
R0061 API reusable upstream candidate

resolventSeries_diag_mul_coe_charpolyRev

For a square matrix M over a commutative ring, the power series with coefficients (Mᵏ)ᵢᵢ times the reversed characteristic polynomial of M equals the reversed characteristic polynomial of the principal submatrix deleting i.

resolventSeries_diag_mul_coe_charpolyRev

Algebraic Geometry

Number Theory

R0026 showcase reusable upstream candidate

Wolstenholme's theorem (1862)

Wolstenholme's theorem: for a prime p ≥ 5, C(2p − 1, p − 1) ≡ 1 and C(2p, p) ≡ 2 (mod p³).

wolstenholme_choose_modEq
R0031 showcase reusable upstream candidate

Touchard's congruence (1933)

Touchard's congruence: for every prime p and every n, the Bell numbers satisfy B(n + p) ≡ B(n) + B(n + 1) (mod p); in particular B(p) ≡ 2 (mod p).

touchard_bell_add_prime
R0045 API reusable

Dedekind reciprocity

Dedekind reciprocity: for coprime positive integers h, k, s(h,k) + s(k,h) = (h² + k² + 1)/(12hk) − 1/4, with s(h,k) = \(Σ_{r<k}\) ((r/k))((hr/k)) the Dedekind sum.

ded_reciprocity
R0049 API reusable upstream candidate

The Dirichlet identity `τ ∗ φ = σ`

The Dirichlet identity τ ∗ φ = σ: for every n, \(Σ_{d∣n}\) τ(d) φ(n/d) = σ(n), with τ the number of divisors, φ Euler's totient and σ the sum of divisors.

sum_card_divisors_mul_totient
R0057 API reusable upstream candidate

Cyclotomic reciprocity

Cyclotomic reciprocity: for n ≥ 2, the nth cyclotomic polynomial over ℝ equals its coefficient reversal.

reverse_cyclotomic
R0063 API reusable upstream candidate

Existence of Pisano periods

For every positive m, the Fibonacci sequence modulo m has a positive period valid from index zero.

exists_fib_modEq_period
R0064 API reusable upstream candidate

Parity of Pisano periods

For every modulus m > 2, each positive period of the Fibonacci sequence modulo m is even.

even_of_fib_modEq_period
R0065 API reusable upstream candidate

Fibonacci numbers at primes

For every prime p, the pth Fibonacci number equals the Legendre symbol (5/p) modulo p.

fib_prime_eq_legendreSym
R0066 showcase reusable

Flynn-Connolly's theorem

Infinitely many odd k divide the sum F₁ + ⋯ + Fₖ. For odd primes p ≡ 2 modulo 3 and p ≡ ±2 modulo 5, both k = F_(2p) and k = F_(4p) are odd and satisfy F_(k+2) ≡ 1 modulo k.

flynn_connolly
R0067 API reusable upstream candidate

Amiot's interval lemma

A cyclic interval of k consecutive residues modulo n, with 1 < k < n − 1, cannot be preserved by multiplication by a unit other than ±1.

amiot_interval

Group Theory