Lean / Reader
Lean readerExact447.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports ThresholdWitnesses, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import ThresholdWitnessesimport Mathlib.Data.Nat.Factorization.Basicimport Mathlib.Data.Nat.Factorial.BigOperatorsnamespace FactorialThresholdsopen Finsetprivate theorem score_prod (w : ℕ → ℤ) (one : w 1 = 0)(mul : ∀ a b, a ≠ 0 → b ≠ 0 → w (a*b)=w a+w b) (A : Finset ℕ)(pos : ∀ a ∈ A, 0<a) : w (∏ a ∈ A,a) = ∑ a ∈ A, w a := byinduction A using Finset.induction_on with| empty => simpa using one| @insert a A fresh ih =>have hpos : ∀ b∈A,0<b := fun b hb => pos b (mem_insert_of_mem hb)rw [prod_insert fresh,sum_insert fresh,mul,ih hpos]· exact (pos a (mem_insert_self _ _)).ne'· exact (Finset.prod_pos hpos).ne'private theorem score_factorial (w : ℕ → ℤ) (one : w 1 = 0)(mul : ∀ a b, a ≠ 0 → b ≠ 0 → w (a*b)=w a+w b) (n : ℕ) :w n.factorial = ∑ i ∈ range n, w (i+1) := byinduction n with| zero => simpa using one| succ n ih =>rw [Nat.factorial_succ,mul _ _ (by omega) (Nat.factorial_ne_zero _),ih,sum_range_succ,add_comm]/-- Every nonnegative additive valuation score on the interval must supplyat least the score required by the factorial. -/theorem valuation_obstruction (n m : ℕ) (w : ℕ → ℤ) (one : w 1=0)(mul : ∀ a b, a ≠ 0 → b ≠ 0 → w (a*b)=w a+w b)(nonneg : ∀ a ∈ Ioc n m, 0≤w a)(short : (∑ a ∈ Ioc n m, w a) < ∑ i ∈ range n, w (i+1)) : ¬ Fits n m := byrintro ⟨xs,nodup,inside,target⟩let S := xs.toFinsethave sub : S ⊆ Ioc n m := by simpa [S,Finset.subset_iff] using insidehave pos : ∀ a∈S,0<a := fun a ha => (mem_Ioc.mp (sub ha)).1.trans_le' (Nat.zero_le n)have ep : (∏ a ∈ S,a) = n.factorial := byhave e := List.prod_toFinset id nodupsimpa [S] using e.trans (by simpa using target)have eq := score_prod w one mul S posrw [ep,score_factorial w one mul] at eqhave le : (∑ a ∈ S,w a) ≤ ∑ a ∈ Ioc n m,w a :=Finset.sum_le_sum_of_subset_of_nonneg sub (fun a ha _ => nonneg a ha)omegaprivate def ps : List ℕ := [227,229,233,239,241,251,257,263,269,271,277,281,283,293]private def negScore (ps : List ℕ) (x : ℕ) : ℤ :=(ps.map (fun p => (x.primeFactorsList.count p : ℤ))).sumprivate def score447 (x : ℕ) : ℤ :=x.primeFactorsList.count 2 + (x.primeFactorsList.count 3 : ℤ) - negScore ps xprivate theorem counts_mul {a b : ℕ} (p : ℕ) (ha : a≠0) (hb : b≠0) :((a*b).primeFactorsList.count p : ℤ) = a.primeFactorsList.count p + (b.primeFactorsList.count p : ℤ) := bysimp [Nat.factorization_mul ha hb]private theorem neg_mul {a b : ℕ} (ha : a≠0) (hb : b≠0) (ps : List ℕ) :negScore ps (a*b) = negScore ps a + negScore ps b := byinduction ps with| nil => simp [negScore]| cons p tail ih =>simp only [negScore,List.map_cons,List.sum_cons] at ih ⊢rw [counts_mul p ha hb,ih];ringprivate theorem score_mul (a b : ℕ) (ha : a≠0) (hb : b≠0) :score447 (a*b)=score447 a+score447 b := byunfold score447rw [counts_mul 2 ha hb,counts_mul 3 ha hb,neg_mul ha hb];ringset_option maxRecDepth 100000set_option maxHeartbeats 0theorem not_fit_447_895 : ¬Fits 447 895 := byapply valuation_obstruction _ _ score447 (by decide +kernel) score_mul· decide +kernel· decide +kerneltheorem exact_447 : IsLeast {m | Fits 447 m} 896 := byrefine ⟨fit_447_2,?_⟩intro m hmby_contra! hexact not_fit_447_895 (fits_mono hm (by omega))#print axioms exact_447end FactorialThresholds