/02-development/Hets/GMP/GMP-CoLoSS/GMP/Logics/DisjUnion.hs

https://bitbucket.org/jmelo_lyncode/thesis · Haskell · 57 lines · 31 code · 9 blank · 17 comment · 4 complexity · c8cc4f5f32c12568730e287908f1193b MD5 · raw file

  1. {- | Module : $Header$
  2. - Description : Implementation of logic instance of disjoint union of features
  3. - Copyright : (c) Daniel Hausmann & Georgel Calin & Lutz Schroeder, DFKI Lab Bremen,
  4. - Rob Myers & Dirk Pattinson, Department of Computing, ICL
  5. - License : GPLv2 or higher, see LICENSE.txt
  6. - Maintainer : hausmann@dfki.de
  7. - Stability : provisional
  8. - Portability : portable
  9. -
  10. - Provides the implementation of the matching functions of disjoint union of features.
  11. -}
  12. module GMP.Logics.DisjUnion where
  13. import List
  14. import Ratio
  15. import Maybe
  16. import Debug.Trace
  17. import Text.ParserCombinators.Parsec
  18. import GMP.Logics.Generic
  19. import GMP.Parser
  20. --------------------------------------------------------------------------------
  21. -- instance of feature for Disjoint union of features
  22. --------------------------------------------------------------------------------
  23. data DisjUnion a b c = DisjUnion ((a c),(b c)) deriving (Eq, Ord, Show)
  24. instance (Feature a (c (d e)), Feature b (c (d e)), Eq (a (c (d e))), Eq (b (c (d e))), SigFeature c d e, Eq (d e)) =>
  25. NonEmptyFeature (DisjUnion a b) c d e where
  26. nefMatch flags seq = let fstposlits = [ (Mod p) | (Mod (DisjUnion (p,q))) <- seq ]
  27. fstneglits = [ Neg (Mod p) | Neg (Mod (DisjUnion (p,q))) <- seq ]
  28. sndposlits = [ (Mod q) | (Mod (DisjUnion (p,q))) <- seq ]
  29. sndneglits = [ Neg (Mod q) | Neg (Mod (DisjUnion (p,q))) <- seq ]
  30. in if (flags!!1)
  31. then trace ("\n [+-matching this:] " ++ (pretty_list seq)) $
  32. [[[Sequent (fstposlits ++ fstneglits)]]]++[[[Sequent (sndposlits ++ sndneglits)]]]
  33. else [[[Sequent (fstposlits ++ fstneglits)]]]++[[[Sequent (sndposlits ++ sndneglits)]]]
  34. nefPretty d = case d of DisjUnion (p,q) -> "[DisjUnion](" ++ fPretty p ++ fPretty q ++ ")"
  35. nefDisj2Conj (Mod (DisjUnion (p,q))) = Mod (DisjUnion ((\(Mod phi) -> phi) (fDisj2Conj (Mod p)),
  36. (\(Mod phi) -> phi) (fDisj2Conj (Mod q))))
  37. nefNegNorm (Mod (DisjUnion (p,q))) = Mod (DisjUnion ((\(Mod phi) -> phi) (fNegNorm (Mod p)),
  38. (\(Mod phi) -> phi) (fNegNorm (Mod q))))
  39. nefFeatureFromSignature (DisjUnion (p,q)) = \phi -> (DisjUnion (((fFeatureFromSignature p) phi), ((fFeatureFromSignature q) phi)))
  40. nefStripFeature (DisjUnion (p,q)) = fStripFeature p
  41. nefParser (DisjUnion (p,q)) = return (\(phi:psi:_) -> (DisjUnion (((fFeatureFromSignature p) [phi]), ((fFeatureFromSignature q) [psi]))))
  42. nefSeparator sig = "+"
  43. --------------------------------------------------------------------------------
  44. -- instance of sigFeature for disjoint union of features
  45. --------------------------------------------------------------------------------
  46. instance (Eq (b (c (d e))), Eq (a (c (d e))), Feature b (c (d e)), Feature a (c (d e)),
  47. SigFeature c d e, Eq (d e)) => NonEmptySigFeature (DisjUnion a b) c d e where
  48. neGoOn sig flag = genericPGoOn sig flag