AnalysisStructured.hs revision c616e681da8c052b62e14247fea522da099ac0e4
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Analysis of structured specifications
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Follows the extended static semantic rules in:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder T. Mossakowski, S. Autexier, D. Hutter, P. Hoffman:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder CASL Proof calculus.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Available from http://www.informatik.uni-bremen.de/~till/calculus.ps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder To appear in the CASL book.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Check that translations and reductions do not effect local env
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Unions (already in the parser) need unions of logics
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder = suprema in the lattice of default logic inclusions!
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (also needed by closed specs)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Should we use institution independent analysis over the Grothendieck logic?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder abstract syntax + devgraph would have to be changed to homogeneous case
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder logic translations are symbol maps in the Grothendieck logic
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Problem with this approach: symbol functor goes into rel,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder and induced_from_morphism gets difficult to implement
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Unions need inclusion morphisms. Should these play a special role?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder At least we need a function delivering the inclusion morphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder between two (sub)signatures.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder In most logics, inclusions could be represented specially, such
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder that composition for them becomes fast.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Should we even identify an inclusion subcategory?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Then inclusions are represented by pair of signatures
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (Non-inclusions could be specially displayed in the DG)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Treatment of translations and reductions along logic translations
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (see WADT 02 paper).
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Open question:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder may local env be translated, and even reduced, along logic translations?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder if yes: how is local env linked to signature of resulting spec?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (important e.g. for checking that local env is not being renamed?)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder does signature+comorphism suffice, such that c(local env)\subseteq sig?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder if no: this means that only closed specs may be translated
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Revealings wihout translations: just one arrow
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Pushouts: only admissible within one logic?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Optimizations:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Union nodes can be extended by a basic spec directly no new node needed)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Also: free, cofree nodes
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Common.Lib.Graph hiding (empty)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Common.Lib.Set hiding (filter)
c616e681da8c052b62e14247fea522da099ac0e4Christian Maederimport qualified Common.Lib.Map as Map
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Data.List hiding (union)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederpretty x = show $ printText0 emptyGlobalAnnos x
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaederlookupNode n dg = lab' $ context n dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaedersetFilter p s = fromList (filter p (toList s))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaedersetAny p s = any p (toList s)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaedersetAll p s = all p (toList s)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeders1 `disjoint` s2 = s1 `intersection` s2 == empty
c616e681da8c052b62e14247fea522da099ac0e4Christian MaederdomFM m = fromList (Map.keys m)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_SPEC :: GlobalAnnos -> GlobalEnv -> DGraph -> NodeSig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Maybe SIMPLE_ID -> SPEC
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result (NodeSig,DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_SPEC gannos genv dg nsig name sp =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Basic_spec (G_basic_spec lid bspec) ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do G_sign lid' sigma' <- return (getSig nsig)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigma <- rcoerce lid' lid nullPos sigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder b <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ("no basic analysis for logic "++language_name lid)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (basic_analysis lid)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (sigma_local, sigma_complete, ax) <- b (bspec,sigma,gannos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid sigma_local, -- only the delta
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid ax,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGBasic }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dg' = insNode (node,node_contents) dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = undefined, -- where to get it from ???
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGExtension }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dg'' = case nsig of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder EmptyNode _ -> dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder NodeSig (n,_) -> insEdge (n,node,link) dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig (node,G_sign lid sigma_complete),dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Translation asp ren ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Translation of empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor <- ana_RENAMING dg (getSig nsig') ren
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? check that mor is identity on local env
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma' = cod Grothendieck mor
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? too simplistic for non-comorphism inter-logic translations
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'), -- delta is empty
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGTranslation }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (n',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = mor,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGTranslation })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Reduction asp restr ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma = getSig nsig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Reduction of empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (hmor,tmor) <- ana_RESTRICTION dg gsigma gsigma' restr
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- we treat hiding and revealing differently
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- in order to keep the dg as simple as possible
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let gsigma' = dom Grothendieck hmor
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? too simplistic for non-comorphism inter-logic reductions
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGHiding }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (n',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = hmor,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = HidingDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGHiding })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just tmor' ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let gsigma1 = dom Grothendieck tmor'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma'' = cod Grothendieck tmor'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? too simplistic for non-comorphism inter-logic reductions
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid1 sigma1 <- return gsigma1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid'' sigma'' <- return gsigma''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let [node1,node''] = newNodes 1 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents1 = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = Nothing,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid1 (empty_signature lid1),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid1 [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGRevealing }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link1 = (n',node1,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = hmor,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = HidingDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGRevealing })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents'' = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid'' (empty_signature lid''),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid'' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGRevealTranslation }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link'' = (node1,node'',DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = tmor',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGRevealTranslation })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node'',gsigma''),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link'' $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node'',node_contents'') $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link1 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node1,node_contents1) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Union [] pos -> return (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Union asps pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sps = map item asps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigs,dg') <- let ana r sp = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigs,dg) <- r
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig,dg1) <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (nsig:nsigs,dg1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder in foldl ana (return ([],dg)) sps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let nsigs' = reverse nsigs
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nodes = catMaybes (map getNode nsigs')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' bigSigma <-
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder homogeneousGsigManyUnion (headPos pos) (map getSig nsigs')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGUnion }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = undefined, -- ??? how to get it?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGUnion }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (let insE dg n = insEdge (n,node,link) dg -- link should vary
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder in (NodeSig(node,G_sign lid' bigSigma),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldl insE (insNode (node,node_contents) dg') nodes))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Extension [] pos -> return (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Extension asps pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldl ana (return (nsig,dg)) namedSps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder namedSps = zip (map (\_ -> Nothing) (tail asps) ++ [name]) (map item asps)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res (name,sp) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig,dg) <- res
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_SPEC gannos genv dg nsig name sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Free_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Free spec over empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'), -- delta is empty
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGFree }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (n',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = undefined, -- ??? inclusion
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = FreeDef nsig,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGFree })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Cofree_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Free spec over empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'), -- delta is empty
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGCofree }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (n',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = undefined, -- ??? inclusion
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = CofreeDef nsig,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGCofree })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Local_spec asp asp' pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sp' = item asp'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg nsig Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig'',dg'') <- ana_SPEC gannos genv dg' nsig' Nothing sp'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n'' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Local spec over empty spec" (getNode nsig'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma = getSig nsig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma'' = getSig nsig''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid sigma <- return gsigma
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid'' sigma'' <- return gsigma''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigma1 <- rcoerce lid' lid nullPos sigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigma2 <- rcoerce lid'' lid nullPos sigma''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sys = sym_of lid sigma
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sys1 = sym_of lid sigma1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sys2 = sym_of lid sigma2
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor3 <- cogenerated_sign lid (toList (sys1 `difference` sys)) sigma2
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sigma3 = dom lid mor3
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma2 = G_sign lid sigma2
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma3 = G_sign lid sigma3
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sys3 = sym_of lid sigma3
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder if sys2 `difference` sys1 `subset` sys3 then return ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder else plain_error ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "attempt to hide symbols from the local environment" (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid (empty_signature lid), -- delta is empty
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGLocal }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (n'',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = gEmbed (G_morphism lid mor3),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = HidingDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGLocal })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma3),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Closed_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder l = getLogic nsig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsig',dg') <- ana_SPEC gannos genv dg (EmptyNode l) Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Closed spec over empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma = getSig nsig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma'' <- homogeneousGsigUnion (headPos pos) gsigma gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- also allow different logics???
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid'' sigma'' <- return gsigma''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid'' (empty_signature lid''),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid'' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGClosed }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link1 = (n',node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion gsigma' gsigma'',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGClosed })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link2 = DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion gsigma' gsigma'',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGClosedLenv }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insLink2 = case (getNode nsig) of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> id
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just n -> insEdge (n,node,link2)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma''),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link1 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Group asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_SPEC gannos genv dg nsig name (item asp)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Spec_inst spname afitargs pos ->
c616e681da8c052b62e14247fea522da099ac0e4Christian Maeder case Map.lookup spname genv of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> plain_error (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ("Specification "++pretty spname++" not found") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (ViewEntry _) ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder plain_error (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pretty spname++" is a view, not a specification") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (ArchEntry _) ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder plain_error (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pretty spname++
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder " is an architectural, not a structured specification") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (UnitEntry _) ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder plain_error (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pretty spname++
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder " is a unit specification, not a structured specification") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (SpecEntry gs@(imps,params,gSigmaP,body)) ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case (\x y -> (x,x-y)) (length afitargs) (length params) of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- the case without parameters leads to a simpler dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigmaB = getSig body
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigma <- homogeneousGsigUnion (headPos pos) (getSig nsig) gsigmaB
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid sigma <- return gsigma
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nB <- maybeToResult (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: empty body spec" (getNode body)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case (getNode nsig) of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- the case with empty local env leads to an even simpler dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> case name of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- if the node shall not be named, just return the body
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> return (body,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- if the node shall be named, we need to create a new one
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let [node] = newNodes 0 dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid (empty_signature lid),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGSpecInst spname}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link = (nB,node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion gsigmaB gsigma,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder in return (NodeSig(node,gsigma),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- the case with nonempty local env
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let [node] = newNodes 0 dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid (empty_signature lid),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGSpecInst spname}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link1 = (n,node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion (getSig nsig) gsigma,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link2 = (nB,node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion gsigmaB gsigma,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder in return (NodeSig(node,gsigma),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link1 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link2 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- now the general case: with parameters
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let fitargs = map item afitargs
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (dg',args) <- foldl ana (return (dg,[])) (zip params fitargs)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let actualargs = reverse args
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (gsigma',mor_f) <- apply_GS (headPos pos) gs actualargs
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaRes <- homogeneousGsigUnion (headPos pos) (getSig nsig) gsigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nB <- maybeToResult (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: empty body spec" (getNode body)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let [node] = newNodes 0 dg'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = name,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lid' (empty_signature lid'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lid' [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGSpecInst spname}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link1 = DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion (getSig nsig) gsigma',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insLink1 = case (getNode nsig) of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> id
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just n -> insEdge (n,node,link1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link2 = (nB,node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion (getSig body) gsigma',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder parLinks = catMaybes (map (parLink node) actualargs)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldr insEdge
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link2 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res (nsig,fa) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (dg,args) <- res
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (dg',arg) <- ana_FIT_ARG gannos genv dg spname imps nsig fa
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (dg',arg:args)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder parLink node (mor_i,nsigA_i) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nA_i <- getNode nsigA_i
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let link = DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = gEmbed mor_i,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGClosed }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (nA_i,node,link)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- finally the case with conflicting numbers of formal and actual parameters
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder plain_error (nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pretty spname++" expects "++show (length params)++" arguments"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ++" but was given "++show (length afitargs)) (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Qualified_spec logname asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_err "logic qualified specs"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- analysis of renamings
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_ren1 dg (GMorphism lid1 lid2 r sigma mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_symb_map (G_symb_map_items_list lid sis),pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sis1 <- rcoerce lid2 lid pos sis
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rmap <- stat_symb_map_items lid2 sis1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor1 <- induced_from_morphism lid2 rmap (cod lid2 mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor2 <- maybeToResult pos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "renaming: signature morphism composition failed"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (comp lid2 mor mor1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (GMorphism lid1 lid2 r sigma mor2)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_ren1 dg mor (G_logic_translation (Logic_code tok src tar pos1),pos2) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder fatal_error "no analysis of logic translations yet" pos2
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_ren :: DGraph -> Result GMorphism -> (G_mapping,Pos) -> Result GMorphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_ren dg mor_res ren =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do mor <- mor_res
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_ren1 dg mor ren
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RENAMING :: DGraph -> G_sign -> RENAMING -> Result GMorphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RENAMING dg gSigma (Renaming ren pos) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldl (ana_ren dg) (return (ide Grothendieck gSigma)) ren'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ren' = zip ren (tail (pos ++ repeat nullPos))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- analysis of restrictions
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_restr1 dg (G_sign lid sigma) (GMorphism lid1 lid2 r sigma1 mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_symb_list (G_symb_items_list lid' sis'),pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sis1 <- rcoerce lid1 lid' pos sis'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rsys <- stat_symb_items lid1 sis1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sys = sym_of lid1 sigma1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sys' = filter (\sy -> any (\rsy -> matches lid1 sy rsy) rsys)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- if sys' `disjoint` () then return ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- else plain_error () "attempt to hide symbols from the local environment" pos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor1 <- cogenerated_sign lid1 sys' sigma1
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor1' <- maybeToResult pos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ("restriction: could not map morphism along" ++ repr_name r)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (map_morphism r mor1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor2 <- maybeToResult pos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "restriction: signature morphism composition failed"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (comp lid2 mor1' mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (GMorphism lid1 lid2 r (dom lid1 mor1) mor2)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_restr1 dg gSigma mor
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_logic_projection (Logic_code tok src tar pos1),pos2) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder fatal_error "no analysis of logic projections yet" pos2
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_restr :: DGraph -> G_sign -> Result GMorphism -> (G_hiding,Pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result GMorphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_restr dg gSigma mor_res restr =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do mor <- mor_res
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_restr1 dg gSigma mor restr
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RESTRICTION :: DGraph -> G_sign -> G_sign -> RESTRICTION
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result (GMorphism, Maybe GMorphism)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RESTRICTION dg gSigma gSigma' (Hidden restr pos) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do mor <- foldl (ana_restr dg gSigma)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (return (ide Grothendieck gSigma'))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (mor,Nothing)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder restr' = zip restr (tail (pos ++ repeat nullPos))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RESTRICTION dg gSigma@(G_sign lid sigma) gSigma'@(G_sign lid' sigma')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (Revealed (G_symb_map_items_list lid1 sis) pos) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sys = sym_of lid sigma
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sys' = sym_of lid' sigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sis' <- rcoerce lid1 lid' (headPos pos) sis
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rmap <- stat_symb_map_items lid' sis'
c616e681da8c052b62e14247fea522da099ac0e4Christian Maeder [sy | sy <- toList sys', rsy <- Map.keys rmap, matches lid' sy rsy]
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sys1 <- rcoerce lid lid' (headPos pos) sys
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? this is too simple in case that local env is translated
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- to a different logic
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder if sys1 `disjoint` sys'' then return ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder else plain_error () "attempt to hide symbols from the local environment" (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor1 <- generated_sign lid' (toList (sys1 `union` sys'')) sigma'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor2 <- induced_from_morphism lid' rmap (dom lid' mor1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (gEmbed (G_morphism lid' mor1),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (gEmbed (G_morphism lid' mor2)))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_FIT_ARG gannos genv dg spname nsigI nsigP (Fit_spec asp gsis pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nP <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: empty parameter spec" (getNode nsigP)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigA,dg') <- ana_SPEC gannos genv dg nsigI Nothing (item asp)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nA <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: empty argument spec" (getNode nsigA)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigmaP = getSig nsigP
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaA = getSig nsigA
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaI = getSig nsigI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lidP sigmaP <- return gsigmaP
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lidA sigmaA <- return gsigmaA
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lidI sigmaI <- return gsigmaI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_symb_map_items_list lid sis <- return gsis
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rmap <- stat_symb_map_items lid sis
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigmaA' <- rcoerce lidA lidP (headPos pos) sigmaA
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigmaI' <- rcoerce lidI lidP (headPos pos) sigmaI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rmap' <- rcoerce lid lidP (headPos pos) rmap
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor <- induced_from_to_morphism lidP rmap' sigmaP sigmaA'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let symI = sym_of lidP sigmaI'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder symmap_mor = symmap_of lidP mor
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- are symbols of the imports left untouched?
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder {- if setAll (\sy -> lookupFM symmap_mor sy == Just sy) symI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder then return ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder else plain_error () "Fitting morphism must not affect import" (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -} -- ??? does not work
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? also output some symbol that is affected
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let link = (nP,nA,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = gEmbed (G_morphism lidP mor),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalThm False,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (insEdge link dg',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_morphism lidP mor,nsigA)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_FIT_ARG gannos genv dg spname nsigI nsigP (Fit_view vn fas pos ans) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid sigma <- return (getSig nsigP)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (dg,(G_morphism lid (ide lid sigma),nsigP))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? Needs to be implemented
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaederextendMorphism :: Pos -> G_sign -> G_sign -> G_sign -> G_morphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result(G_sign,G_morphism)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian MaederextendMorphism pos gsigma gsigma' gsigmaA mor =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (gsigmaA,mor) -- ??? needs to be implemented
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederapply_GS :: Pos -> ExtGenSig -> [(G_morphism,NodeSig)] -> Result(G_sign,G_morphism)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederapply_GS pos (nsigI,params,gsigmaP,nsigB) args = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let mor_i = map fst args
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaA_i = map (getSig . snd) args
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaB = getSig nsigB
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaI = getSig nsigI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lidI sigmaI <- return gsigmaI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let idI = ide lidI sigmaI
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaA <- homogeneousGsigManyUnion pos gsigmaA_i
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor_f <- homogeneousMorManyUnion pos (G_morphism lidI idI:mor_i)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder extendMorphism pos gsigmaP gsigmaB gsigmaA mor_f
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_GENERICITY :: GlobalAnnos -> GlobalEnv -> DGraph -> AnyLogic -> GENERICITY
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result (ExtGenSig,DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_GENERICITY gannos genv dg l@(Logic lid)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (Genericity (Params []) (Imported []) pos) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return ((EmptyNode l,[],G_sign lid (empty_signature lid),EmptyNode l),dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_GENERICITY gannos genv dg l (Genericity (Params [asp]) imps pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigI,dg') <- ana_IMPORTS gannos genv dg l imps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigP,dg'') <- ana_SPEC gannos genv dg' nsigI Nothing (item asp)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return ((nsigI,[nsigP],getSig nsigP,nsigP),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_GENERICITY gannos genv dg l (Genericity params imps pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigI,dg') <- ana_IMPORTS gannos genv dg l imps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (nsigPs,dg'') <- ana_PARAMS gannos genv dg' l nsigI params
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder gsigmaP <- homogeneousGsigManyUnion (headPos pos) (map getSig nsigPs)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lidP sigmaP <- return gsigmaP
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let node_contents = DGNode {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_name = Nothing,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sign = G_sign lidP (empty_signature lidP),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_sens = G_l_sentence lidP [],
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgn_origin = DGFormalParams }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder [node] = newNodes 0 dg''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dg''' = insNode (node,node_contents) dg''
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder inslink dg nsig =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case getNode nsig of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing -> dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just n -> insEdge (n,node,DGLink {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_morphism = inclusion (getSig nsig) gsigmaP,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGFormalParams }) dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return ((nsigI,nsigPs,gsigmaP,NodeSig(node,gsigmaP)),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldl inslink dg''' nsigPs)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_PARAMS :: GlobalAnnos -> GlobalEnv -> DGraph -> AnyLogic -> NodeSig -> PARAMS
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result ([NodeSig],DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_PARAMS gannos genv dg l nsigI (Params asps) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pars,dg') <- foldl ana (return ([],dg)) (map item asps)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (reverse pars,dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res sp = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (pars,dg) <- res
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (par,dg') <- ana_SPEC gannos genv dg nsigI Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (par:pars,dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_IMPORTS :: GlobalAnnos -> GlobalEnv -> DGraph -> AnyLogic -> IMPORTED
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result (NodeSig,DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_IMPORTS gannos genv dg l (Imported asps) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sp = Union asps (map (\_ -> nullPos) asps)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_SPEC gannos genv dg (EmptyNode l) Nothing sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? emptyExplicit stuff needs to be added here
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_VIEW_TYPE:: GlobalAnnos -> GlobalEnv -> DGraph -> AnyLogic
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> NodeSig -> VIEW_TYPE
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result ((NodeSig,NodeSig),DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_VIEW_TYPE gannos genv dg l parSig
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (View_type aspSrc aspTar pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (srcNsig,dg') <- ana_SPEC gannos genv dg (EmptyNode l) Nothing (item aspSrc)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (tarNsig,dg'') <- ana_SPEC gannos genv dg parSig Nothing (item aspTar)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return ((srcNsig,tarNsig),dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder---- helpers ---------------------------------
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_err :: String -> a
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_err fname =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder error ("*** Analysis of " ++ fname ++ " is not yet implemented!")
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder----------------------------------------------