imp-ppl-0.1.0.0: src/Imp/Examples/Polytope.hs
{-# LANGUAGE QualifiedDo, RebindableSyntax #-}
-- | Polytope credal sets from composed intervals.
module Imp.Examples.Polytope
( Three(..)
, polytope
, polytope2
) where
import Imp
-- | Three-valued outcome.
data Three = Red | Green | Blue
deriving stock (Eq, Ord, Show)
-- | Two independent intervals composed to give an imprecise distribution.
polytope :: Imp '["p", "q"] Three
polytope = Imp.do
p <- interval @"p" 0.2 0.8
q <- interval @"q" 0.3 0.7
Imp.return $ if p then Red else (if q then Green else Blue)
-- | Three intervals composed to give a finer polytope.
polytope2 :: Imp '["b", "g", "r"] Three
polytope2 = Imp.do
r <- interval @"r" 0.2 0.5
g <- interval @"g" 0.2 0.5
b <- interval @"b" 0.2 0.5
Imp.return $ if r then Red else (if g then Green else (if b then Blue else Red))