proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Category.Instance.OpenGame

Description

Open games in a copy/discard category. Strategies are finite catalogues of monoidal lenses; contexts retain the joint state of the environment.

The categorical laws identify games up to bijections of profiles preserving play and evaluation, with diagnostic lists compared up to permutation. Enumeration order and diagnostic order are not categorical invariants. Strictification handles profile parenthesisation, not arbitrary equivalence of strategies. There is no Eq instance for games containing opaque arrows.

Synopsis

Documentation

data GAME k Source Github #

Constructors

G k k 

Instances

Instances details
CopyDiscard k => Monoidal (GAME k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Associated Types

type Unit 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type Unit = 'G (Unit :: k) (Unit :: k)

Methods

withOb2 :: forall (a :: GAME k) (b :: GAME k) r. (Ob a, Ob b) => (Ob (a ** b) => r) -> r Source Github #

leftUnitor :: forall (a :: GAME k). Ob a => ((Unit :: GAME k) ** a) ~> a Source Github #

leftUnitorInv :: forall (a :: GAME k). Ob a => a ~> ((Unit :: GAME k) ** a) Source Github #

rightUnitor :: forall (a :: GAME k). Ob a => (a ** (Unit :: GAME k)) ~> a Source Github #

rightUnitorInv :: forall (a :: GAME k). Ob a => a ~> (a ** (Unit :: GAME k)) Source Github #

associator :: forall (a :: GAME k) (b :: GAME k) (c :: GAME k). (Ob a, Ob b, Ob c) => ((a ** b) ** c) ~> (a ** (b ** c)) Source Github #

associatorInv :: forall (a :: GAME k) (b :: GAME k) (c :: GAME k). (Ob a, Ob b, Ob c) => (a ** (b ** c)) ~> ((a ** b) ** c) Source Github #

CopyDiscard k => SymMonoidal (GAME k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

swap :: forall (a :: GAME k) (b :: GAME k). (Ob a, Ob b) => (a ** b) ~> (b ** a) Source Github #

CopyDiscard k => CategoryOf (GAME k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Associated Types

type (~>) 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type (~>) = Game :: GAME k -> GAME k -> Type
CopyDiscard k => Promonad (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

id :: forall (a :: GAME k). Ob a => Game a a Source Github #

(.) :: forall (b :: GAME k) (c :: GAME k) (a :: GAME k). Game b c -> Game a b -> Game a c Source Github #

CopyDiscard k => MonoidalProfunctor (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

one :: Game (Unit :: GAME k) (Unit :: GAME k) Source Github #

(**) :: forall (x1 :: GAME k) (x2 :: GAME k) (y1 :: GAME k) (y2 :: GAME k). Game x1 x2 -> Game y1 y2 -> Game (x1 ** y1) (x2 ** y2) Source Github #

CopyDiscard k => Profunctor (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

dimap :: forall (c :: GAME k) (a :: GAME k) (b :: GAME k) (d :: GAME k). (c ~> a) -> (b ~> d) -> Game a b -> Game c d Source Github #

lmap :: forall (c :: GAME k) (a :: GAME k) (b :: GAME k). (c ~> a) -> Game a b -> Game c b Source Github #

rmap :: forall (b :: GAME k) (d :: GAME k) (a :: GAME k). (b ~> d) -> Game a b -> Game a d Source Github #

(\\) :: forall (a :: GAME k) (b :: GAME k) r. ((Ob a, Ob b) => r) -> Game a b -> r Source Github #

type Unit Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type Unit = 'G (Unit :: k) (Unit :: k)
type (~>) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type (~>) = Game :: GAME k -> GAME k -> Type
type Ob (a :: GAME k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type Ob (a :: GAME k) = (a ~ 'G (Observation a) (Coutility a), Ob (Observation a), Ob (Coutility a))
type (a :: GAME k) ** (b :: GAME k) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

type (a :: GAME k) ** (b :: GAME k) = 'G (Observation a ** Observation b) (Coutility a ** Coutility b)

type family Observation (a :: GAME k) :: k where ... Source Github #

Equations

Observation ('G x s :: GAME k) = x 

type family Coutility (a :: GAME k) :: k where ... Source Github #

Equations

Coutility ('G x s :: GAME k) = s 

type Context (a :: GAME k) (b :: GAME k) = MonoidalLens (Unit :: k) (Coutility b) (Observation a) (Observation b) Source Github #

A joint state and continuation represented directly as an optic.

type Payoff = Rational Source Github #

Exact utilities used by the finite decision primitives.

data OpenGame (ss :: [Type]) (a :: GAME k) (b :: GAME k) where Source Github #

A game with an explicit finite, lazy profile catalogue. Custom constructors should supply each admissible profile once; enumeration can be exponential. Profiles use Fold of a strictified strategy list, so composing games concatenates their lists without introducing parenthesisation into profiles.

Constructors

OpenGame 

Fields

data Game (a :: GAME k) (b :: GAME k) where Source Github #

Hide the strategy list to obtain arrows of GAME. Use strategies to access profiles with their play and evaluators, or withGame for typed access.

Constructors

Game :: forall {k} (ss :: [Type]) (a :: GAME k) (b :: GAME k). OpenGame ss a b -> Game a b 

Instances

Instances details
CopyDiscard k => Promonad (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

id :: forall (a :: GAME k). Ob a => Game a a Source Github #

(.) :: forall (b :: GAME k) (c :: GAME k) (a :: GAME k). Game b c -> Game a b -> Game a c Source Github #

CopyDiscard k => MonoidalProfunctor (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

one :: Game (Unit :: GAME k) (Unit :: GAME k) Source Github #

(**) :: forall (x1 :: GAME k) (x2 :: GAME k) (y1 :: GAME k) (y2 :: GAME k). Game x1 x2 -> Game y1 y2 -> Game (x1 ** y1) (x2 ** y2) Source Github #

CopyDiscard k => Profunctor (Game :: GAME k -> GAME k -> Type) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.OpenGame

Methods

dimap :: forall (c :: GAME k) (a :: GAME k) (b :: GAME k) (d :: GAME k). (c ~> a) -> (b ~> d) -> Game a b -> Game c d Source Github #

lmap :: forall (c :: GAME k) (a :: GAME k) (b :: GAME k). (c ~> a) -> Game a b -> Game c b Source Github #

rmap :: forall (b :: GAME k) (d :: GAME k) (a :: GAME k). (b ~> d) -> Game a b -> Game a d Source Github #

(\\) :: forall (a :: GAME k) (b :: GAME k) r. ((Ob a, Ob b) => r) -> Game a b -> r Source Github #

data Strategy (a :: GAME k) (b :: GAME k) where Source Github #

A profile closed over its game's play and evaluator. It can be stored and evaluated in different contexts without exposing the hidden profile type.

Constructors

Strategy 

Fields

strategies :: forall {k} (a :: GAME k) (b :: GAME k). Game a b -> [Strategy a b] Source Github #

Enumerate profiles with their play and evaluator closed over the game.

play :: forall {k} (ss :: [Type]) (a :: GAME k) (b :: GAME k). OpenGame ss a b -> Fold ss -> MonoidalLens (Observation a) (Coutility a) (Observation b) (Coutility b) Source Github #

Play the selected profile's bundled strategy.

evaluate :: forall {k} (ss :: [Type]) (a :: GAME k) (b :: GAME k). OpenGame ss a b -> Fold ss -> Context a b -> [Diagnostic] Source Github #

Evaluate the selected profile's bundled strategy in a context.

memoisePlay :: forall k (a :: GAME k) (b :: GAME k). Game a b -> Game a b Source Github #

Share each profile's play and evaluator closures across repeated uses. The lazy catalogue retains its order and multiplicity; its hidden profile representation becomes the corresponding first-class Strategy.

equilibria :: forall {k} (a :: GAME k) (b :: GAME k). Game a b -> Context a b -> [Strategy a b] Source Github #

Equilibria within the supplied finite strategy catalogue.

withGame :: forall {k} (a :: GAME k) (b :: GAME k) r. Game a b -> (forall (ss :: [Type]). OpenGame ss a b -> r) -> r Source Github #

outputs :: forall k (a :: GAME k) (b :: GAME k). CopyDiscard k => Strategy a b -> Observation a ~> Observation b Source Github #

runStrategy :: forall k (a :: GAME k) (b :: GAME k). CopyDiscard k => Strategy a b -> Context a b -> (Unit :: k) ~> (Observation b ** Coutility a) Source Github #

Execute both passes with the same residual, retaining joint outcomes.

fromMonoidalLens :: forall k (x :: k) (s :: k) (y :: k) (r :: k). CopyDiscard k => MonoidalLens x s y r -> OpenGame ('[] :: [Type]) ('G x s) ('G y r) Source Github #

A nonstrategic component with one empty profile and no decision checks.

fromArrows :: forall k (x :: k) (y :: k) (r :: k) (s :: k). CopyDiscard k => (x ~> y) -> (r ~> s) -> OpenGame ('[] :: [Type]) ('G x s) ('G y r) Source Github #

parallel :: forall k (ss :: [Type]) (ts :: [Type]) (a :: GAME k) (b :: GAME k) (c :: GAME k) (d :: GAME k). CopyDiscard k => OpenGame ss a b -> OpenGame ts c d -> OpenGame (ss ++ ts) (a ** c) (b ** d) Source Github #

Independent parallel play; each deviation holds the other strategy fixed.

reindex :: forall {k} (ss :: [Type]) (ts :: [Type]) (a :: GAME k) (b :: GAME k). [Fold ss] -> Strictified ss ts -> OpenGame ts a b -> OpenGame ss a b Source Github #