Symbol.hs revision 6e2dba19f0c5ef183c1ac9cf1dff55b9626aeabd
{-# OPTIONS -fallow-undecidable-instances #-}
{- |
Module : $Header$
Description : Instance of class Logic for propositional logic
Copyright : (c) Dominik Luecke, Uni Bremen 2007
License : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
Maintainer : luecke@tzi.de
Stability : experimental
Portability : portable
Definition of symbols for propositional logic
-}
module Propositional.Symbol
(
Symbol (..) -- Symbol type
, pretty -- pretty printing for Symbols
, symOf -- Extracts the symbols out of a signature
, getSymbolMap -- Determines the symbol map
, getSymbolName -- Determines the name of a symbol
, idToRaw -- Creates a raw symbol
, symbolToRaw -- Convert symbol to raw symbol
, matches -- does a symbol match a raw symbol?
, applySymMap -- application function for symbol maps
) where
import qualified Common.Id as Id
import Common.Doc
import Common.DocUtils
import qualified Data.Set as Set
import qualified Data.Map as Map
import qualified Propositional.Sign as Sign
import qualified Propositional.Morphism as Morphism
-- | Datatype for symbols
newtype Symbol = Symbol {symName :: Id.Id}
deriving (Show, Eq, Ord)
instance Pretty Symbol where
pretty = printSymbol
printSymbol :: Symbol -> Doc
printSymbol x = pretty $ symName x
-- | Extraction of symbols from a signature
-- | Determines the symbol map of a morhpism
getSymbolMap :: Morphism.Morphism -> Map.Map Symbol Symbol
getSymbolMap f = Map.foldWithKey
(\ k a -> Map.insert Symbol{symName=k} Symbol{symName=a})
-- | Determines the name of a symbol
getSymbolName :: Symbol -> Id.Id
getSymbolName sym = symName sym
-- | make a raw_symbol
idToRaw :: Id.Id -> Symbol
idToRaw mid = Symbol {symName = mid}
-- | convert to raw symbol
symbolToRaw :: Symbol -> Symbol
symbolToRaw = id
-- | does a smybol match a raw symbol?
matches :: Symbol -> Symbol -> Bool
matches s1 s2 = s1 == s2
-- | application function for Symbol Maps
applySymMap :: Map.Map Symbol Symbol -> Symbol -> Symbol
applySymMap smap idt = Map.findWithDefault idt idt $ smap