lean-golf Lean 4 proof leaderboard

USA2017 P5

open: first valid proof sets the record

Compfiles · Usa · Apache-2.0
Copyright (c) 2024 David Renshaw. All rights reserved. Authors: David Renshaw, hillosanation

Statement

import Mathlib.Tactic
theorem _root_.LeanGolf.compfiles.usa2017_p5 (c : ℝ) :
  c ∈ solution_set ↔
  (0 < c ∧
    ∃ l : ℤ × ℤ → ℕ,
      (Set.range l).Finite ∧
      (∀ p, 0 < l p) ∧
      ∀ {p1 p2}, p1 ≠ p2 → (l p1 = l p2) →
          c ^ (l p1) ≤ dist p1 p2)
Trusted statement context
noncomputable section

namespace Usa2017P5

noncomputable abbrev solution_set : Set ℝ := Set.Ioo 0 (Real.sqrt 2)

noncomputable def dist : ℤ × ℤ → ℤ × ℤ → ℝ
| ⟨x1, y1⟩, ⟨x2, y2⟩ => Real.sqrt ((x2 - x1)^2 + (y2 - y1)^2)

open Real

def labelling (c : ℝ) := { l : ℤ × ℤ → ℕ //
  (Set.range l).Finite ∧
  (∀ p, 0 < l p) ∧
  ∀ {p1 p2}, p1 ≠ p2 → (l p1 = l p2) →
      c ^ (l p1) ≤ dist p1 p2 }

instance (c : ℝ) : FunLike (labelling c) (ℤ × ℤ) ℕ :=
  ⟨(·.1), fun _ _ => Subtype.ext⟩

attribute [local simp] DFunLike.coe

instance (n : ℕ) : CoeOut (Finset.range (2 ^ n) × Finset.range (2 ^ n)) (ℤ × ℤ) := ⟨fun ⟨x, y⟩ => ⟨x, y⟩⟩

instance : Coe (ℕ × ℕ) (ℤ × ℤ) := ⟨fun ⟨x, y⟩ => ⟨x, y⟩⟩

variable (limit : ℕ) (p : ℤ × ℤ)