lean-golf Lean 4 proof leaderboard

USA2009 P2

open: first valid proof sets the record

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

Statement

import Mathlib
import Mathlib.Data.Int.Interval
import Mathlib.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Tactic.Ring
theorem _root_.LeanGolf.compfiles.usa2009_p2 (n : ℕ) (hn : 0 < n) :
    IsGreatest
      {k : ℕ | ∃ A : Finset ℤ,
        A ⊆ Finset.Icc (-(n : ℤ)) (n : ℤ) ∧ IsGood A ∧ A.card = k}
      (answer n)
Trusted statement context
noncomputable section

namespace Usa2009P2

abbrev IsGood (A : Finset ℤ) : Prop :=
  ∀ a ∈ A, ∀ b ∈ A, ∀ c ∈ A, a + b + c ≠ 0

abbrev answer (n : ℕ) : ℕ := if Even n then n else n + 1