{- |
Module : ./Temporal/ModalCaslToNuSmvLtl.hs
Copyright : (c) Klaus Hartke, Uni Bremen 2008
License : GPLv2 or higher, see LICENSE.txt
Maintainer : Christian.Maeder@dfki.de
Stability : experimental
Portability : portable
-}
module ModalCaslToNuSmvLtl where
import Control.Monad as Monad
import Data.Maybe as Maybe
import Text.ParserCombinators.Parsec hiding (State)
import ModalCasl as Casl
import NuSmvLtl as Ltl
{- ----------------------------------------------------------------------------
Convert Modal CASL formulas to LTL formulas recognized by NuSMV
---------------------------------------------------------------------------- -}
convert :: Casl.StateFormula a -> Maybe (Ltl.Formula a)
convert (Casl.A phi) = convert' phi
convert _ = Nothing
convert' :: Casl.PathFormula a -> Maybe (Ltl.Formula a)
(convert' psi)
Casl.Pnot psi))
(phi `Casl.Pand` psi))
convert' (Casl.XPast phi) = liftM Ltl.Y (convert' phi)
convert' (Casl.GPast phi) = liftM Ltl.H (convert' phi)
convert' (Casl.FPast phi) = liftM Ltl.O (convert' phi)
convert' (Casl.UPast phi psi) = convert' (psi `Casl.BPast`
convert' (Casl.BPast phi psi) = liftM2 Ltl.T (convert' phi) (convert' psi)
(phi `Casl.Pand` psi))
convert' (Casl.UPast' phi psi) = liftM2 Ltl.S (convert' phi) (convert' psi)
convert' (Casl.XPast' phi) = liftM Ltl.Z (convert' phi)
convert' _ = Nothing
-- ----------------------------------------------------------------------------
data Expr = Expr String
instance Show Expr where show (Expr x) = x
expr = liftM Expr (many1 (lower <|> char '=' <|> char '_' <|> char '.' <|>
digit))
parseAndConvert :: String -> Formula Expr
parseAndConvert text = let Right x = parse (Casl.parser expr) "<<input>>" text
Just y = convert x in y
-- ----------------------------------------------------------------------------