Lean / Reader
Lean readerGridLift.lean
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.
import GridArithmeticnamespace ReciprocalGridopen Finsetdef harmonic (A : Finset ℕ) : ℚ := ∑ n ∈ A, (n : ℚ)⁻¹def fiber (B : Finset ℕ) (z : ℚ) : Finset (Finset ℕ) :=B.powerset.filter (fun A => harmonic A = z)@[simp] theorem mem_fiber {A B : Finset ℕ} {z : ℚ} :A ∈ fiber B z ↔ A ⊆ B ∧ harmonic A = z := by simp [fiber]theorem append_mass {A F : Finset ℕ} (h : Disjoint A F) :harmonic (A ∪ F) = harmonic A + harmonic F := Finset.sum_union htheorem recover_bulk {A B F : Finset ℕ} (ha : A ⊆ B) (hf : Disjoint B F) :(A ∪ F) ∩ B = A := byext nsimp only [mem_inter, mem_union]constructor· rintro ⟨hu, hb⟩exact hu.elim id fun hn => False.elim (Finset.disjoint_left.mp hf hb hn)· intro hnexact ⟨Or.inl hn, ha hn⟩theorem append_fiber_card {B F : Finset ℕ} {z : ℚ} (hf : Disjoint B F) :(fiber B z).card ≤ (fiber (B ∪ F) (z + harmonic F)).card := byapply Finset.card_le_card_of_injOn (fun A => A ∪ F)· intro A hAobtain ⟨ha, hz⟩ := mem_fiber.mp hAapply mem_fiber.mprexact ⟨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])⟩· intro A hA A' hA' hesimpa only [recover_bulk (mem_fiber.mp hA).1 hf, recover_bulk (mem_fiber.mp hA').1 hf] using congrArg (fun S : Finset ℕ => S ∩ B) heend ReciprocalGrid