Lean / Reader
Lean reader

Pivot.lean

38 lines3 declarationsno sorryimports Thresholds Mathlib.Algebra.BigOperators.Associated

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports Thresholds, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import Thresholds
  2. import Mathlib.Algebra.BigOperators.Associated
  3. namespace FactorialThresholds
  4. open Finset
  5. def Representable (A : Finset ℕ) (t : ℕ) : Prop := ∃ S ⊆ A, ∏ a ∈ S, a = t
  6. /-- A certificate pivot need only test subsets of the eligible factors divisible by p.
  7. The remaining target is coprime to p and is itself representable if the original target is. -/
  8. theorem prime_pivot {A : Finset ℕ} {t p : ℕ} (hp : p.Prime) (repr : Representable A t) :
  9. ∃ C ⊆ A.filter (fun a => p ∣ a ∧ a ∣ t), ∃ r, (∏ a ∈ C, a)*r=t ∧ ¬ p ∣ r ∧ Representable A r := by
  10. obtain ⟨S,sub,prod⟩ := repr
  11. let C := S.filter fun a => p ∣ a
  12. let R := S.filter fun a => ¬ p ∣ a
  13. refine ⟨C,?_,∏ a ∈ R, a,?_,?_,R,?_,rfl⟩
  14. · intro a ha
  15. obtain ⟨hs,dvd⟩ := mem_filter.mp ha
  16. have dt : a ∣ t := prod ▸ Finset.dvd_prod_of_mem id hs
  17. exact mem_filter.mpr ⟨sub hs,dvd,dt⟩
  18. · exact (prod_filter_mul_prod_filter_not S (fun a => p ∣ a) id).trans prod
  19. · intro dvd
  20. obtain ⟨a,ha,pa⟩ := ((Nat.prime_iff.mp hp).dvd_finset_prod_iff id).mp dvd
  21. exact (mem_filter.mp ha).2 pa
  22. · exact (filter_subset _ _).trans sub
  23. /-- Sound rule for verifying a stored negative node in a prime-pivot certificate. -/
  24. theorem pivot_excludes {A : Finset ℕ} {t p : ℕ} (hp : p.Prime)
  25. (test : ∀ C ⊆ A.filter (fun a => p ∣ a ∧ a ∣ t), ∀ r,
  26. (∏ a ∈ C, a)*r=t → ¬ p ∣ r → ¬ Representable A r) :
  27. ¬ Representable A t := by
  28. intro yes
  29. obtain ⟨C,hC,r,eq,free,child⟩ := prime_pivot hp yes
  30. exact test C hC r eq free child
  31. #print axioms prime_pivot
  32. #print axioms pivot_excludes
  33. end FactorialThresholds