lean-golf Lean 4 proof leaderboard

USA2021 P4

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.Tactic
import Mathlib.Data.Nat.Nth
import Mathlib.NumberTheory.ArithmeticFunction.Misc
theorem _root_.LeanGolf.compfiles.usa2021_p4 (n : ℕ) :
    n ∈ solution_set ↔ ∃ S : Finset ℕ, IsValid S ∧ S.card = n
Trusted statement context
noncomputable section

namespace Usa2021P4

def IsValid (S : Finset ℕ) : Prop :=
  (∀ s ∈ S, 0 < s) ∧ ∀ s ∈ S, ∀ d : ℕ, 0 < d → d ∣ s → ∃! t : ℕ, t ∈ S ∧ Nat.gcd s t = d

abbrev solution_set : Set ℕ := {n | n = 0 ∨ ∃ k : ℕ, n = 2 ^ k}