Arc Kayles

Lax783278.ArcKayles · concepts/Lax783278/ArcKayles.lean · lax-783278

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    A position consists of a finite set of surviving vertices of a simple graph. A move removes the two endpoints of a surviving edge. Under normal play, the player with no legal move loses. A position is winning for the player to move if some legal move leaves a position losing for the opponent. Isolated vertices may be retained: they permit no moves.

    Concept map
    1 concept; 10 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Combinatorics.SimpleGraph.Basic
    2import Mathlib.Data.Finset.Card
    3import Mathlib.Data.Finset.Prod
    4
    5/-!
    6---
    7title: Arc Kayles
    8type: definition
    9---
    10A position consists of a finite set of surviving vertices of a simple graph.
    11A move removes the two endpoints of a surviving edge. Under normal play,
    12the player with no legal move loses. A position is winning for the player
    13to move if some legal move leaves a position losing for the opponent.
    14Isolated vertices may be retained: they permit no moves.
    15-/
    16
    17namespace Lax783278.ArcKayles
    18
    19open scoped Classical
    20
    21variable {V : Type} [DecidableEq V]
    22
    23/-- The position after playing an edge with endpoints `u` and `v`. -/
    24def remove (S : Finset V) (u v : V) : Finset V := (S.erase u).erase v
    25
    26/-- Legal moves, represented by ordered pairs of endpoints. -/
    27noncomputable def moves (G : SimpleGraph V) (S : Finset V) : Finset (V × V) :=
    28 (S ×ˢ S).filter fun e => G.Adj e.1 e.2
    29
    30/-- Backward induction through `rounds` moves. With no rounds left the
    31player to move loses; otherwise a winning move leaves a losing position. -/
    32def WinningAfter (G : SimpleGraph V) : ℕ → Finset V → Prop
    33 | 0, _ => False
    34 | rounds + 1, S =>
    35 ∃ e ∈ moves G S, ¬ WinningAfter G rounds (remove S e.1 e.2)
    36
    37/-- A winning strategy for the next player. There are at most `S.card` moves,
    38since every move removes vertices, so this many rounds evaluates the whole game. -/
    39def Winning (G : SimpleGraph V) (S : Finset V) : Prop :=
    40 WinningAfter G S.card S
    41
    42end Lax783278.ArcKayles
    43

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…