dual_cert_p_bounds
For any positive integer m, dual_cert_p m is between 1 and m, and when it is at least 2, every triangular number T_k for k < dual_cert_p m - 1 satisfies T_k + dual_cert_p m < m.
Statement
theorem dual_cert_p_bounds (m : ℕ) (hm : 1 ≤ m) :
1 ≤ dual_cert_p m ∧ dual_cert_p m ≤ m ∧
(2 ≤ dual_cert_p m → ∀ k < dual_cert_p m - 1, triangular_number k + dual_cert_p m < m)- Source
- step towards dual_certificate_identity
- Verified
- 17 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- triangular_numberFor any natural number k, the k-th triangular number is defined as k(k+1)/2.
- dual_cert_pFor each natural number m, p(m) is the largest integer p >= 2 such that p + (p-2)(p-1)/2 < m, or 1 if no such integer exists.
- Used by 2
- dual_certificate_identityFor every natural number n with 1 ≤ n, there exists a sequence of integers y : Fin n → ℤ with 1 ≤ y j for all j : Fin n, such that for all…
- signed_relation_step_basis_triangularThe evaluation of signed_relation n (j.val + 1) on the step basis vector v^(i) (1 if i <= k else 0) is 0 for i < j, 1 for i = j, and…
The proof, explained
The proof branches on whether the candidate set s = {p ∈ [2, m] | p + T(p - 2) < m} is nonempty, following the definition of dual_cert_p m. When s is nonempty, dual_cert_p m is its maximum M ∈ s, which satisfies 2 ≤ M ≤ m and M + T(M - 2) < m; any k < M - 1 satisfies k ≤ M - 2, so by monotonicity of triangular numbers (proved in an auxiliary lemma), T(k) + M ≤ T(M - 2) + M < m. When s is empty, dual_cert_p m defaults to 1, which satisfies 1 ≤ 1 ≤ m and vacuously satisfies the implication since 2 ≤ 1 is false.
The triangular number function is monotonic: if a ≤ b, then triangular_number a ≤ triangular_number b.
Unfolding the definition of triangular numbers T(n) = n(n+1)/2, the goal becomes a(a+1)/2 ≤ b(b+1)/2. Since a ≤ b and consequently a + 1 ≤ b + 1, their product satisfies a(a+1) ≤ b(b+1) by `Nat.mul_le_mul`. Dividing both sides by 2 preserves the inequality by `Nat.div_le_div_right`.
uses
Nat.div_le_div_right,Nat.mul_le_mulunfold triangular_number exact Nat.div_le_div_right (Nat.mul_le_mul h (by omega))
It suffices to establish the desired bounds in two cases: when the candidate set s is nonempty, and when it is empty.
Unfolding the definition of `dual_cert_p`, the value is defined conditionally: if the finite set s = {p ∈ [2, m] | p + T(p - 2) < m} is nonempty, it evaluates to max s; otherwise, it defaults to 1. The proof splits into these two cases.
unfold dual_cert_p dsimp only split_ifs with h
When s is nonempty, its maximum element M satisfies 2 ≤ M ≤ m and M + triangular_number (M - 2) < m.
Let M = max s. By `Finset.max'_mem`, M is an element of s. Simplifying the membership condition using `Finset.mem_filter` and `Finset.mem_Icc` shows that M lies in the closed interval [2, m] (so 2 ≤ M ≤ m) and satisfies the filter predicate M + triangular_number (M - 2) < m.
uses
Finset.max'_mem,Finset.mem_filter,Finset.mem_Icc· have hmem := Finset.max'_mem _ h generalize Finset.max' _ h = M at hmem ⊢ simp only [Finset.mem_filter, Finset.mem_Icc] at hmem
When s is nonempty, M satisfies 1 ≤ M, M ≤ m, and triangular_number k + M < m for every k < M - 1.
From 2 ≤ M ≤ m, linear arithmetic immediately gives 1 ≤ M and M ≤ m. For the third condition, assuming 2 ≤ M and k < M - 1, we have k ≤ M - 2 over ℕ. By the monotonicity of triangular numbers (`DCB1.tri_mono`), triangular_number k ≤ triangular_number (M - 2). Combining this with the membership bound M + triangular_number (M - 2) < m yields triangular_number k + M < m by linear arithmetic.
uses
DCB1.tri_monorefine ⟨by omega, by omega, fun _ k hk => ?_⟩ have := DCB1.tri_mono (show k ≤ M - 2 by omega) omega
When s is empty, dual_cert_p m = 1 satisfies the bounds 1 ≤ 1 ≤ m, and the conditional inequality holds vacuously.
When s is empty, `dual_cert_p m` evaluates to 1. The inequality 1 ≤ 1 holds by reflexivity (`le_rfl`), 1 ≤ m is the theorem's hypothesis (hm), and the implication 2 ≤ 1 → ... is vacuously true because 2 ≤ 1 is false.
uses
le_rfl· exact ⟨le_rfl, hm, fun h2 => absurd h2 (by omega)⟩
Nat.div_le_div_right- Dividing both sides of an inequality of natural numbers by a positive natural number preserves the inequality: if a ≤ b, then a / c ≤ b / c.
Nat.mul_le_mul- Multiplying inequalities between natural numbers preserves the inequality: if n₁ ≤ n₂ and m₁ ≤ m₂, then n₁ * m₁ ≤ n₂ * m₂.
Finset.max'_mem- The maximum element of a nonempty finite set belongs to that set.
Finset.mem_filter- An element belongs to a filtered finite set if and only if it belongs to the base set and satisfies the predicate.
Finset.mem_Icc- An integer lies in the closed interval [a, b] if and only if a ≤ x ≤ b.
DCB1.tri_mono- The triangular number function is monotonic: if a ≤ b, then T(a) ≤ T(b).
le_rfl- The inequality relation ≤ is reflexive: a ≤ a for every a.
- The source file contains an auxiliary lemma, `DCB1.tri_mono` (lines 3–6), which establishes the monotonicity of triangular numbers and is used in the main theorem `dual_cert_p_bounds`.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
namespace DCB1theorem tri_mono {a b : ℕ} (h : a ≤ b) : triangular_number a ≤ triangular_number b := by unfold triangular_number exact Nat.div_le_div_right (Nat.mul_le_mul h (by omega))end DCB1/-- Bounds on dual_cert_p m: dual_cert_p m is between 1 and m, and when it is at least 2, every triangular number T_k for k < dual_cert_p m - 1 satisfies T_k + dual_cert_p m < m. -/theorem dual_cert_p_bounds (m : ℕ) (hm : 1 ≤ m) : 1 ≤ dual_cert_p m ∧ dual_cert_p m ≤ m ∧ (2 ≤ dual_cert_p m → ∀ k < dual_cert_p m - 1, triangular_number k + dual_cert_p m < m) := by unfold dual_cert_p dsimp only split_ifs with h · have hmem := Finset.max'_mem _ h generalize Finset.max' _ h = M at hmem ⊢ simp only [Finset.mem_filter, Finset.mem_Icc] at hmem refine ⟨by omega, by omega, fun _ k hk => ?_⟩ have := DCB1.tri_mono (show k ≤ M - 2 by omega) omega · exact ⟨le_rfl, hm, fun h2 => absurd h2 (by omega)⟩