Morphism.hs revision 1a38107941725211e7c3f051f7a8f5e12199f03a
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh{-# LANGUAGE DeriveDataTypeable #-}
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhModule : $Header$
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhDescription : Morphisms in Propositional logic
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhCopyright : (c) Dominik Luecke, Uni Bremen 2007
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhLicense : GPLv2 or higher, see LICENSE.txt
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhMaintainer : luecke@informatik.uni-bremen.de
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhStability : experimental
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhPortability : portable
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh Definition of morphisms for propositional logic
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh Till Mossakowski, Joseph Goguen, Razvan Diaconescu, Andrzej Tarlecki.
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh What is a Logic?.
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh In Jean-Yves Beziau (Ed.), Logica Universalis, pp. 113-@133. Birkhaeuser.
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh ( Morphism (..) -- datatype for Morphisms
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , pretty -- pretty printing
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , idMor -- identity morphism
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , isLegalMorphism -- check if morhpism is ok
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , composeMor -- composition
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , inclusionMap -- inclusion map
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , mapSentence -- map of sentences
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , mapSentenceH -- map of sentences, without Result type
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , applyMap -- application function for maps
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , applyMorphism -- application function for morphism
4a13940dc2990df0a798718d3a3f9cf1566c2217bjh , morphismUnion
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhimport qualified Data.Map as Map
4a13940dc2990df0a798718d3a3f9cf1566c2217bjhimport qualified Data.Set as Set
import Propositional.Sign as Sign
import qualified Propositional.AS_BASIC_Propositional as AS_BASIC
import Common.Id as Id
import Common.Result
import Common.Doc
import Common.DocUtils
import qualified Common.Result as Result
import Control.Monad (unless)
, propMap :: Map.Map Id Id
pdom = Map.keysSet $ propMap pmor
pcodom = Set.map (applyMorphism pmor) psource
applyMorphism mor idt = Map.findWithDefault idt idt $ propMap mor
applyMap :: Map.Map Id Id -> Id -> Id
applyMap pmap idt = Map.findWithDefault idt idt pmap
, propMap = if Map.null gMap then fMap else
Set.fold ( \ i -> let j = applyMap gMap (applyMap fMap i) in
if i == j then id else Map.insert i j)
Map.empty $ items fSource }
<> pretty y <> rparen) $ Map.assocs $ propMap m)
, propMap = Map.empty }
AS_BASIC.Conjunction form rn ->
AS_BASIC.Conjunction (map (mapSentenceH mor) form) rn
AS_BASIC.Disjunction form rn ->
AS_BASIC.Disjunction (map (mapSentenceH mor) form) rn
$ id2SimpleId $ applyMorphism mor $ Id.simpleIdToId predH
morphismUnion :: Morphism -> Morphism -> Result.Result Morphism
(pds, pmap) = foldr ( \ (i, j) (ds, m) -> case Map.lookup i m of
Nothing -> (ds, Map.insert i j m)
(Map.toList pmap2 ++ map (\ a -> (a, a))