lean-golf Lean 4 proof leaderboard

IMO2025 P1

open: first valid proof sets the record

Compfiles · Imo · Apache-2.0
Copyright (c) 2025 Joseph Myers. All rights reserved. Authors: Joseph Myers (Problem statement), Yizheng Zhu (Solution)

Statement

import Mathlib
theorem _root_.LeanGolf.compfiles.imo2025_p1 (n : Set.Ici 3) :
    {k | ∃ lines : Finset (AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2))),
      have := sunnyPred;
      #lines = n ∧ (∀ l ∈ lines, finrank ℝ l.direction = 1) ∧
      (∀ a b : ℕ, 0 < a → 0 < b → a + b ≤ (n : ℕ) + 1 → ∃ l ∈ lines, !₂[(a : ℝ), b] ∈ l) ∧
      #{l ∈ lines | Sunny l} = k} = answer n
Trusted statement context
noncomputable section

namespace Imo2025P1

open scoped Affine Finset

open Module

def xAxis : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2)) where
  carrier := {p | p 1 = 0}
  smul_vsub_vadd_mem' c p₁ p₂ p₃ hp₁ hp₂ hp₃ := by simp_all

def yAxis : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2)) where
  carrier := {p | p 0 = 0}
  smul_vsub_vadd_mem' c p₁ p₂ p₃ hp₁ hp₂ hp₃ := by simp_all

def linexy0 : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2)) where
  carrier := {p | p 0 + p 1 = 0}
  smul_vsub_vadd_mem' c p₁ p₂ p₃ hp₁ hp₂ hp₃ := by
    simp only [Fin.isValue, vsub_eq_sub, vadd_eq_add, Set.mem_ofPred_eq, PiLp.add_apply,
      PiLp.smul_apply, PiLp.sub_apply, smul_eq_mul]
    suffices c * (p₁ 0 + p₁ 1 - (p₂ 0 + p₂ 1)) + (p₃ 0 + p₃ 1) = 0 by
      rw [← this]
      ring
    simp_all

def Sunny (s : AffineSubspace ℝ (EuclideanSpace ℝ (Fin 2))) : Prop :=
   ¬ s ∥ xAxis ∧ ¬ s ∥ yAxis ∧ ¬ s ∥ linexy0

noncomputable def sunnyPred : DecidablePred Sunny := Classical.decPred _

abbrev answer : Set.Ici 3 → Set ℕ := fun _ => {0, 1, 3}