-- | Simplifies SOP terms using
--
-- * 'mergeS'
-- * 'mergeP'
-- * 'reduceExp'
simplifySOP :: (Ord v, Ord c) => SOP v c -> SOP v c
simplifySOP
  = S
  . sort . filter (not . zeroP)
  . mergeWith mergeP
  . map (P . sort . map reduceExp . mergeWith mergeS . unP)
  . unS
simplifySOP :: (Ord v, Ord c) => SOP v c -> SOP v c
simplifySOP
  = S
  . sort . filter (not . zeroP)
  . mergeWith mergeP
  . map (P . sort . map reduceExp . mergeWith mergeS . unP)
  . unS
simplifySOP
  = S
  . sort . filter (not . zeroP)
  . mergeWith mergeP
  . map (P . sort . map reduceExp . mergeWith mergeS . unP)
  . unS