IMO2011 P4
open: first valid proof sets the record
Compfiles · Imo · Apache-2.0
Copyright (c) 2026 The Compfiles Contributors. All rights reserved. Authors: Kimi K3
Statement
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Ring.Star
import Mathlib.Algebra.Ring.GeomSum
import Mathlib.AlgebraicTopology.SimplexCategory.Basic
import Mathlib
import Mathlib.Data.Nat.Factorial.DoubleFactorial
import Mathlib.Order.Lattice.Nat
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Linarith.Lemmas
theorem _root_.LeanGolf.compfiles.imo2011_p4 (n : ℕ) (hn : 0 < n) :
Nat.card (Ways n) = solution_value nTrusted statement context
noncomputable section
namespace Imo2011P4
open scoped Nat
open scoped List
def Balance (l : List (ℕ × Bool)) : ℤ :=
((l.map fun p ↦ if p.2 then (2 : ℤ) ^ p.1 else -((2 : ℤ) ^ p.1))).sum
def ValidSeq (l : List (ℕ × Bool)) : Prop :=
∀ pre : List (ℕ × Bool), pre <+: l → 0 ≤ Balance pre
def Ways (n : ℕ) : Type :=
{ l : List (ℕ × Bool) // l.map Prod.fst ~ List.range n ∧ ValidSeq l }
abbrev solution_value : ℕ → ℕ := fun n ↦ (2 * n - 1)‼