Skip to content

Commit

Permalink
minor additions for game
Browse files Browse the repository at this point in the history
Co-authored-by: Paulo Oliva <[email protected]>
  • Loading branch information
martinescardo and pauloboliva committed Nov 27, 2024
1 parent 3ec80fa commit 01f1ec9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
42 changes: 42 additions & 0 deletions source/Games/List.lagda
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Martin Escardo, Paulo Oliva, 2024

The list monad.

\begin{code}

{-# OPTIONS --safe --without-K #-}

module Games.List where

open import Games.Monad
open import MLTT.Spartan hiding (J)
open import MLTT.List hiding (map)

𝕃 : Monad
𝕃 = record {
functor = List ;
η = [_] ;
ext = List-ext ;
ext-η = concat-singletons ;
unit = List-ext-unit ;
assoc = List-ext-assoc
}

module List-definitions where

_⊗ᴸ⁺_ : {X : Type} {Y : X → Type}
→ List X
→ ((x : X) → List (Y x))
→ List (Σ x ꞉ X , Y x)
_⊗ᴸ⁺_ = _⊗_ 𝕃

ηᴸ⁺ : {X : Type} → X → List X
ηᴸ⁺ = η 𝕃

extᴸ⁺ : {X Y : Type} → (X → List Y) → List X → List Y
extᴸ⁺ = ext 𝕃

mapᴸ⁺ : {X Y : Type} → (X → Y) → List X → List Y
mapᴸ⁺ = map 𝕃

\end{code}
5 changes: 3 additions & 2 deletions source/Games/index.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import Games.J -- Selection monad.
import Games.K -- Continuation (or quantifier) monad.
import Games.JK -- Relationship between the two mondas.
import Games.Monad -- (Automatically strong, wild) monads on types.
import Games.Reader
import Games.NonEmptyList
import Games.Reader -- Reader monad.
import Games.List -- List monad.
import Games.NonEmptyList -- Non-empty list monad.
import Games.TicTacToe0
import Games.TicTacToe1 -- Like TicTacToe0 but using Games.Constructor.
import Games.TicTacToe2 -- More efficient and less elegant version.
Expand Down
5 changes: 5 additions & 0 deletions source/MLTT/List.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ List-ext : {X : 𝓤 ̇ } {Y : 𝓥 ̇ }
→ (X → List Y) → (List X → List Y)
List-ext f xs = concat (map f xs)

List-ext-unit : {X : 𝓤 ̇ } {Y : 𝓥 ̇ }
(f : X → List Y) (x : X)
→ f x ++ [] = f x
List-ext-unit f x = ([]-right-neutral (f x))⁻¹

List-ext-assoc
: {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : 𝓦 ̇ }
(g : Y → List Z) (f : X → List Y)
Expand Down

0 comments on commit 01f1ec9

Please sign in to comment.