Lean / Reader
Lean reader

GridLift.lean

38 lines6 declarationsno sorryimports GridArithmetic

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

  1. import GridArithmetic
  2. namespace ReciprocalGrid
  3. open Finset
  4. def harmonic (A : Finset ℕ) : ℚ := ∑ n ∈ A, (n : ℚ)⁻¹
  5. def fiber (B : Finset ℕ) (z : ℚ) : Finset (Finset ℕ) :=
  6. B.powerset.filter (fun A => harmonic A = z)
  7. @[simp] theorem mem_fiber {A B : Finset ℕ} {z : ℚ} :
  8. A ∈ fiber B z ↔ A ⊆ B ∧ harmonic A = z := by simp [fiber]
  9. theorem append_mass {A F : Finset ℕ} (h : Disjoint A F) :
  10. harmonic (A ∪ F) = harmonic A + harmonic F := Finset.sum_union h
  11. theorem recover_bulk {A B F : Finset ℕ} (ha : A ⊆ B) (hf : Disjoint B F) :
  12. (A ∪ F) ∩ B = A := by
  13. ext n
  14. simp only [mem_inter, mem_union]
  15. constructor
  16. · rintro ⟨hu, hb⟩
  17. exact hu.elim id fun hn => False.elim (Finset.disjoint_left.mp hf hb hn)
  18. · intro hn
  19. exact ⟨Or.inl hn, ha hn⟩
  20. theorem append_fiber_card {B F : Finset ℕ} {z : ℚ} (hf : Disjoint B F) :
  21. (fiber B z).card ≤ (fiber (B ∪ F) (z + harmonic F)).card := by
  22. apply Finset.card_le_card_of_injOn (fun A => A ∪ F)
  23. · intro A hA
  24. obtain ⟨ha, hz⟩ := mem_fiber.mp hA
  25. apply mem_fiber.mpr
  26. exact ⟨Finset.union_subset_union_left ha, (append_mass (Finset.disjoint_left.mpr fun _ h h' => Finset.disjoint_left.mp hf (ha h) h')).trans (by rw [hz])⟩
  27. · intro A hA A' hA' he
  28. simpa only [recover_bulk (mem_fiber.mp hA).1 hf, recover_bulk (mem_fiber.mp hA').1 hf] using congrArg (fun S : Finset ℕ => S ∩ B) he
  29. end ReciprocalGrid