File: Mathlib/SetTheory/Game/State.lean

full_name: SetTheory.PGame.State
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: Type u

full_name: SetTheory.PGame.State.right_bound
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: t ∈ SetTheory.PGame.State.r s → SetTheory.PGame.State.turnBound t < SetTheory.PGame.State.turnBound s

full_name: SetTheory.PGame.State.turnBound
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: S → ℕ

full_name: SetTheory.PGame.State.r
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: S → Finset S

full_name: SetTheory.PGame.State.l
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: S → Finset S

full_name: SetTheory.PGame.State.left_bound
code: /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game.
Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game.

`SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe
the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ`
gives an upper bound on the number of possible turns remaining from this state.
-/
class State (S : Type u) where
  turnBound : S → ℕ
  l : S → Finset S
  r : S → Finset S
  left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s
  right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s
goal: t ∈ SetTheory.PGame.State.l s → SetTheory.PGame.State.turnBound t < SetTheory.PGame.State.turnBound s

full_name: SetTheory.PGame.turnBound_ne_zero_of_left_move
code: theorem turnBound_ne_zero_of_left_move {s t : S} (m : t ∈ l s) : turnBound s ≠ 0 
goal: SetTheory.PGame.State.turnBound s ≠ 0

full_name: SetTheory.PGame.turnBound_ne_zero_of_right_move
code: theorem turnBound_ne_zero_of_right_move {s t : S} (m : t ∈ r s) : turnBound s ≠ 0 
goal: SetTheory.PGame.State.turnBound s ≠ 0

full_name: SetTheory.PGame.turnBound_of_left
code: theorem turnBound_of_left {s t : S} (m : t ∈ l s) (n : ℕ) (h : turnBound s ≤ n + 1) :
    turnBound t ≤ n 
goal: SetTheory.PGame.State.turnBound t ≤ n

full_name: SetTheory.PGame.turnBound_of_right
code: theorem turnBound_of_right {s t : S} (m : t ∈ r s) (n : ℕ) (h : turnBound s ≤ n + 1) :
    turnBound t ≤ n 
goal: SetTheory.PGame.State.turnBound t ≤ n

full_name: SetTheory.PGame.ofStateAux
code: /-- Construct a `PGame` from a state and a (not necessarily optimal) bound on the number of
turns remaining.
-/
def ofStateAux : ∀ (n : ℕ) (s : S), turnBound s ≤ n → PGame
  
goal: SetTheory.PGame.State.turnBound s ≤ n → SetTheory.PGame

full_name: SetTheory.PGame.ofStateAuxRelabelling
code: /-- Two different (valid) turn bounds give equivalent games. -/
def ofStateAuxRelabelling :
    ∀ (s : S) (n m : ℕ) (hn : turnBound s ≤ n) (hm : turnBound s ≤ m),
      Relabelling (ofStateAux n s hn) (ofStateAux m s hm)
  
goal: (SetTheory.PGame.ofStateAux n s hn).Relabelling (SetTheory.PGame.ofStateAux m s hm)

full_name: SetTheory.PGame.ofState
code: /-- Construct a combinatorial `PGame` from a state. -/
def ofState (s : S) : PGame 
goal: SetTheory.PGame

