This section runs from the Frobenius to reciprocity. Every step reads a prime \(p\) in two ways and shows that the two readings agree.
Inside the arithmetic of \(\mathrm {rem}_p\),
the step “do it \(n\) times” applied to multiplication by \(x\).
Link 41. Let \(p\) be prime and \(0 < k < p\). The absorption identity gives
So \(p \mid k\binom {p}{k}\). Since \(0 < k < p\), \(p \nmid k\), and by Euclid’s lemma
Link 42. By the binomial theorem and link 41,
The Frobenius keeps both \(+\) and \(\cdot \).
Link 43: Fermat.
The fixed points of the step \(F\) are the base.
Link 44. If \(f\) has coefficients in the base and \(f(\alpha ) = 0\), then
The Frobenius sends roots to roots and permutes them; write \(\mathrm {Frob}_p := F\).
Link 45. The factors of \(f \bmod p\) have degrees \(d\) with \(F^d(\alpha ) = \alpha \), \(d\) least: the splitting of \(f\) at \(p\) is the cycle type of \(\mathrm {Frob}_p\) on the roots.
Link 46: cyclotomic. Let \(\zeta ^n = 1\) with \(\zeta ^m \neq 1\) for \(0 < m < n\). An automorphism \(\sigma \) keeps \(\cdot \), so \(\sigma (\zeta ) = \zeta ^a\) with \(a\) invertible modulo \(n\), and \(\sigma \tau (\zeta ) = \zeta ^{ab}\). Hence
Link 47: abelian reciprocity. The Galois reading of \(p\) is its remainder reading:
Let \(p \neq q\) be odd primes. Euler’s criterion reads the Legendre symbol as a power:
Gauss’s lemma, in Eisenstein’s form, reads it as a count:
The lattice points with \(1 \leq x \leq \frac {p-1}{2}\) and \(1 \leq y \leq \frac {q-1}{2}\) lie on one side or the other of the line \(q\,x = p\,y\), and none lies on it. Counting both sides:
So
On the modular curve \(X_0(N)\) the Hecke correspondence is \(T_p = \pi _{2*}\pi _1^{*}\) through \(X_0(Np)\), with \(p+1\) branches. Modulo \(p\), \(X_0(Np)\) becomes two copies of \(X_0(N)\): on one, \(D = \ker F\) and the correspondence is \(F\); on the other, \(D = \ker V\) and it is \(V = F^{t}\).
On \(H^1_{\text {\'et}}(X_0(N), \mathbb Q_\ell )\), for an eigenform with \(T_p f = a_p f\),
In general the Hecke algebra at \(p\) is the representation ring of the dual group (Satake), and the same line reads \(H_p(\mathrm {Frob}_p) = 0\) with
For an odd prime \(p\), \(y^2 + y = c\) is \((2y+1)^2 = 4c + 1\), so it has \(1 + \bigl (\frac {4c+1}{p}\bigr )\) solutions. Summing over \(x\) and adding the point at infinity,
On the other side, the coefficients of \(q \prod _{n \geq 1} (1 - q^n)^2 (1 - q^{11 n})^2\). The two agree at every prime below \(200\); the first few:
| \(p\) | 2 | 3 | 5 | 7 | 13 | 17 | 19 |
| \(a_p\) | \(-2\) | \(-1\) | \(1\) | \(-2\) | \(4\) | \(-2\) | \(0\) |
For \(\mathrm {GL}_n\) over a field \(F\) with \(r_1\) real and \(r_2\) complex places,
The space is algebraic, and the Frobenius acts on it, exactly when \(l_0 = 0\). A cuspidal \(\pi \) contributes to degree \(q_0 + i\) with multiplicity \(\binom {l_0}{i}\), and
These are the ranks of a Koszul complex on \(l_0\) elements: the condition for \(l_0 \geq 1\) is \(l_0\) successive nonzerodivisors, one for each step.
| \(F\) | \(n\) | \(l_0\) | \(\binom {l_0}{i}\) |
| \(\mathbb Q\) | 2 | 0 | \(1\) |
| \(\mathbb Q\) | 3 | 1 | \(1, 1\) |
| imaginary quadratic | 2 | 1 | \(1, 1\) |
| imaginary quadratic | 3 | 2 | \(1, 2, 1\) |
| quartic, \(r_2 = 2\) | 2 | 2 | \(1, 2, 1\) |
| Link | From | What appears |
| 40 | 10, 17 | the Frobenius: multiply \(p\) times |
| 41 | 33, 34 | \(p \mid \binom {p}{k}\) |
| 42 | 11, 41 | \(F\) keeps \(+\) and \(\cdot \) |
| 43 | 12, 42 | Fermat: the fixed points of \(F\) are the base |
| 44 | 42, 43 | \(F\) permutes roots: \(\mathrm {Frob}_p\) |
| 45 | 39, 44 | splitting \(=\) cycle type |
| 46 | 17, 18, 40 | cyclotomic: \(\mathrm {Frob}_p = \mathrm {rem}_n(p)\) |
| 47 | 24, 46 | abelian reciprocity |
| 48 | 36, 45, 46 | quadratic reciprocity |
| 49 | 24, 25 | \(T_p \equiv F + V\) |
| 50 | 49 | \(\mathrm {tr}\,\rho (\mathrm {Frob}_p) = a_p\), \(\det = p\) |
| 51 | 50 | counting points on \(y^2 + y = x^3 - x^2\) |
| 52 | 50 | the defect \(l_0\) |
| 53 | 52 | \(\binom {l_0}{i}\) and the Koszul shape |
The links of this section are checked in four Lean 4 files under work/, built on FTAChain.lean (Listing 9). The five files form one library, Work, and are compiled in order by a single lake build. They use the Lean core only. Every proof is a hand-written term: no omega, no simp, no ring, no decide; concrete numbers are checked by rfl. The output of every #print axioms command is recorded in AXIOMS.txt (Listing 16): 227 theorems in these five files, each “does not depend on any axioms”.
| File | Theorems | Without axioms |
| FTAChain.lean | 25 | 25 |
| FrobChain.lean | 21 | 21 |
| QRChain.lean | 132 | 132 |
| DefectChain.lean | 16 | 16 |
| ESChain.lean | 33 | 33 |
| Total | 227 | 227 |
| Link | Lean names | Checked |
| 41 | absorb, prime_dvd_C | every prime \(p\) |
| 42 | binom, sum_mid, frob | every prime \(p\) |
| 43 | fermat | every prime \(p\) |
| 48 | roots_le, euler_pm, euler_iff | every odd prime \(p\) |
| 48 | gauss_lemma, lattice, eisenstein_par | every odd prime |
| 48 | qr_by_floor, qr_law, qr_law_iff | every pair of odd primes \(p \neq q\) |
| 48 | leg_values, qr_example | numerical |
| 51 | cnt_sq, nE_formula, nE_signed, ap_eq | every odd prime \(p\) |
| 51 | modular_check | every prime \(p < 200\) |
| 52 | l0_even, l0_odd, l0_values | every \(n\); table values |
| 53 | sum_C, even_eq_odd, C_symm | every \(l\) |
What the check rests on. The numbers are Lean’s Nat; divisibility, the remainder and Euclid’s lemma come from FTAChain.lean. An odd prime is written \(h + h + 1\), so that \((p-1)/2\) is \(h\). Signs are not integers: a Legendre symbol is a truth value, and \((-1)^m\) is the parity of \(m\), so quadratic reciprocity is stated as “the two square-or-not values differ exactly when \(h \cdot g\) is odd” (qr_law). In link 51, \(a_p = -\sum _x \bigl (\frac {4x^3 - 4x^2 + 1}{p}\bigr )\) is proved as the natural-number identity \(\#E + N = p + 1 + P\), where \(P\) and \(N\) count the \(x\) whose symbol is \(+1\) and \(-1\) (nE_signed, ap_eq). The comparison with the coefficients of \(q \prod (1-q^n)^2 (1-q^{11n})^2\) is computed by rfl at all 46 primes below \(200\), including \(p = 2\) and \(p = 11\); for speed it uses Lean’s %, which rem_eq_mod proves equal to the remainder of the chain, and it runs with a raised heartbeat and recursion limit. Links 44–47 and 49–50 are not in these files.
FrobChain.lean
/-
FrobChain.lean
Frobenius and Fermat for every prime p (links 40-41).
Lean 4 core plus FTAChain. Proofs are hand-written terms and plain
rewriting; no omega / simp / ring / decide / norm_num / linarith.
Divisibility and congruence are FTAChain's `Dv` and `rem`.
Proved here:
C_self, C_one, C_gt basic values of the Pascal binomial
absorb' (k+1) * C (n+1) (k+1) = (n+1) * C n k
absorb 0 < k ≤ n → k * C n k = n * C (n-1) (k-1)
prime_dvd_C prime p, 0 < k < p → p ∣ C p k
binom (x+y)^n = Σ_{k ≤ n} C n k * x^k * y^(n-k)
frob (x+y)^p ≡ x^p + y^p (mod p)
fermat x^p ≡ x (mod p)
-/
import FTAChain
namespace FrobChain
open FTAChain
/-! ## The binomial coefficient, by Pascal's rule -/
def C : Nat → Nat → Nat
| _, 0 => 1
| 0, _ + 1 => 0
| n + 1, k + 1 => C n k + C n (k + 1)
theorem C_zero_right (n : Nat) : C n 0 = 1 := by
cases n <;> rfl
theorem C_succ_succ (n k : Nat) : C (n + 1) (k + 1) = C n k + C n (k + 1) := rfl
theorem C_gt : ∀ n k : Nat, C n (n + k + 1) = 0
| 0, _ => rfl
| n + 1, k => by
show C n (n + 1 + k) + C n (n + 1 + k + 1) = 0
rw [Nat.succ_add n k, C_gt n k, nzero_add]
exact C_gt n (k + 1)
theorem C_self : ∀ n : Nat, C n n = 1
| 0 => rfl
| n + 1 => by
show C n n + C n (n + 0 + 1) = 1
rw [C_self n, C_gt n 0]
theorem C_one : ∀ n : Nat, C n 1 = n
| 0 => rfl
| n + 1 => by
show C n 0 + C n 1 = n + 1
rw [C_zero_right n, C_one n]
exact Nat.add_comm 1 n
/-! ## The absorption identity -/
theorem absorb' : ∀ n k : Nat, (k + 1) * C (n + 1) (k + 1) = (n + 1) * C n k
| 0, 0 => rfl
| 0, _ + 1 => rfl
| n + 1, k => by
show (k + 1) * (C (n + 1) k + C (n + 1) (k + 1)) = (n + 1 + 1) * C (n + 1) k
rw [nleft_distrib, absorb' n k]
cases k with
| zero =>
show 1 * C (n + 1) 0 + (n + 1) * C n 0 = (n + 1 + 1) * C (n + 1) 0
rw [C_zero_right, C_zero_right, Nat.one_mul, Nat.mul_one, Nat.mul_one]
exact Nat.add_comm 1 (n + 1)
| succ j =>
rw [nsucc_mul (j + 1), absorb' n j, nsucc_mul (n + 1), C_succ_succ n j,
nleft_distrib]
exact nadd_right_comm _ _ _
theorem absorb (n k : Nat) (h0 : 0 < k) (hk : k ≤ n) :
k * C n k = n * C (n - 1) (k - 1) :=
match n, k, h0, hk with
| _, 0, h0, _ => absurd h0 (Nat.lt_irrefl 0)
| 0, _ + 1, _, hk => absurd hk (Nat.not_succ_le_zero _)
| n + 1, k + 1, _, _ => absorb' n k
/-! ## A prime divides the inner binomials -/
theorem dv_mul_right (d x h : Nat) (hx : Dv d x) : Dv d (x * h) :=
match hx with
| ⟨q, hq⟩ =>
⟨h * q, by rw [hq, nmul_comm (q * d) h, nmul_assoc]⟩
theorem prime_dvd_C (p k : Nat) (hp : Pr p) (h0 : 0 < k) (hk : k < p) : Dv p (C p k) :=
match hp, k, h0, hk with
| _, 0, h0, _ => absurd h0 (Nat.lt_irrefl 0)
| ⟨⟨j, hj⟩, hpr⟩, a + 1, _, hk => by
subst hj
have hpr' : ∀ d, Dv d (j + 1 + 1) → d = 1 ∨ d = j + 1 + 1 := hpr
have hab : Dv (j + 1 + 1) ((a + 1) * C (j + 1 + 1) (a + 1)) :=
⟨C (j + 1) a, by rw [absorb' (j + 1) a]; exact nmul_comm _ _⟩
match euclid_core j a (C (j + 1 + 1) (a + 1)) hpr' hab with
| Or.inr h => exact h
| Or.inl h =>
match dv_le (j + 1 + 1) a h with
| ⟨e, he⟩ =>
exact absurd (Nat.lt_of_le_of_lt (Nat.le.intro he) hk) (Nat.lt_irrefl _)
/-! ## Finite sums -/
def sumTo : Nat → (Nat → Nat) → Nat
| 0, _ => 0
| n + 1, f => sumTo n f + f n
theorem sum_ext : ∀ (n : Nat) (f g : Nat → Nat), (∀ k, k < n → f k = g k) →
sumTo n f = sumTo n g
| 0, _, _, _ => rfl
| n + 1, f, g, h => by
show sumTo n f + f n = sumTo n g + g n
rw [sum_ext n f g (fun k hk => h k (Nat.lt_succ_of_lt hk)), h n (Nat.lt_succ_self n)]
theorem sum_add : ∀ (n : Nat) (f g : Nat → Nat),
sumTo n (fun k => f k + g k) = sumTo n f + sumTo n g
| 0, _, _ => rfl
| n + 1, f, g => by
show sumTo n (fun k => f k + g k) + (f n + g n) = (sumTo n f + f n) + (sumTo n g + g n)
rw [sum_add n f g]
exact mid4 _ _ _ _
theorem sum_mul : ∀ (n : Nat) (f : Nat → Nat) (c : Nat),
sumTo n f * c = sumTo n (fun k => f k * c)
| 0, _, c => nzero_mul c
| n + 1, f, c => by
show (sumTo n f + f n) * c = sumTo n (fun k => f k * c) + f n * c
rw [nright_distrib, sum_mul n f c]
theorem sum_shift : ∀ (n : Nat) (f : Nat → Nat),
sumTo (n + 1) f = f 0 + sumTo n (fun k => f (k + 1))
| 0, f => nzero_add (f 0)
| n + 1, f => by
show sumTo (n + 1) f + f (n + 1) = f 0 + (sumTo n (fun k => f (k + 1)) + f (n + 1))
rw [sum_shift n f]
exact nadd_assoc _ _ _
/-! ## The binomial theorem -/
theorem sub_succ_add : ∀ n k : Nat, k < n → n - (k + 1) + 1 = n - k
| 0, k, h => absurd h (Nat.not_lt_zero k)
| _ + 1, 0, _ => rfl
| n + 1, k + 1, h => by
rw [Nat.succ_sub_succ, Nat.succ_sub_succ]
exact sub_succ_add n k (Nat.lt_of_succ_lt_succ h)
theorem mul_swap3 (a b c x : Nat) : a * b * c * x = a * (b * x) * c := by
rw [nmul_assoc a b c, nmul_assoc a (b * c) x, nmul_assoc b c x, nmul_comm c x,
← nmul_assoc b x c, ← nmul_assoc a (b * x) c]
theorem binom (x y : Nat) : ∀ n : Nat,
(x + y) ^ n = sumTo (n + 1) (fun k => C n k * x ^ k * y ^ (n - k))
| 0 => rfl
| n + 1 => by
have hS := binom x y n
-- the x-part
have hA : sumTo (n + 1) (fun k => C n k * x ^ k * y ^ (n - k)) * x
= sumTo (n + 1) (fun k => C n k * x ^ (k + 1) * y ^ (n - k)) := by
rw [sum_mul]
exact sum_ext _ _ _ (fun k _ => mul_swap3 _ _ _ _)
-- the y-part
have hB : sumTo (n + 1) (fun k => C n k * x ^ k * y ^ (n - k)) * y
= y ^ (n + 1) + sumTo n (fun k => C n (k + 1) * x ^ (k + 1) * y ^ (n - k)) := by
rw [sum_mul, sum_shift]
show C n 0 * x ^ 0 * y ^ n * y + _ = _
rw [C_zero_right, Nat.one_mul, Nat.pow_zero, Nat.one_mul]
apply congrArg (fun t => y ^ (n + 1) + t)
apply sum_ext
intro k hk
rw [nmul_assoc (C n (k + 1) * x ^ (k + 1))]
show C n (k + 1) * x ^ (k + 1) * y ^ (n - (k + 1) + 1) = _
rw [sub_succ_add n k hk]
-- the target, split
have hT : sumTo (n + 1 + 1) (fun k => C (n + 1) k * x ^ k * y ^ (n + 1 - k))
= y ^ (n + 1) + (sumTo (n + 1) (fun k => C n k * x ^ (k + 1) * y ^ (n - k))
+ sumTo n (fun k => C n (k + 1) * x ^ (k + 1) * y ^ (n - k))) := by
rw [sum_shift]
show C (n + 1) 0 * x ^ 0 * y ^ (n + 1) + _ = _
rw [C_zero_right, Nat.one_mul, Nat.pow_zero, Nat.one_mul]
apply congrArg (fun t => y ^ (n + 1) + t)
have h1 : sumTo (n + 1) (fun k => C (n + 1) (k + 1) * x ^ (k + 1) * y ^ (n + 1 - (k + 1)))
= sumTo (n + 1) (fun k => C n k * x ^ (k + 1) * y ^ (n - k)
+ C n (k + 1) * x ^ (k + 1) * y ^ (n - k)) := by
apply sum_ext
intro k _
rw [Nat.succ_sub_succ, C_succ_succ, nright_distrib, nright_distrib]
rw [h1, sum_add]
apply congrArg (fun t => sumTo (n + 1) (fun k => C n k * x ^ (k + 1) * y ^ (n - k)) + t)
show _ + C n (n + 0 + 1) * x ^ (n + 1) * y ^ (n - n) = _
rw [C_gt n 0, nzero_mul, nzero_mul, Nat.add_zero]
rw [hT]
show (x + y) ^ n * (x + y) = _
rw [hS, nleft_distrib, hA, hB]
exact nadd_left_comm _ _ _
/-! ## Frobenius -/
theorem sum_mid (p : Nat) (f : Nat → Nat) : ∀ m : Nat,
(∀ k, 0 < k → k ≤ m → Dv p (f k)) → ∃ q, sumTo (m + 1) f = f 0 + q * p
| 0, _ => ⟨0, by rw [nzero_mul]; exact nzero_add (f 0)⟩
| m + 1, h =>
match sum_mid p f m (fun k h0 hk => h k h0 (Nat.le_succ_of_le hk)),
h (m + 1) (Nat.zero_lt_succ m) (Nat.le_refl _) with
| ⟨q, hq⟩, ⟨e, he⟩ =>
⟨q + e, by
show sumTo (m + 1) f + f (m + 1) = _
rw [hq, he, nright_distrib, nadd_assoc]⟩
theorem rem_add_left (m' a c : Nat) :
rem (m' + 1) (a + c) = rem (m' + 1) (rem (m' + 1) a + c) :=
match rem_spec m' a with
| ⟨q, r, _, ha, _, hr⟩ => by
rw [hr, ha, nadd_assoc, rem_add_mul]
theorem rem_add_congr (m' a b c : Nat) (h : rem (m' + 1) a = rem (m' + 1) b) :
rem (m' + 1) (a + c) = rem (m' + 1) (b + c) := by
rw [rem_add_left m' a c, h, ← rem_add_left m' b c]
theorem frob (p x y : Nat) (hp : Pr p) : rem p ((x + y) ^ p) = rem p (x ^ p + y ^ p) :=
match hp with
| ⟨⟨j, hj⟩, _⟩ => by
have hmid : ∀ k, 0 < k → k ≤ j + 1 →
Dv p (C p k * x ^ k * y ^ (p - k)) := by
intro k h0 hk
apply dv_mul_right
apply dv_mul_right
apply prime_dvd_C p k hp h0
rw [hj]
exact Nat.lt_succ_of_le hk
match sum_mid p (fun k => C p k * x ^ k * y ^ (p - k)) (j + 1) hmid with
| ⟨q, hq⟩ =>
have hsplit : (x + y) ^ p = y ^ p + q * p + x ^ p := by
rw [binom x y p]
have e0 : C p 0 * x ^ 0 * y ^ (p - 0) = y ^ p := by
rw [C_zero_right, Nat.one_mul, Nat.pow_zero, Nat.one_mul]; rfl
have ep : C p p * x ^ p * y ^ (p - p) = x ^ p := by
rw [C_self, Nat.one_mul, Nat.sub_self, Nat.pow_zero, Nat.mul_one]
have hq' := hq
rw [e0] at hq'
show sumTo p (fun k => C p k * x ^ k * y ^ (p - k)) + C p p * x ^ p * y ^ (p - p) = _
rw [ep]
have hpj : p = j + 1 + 1 := hj
rw [hpj] at hq' ⊢
rw [hq']
rw [hsplit, nadd_right_comm, nadd_comm (y ^ p + x ^ p) (q * p), nadd_comm (y ^ p) (x ^ p),
hj, rem_add_mul]
/-! ## Fermat -/
theorem fermat (p : Nat) (hp : Pr p) : ∀ x : Nat, rem p (x ^ p) = rem p x
| 0 => match hp with
| ⟨⟨j, hj⟩, _⟩ => by rw [hj]; rfl
| x + 1 => by
rw [frob p x 1 hp, Nat.one_pow]
match hp with
| ⟨⟨j, hj⟩, _⟩ =>
rw [hj] at ⊢
have ih := fermat p hp x
rw [hj] at ih
exact rem_add_congr (j + 1) _ _ 1 ih
/-! ## Checks -/
theorem C_values : C 5 2 = 10 ∧ C 7 3 = 35 ∧ C 10 5 = 252 := ⟨rfl, rfl, rfl⟩
end FrobChain
#print axioms FrobChain.C_zero_right
#print axioms FrobChain.C_gt
#print axioms FrobChain.C_self
#print axioms FrobChain.C_one
#print axioms FrobChain.absorb'
#print axioms FrobChain.absorb
#print axioms FrobChain.dv_mul_right
#print axioms FrobChain.prime_dvd_C
#print axioms FrobChain.sum_ext
#print axioms FrobChain.sum_add
#print axioms FrobChain.sum_mul
#print axioms FrobChain.sum_shift
#print axioms FrobChain.sub_succ_add
#print axioms FrobChain.mul_swap3
#print axioms FrobChain.binom
#print axioms FrobChain.sum_mid
#print axioms FrobChain.rem_add_left
#print axioms FrobChain.rem_add_congr
#print axioms FrobChain.frob
#print axioms FrobChain.fermat
#print axioms FrobChain.C_values
QRChain.lean
/-
QRChain.lean
Quadratic reciprocity for all distinct odd primes p, q (links 42-46).
Lean 4 core plus FTAChain and FrobChain. Proofs are hand-written terms
and plain rewriting; no omega / simp / ring / decide / norm_num /
linarith. Divisibility and congruence are FTAChain's `Dv` and `rem`.
An odd prime is written `h + h + 1`, so that (p-1)/2 is `h`.
Signs are Booleans: `qr p a = true` means "a is a square mod p",
and the sign (-1)^n is read from the parity `par n`.
Proved here:
roots_le a polynomial over F_p with leading coefficient
not ≡ 0 has at most (degree) distinct roots
euler_pm p ∤ a → a^h ≡ 1 or a^h ≡ p-1
euler_iff p ∤ a → (a^h ≡ 1 ↔ a is a square mod p)
gauss_lemma p ∤ a → (a is a square ↔ μ is even)
eisenstein_par a odd, p ∤ a → μ ≡ Σ_{k=1}^{h} ⌊k a / p⌋ (mod 2)
lattice Σ_{k=1}^{h} ⌊k q/p⌋ + Σ_{k=1}^{g} ⌊k p/q⌋ = h g
qr_law (p|q)(q|p) = (-1)^(h g)
-/
import FrobChain
namespace QRChain
open FTAChain FrobChain
/-! ## Order and cancellation -/
theorem add_left_cancel' : ∀ (a b c : Nat), a + b = a + c → b = c
| 0, b, c, h => by rw [nzero_add, nzero_add] at h; exact h
| a + 1, b, c, h => by
rw [Nat.add_right_comm a 1 b, Nat.add_right_comm a 1 c] at h
exact add_left_cancel' a b c (succ_inj' h)
theorem add_right_cancel' (a b c : Nat) (h : b + a = c + a) : b = c := by
rw [Nat.add_comm b a, Nat.add_comm c a] at h
exact add_left_cancel' a b c h
theorem le_of_add_le_add_left' (a b c : Nat) (h : a + b ≤ a + c) : b ≤ c :=
match Nat.le.dest h with
| ⟨k, hk⟩ => Nat.le.intro (add_left_cancel' a _ _ (by rw [← Nat.add_assoc]; exact hk))
theorem lt_of_add_lt_add_left' (a b c : Nat) (h : a + b < a + c) : b < c :=
le_of_add_le_add_left' a (b + 1) c h
theorem add_sub_of_le' : ∀ (a b : Nat), a ≤ b → a + (b - a) = b
| 0, b, _ => by rw [nzero_add]; rfl
| a + 1, 0, h => absurd h (Nat.not_succ_le_zero a)
| a + 1, b + 1, h => by
rw [Nat.succ_sub_succ, Nat.add_right_comm]
exact congrArg Nat.succ (add_sub_of_le' a b (Nat.le_of_succ_le_succ h))
theorem lt_irrefl_of_le (a b : Nat) (h1 : a < b) (h2 : b ≤ a) : False :=
Nat.lt_irrefl a (Nat.lt_of_lt_of_le h1 h2)
theorem eq_zero_of_add_eq_self (a b : Nat) (h : a + b = a) : b = 0 :=
add_left_cancel' a b 0 h
theorem lt_of_le_of_ne' (a b : Nat) (h1 : a ≤ b) (h2 : a ≠ b) : a < b :=
match Nat.eq_or_lt_of_le h1 with
| Or.inl e => absurd e h2
| Or.inr l => l
/-! ## Parity -/
def par : Nat → Bool
| 0 => false
| n + 1 => !par n
def bx : Bool → Bool → Bool
| true, b => !b
| false, b => b
theorem par_add (a : Nat) : ∀ b : Nat, par (a + b) = bx (par a) (par b)
| 0 => by cases par a <;> rfl
| b + 1 => by
show (!par (a + b)) = bx (par a) (!par b)
rw [par_add a b]
cases par a <;> cases par b <;> rfl
theorem par_mul (a : Nat) : ∀ b : Nat, par (a * b) = (par a && par b)
| 0 => by show false = (par a && false); cases par a <;> rfl
| b + 1 => by
show par (a * b + a) = (par a && !par b)
rw [par_add, par_mul a b]
cases par a <;> cases par b <;> rfl
theorem par_double (a : Nat) : par (a + a) = false := by
rw [par_add]; cases par a <;> rfl
theorem par_split : ∀ n : Nat,
(par n = false → ∃ k, n = k + k) ∧ (par n = true → ∃ k, n = k + k + 1)
| 0 => ⟨fun _ => ⟨0, rfl⟩, fun h => Bool.noConfusion h⟩
| n + 1 => by
have ih := par_split n
constructor
· intro h
have h' : par n = true := by
revert h; show (!par n) = false → par n = true
cases par n <;> intro h <;> first | rfl | exact Bool.noConfusion h
match ih.2 h' with
| ⟨k, hk⟩ => exact ⟨k + 1, by rw [hk, ← Nat.add_assoc, Nat.add_right_comm k 1 k]⟩
· intro h
have h' : par n = false := by
revert h; show (!par n) = true → par n = false
cases par n <;> intro h <;> first | rfl | exact Bool.noConfusion h
match ih.1 h' with
| ⟨k, hk⟩ => exact ⟨k, by rw [hk]⟩
theorem bx_self (a : Bool) : bx a a = false := by cases a <;> rfl
theorem bx_false (a : Bool) : bx a false = a := by cases a <;> rfl
theorem bx_comm (a b : Bool) : bx a b = bx b a := by cases a <;> cases b <;> rfl
theorem bx_assoc (a b c : Bool) : bx (bx a b) c = bx a (bx b c) := by
cases a <;> cases b <;> cases c <;> rfl
/-! ## Finite sums and products over 1..n -/
def sum1 : Nat → (Nat → Nat) → Nat
| 0, _ => 0
| n + 1, f => sum1 n f + f (n + 1)
def prod1 : Nat → (Nat → Nat) → Nat
| 0, _ => 1
| n + 1, f => prod1 n f * f (n + 1)
theorem sum1_ext : ∀ (n : Nat) (f g : Nat → Nat), (∀ k, 0 < k → k ≤ n → f k = g k) →
sum1 n f = sum1 n g
| 0, _, _, _ => rfl
| n + 1, f, g, h => by
show sum1 n f + f (n + 1) = sum1 n g + g (n + 1)
rw [sum1_ext n f g (fun k h0 hk => h k h0 (Nat.le_succ_of_le hk)),
h (n + 1) (Nat.zero_lt_succ n) (Nat.le_refl _)]
theorem prod1_ext : ∀ (n : Nat) (f g : Nat → Nat), (∀ k, 0 < k → k ≤ n → f k = g k) →
prod1 n f = prod1 n g
| 0, _, _, _ => rfl
| n + 1, f, g, h => by
show prod1 n f * f (n + 1) = prod1 n g * g (n + 1)
rw [prod1_ext n f g (fun k h0 hk => h k h0 (Nat.le_succ_of_le hk)),
h (n + 1) (Nat.zero_lt_succ n) (Nat.le_refl _)]
theorem sum1_add : ∀ (n : Nat) (f g : Nat → Nat),
sum1 n (fun k => f k + g k) = sum1 n f + sum1 n g
| 0, _, _ => rfl
| n + 1, f, g => by
show sum1 n (fun k => f k + g k) + (f (n + 1) + g (n + 1))
= (sum1 n f + f (n + 1)) + (sum1 n g + g (n + 1))
rw [sum1_add n f g]
exact mid4 _ _ _ _
theorem sum1_mul_left : ∀ (n : Nat) (f : Nat → Nat) (c : Nat),
c * sum1 n f = sum1 n (fun k => c * f k)
| 0, _, _ => rfl
| n + 1, f, c => by
show c * (sum1 n f + f (n + 1)) = sum1 n (fun k => c * f k) + c * f (n + 1)
rw [nleft_distrib, sum1_mul_left n f c]
theorem sum1_const : ∀ (n c : Nat), sum1 n (fun _ => c) = n * c
| 0, c => (nzero_mul c).symm
| n + 1, c => by
show sum1 n (fun _ => c) + c = (n + 1) * c
rw [sum1_const n c, nsucc_mul]
theorem sum1_swap (f : Nat → Nat → Nat) (B : Nat) : ∀ A : Nat,
sum1 A (fun x => sum1 B (fun y => f x y)) = sum1 B (fun y => sum1 A (fun x => f x y))
| 0 => by
show 0 = sum1 B (fun _ => 0)
rw [sum1_const, Nat.mul_zero]
| A + 1 => by
show sum1 A (fun x => sum1 B (fun y => f x y)) + sum1 B (fun y => f (A + 1) y)
= sum1 B (fun y => sum1 A (fun x => f x y) + f (A + 1) y)
rw [sum1_swap f B A, sum1_add]
theorem prod1_mul : ∀ (n : Nat) (f g : Nat → Nat),
prod1 n (fun k => f k * g k) = prod1 n f * prod1 n g
| 0, _, _ => rfl
| n + 1, f, g => by
show prod1 n (fun k => f k * g k) * (f (n + 1) * g (n + 1))
= (prod1 n f * f (n + 1)) * (prod1 n g * g (n + 1))
rw [prod1_mul n f g]
exact mmid4 _ _ _ _
theorem pow_add' (a m : Nat) : ∀ n : Nat, a ^ (m + n) = a ^ m * a ^ n
| 0 => (Nat.mul_one _).symm
| n + 1 => by
show a ^ (m + n) * a = a ^ m * (a ^ n * a)
rw [pow_add' a m n, nmul_assoc]
theorem pow_mul' (a m : Nat) : ∀ n : Nat, a ^ (m * n) = (a ^ m) ^ n
| 0 => rfl
| n + 1 => by
show a ^ (m * n + m) = (a ^ m) ^ n * a ^ m
rw [pow_add', pow_mul' a m n]
theorem prod1_const : ∀ (n c : Nat), prod1 n (fun _ => c) = c ^ n
| 0, _ => rfl
| n + 1, c => by
show prod1 n (fun _ => c) * c = c ^ n * c
rw [prod1_const n c]
theorem prod1_pow (c : Nat) : ∀ (n : Nat) (e : Nat → Nat),
prod1 n (fun k => c ^ e k) = c ^ sum1 n e
| 0, _ => rfl
| n + 1, e => by
show prod1 n (fun k => c ^ e k) * c ^ e (n + 1) = c ^ (sum1 n e + e (n + 1))
rw [prod1_pow c n e, pow_add']
/-! ## Congruence modulo m' + 1 -/
theorem rem_of_lt (m' x : Nat) (h : x < m' + 1) : rem (m' + 1) x = x :=
match Nat.le.dest h with
| ⟨k, hk⟩ => by
have hk' : x + (k + 1) = m' + 1 := by rw [Nat.add_comm k 1, ← Nat.add_assoc]; exact hk
have e := rem_div m' 0 x k hk'
rw [nzero_mul, nzero_add] at e
exact e
theorem rem_lt' (m' n : Nat) : rem (m' + 1) n < m' + 1 :=
match rem_lt m' n with
| ⟨k, hk⟩ => by
show rem (m' + 1) n + 1 ≤ m' + 1
exact Nat.le.intro (by rw [Nat.add_assoc, Nat.add_comm 1 k]; exact hk)
theorem rem_zero_of_dv (m' n : Nat) (h : Dv (m' + 1) n) : rem (m' + 1) n = 0 :=
match h with
| ⟨q, hq⟩ => by
rw [hq]
exact rem_div m' q 0 m' (nzero_add (m' + 1))
theorem dv_of_rem_zero (m' n : Nat) (h : rem (m' + 1) n = 0) : Dv (m' + 1) n :=
match rem_spec m' n with
| ⟨q, r, _, hn, _, hr⟩ => by
have r0 : r = 0 := hr.symm.trans h
exact ⟨q, by rw [hn, r0]; rfl⟩
theorem rem_mul_left (m' a c : Nat) :
rem (m' + 1) (a * c) = rem (m' + 1) (rem (m' + 1) a * c) :=
match rem_spec m' a with
| ⟨q, r, _, ha, _, hr⟩ => by
rw [hr, ha, nright_distrib, nmul_assoc q (m' + 1) c, nmul_comm (m' + 1) c,
← nmul_assoc q c (m' + 1), rem_add_mul]
theorem rem_mul_congr (m' a b c : Nat) (h : rem (m' + 1) a = rem (m' + 1) b) :
rem (m' + 1) (a * c) = rem (m' + 1) (b * c) := by
rw [rem_mul_left m' a c, h, ← rem_mul_left m' b c]
theorem rem_mul_congr' (m' a b c : Nat) (h : rem (m' + 1) a = rem (m' + 1) b) :
rem (m' + 1) (c * a) = rem (m' + 1) (c * b) := by
rw [nmul_comm c a, nmul_comm c b]; exact rem_mul_congr m' a b c h
theorem rem_mul_congr2 (m' a b c d : Nat) (h1 : rem (m' + 1) a = rem (m' + 1) b)
(h2 : rem (m' + 1) c = rem (m' + 1) d) : rem (m' + 1) (a * c) = rem (m' + 1) (b * d) :=
Eq.trans (rem_mul_congr m' a b c h1) (rem_mul_congr' m' c d b h2)
theorem rem_add_congr' (m' a b c : Nat) (h : rem (m' + 1) a = rem (m' + 1) b) :
rem (m' + 1) (c + a) = rem (m' + 1) (c + b) := by
rw [Nat.add_comm c a, Nat.add_comm c b]; exact rem_add_congr m' a b c h
theorem rem_add_congr2 (m' a b c d : Nat) (h1 : rem (m' + 1) a = rem (m' + 1) b)
(h2 : rem (m' + 1) c = rem (m' + 1) d) : rem (m' + 1) (a + c) = rem (m' + 1) (b + d) :=
Eq.trans (rem_add_congr m' a b c h1) (rem_add_congr' m' c d b h2)
theorem rem_pow_congr (m' a b : Nat) (h : rem (m' + 1) a = rem (m' + 1) b) :
∀ n : Nat, rem (m' + 1) (a ^ n) = rem (m' + 1) (b ^ n)
| 0 => rfl
| n + 1 => rem_mul_congr2 m' _ _ _ _ (rem_pow_congr m' a b h n) h
theorem rem_cancel_add (m' a b c : Nat) (h : rem (m' + 1) (a + c) = rem (m' + 1) (b + c)) :
rem (m' + 1) a = rem (m' + 1) b := by
have h2 := rem_add_congr m' _ _ (m' * c) h
have e : ∀ x, x + c + m' * c = c * (m' + 1) + x := fun x => by
rw [Nat.add_assoc x c (m' * c), Nat.add_comm c (m' * c), ← nsucc_mul m' c,
nmul_comm (m' + 1) c, Nat.add_comm x (c * (m' + 1))]
rw [e a, e b, rem_add_mul, rem_add_mul] at h2
exact h2
theorem dv_of_rem_add (m' u v : Nat) (h : rem (m' + 1) (u + v) = rem (m' + 1) u) :
Dv (m' + 1) v := by
apply dv_of_rem_zero
have h2 : rem (m' + 1) (v + u) = rem (m' + 1) (0 + u) := by
rw [Nat.add_comm v u, nzero_add]; exact h
exact rem_cancel_add m' v 0 u h2
theorem rem_add_dv (m' u v : Nat) (h : Dv (m' + 1) v) : rem (m' + 1) (u + v) = rem (m' + 1) u :=
match h with
| ⟨q, hq⟩ => by rw [hq, Nat.add_comm u, rem_add_mul]
theorem rem_prod1_congr (m' : Nat) (f g : Nat → Nat) : ∀ n : Nat,
(∀ k, 0 < k → k ≤ n → rem (m' + 1) (f k) = rem (m' + 1) (g k)) →
rem (m' + 1) (prod1 n f) = rem (m' + 1) (prod1 n g)
| 0, _ => rfl
| n + 1, h =>
rem_mul_congr2 m' _ _ _ _
(rem_prod1_congr m' f g n (fun k h0 hk => h k h0 (Nat.le_succ_of_le hk)))
(h (n + 1) (Nat.zero_lt_succ n) (Nat.le_refl _))
/-! ## Primes -/
theorem euclid (p a b : Nat) (hp : Pr p) (h : Dv p (a * b)) : Dv p a ∨ Dv p b :=
match hp, a, h with
| _, 0, _ => Or.inl ⟨0, (nzero_mul p).symm⟩
| ⟨⟨j, hj⟩, hpr⟩, a + 1, h => by
subst hj; exact euclid_core j a b hpr h
theorem eq_zero_of_dv_lt (d t : Nat) (h : Dv d t) (hl : t < d) : t = 0 :=
match h with
| ⟨0, hq⟩ => by rw [hq, nzero_mul]
| ⟨q + 1, hq⟩ => by
rw [hq, nsucc_mul] at hl
exact absurd (Nat.lt_of_le_of_lt (Nat.le_add_left d (q * d)) hl) (Nat.lt_irrefl d)
theorem not_dv_of_lt (d k : Nat) (h0 : 0 < k) (hk : k < d) (h : Dv d k) : False := by
have e := eq_zero_of_dv_lt d k h hk
rw [e] at h0
exact Nat.lt_irrefl 0 h0
theorem not_dv_prod1 (p : Nat) (hp : Pr p) (f : Nat → Nat) : ∀ n : Nat,
(∀ k, 0 < k → k ≤ n → ¬ Dv p (f k)) → ¬ Dv p (prod1 n f)
| 0, _, hd =>
match hp with
| ⟨⟨j, hj⟩, _⟩ => by subst hj; exact dv_one_absurd j hd
| n + 1, h, hd =>
match euclid p _ _ hp hd with
| Or.inl h1 => not_dv_prod1 p hp f n (fun k h0 hk => h k h0 (Nat.le_succ_of_le hk)) h1
| Or.inr h2 => h (n + 1) (Nat.zero_lt_succ n) (Nat.le_refl _) h2
theorem cancel_core (m' a u v : Nat) (hp : Pr (m' + 1)) (ha : ¬ Dv (m' + 1) a)
(hv : v < m' + 1) (huv : u ≤ v)
(h : rem (m' + 1) (a * u) = rem (m' + 1) (a * v)) : u = v :=
match Nat.le.dest huv with
| ⟨t, ht⟩ => by
rw [← ht, nleft_distrib] at h
have hd := dv_of_rem_add m' _ _ h.symm
match euclid _ _ _ hp hd with
| Or.inl hda => exact absurd hda ha
| Or.inr hdt =>
have htv : t ≤ v := Nat.le.intro (by rw [Nat.add_comm]; exact ht)
have ht0 : t = 0 := eq_zero_of_dv_lt _ _ hdt (Nat.lt_of_le_of_lt htv hv)
rw [← ht, ht0]; rfl
theorem rem_cancel_mul (m' a x y : Nat) (hp : Pr (m' + 1)) (ha : ¬ Dv (m' + 1) a)
(h : rem (m' + 1) (a * x) = rem (m' + 1) (a * y)) : rem (m' + 1) x = rem (m' + 1) y := by
have hx := rem_mul_congr' m' x (rem (m' + 1) x) a (rem_idem m' x).symm
have hy := rem_mul_congr' m' y (rem (m' + 1) y) a (rem_idem m' y).symm
have e1 := (hx.symm.trans h).trans hy
match Nat.le_total (rem (m' + 1) x) (rem (m' + 1) y) with
| Or.inl hl => exact cancel_core m' a _ _ hp ha (rem_lt' m' y) hl e1
| Or.inr hl => exact (cancel_core m' a _ _ hp ha (rem_lt' m' x) hl e1.symm).symm
/-! ## Lists -/
def memL (v : Nat) : List Nat → Prop
| [] => False
| x :: xs => v = x ∨ memL v xs
def nodupL : List Nat → Prop
| [] => True
| x :: xs => ¬ memL x xs ∧ nodupL xs
def allL (P : Nat → Prop) : List Nat → Prop
| [] => True
| x :: xs => P x ∧ allL P xs
theorem allL_mono (P Q : Nat → Prop) (r : Nat) (hPQ : ∀ x, P x → x ≠ r → Q x) :
∀ L : List Nat, allL P L → ¬ memL r L → allL Q L
| [], _, _ => True.intro
| x :: xs, ⟨hx, hxs⟩, hm =>
⟨hPQ x hx (fun e => hm (Or.inl e.symm)),
allL_mono P Q r hPQ xs hxs (fun h => hm (Or.inr h))⟩
/-! ## Polynomials over F_p have at most (degree) roots -/
/-- Evaluation of a coefficient list, leading coefficient first. -/
def ev (x : Nat) : List Nat → Nat
| [] => 0
| c :: cs => c * x ^ cs.length + ev x cs
/-- Synthetic division by `X - r`: the quotient's coefficients. -/
def qd (r : Nat) : Nat → List Nat → List Nat
| _, [] => []
| b, c :: cs => b :: qd r (b * r + c) cs
theorem qd_length (r : Nat) : ∀ (b : Nat) (cs : List Nat), (qd r b cs).length = cs.length
| _, [] => rfl
| _, _ :: cs => congrArg Nat.succ (qd_length r _ cs)
/-- The remainder theorem, without subtraction:
`P(x) + r Q(x) = x Q(x) + P(r)`. -/
theorem qd_spec (x r : Nat) : ∀ (b : Nat) (cs : List Nat),
ev x (b :: cs) + r * ev x (qd r b cs) = x * ev x (qd r b cs) + ev r (b :: cs)
| b, [] => (nzero_add (b * 1)).symm
| b, c :: cs => by
have ih := qd_spec x r (b * r + c) cs
have t1 : r * (b * x ^ cs.length) = b * r * x ^ cs.length := by
rw [← nmul_assoc r b, nmul_comm r b]
have t2 : x * (b * x ^ cs.length) = b * x ^ (cs.length + 1) := by
rw [nmul_comm x, nmul_assoc]; rfl
have t3 : b * r ^ (cs.length + 1) = b * r * r ^ cs.length := by
rw [nmul_assoc]; show b * (r ^ cs.length * r) = _; rw [nmul_comm (r ^ cs.length) r]
show b * x ^ (cs.length + 1) + (c * x ^ cs.length + ev x cs)
+ r * (b * x ^ (qd r (b * r + c) cs).length + ev x (qd r (b * r + c) cs))
= x * (b * x ^ (qd r (b * r + c) cs).length + ev x (qd r (b * r + c) cs))
+ (b * r ^ (cs.length + 1) + (c * r ^ cs.length + ev r cs))
rw [qd_length, nleft_distrib, nleft_distrib, t1, t2, t3]
rw [Nat.add_assoc, Nat.add_assoc (b * x ^ (cs.length + 1))]
apply congrArg (fun t => b * x ^ (cs.length + 1) + t)
have hR : b * r * r ^ cs.length + (c * r ^ cs.length + ev r cs)
= (b * r + c) * r ^ cs.length + ev r cs := by
rw [← Nat.add_assoc, ← nright_distrib]
have hL : (c * x ^ cs.length + ev x cs) + (b * r * x ^ cs.length + r * ev x (qd r (b * r + c) cs))
= (b * r + c) * x ^ cs.length + ev x cs + r * ev x (qd r (b * r + c) cs) := by
rw [nright_distrib, ← Nat.add_assoc (c * x ^ cs.length + ev x cs),
Nat.add_right_comm (c * x ^ cs.length) (ev x cs), Nat.add_comm (c * x ^ cs.length)]
rw [hR, hL]
exact ih
/-- A root of `P` other than `r` is a root of the quotient by `X - r`. -/
theorem root_quot (m' : Nat) (hp : Pr (m' + 1)) (r s b : Nat) (cs : List Nat)
(hr : r < m' + 1) (hs : s < m' + 1) (hrs : s ≠ r)
(hPr : rem (m' + 1) (ev r (b :: cs)) = 0) (hPs : rem (m' + 1) (ev s (b :: cs)) = 0) :
rem (m' + 1) (ev s (qd r b cs)) = 0 := by
have hq := qd_spec s r b cs
have h1 : rem (m' + 1) (0 + r * ev s (qd r b cs)) = rem (m' + 1) (0 + s * ev s (qd r b cs)) := by
have a1 : rem (m' + 1) (ev s (b :: cs) + r * ev s (qd r b cs))
= rem (m' + 1) (0 + r * ev s (qd r b cs)) := rem_add_congr m' _ 0 _ hPs
have a2 : rem (m' + 1) (s * ev s (qd r b cs) + ev r (b :: cs))
= rem (m' + 1) (s * ev s (qd r b cs) + 0) := rem_add_congr' m' _ 0 _ hPr
rw [← a1, hq, a2, nzero_add]; rfl
rw [nzero_add, nzero_add, nmul_comm r, nmul_comm s] at h1
match dv_dec m' (ev s (qd r b cs)) with
| Or.inl hd => exact rem_zero_of_dv m' _ hd
| Or.inr hnd =>
have e := rem_cancel_mul m' _ r s hp hnd h1
rw [rem_of_lt m' r hr, rem_of_lt m' s hs] at e
exact absurd e.symm hrs
theorem roots_le_n (m' : Nat) (hp : Pr (m' + 1)) : ∀ (n : Nat) (cs : List Nat) (c : Nat)
(R : List Nat), cs.length = n → ¬ Dv (m' + 1) c → nodupL R →
allL (fun x => x < m' + 1 ∧ rem (m' + 1) (ev x (c :: cs)) = 0) R →
R.length ≤ n
| n, _, _, [], _, _, _, _ => Nat.zero_le n
| 0, [], c, x :: _, _, hc, _, ⟨⟨_, hx⟩, _⟩ => by
have e : rem (m' + 1) c = 0 := by
have hx' : rem (m' + 1) (c * 1 + 0) = 0 := hx
rw [Nat.mul_one] at hx'; exact hx'
exact absurd (dv_of_rem_zero m' c e) hc
| 0, _ :: _, _, _ :: _, hl, _, _, _ => Nat.noConfusion hl
| n + 1, [], _, _ :: _, hl, _, _, _ => Nat.noConfusion hl
| n + 1, d :: ds, c, r :: R', hl, hc, ⟨hnm, hnd⟩, ⟨⟨hr, hPr⟩, hall⟩ => by
have hds : (qd r (c * r + d) ds).length = n := by
rw [qd_length]; exact succ_inj' hl
have hall' : allL (fun x => x < m' + 1 ∧
rem (m' + 1) (ev x (c :: qd r (c * r + d) ds)) = 0) R' :=
allL_mono _ _ r
(fun x ⟨hx, hPx⟩ hxr => ⟨hx, root_quot m' hp r x c (d :: ds) hr hx hxr hPr hPx⟩)
R' hall hnm
exact Nat.succ_le_succ (roots_le_n m' hp n _ c R' hds hc hnd hall')
/-- **Roots.** A polynomial over F_p whose leading coefficient is not `≡ 0`
has at most (degree) distinct roots in `0..p-1`. -/
theorem roots_le (m' : Nat) (hp : Pr (m' + 1)) (c : Nat) (cs R : List Nat)
(hc : ¬ Dv (m' + 1) c) (hR : nodupL R)
(hroots : allL (fun x => x < m' + 1 ∧ rem (m' + 1) (ev x (c :: cs)) = 0) R) :
R.length ≤ cs.length :=
roots_le_n m' hp cs.length cs c R rfl hc hR hroots
/-! ## Euler's criterion. Here p = h + h + 1. -/
theorem h_pos (h : Nat) (hp : Pr (h + h + 1)) : 0 < h :=
match h, hp with
| 0, ⟨⟨j, hj⟩, _⟩ => absurd (succ_inj' hj).symm (succ_ne_zero' j)
| h + 1, _ => Nat.zero_lt_succ h
theorem rem_one (m' : Nat) (h0 : 0 < m') : rem (m' + 1) 1 = 1 :=
rem_of_lt m' 1 (Nat.succ_le_succ h0)
theorem hh_pos (h : Nat) (hp : Pr (h + h + 1)) : 0 < h + h :=
Nat.lt_of_lt_of_le (h_pos h hp) (Nat.le_add_right h h)
/-- Fermat in the form `y^(p-1) ≡ 1` for `p ∤ y`. -/
theorem fermat1 (h y : Nat) (hp : Pr (h + h + 1)) (hy : ¬ Dv (h + h + 1) y) :
rem (h + h + 1) (y ^ (h + h)) = 1 := by
have f := fermat (h + h + 1) hp y
have f' : rem (h + h + 1) (y * y ^ (h + h)) = rem (h + h + 1) (y * 1) := by
rw [nmul_comm, Nat.mul_one]; exact f
rw [rem_cancel_mul (h + h) y _ 1 hp hy f']
exact rem_one (h + h) (hh_pos h hp)
theorem sq_pow (x : Nat) : ∀ n : Nat, (x * x) ^ n = x ^ (n + n)
| 0 => rfl
| n + 1 => by
show (x * x) ^ n * (x * x) = x ^ (n + 1 + (n + 1))
rw [sq_pow x n, ← Nat.add_assoc (n + 1) n 1, Nat.add_right_comm n 1 n]
exact (nmul_assoc _ x x).symm
/-- `x² ≡ 1` forces `x ≡ 1` or `x ≡ -1`. -/
theorem sq_one (m' : Nat) (hp : Pr (m' + 1)) (h0 : 0 < m') (x : Nat)
(hx : rem (m' + 1) (x * x) = 1) : rem (m' + 1) x = 1 ∨ rem (m' + 1) x = m' := by
have hrr : rem (m' + 1) (rem (m' + 1) x * rem (m' + 1) x) = 1 :=
(rem_mul_congr2 m' _ _ _ _ (rem_idem m' x).symm (rem_idem m' x).symm).symm.trans hx
have hlt := rem_lt' m' x
revert hrr hlt
cases rem (m' + 1) x with
| zero =>
intro hrr _
have e0 : (0 : Nat) = 1 := hrr
exact absurd e0 (fun e => Nat.noConfusion e)
| succ t =>
intro hrr hlt
have e : (t + 1) * (t + 1) = t * (t + 1 + 1) + 1 := by rw [nsucc_mul]; rfl
rw [e] at hrr
have h2 : rem (m' + 1) (t * (t + 1 + 1) + 1) = rem (m' + 1) (0 + 1) := by
rw [hrr, nzero_add]; exact (rem_one m' h0).symm
have hd := dv_of_rem_zero m' _ (rem_cancel_add m' _ 0 1 h2)
match euclid _ _ _ hp hd with
| Or.inl ht =>
have t0 : t = 0 := eq_zero_of_dv_lt _ _ ht (Nat.lt_trans (Nat.lt_succ_self t) hlt)
rw [t0]; exact Or.inl rfl
| Or.inr ht2 =>
have hle : t + 1 + 1 ≤ m' + 1 := hlt
match Nat.eq_or_lt_of_le hle with
| Or.inl e2 => exact Or.inr (succ_inj' e2)
| Or.inr l2 => exact absurd (eq_zero_of_dv_lt _ _ ht2 l2) (fun e => Nat.noConfusion e)
/-- **Euler, part 1.** For `p ∤ a`: `a^h ≡ 1` or `a^h ≡ p - 1`. -/
theorem euler_pm (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a) :
rem (h + h + 1) (a ^ h) = 1 ∨ rem (h + h + 1) (a ^ h) = (h + h + 1) - 1 := by
have e : rem (h + h + 1) (a ^ h * a ^ h) = 1 := by
rw [← pow_add']; exact fermat1 h a hp ha
exact sq_one (h + h) hp (hh_pos h hp) _ e
/-- A square (of a unit) satisfies `a^h ≡ 1`. -/
theorem euler_of_sq (h a x : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(hx : rem (h + h + 1) (x * x) = rem (h + h + 1) a) : rem (h + h + 1) (a ^ h) = 1 := by
have hnx : ¬ Dv (h + h + 1) x := fun hd =>
ha (dv_of_rem_zero _ _ (hx.symm.trans (rem_zero_of_dv _ _ (dv_mul_right _ _ x hd))))
rw [← rem_pow_congr (h + h) _ _ hx h, sq_pow]
exact fermat1 h x hp hnx
def tailL : Nat → Nat → List Nat
| 0, c => [c]
| n + 1, c => 0 :: tailL n c
theorem tailL_length (c : Nat) : ∀ n : Nat, (tailL n c).length = n + 1
| 0 => rfl
| n + 1 => congrArg Nat.succ (tailL_length c n)
theorem ev_tailL (x c : Nat) : ∀ n : Nat, ev x (tailL n c) = c
| 0 => Nat.mul_one c
| n + 1 => by
show 0 * x ^ (tailL n c).length + ev x (tailL n c) = c
rw [nzero_mul, nzero_add, ev_tailL x c n]
def sqL (m : Nat) : Nat → List Nat
| 0 => []
| n + 1 => rem m ((n + 1) * (n + 1)) :: sqL m n
theorem sqL_length (m : Nat) : ∀ n : Nat, (sqL m n).length = n
| 0 => rfl
| n + 1 => congrArg Nat.succ (sqL_length m n)
theorem sqL_mem (m v : Nat) : ∀ n : Nat, memL v (sqL m n) →
∃ y, 0 < y ∧ y ≤ n ∧ v = rem m (y * y)
| 0, hm => False.elim hm
| n + 1, Or.inl e => ⟨n + 1, Nat.zero_lt_succ n, Nat.le_refl _, e⟩
| n + 1, Or.inr hm =>
match sqL_mem m v n hm with
| ⟨y, h0, hy, e⟩ => ⟨y, h0, Nat.le_succ_of_le hy, e⟩
theorem sq_expand (y t : Nat) : (y + t) * (y + t) = y * y + t * (y + (y + t)) := by
rw [nleft_distrib (y + t) y t, nright_distrib y t y, nright_distrib y t t,
nleft_distrib t y (y + t), nleft_distrib t y t, nmul_comm y t, Nat.add_assoc (y * y)]
theorem lt_p_of_le_h (h z : Nat) (hz : z ≤ h) : z < h + h + 1 :=
Nat.lt_succ_of_le (Nat.le_trans hz (Nat.le_add_right h h))
/-- The squares of `1, ..., h` are distinct mod p. -/
theorem sq_distinct (h : Nat) (hp : Pr (h + h + 1)) (y z : Nat) (h0 : 0 < y) (hyz : y < z)
(hz : z ≤ h) : rem (h + h + 1) (y * y) ≠ rem (h + h + 1) (z * z) := fun he =>
match Nat.le.dest hyz with
| ⟨k, hk⟩ => by
have hz' : z = y + (k + 1) := hk.symm.trans (Nat.succ_add y k)
rw [hz', sq_expand] at he
have hd := dv_of_rem_add (h + h) _ _ he.symm
match euclid _ _ _ hp hd with
| Or.inl ht =>
have hkz : k + 1 ≤ z := Nat.le.intro (by rw [Nat.add_comm, ← hz'])
exact not_dv_of_lt _ (k + 1) (Nat.zero_lt_succ k)
(lt_p_of_le_h h _ (Nat.le_trans hkz hz)) ht
| Or.inr hs =>
have hs' : y + (y + (k + 1)) ≤ h + h :=
Nat.add_le_add (Nat.le_trans (Nat.le_of_lt hyz) hz) (by rw [← hz']; exact hz)
exact not_dv_of_lt _ _ (Nat.lt_of_lt_of_le h0 (Nat.le_add_right y _))
(Nat.lt_succ_of_le hs') hs
theorem sqL_nodup (h : Nat) (hp : Pr (h + h + 1)) : ∀ n : Nat, n ≤ h →
nodupL (sqL (h + h + 1) n)
| 0, _ => True.intro
| n + 1, hn =>
⟨fun hm =>
match sqL_mem _ _ n hm with
| ⟨y, h0, hy, e⟩ =>
sq_distinct h hp y (n + 1) h0 (Nat.lt_succ_of_le hy) hn e.symm,
sqL_nodup h hp n (Nat.le_trans (Nat.le_succ n) hn)⟩
/-- `X^h - 1`, written `X^h + (p - 1)`; its roots are the `v` with `v^h ≡ 1`. -/
theorem root_of_pow (h' v : Nat) (hv : rem (h' + 1 + (h' + 1) + 1) (v ^ (h' + 1)) = 1) :
rem (h' + 1 + (h' + 1) + 1) (ev v (1 :: tailL h' (h' + 1 + (h' + 1)))) = 0 := by
show rem _ (1 * v ^ (tailL h' (h' + 1 + (h' + 1))).length + ev v (tailL h' _)) = 0
rw [tailL_length, ev_tailL, Nat.one_mul]
have e1 := rem_add_congr (h' + 1 + (h' + 1)) _ 1 (h' + 1 + (h' + 1))
(hv.trans (rem_one _ (Nat.zero_lt_succ _)).symm)
rw [e1, Nat.add_comm 1]
exact rem_zero_of_dv _ _ (dv_refl _)
theorem sq_search (m a : Nat) : ∀ n : Nat,
(∃ y, rem m (y * y) = rem m a) ∨ (∀ y, y ≤ n → rem m (y * y) ≠ rem m a)
| 0 =>
match Nat.decEq (rem m (0 * 0)) (rem m a) with
| isTrue e => Or.inl ⟨0, e⟩
| isFalse ne => Or.inr (fun y hy => by
have y0 : y = 0 := Nat.le_antisymm hy (Nat.zero_le y)
rw [y0]; exact ne)
| n + 1 =>
match sq_search m a n with
| Or.inl ex => Or.inl ex
| Or.inr hall =>
match Nat.decEq (rem m ((n + 1) * (n + 1))) (rem m a) with
| isTrue e => Or.inl ⟨n + 1, e⟩
| isFalse ne => Or.inr (fun y hy =>
match Nat.eq_or_lt_of_le hy with
| Or.inl e => by rw [e]; exact ne
| Or.inr l => hall y (Nat.le_of_lt_succ l))
/-- **Euler, part 2.** For `p ∤ a`: `a^h ≡ 1` exactly when `a` is a square mod p. -/
theorem euler_iff (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a) :
rem (h + h + 1) (a ^ h) = 1 ↔ ∃ x, rem (h + h + 1) (x * x) = rem (h + h + 1) a := by
constructor
· intro hah
match sq_search (h + h + 1) a h with
| Or.inl ex => exact ex
| Or.inr hall =>
exfalso
match h, hp, ha, hah, hall with
| 0, hp, _, _, _ => exact Nat.lt_irrefl 0 (h_pos 0 hp)
| h' + 1, hp, ha, hah, hall =>
have hnm : ¬ memL (rem (h' + 1 + (h' + 1) + 1) a) (sqL (h' + 1 + (h' + 1) + 1) (h' + 1)) :=
fun hm =>
match sqL_mem _ _ _ hm with
| ⟨y, _, hy, e⟩ => hall y hy e.symm
have hroots : allL (fun x => x < h' + 1 + (h' + 1) + 1 ∧
rem (h' + 1 + (h' + 1) + 1) (ev x (1 :: tailL h' (h' + 1 + (h' + 1)))) = 0)
(rem (h' + 1 + (h' + 1) + 1) a :: sqL (h' + 1 + (h' + 1) + 1) (h' + 1)) := by
refine ⟨⟨rem_lt' _ a, root_of_pow h' _ ?_⟩, ?_⟩
· rw [rem_pow_congr _ _ _ (rem_idem _ a)]; exact hah
· have gen : ∀ n, n ≤ h' + 1 → allL (fun x => x < h' + 1 + (h' + 1) + 1 ∧
rem (h' + 1 + (h' + 1) + 1) (ev x (1 :: tailL h' (h' + 1 + (h' + 1)))) = 0)
(sqL (h' + 1 + (h' + 1) + 1) n) := by
intro n
induction n with
| zero => intro _; exact True.intro
| succ n ih =>
intro hn
refine ⟨⟨rem_lt' _ _, root_of_pow h' _ ?_⟩, ih (Nat.le_trans (Nat.le_succ n) hn)⟩
rw [rem_pow_congr _ _ _ (rem_idem _ _), sq_pow]
apply fermat1 (h' + 1) (n + 1) hp
exact not_dv_of_lt _ _ (Nat.zero_lt_succ n) (lt_p_of_le_h _ _ hn)
exact gen (h' + 1) (Nat.le_refl _)
have hle := roots_le (h' + 1 + (h' + 1)) hp 1 (tailL h' (h' + 1 + (h' + 1)))
(rem (h' + 1 + (h' + 1) + 1) a :: sqL (h' + 1 + (h' + 1) + 1) (h' + 1)) (dv_one_absurd _)
⟨hnm, sqL_nodup (h' + 1) hp (h' + 1) (Nat.le_refl _)⟩ hroots
rw [tailL_length] at hle
show False
have hle' : h' + 1 + 1 ≤ h' + 1 := by
have l := hle; revert l
show (sqL _ (h' + 1)).length + 1 ≤ h' + 1 → h' + 1 + 1 ≤ h' + 1
rw [sqL_length]; exact id
exact Nat.not_succ_le_self _ hle'
· intro ⟨x, hx⟩
exact euler_of_sq h a x hp ha hx
/-! ## A list of distinct numbers in 1..n of length n: product n!, sum 1+...+n -/
def prodL : List Nat → Nat
| [] => 1
| x :: xs => x * prodL xs
def sumL : List Nat → Nat
| [] => 0
| x :: xs => x + sumL xs
def eraseL (w : Nat) : List Nat → List Nat
| [] => []
| x :: xs => if x = w then xs else x :: eraseL w xs
theorem memL_dec (v : Nat) : ∀ L : List Nat, memL v L ∨ ¬ memL v L
| [] => Or.inr id
| x :: xs =>
match Nat.decEq v x with
| isTrue e => Or.inl (Or.inl e)
| isFalse ne =>
match memL_dec v xs with
| Or.inl h => Or.inl (Or.inr h)
| Or.inr h => Or.inr (fun hm =>
match hm with
| Or.inl e => ne e
| Or.inr h' => h h')
theorem eraseL_eq (w x : Nat) (xs : List Nat) (e : x = w) : eraseL w (x :: xs) = xs :=
ite_eq_left e
theorem eraseL_ne (w x : Nat) (xs : List Nat) (ne : ¬ x = w) :
eraseL w (x :: xs) = x :: eraseL w xs :=
ite_eq_right ne
theorem erase_mem (w v : Nat) : ∀ L : List Nat, memL v (eraseL w L) → memL v L
| [], h => h
| x :: xs, h =>
match Nat.decEq x w with
| isTrue e => by rw [eraseL_eq w x xs e] at h; exact Or.inr h
| isFalse ne => by
rw [eraseL_ne w x xs ne] at h
match h with
| Or.inl e => exact Or.inl e
| Or.inr h' => exact Or.inr (erase_mem w v xs h')
theorem erase_ne (w v : Nat) : ∀ L : List Nat, nodupL L → memL v (eraseL w L) → v ≠ w
| [], _, h => False.elim h
| x :: xs, ⟨hnm, hnd⟩, h =>
match Nat.decEq x w with
| isTrue e => by
rw [eraseL_eq w x xs e] at h
intro hv
rw [hv, ← e] at h
exact hnm h
| isFalse ne => by
rw [eraseL_ne w x xs ne] at h
match h with
| Or.inl e => rw [e]; exact ne
| Or.inr h' => exact erase_ne w v xs hnd h'
theorem erase_nodup (w : Nat) : ∀ L : List Nat, nodupL L → nodupL (eraseL w L)
| [], _ => True.intro
| x :: xs, ⟨hnm, hnd⟩ =>
match Nat.decEq x w with
| isTrue e => by rw [eraseL_eq w x xs e]; exact hnd
| isFalse ne => by
rw [eraseL_ne w x xs ne]
exact ⟨fun hm => hnm (erase_mem w x xs hm), erase_nodup w xs hnd⟩
theorem erase_count (w : Nat) : ∀ L : List Nat, memL w L →
(eraseL w L).length + 1 = L.length ∧ prodL L = w * prodL (eraseL w L) ∧
sumL L = w + sumL (eraseL w L)
| [], h => False.elim h
| x :: xs, hm =>
match Nat.decEq x w with
| isTrue e => by
rw [eraseL_eq w x xs e]
exact ⟨rfl, by rw [← e]; rfl, by rw [← e]; rfl⟩
| isFalse ne => by
rw [eraseL_ne w x xs ne]
match hm with
| Or.inl e => exact absurd e.symm ne
| Or.inr h' =>
have ⟨h1, h2, h3⟩ := erase_count w xs h'
refine ⟨congrArg Nat.succ h1, ?_, ?_⟩
· show x * prodL xs = w * (x * prodL (eraseL w xs))
rw [h2]; exact mul_left_comm' _ _ _
· show x + sumL xs = w + (x + sumL (eraseL w xs))
rw [h3]; exact Nat.add_left_comm _ _ _
theorem erase_not_mem (w : Nat) : ∀ L : List Nat, ¬ memL w L → eraseL w L = L
| [], _ => rfl
| x :: xs, hn =>
match Nat.decEq x w with
| isTrue e => absurd (Or.inl e.symm) hn
| isFalse ne => by
rw [eraseL_ne w x xs ne, erase_not_mem w xs (fun h => hn (Or.inr h))]
theorem perm_count : ∀ (n : Nat) (L : List Nat), nodupL L →
(∀ v, memL v L → 0 < v ∧ v ≤ n) →
L.length ≤ n ∧
(L.length = n → prodL L = prod1 n (fun k => k) ∧ sumL L = sum1 n (fun k => k))
| 0, [], _, _ => ⟨Nat.le_refl 0, fun _ => ⟨rfl, rfl⟩⟩
| 0, x :: _, _, hb =>
match hb x (Or.inl rfl) with
| ⟨h0, hx⟩ => absurd (Nat.lt_of_lt_of_le h0 hx) (Nat.lt_irrefl 0)
| n + 1, L, hnd, hb => by
have hb' : ∀ v, memL v (eraseL (n + 1) L) → 0 < v ∧ v ≤ n := fun v hv =>
match hb v (erase_mem _ _ L hv) with
| ⟨h0, hle⟩ =>
⟨h0, Nat.le_of_lt_succ (lt_of_le_of_ne' v (n + 1) hle (erase_ne (n + 1) v L hnd hv))⟩
have ih := perm_count n (eraseL (n + 1) L) (erase_nodup (n + 1) L hnd) hb'
match memL_dec (n + 1) L with
| Or.inl hm =>
have ⟨hlen, hprod, hsum⟩ := erase_count (n + 1) L hm
refine ⟨?_, fun hl => ?_⟩
· rw [← hlen]; exact Nat.succ_le_succ ih.1
· have hl' : (eraseL (n + 1) L).length = n := succ_inj' (hlen.trans hl)
have ⟨p1, s1⟩ := ih.2 hl'
refine ⟨?_, ?_⟩
· rw [hprod, p1]; exact nmul_comm _ _
· rw [hsum, s1]; exact Nat.add_comm _ _
| Or.inr hn =>
rw [erase_not_mem (n + 1) L hn] at ih
refine ⟨Nat.le_succ_of_le ih.1, fun hl => ?_⟩
have h1 := ih.1
rw [hl] at h1
exact absurd h1 (Nat.not_succ_le_self n)
def mkL (f : Nat → Nat) : Nat → List Nat
| 0 => []
| n + 1 => f (n + 1) :: mkL f n
theorem mkL_length (f : Nat → Nat) : ∀ n : Nat, (mkL f n).length = n
| 0 => rfl
| n + 1 => congrArg Nat.succ (mkL_length f n)
theorem prodL_mkL (f : Nat → Nat) : ∀ n : Nat, prodL (mkL f n) = prod1 n f
| 0 => rfl
| n + 1 => by
show f (n + 1) * prodL (mkL f n) = prod1 n f * f (n + 1)
rw [prodL_mkL f n]; exact nmul_comm _ _
theorem sumL_mkL (f : Nat → Nat) : ∀ n : Nat, sumL (mkL f n) = sum1 n f
| 0 => rfl
| n + 1 => by
show f (n + 1) + sumL (mkL f n) = sum1 n f + f (n + 1)
rw [sumL_mkL f n]; exact Nat.add_comm _ _
theorem mkL_mem (f : Nat → Nat) (v : Nat) : ∀ n : Nat, memL v (mkL f n) →
∃ k, 0 < k ∧ k ≤ n ∧ v = f k
| 0, h => False.elim h
| n + 1, Or.inl e => ⟨n + 1, Nat.zero_lt_succ n, Nat.le_refl _, e⟩
| n + 1, Or.inr h =>
match mkL_mem f v n h with
| ⟨k, h0, hk, e⟩ => ⟨k, h0, Nat.le_succ_of_le hk, e⟩
theorem mkL_nodup (f : Nat → Nat) : ∀ n : Nat,
(∀ i j, 0 < i → i < j → j ≤ n → f i ≠ f j) → nodupL (mkL f n)
| 0, _ => True.intro
| n + 1, hinj =>
⟨fun hm =>
match mkL_mem f _ n hm with
| ⟨k, h0, hk, e⟩ => hinj k (n + 1) h0 (Nat.lt_succ_of_le hk) (Nat.le_refl _) e.symm,
mkL_nodup f n (fun i j h0 hij hj => hinj i j h0 hij (Nat.le_succ_of_le hj))⟩
/-- A map of `1..n` into `1..n` without repeats has the same product and sum
as the identity. -/
theorem perm_fun (f : Nat → Nat) (n : Nat) (hb : ∀ k, 0 < k → k ≤ n → 0 < f k ∧ f k ≤ n)
(hinj : ∀ i j, 0 < i → i < j → j ≤ n → f i ≠ f j) :
prod1 n f = prod1 n (fun k => k) ∧ sum1 n f = sum1 n (fun k => k) := by
have hpc := perm_count n (mkL f n) (mkL_nodup f n hinj)
(fun v hv => match mkL_mem f v n hv with
| ⟨k, h0, hk, e⟩ => by rw [e]; exact hb k h0 hk)
have ⟨p1, s1⟩ := hpc.2 (mkL_length f n)
rw [prodL_mkL] at p1
rw [sumL_mkL] at s1
exact ⟨p1, s1⟩
/-! ## Floor division -/
/-- Quotient and remainder by `m' + 1`, counting up from 0. -/
def dm (m' : Nat) : Nat → Nat × Nat
| 0 => (0, 0)
| n + 1 =>
if (dm m' n).2 = m' then ((dm m' n).1 + 1, 0) else ((dm m' n).1, (dm m' n).2 + 1)
/-- `fl m' n = ⌊n / (m' + 1)⌋`. -/
def fl (m' n : Nat) : Nat := (dm m' n).1
theorem dm_spec (m' : Nat) : ∀ n : Nat,
n = (dm m' n).1 * (m' + 1) + (dm m' n).2 ∧ (dm m' n).2 ≤ m'
| 0 => ⟨by show 0 = 0 * (m' + 1) + 0; rw [nzero_mul], Nat.zero_le _⟩
| n + 1 => by
have ⟨ih1, ih2⟩ := dm_spec m' n
match Nat.decEq (dm m' n).2 m' with
| isTrue e =>
have hd : dm m' (n + 1) = ((dm m' n).1 + 1, 0) := ite_eq_left e
rw [hd]
refine ⟨?_, Nat.zero_le _⟩
show n + 1 = ((dm m' n).1 + 1) * (m' + 1) + 0
rw [nsucc_mul]
exact congrArg Nat.succ (ih1.trans (congrArg (fun t => (dm m' n).1 * (m' + 1) + t) e))
| isFalse ne =>
have hd : dm m' (n + 1) = ((dm m' n).1, (dm m' n).2 + 1) := ite_eq_right ne
rw [hd]
exact ⟨congrArg Nat.succ ih1, lt_of_le_of_ne' _ _ ih2 ne⟩
theorem fl_spec (m' n : Nat) : n = fl m' n * (m' + 1) + rem (m' + 1) n := by
have ⟨h1, h2⟩ := dm_spec m' n
have ⟨k, hk⟩ := Nat.le.dest h2
have hr : rem (m' + 1) n = (dm m' n).2 := by
have hk' : (dm m' n).2 + (k + 1) = m' + 1 := congrArg Nat.succ hk
rw [h1]
rw [rem_div m' _ _ k hk']
rw [← h1]
rw [hr]
exact h1
theorem fl_values : fl 6 23 = 3 ∧ fl 4 17 = 3 ∧ fl 2 2 = 0 := ⟨rfl, rfl, rfl⟩
/-! ## Gauss's lemma. p = h + h + 1, p ∤ a. -/
/-- `a k` reduced mod p. -/
def rk (h a k : Nat) : Nat := rem (h + h + 1) (a * k)
/-- the reduced value folded into `1..h`. -/
def sk (h a k : Nat) : Nat := if rk h a k ≤ h then rk h a k else (h + h + 1) - rk h a k
/-- 1 when `a k` reduces above `p/2`, else 0. -/
def lk (h a k : Nat) : Nat := if rk h a k ≤ h then 0 else 1
/-- μ: how many of `a, 2a, ..., h a` reduce above `p/2`. -/
def mu (h a : Nat) : Nat := sum1 h (lk h a)
theorem rk_cases (h a k : Nat) :
(rk h a k ≤ h ∧ sk h a k = rk h a k ∧ lk h a k = 0) ∨
(h < rk h a k ∧ rk h a k + sk h a k = h + h + 1 ∧ lk h a k = 1) :=
match Nat.lt_or_ge h (rk h a k) with
| Or.inl hl =>
have hn : ¬ rk h a k ≤ h := Nat.not_le_of_gt hl
Or.inr ⟨hl,
by
show rk h a k + (if rk h a k ≤ h then rk h a k else (h + h + 1) - rk h a k) = _
rw [ite_eq_right hn]
exact add_sub_of_le' _ _ (Nat.le_of_lt (rem_lt' (h + h) (a * k))),
ite_eq_right hn⟩
| Or.inr hg => Or.inl ⟨hg, ite_eq_left hg, ite_eq_left hg⟩
theorem rk_pos (h a k : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(h0 : 0 < k) (hk : k ≤ h) : 0 < rk h a k := by
apply Nat.pos_of_ne_zero
intro e
match euclid _ _ _ hp (dv_of_rem_zero (h + h) _ e) with
| Or.inl hd => exact ha hd
| Or.inr hd => exact not_dv_of_lt _ _ h0 (lt_p_of_le_h h k hk) hd
theorem sk_bounds (h a k : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(h0 : 0 < k) (hk : k ≤ h) : 0 < sk h a k ∧ sk h a k ≤ h :=
match rk_cases h a k with
| Or.inl ⟨hle, hs, _⟩ => by rw [hs]; exact ⟨rk_pos h a k hp ha h0 hk, hle⟩
| Or.inr ⟨hl, hsum, _⟩ => by
constructor
· apply Nat.pos_of_ne_zero
intro e
rw [e] at hsum
exact Nat.lt_irrefl _ (Nat.lt_of_lt_of_le (rem_lt' (h + h) (a * k)) (Nat.le_of_eq hsum.symm))
· apply le_of_add_le_add_left' (h + 1)
rw [← Nat.add_right_comm h h 1, ← hsum]
exact Nat.add_le_add_right hl _
theorem rk_sign (h a k : Nat) :
rem (h + h + 1) (a * k) = rem (h + h + 1) ((h + h) ^ lk h a k * sk h a k) :=
match rk_cases h a k with
| Or.inl ⟨_, hs, hl⟩ => by
rw [hl, hs, Nat.pow_zero, Nat.one_mul]
exact (rem_idem (h + h) (a * k)).symm
| Or.inr ⟨_, hsum, hl⟩ => by
rw [hl, show (h + h) ^ 1 = h + h from Nat.one_mul (h + h)]
apply Eq.trans (rem_idem (h + h) (a * k)).symm
apply rem_cancel_add (h + h) _ _ (sk h a k)
show rem (h + h + 1) (rk h a k + sk h a k) = _
rw [hsum, ← nsucc_mul, nmul_comm]
rw [rem_zero_of_dv _ _ (dv_refl _), rem_zero_of_dv _ _ ⟨sk h a k, rfl⟩]
theorem rk_no_eq (h a i j : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(hi : i < j) (hj : j ≤ h) (e : rk h a i = rk h a j) : False := by
have e2 := rem_cancel_mul (h + h) a i j hp ha e
rw [rem_of_lt _ _ (lt_p_of_le_h h i (Nat.le_trans (Nat.le_of_lt hi) hj)),
rem_of_lt _ _ (lt_p_of_le_h h j hj)] at e2
rw [e2] at hi
exact Nat.lt_irrefl j hi
theorem rk_no_sum (h a i j : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(h0 : 0 < i) (hi : i ≤ h) (hj : j ≤ h) (e : rk h a i + rk h a j = h + h + 1) : False := by
have e2 : rem (h + h + 1) (a * i + a * j) = 0 := by
rw [rem_add_congr2 (h + h) _ (rk h a i) _ (rk h a j) (rem_idem _ _).symm (rem_idem _ _).symm,
e]
exact rem_zero_of_dv _ _ (dv_refl _)
rw [← nleft_distrib] at e2
match euclid _ _ _ hp (dv_of_rem_zero _ _ e2) with
| Or.inl hd => exact ha hd
| Or.inr hd =>
exact not_dv_of_lt _ _ (Nat.lt_of_lt_of_le h0 (Nat.le_add_right i j))
(Nat.lt_succ_of_le (Nat.add_le_add hi hj)) hd
theorem sk_inj (h a i j : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(h0 : 0 < i) (hij : i < j) (hj : j ≤ h) : sk h a i ≠ sk h a j := fun e =>
have hi : i ≤ h := Nat.le_trans (Nat.le_of_lt hij) hj
have h0j : 0 < j := Nat.lt_trans h0 hij
match rk_cases h a i, rk_cases h a j with
| Or.inl ⟨_, hsi, _⟩, Or.inl ⟨_, hsj, _⟩ =>
rk_no_eq h a i j hp ha hij hj (hsi.symm.trans (e.trans hsj))
| Or.inr ⟨_, hsi, _⟩, Or.inr ⟨_, hsj, _⟩ =>
rk_no_eq h a i j hp ha hij hj
(add_right_cancel' (sk h a i) _ _ (hsi.trans (by rw [e]; exact hsj.symm)))
| Or.inl ⟨_, hsi, _⟩, Or.inr ⟨_, hsj, _⟩ =>
rk_no_sum h a j i hp ha h0j hj hi
(by rw [← hsi, e]; exact hsj)
| Or.inr ⟨_, hsi, _⟩, Or.inl ⟨_, hsj, _⟩ =>
rk_no_sum h a i j hp ha h0 hi hj
(by rw [← hsj, ← e]; exact hsi)
theorem neg_sq (m'' : Nat) : rem (m'' + 1 + 1) ((m'' + 1) * (m'' + 1)) = 1 := by
have e : (m'' + 1) * (m'' + 1) = m'' * (m'' + 1 + 1) + 1 := by rw [nsucc_mul]; rfl
rw [e, rem_add_mul (m'' + 1) 1 m'']
exact rem_one (m'' + 1) (Nat.zero_lt_succ m'')
theorem neg_sq' (h : Nat) (hp : Pr (h + h + 1)) : rem (h + h + 1) ((h + h) * (h + h)) = 1 :=
match h, hp with
| 0, hp => absurd (h_pos 0 hp) (Nat.lt_irrefl 0)
| h' + 1, _ => neg_sq (h' + 1 + h')
theorem neg_pow_even (h n : Nat) (hp : Pr (h + h + 1)) : rem (h + h + 1) ((h + h) ^ (n + n)) = 1 := by
rw [← sq_pow, rem_pow_congr (h + h) _ 1 (by rw [neg_sq' h hp]; exact (rem_one _ (hh_pos h hp)).symm),
Nat.one_pow]
exact rem_one _ (hh_pos h hp)
theorem neg_pow_odd (h n : Nat) (hp : Pr (h + h + 1)) :
rem (h + h + 1) ((h + h) ^ (n + n + 1)) = h + h := by
show rem (h + h + 1) ((h + h) ^ (n + n) * (h + h)) = h + h
rw [rem_mul_congr (h + h) _ 1 _ (by rw [neg_pow_even h n hp]; exact (rem_one _ (hh_pos h hp)).symm),
Nat.one_mul]
exact rem_of_lt _ _ (Nat.lt_succ_self _)
/-- `a^h ≡ (-1)^μ`, with `-1` written `p - 1 = h + h`. -/
theorem gauss_pow (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a) :
rem (h + h + 1) (a ^ h) = rem (h + h + 1) ((h + h) ^ mu h a) := by
have hperm := perm_fun (sk h a) h (fun k h0 hk => sk_bounds h a k hp ha h0 hk)
(fun i j h0 hij hj => sk_inj h a i j hp ha h0 hij hj)
have hprod : rem (h + h + 1) (prod1 h (fun k => a * k))
= rem (h + h + 1) ((h + h) ^ mu h a * prod1 h (fun k => k)) := by
rw [rem_prod1_congr (h + h) _ (fun k => (h + h) ^ lk h a k * sk h a k) h
(fun k _ _ => rk_sign h a k)]
rw [prod1_mul h (fun k => (h + h) ^ lk h a k) (sk h a), prod1_pow, hperm.1]
rfl
have hl : prod1 h (fun k => a * k) = a ^ h * prod1 h (fun k => k) := by
rw [prod1_mul h (fun _ => a) (fun k => k), prod1_const]
rw [hl, nmul_comm (a ^ h), nmul_comm ((h + h) ^ mu h a)] at hprod
exact rem_cancel_mul (h + h) _ _ _ hp
(not_dv_prod1 _ hp _ h (fun k h0 hk => not_dv_of_lt _ _ h0 (lt_p_of_le_h h k hk))) hprod
theorem par_one_ne (h : Nat) (e : h + h = 1) : False := by
have e2 := congrArg par e
rw [par_double] at e2
exact Bool.noConfusion e2
/-- **Gauss's lemma.** For `p ∤ a`: `a` is a square mod p exactly when μ is even,
i.e. `(a|p) = (-1)^μ`. -/
theorem gauss_lemma (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a) :
(∃ x, rem (h + h + 1) (x * x) = rem (h + h + 1) a) ↔ par (mu h a) = false := by
have key : rem (h + h + 1) (a ^ h) = 1 ↔ par (mu h a) = false := by
rw [gauss_pow h a hp ha]
have hs := par_split (mu h a)
constructor
· intro e
revert hs
cases par (mu h a) with
| false => intro _; rfl
| true =>
intro hs
have ⟨n, hn⟩ := hs.2 rfl
rw [hn, neg_pow_odd h n hp] at e
exact False.elim (par_one_ne h e)
· intro hf
have ⟨n, hn⟩ := hs.1 hf
rw [hn]
exact neg_pow_even h n hp
exact (euler_iff h a hp ha).symm.trans key
/-! ## Eisenstein: μ has the parity of Σ ⌊a k / p⌋ (a odd) -/
theorem bx_solve (x y z : Bool) (h : y = bx x (bx y z)) : x = z := by
cases x <;> cases y <;> cases z <;> first | rfl | exact Bool.noConfusion h
theorem par_p (h : Nat) : par (h + h + 1) = true := by
rw [par_add, par_double]; rfl
theorem eisenstein_par (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(hodd : par a = true) :
par (sum1 h (fun k => fl (h + h) (a * k))) = par (mu h a) := by
have hperm := perm_fun (sk h a) h (fun k h0 hk => sk_bounds h a k hp ha h0 hk)
(fun i j h0 hij hj => sk_inj h a i j hp ha h0 hij hj)
-- a S = p F + R
have h1 : a * sum1 h (fun k => k)
= (h + h + 1) * sum1 h (fun k => fl (h + h) (a * k)) + sum1 h (rk h a) := by
rw [sum1_mul_left, sum1_mul_left, ← sum1_add]
apply sum1_ext
intro k _ _
show a * k = (h + h + 1) * fl (h + h) (a * k) + rem (h + h + 1) (a * k)
rw [nmul_comm (h + h + 1)]
exact fl_spec (h + h) (a * k)
-- R + 2X = S + p μ
have h2 : sum1 h (rk h a) + (sum1 h (fun k => lk h a k * sk h a k)
+ sum1 h (fun k => lk h a k * sk h a k))
= sum1 h (fun k => k) + (h + h + 1) * mu h a := by
rw [← sum1_add, ← sum1_add, ← hperm.2]
show _ = sum1 h (sk h a) + (h + h + 1) * sum1 h (lk h a)
rw [sum1_mul_left, ← sum1_add]
apply sum1_ext
intro k _ _
show rk h a k + (lk h a k * sk h a k + lk h a k * sk h a k)
= sk h a k + (h + h + 1) * lk h a k
match rk_cases h a k with
| Or.inl ⟨_, hs, hl⟩ =>
rw [hl, hs, nzero_mul, Nat.mul_zero]
| Or.inr ⟨_, hsum, hl⟩ =>
rw [hl, Nat.one_mul, Nat.mul_one, ← Nat.add_assoc, hsum]
exact Nat.add_comm _ _
have p1 := congrArg par h1
have p2 := congrArg par h2
rw [par_mul, hodd, par_add, par_mul, par_p] at p1
rw [par_add, par_double, bx_false, par_add, par_mul, par_p] at p2
rw [p2] at p1
exact bx_solve _ _ _ p1
/-- Gauss and Eisenstein together: for odd `a` with `p ∤ a`,
`a` is a square mod p exactly when `Σ_{k=1}^{h} ⌊a k / p⌋` is even. -/
theorem qr_by_floor (h a : Nat) (hp : Pr (h + h + 1)) (ha : ¬ Dv (h + h + 1) a)
(hodd : par a = true) :
(∃ x, rem (h + h + 1) (x * x) = rem (h + h + 1) a) ↔
par (sum1 h (fun k => fl (h + h) (a * k))) = false := by
rw [eisenstein_par h a hp ha hodd]
exact gauss_lemma h a hp ha
/-! ## Eisenstein's lattice count -/
/-- `[a < b]` as 0 or 1. -/
def ltI (a b : Nat) : Nat := if a < b then 1 else 0
theorem ltI_one (a b : Nat) (h : a < b) : ltI a b = 1 := ite_eq_left h
theorem ltI_zero (a b : Nat) (h : b ≤ a) : ltI a b = 0 := ite_eq_right (Nat.not_lt_of_le h)
theorem ltI_add (a b : Nat) (hne : a ≠ b) : ltI a b + ltI b a = 1 :=
match Nat.lt_or_ge a b with
| Or.inl hl => by rw [ltI_one a b hl, ltI_zero b a (Nat.le_of_lt hl)]
| Or.inr hg => by
rw [ltI_zero a b hg, ltI_one b a (lt_of_le_of_ne' b a hg (fun e => hne e.symm))]
theorem count_low (m' N Q r : Nat) (hN : N = Q * (m' + 1) + r) (hr : 0 < r) :
∀ Y : Nat, Y ≤ Q → sum1 Y (fun y => ltI ((m' + 1) * y) N) = Y
| 0, _ => rfl
| Y + 1, hY => by
show sum1 Y (fun y => ltI ((m' + 1) * y) N) + ltI ((m' + 1) * (Y + 1)) N = Y + 1
rw [count_low m' N Q r hN hr Y (Nat.le_of_succ_le hY), ltI_one]
rw [hN, nmul_comm (m' + 1) (Y + 1)]
exact Nat.lt_of_le_of_lt (Nat.mul_le_mul_right (m' + 1) hY) (Nat.lt_add_of_pos_right hr)
theorem count_high (m' N Q r : Nat) (hN : N = Q * (m' + 1) + r) (hr0 : 0 < r)
(hr : r < m' + 1) : ∀ j : Nat, sum1 (Q + j) (fun y => ltI ((m' + 1) * y) N) = Q
| 0 => count_low m' N Q r hN hr0 Q (Nat.le_refl Q)
| j + 1 => by
show sum1 (Q + j) (fun y => ltI ((m' + 1) * y) N) + ltI ((m' + 1) * (Q + j + 1)) N = Q
rw [count_high m' N Q r hN hr0 hr j, ltI_zero]
· rfl
rw [hN, nmul_comm (m' + 1) (Q + j + 1)]
apply Nat.le_trans (Nat.add_le_add_left (Nat.le_of_lt hr) _)
rw [← nsucc_mul]
exact Nat.mul_le_mul_right _ (Nat.succ_le_succ (Nat.le_add_right Q j))
/-- `⌊N/m⌋` counts the `y` in `1..Y` with `m y < N`, once `⌊N/m⌋ ≤ Y` and `m ∤ N`. -/
theorem fl_count (m' N Y : Nat) (hr0 : rem (m' + 1) N ≠ 0) (hY : fl m' N ≤ Y) :
sum1 Y (fun y => ltI ((m' + 1) * y) N) = fl m' N :=
match Nat.le.dest hY with
| ⟨j, hj⟩ => by
rw [← hj]
exact count_high m' N (fl m' N) (rem (m' + 1) N) (fl_spec m' N)
(Nat.pos_of_ne_zero hr0) (rem_lt' m' N) j
theorem double_inj (h g : Nat) (e : h + h = g + g) : h = g :=
match Nat.lt_trichotomy h g with
| Or.inl hl => absurd (Nat.lt_of_lt_of_le (Nat.add_lt_add hl hl) (Nat.le_of_eq e.symm))
(Nat.lt_irrefl _)
| Or.inr (Or.inl he) => he
| Or.inr (Or.inr hl) => absurd (Nat.lt_of_lt_of_le (Nat.add_lt_add hl hl) (Nat.le_of_eq e))
(Nat.lt_irrefl _)
theorem not_dv_qx (h g x : Nat) (hp : Pr (h + h + 1)) (hq : Pr (g + g + 1)) (hne : h ≠ g)
(h0 : 0 < x) (hx : x ≤ h) : ¬ Dv (h + h + 1) ((g + g + 1) * x) := fun hd =>
match euclid _ _ _ hp hd with
| Or.inr hdx => not_dv_of_lt _ _ h0 (lt_p_of_le_h h x hx) hdx
| Or.inl hdq =>
match hq.2 _ hdq with
| Or.inl e1 => by
have e2 : h + h = 0 := succ_inj' e1
have l := hh_pos h hp
rw [e2] at l
exact Nat.lt_irrefl 0 l
| Or.inr e2 => hne (double_inj h g (succ_inj' e2))
theorem fl_le (h g x : Nat) (hx : x ≤ h) : fl (h + h) ((g + g + 1) * x) ≤ g :=
match Nat.lt_or_ge g (fl (h + h) ((g + g + 1) * x)) with
| Or.inr hge => hge
| Or.inl hlt => by
have e := fl_spec (h + h) ((g + g + 1) * x)
have i1 : g + (h + h + 1) = h + (h + g + 1) :=
congrArg Nat.succ ((Nat.add_comm g (h + h)).trans (Nat.add_assoc h h g))
have i2 : (g + 1) * (h + h + 1) = (g + g + 1) * h + (h + g + 1) := by
rw [nsucc_mul g, nsucc_mul (g + g) h, nright_distrib g g h]
show g * (h + h) + g + (h + h + 1) = g * h + g * h + h + (h + g + 1)
rw [nleft_distrib g h h, Nat.add_assoc (g * h + g * h) g, Nat.add_assoc (g * h + g * h) h, i1]
have c1 : (g + 1) * (h + h + 1) ≤ (g + g + 1) * h :=
Nat.le_trans (Nat.mul_le_mul_right _ hlt)
(Nat.le_trans (Nat.le_add_right _ (rem (h + h + 1) ((g + g + 1) * x)))
(Nat.le_trans (Nat.le_of_eq e.symm) (Nat.mul_le_mul_left _ hx)))
rw [i2] at c1
exact absurd (Nat.lt_of_lt_of_le (Nat.lt_add_of_pos_right (Nat.zero_lt_succ _)) c1)
(Nat.lt_irrefl _)
theorem fl_as_count (h g x : Nat) (hp : Pr (h + h + 1)) (hq : Pr (g + g + 1)) (hne : h ≠ g)
(h0 : 0 < x) (hx : x ≤ h) :
fl (h + h) ((g + g + 1) * x) = sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x)) :=
(fl_count (h + h) _ g (fun e => not_dv_qx h g x hp hq hne h0 hx (dv_of_rem_zero _ _ e))
(fl_le h g x hx)).symm
/-- **Eisenstein's lattice count.**
`Σ_{k=1}^{h} ⌊k q/p⌋ + Σ_{k=1}^{g} ⌊k p/q⌋ = h g`. -/
theorem lattice (h g : Nat) (hp : Pr (h + h + 1)) (hq : Pr (g + g + 1)) (hne : h ≠ g) :
sum1 h (fun x => fl (h + h) ((g + g + 1) * x)) + sum1 g (fun y => fl (g + g) ((h + h + 1) * y))
= h * g :=
calc sum1 h (fun x => fl (h + h) ((g + g + 1) * x)) + sum1 g (fun y => fl (g + g) ((h + h + 1) * y))
= sum1 h (fun x => sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x)))
+ sum1 g (fun y => sum1 h (fun x => ltI ((g + g + 1) * x) ((h + h + 1) * y))) := by
rw [sum1_ext h _ _ (fun x h0 hx => fl_as_count h g x hp hq hne h0 hx),
sum1_ext g _ _ (fun y h0 hy => fl_as_count g h y hq hp (fun e => hne e.symm) h0 hy)]
_ = sum1 h (fun x => sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x)))
+ sum1 h (fun x => sum1 g (fun y => ltI ((g + g + 1) * x) ((h + h + 1) * y))) :=
congrArg (fun t => sum1 h (fun x => sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x))) + t)
(sum1_swap (fun x y => ltI ((g + g + 1) * x) ((h + h + 1) * y)) g h).symm
_ = sum1 h (fun x => sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x))
+ sum1 g (fun y => ltI ((g + g + 1) * x) ((h + h + 1) * y))) := (sum1_add h _ _).symm
_ = sum1 h (fun x => sum1 g (fun y => ltI ((h + h + 1) * y) ((g + g + 1) * x)
+ ltI ((g + g + 1) * x) ((h + h + 1) * y))) :=
sum1_ext h _ _ (fun x _ _ => (sum1_add g _ _).symm)
_ = sum1 h (fun _ => sum1 g (fun _ => 1)) :=
sum1_ext h _ _ (fun x h0 hx => sum1_ext g _ _ (fun y _ _ =>
ltI_add _ _ (fun e => not_dv_qx h g x hp hq hne h0 hx
⟨y, e.symm.trans (nmul_comm _ _)⟩)))
_ = h * g := by rw [sum1_const g 1, sum1_const h, Nat.mul_one]
/-! ## Quadratic reciprocity -/
theorem beq_refl' : ∀ n : Nat, Nat.beq n n = true
| 0 => rfl
| n + 1 => beq_refl' n
def sqS (m a : Nat) : Nat → Bool
| 0 => Nat.beq (rem m (0 * 0)) (rem m a)
| n + 1 => sqS m a n || Nat.beq (rem m ((n + 1) * (n + 1))) (rem m a)
/-- The Legendre symbol as a Boolean: `true` for +1 (a square mod m),
`false` for -1. -/
def legB (m a : Nat) : Bool := sqS m a m
theorem or_true_cases (b c : Bool) (h : (b || c) = true) : b = true ∨ c = true := by
cases b <;> cases c <;> first | exact Or.inl rfl | exact Or.inr rfl | exact Bool.noConfusion h
theorem or_true_right (b : Bool) : (b || true) = true := by cases b <;> rfl
theorem sqS_sound (m a : Nat) : ∀ n : Nat, sqS m a n = true → ∃ x, rem m (x * x) = rem m a
| 0, h => ⟨0, Nat.eq_of_beq_eq_true h⟩
| n + 1, h =>
match or_true_cases _ _ h with
| Or.inl h1 => sqS_sound m a n h1
| Or.inr h2 => ⟨n + 1, Nat.eq_of_beq_eq_true h2⟩
theorem sqS_complete (m a : Nat) : ∀ n x : Nat, x ≤ n → rem m (x * x) = rem m a →
sqS m a n = true
| 0, x, hx, e => by
have x0 : x = 0 := Nat.le_antisymm hx (Nat.zero_le x)
rw [x0] at e
show Nat.beq (rem m (0 * 0)) (rem m a) = true
rw [e]; exact beq_refl' _
| n + 1, x, hx, e =>
match Nat.eq_or_lt_of_le hx with
| Or.inl ex => by
show (sqS m a n || Nat.beq (rem m ((n + 1) * (n + 1))) (rem m a)) = true
rw [← ex, e, beq_refl']
exact or_true_right _
| Or.inr lx => by
show (sqS m a n || Nat.beq (rem m ((n + 1) * (n + 1))) (rem m a)) = true
rw [sqS_complete m a n x (Nat.le_of_lt_succ lx) e]
rfl
theorem legB_iff (m' a : Nat) :
legB (m' + 1) a = true ↔ ∃ x, rem (m' + 1) (x * x) = rem (m' + 1) a :=
⟨sqS_sound (m' + 1) a (m' + 1), fun ⟨x, e⟩ =>
sqS_complete (m' + 1) a (m' + 1) (rem (m' + 1) x) (Nat.le_of_lt (rem_lt' m' x))
((rem_mul_congr2 m' _ _ _ _ (rem_idem m' x) (rem_idem m' x)).trans e)⟩
theorem b_of_iff (x y : Bool) (h : x = true ↔ y = false) : x = !y := by
cases x <;> cases y
· exact absurd (h.mpr rfl) (fun e => Bool.noConfusion e)
· rfl
· rfl
· exact absurd (h.mp rfl) (fun e => Bool.noConfusion e)
/-- **Quadratic reciprocity.** For distinct odd primes `p = 2h+1`, `q = 2g+1`
(written `h + h + 1`, `g + g + 1`):
`(p|q)(q|p) = (-1)^(h g)`, with the product of signs read as
"different" (`bx` = exclusive or) and `(-1)^n` read as `par n`. -/
theorem qr_law (h g : Nat) (hp : Pr (h + h + 1)) (hq : Pr (g + g + 1)) (hne : h ≠ g) :
bx (legB (h + h + 1) (g + g + 1)) (legB (g + g + 1) (h + h + 1)) = par (h * g) := by
have nq : ¬ Dv (h + h + 1) (g + g + 1) := fun hd =>
not_dv_qx h g 1 hp hq hne Nat.zero_lt_one (h_pos h hp) (by rw [Nat.mul_one]; exact hd)
have np : ¬ Dv (g + g + 1) (h + h + 1) := fun hd =>
not_dv_qx g h 1 hq hp (fun e => hne e.symm) Nat.zero_lt_one (h_pos g hq)
(by rw [Nat.mul_one]; exact hd)
have hA := (legB_iff (h + h) (g + g + 1)).trans (qr_by_floor h (g + g + 1) hp nq (par_p g))
have hB := (legB_iff (g + g) (h + h + 1)).trans (qr_by_floor g (h + h + 1) hq np (par_p h))
rw [b_of_iff _ _ hA, b_of_iff _ _ hB, ← lattice h g hp hq hne, par_add]
cases par (sum1 h (fun k => fl (h + h) ((g + g + 1) * k))) <;>
cases par (sum1 g (fun k => fl (g + g) ((h + h + 1) * k))) <;> rfl
/-- The same, as a statement about squares: `q` is a square mod `p` exactly as
`p` is a square mod `q`, unless both `h` and `g` are odd. -/
theorem iff_bx (a b : Bool) : ((a = true ↔ b = true) ↔ bx a b = false) := by
cases a <;> cases b
· exact ⟨fun _ => rfl, fun _ => Iff.rfl⟩
· exact ⟨fun h => absurd (h.mpr rfl) (fun e => Bool.noConfusion e), fun e => Bool.noConfusion e⟩
· exact ⟨fun h => absurd (h.mp rfl) (fun e => Bool.noConfusion e), fun e => Bool.noConfusion e⟩
· exact ⟨fun _ => rfl, fun _ => Iff.rfl⟩
theorem qr_law_iff (h g : Nat) (hp : Pr (h + h + 1)) (hq : Pr (g + g + 1)) (hne : h ≠ g) :
((∃ x, rem (h + h + 1) (x * x) = rem (h + h + 1) (g + g + 1)) ↔
(∃ y, rem (g + g + 1) (y * y) = rem (g + g + 1) (h + h + 1))) ↔ par (h * g) = false := by
have e := iff_bx (legB (h + h + 1) (g + g + 1)) (legB (g + g + 1) (h + h + 1))
rw [qr_law h g hp hq hne] at e
have iA := legB_iff (h + h) (g + g + 1)
have iB := legB_iff (g + g) (h + h + 1)
exact ⟨fun hAB => e.mp ⟨fun a => iB.mpr (hAB.mp (iA.mp a)), fun b => iA.mpr (hAB.mpr (iB.mp b))⟩,
fun hf => ⟨fun a => iB.mp ((e.mpr hf).mp (iA.mpr a)), fun b => iA.mp ((e.mpr hf).mpr (iB.mpr b))⟩⟩
/-! ## Checks by computation -/
set_option maxRecDepth 100000 in
theorem leg_values : legB 7 2 = true ∧ legB 7 3 = false ∧ legB 11 5 = true ∧ legB 11 2 = false :=
⟨rfl, rfl, rfl, rfl⟩
set_option maxRecDepth 100000 in
theorem qr_example : bx (legB 7 11) (legB 11 7) = par (3 * 5) := rfl
end QRChain
#print axioms QRChain.add_left_cancel'
#print axioms QRChain.add_right_cancel'
#print axioms QRChain.le_of_add_le_add_left'
#print axioms QRChain.lt_of_add_lt_add_left'
#print axioms QRChain.add_sub_of_le'
#print axioms QRChain.lt_irrefl_of_le
#print axioms QRChain.eq_zero_of_add_eq_self
#print axioms QRChain.lt_of_le_of_ne'
#print axioms QRChain.par_add
#print axioms QRChain.par_mul
#print axioms QRChain.par_double
#print axioms QRChain.par_split
#print axioms QRChain.bx_self
#print axioms QRChain.bx_false
#print axioms QRChain.bx_comm
#print axioms QRChain.bx_assoc
#print axioms QRChain.sum1_ext
#print axioms QRChain.prod1_ext
#print axioms QRChain.sum1_add
#print axioms QRChain.sum1_mul_left
#print axioms QRChain.sum1_const
#print axioms QRChain.sum1_swap
#print axioms QRChain.prod1_mul
#print axioms QRChain.pow_add'
#print axioms QRChain.pow_mul'
#print axioms QRChain.prod1_const
#print axioms QRChain.prod1_pow
#print axioms QRChain.rem_of_lt
#print axioms QRChain.rem_lt'
#print axioms QRChain.rem_zero_of_dv
#print axioms QRChain.dv_of_rem_zero
#print axioms QRChain.rem_mul_left
#print axioms QRChain.rem_mul_congr
#print axioms QRChain.rem_mul_congr'
#print axioms QRChain.rem_mul_congr2
#print axioms QRChain.rem_add_congr'
#print axioms QRChain.rem_add_congr2
#print axioms QRChain.rem_pow_congr
#print axioms QRChain.rem_cancel_add
#print axioms QRChain.dv_of_rem_add
#print axioms QRChain.rem_add_dv
#print axioms QRChain.rem_prod1_congr
#print axioms QRChain.euclid
#print axioms QRChain.eq_zero_of_dv_lt
#print axioms QRChain.not_dv_of_lt
#print axioms QRChain.not_dv_prod1
#print axioms QRChain.cancel_core
#print axioms QRChain.rem_cancel_mul
#print axioms QRChain.allL_mono
#print axioms QRChain.qd_length
#print axioms QRChain.qd_spec
#print axioms QRChain.root_quot
#print axioms QRChain.roots_le_n
#print axioms QRChain.roots_le
#print axioms QRChain.h_pos
#print axioms QRChain.rem_one
#print axioms QRChain.hh_pos
#print axioms QRChain.fermat1
#print axioms QRChain.sq_pow
#print axioms QRChain.sq_one
#print axioms QRChain.euler_pm
#print axioms QRChain.euler_of_sq
#print axioms QRChain.tailL_length
#print axioms QRChain.ev_tailL
#print axioms QRChain.sqL_length
#print axioms QRChain.sqL_mem
#print axioms QRChain.sq_expand
#print axioms QRChain.lt_p_of_le_h
#print axioms QRChain.sq_distinct
#print axioms QRChain.sqL_nodup
#print axioms QRChain.root_of_pow
#print axioms QRChain.sq_search
#print axioms QRChain.euler_iff
#print axioms QRChain.memL_dec
#print axioms QRChain.eraseL_eq
#print axioms QRChain.eraseL_ne
#print axioms QRChain.erase_mem
#print axioms QRChain.erase_ne
#print axioms QRChain.erase_nodup
#print axioms QRChain.erase_count
#print axioms QRChain.erase_not_mem
#print axioms QRChain.perm_count
#print axioms QRChain.mkL_length
#print axioms QRChain.prodL_mkL
#print axioms QRChain.sumL_mkL
#print axioms QRChain.mkL_mem
#print axioms QRChain.mkL_nodup
#print axioms QRChain.perm_fun
#print axioms QRChain.dm_spec
#print axioms QRChain.fl_spec
#print axioms QRChain.fl_values
#print axioms QRChain.rk_cases
#print axioms QRChain.rk_pos
#print axioms QRChain.sk_bounds
#print axioms QRChain.rk_sign
#print axioms QRChain.rk_no_eq
#print axioms QRChain.rk_no_sum
#print axioms QRChain.sk_inj
#print axioms QRChain.neg_sq
#print axioms QRChain.neg_sq'
#print axioms QRChain.neg_pow_even
#print axioms QRChain.neg_pow_odd
#print axioms QRChain.gauss_pow
#print axioms QRChain.par_one_ne
#print axioms QRChain.gauss_lemma
#print axioms QRChain.bx_solve
#print axioms QRChain.beq_refl'
#print axioms QRChain.par_p
#print axioms QRChain.eisenstein_par
#print axioms QRChain.qr_by_floor
#print axioms QRChain.ltI_one
#print axioms QRChain.ltI_zero
#print axioms QRChain.ltI_add
#print axioms QRChain.count_low
#print axioms QRChain.count_high
#print axioms QRChain.fl_count
#print axioms QRChain.double_inj
#print axioms QRChain.not_dv_qx
#print axioms QRChain.fl_le
#print axioms QRChain.fl_as_count
#print axioms QRChain.lattice
#print axioms QRChain.or_true_cases
#print axioms QRChain.or_true_right
#print axioms QRChain.sqS_sound
#print axioms QRChain.sqS_complete
#print axioms QRChain.legB_iff
#print axioms QRChain.b_of_iff
#print axioms QRChain.qr_law
#print axioms QRChain.iff_bx
#print axioms QRChain.qr_law_iff
#print axioms QRChain.leg_values
#print axioms QRChain.qr_example
DefectChain.lean
/-
DefectChain.lean
The defect count l0 and the binomial identities it uses, for every l
(links 47-48).
Lean 4 core plus FTAChain and FrobChain (the Pascal binomial `C` and the
finite sums `sumTo`). Proofs are hand-written terms and plain rewriting;
no omega / simp / ring / decide / norm_num / linarith.
Proved here:
ceilHalf_even, ceilHalf_odd ⌈n/2⌉ on even and odd n
l0_even, l0_odd closed forms of l0
sum_C Σ_{i ≤ l} C l i = 2^l
sum_C_long the same with any number of extra terms
even_eq_odd l ≥ 1: Σ_{i even} C l i = Σ_{i odd} C l i
C_symm i ≤ l: C l i = C l (l - i)
-/
import FrobChain
namespace DefectChain
open FTAChain FrobChain
/-! ## l0 -/
/-- `⌈n / 2⌉`. -/
def ceilHalf : Nat → Nat
| 0 => 0
| 1 => 1
| n + 2 => ceilHalf n + 1
/-- `l0(r1, r2, n) = r1 * (⌈n/2⌉ - 1) + r2 * (n - 1)`. -/
def l0 (r1 r2 n : Nat) : Nat := r1 * (ceilHalf n - 1) + r2 * (n - 1)
theorem ceilHalf_even : ∀ k : Nat, ceilHalf (k + k) = k
| 0 => rfl
| k + 1 => by
rw [← Nat.add_assoc (k + 1) k 1, Nat.add_right_comm k 1 k]
show ceilHalf (k + k) + 1 = k + 1
rw [ceilHalf_even k]
theorem ceilHalf_odd : ∀ k : Nat, ceilHalf (k + k + 1) = k + 1
| 0 => rfl
| k + 1 => by
rw [← Nat.add_assoc (k + 1) k 1, Nat.add_right_comm k 1 k]
show ceilHalf (k + k + 1) + 1 = k + 1 + 1
rw [ceilHalf_odd k]
/-- For `n = 2k + 2`: `l0 = r1 * k + r2 * (2k + 1)`. -/
theorem l0_even (r1 r2 k : Nat) : l0 r1 r2 (k + 1 + (k + 1)) = r1 * k + r2 * (k + k + 1) := by
show r1 * (ceilHalf (k + 1 + (k + 1)) - 1) + r2 * (k + 1 + (k + 1) - 1) = _
rw [ceilHalf_even (k + 1), Nat.add_right_comm k 1 (k + 1)]
rfl
/-- For `n = 2k + 1`: `l0 = r1 * k + r2 * (2k)`. -/
theorem l0_odd (r1 r2 k : Nat) : l0 r1 r2 (k + k + 1) = r1 * k + r2 * (k + k) := by
show r1 * (ceilHalf (k + k + 1) - 1) + r2 * (k + k + 1 - 1) = _
rw [ceilHalf_odd k]
rfl
theorem l0_values : l0 3 5 1 = 0 ∧ l0 3 5 4 = 18 ∧ l0 2 1 7 = 12 := ⟨rfl, rfl, rfl⟩
/-! ## Σ_i C l i = 2^l -/
theorem sum_C (l : Nat) : sumTo (l + 1) (C l) = 2 ^ l := by
have hb := binom 1 1 l
have e : sumTo (l + 1) (fun k => C l k * 1 ^ k * 1 ^ (l - k)) = sumTo (l + 1) (C l) :=
sum_ext _ _ _ (fun k _ => by rw [Nat.one_pow, Nat.one_pow, Nat.mul_one, Nat.mul_one])
rw [e] at hb
exact hb.symm
/-- Extra terms past `l` add nothing. -/
theorem sum_C_long (l : Nat) : ∀ k : Nat, sumTo (l + 1 + k) (C l) = 2 ^ l
| 0 => sum_C l
| k + 1 => by
show sumTo (l + 1 + k) (C l) + C l (l + 1 + k) = 2 ^ l
rw [sum_C_long l k, Nat.add_assoc, Nat.add_comm 1 k, ← Nat.add_assoc, C_gt l k, Nat.add_zero]
/-! ## Even and odd halves -/
/-- Summing in pairs. -/
theorem sum_pairs (f : Nat → Nat) : ∀ m : Nat,
sumTo (m + m) f = sumTo m (fun j => f (j + j) + f (j + j + 1))
| 0 => rfl
| m + 1 => by
rw [← Nat.add_assoc (m + 1) m 1, Nat.add_right_comm m 1 m]
show sumTo (m + m) f + f (m + m) + f (m + m + 1)
= sumTo m (fun j => f (j + j) + f (j + j + 1)) + (f (m + m) + f (m + m + 1))
rw [sum_pairs f m, Nat.add_assoc]
/-- `Σ_{j ≤ l} C l (2j)`. -/
def evenSum (l : Nat) : Nat := sumTo (l + 1) (fun j => C l (j + j))
/-- `Σ_{j ≤ l} C l (2j + 1)`. -/
def oddSum (l : Nat) : Nat := sumTo (l + 1) (fun j => C l (j + j + 1))
theorem le_two_mul (l : Nat) : ∀ m : Nat, ∃ k, l + 1 + k = l + 1 + m + (l + 1 + m)
| m => ⟨m + (l + 1 + m), (Nat.add_assoc _ _ _).symm⟩
theorem oddSum_succ (l : Nat) : oddSum (l + 1) = 2 ^ l := by
show sumTo (l + 1 + 1) (fun j => C (l + 1) (j + j + 1)) = 2 ^ l
have e : sumTo (l + 1 + 1) (fun j => C (l + 1) (j + j + 1))
= sumTo (l + 1 + 1) (fun j => C l (j + j) + C l (j + j + 1)) :=
sum_ext _ _ _ (fun j _ => rfl)
rw [e, ← sum_pairs]
have ⟨k, hk⟩ := le_two_mul l 1
rw [← hk]
exact sum_C_long l k
theorem evenSum_succ (l : Nat) : evenSum (l + 1) = 2 ^ l := by
show sumTo (l + 1 + 1) (fun j => C (l + 1) (j + j)) = 2 ^ l
rw [sum_shift]
have e : sumTo (l + 1) (fun j => C (l + 1) (j + 1 + (j + 1)))
= sumTo (l + 1) (fun j => C l (j + 1 + j) + C l (j + 1 + j + 1)) :=
sum_ext _ _ _ (fun j _ => rfl)
have e2 : sumTo (l + 1) (fun j => C l (j + 1 + j) + C l (j + 1 + j + 1))
= sumTo (l + 1) (fun j => C l (j + j + 1) + C l (j + j + 1 + 1)) :=
sum_ext _ _ _ (fun j _ => by rw [Nat.add_right_comm j 1 j])
rw [e, e2]
have e3 := sum_pairs (fun i => C l (i + 1)) (l + 1)
rw [← e3]
show C (l + 1) 0 + sumTo (l + 1 + (l + 1)) (fun i => C l (i + 1)) = 2 ^ l
rw [show C (l + 1) 0 = C l 0 from (C_zero_right (l + 1)).trans (C_zero_right l).symm,
← sum_shift (l + 1 + (l + 1)) (C l)]
rw [Nat.add_assoc (l + 1) (l + 1) 1]
exact sum_C_long l (l + 1 + 1)
/-- **For l ≥ 1, the even binomials and the odd binomials have the same sum**
(in natural numbers, without signs). -/
theorem even_eq_odd (l : Nat) (hl : 1 ≤ l) : evenSum l = oddSum l :=
match l, hl with
| 0, hl => absurd hl (Nat.not_succ_le_zero 0)
| l + 1, _ => (evenSum_succ l).trans (oddSum_succ l).symm
theorem even_odd_values : evenSum 5 = 16 ∧ oddSum 5 = 16 ∧ evenSum 0 = 1 ∧ oddSum 0 = 0 :=
⟨rfl, rfl, rfl, rfl⟩
/-! ## Symmetry -/
theorem C_symm_add : ∀ (n a b : Nat), a + b = n → C n a = C n b
| 0, 0, 0, _ => rfl
| 0, a + 1, b, h => absurd ((Nat.add_right_comm a 1 b).symm.trans h) (succ_ne_zero' _)
| 0, 0, b + 1, h => absurd h (succ_ne_zero' _)
| n + 1, 0, b, h => by
rw [nzero_add] at h
rw [h, C_zero_right, C_self]
| n + 1, a + 1, 0, h => by
have h' : a + 1 = n + 1 := h
rw [h', C_zero_right, C_self]
| n + 1, a + 1, b + 1, h => by
have h' : a + b + 1 = n := (Nat.add_right_comm a 1 b).symm.trans (@succ_inj' (a + 1 + b) n h)
show C n a + C n (a + 1) = C n b + C n (b + 1)
rw [C_symm_add n a (b + 1) h', C_symm_add n (a + 1) b (by rw [Nat.add_right_comm a 1 b]; exact h')]
exact Nat.add_comm _ _
theorem add_sub_of_le'' : ∀ (a b : Nat), a ≤ b → a + (b - a) = b
| 0, b, _ => by rw [nzero_add]; rfl
| a + 1, 0, h => absurd h (Nat.not_succ_le_zero a)
| a + 1, b + 1, h => by
rw [Nat.succ_sub_succ, Nat.add_right_comm]
exact congrArg Nat.succ (add_sub_of_le'' a b (Nat.le_of_succ_le_succ h))
/-- **Symmetry.** `i ≤ l → C l i = C l (l - i)`. -/
theorem C_symm (l i : Nat) (h : i ≤ l) : C l i = C l (l - i) :=
C_symm_add l i (l - i) (add_sub_of_le'' i l h)
end DefectChain
#print axioms DefectChain.ceilHalf_even
#print axioms DefectChain.ceilHalf_odd
#print axioms DefectChain.l0_even
#print axioms DefectChain.l0_odd
#print axioms DefectChain.l0_values
#print axioms DefectChain.sum_C
#print axioms DefectChain.sum_C_long
#print axioms DefectChain.sum_pairs
#print axioms DefectChain.le_two_mul
#print axioms DefectChain.oddSum_succ
#print axioms DefectChain.evenSum_succ
#print axioms DefectChain.even_eq_odd
#print axioms DefectChain.even_odd_values
#print axioms DefectChain.C_symm_add
#print axioms DefectChain.add_sub_of_le''
#print axioms DefectChain.C_symm
ESChain.lean
/-
ESChain.lean
Counting points on 11a: y^2 + y = x^3 - x^2, for every odd prime p
(links 49-50).
Lean 4 core plus FTAChain, FrobChain and QRChain. Proofs are
hand-written terms and plain rewriting; no omega / simp / ring /
decide / norm_num / linarith. Concrete numerical checks use `rfl`.
An odd prime is written `h + h + 1`. The Legendre symbol enters as
`legV p d = 1 + (d|p)`, with `(0|p) = 0`:
legV p d = 1 if p ∣ d, 2 if d is a nonzero square, 0 otherwise.
Proved here:
rem_eq_mod FTAChain's `rem` is the core `%` (no axioms)
odd_sq (2y+1)^2 = 4(y^2+y) + 1
cnt_sq #{y : y^2 + y ≡ c} = 1 + (4c+1 | p)
nE_formula #E(F_p) = 1 + Σ_x (1 + (4x^3-4x^2+1 | p))
nE_signed #E(F_p) + N = p + 1 + P, where P (N) counts the x with
(4x^3-4x^2+1 | p) = +1 (-1); i.e.
a_p := p + 1 - #E(F_p) = N - P = -Σ_x (4x^3-4x^2+1 | p)
modular_check for every prime p < 200, the q^p coefficient of
q Π (1-q^n)^2 (1-q^{11n})^2 equals p + 1 - #E(F_p) (rfl)
-/
import QRChain
namespace ESChain
open FTAChain FrobChain QRChain
/-! ## `rem` is `%` -/
theorem modgo_spec (y : Nat) (hy : 0 < y) : ∀ (fuel x : Nat) (hf : x < fuel),
∃ q, x = q * y + Nat.modCore.go y hy fuel x hf
| 0, x, hf => absurd hf (Nat.not_lt_zero x)
| fuel + 1, x, hf => by
rw [Nat.modCore.go.eq_def]
show ∃ q, x = q * y +
(if h : y ≤ x then Nat.modCore.go y hy fuel (x - y) (Nat.div_rec_fuel_lemma hy h hf) else x)
match Nat.decLe y x with
| isTrue h =>
rw [dite_eq_left h]
have ⟨q, hq⟩ := modgo_spec y hy fuel (x - y) (Nat.div_rec_fuel_lemma hy h hf)
refine ⟨q + 1, ?_⟩
rw [nsucc_mul, Nat.add_right_comm, ← hq, Nat.add_comm]
exact (add_sub_of_le' y x h).symm
| isFalse h =>
rw [dite_eq_right h]
exact ⟨0, by rw [nzero_mul, nzero_add]⟩
theorem mod_decomp (m : Nat) (hm : 0 < m) : ∀ n : Nat, ∃ q, n = q * m + n % m
| 0 => ⟨0, by rw [Nat.zero_mod, nzero_mul]⟩
| k + 1 => by
show ∃ q, k + 1 = q * m + Nat.mod (k + 1) m
rw [Nat.mod.eq_def]
show ∃ q, k + 1 = q * m + (if m ≤ k + 1 then Nat.modCore (k + 1) m else k + 1)
match Nat.decLe m (k + 1) with
| isTrue h =>
rw [ite_eq_left h, Nat.modCore.eq_def, dite_eq_left hm]
exact modgo_spec m hm _ _ _
| isFalse h =>
rw [ite_eq_right h]
exact ⟨0, by rw [nzero_mul, nzero_add]⟩
theorem rem_eq_mod (m' n : Nat) : rem (m' + 1) n = n % (m' + 1) :=
match mod_decomp (m' + 1) (Nat.zero_lt_succ m') n,
Nat.le.dest (Nat.mod_lt n (Nat.zero_lt_succ m')) with
| ⟨q, hq⟩, ⟨k, hk⟩ =>
have hk' : n % (m' + 1) + (k + 1) = m' + 1 := (Nat.succ_add _ k).symm.trans hk
Eq.trans (congrArg (rem (m' + 1)) hq) (rem_div m' q _ k hk')
/-! ## Indicators and counting -/
def b2n : Bool → Nat
| true => 1
| false => 0
/-- `[y = a]`. -/
def eqI (y a : Nat) : Nat := if y = a then 1 else 0
theorem b2n_beq (a b : Nat) : b2n (Nat.beq a b) = if a = b then 1 else 0 :=
match Nat.decEq a b with
| isTrue e => by rw [ite_eq_left e, e, beq_refl']; rfl
| isFalse ne => by
rw [ite_eq_right ne]
cases hb : Nat.beq a b with
| false => rfl
| true => exact absurd (Nat.eq_of_beq_eq_true hb) ne
theorem sum_zero : ∀ (n : Nat) (f : Nat → Nat), (∀ y, y < n → f y = 0) → sumTo n f = 0
| 0, _, _ => rfl
| n + 1, f, h => by
show sumTo n f + f n = 0
rw [sum_zero n f (fun y hy => h y (Nat.lt_succ_of_lt hy)), h n (Nat.lt_succ_self n)]
theorem sum_eqI (a : Nat) : ∀ n : Nat, a < n → sumTo n (fun y => eqI y a) = 1
| 0, h => absurd h (Nat.not_lt_zero a)
| n + 1, h => by
show sumTo n (fun y => eqI y a) + eqI n a = 1
match Nat.eq_or_lt_of_le (Nat.le_of_lt_succ h) with
| Or.inl e =>
rw [e, sum_zero n (fun y => eqI y n) (fun y hy => ite_eq_right (Nat.ne_of_lt hy)),
show eqI n n = 1 from ite_eq_left rfl]
| Or.inr l =>
rw [sum_eqI a n l, show eqI n a = 0 from ite_eq_right (fun e2 => Nat.ne_of_lt l e2.symm)]
theorem sum_const1 : ∀ n : Nat, sumTo n (fun _ => 1) = n
| 0 => rfl
| n + 1 => congrArg Nat.succ (sum_const1 n)
/-! ## Odd squares -/
theorem four_mul (t : Nat) : 4 * t = t + t + t + t := by
rw [nmul_comm]
show t * 0 + t + t + t + t = _
rw [Nat.mul_zero, nzero_add]
theorem odd_sq (y : Nat) : (y + y + 1) * (y + y + 1) = 4 * (y * y + y) + 1 := by
rw [four_mul]
show (y + y + 1) * (y + y) + (y + y) + 1 = _
rw [nsucc_mul (y + y) (y + y), nright_distrib y y (y + y), nleft_distrib y y y]
apply congrArg Nat.succ
rw [Nat.add_assoc ((y * y + y * y) + (y * y + y * y)) (y + y) (y + y),
mid4 (y * y + y * y) (y * y + y * y) (y + y) (y + y),
mid4 (y * y) (y * y) y y, ← Nat.add_assoc]
theorem not_dv_two (h : Nat) (hp : Pr (h + h + 1)) : ¬ Dv (h + h + 1) 2 :=
not_dv_of_lt _ 2 (Nat.zero_lt_succ 1)
(Nat.succ_le_succ (Nat.add_le_add (h_pos h hp) (h_pos h hp)))
theorem not_dv_four (h : Nat) (hp : Pr (h + h + 1)) : ¬ Dv (h + h + 1) 4 := fun hd =>
match euclid _ 2 2 hp hd with
| Or.inl h2 => not_dv_two h hp h2
| Or.inr h2 => not_dv_two h hp h2
/-- `y^2 + y ≡ c` exactly when `(2y+1)^2 ≡ 4c + 1`. -/
theorem root_iff (h y c : Nat) (hp : Pr (h + h + 1)) :
rem (h + h + 1) (y * y + y) = rem (h + h + 1) c ↔
rem (h + h + 1) ((y + y + 1) * (y + y + 1)) = rem (h + h + 1) (4 * c + 1) := by
rw [odd_sq]
constructor
· intro e
exact rem_add_congr _ _ _ 1 (rem_mul_congr' _ _ _ 4 e)
· intro e
exact rem_cancel_mul _ 4 _ _ hp (not_dv_four h hp) (rem_cancel_add _ _ _ 1 e)
/-! ## The number of solutions of y^2 + y ≡ c -/
/-- `#{y ∈ 0..p-1 : y^2 + y ≡ c}`. -/
def cntY (p c : Nat) : Nat := sumTo p (fun y => b2n (Nat.beq (rem p (y * y + y)) (rem p c)))
/-- `1 + (d|p)`, with `(0|p) = 0`. -/
def legV (p d : Nat) : Nat := if rem p d = 0 then 1 else cond (legB p d) 2 0
theorem two_y_lt (h y : Nat) (hy : y < h + h + 1) : y + y + 1 < (h + h + 1) + (h + h + 1) :=
Nat.lt_of_le_of_lt (Nat.add_le_add_left (hy : y + 1 ≤ h + h + 1) y)
(Nat.add_lt_add_right hy _)
/-- When `p ∣ 4c+1` the only solution is `y = h`. -/
theorem roots_zero (h c y : Nat) (hp : Pr (h + h + 1)) (hd : rem (h + h + 1) (4 * c + 1) = 0)
(hy : y < h + h + 1) :
rem (h + h + 1) (y * y + y) = rem (h + h + 1) c ↔ y = h := by
refine (root_iff h y c hp).trans ?_
rw [hd]
constructor
· intro e
have hdv : Dv (h + h + 1) (y + y + 1) :=
match euclid _ _ _ hp (dv_of_rem_zero _ _ e) with
| Or.inl d => d
| Or.inr d => d
match hdv with
| ⟨0, hq⟩ => exact absurd hq (fun e => Nat.noConfusion (e.trans (nzero_mul _)))
| ⟨1, hq⟩ =>
rw [Nat.one_mul] at hq
exact double_inj y h (succ_inj' hq)
| ⟨q + 1 + 1, hq⟩ =>
rw [nsucc_mul, nsucc_mul] at hq
have l := two_y_lt h y hy
rw [hq, Nat.add_assoc] at l
exact absurd (Nat.lt_of_le_of_lt (Nat.le_add_left _ _) l) (Nat.lt_irrefl _)
· intro e
rw [e]
exact rem_zero_of_dv _ _ ⟨h + h + 1, rfl⟩
theorem leg_root (h c y : Nat) (hp : Pr (h + h + 1))
(e : rem (h + h + 1) (y * y + y) = rem (h + h + 1) c) :
legB (h + h + 1) (4 * c + 1) = true :=
(legB_iff (h + h) _).mpr ⟨y + y + 1, (root_iff h y c hp).mp e⟩
/-- The polynomial `X^2 + X + (p - c)`, whose roots are the solutions. -/
theorem poly_root (h c y : Nat) (e : rem (h + h + 1) (y * y + y) = rem (h + h + 1) c) :
rem (h + h + 1) (ev y [1, 1, (h + h + 1) - rem (h + h + 1) c]) = 0 := by
show rem (h + h + 1) (1 * (1 * y * y) + (1 * (1 * y) + (((h + h + 1) - rem (h + h + 1) c) * 1 + 0))) = 0
repeat rw [Nat.one_mul]
rw [Nat.mul_one, Nat.add_zero, ← Nat.add_assoc]
rw [rem_add_congr _ _ (rem (h + h + 1) c) _ (e.trans (rem_idem _ c).symm),
Nat.add_zero ((h + h + 1) - rem (h + h + 1) c),
add_sub_of_le' _ _ (Nat.le_of_lt (rem_lt' _ c))]
exact rem_zero_of_dv _ _ (dv_refl _)
/-- At most two solutions. -/
theorem at_most_two (h c y y0 y1 : Nat) (hp : Pr (h + h + 1))
(hy : y < h + h + 1) (hy0 : y0 < h + h + 1) (hy1 : y1 < h + h + 1) (h01 : y0 ≠ y1)
(e : rem (h + h + 1) (y * y + y) = rem (h + h + 1) c)
(e0 : rem (h + h + 1) (y0 * y0 + y0) = rem (h + h + 1) c)
(e1 : rem (h + h + 1) (y1 * y1 + y1) = rem (h + h + 1) c) : y = y0 ∨ y = y1 :=
match Nat.decEq y y0, Nat.decEq y y1 with
| isTrue a, _ => Or.inl a
| _, isTrue b => Or.inr b
| isFalse a, isFalse b => by
have hle := roots_le (h + h) hp 1 [1, (h + h + 1) - rem (h + h + 1) c] [y, y0, y1]
(not_dv_of_lt _ 1 Nat.zero_lt_one (Nat.succ_lt_succ (hh_pos h hp)))
⟨fun hm => match hm with
| Or.inl x => a x
| Or.inr (Or.inl x) => b x,
fun hm => match hm with
| Or.inl x => h01 x,
fun hm => hm, True.intro⟩
⟨⟨hy, poly_root h c y e⟩, ⟨hy0, poly_root h c y0 e0⟩, ⟨hy1, poly_root h c y1 e1⟩, True.intro⟩
exact absurd hle (Nat.not_succ_le_self 2)
/-- The partner solution `p - 1 - y0`. -/
theorem partner (h c y0 y1 : Nat) (hs : y0 + y1 + 1 = h + h + 1)
(e0 : rem (h + h + 1) (y0 * y0 + y0) = rem (h + h + 1) c) :
rem (h + h + 1) (y1 * y1 + y1) = rem (h + h + 1) c := by
rw [← e0]
apply rem_cancel_add (h + h) _ _ (y1 * y0)
have a1 : y1 * y1 + y1 + y1 * y0 = y1 * (h + h + 1) := by
rw [← hs]
show y1 * y1 + y1 + y1 * y0 = y1 * (y0 + y1) + y1
rw [nleft_distrib, Nat.add_comm (y1 * y0) (y1 * y1), Nat.add_right_comm]
have a2 : y0 * y0 + y0 + y1 * y0 = y0 * (h + h + 1) := by
rw [← hs, nmul_comm y1 y0]
show y0 * y0 + y0 + y0 * y1 = y0 * (y0 + y1) + y0
rw [nleft_distrib, Nat.add_right_comm]
rw [a1, a2, rem_zero_of_dv (h + h) (y1 * (h + h + 1)) ⟨y1, rfl⟩,
rem_zero_of_dv (h + h) (y0 * (h + h + 1)) ⟨y0, rfl⟩]
/-- **Solutions of y^2 + y ≡ c.** `#{y : y^2 + y ≡ c (mod p)} = 1 + (4c+1 | p)`. -/
theorem cnt_sq (h c : Nat) (hp : Pr (h + h + 1)) :
cntY (h + h + 1) c = legV (h + h + 1) (4 * c + 1) := by
unfold cntY legV
match Nat.decEq (rem (h + h + 1) (4 * c + 1)) 0 with
| isTrue hd =>
rw [ite_eq_left hd]
rw [sum_ext _ _ (fun y => eqI y h) (fun y hy => by
rw [b2n_beq]
match Nat.decEq (rem (h + h + 1) (y * y + y)) (rem (h + h + 1) c) with
| isTrue e2 =>
rw [ite_eq_left e2, show eqI y h = 1 from ite_eq_left ((roots_zero h c y hp hd hy).mp e2)]
| isFalse n2 =>
rw [ite_eq_right n2, show eqI y h = 0 from
ite_eq_right (fun e3 => n2 ((roots_zero h c y hp hd hy).mpr e3))])]
exact sum_eqI h _ (lt_p_of_le_h h h (Nat.le_refl h))
| isFalse hd =>
rw [ite_eq_right hd]
cases hl : legB (h + h + 1) (4 * c + 1) with
| false =>
show _ = 0
exact sum_zero _ _ (fun y _ => by
rw [b2n_beq]
exact ite_eq_right (fun e => Bool.noConfusion (hl.symm.trans (leg_root h c y hp e))))
| true =>
show _ = 2
have ⟨z0, hz0⟩ := (legB_iff (h + h) _).mp hl
-- a solution y0 with 2 y0 + 1 ≡ z0
have hW : rem (h + h + 1) ((z0 + h + h) * (h + 1) + (z0 + h + h) * (h + 1) + 1)
= rem (h + h + 1) z0 := by
have e1 : (z0 + h + h) * (h + 1) + (z0 + h + h) * (h + 1) + 1
= (z0 + h + h) * (h + h + 1) + z0 * 1 + (h + h + 1) := by
rw [← nleft_distrib, Nat.add_right_comm h 1 (h + 1), ← Nat.add_assoc h h 1]
show (z0 + h + h) * (h + h + 1) + (z0 + h + h) + 1 = _
rw [Nat.mul_one, Nat.add_assoc ((z0 + h + h) * (h + h + 1)) z0 (h + h + 1)]
rw [Nat.add_assoc ((z0 + h + h) * (h + h + 1)) (z0 + h + h) 1, Nat.add_assoc z0 h h]
rfl
rw [e1, rem_add_dv _ _ _ (dv_refl _), rem_add_mul, Nat.mul_one]
let y0 := rem (h + h + 1) ((z0 + h + h) * (h + 1))
have hy0 : y0 < h + h + 1 := rem_lt' _ _
have h2y0 : rem (h + h + 1) (y0 + y0 + 1) = rem (h + h + 1) z0 := by
rw [← hW]
apply rem_add_congr _ _ _ 1
exact rem_add_congr2 _ _ _ _ _ (rem_idem _ _) (rem_idem _ _)
have e0 : rem (h + h + 1) (y0 * y0 + y0) = rem (h + h + 1) c :=
(root_iff h y0 c hp).mpr ((rem_mul_congr2 _ _ _ _ _ h2y0 h2y0).trans hz0)
have ⟨y1, hy1s⟩ := Nat.le.dest (Nat.le_of_lt_succ hy0)
have hs : y0 + y1 + 1 = h + h + 1 := congrArg Nat.succ hy1s
have hy1 : y1 < h + h + 1 :=
Nat.lt_succ_of_le (Nat.le.intro (by rw [Nat.add_comm]; exact hy1s))
have e1 := partner h c y0 y1 hs e0
have h01 : y0 ≠ y1 := fun e => by
rw [← e] at hs
have hyh : y0 = h := double_inj y0 h (succ_inj' hs)
rw [hyh] at h2y0
have hz : rem (h + h + 1) (z0 * z0) = 0 := by
rw [← rem_mul_congr2 _ _ _ _ _ h2y0 h2y0]
exact rem_zero_of_dv _ _ ⟨h + h + 1, rfl⟩
exact hd (hz0.symm.trans hz)
rw [sum_ext _ _ (fun y => eqI y y0 + eqI y y1) (fun y hy => by
rw [b2n_beq]
match Nat.decEq (rem (h + h + 1) (y * y + y)) (rem (h + h + 1) c) with
| isTrue e2 =>
rw [ite_eq_left e2]
match at_most_two h c y y0 y1 hp hy hy0 hy1 h01 e2 e0 e1 with
| Or.inl a =>
rw [show eqI y y0 = 1 from ite_eq_left a,
show eqI y y1 = 0 from ite_eq_right (fun b => h01 (a.symm.trans b))]
| Or.inr b =>
rw [show eqI y y0 = 0 from ite_eq_right (fun a => h01 (a.symm.trans b)),
show eqI y y1 = 1 from ite_eq_left b]
| isFalse n2 =>
rw [ite_eq_right n2,
show eqI y y0 = 0 from ite_eq_right (fun a => n2 (by rw [a]; exact e0)),
show eqI y y1 = 0 from ite_eq_right (fun b => n2 (by rw [b]; exact e1))]),
sum_add, sum_eqI y0 _ hy0, sum_eqI y1 _ hy1]
/-! ## Points of y^2 + y = x^3 - x^2 -/
/-- `x^3 - x^2` (never truncated: `x^2 ≤ x^3`). -/
def cx (x : Nat) : Nat := x * x * x - x * x
/-- `4x^3 - 4x^2 + 1`. -/
def dx (x : Nat) : Nat := 4 * cx x + 1
/-- Affine points of `y^2 + y = x^3 - x^2` over F_p, written
`y^2 + y + x^2 ≡ x^3`. -/
def affE (p : Nat) : Nat :=
sumTo p (fun x => sumTo p (fun y =>
b2n (Nat.beq (rem p (y * y + y + x * x)) (rem p (x * x * x)))))
/-- `#E(F_p)`: the affine points and the point at infinity. -/
def nE (p : Nat) : Nat := affE p + 1
theorem sq_le_cube : ∀ x : Nat, x * x ≤ x * x * x
| 0 => Nat.le_refl 0
| k + 1 => Nat.le_add_left ((k + 1) * (k + 1)) ((k + 1) * (k + 1) * k)
theorem cx_add (x : Nat) : cx x + x * x = x * x * x := by
unfold cx
rw [Nat.add_comm]
exact add_sub_of_le' _ _ (sq_le_cube x)
theorem ite_iff {P Q : Prop} [dP : Decidable P] [dQ : Decidable Q] (h : P ↔ Q) :
(if P then (1 : Nat) else 0) = (if Q then 1 else 0) :=
match dP with
| isTrue hp => by rw [ite_eq_left hp, ite_eq_left (h.mp hp)]
| isFalse hn => by rw [ite_eq_right hn, ite_eq_right (fun hq => hn (h.mpr hq))]
theorem affE_eq (m' : Nat) :
affE (m' + 1) = sumTo (m' + 1) (fun x => cntY (m' + 1) (cx x)) :=
sum_ext _ _ _ (fun x _ => sum_ext _ _ _ (fun y _ => by
rw [b2n_beq, b2n_beq]
apply ite_iff
rw [← cx_add x]
exact ⟨rem_cancel_add m' _ _ (x * x), rem_add_congr m' _ _ (x * x)⟩))
/-- **Point count.** `#E(F_p) = 1 + Σ_x (1 + (4x^3 - 4x^2 + 1 | p))`
for every odd prime p. -/
theorem nE_formula (h : Nat) (hp : Pr (h + h + 1)) :
nE (h + h + 1) = 1 + sumTo (h + h + 1) (fun x => legV (h + h + 1) (dx x)) := by
unfold nE
rw [affE_eq (h + h), sum_ext _ _ _ (fun x _ => cnt_sq h (cx x) hp)]
exact Nat.add_comm _ _
/-- `[v = 2]`: the x with `(4x^3-4x^2+1 | p) = +1`. -/
def twoI (v : Nat) : Nat := if v = 2 then 1 else 0
/-- `[v = 0]`: the x with `(4x^3-4x^2+1 | p) = -1`. -/
def zeroI (v : Nat) : Nat := if v = 0 then 1 else 0
def Pcount (p : Nat) : Nat := sumTo p (fun x => twoI (legV p (dx x)))
def Ncount (p : Nat) : Nat := sumTo p (fun x => zeroI (legV p (dx x)))
theorem legV_cases (p d : Nat) : legV p d = 0 ∨ legV p d = 1 ∨ legV p d = 2 := by
unfold legV
match Nat.decEq (rem p d) 0 with
| isTrue e => rw [ite_eq_left e]; exact Or.inr (Or.inl rfl)
| isFalse n =>
rw [ite_eq_right n]
cases legB p d with
| true => exact Or.inr (Or.inr rfl)
| false => exact Or.inl rfl
theorem signed_point (v : Nat) (h : v = 0 ∨ v = 1 ∨ v = 2) : v + zeroI v = 1 + twoI v :=
match h with
| Or.inl e => by rw [e]; rfl
| Or.inr (Or.inl e) => by rw [e]; rfl
| Or.inr (Or.inr e) => by rw [e]; rfl
/-- **The trace.** `#E(F_p) + N = p + 1 + P`, where `P` and `N` count the x with
`(4x^3 - 4x^2 + 1 | p)` equal to `+1` and `-1`. So
`a_p := p + 1 - #E(F_p) = N - P = -Σ_x (4x^3 - 4x^2 + 1 | p)`. -/
theorem nE_signed (h : Nat) (hp : Pr (h + h + 1)) :
nE (h + h + 1) + Ncount (h + h + 1) = (h + h + 1) + 1 + Pcount (h + h + 1) := by
rw [nE_formula h hp]
unfold Ncount Pcount
rw [Nat.add_assoc, ← sum_add,
sum_ext _ _ (fun x => 1 + twoI (legV (h + h + 1) (dx x)))
(fun x _ => signed_point _ (legV_cases _ _)),
sum_add, sum_const1, ← Nat.add_assoc, Nat.add_comm 1 (h + h + 1)]
/-! ## The modular form, checked against #E(F_p) for p < 200 -/
/-- `affE` with the core `%` (equal to `affE`, and fast to evaluate). -/
def affC (p : Nat) : Nat :=
sumTo p (fun x => sumTo p (fun y =>
b2n (Nat.beq ((y * y + y + x * x) % p) ((x * x * x) % p))))
theorem affE_affC : ∀ p : Nat, affE p = affC p
| 0 => rfl
| _ + 1 => sum_ext _ _ _ (fun _ _ => sum_ext _ _ _ (fun _ _ => by rw [rem_eq_mod, rem_eq_mod]))
/-- `a_p = p + 1 - #E(F_p)`. -/
def ap (p : Nat) : Int := Int.ofNat (p + 1) - Int.ofNat (nE p)
def apC (p : Nat) : Int := Int.ofNat (p + 1) - Int.ofNat (affC p + 1)
theorem ap_eq (p : Nat) : ap p = apC p := by
unfold ap apC nE
rw [affE_affC]
/-- Coefficient lists of power series (index i is the coefficient of q^i). -/
def zsub : List Int → List Int → List Int
| a :: as, b :: bs => (a - b) :: zsub as bs
| as, [] => as
| [], _ :: _ => []
def zeros : Nat → List Int
| 0 => []
| n + 1 => 0 :: zeros n
/-- Multiply by `1 - q^k`, keeping the length. -/
def mul1m (k : Nat) (l : List Int) : List Int := zsub l (zeros k ++ l)
/-- Multiply by `Π_{n=1}^{N} (1 - q^n)^2`. -/
def prodA : Nat → List Int → List Int
| 0, l => l
| n + 1, l => prodA n (mul1m (n + 1) (mul1m (n + 1) l))
/-- Multiply by `Π_{n=1}^{N} (1 - q^{11n})^2`. -/
def prodB : Nat → List Int → List Int
| 0, l => l
| n + 1, l => prodB n (mul1m (11 * (n + 1)) (mul1m (11 * (n + 1)) l))
def oneS : Nat → List Int
| 0 => []
| n + 1 => 1 :: zeros n
/-- The coefficients of `q^0, ..., q^{N-1}` of `Π_{n≥1} (1-q^n)^2 (1-q^{11n})^2`
(factors with n > N do not reach these). -/
def etaProd (N : Nat) : List Int := prodB N (prodA N (oneS N))
/-- The coefficient of `q^p` in `q Π_{n≥1} (1-q^n)^2 (1-q^{11n})^2`, for `1 ≤ p ≤ 200`. -/
def nth : List Int → Nat → Int
| [], _ => 0
| a :: _, 0 => a
| _ :: as, n + 1 => nth as n
def coef (p : Nat) : Int := nth (etaProd 200) (p - 1)
def primes200 : List Nat :=
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83,
89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179,
181, 191, 193, 197, 199]
/-- Trial division. -/
def noDivFrom (n : Nat) : Nat → Bool
| 0 => true
| 1 => true
| d + 2 => noDivFrom n (d + 1) && !(Nat.beq (n % (d + 2)) 0)
def isPrimeB (n : Nat) : Bool := Nat.blt 1 n && noDivFrom n (n - 1)
def primesBelow : Nat → List Nat
| 0 => []
| n + 1 => primesBelow n ++ (if isPrimeB n then [n] else [])
set_option maxHeartbeats 0 in
set_option maxRecDepth 1000000 in
theorem primes200_def : primesBelow 200 = primes200 := by rfl
theorem map_congr' (f g : Nat → Int) (hfg : ∀ p, f p = g p) :
∀ L : List Nat, L.map f = L.map g
| [] => rfl
| x :: xs => by
show f x :: xs.map f = g x :: xs.map g
rw [hfg x, map_congr' f g hfg xs]
set_option maxHeartbeats 0 in
set_option maxRecDepth 1000000 in
theorem modular_check_fast : primes200.map coef = primes200.map apC := by rfl
/-- **Modularity check.** For every prime `p < 200`, the coefficient of `q^p` in
`q Π (1-q^n)^2 (1-q^{11n})^2` equals `a_p = p + 1 - #E(F_p)`. -/
theorem modular_check : primes200.map coef = primes200.map ap :=
modular_check_fast.trans (map_congr' _ _ (fun p => (ap_eq p).symm) primes200)
end ESChain
#print axioms ESChain.modgo_spec
#print axioms ESChain.mod_decomp
#print axioms ESChain.rem_eq_mod
#print axioms ESChain.b2n_beq
#print axioms ESChain.sum_zero
#print axioms ESChain.sum_eqI
#print axioms ESChain.sum_const1
#print axioms ESChain.four_mul
#print axioms ESChain.odd_sq
#print axioms ESChain.not_dv_two
#print axioms ESChain.not_dv_four
#print axioms ESChain.root_iff
#print axioms ESChain.two_y_lt
#print axioms ESChain.roots_zero
#print axioms ESChain.leg_root
#print axioms ESChain.poly_root
#print axioms ESChain.at_most_two
#print axioms ESChain.partner
#print axioms ESChain.cnt_sq
#print axioms ESChain.sq_le_cube
#print axioms ESChain.cx_add
#print axioms ESChain.ite_iff
#print axioms ESChain.affE_eq
#print axioms ESChain.nE_formula
#print axioms ESChain.legV_cases
#print axioms ESChain.signed_point
#print axioms ESChain.nE_signed
#print axioms ESChain.affE_affC
#print axioms ESChain.ap_eq
#print axioms ESChain.primes200_def
#print axioms ESChain.map_congr'
#print axioms ESChain.modular_check_fast
#print axioms ESChain.modular_check
AXIOMS.txt
== FTAChain.lean 'FTAChain.le_or_lt' does not depend on any axioms 'FTAChain.dv_sub' does not depend on any axioms 'FTAChain.dv_dec' does not depend on any axioms 'FTAChain.euclid_walk' does not depend on any axioms 'FTAChain.euclid_core' does not depend on any axioms 'FTAChain.lp_exists' does not depend on any axioms 'FTAChain.lp_prime' does not depend on any axioms 'FTAChain.swp_fix' does not depend on any axioms 'FTAChain.ord_idem' does not depend on any axioms 'FTAChain.prod_ins' does not depend on any axioms 'FTAChain.sorted_ins' does not depend on any axioms 'FTAChain.prod_isort' does not depend on any axioms 'FTAChain.allpr_isort' does not depend on any axioms 'FTAChain.sorted_isort' does not depend on any axioms 'FTAChain.isort_example' does not depend on any axioms 'FTAChain.factor_exists' does not depend on any axioms 'FTAChain.fta_exists' does not depend on any axioms 'FTAChain.mul_cancel' does not depend on any axioms 'FTAChain.head_le' does not depend on any axioms 'FTAChain.fta_unique' does not depend on any axioms 'FTAChain.fta' does not depend on any axioms 'FTAChain.read_prod' does not depend on any axioms 'FTAChain.isort_idem' does not depend on any axioms 'FTAChain.prod_eq_of_isort' does not depend on any axioms 'FTAChain.isort_eq_of_prod' does not depend on any axioms == FrobChain.lean 'FrobChain.C_zero_right' does not depend on any axioms 'FrobChain.C_gt' does not depend on any axioms 'FrobChain.C_self' does not depend on any axioms 'FrobChain.C_one' does not depend on any axioms 'FrobChain.absorb'' does not depend on any axioms 'FrobChain.absorb' does not depend on any axioms 'FrobChain.dv_mul_right' does not depend on any axioms 'FrobChain.prime_dvd_C' does not depend on any axioms 'FrobChain.sum_ext' does not depend on any axioms 'FrobChain.sum_add' does not depend on any axioms 'FrobChain.sum_mul' does not depend on any axioms 'FrobChain.sum_shift' does not depend on any axioms 'FrobChain.sub_succ_add' does not depend on any axioms 'FrobChain.mul_swap3' does not depend on any axioms 'FrobChain.binom' does not depend on any axioms 'FrobChain.sum_mid' does not depend on any axioms 'FrobChain.rem_add_left' does not depend on any axioms 'FrobChain.rem_add_congr' does not depend on any axioms 'FrobChain.frob' does not depend on any axioms 'FrobChain.fermat' does not depend on any axioms 'FrobChain.C_values' does not depend on any axioms == QRChain.lean 'QRChain.add_left_cancel'' does not depend on any axioms 'QRChain.add_right_cancel'' does not depend on any axioms 'QRChain.le_of_add_le_add_left'' does not depend on any axioms 'QRChain.lt_of_add_lt_add_left'' does not depend on any axioms 'QRChain.add_sub_of_le'' does not depend on any axioms 'QRChain.lt_irrefl_of_le' does not depend on any axioms 'QRChain.eq_zero_of_add_eq_self' does not depend on any axioms 'QRChain.lt_of_le_of_ne'' does not depend on any axioms 'QRChain.par_add' does not depend on any axioms 'QRChain.par_mul' does not depend on any axioms 'QRChain.par_double' does not depend on any axioms 'QRChain.par_split' does not depend on any axioms 'QRChain.bx_self' does not depend on any axioms 'QRChain.bx_false' does not depend on any axioms 'QRChain.bx_comm' does not depend on any axioms 'QRChain.bx_assoc' does not depend on any axioms 'QRChain.sum1_ext' does not depend on any axioms 'QRChain.prod1_ext' does not depend on any axioms 'QRChain.sum1_add' does not depend on any axioms 'QRChain.sum1_mul_left' does not depend on any axioms 'QRChain.sum1_const' does not depend on any axioms 'QRChain.sum1_swap' does not depend on any axioms 'QRChain.prod1_mul' does not depend on any axioms 'QRChain.pow_add'' does not depend on any axioms 'QRChain.pow_mul'' does not depend on any axioms 'QRChain.prod1_const' does not depend on any axioms 'QRChain.prod1_pow' does not depend on any axioms 'QRChain.rem_of_lt' does not depend on any axioms 'QRChain.rem_lt'' does not depend on any axioms 'QRChain.rem_zero_of_dv' does not depend on any axioms 'QRChain.dv_of_rem_zero' does not depend on any axioms 'QRChain.rem_mul_left' does not depend on any axioms 'QRChain.rem_mul_congr' does not depend on any axioms 'QRChain.rem_mul_congr'' does not depend on any axioms 'QRChain.rem_mul_congr2' does not depend on any axioms 'QRChain.rem_add_congr'' does not depend on any axioms 'QRChain.rem_add_congr2' does not depend on any axioms 'QRChain.rem_pow_congr' does not depend on any axioms 'QRChain.rem_cancel_add' does not depend on any axioms 'QRChain.dv_of_rem_add' does not depend on any axioms 'QRChain.rem_add_dv' does not depend on any axioms 'QRChain.rem_prod1_congr' does not depend on any axioms 'QRChain.euclid' does not depend on any axioms 'QRChain.eq_zero_of_dv_lt' does not depend on any axioms 'QRChain.not_dv_of_lt' does not depend on any axioms 'QRChain.not_dv_prod1' does not depend on any axioms 'QRChain.cancel_core' does not depend on any axioms 'QRChain.rem_cancel_mul' does not depend on any axioms 'QRChain.allL_mono' does not depend on any axioms 'QRChain.qd_length' does not depend on any axioms 'QRChain.qd_spec' does not depend on any axioms 'QRChain.root_quot' does not depend on any axioms 'QRChain.roots_le_n' does not depend on any axioms 'QRChain.roots_le' does not depend on any axioms 'QRChain.h_pos' does not depend on any axioms 'QRChain.rem_one' does not depend on any axioms 'QRChain.hh_pos' does not depend on any axioms 'QRChain.fermat1' does not depend on any axioms 'QRChain.sq_pow' does not depend on any axioms 'QRChain.sq_one' does not depend on any axioms 'QRChain.euler_pm' does not depend on any axioms 'QRChain.euler_of_sq' does not depend on any axioms 'QRChain.tailL_length' does not depend on any axioms 'QRChain.ev_tailL' does not depend on any axioms 'QRChain.sqL_length' does not depend on any axioms 'QRChain.sqL_mem' does not depend on any axioms 'QRChain.sq_expand' does not depend on any axioms 'QRChain.lt_p_of_le_h' does not depend on any axioms 'QRChain.sq_distinct' does not depend on any axioms 'QRChain.sqL_nodup' does not depend on any axioms 'QRChain.root_of_pow' does not depend on any axioms 'QRChain.sq_search' does not depend on any axioms 'QRChain.euler_iff' does not depend on any axioms 'QRChain.memL_dec' does not depend on any axioms 'QRChain.eraseL_eq' does not depend on any axioms 'QRChain.eraseL_ne' does not depend on any axioms 'QRChain.erase_mem' does not depend on any axioms 'QRChain.erase_ne' does not depend on any axioms 'QRChain.erase_nodup' does not depend on any axioms 'QRChain.erase_count' does not depend on any axioms 'QRChain.erase_not_mem' does not depend on any axioms 'QRChain.perm_count' does not depend on any axioms 'QRChain.mkL_length' does not depend on any axioms 'QRChain.prodL_mkL' does not depend on any axioms 'QRChain.sumL_mkL' does not depend on any axioms 'QRChain.mkL_mem' does not depend on any axioms 'QRChain.mkL_nodup' does not depend on any axioms 'QRChain.perm_fun' does not depend on any axioms 'QRChain.dm_spec' does not depend on any axioms 'QRChain.fl_spec' does not depend on any axioms 'QRChain.fl_values' does not depend on any axioms 'QRChain.rk_cases' does not depend on any axioms 'QRChain.rk_pos' does not depend on any axioms 'QRChain.sk_bounds' does not depend on any axioms 'QRChain.rk_sign' does not depend on any axioms 'QRChain.rk_no_eq' does not depend on any axioms 'QRChain.rk_no_sum' does not depend on any axioms 'QRChain.sk_inj' does not depend on any axioms 'QRChain.neg_sq' does not depend on any axioms 'QRChain.neg_sq'' does not depend on any axioms 'QRChain.neg_pow_even' does not depend on any axioms 'QRChain.neg_pow_odd' does not depend on any axioms 'QRChain.gauss_pow' does not depend on any axioms 'QRChain.par_one_ne' does not depend on any axioms 'QRChain.gauss_lemma' does not depend on any axioms 'QRChain.bx_solve' does not depend on any axioms 'QRChain.beq_refl'' does not depend on any axioms 'QRChain.par_p' does not depend on any axioms 'QRChain.eisenstein_par' does not depend on any axioms 'QRChain.qr_by_floor' does not depend on any axioms 'QRChain.ltI_one' does not depend on any axioms 'QRChain.ltI_zero' does not depend on any axioms 'QRChain.ltI_add' does not depend on any axioms 'QRChain.count_low' does not depend on any axioms 'QRChain.count_high' does not depend on any axioms 'QRChain.fl_count' does not depend on any axioms 'QRChain.double_inj' does not depend on any axioms 'QRChain.not_dv_qx' does not depend on any axioms 'QRChain.fl_le' does not depend on any axioms 'QRChain.fl_as_count' does not depend on any axioms 'QRChain.lattice' does not depend on any axioms 'QRChain.or_true_cases' does not depend on any axioms 'QRChain.or_true_right' does not depend on any axioms 'QRChain.sqS_sound' does not depend on any axioms 'QRChain.sqS_complete' does not depend on any axioms 'QRChain.legB_iff' does not depend on any axioms 'QRChain.b_of_iff' does not depend on any axioms 'QRChain.qr_law' does not depend on any axioms 'QRChain.iff_bx' does not depend on any axioms 'QRChain.qr_law_iff' does not depend on any axioms 'QRChain.leg_values' does not depend on any axioms 'QRChain.qr_example' does not depend on any axioms == DefectChain.lean 'DefectChain.ceilHalf_even' does not depend on any axioms 'DefectChain.ceilHalf_odd' does not depend on any axioms 'DefectChain.l0_even' does not depend on any axioms 'DefectChain.l0_odd' does not depend on any axioms 'DefectChain.l0_values' does not depend on any axioms 'DefectChain.sum_C' does not depend on any axioms 'DefectChain.sum_C_long' does not depend on any axioms 'DefectChain.sum_pairs' does not depend on any axioms 'DefectChain.le_two_mul' does not depend on any axioms 'DefectChain.oddSum_succ' does not depend on any axioms 'DefectChain.evenSum_succ' does not depend on any axioms 'DefectChain.even_eq_odd' does not depend on any axioms 'DefectChain.even_odd_values' does not depend on any axioms 'DefectChain.C_symm_add' does not depend on any axioms 'DefectChain.add_sub_of_le''' does not depend on any axioms 'DefectChain.C_symm' does not depend on any axioms == ESChain.lean 'ESChain.modgo_spec' does not depend on any axioms 'ESChain.mod_decomp' does not depend on any axioms 'ESChain.rem_eq_mod' does not depend on any axioms 'ESChain.b2n_beq' does not depend on any axioms 'ESChain.sum_zero' does not depend on any axioms 'ESChain.sum_eqI' does not depend on any axioms 'ESChain.sum_const1' does not depend on any axioms 'ESChain.four_mul' does not depend on any axioms 'ESChain.odd_sq' does not depend on any axioms 'ESChain.not_dv_two' does not depend on any axioms 'ESChain.not_dv_four' does not depend on any axioms 'ESChain.root_iff' does not depend on any axioms 'ESChain.two_y_lt' does not depend on any axioms 'ESChain.roots_zero' does not depend on any axioms 'ESChain.leg_root' does not depend on any axioms 'ESChain.poly_root' does not depend on any axioms 'ESChain.at_most_two' does not depend on any axioms 'ESChain.partner' does not depend on any axioms 'ESChain.cnt_sq' does not depend on any axioms 'ESChain.sq_le_cube' does not depend on any axioms 'ESChain.cx_add' does not depend on any axioms 'ESChain.ite_iff' does not depend on any axioms 'ESChain.affE_eq' does not depend on any axioms 'ESChain.nE_formula' does not depend on any axioms 'ESChain.legV_cases' does not depend on any axioms 'ESChain.signed_point' does not depend on any axioms 'ESChain.nE_signed' does not depend on any axioms 'ESChain.affE_affC' does not depend on any axioms 'ESChain.ap_eq' does not depend on any axioms 'ESChain.primes200_def' does not depend on any axioms 'ESChain.map_congr'' does not depend on any axioms 'ESChain.modular_check_fast' does not depend on any axioms 'ESChain.modular_check' does not depend on any axioms == SimplexChain.lean 'SimplexChain.par_dbl' does not depend on any axioms 'SimplexChain.par_dbl1' does not depend on any axioms 'SimplexChain.par_cases' does not depend on any axioms 'SimplexChain.sum_tail_zero' does not depend on any axioms 'SimplexChain.tail_C' does not depend on any axioms 'SimplexChain.evenSum_w' does not depend on any axioms 'SimplexChain.oddSum_w' does not depend on any axioms 'SimplexChain.w_succ' does not depend on any axioms 'SimplexChain.v_succ' does not depend on any axioms 'SimplexChain.add_right_cancel'' does not depend on any axioms 'SimplexChain.euler_char' does not depend on any axioms 'SimplexChain.euler_odd' does not depend on any axioms 'SimplexChain.euler_even' does not depend on any axioms 'SimplexChain.fvec5' does not depend on any axioms 'SimplexChain.chi5' does not depend on any axioms 'SimplexChain.C_succ_self' does not depend on any axioms 'SimplexChain.cofaces_eq' does not depend on any axioms 'SimplexChain.triangle5' does not depend on any axioms == SMChain.lean 'SMChain.su_dims' does not depend on any axioms 'SMChain.gauge_dim' does not depend on any axioms 'SMChain.g2_minus_s6' does not depend on any axioms 'SMChain.charge_mult' does not depend on any axioms 'SMChain.charge_total' does not depend on any axioms 'SMChain.charge_total_8' does not depend on any axioms 'SMChain.anomaly_linear' does not depend on any axioms 'SMChain.anomaly_cubic' does not depend on any axioms 'SMChain.anomaly_su3' does not depend on any axioms 'SMChain.anomaly_su2' does not depend on any axioms == HeckeChain.lean 'HeckeChain.add_zero'' does not depend on any axioms 'HeckeChain.one_mul'' does not depend on any axioms 'HeckeChain.right_distrib'' does not depend on any axioms 'HeckeChain.sumR_ext' does not depend on any axioms 'HeckeChain.sumR_shift' does not depend on any axioms 'HeckeChain.mul_sumR' does not depend on any axioms 'HeckeChain.s_succ' does not depend on any axioms 'HeckeChain.hecke_rec' does not depend on any axioms 'HeckeChain.hecke_rec_nat' does not depend on any axioms 'HeckeChain.s_nat_values' does not depend on any axioms 'HeckeChain.e3_eq' does not depend on any axioms 'HeckeChain.step6' does not depend on any axioms 'HeckeChain.step9' does not depend on any axioms 'HeckeChain.step12' does not depend on any axioms 'HeckeChain.step15' does not depend on any axioms 'HeckeChain.step18' does not depend on any axioms 'HeckeChain.step21' does not depend on any axioms 'HeckeChain.step24' does not depend on any axioms 'HeckeChain.deltaList_eq' does not depend on any axioms 'HeckeChain.tau_values' does not depend on any axioms 'HeckeChain.tau_mult' does not depend on any axioms 'HeckeChain.tau_hecke' does not depend on any axioms 'HeckeChain.tau_ramanujan' does not depend on any axioms 'HeckeChain.a11List_eq' does not depend on any axioms 'HeckeChain.a11_values' does not depend on any axioms 'HeckeChain.a11_mult' does not depend on any axioms 'HeckeChain.a11_hecke' does not depend on any axioms 'HeckeChain.a11_ramanujan' does not depend on any axioms == NonAbChain.lean 'NonAbChain.perms_list' does not depend on any axioms 'NonAbChain.fix_values' does not depend on any axioms 'NonAbChain.chi_values' does not depend on any axioms 'NonAbChain.inv_check' does not depend on any axioms 'NonAbChain.comp_check' does not depend on any axioms 'NonAbChain.chi_class' does not depend on any axioms 'NonAbChain.chi_norm' does not depend on any axioms 'NonAbChain.noncomm_bool' does not depend on any axioms 'NonAbChain.noncomm' does not depend on any axioms 'NonAbChain.a23List_eq' does not depend on any axioms 'NonAbChain.a23_values' does not depend on any axioms 'NonAbChain.r_values' does not depend on any axioms 'NonAbChain.primesNo23_length' does not depend on any axioms 'NonAbChain.ap_eq_rp' does not depend on any axioms 'NonAbChain.rp_013' does not depend on any axioms == FluidChain.lean 'FluidChain.nat_beq_self' does not depend on any axioms 'FluidChain.ne_of_beq_false' does not depend on any axioms 'FluidChain.and_true_l' does not depend on any axioms 'FluidChain.and_true_r' does not depend on any axioms 'FluidChain.one_dim_id_or_swp' does not depend on any axioms 'FluidChain.msets_count' does not depend on any axioms 'FluidChain.allP_filt' does not depend on any axioms 'FluidChain.headOr_P' does not depend on any axioms 'FluidChain.nextAfter_P' does not depend on any axioms 'FluidChain.sameClass_self' does not depend on any axioms 'FluidChain.cellColl_class' does not depend on any axioms 'FluidChain.cons_mass' does not depend on any axioms 'FluidChain.cons_mx' does not depend on any axioms 'FluidChain.cons_my' does not depend on any axioms 'FluidChain.cons_en' does not depend on any axioms 'FluidChain.coll_examples' does not depend on any axioms 'FluidChain.lsum_ext' does not depend on any axioms 'FluidChain.lsum_add' does not depend on any axioms 'FluidChain.lsum_map' does not depend on any axioms 'FluidChain.lsum_append' does not depend on any axioms 'FluidChain.lsum_ins' does not depend on any axioms 'FluidChain.lsum_isort' does not depend on any axioms 'FluidChain.atC_same' does not depend on any axioms 'FluidChain.emit_sum' does not depend on any axioms 'FluidChain.run_sum' does not depend on any axioms 'FluidChain.collideAll_sum' does not depend on any axioms 'FluidChain.sameCell_refl' does not depend on any axioms 'FluidChain.collideAll_total' does not depend on any axioms 'FluidChain.step_conserves' does not depend on any axioms 'FluidChain.iter_conserves' does not depend on any axioms 'FluidChain.number_conserved' does not depend on any axioms 'FluidChain.momentum_x_conserved' does not depend on any axioms 'FluidChain.momentum_y_conserved' does not depend on any axioms 'FluidChain.energy_conserved' does not depend on any axioms 'FluidChain.ind_balance' does not depend on any axioms 'FluidChain.stream_balance' does not depend on any axioms 'FluidChain.collideAll_cell' does not depend on any axioms 'FluidChain.isort_cell' does not depend on any axioms 'FluidChain.cell_step' does not depend on any axioms 'FluidChain.cell_telescope' does not depend on any axioms 'FluidChain.continuity' does not depend on any axioms 'FluidChain.momentum_x' does not depend on any axioms 'FluidChain.momentum_y' does not depend on any axioms 'FluidChain.energy_cell' does not depend on any axioms 'FluidChain.demo_run' does not depend on any axioms 'FluidChain.demo_final' does not depend on any axioms == YMChain.lean 'YMChain.cancel_left' does not depend on any axioms 'YMChain.inv_unique' does not depend on any axioms 'YMChain.inv_mul_rev' does not depend on any axioms 'YMChain.inv_inv' does not depend on any axioms 'YMChain.conj_mul' does not depend on any axioms 'YMChain.conj_inv' does not depend on any axioms 'YMChain.hol_gauge' does not depend on any axioms 'YMChain.gauge_inverse' does not depend on any axioms 'YMChain.lsum_ext' does not depend on any axioms 'YMChain.action_gauge_inv' does not depend on any axioms 'YMChain.weight_gauge_inv' does not depend on any axioms 'YMChain.torus_comm' does not depend on any axioms 'YMChain.sites_length' does not depend on any axioms 'YMChain.torus_action_gauge_inv' does not depend on any axioms 'YMChain.q8_assoc' does not depend on any axioms 'YMChain.q8_one_mul' does not depend on any axioms 'YMChain.q8_mul_one' does not depend on any axioms 'YMChain.q8_inv_mul' does not depend on any axioms 'YMChain.q8_mul_inv' does not depend on any axioms 'YMChain.mul_is_quaternion' does not depend on any axioms 'YMChain.unit_norm' does not depend on any axioms 'YMChain.q8_noncomm' does not depend on any axioms 'YMChain.defect_class' does not depend on any axioms 'YMChain.wilson_class' does not depend on any axioms 'YMChain.regroup' does not depend on any axioms 'YMChain.interaction' does not depend on any axioms 'YMChain.factor_sum' does not depend on any axioms 'YMChain.sumK_ext' does not depend on any axioms 'YMChain.sumK_add' does not depend on any axioms 'YMChain.mul_sumK' does not depend on any axioms 'YMChain.sumK_mul' does not depend on any axioms 'YMChain.sumK_swap' does not depend on any axioms 'YMChain.rearr' does not depend on any axioms 'YMChain.rp_identity' does not depend on any axioms 'YMChain.sumK_nn' does not depend on any axioms 'YMChain.sumK_nn_list' does not depend on any axioms 'YMChain.rp_nonneg' does not depend on any axioms 'YMChain.sumK_append' does not depend on any axioms 'YMChain.sumK_map' does not depend on any axioms 'YMChain.mul_mid4' does not depend on any axioms 'YMChain.rearr2' does not depend on any axioms 'YMChain.gram_mul' does not depend on any axioms 'YMChain.gram_mul_nn' does not depend on any axioms 'YMChain.delta_gram' does not depend on any axioms 'YMChain.defect_gram' does not depend on any axioms 'YMChain.pow_pos'' does not depend on any axioms 'YMChain.transfer_pos' does not depend on any axioms 'YMChain.len_app2' does not depend on any axioms 'YMChain.len_map2' does not depend on any axioms 'YMChain.consAll_length' does not depend on any axioms 'YMChain.words_length' does not depend on any axioms 'YMChain.surface_count' does not depend on any axioms 'YMChain.geom_telescope' does not depend on any axioms 'YMChain.le_cancel' does not depend on any axioms 'YMChain.geom_bound' does not depend on any axioms 'YMChain.decay_bound' does not depend on any axioms 'YMChain.c_441' does not depend on any axioms 'YMChain.mul_pow'' does not depend on any axioms 'YMChain.gap_explicit' does not depend on any axioms 'YMChain.argmin' does not depend on any axioms 'YMChain.sum_zero_each' does not depend on any axioms 'YMChain.sumK_sub' does not depend on any axioms 'YMChain.mul_neg_r' does not depend on any axioms 'YMChain.swap3' does not depend on any axioms 'YMChain.perron_simple' does not depend on any axioms 'YMChain.sum_le' does not depend on any axioms 'YMChain.abs_sum' does not depend on any axioms 'YMChain.argmax' does not depend on any axioms 'YMChain.perron_dominant' does not depend on any axioms 'YMChain.pos_sum' does not depend on any axioms 'YMChain.sq_eigen' does not depend on any axioms 'YMChain.perron_gap' does not depend on any axioms 'YMChain.ker_symm' does not depend on any axioms 'YMChain.sh2_comm' does not depend on any axioms 'YMChain.block_gauge' does not depend on any axioms 'YMChain.block_weight_pos' does not depend on any axioms 'YMChain.block_rp' does not depend on any axioms 'YMChain.doeblin' does not depend on any axioms 'YMChain.pow_add_nat' does not depend on any axioms 'YMChain.pow_mul_nat' does not depend on any axioms 'YMChain.block_decay' does not depend on any axioms 'YMChain.block_decay_explicit' does not depend on any axioms == KineticChain.lean 'KineticChain.sumL_ext' does not depend on any axioms 'KineticChain.sumL_add' does not depend on any axioms 'KineticChain.sumL_mul' does not depend on any axioms 'KineticChain.sumL_cmul' does not depend on any axioms 'KineticChain.sumL_swap' does not depend on any axioms 'KineticChain.gate_mul' does not depend on any axioms 'KineticChain.gate_and_false' does not depend on any axioms 'KineticChain.c3Eq_sound' does not depend on any axioms 'KineticChain.c3Eq_refl' does not depend on any axioms 'KineticChain.vEq_sound' does not depend on any axioms 'KineticChain.vEq_refl' does not depend on any axioms 'KineticChain.lEq_sound' does not depend on any axioms 'KineticChain.lEq_refl' does not depend on any axioms 'KineticChain.llEq_sound' does not depend on any axioms 'KineticChain.or_false_l' does not depend on any axioms 'KineticChain.fiber_zero' does not depend on any axioms 'KineticChain.fiber' does not depend on any axioms 'KineticChain.cnt_ins' does not depend on any axioms 'KineticChain.cnt_sort' does not depend on any axioms 'KineticChain.pairs2_nodup' does not depend on any axioms 'KineticChain.pairs2_mem' does not depend on any axioms 'KineticChain.cc_nil' does not depend on any axioms 'KineticChain.cc_single' does not depend on any axioms 'KineticChain.same_velocity_no_coll' does not depend on any axioms 'KineticChain.pair_world' does not depend on any axioms 'KineticChain.gate_true' does not depend on any axioms 'KineticChain.gate_false' does not depend on any axioms 'KineticChain.single_not_pair' does not depend on any axioms 'KineticChain.world_identity' does not depend on any axioms 'KineticChain.gain2_eq' does not depend on any axioms 'KineticChain.loss2_eq' does not depend on any axioms 'KineticChain.hierarchy' does not depend on any axioms 'KineticChain.g3_zero' does not depend on any axioms 'KineticChain.l3_zero' does not depend on any axioms 'KineticChain.hierarchy_dilute' does not depend on any axioms 'KineticChain.chaos_product' does not depend on any axioms 'KineticChain.chaos_not_kept' does not depend on any axioms 'KineticChain.sumR_ins' does not depend on any axioms 'KineticChain.sumR_sort' does not depend on any axioms 'KineticChain.sumR_map' does not depend on any axioms 'KineticChain.sumR_ext' does not depend on any axioms 'KineticChain.pairs2_lit' does not depend on any axioms 'KineticChain.map_lit' does not depend on any axioms 'KineticChain.pairs_perm' does not depend on any axioms 'KineticChain.sum_perm' does not depend on any axioms 'KineticChain.balance' does not depend on any axioms 'KineticChain.memV_all' does not depend on any axioms 'KineticChain.fiber_zeroV' does not depend on any axioms 'KineticChain.fiberV2' does not depend on any axioms 'KineticChain.gate_ind' does not depend on any axioms 'KineticChain.pick' does not depend on any axioms 'KineticChain.moment_cell' does not depend on any axioms 'KineticChain.moments_exact' does not depend on any axioms 'KineticChain.moments_closed' does not depend on any axioms == ClosureChain.lean 'ClosureChain.vsum_add' does not depend on any axioms 'ClosureChain.vsum_ext' does not depend on any axioms 'ClosureChain.regroup5' does not depend on any axioms 'ClosureChain.offDiag_full' does not depend on any axioms 'ClosureChain.vsum_counts' does not depend on any axioms 'ClosureChain.pair_counting' does not depend on any axioms 'ClosureChain.diag_gain_loss' does not depend on any axioms 'ClosureChain.kac_hierarchy' does not depend on any axioms 'ClosureChain.mul_right_comm''' does not depend on any axioms 'ClosureChain.rearr4' does not depend on any axioms 'ClosureChain.tagged_product' does not depend on any axioms 'ClosureChain.enc_complement' does not depend on any axioms 'ClosureChain.enc_bound' does not depend on any axioms 'ClosureChain.mul_right_comm'' does not depend on any axioms 'ClosureChain.W_ratio' does not depend on any axioms 'ClosureChain.lt_irrefl'' does not depend on any axioms 'ClosureChain.W_compare' does not depend on any axioms 'ClosureChain.lt_succ_prod' does not depend on any axioms 'ClosureChain.pos_mul' does not depend on any axioms 'ClosureChain.fact_pos' does not depend on any axioms 'ClosureChain.no_increase_at_balance' does not depend on any axioms 'ClosureChain.pressure_half' does not depend on any axioms == DetChain.lean 'DetChain.add_zero'' does not depend on any axioms 'DetChain.add_cancel_left' does not depend on any axioms 'DetChain.right_distrib' does not depend on any axioms 'DetChain.mul_zero' does not depend on any axioms 'DetChain.zero_mul'' does not depend on any axioms 'DetChain.neg_unique' does not depend on any axioms 'DetChain.neg_mul_left' does not depend on any axioms 'DetChain.neg_neg'' does not depend on any axioms 'DetChain.add_neg'' does not depend on any axioms 'DetChain.add_mid4' does not depend on any axioms 'DetChain.inj1' does not depend on any axioms 'DetChain.inj1'' does not depend on any axioms 'DetChain.adj2_left' does not depend on any axioms 'DetChain.adj2_right' does not depend on any axioms 'DetChain.inj2' does not depend on any axioms 'DetChain.koszul1_exact' does not depend on any axioms 'DetChain.koszul2_complex' does not depend on any axioms 'DetChain.koszul2_H2' does not depend on any axioms 'DetChain.koszul2_H1' does not depend on any axioms == DetNChain.lean 'DetN.app_nil'' does not depend on any axioms 'DetN.app_assoc'' does not depend on any axioms 'DetN.map_app'' does not depend on any axioms 'DetN.len_app'' does not depend on any axioms 'DetN.len_map'' does not depend on any axioms 'DetN.neg_zero'' does not depend on any axioms 'DetN.neg_add'' does not depend on any axioms 'DetN.mul_neg'' does not depend on any axioms 'DetN.sgn_zero' does not depend on any axioms 'DetN.sgn_add' does not depend on any axioms 'DetN.sgn_mul' does not depend on any axioms 'DetN.det_succ' does not depend on any axioms 'DetN.lapS_split' does not depend on any axioms 'DetN.len_fix' does not depend on any axioms 'DetN.lapS_vanish' does not depend on any axioms 'DetN.reshape2' does not depend on any axioms 'DetN.det_adj' does not depend on any axioms 'DetN.len_step' does not depend on any axioms 'DetN.len_col' does not depend on any axioms 'DetN.lin_comb' does not depend on any axioms 'DetN.lin_zero' does not depend on any axioms 'DetN.swap_mul' does not depend on any axioms 'DetN.term_lin' does not depend on any axioms 'DetN.term_col' does not depend on any axioms 'DetN.lapS_lin_suf' does not depend on any axioms 'DetN.lapS_lin_pre' does not depend on any axioms 'DetN.det_lin' does not depend on any axioms 'DetN.peq_refl' does not depend on any axioms 'DetN.peq_app' does not depend on any axioms 'DetN.peq_map' does not depend on any axioms 'DetN.peq_len' does not depend on any axioms 'DetN.lapS_congr' does not depend on any axioms 'DetN.det_congr' does not depend on any axioms 'DetN.det_zero_col' does not depend on any axioms 'DetN.swap_alg' does not depend on any axioms 'DetN.det_swap' does not depend on any axioms 'DetN.det_eq_cols' does not depend on any axioms 'DetN.det_comb' does not depend on any axioms 'DetN.sumC_app' does not depend on any axioms 'DetN.sum_in_P' does not depend on any axioms 'DetN.sum_in_Q' does not depend on any axioms 'DetN.kernel_trivial' does not depend on any axioms == FiniteRecChain.lean 'FiniteRecChain.ite_pos'' does not depend on any axioms 'FiniteRecChain.ite_neg'' does not depend on any axioms 'FiniteRecChain.delta_symm' does not depend on any axioms 'FiniteRecChain.delta_mul' does not depend on any axioms 'FiniteRecChain.delta_sum' does not depend on any axioms 'FiniteRecChain.pick' does not depend on any axioms 'FiniteRecChain.reindex' does not depend on any axioms 'FiniteRecChain.conj_conj' does not depend on any axioms 'FiniteRecChain.ind_class' does not depend on any axioms 'FiniteRecChain.conj_inv_conj' does not depend on any axioms 'FiniteRecChain.frobenius' does not depend on any axioms == BridgeChain.lean 'BridgeChain.sq_diff' does not depend on any axioms 'BridgeChain.double_sum' does not depend on any axioms 'BridgeChain.lagrange' does not depend on any axioms 'BridgeChain.zero_le_sum' does not depend on any axioms 'BridgeChain.add_le_cancel' does not depend on any axioms 'BridgeChain.variance_nonneg' does not depend on any axioms 'BridgeChain.sq_le_self' does not depend on any axioms 'BridgeChain.iter4_bounds' does not depend on any axioms 'BridgeChain.iter4_contract' does not depend on any axioms == KoszulRangeChain.lean 'KoszulRangeChain.range1_iff' does not depend on any axioms 'KoszulRangeChain.range2_of_regular' does not depend on any axioms 'KoszulRangeChain.regular_of_range2' does not depend on any axioms 'KoszulRangeChain.range2_iff' does not depend on any axioms == NSChain.lean 'NSChain.sumN_add' does not depend on any axioms 'NSChain.sumN_zero' does not depend on any axioms 'NSChain.sumN_ext' does not depend on any axioms 'NSChain.sumN_neg' does not depend on any axioms 'NSChain.sumN_mul_left' does not depend on any axioms 'NSChain.telescope' does not depend on any axioms 'NSChain.mul_neg'' does not depend on any axioms 'NSChain.dyadic_term' does not depend on any axioms 'NSChain.dyadic_energy_neutral' does not depend on any axioms 'NSChain.lsum_add' does not depend on any axioms 'NSChain.lsum_ext' does not depend on any axioms 'NSChain.lsum_zero' does not depend on any axioms 'NSChain.lsum_neg' does not depend on any axioms 'NSChain.lsum_mul_left' does not depend on any axioms 'NSChain.double_antisym' does not depend on any axioms 'NSChain.galerkin_neutral' does not depend on any axioms 'NSChain.sq_diff' does not depend on any axioms 'NSChain.cn_energy' does not depend on any axioms 'NSChain.le_refl'' does not depend on any axioms 'NSChain.le_trans'' does not depend on any axioms 'NSChain.sumN_nn' does not depend on any axioms 'NSChain.sq_sum_nonneg' does not depend on any axioms 'NSChain.dissipation_nonneg' does not depend on any axioms 'NSChain.cn_decreasing' does not depend on any axioms 'NSChain.mode_le_energy' does not depend on any axioms 'NSChain.cn_global' does not depend on any axioms 'NSChain.degiorgi_iteration' does not depend on any axioms 'NSChain.dyadic_example' does not depend on any axioms == BSDChain.lean 'BSDChain.legV_le_two' does not depend on any axioms 'BSDChain.sum_le_two' does not depend on any axioms 'BSDChain.nE_upper' does not depend on any axioms 'BSDChain.nE_lower' does not depend on any axioms 'BSDChain.trivial_bound' does not depend on any axioms 'BSDChain.hasse_check' does not depend on any axioms 'BSDChain.ap_table' does not depend on any axioms 'BSDChain.Z3.add_assoc' does not depend on any axioms 'BSDChain.Z3.distrib' does not depend on any axioms 'BSDChain.r3_add' does not depend on any axioms 'BSDChain.r3_mul' does not depend on any axioms 'BSDChain.r3_spec' does not depend on any axioms 'BSDChain.three_dvd' does not depend on any axioms 'BSDChain.r3_sq' does not depend on any axioms 'BSDChain.r3_q4' does not depend on any axioms 'BSDChain.mul_mul_mul' does not depend on any axioms 'BSDChain.sq_three' does not depend on any axioms 'BSDChain.q4_three' does not depend on any axioms 'BSDChain.cancel3' does not depend on any axioms 'BSDChain.cancel9' does not depend on any axioms 'BSDChain.H1' does not depend on any axioms 'BSDChain.H2' does not depend on any axioms 'BSDChain.H3' does not depend on any axioms 'BSDChain.H4' does not depend on any axioms 'BSDChain.H5' does not depend on any axioms 'BSDChain.desc6' does not depend on any axioms 'BSDChain.desc3' does not depend on any axioms 'BSDChain.desc2' does not depend on any axioms 'BSDChain.real_insoluble' does not depend on any axioms 'BSDChain.points_E' does not depend on any axioms == HodgeChain.lean 'HodgeChain.dv_between' does not depend on any axioms 'HodgeChain.paired_sum' does not depend on any axioms 'HodgeChain.count_3_2' does not depend on any axioms 'HodgeChain.count_4_2' does not depend on any axioms 'HodgeChain.count_5_2' does not depend on any axioms 'HodgeChain.count_6_2' does not depend on any axioms 'HodgeChain.count_7_2' does not depend on any axioms 'HodgeChain.count_3_4' does not depend on any axioms 'HodgeChain.count_4_4' does not depend on any axioms 'HodgeChain.count_5_4' does not depend on any axioms == ns/DyadicHs.lean 'DyadicHs.neg_add'' does not depend on any axioms 'DyadicHs.abel_step' does not depend on any axioms 'DyadicHs.abel' does not depend on any axioms 'DyadicHs.weighted_flux' does not depend on any axioms 'DyadicHs.sumN_shift' does not depend on any axioms 'DyadicHs.hs_rate' does not depend on any axioms 'DyadicHs.small_data' does not depend on any axioms 'DyadicHs.small_data_check' does not depend on any axioms == bsd/Zeta2.lean 'Zeta2.zeta2_11a' does not depend on any axioms 'Zeta2.zeta2_37a' does not depend on any axioms == bsd/HasseDeg.lean 'HasseDeg.mul_two' does not depend on any axioms 'HasseDeg.neg_add2' does not depend on any axioms 'HasseDeg.form_at_a_two' does not depend on any axioms 'HasseDeg.hasse_from_deg' does not depend on any axioms == hodge/FermatPrime.lean 'FermatPrime.rdistrib' does not depend on any axioms 'FermatPrime.sum_scale' does not depend on any axioms 'FermatPrime.sum_swap' does not depend on any axioms 'FermatPrime.sum_indicator' does not depend on any axioms 'FermatPrime.dot_lsum' does not depend on any axioms 'FermatPrime.dot_add_scale' does not depend on any axioms 'FermatPrime.combine' does not depend on any axioms 'FermatPrime.cancel_l' does not depend on any axioms 'FermatPrime.extract' does not depend on any axioms 'FermatPrime.and_left' does not depend on any axioms 'FermatPrime.and_right' does not depend on any axioms 'FermatPrime.all_range' does not depend on any axioms 'FermatPrime.beq_eq' does not depend on any axioms 'FermatPrime.paired_one' does not depend on any axioms 'FermatPrime.paired_3' does not depend on any axioms 'FermatPrime.paired_5' does not depend on any axioms 'FermatPrime.cert7_0' does not depend on any axioms 'FermatPrime.cert7_1' does not depend on any axioms 'FermatPrime.cert7_2' does not depend on any axioms 'FermatPrime.paired_7' does not depend on any axioms 'FermatPrime.cert11_0' does not depend on any axioms 'FermatPrime.cert11_1' does not depend on any axioms 'FermatPrime.cert11_2' does not depend on any axioms 'FermatPrime.cert11_3' does not depend on any axioms 'FermatPrime.cert11_4' does not depend on any axioms 'FermatPrime.paired_11' does not depend on any axioms 'FermatPrime.cert13_0' does not depend on any axioms 'FermatPrime.cert13_1' does not depend on any axioms 'FermatPrime.cert13_2' does not depend on any axioms 'FermatPrime.cert13_3' does not depend on any axioms 'FermatPrime.cert13_4' does not depend on any axioms 'FermatPrime.cert13_5' does not depend on any axioms 'FermatPrime.paired_13' does not depend on any axioms == ns/DyadicLarge.lean 'DyadicLarge.le_add'' does not depend on any axioms 'DyadicLarge.le_mul_nn' does not depend on any axioms 'DyadicLarge.le_of_nn_add' does not depend on any axioms 'DyadicLarge.le_zero_add' does not depend on any axioms 'DyadicLarge.sum_le' does not depend on any axioms 'DyadicLarge.shell_bound' does not depend on any axioms 'DyadicLarge.flux_eq' does not depend on any axioms 'DyadicLarge.rate_bound' does not depend on any axioms 'DyadicLarge.head_stable' does not depend on any axioms == bsd/CountGeneral.lean 'CountGeneral.affG_eq' does not depend on any axioms 'CountGeneral.shift_mul' does not depend on any axioms 'CountGeneral.count_general' does not depend on any axioms 'CountGeneral.count_37a' does not depend on any axioms 'CountGeneral.count_389a' does not depend on any axioms 'CountGeneral.count_5077a' does not depend on any axioms == hodge/FermatFull.lean 'FermatFull.sum_zero''' does not depend on any axioms 'FermatFull.regroup' does not depend on any axioms 'FermatFull.combine1' does not depend on any axioms 'FermatFull.extract1' does not depend on any axioms 'FermatFull.pair_one' does not depend on any axioms 'FermatFull.certF3_0' does not depend on any axioms 'FermatFull.paired_char_3' does not depend on any axioms 'FermatFull.certF5_0' does not depend on any axioms 'FermatFull.certF5_1' does not depend on any axioms 'FermatFull.paired_char_5' does not depend on any axioms 'FermatFull.certF7_0' does not depend on any axioms 'FermatFull.certF7_1' does not depend on any axioms 'FermatFull.certF7_2' does not depend on any axioms 'FermatFull.paired_char_7' does not depend on any axioms 'FermatFull.certF11_0' does not depend on any axioms 'FermatFull.certF11_1' does not depend on any axioms 'FermatFull.certF11_2' does not depend on any axioms 'FermatFull.certF11_3' does not depend on any axioms 'FermatFull.certF11_4' does not depend on any axioms 'FermatFull.paired_char_11' does not depend on any axioms 'FermatFull.certF13_0' does not depend on any axioms 'FermatFull.certF13_1' does not depend on any axioms 'FermatFull.certF13_2' does not depend on any axioms 'FermatFull.certF13_3' does not depend on any axioms 'FermatFull.certF13_4' does not depend on any axioms 'FermatFull.certF13_5' does not depend on any axioms 'FermatFull.paired_char_13' does not depend on any axioms == bsd/CountModel.lean 'CountModel.sum_front' does not depend on any axioms 'CountModel.rot_one' does not depend on any axioms 'CountModel.rem_rem_add' does not depend on any axioms 'CountModel.sum_rem' does not depend on any axioms 'CountModel.rot' does not depend on any axioms 'CountModel.sqS_congr' does not depend on any axioms 'CountModel.legV_congr' does not depend on any axioms 'CountModel.succ_add_succ' does not depend on any axioms 'CountModel.two_inv_eq' does not depend on any axioms 'CountModel.two_inv' does not depend on any axioms 'CountModel.shift_square' does not depend on any axioms 'CountModel.cntB_eq' does not depend on any axioms 'CountModel.count_model' does not depend on any axioms 'CountModel.count_14a' does not depend on any axioms == ns/FourierGalerkin.lean 'FourierGalerkin.dot3_add' does not depend on any axioms 'FourierGalerkin.dot3_neg' does not depend on any axioms 'FourierGalerkin.dot3_comm' does not depend on any axioms 'FourierGalerkin.lsum_swap' does not depend on any axioms 'FourierGalerkin.triad_zero' does not depend on any axioms 'FourierGalerkin.antisym' does not depend on any axioms 'FourierGalerkin.neutral' does not depend on any axioms == bsd/CongruentDescent.lean 'CongruentDescent.mul4' does not depend on any axioms 'CongruentDescent.nonres_dv' does not depend on any axioms 'CongruentDescent.neg1_nonres' does not depend on any axioms 'CongruentDescent.dv_sq' does not depend on any axioms 'CongruentDescent.dv_q4' does not depend on any axioms 'CongruentDescent.not_dv_two' does not depend on any axioms 'CongruentDescent.cancel_square' does not depend on any axioms 'CongruentDescent.shift_neg' does not depend on any axioms 'CongruentDescent.desc_p' does not depend on any axioms 'CongruentDescent.desc_2p' does not depend on any axioms == hodge/FermatPrimes2.lean 'FermatPrimes2.certF17_0' does not depend on any axioms 'FermatPrimes2.certF17_1' does not depend on any axioms 'FermatPrimes2.certF17_2' does not depend on any axioms 'FermatPrimes2.certF17_3' does not depend on any axioms 'FermatPrimes2.certF17_4' does not depend on any axioms 'FermatPrimes2.certF17_5' does not depend on any axioms 'FermatPrimes2.certF17_6' does not depend on any axioms 'FermatPrimes2.certF17_7' does not depend on any axioms 'FermatPrimes2.paired_char_17' does not depend on any axioms 'FermatPrimes2.certF19_0' does not depend on any axioms 'FermatPrimes2.certF19_1' does not depend on any axioms 'FermatPrimes2.certF19_2' does not depend on any axioms 'FermatPrimes2.certF19_3' does not depend on any axioms 'FermatPrimes2.certF19_4' does not depend on any axioms 'FermatPrimes2.certF19_5' does not depend on any axioms 'FermatPrimes2.certF19_6' does not depend on any axioms 'FermatPrimes2.certF19_7' does not depend on any axioms 'FermatPrimes2.certF19_8' does not depend on any axioms 'FermatPrimes2.paired_char_19' does not depend on any axioms 'FermatPrimes2.certF23_0' does not depend on any axioms 'FermatPrimes2.certF23_1' does not depend on any axioms 'FermatPrimes2.certF23_2' does not depend on any axioms 'FermatPrimes2.certF23_3' does not depend on any axioms 'FermatPrimes2.certF23_4' does not depend on any axioms 'FermatPrimes2.certF23_5' does not depend on any axioms 'FermatPrimes2.certF23_6' does not depend on any axioms 'FermatPrimes2.certF23_7' does not depend on any axioms 'FermatPrimes2.certF23_8' does not depend on any axioms 'FermatPrimes2.certF23_9' does not depend on any axioms 'FermatPrimes2.certF23_10' does not depend on any axioms 'FermatPrimes2.paired_char_23' does not depend on any axioms 'FermatPrimes2.certF29_0' does not depend on any axioms 'FermatPrimes2.certF29_1' does not depend on any axioms 'FermatPrimes2.certF29_2' does not depend on any axioms 'FermatPrimes2.certF29_3' does not depend on any axioms 'FermatPrimes2.certF29_4' does not depend on any axioms 'FermatPrimes2.certF29_5' does not depend on any axioms 'FermatPrimes2.certF29_6' does not depend on any axioms 'FermatPrimes2.certF29_7' does not depend on any axioms 'FermatPrimes2.certF29_8' does not depend on any axioms 'FermatPrimes2.certF29_9' does not depend on any axioms 'FermatPrimes2.certF29_10' does not depend on any axioms 'FermatPrimes2.certF29_11' does not depend on any axioms 'FermatPrimes2.certF29_12' does not depend on any axioms 'FermatPrimes2.certF29_13' does not depend on any axioms 'FermatPrimes2.paired_char_29' does not depend on any axioms 'FermatPrimes2.certF31_0' does not depend on any axioms 'FermatPrimes2.certF31_1' does not depend on any axioms 'FermatPrimes2.certF31_2' does not depend on any axioms 'FermatPrimes2.certF31_3' does not depend on any axioms 'FermatPrimes2.certF31_4' does not depend on any axioms 'FermatPrimes2.certF31_5' does not depend on any axioms 'FermatPrimes2.certF31_6' does not depend on any axioms 'FermatPrimes2.certF31_7' does not depend on any axioms 'FermatPrimes2.certF31_8' does not depend on any axioms 'FermatPrimes2.certF31_9' does not depend on any axioms 'FermatPrimes2.certF31_10' does not depend on any axioms 'FermatPrimes2.certF31_11' does not depend on any axioms 'FermatPrimes2.certF31_12' does not depend on any axioms 'FermatPrimes2.certF31_13' does not depend on any axioms 'FermatPrimes2.certF31_14' does not depend on any axioms 'FermatPrimes2.paired_char_31' does not depend on any axioms 'FermatPrimes2.certF37_0' does not depend on any axioms 'FermatPrimes2.certF37_1' does not depend on any axioms 'FermatPrimes2.certF37_2' does not depend on any axioms 'FermatPrimes2.certF37_3' does not depend on any axioms 'FermatPrimes2.certF37_4' does not depend on any axioms 'FermatPrimes2.certF37_5' does not depend on any axioms 'FermatPrimes2.certF37_6' does not depend on any axioms 'FermatPrimes2.certF37_7' does not depend on any axioms 'FermatPrimes2.certF37_8' does not depend on any axioms 'FermatPrimes2.certF37_9' does not depend on any axioms 'FermatPrimes2.certF37_10' does not depend on any axioms 'FermatPrimes2.certF37_11' does not depend on any axioms 'FermatPrimes2.certF37_12' does not depend on any axioms 'FermatPrimes2.certF37_13' does not depend on any axioms 'FermatPrimes2.certF37_14' does not depend on any axioms 'FermatPrimes2.certF37_15' does not depend on any axioms 'FermatPrimes2.certF37_16' does not depend on any axioms 'FermatPrimes2.certF37_17' does not depend on any axioms 'FermatPrimes2.paired_char_37' does not depend on any axioms 'FermatPrimes2.certF41_0' does not depend on any axioms 'FermatPrimes2.certF41_1' does not depend on any axioms 'FermatPrimes2.certF41_2' does not depend on any axioms 'FermatPrimes2.certF41_3' does not depend on any axioms 'FermatPrimes2.certF41_4' does not depend on any axioms 'FermatPrimes2.certF41_5' does not depend on any axioms 'FermatPrimes2.certF41_6' does not depend on any axioms 'FermatPrimes2.certF41_7' does not depend on any axioms 'FermatPrimes2.certF41_8' does not depend on any axioms 'FermatPrimes2.certF41_9' does not depend on any axioms 'FermatPrimes2.certF41_10' does not depend on any axioms 'FermatPrimes2.certF41_11' does not depend on any axioms 'FermatPrimes2.certF41_12' does not depend on any axioms 'FermatPrimes2.certF41_13' does not depend on any axioms 'FermatPrimes2.certF41_14' does not depend on any axioms 'FermatPrimes2.certF41_15' does not depend on any axioms 'FermatPrimes2.certF41_16' does not depend on any axioms 'FermatPrimes2.certF41_17' does not depend on any axioms 'FermatPrimes2.certF41_18' does not depend on any axioms 'FermatPrimes2.certF41_19' does not depend on any axioms 'FermatPrimes2.paired_char_41' does not depend on any axioms 'FermatPrimes2.certF43_0' does not depend on any axioms 'FermatPrimes2.certF43_1' does not depend on any axioms 'FermatPrimes2.certF43_2' does not depend on any axioms 'FermatPrimes2.certF43_3' does not depend on any axioms 'FermatPrimes2.certF43_4' does not depend on any axioms 'FermatPrimes2.certF43_5' does not depend on any axioms 'FermatPrimes2.certF43_6' does not depend on any axioms 'FermatPrimes2.certF43_7' does not depend on any axioms 'FermatPrimes2.certF43_8' does not depend on any axioms 'FermatPrimes2.certF43_9' does not depend on any axioms 'FermatPrimes2.certF43_10' does not depend on any axioms 'FermatPrimes2.certF43_11' does not depend on any axioms 'FermatPrimes2.certF43_12' does not depend on any axioms 'FermatPrimes2.certF43_13' does not depend on any axioms 'FermatPrimes2.certF43_14' does not depend on any axioms 'FermatPrimes2.certF43_15' does not depend on any axioms 'FermatPrimes2.certF43_16' does not depend on any axioms 'FermatPrimes2.certF43_17' does not depend on any axioms 'FermatPrimes2.certF43_18' does not depend on any axioms 'FermatPrimes2.certF43_19' does not depend on any axioms 'FermatPrimes2.certF43_20' does not depend on any axioms 'FermatPrimes2.paired_char_43' does not depend on any axioms 'FermatPrimes2.certF47_0' does not depend on any axioms 'FermatPrimes2.certF47_1' does not depend on any axioms 'FermatPrimes2.certF47_2' does not depend on any axioms 'FermatPrimes2.certF47_3' does not depend on any axioms 'FermatPrimes2.certF47_4' does not depend on any axioms 'FermatPrimes2.certF47_5' does not depend on any axioms 'FermatPrimes2.certF47_6' does not depend on any axioms 'FermatPrimes2.certF47_7' does not depend on any axioms 'FermatPrimes2.certF47_8' does not depend on any axioms 'FermatPrimes2.certF47_9' does not depend on any axioms 'FermatPrimes2.certF47_10' does not depend on any axioms 'FermatPrimes2.certF47_11' does not depend on any axioms 'FermatPrimes2.certF47_12' does not depend on any axioms 'FermatPrimes2.certF47_13' does not depend on any axioms 'FermatPrimes2.certF47_14' does not depend on any axioms 'FermatPrimes2.certF47_15' does not depend on any axioms 'FermatPrimes2.certF47_16' does not depend on any axioms 'FermatPrimes2.certF47_17' does not depend on any axioms 'FermatPrimes2.certF47_18' does not depend on any axioms 'FermatPrimes2.certF47_19' does not depend on any axioms 'FermatPrimes2.certF47_20' does not depend on any axioms 'FermatPrimes2.certF47_21' does not depend on any axioms 'FermatPrimes2.certF47_22' does not depend on any axioms 'FermatPrimes2.paired_char_47' does not depend on any axioms == ns/Enstrophy2D.lean 'Enstrophy2D.neg_add2' does not depend on any axioms 'Enstrophy2D.J_cyclic1' does not depend on any axioms 'Enstrophy2D.J_cyclic2' does not depend on any axioms 'Enstrophy2D.sum3_zero' does not depend on any axioms 'Enstrophy2D.sum3_zero'' does not depend on any axioms 'Enstrophy2D.mul_sub' does not depend on any axioms 'Enstrophy2D.triad_energy' does not depend on any axioms 'Enstrophy2D.triad_enstrophy' does not depend on any axioms 'Enstrophy2D.per_mode' does not depend on any axioms 'Enstrophy2D.cn_weighted' does not depend on any axioms 'Enstrophy2D.cn_weighted_le' does not depend on any axioms == bsd/CongruentFamily.lean 'CongruentFamily.sum1_split' does not depend on any axioms 'CongruentFamily.sum1_zero' does not depend on any axioms 'CongruentFamily.sum1_one' does not depend on any axioms 'CongruentFamily.mu_two' does not depend on any axioms 'CongruentFamily.par_odd' does not depend on any axioms 'CongruentFamily.two_nonres' does not depend on any axioms 'CongruentFamily.desc_2' does not depend on any axioms 'CongruentFamily.family_rank0' does not depend on any axioms == hodge/QuadEigen.lean 'QuadEigen.sum_id' does not depend on any axioms 'QuadEigen.split_sum' does not depend on any axioms 'QuadEigen.total' does not depend on any axioms 'QuadEigen.total'' does not depend on any axioms 'QuadEigen.total_odd' does not depend on any axioms 'QuadEigen.quad_eigen_ne' does not depend on any axioms 'QuadEigen.instances' does not depend on any axioms == ns/Stretch3D.lean 'Stretch3D.div_free' does not depend on any axioms 'Stretch3D.energy_zero' does not depend on any axioms 'Stretch3D.enstrophy_nonzero' does not depend on any axioms 'Stretch3D.planar_zero' does not depend on any axioms == hodge/FermatFour.lean 'FermatFour.certF4_0' does not depend on any axioms 'FermatFour.paired_char_4' does not depend on any axioms 'FermatFour.units6' does not depend on any axioms 'FermatFour.hodge6' does not depend on any axioms 'FermatFour.not_paired6' does not depend on any axioms == hodge/Standard.lean 'Standard.dv_between2' does not depend on any axioms 'Standard.std_core' does not depend on any axioms 'Standard.std_hodge' does not depend on any axioms == ns/DyadicCN.lean 'DyadicCN.cn_hs_identity' does not depend on any axioms 'DyadicCN.cn_hs_step' does not depend on any axioms 'DyadicCN.cn_hs_global' does not depend on any axioms == bsd/Mod16.lean 'Mod16.Z16.add_assoc' does not depend on any axioms 'Mod16.Z16.distrib1' does not depend on any axioms 'Mod16.Z16.add_zero' does not depend on any axioms 'Mod16.Z16.mul_zero' does not depend on any axioms 'Mod16.r16_add' does not depend on any axioms 'Mod16.r16_mul' does not depend on any axioms 'Mod16.r16_q4' does not depend on any axioms 'Mod16.table_odd' does not depend on any axioms 'Mod16.table_reduced' does not depend on any axioms 'Mod16.case_odd' does not depend on any axioms 'Mod16.case_reduced' does not depend on any axioms == hodge/Fermat6.lean 'Fermat6.extract_lin' does not depend on any axioms 'Fermat6.cert6_ok' does not depend on any axioms 'Fermat6.hodge6_rel' does not depend on any axioms == ns/DyadicSmallGlobal.lean 'DyadicSmallGlobal.nn_sum_zero' does not depend on any axioms 'DyadicSmallGlobal.le_of_sq_le' does not depend on any axioms 'DyadicSmallGlobal.small_data_global' does not depend on any axioms == bsd/Congruent2p.lean 'Congruent2p.mu_two5' does not depend on any axioms 'Congruent2p.two_nonres5' does not depend on any axioms 'Congruent2p.desc2_5' does not depend on any axioms 'Congruent2p.tbl_2p' does not depend on any axioms 'Congruent2p.r16_P' does not depend on any axioms 'Congruent2p.desc2p_5' does not depend on any axioms == hodge/Fermat8.lean 'Fermat8.cert8_1' does not depend on any axioms 'Fermat8.cert8_2' does not depend on any axioms 'Fermat8.hx8' does not depend on any axioms 'Fermat8.hodge8_rel1' does not depend on any axioms 'Fermat8.hodge8_rel2' does not depend on any axioms == ns/DyadicScaling.lean 'DyadicScaling.dyN_shift' does not depend on any axioms 'DyadicScaling.field_shift' does not depend on any axioms == bsd/Congruent2pP.lean 'Congruent2pP.r16_spec' does not depend on any axioms 'Congruent2pP.even_of_r16' does not depend on any axioms 'Congruent2pP.four_of_r16' does not depend on any axioms 'Congruent2pP.sq_unit_zero' does not depend on any axioms 'Congruent2pP.q4_two' does not depend on any axioms 'Congruent2pP.zero_mul16' does not depend on any axioms 'Congruent2pP.descP_5' does not depend on any axioms == hodge/FermatRel.lean 'FermatRel.hxG' does not depend on any axioms 'FermatRel.cert9_1' does not depend on any axioms 'FermatRel.rel9_1' does not depend on any axioms 'FermatRel.cert9_2' does not depend on any axioms 'FermatRel.rel9_2' does not depend on any axioms 'FermatRel.cert9_4' does not depend on any axioms 'FermatRel.rel9_4' does not depend on any axioms 'FermatRel.cert9_5' does not depend on any axioms 'FermatRel.rel9_5' does not depend on any axioms 'FermatRel.cert9_7' does not depend on any axioms 'FermatRel.rel9_7' does not depend on any axioms 'FermatRel.cert9_8' does not depend on any axioms 'FermatRel.rel9_8' does not depend on any axioms 'FermatRel.cert10_1' does not depend on any axioms 'FermatRel.rel10_1' does not depend on any axioms 'FermatRel.cert10_3' does not depend on any axioms 'FermatRel.rel10_3' does not depend on any axioms 'FermatRel.cert10_7' does not depend on any axioms 'FermatRel.rel10_7' does not depend on any axioms 'FermatRel.cert10_9' does not depend on any axioms 'FermatRel.rel10_9' does not depend on any axioms 'FermatRel.cert12_1' does not depend on any axioms 'FermatRel.rel12_1' does not depend on any axioms 'FermatRel.cert12_5' does not depend on any axioms 'FermatRel.rel12_5' does not depend on any axioms 'FermatRel.cert12_7' does not depend on any axioms 'FermatRel.rel12_7' does not depend on any axioms 'FermatRel.cert12_11' does not depend on any axioms 'FermatRel.rel12_11' does not depend on any axioms 'FermatRel.cert14_1' does not depend on any axioms 'FermatRel.rel14_1' does not depend on any axioms 'FermatRel.cert14_3' does not depend on any axioms 'FermatRel.rel14_3' does not depend on any axioms 'FermatRel.cert14_5' does not depend on any axioms 'FermatRel.rel14_5' does not depend on any axioms 'FermatRel.cert14_9' does not depend on any axioms 'FermatRel.rel14_9' does not depend on any axioms 'FermatRel.cert14_11' does not depend on any axioms 'FermatRel.rel14_11' does not depend on any axioms 'FermatRel.cert14_13' does not depend on any axioms 'FermatRel.rel14_13' does not depend on any axioms 'FermatRel.cert15_1' does not depend on any axioms 'FermatRel.rel15_1' does not depend on any axioms 'FermatRel.cert15_2' does not depend on any axioms 'FermatRel.rel15_2' does not depend on any axioms 'FermatRel.cert15_4' does not depend on any axioms 'FermatRel.rel15_4' does not depend on any axioms 'FermatRel.cert15_7' does not depend on any axioms 'FermatRel.rel15_7' does not depend on any axioms 'FermatRel.cert15_8' does not depend on any axioms 'FermatRel.rel15_8' does not depend on any axioms 'FermatRel.cert15_11' does not depend on any axioms 'FermatRel.rel15_11' does not depend on any axioms 'FermatRel.cert15_13' does not depend on any axioms 'FermatRel.rel15_13' does not depend on any axioms 'FermatRel.cert15_14' does not depend on any axioms 'FermatRel.rel15_14' does not depend on any axioms 'FermatRel.cert16_1' does not depend on any axioms 'FermatRel.rel16_1' does not depend on any axioms 'FermatRel.cert16_3' does not depend on any axioms 'FermatRel.rel16_3' does not depend on any axioms 'FermatRel.cert16_5' does not depend on any axioms 'FermatRel.rel16_5' does not depend on any axioms 'FermatRel.cert16_7' does not depend on any axioms 'FermatRel.rel16_7' does not depend on any axioms 'FermatRel.cert16_9' does not depend on any axioms 'FermatRel.rel16_9' does not depend on any axioms 'FermatRel.cert16_11' does not depend on any axioms 'FermatRel.rel16_11' does not depend on any axioms 'FermatRel.cert16_13' does not depend on any axioms 'FermatRel.rel16_13' does not depend on any axioms 'FermatRel.cert16_15' does not depend on any axioms 'FermatRel.rel16_15' does not depend on any axioms