| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
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
- data GAME k = G k k
- type family Observation (a :: GAME k) :: k where ...
- type family Coutility (a :: GAME k) :: k where ...
- type Context (a :: GAME k) (b :: GAME k) = MonoidalLens (Unit :: k) (Coutility b) (Observation a) (Observation b)
- type Payoff = Rational
- data Diagnostic = Diagnostic {
- player :: String
- observation :: String
- chosenAction :: String
- payoff :: Payoff
- optimalActions :: [String]
- optimalPayoff :: Payoff
- equilibrium :: Bool
- isEquilibrium :: [Diagnostic] -> Bool
- data OpenGame (ss :: [Type]) (a :: GAME k) (b :: GAME k) where
- data Game (a :: GAME k) (b :: GAME k) where
- data Strategy (a :: GAME k) (b :: GAME k) where
- strategies :: forall {k} (a :: GAME k) (b :: GAME k). Game a b -> [Strategy a b]
- 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)
- evaluate :: forall {k} (ss :: [Type]) (a :: GAME k) (b :: GAME k). OpenGame ss a b -> Fold ss -> Context a b -> [Diagnostic]
- memoisePlay :: forall k (a :: GAME k) (b :: GAME k). Game a b -> Game a b
- equilibria :: forall {k} (a :: GAME k) (b :: GAME k). Game a b -> Context a b -> [Strategy a b]
- withGame :: forall {k} (a :: GAME k) (b :: GAME k) r. Game a b -> (forall (ss :: [Type]). OpenGame ss a b -> r) -> r
- outputs :: forall k (a :: GAME k) (b :: GAME k). CopyDiscard k => Strategy a b -> Observation a ~> Observation b
- runStrategy :: forall k (a :: GAME k) (b :: GAME k). CopyDiscard k => Strategy a b -> Context a b -> (Unit :: k) ~> (Observation b ** Coutility a)
- 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)
- 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)
- 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)
- 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
Documentation
Constructors
| G k k |
Instances
type family Observation (a :: GAME k) :: k where ... Source Github #
Equations
| Observation ('G x s :: GAME k) = x |
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.
data Diagnostic Source Github #
A local best-response check, including all tied optimal actions.
Constructors
| Diagnostic | |
Fields
| |
Instances
| Show Diagnostic Source Github # | |
Defined in Proarrow.Category.Instance.OpenGame | |
| Eq Diagnostic Source Github # | |
Defined in Proarrow.Category.Instance.OpenGame Methods (==) :: Diagnostic -> Diagnostic -> Bool Github # (/=) :: Diagnostic -> Diagnostic -> Bool Github # | |
| Ord Diagnostic Source Github # | |
Defined in Proarrow.Category.Instance.OpenGame Methods compare :: Diagnostic -> Diagnostic -> Ordering Github # (<) :: Diagnostic -> Diagnostic -> Bool Github # (<=) :: Diagnostic -> Diagnostic -> Bool Github # (>) :: Diagnostic -> Diagnostic -> Bool Github # (>=) :: Diagnostic -> Diagnostic -> Bool Github # max :: Diagnostic -> Diagnostic -> Diagnostic Github # min :: Diagnostic -> Diagnostic -> Diagnostic Github # | |
isEquilibrium :: [Diagnostic] -> Bool Source Github #
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.
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
| CopyDiscard k => Promonad (Game :: GAME k -> GAME k -> Type) Source Github # | |
| CopyDiscard k => MonoidalProfunctor (Game :: GAME k -> GAME k -> Type) Source Github # | |
| CopyDiscard k => Profunctor (Game :: GAME k -> GAME k -> Type) Source Github # | |
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 #