full_name: SetTheory.PGame.leftMovesOfStateAux
code: /-- The equivalence between `leftMoves` for a `PGame` constructed using `ofStateAux _ s _`, and
`L s`. -/
def leftMovesOfStateAux (n : ℕ) {s : S} (h : turnBound s ≤ n) :
    LeftMoves (ofStateAux n s h) ≃ { t // t ∈ l s } 
goal: (SetTheory.PGame.ofStateAux n s h).LeftMoves ≃ { t // t ∈ SetTheory.PGame.State.l s }

full_name: SetTheory.PGame.leftMovesOfState
code: /-- The equivalence between `leftMoves` for a `PGame` constructed using `ofState s`, and `l s`. -/
def leftMovesOfState (s : S) : LeftMoves (ofState s) ≃ { t // t ∈ l s } 
goal: (SetTheory.PGame.ofState s).LeftMoves ≃ { t // t ∈ SetTheory.PGame.State.l s }

full_name: SetTheory.PGame.rightMovesOfStateAux
code: /-- The equivalence between `rightMoves` for a `PGame` constructed using `ofStateAux _ s _`, and
`R s`. -/
def rightMovesOfStateAux (n : ℕ) {s : S} (h : turnBound s ≤ n) :
    RightMoves (ofStateAux n s h) ≃ { t // t ∈ r s } 
goal: (SetTheory.PGame.ofStateAux n s h).RightMoves ≃ { t // t ∈ SetTheory.PGame.State.r s }

full_name: SetTheory.PGame.rightMovesOfState
code: /-- The equivalence between `rightMoves` for a `PGame` constructed using `ofState s`, and
`R s`. -/
def rightMovesOfState (s : S) : RightMoves (ofState s) ≃ { t // t ∈ r s } 
goal: (SetTheory.PGame.ofState s).RightMoves ≃ { t // t ∈ SetTheory.PGame.State.r s }

full_name: SetTheory.PGame.relabellingMoveLeftAux
code: /-- The relabelling showing `moveLeft` applied to a game constructed using `ofStateAux`
has itself been constructed using `ofStateAux`.
-/
def relabellingMoveLeftAux (n : ℕ) {s : S} (h : turnBound s ≤ n)
    (t : LeftMoves (ofStateAux n s h)) :
    Relabelling (moveLeft (ofStateAux n s h) t)
      (ofStateAux (n - 1) ((leftMovesOfStateAux n h) t : S)
        (turnBound_of_left ((leftMovesOfStateAux n h) t).2 (n - 1)
          (Nat.le_trans h le_tsub_add))) 
goal: ((SetTheory.PGame.ofStateAux n s h).moveLeft t).Relabelling
  (SetTheory.PGame.ofStateAux (n - 1) ↑((SetTheory.PGame.leftMovesOfStateAux n h) t) ⋯)

full_name: SetTheory.PGame.relabellingMoveLeft
code: /-- The relabelling showing `moveLeft` applied to a game constructed using `of`
has itself been constructed using `of`.
-/
def relabellingMoveLeft (s : S) (t : LeftMoves (ofState s)) :
    Relabelling (moveLeft (ofState s) t) (ofState ((leftMovesOfState s).toFun t : S)) 
goal: ((SetTheory.PGame.ofState s).moveLeft t).Relabelling
  (SetTheory.PGame.ofState ↑((SetTheory.PGame.leftMovesOfState s).toFun t))

full_name: SetTheory.PGame.relabellingMoveRightAux
code: /-- The relabelling showing `moveRight` applied to a game constructed using `ofStateAux`
has itself been constructed using `ofStateAux`.
-/
def relabellingMoveRightAux (n : ℕ) {s : S} (h : turnBound s ≤ n)
    (t : RightMoves (ofStateAux n s h)) :
    Relabelling (moveRight (ofStateAux n s h) t)
      (ofStateAux (n - 1) ((rightMovesOfStateAux n h) t : S)
        (turnBound_of_right ((rightMovesOfStateAux n h) t).2 (n - 1)
          (Nat.le_trans h le_tsub_add))) 
goal: ((SetTheory.PGame.ofStateAux n s h).moveRight t).Relabelling
  (SetTheory.PGame.ofStateAux (n - 1) ↑((SetTheory.PGame.rightMovesOfStateAux n h) t) ⋯)

full_name: SetTheory.PGame.relabellingMoveRight
code: /-- The relabelling showing `moveRight` applied to a game constructed using `of`
has itself been constructed using `of`.
-/
def relabellingMoveRight (s : S) (t : RightMoves (ofState s)) :
    Relabelling (moveRight (ofState s) t) (ofState ((rightMovesOfState s).toFun t : S)) 
goal: ((SetTheory.PGame.ofState s).moveRight t).Relabelling
  (SetTheory.PGame.ofState ↑((SetTheory.PGame.rightMovesOfState s).toFun t))

full_name: SetTheory.PGame.fintypeLeftMovesOfStateAux
code: instance fintypeLeftMovesOfStateAux (n : ℕ) (s : S) (h : turnBound s ≤ n) :
    Fintype (LeftMoves (ofStateAux n s h)) 
goal: Fintype (SetTheory.PGame.ofStateAux n s h).LeftMoves

full_name: SetTheory.PGame.fintypeRightMovesOfStateAux
code: instance fintypeRightMovesOfStateAux (n : ℕ) (s : S) (h : turnBound s ≤ n) :
    Fintype (RightMoves (ofStateAux n s h)) 
goal: Fintype (SetTheory.PGame.ofStateAux n s h).RightMoves

full_name: SetTheory.PGame.shortOfStateAux
code: instance shortOfStateAux : ∀ (n : ℕ) {s : S} (h : turnBound s ≤ n), Short (ofStateAux n s h)
  
goal: (SetTheory.PGame.ofStateAux n s h).Short

full_name: SetTheory.PGame.shortOfState
code: instance shortOfState (s : S) : Short (ofState s) 
goal: (SetTheory.PGame.ofState s).Short

full_name: SetTheory.Game.ofState
code: /-- Construct a combinatorial `Game` from a state. -/
def ofState {S : Type u} [PGame.State S] (s : S) : Game 
goal: SetTheory.Game