CASL2NNF.hs revision 414029fc573cb2506241ed5a17643f9f721502b8
05bf9cbe382548c2665dd01a6a402640c9ec3813Christian Maeder{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-}
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederModule : $Header$
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederDescription : negation normal form
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederCopyright : (c) Mihai Codescu, 2016
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuLicense : GPLv2 or higher, see LICENSE.txt
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederMaintainer : codescu@iws.cs.uni-magdeburg.de
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederStability : provisional
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaederPortability : non-portable (imports Logic.Comorphism)
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maederimport CASL.Sublogic as SL hiding (bottom)
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maederimport qualified Data.Set as Set
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maederdata CASL2NNF = CASL2NNF deriving Show
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maederinstance Language CASL2NNF where
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder language_name CASL2NNF = "CASL2NNF"
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maederinstance Comorphism CASL2NNF
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder CASL CASL_Sublogics
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder CASLBasicSpec CASLFORMULA SYMB_ITEMS SYMB_MAP_ITEMS
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder Symbol RawSymbol ProofTree
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder CASL CASL_Sublogics
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder CASLBasicSpec CASLFORMULA SYMB_ITEMS SYMB_MAP_ITEMS
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder Symbol RawSymbol ProofTree where
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder sourceLogic CASL2NNF = CASL
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder sourceSublogic CASL2NNF = SL.caslTop
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder targetLogic CASL2NNF = CASL
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder mapSublogic CASL2NNF sl = if SL.which_logic sl == SL.Horn
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder map_theory CASL2NNF = mapTheory
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder map_morphism CASL2NNF = return -- morphisms are mapped identically
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder map_sentence CASL2NNF _ s = return $ negationNormalForm s
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder map_symbol CASL2NNF _ = Set.singleton . id
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder has_model_expansion CASL2NNF = True
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder is_weakly_amalgamable CASL2NNF = True
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaedermapTheory :: (CASLSign, [Named CASLFORMULA]) -> Result (CASLSign, [Named CASLFORMULA])
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaedermapTheory (sig, nsens) = do
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder return (sig, map (\nsen -> nsen{sentence = negationNormalForm $ sentence nsen}) nsens)
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder-- nnf, implemented recursively
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaedernegationNormalForm :: CASLFORMULA -> CASLFORMULA
286f4deb69d3912337bb09dd7f81284d12912ce8Christian MaedernegationNormalForm sen = case sen of
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder Quantification q vars qsen _ ->
286f4deb69d3912337bb09dd7f81284d12912ce8Christian Maeder Quantification q vars (negationNormalForm qsen) nullRange