CASL2SubCFOL.inline.hs revision bba825b39570777866d560bfde3807731131097e
Copyright : (c) Zicheng Wang, C.Maeder Uni Bremen 2002-2006
Portability : non-portable (imports Logic.Comorphism)
module Comorphisms.CASL2SubCFOL where
import Logic.Logic
import Logic.Comorphism
import CASL.Logic_CASL
import CASL.AS_Basic_CASL
import CASL.Sign
import CASL.Morphism
import CASL.Sublogic as SL hiding(bottom)
import CASL.Overload
import CASL.Fold
import CASL.Project
import CASL.Simplify
import Common.Id
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Common.Lib.Rel as Rel
import Common.AS_Annotation
import Common.ProofUtils
import Data.List (zip)
sourceSublogic CASL2SubCFOL = SL.top
let bsrts = sortsWithBottom sig $ Set.unions $
in return (encodeSig bsrts sig, disambiguateSens Set.empty . nameSens
mor { msource = encodeSig (sortsWithBottom src Set.empty) src
, mtarget = encodeSig (sortsWithBottom tar Set.empty) tar
, fun_map = Map.map (\ (i, _) -> (i, Total)) $ fun_map mor }
Set.singleton s { symbType = totalizeSymbType $ symbType s }
let ops = Map.elems $ opMap sign
allSortsWithBottom $ Set.unions $ formBotSrts :
Set.filter ( \ t -> any
(flip Set.member given) $ opArgs t)) ops
in if Set.isSubsetOf more given then given
else collect $ Set.union more given
defined :: Set.Set SORT -> TERM f -> SORT -> Range -> FORMULA f
if Set.member s bsorts then Predication
defVards :: Set.Set SORT -> [VAR_DECL] -> FORMULA f
defVars :: Set.Set SORT -> VAR_DECL -> [FORMULA f]
defVar :: Set.Set SORT -> SORT -> Token -> FORMULA f
argSorts :: Constraint -> Set.Set SORT
argSorts c = Set.unions $ map (argsOpSymb . fst) $ opSymbs c
Qual_op_name _ ot _ -> Set.fromList $ args_OP_TYPE ot
totalizeConstraint :: Set.Set SORT -> Constraint -> Constraint
(if Set.member (newSort c) bsrts then addBottomAlt else id)
encodeSig :: Set.Set SORT -> Sign f e -> Sign f e
encodeSig bsorts sig = if Set.null bsorts then sig else
botTypes = Set.map botType bsorts
botOpMap = Map.insert bottom botTypes newTotalMap
defTypes = Set.map defType bsorts
newpredMap = Map.insert defPred defTypes $ predMap sig
rel = Rel.irreflex $ sortRel sig
projOpMap = Set.fold ( \ t ->
Map.insert (uniqueProjName $ toOP_TYPE t)
$ Set.singleton t) botOpMap setprojOptype
generateAxioms :: Set.Set SORT -> Sign f e -> [Named (FORMULA ())]
\ . exists x:s.d(x) %(ga_nonEmpty)%" ++
sig2 = sig { sortRel = Rel.irreflex $ sortRel sig }
sortList = Set.toList bsorts
opList = [(f,t) | (f,types) <- Map.toList $ opMap sig,
t <- Set.toList types ]
predList = [(p,t) | (p,types) <- Map.toList $ predMap sig,
t <- Set.toList types ]
mkVars n = [mkSimpleId ("x_"++show i) | i<-[1..n]]
codeRecord :: Set.Set SORT -> (f -> f) -> Record f (FORMULA f) (TERM f)
codeFormula :: Set.Set SORT -> FORMULA () -> FORMULA ()
rmDefsRecord :: Set.Set SORT -> (f -> f) -> Record f (FORMULA f) (TERM f)
rmDefs :: Set.Set SORT -> (f -> f) -> FORMULA f -> FORMULA f
{ foldMembership = \ _ _ s _ -> Set.singleton s
, foldCast = \ _ _ s _ -> Set.singleton s }
botFormulaSorts :: FORMULA f -> Set.Set SORT
botFormulaSorts = foldFormula (botSorts $ const Set.empty)