{-# LANGUAGE CPP #-}
module Algebra.Heyting.BoolRing
( BoolRing (..)
, Semiring (..)
, (<+>)
) where
import Prelude
#if __GLASGOW_HASKELL__ < 808
import Data.Monoid (Monoid (..))
#endif
#if __GLASGOW_HASKELL__ < 804
import Data.Semigroup (Semigroup (..))
#endif
import Algebra.Lattice (bottom, top, (/\), (\/))
import Data.Semiring (Semiring (..), (<+>))
import Algebra.Heyting
newtype BoolRing a = BoolRing { BoolRing a -> a
getBoolRing :: a }
instance Heyting a => Semigroup (BoolRing a) where
(BoolRing a
a) <> :: BoolRing a -> BoolRing a -> BoolRing a
<> (BoolRing a
b) = a -> BoolRing a
forall a. a -> BoolRing a
BoolRing (a -> BoolRing a) -> a -> BoolRing a
forall a b. (a -> b) -> a -> b
$ (a -> a
forall a. Heyting a => a -> a
neg a
a a -> a -> a
forall a. Lattice a => a -> a -> a
/\ a
b) a -> a -> a
forall a. Lattice a => a -> a -> a
\/ (a
a a -> a -> a
forall a. Lattice a => a -> a -> a
/\ a -> a
forall a. Heyting a => a -> a
neg a
b)
instance Heyting a => Monoid (BoolRing a) where
mempty :: BoolRing a
mempty = a -> BoolRing a
forall a. a -> BoolRing a
BoolRing a
forall a. BoundedJoinSemiLattice a => a
bottom
#if __GLASGOW_HASKELL__ <= 804
mappend = (<>)
#endif
instance Heyting a => Semiring (BoolRing a) where
BoolRing a
a <.> :: BoolRing a -> BoolRing a -> BoolRing a
<.> BoolRing a
b = a -> BoolRing a
forall a. a -> BoolRing a
BoolRing (a
a a -> a -> a
forall a. Lattice a => a -> a -> a
\/ a
b)
one :: BoolRing a
one = a -> BoolRing a
forall a. a -> BoolRing a
BoolRing a
forall a. BoundedMeetSemiLattice a => a
top