-- analyzes a logic definition
anaLogicDef :: LogicDef -> DGraph -> IO DGraph
anaLogicDefH :: LogicFram lid sublogics basic_spec sentence symb_items
symb_map_items sign morphism symbol raw_symbol
=> lid -> LogicDef -> DGraph -> IO DGraph
anaLogicDefH ml ld dg = do
case retrieveDiagram ml ld dg of
Result _ (Just (ltruth,lmod,lpf)) -> do
buildLogic ml (newlogicName ld) ltruth lmod lpf
return $ addLogicDef2DG ld dg
-- creates a node for the logic definition
addLogicDef2DG :: LogicDef -> DGraph -> DGraph
let node = getNewNodeDG dg
nodeName = emptyNodeName { getName = name }
info = newNodeInfo DGBasic
extSign = makeExtSign Framework ld
gth = noSensGTheory Framework extSign startSigId
nodeLabel = newInfoNodeLab nodeName info gth
dg1 = insNodeDG (node,nodeLabel) dg
emptyNode = EmptyNode $ Logic Framework
genSig = GenSig emptyNode [] emptyNode
nodeSig = NodeSig node $ G_sign Framework extSign startSigId
gEntry = SpecEntry $ ExtGenSig genSig nodeSig
dg2 = dg1 { globalEnv =
Map.insert name gEntry $ globalEnv dg1 }
{- constructs the diagram in the signature category of the meta logic
which represents the object logic -}
retrieveDiagram :: LogicFram lid sublogics basic_spec sentence symb_items
symb_map_items sign morphism symbol raw_symbol
=> lid -> LogicDef -> DGraph ->
Result (morphism, morphism, morphism)
retrieveDiagram ml (LogicDef _ _ sy t _ m p) dg = do
lSyn <- lookupSig ml sy dg
ltruth <- lookupMorph ml t dg
lmod <- lookupMorph ml m dg
lpf <- lookupMorph ml p dg
if (dom ltruth /= getBaseSig ml || cod ltruth /= lSyn) then
error $ "The morphism " ++ (show t) ++ " must go from Base to " ++
if (dom lmod /= lSyn) then
error $ "The morphism " ++ (show m) ++ " must go from " ++
if (dom lpf /= lSyn) then
error $ "The morphism " ++ (show p) ++ " must go from " ++
-- looks up a signature by name
lookupSig :: Logic lid sublogics basic_spec sentence symb_items symb_map_items
sign morphism symbol raw_symbol proof_tree
=> lid -> SIG_NAME -> DGraph -> Result sign
let extSig = case lookupGlobalEnvDG n dg of
Just (SpecEntry es) -> es
_ -> error $ "The signature " ++ (show n) ++
ExtGenSig _ (NodeSig _ (G_sign l' (ExtSign sig _) _)) ->
then error $ "The signature " ++ (show n) ++
" is not in the logic " ++ (show l) ++ "."
else coercePlainSign l' l "" sig
-- looks up a morphism by name
lookupMorph :: Logic lid sublogics basic_spec sentence symb_items symb_map_items
sign morphism symbol raw_symbol proof_tree
=> lid -> MORPH_NAME -> DGraph -> Result morphism
let extView = case lookupGlobalEnvDG n dg of
Just (ViewEntry ev) -> ev
Just (StructEntry ev) -> ev
_ -> error $ "The morphism " ++ (show n) ++
ExtViewSig _ (GMorphism c _ _ morph _) _ -> do
then error $ "The morphism " ++ (show n) ++
" is not in the logic " ++ (show l) ++ "."
else coerceMorphism l' l "" morph
-- constructs the logic instance for the object logic
buildLogic :: LogicFram lid sublogics basic_spec sentence symb_items
symb_map_items sign morphism symbol raw_symbol proof_tree
=> lid -> NAME -> morphism -> morphism -> morphism -> IO ()
buildLogic ml lT ltruth _ _ = do
exists <- doesDirectoryExist l
error $ "The directory " ++ l ++ " already exists.\n" ++
"Please choose a different object logic name." else do
let logicC = writeLogic ml l
let syntaxC = writeSyntax ml l ltruth
writeFile (l ++ "/" ++ "Logic_" ++ l ++ ".hs") logicC