lean-golf Lean 4 proof leaderboard

USA2008 P3

open: first valid proof sets the record

Compfiles · Usa · Apache-2.0
Copyright (c) 2026 The Compfiles Contributors. All rights reserved. Authors: Kimi K3

Statement

import Mathlib.Algebra.BigOperators.Group.Finset.Sigma
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Order.BigOperators.Group.List
import Mathlib.Algebra.Order.Ring.Star
import Mathlib
import Mathlib.Data.Int.Interval
import Mathlib.Data.Int.ModEq
import Mathlib.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Linarith.Lemmas
import Mathlib.Tactic.NormNum.Abs
import Mathlib.Tactic.NormNum.Ineq
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Ring.Basic
theorem _root_.LeanGolf.compfiles.usa2008_p3 (n : ℕ) (_hn : 0 < n) (paths : List (List (ℤ × ℤ)))
    (hmem : ∀ P ∈ paths, ∀ p ∈ P, p ∈ S n)
    (hnodup : ∀ P ∈ paths, P.Nodup)
    (hchain : ∀ P ∈ paths, P.IsChain Adj)
    (hdisj : paths.Pairwise List.Disjoint)
    (hcover : ∀ p ∈ S n, ∃ P ∈ paths, p ∈ P) :
    n ≤ paths.length
Trusted statement context
noncomputable section

namespace Usa2008P3

def rowK (n : ℕ) (y : ℤ) : ℤ := if 0 ≤ y then (n : ℤ) - 1 - y else (n : ℤ) + y

noncomputable def S (n : ℕ) : Finset (ℤ × ℤ) :=
  (Finset.Icc (-(n : ℤ)) ((n : ℤ) - 1)).biUnion fun y ↦
    (Finset.Icc (-(rowK n y)) (rowK n y)) ×ˢ {y}

def Adj (p q : ℤ × ℤ) : Prop := |p.1 - q.1| + |p.2 - q.2| = 1

def f (p : ℤ × ℤ) : ℤ := 2 * p.1 + |2 * p.2 + 1|

def blue (n : ℕ) (p : ℤ × ℤ) : Prop := f p ≡ 2 * (n : ℤ) - 1 [ZMOD 4]

instance (n : ℕ) : DecidablePred (blue n) :=
  fun p ↦ inferInstanceAs (Decidable (f p ≡ 2 * (n : ℤ) - 1 [ZMOD 4]))