Lean / Reader
Lean readerMenageFinal.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports MenageCount, MenagePair, MenageOrder, MenageSix, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import MenageCountimport MenagePairimport MenageOrderimport MenageSixopen Polynomialopen scoped Polynomialnamespace Menageprivate theorem expansion_half {d m : ℕ} (hm : 2 ≤ m) :expansion d m = ∑ j ∈ Finset.range (d/2+1), d.choose j * U ((d-2*j)*m) := byunfold expansionhave hdim := Nat.le_mul_of_pos_right d (by omega : 0 < m)have hs : Finset.range (d/2+1) ⊆ Finset.range (d*m+1) := Finset.range_mono (by omega)calc_ = ∑ j ∈ Finset.range (d/2+1), summand (d*m) d m j := bysymmapply Finset.sum_subset hsintro j _ hjhave h := Finset.mem_range.not.mp hjsimp [summand, if_neg (show ¬ 2*j ≤ d by omega)]_ = _ := Finset.sum_congr rfl (fun j hj => byhave hj' := Finset.mem_range.mp hjsimp [summand, if_pos (show 2*j ≤ d by omega), Nat.sub_mul])/-- Exact positive expansion in ordinary ménage numbers, with U₀ = 1. -/theorem productCount_expansion {d m : ℕ} (hm : 2 ≤ m) : productCount d m = expansion d m := byapply Nat.cast_injective (R:=ℤ)rw [productCount_facet hm]change facet (cyc m ^ d) = _rw [cyc_pow_half, map_sum, expansion_half hm, Nat.cast_sum]apply Finset.sum_congr rflintro j hjhave hj' := Finset.mem_range.mp hjrw [map_nsmul, nsmul_eq_mul, Nat.cast_mul]congr 1by_cases hd : 2*j=d· rw [if_pos hd]have he : d-2*j=0 := by omegasimpa [he, U_zero] using facet_X_pow 0· rw [if_neg hd]have ha : 0 < d-2*j := by omegahave hmul := Nat.le_mul_of_pos_left m haexact (U_facet (m:=(d-2*j)*m) (by omega)).symmprivate theorem quotient_large {n k : ℕ} (hk : 0 < k) (hkn : k < n) : 2 ≤ n/(n.gcd k) := byhave hd := Nat.le_of_dvd hk (Nat.gcd_dvd_right n k)have he := Nat.div_mul_cancel (Nat.gcd_dvd_left n k)by_contra! hhave hle := Nat.mul_le_mul_right (n.gcd k) (show n/(n.gcd k) ≤ 1 by omega)simp only [one_mul,he] at hleomega/-- The full divisor ordering conjectured by Pontus von Brömssen in A354408. -/theorem strict_gcd_order {n j k : ℕ} (hj : 0 < j) (hjn : j < n) (hk : 0 < k)(hkn : k < n) (hg : n.gcd j < n.gcd k) (hex : n ≠ 6 ∨ k ≠ 3) : T n j < T n k := byhave hm := quotient_large hj hjnhave hl := quotient_large hk hknrw [T_gcd hj hjn, T_gcd hk hkn, productCount_expansion hm, productCount_expansion hl]have hjp : n.gcd j * (n / n.gcd j) = n := Nat.mul_div_cancel' (Nat.gcd_dvd_left n j)have hkp : n.gcd k * (n / n.gcd k) = n := Nat.mul_div_cancel' (Nat.gcd_dvd_left n k)apply expansion_strict (Nat.gcd_pos_of_pos_right n hj) hm hl (hjp.trans hkp.symm) hgrw [hjp]by_cases hn : n=6· subst nrighthave he : k ≠ 3 := hex.resolve_left (by simp)intro h3have hdiv := Nat.gcd_dvd_right 6 krw [h3] at hdivobtain ⟨t, ht⟩ := hdivomega· exact Or.inl hntheorem strict_above_first {n k : ℕ} (hk : 0 < k) (hkn : k < n) (hg : 1 < n.gcd k)(hex : n ≠ 6 ∨ k ≠ 3) : T n 1 < T n k := byapply strict_gcd_order (by decide) (by omega) hk hkn _ hexsimpa using hgtheorem first_minimum {n k : ℕ} (hk : 0 < k) (hkn : k < n) : T n 1 ≤ T n k := byby_cases hg : 1 < n.gcd k· by_cases hx : n=6 ∧ k=3· rcases hx with ⟨rfl,rfl⟩rw [exceptional_values.1,exceptional_values.2.2]· exact (strict_above_first hk hkn hg (by tauto)).le· have hpos := Nat.gcd_pos_of_pos_right n hkhave h1 : n.gcd k=1 := by omegarw [T_gcd hk hkn, T_gcd (k:=1) (by decide) (by omega)]simp [h1]#print axioms strict_gcd_order#print axioms strict_above_first#print axioms first_minimum#print axioms exceptional_valuesend Menage