ideas-math-1.2: src/Domain/RelationAlgebra/Strategies.hs
-----------------------------------------------------------------------------
-- Copyright 2015, Open Universiteit Nederland. This file is distributed
-- under the terms of the GNU General Public License. For more information,
-- see the file "LICENSE.txt", which is included in the distribution.
-----------------------------------------------------------------------------
-- |
-- Maintainer : bastiaan.heeren@ou.nl
-- Stability : provisional
-- Portability : portable (depends on ghc)
--
-----------------------------------------------------------------------------
-- $Id: Strategies.hs 7527 2015-04-08 07:58:06Z bastiaan $
module Domain.RelationAlgebra.Strategies (toCNF) where
import Domain.RelationAlgebra.Formula
import Domain.RelationAlgebra.Rules
import Ideas.Common.Library
import Prelude
toCNF :: LabeledStrategy (Context RelAlg)
toCNF = label "To CNF" $
repeatS $ label "step1" step1
|> label "step2" step2
|> label "step3" step3
where
step1 = oncetd $ useRules $
[ ruleRemCompl, ruleRemRedunExprs, ruleDoubleNegation
, ruleIdempOr, ruleIdempAnd, ruleAbsorp, ruleAbsorpCompl
] ++ invRules
step2 = oncetd $ useRules
[ ruleCompOverUnion, ruleAddOverIntersec, ruleDeMorganOr, ruleDeMorganAnd
, ruleNotOverComp, ruleNotOverAdd
]
step3 = somewhere $ liftToContext
ruleUnionOverIntersec
-- local helper-function
useRules :: [Rule RelAlg] -> Strategy (Context RelAlg)
useRules = alternatives . map liftToContext