AnalysisStructured.hs revision 8fe1a8e240ccd5f3682a936ef2fa4c22fee973bc
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski{- |
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski
c06dd8856a03b72f6b3f69e874f8700f10cb8522Christian Maeder Module : $Header$
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski Copyright : (c) Till Mossakowski and Uni Bremen 2003
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski Licence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
c06dd8856a03b72f6b3f69e874f8700f10cb8522Christian Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski Maintainer : hets@tzi.de
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski Stability : provisional
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Portability : portable
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Analysis of structured specifications
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Follows the extended static semantic rules in:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder T. Mossakowski, S. Autexier, D. Hutter, P. Hoffman:
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder CASL Proof calculus.
c06dd8856a03b72f6b3f69e874f8700f10cb8522Christian Maeder Available from <http://www.informatik.uni-bremen.de/~till/calculus.ps>
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder To appear in the CASL book.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Todo:
c0ba7121c93e4f9292f2d95a0ac7460a7b9e5aeaTill Mossakowski Option: only the structure is analysed => also for symbol maps!
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Check that translations and reductions do not effect local env
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
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
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
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
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
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Revealings wihout translations: just one arrow
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Pushouts: only admissible within one logic?
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski Instantiations with formal parameter: add no new internal nodes
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski call extend_morphism
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Optimizations:
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski Union nodes can be extended by a basic spec directly (no new node needed)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski no new nodes for trivial translations
8fe1a8e240ccd5f3682a936ef2fa4c22fee973bcTill Mossakowski use foldM
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Also: free, cofree nodes
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowskimodule Static.AnalysisStructured (ana_SPEC, ana_GENERICITY, ana_VIEW_TYPE, ana_err)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederwhere
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Data.Maybe
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Logic.Logic
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiimport Logic.Comorphism
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Logic.Grothendieck
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Common.Lib.Graph hiding (empty)
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Static.DevGraph
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Syntax.AS_Structured
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Common.AS_Annotation
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Common.Result
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Common.Id
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowskiimport qualified Common.Lib.Set as Set
c616e681da8c052b62e14247fea522da099ac0e4Christian Maederimport qualified Common.Lib.Map as Map
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederimport Data.List hiding (union)
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maederimport Common.PrettyPrint
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- | analyze a SPEC
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- Parameters: global context, local environment,
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- the SIMPLE_ID may be a name if the specification shall be named,
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- flag: shall only the structure be analysed?
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_SPEC :: LogicGraph -> GlobalContext -> NodeSig -> Maybe SIMPLE_ID ->
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski Bool -> SPEC -> Result (SPEC,NodeSig,DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_SPEC lg gctx@(gannos,genv,dg) nsig name just_struct sp =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case sp of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
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'
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (bspec',sigma_local, sigma_complete, ax) <-
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski if just_struct
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski then return (bspec,empty_signature lid, empty_signature lid,[])
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski else do b <- maybeToResult nullPos
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski ("no basic analysis for logic "
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski ++language_name lid)
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski (basic_analysis lid)
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski b (bspec,sigma,gannos)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (G_sign lid sigma) (G_sign lid sigma_complete)
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 {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
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'
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Basic_spec (G_basic_spec lid bspec'),
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig (node,G_sign lid sigma_complete),
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Translation asp ren ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx nsig Nothing just_struct sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: Translation of empty spec" (getNode nsig')
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski let gsigma = getSig nsig'
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski mor <- ana_RENAMING dg gsigma just_struct ren
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? check that mor is identity on local env
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski 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,
a938729e277da5c7742bb88946ab2c150416fd5dTill Mossakowski dgn_sign = gsigma',
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 })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Translation (replaceAnnoted sp' asp) ren,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Reduction asp restr ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx nsig Nothing just_struct 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')
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski (hmor,tmor) <- ana_RESTRICTION dg gsigma gsigma' just_struct restr
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- we treat hiding and revealing differently
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- in order to keep the dg as simple as possible
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case tmor of
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Nothing ->
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski 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 })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Reduction (replaceAnnoted sp' asp) restr,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just tmor' ->
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski do let gsigma1 = dom Grothendieck tmor'
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski 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 })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Reduction (replaceAnnoted sp' asp) restr,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski 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
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Union [] pos -> return (sp,nsig,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Union asps pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sps = map item asps
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps',nsigs,dg') <-
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski let ana r sp = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps1,nsigs,dg) <- r
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp1,nsig',dg1) <- ana_SPEC lg (gannos,genv,dg) nsig Nothing just_struct sp
a205324331077b7d5a2c08fb3f0f57e5c029f9aaTill Mossakowski return (sp1:sps1,nsig':nsigs,dg1)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski in foldl ana (return ([],[],dg)) sps
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let nsigs' = reverse nsigs
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski gbigSigma <- homogeneousGsigManyUnion (headPos pos) (map getSig nsigs')
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski G_sign lid' bigSigma <- return gbigSigma
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'
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insE dgres (n,gsigma) = do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg <- dgres
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg gsigma gbigSigma
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski let link = DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_type = GlobalDef,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_origin = DGUnion }
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski return (insEdge (n,node,link) dg)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg'' <- foldl insE (return (insNode (node,node_contents) dg'))
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (catMaybes (map getNodeAndSig nsigs'))
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski return (Union (map (uncurry replaceAnnoted)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (zip (reverse sps') asps))
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski pos,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski NodeSig(node,gbigSigma),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg'')
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Extension [] pos -> return (sp,nsig,dg)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Extension asps pos -> do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps',nsig1,dg1) <- foldl ana (return ([],nsig,dg)) namedSps
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Extension (map (uncurry replaceAnnoted)
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski (zip (reverse sps') asps))
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski nsig1,dg1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder where
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder namedSps = zip (map (\_ -> Nothing) (tail asps) ++ [name]) (map item asps)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res (name,sp) = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps',nsig,dg) <- res
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp1',nsig1,dg1) <- ana_SPEC lg (gannos,genv,dg) nsig name just_struct sp
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (sp1':sps',nsig1,dg1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Free_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx nsig Nothing just_struct 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'
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg (getSig nsig) 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 {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = FreeDef nsig,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGFree })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Free_spec (replaceAnnoted sp' asp) pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Cofree_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx nsig Nothing just_struct sp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder n' <- maybeToResult nullPos
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski "Internal error: Cofree spec over empty spec" (getNode nsig')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let gsigma' = getSig nsig'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid' sigma' <- return gsigma'
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg (getSig nsig) 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 {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = CofreeDef nsig,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGCofree })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Cofree_spec (replaceAnnoted sp' asp) pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Local_spec asp asp' pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sp' = item asp'
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp1,nsig',dg') <- ana_SPEC lg gctx nsig Nothing just_struct sp
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp1',nsig'',dg'') <- ana_SPEC lg (gannos,genv,dg') nsig' Nothing just_struct 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
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski mor3 <- if just_struct then return (ide lid sigma2)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski else cogenerated_sign lid
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski (Set.toList (sys1 `Set.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
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski if just_struct || sys2 `Set.difference` sys1 `Set.subset` sys3
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski 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 })
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Local_spec (replaceAnnoted sp1 asp)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (replaceAnnoted sp1' asp')
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma3),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Closed_spec asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do let sp = item asp
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder l = getLogic nsig
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx (EmptyNode l) Nothing just_struct 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''
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl1 <- ginclusion lg gsigma' gsigma''
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl2 <- ginclusion lg gsigma' 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 {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl1,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGClosed })
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link2 = DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl2,
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)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Closed_spec (replaceAnnoted sp' asp) pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma''),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insLink2 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link1 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Group asp pos -> do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsig',dg') <- ana_SPEC lg gctx nsig name just_struct (item asp)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Group (replaceAnnoted sp' asp) pos,nsig',dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Spec_inst spname afitargs pos ->
c616e681da8c052b62e14247fea522da099ac0e4Christian Maeder case Map.lookup spname genv of
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Nothing -> plain_error (sp,nsig,dg)
74e82e43f5787027c5d4e523397525a259d6d001Christian Maeder ("Specification "++ showPretty spname " not found") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (ViewEntry _) ->
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski plain_error (sp,nsig,dg)
74e82e43f5787027c5d4e523397525a259d6d001Christian Maeder (showPretty spname " is a view, not a specification") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (ArchEntry _) ->
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski plain_error (sp,nsig,dg)
74e82e43f5787027c5d4e523397525a259d6d001Christian Maeder (showPretty spname
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder " is an architectural, not a structured specification") (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Just (UnitEntry _) ->
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski plain_error (sp,nsig,dg)
74e82e43f5787027c5d4e523397525a259d6d001Christian Maeder (showPretty 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
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- the case without parameters leads to a simpler dg
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (0,0) -> do
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
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski Nothing -> return (sp,body,dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- if the node shall be named, we need to create a new one
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski Just _ -> do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg gsigmaB gsigma
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski let [node] = newNodes 0 dg
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski node_contents = DGNode {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_name = name,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_sign = G_sign lid (empty_signature lid),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_sens = G_l_sentence lid [],
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_origin = DGSpecInst spname}
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski link = (nB,node,DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_type = GlobalDef,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_origin = DGSpecInst spname})
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski return (sp,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski NodeSig(node,gsigma),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insEdge link $
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insNode (node,node_contents) dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- the case with nonempty local env
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski Just n -> do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl1 <- ginclusion lg (getSig nsig) gsigma
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl2 <- ginclusion lg gsigmaB gsigma
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski let [node] = newNodes 0 dg
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski node_contents = DGNode {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_name = name,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_sign = G_sign lid (empty_signature lid),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_sens = G_l_sentence lid [],
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgn_origin = DGSpecInst spname}
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski link1 = (n,node,DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl1,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_type = GlobalDef,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_origin = DGSpecInst spname})
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski link2 = (nB,node,DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl2,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_type = GlobalDef,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_origin = DGSpecInst spname})
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski return (sp,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski NodeSig(node,gsigma),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insEdge link1 $
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insEdge link2 $
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski insNode (node,node_contents) dg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- now the general case: with parameters
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (_,0) -> do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let fitargs = map item afitargs
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (fitargs',dg',args) <-
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski 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)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl1 <- ginclusion lg (getSig nsig) gsigma'
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl2 <- ginclusion lg (getSig body) 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 = DGSpecInst spname}
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder link1 = DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl1,
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 {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl2,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder parLinks = catMaybes (map (parLink node) actualargs)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Spec_inst spname
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (map (uncurry replaceAnnoted)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (zip (reverse fitargs') afitargs))
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski NodeSig(node,gsigma'),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder foldr insEdge
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (insLink1 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insEdge link2 $
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder insNode (node,node_contents) dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder parLinks)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder where
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res (nsig,fa) = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (fas',dg,args) <- res
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (fa',dg',arg) <- ana_FIT_ARG lg (gannos,genv,dg)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski spname imps nsig just_struct fa
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (fa':fas',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
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- finally the case with conflicting numbers of formal and actual parameters
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder otherwise ->
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski plain_error (sp,nsig,dg)
74e82e43f5787027c5d4e523397525a259d6d001Christian Maeder (showPretty spname " expects "++show (length params)++" arguments"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ++" but was given "++show (length afitargs)) (headPos pos)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Qualified_spec logname asp pos ->
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana_err "logic qualified specs"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski{-
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski Data (Logic lid1) asp1 asp2 pos ->
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski do let sp1 = item asp1
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski sp2 = item asp2
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski l = getLogic nsig
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski (sp1',nsig1,dg1) <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_SPEC lg gctx (EmptyNode lid1) Nothing just_struct sp1
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski (sp2'nsig2,dg2) <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_SPEC lg (gannos,genv,dg1) nsig1 Nothing just_struct sp2
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski n' <- maybeToResult nullPos
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski "Internal error: Free spec over empty spec" (getNode nsig')
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski let gsigma' = getSig nsig'
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski G_sign lid' sigma' <- return gsigma'
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski let node_contents = DGNode {
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgn_name = name,
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgn_sign = G_sign lid' (empty_signature lid'), -- delta is empty
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgn_sens = G_l_sentence lid' [],
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgn_origin = DGFree }
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski [node] = newNodes 0 dg'
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski link = (n',node,DGLink {
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski dgl_morphism = error "AnalysisStructured.hs:5", -- ??? inclusion
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgl_type = FreeDef nsig,
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski dgl_origin = DGFree })
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski return (Data (Logic lid1)
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski (replaceAnnoted sp1' asp1)
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski (replaceAnnoted sp2' asp2)
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski pos,
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski NodeSig(node,gsigma'),
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski insEdge link $
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski insNode (node,node_contents) dg')
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski-}
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- analysis of renamings
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowskiana_ren1 dg (GMorphism r sigma mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_symb_map (G_symb_map_items_list lid sis),pos) = do
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski let lid1 = sourceLogic r
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski lid2 = targetLogic r
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)
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski return (GMorphism r sigma mor2)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
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 Maeder
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 Maeder
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowskiana_RENAMING :: DGraph -> G_sign -> Bool -> RENAMING -> Result GMorphism
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowskiana_RENAMING dg gSigma just_struct (Renaming ren pos) =
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski if just_struct
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski then return (ide Grothendieck gSigma)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski else foldl (ana_ren dg) (return (ide Grothendieck gSigma)) ren'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder where
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ren' = zip ren (tail (pos ++ repeat nullPos))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder-- analysis of restrictions
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowskiana_restr1 dg (G_sign lid sigma) (GMorphism cid sigma1 mor)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_symb_list (G_symb_items_list lid' sis'),pos) = do
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski let lid1 = sourceLogic cid
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski lid2 = targetLogic cid
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)
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski (Set.toList sys)
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
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski ("restriction: could not map morphism along" ++ language_name cid)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski (map_morphism cid mor1)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder mor2 <- maybeToResult pos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "restriction: signature morphism composition failed"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (comp lid2 mor1' mor)
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski return (GMorphism cid (dom lid1 mor1) mor2)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
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 Maeder
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 Maeder
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowskiana_RESTRICTION :: DGraph -> G_sign -> G_sign -> Bool -> RESTRICTION
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -> Result (GMorphism, Maybe GMorphism)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowskiana_RESTRICTION _ _ gSigma True _ =
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski return (ide Grothendieck gSigma,Nothing)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowskiana_RESTRICTION dg gSigma gSigma' False (Hidden restr pos) =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder do mor <- foldl (ana_restr dg gSigma)
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski (return (ide Grothendieck gSigma'))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder restr'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return (mor,Nothing)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder where
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder restr' = zip restr (tail (pos ++ repeat nullPos))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_RESTRICTION dg gSigma@(G_sign lid sigma) gSigma'@(G_sign lid' sigma')
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski False (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'
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sys'' =
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski Set.fromList
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski [sy | sy <- Set.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
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski if sys1 `Set.disjoint` sys'' then return ()
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder else plain_error () "attempt to hide symbols from the local environment" (headPos pos)
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski mor1 <- generated_sign lid' (Set.toList (sys1 `Set.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 Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_FIT_ARG lg gctx@(gannos,genv,dg) spname nsigI nsigP just_struct
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (Fit_spec asp gsis pos) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder nP <- maybeToResult nullPos
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Internal error: empty parameter spec" (getNode nsigP)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsigA,dg') <- ana_SPEC lg gctx nsigI Nothing just_struct (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 sigmaA' <- rcoerce lidA lidP (headPos pos) sigmaA
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder sigmaI' <- rcoerce lidI lidP (headPos pos) sigmaI
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski mor <- if just_struct then return (ide lidP sigmaP)
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski else do
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski rmap <- stat_symb_map_items lid sis
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski rmap' <- rcoerce lid lidP (headPos pos) rmap
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski 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?
5e46b572ed576c0494768998b043d9d340594122Till Mossakowski {- if Set.all (\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),
022f4e4f5488defedc48581e87f0222f82d5afe4Jorina Freya Gerken dgl_type = GlobalThm Open None Open,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_origin = DGSpecInst spname})
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Fit_spec (replaceAnnoted sp' asp) gsis pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski insEdge link dg',
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (G_morphism lidP mor,nsigA)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder )
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_FIT_ARG lg gctx@(gannos,genv,dg) spname nsigI nsigP just_struct
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (Fit_view vn fas pos ans) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder G_sign lid sigma <- return (getSig nsigP)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Fit_view vn fas pos ans,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski dg,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (G_morphism lid (ide lid sigma),nsigP))
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? Needs to be implemented
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
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 Maeder
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 Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- | analyze a GENERICITY
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- Parameters: global context, current logic, just-structure-flag, GENERICITY
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_GENERICITY :: LogicGraph -> GlobalContext -> AnyLogic -> Bool
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski -> GENERICITY
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski -> Result (GENERICITY,ExtGenSig,DGraph)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski-- zero parameters,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_GENERICITY lg (_,_,dg) l@(Logic lid) _
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski gen@(Genericity (Params []) (Imported []) pos) =
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (gen,(EmptyNode l,[],G_sign lid (empty_signature lid),EmptyNode l),dg)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski-- one parameter ...
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_GENERICITY lg gctx@(gannos,genv,_) l just_struct
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (Genericity (Params [asp]) imps pos) = do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (imps',nsigI,dg') <- ana_IMPORTS lg gctx l just_struct imps
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',nsigP,dg'') <- ana_SPEC lg (gannos,genv,dg') nsigI Nothing just_struct (item asp)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Genericity (Params [replaceAnnoted sp' asp]) imps' pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (nsigI,[nsigP],getSig nsigP,nsigP),
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski-- ... and more parameters
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_GENERICITY lg gctx@(gannos,genv,_) l just_struct
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (Genericity params imps pos) = do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (imps',nsigI,dg') <- ana_IMPORTS lg gctx l just_struct imps
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (params',nsigPs,dg'') <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_PARAMS lg (gannos,genv,dg') l nsigI just_struct 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''
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski inslink dgres nsig = do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg <- dgres
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case getNode nsig of
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski Nothing -> return dg
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski Just n -> do
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski incl <- ginclusion lg (getSig nsig) gsigmaP
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski return (insEdge (n,node,DGLink {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_morphism = incl,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder dgl_type = GlobalDef,
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dgl_origin = DGFormalParams }) dg)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg4 <- foldl inslink (return dg''') nsigPs
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Genericity params' imps' pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (nsigI,nsigPs,gsigmaP,NodeSig(node,gsigmaP)),
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski dg4)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_PARAMS :: LogicGraph -> GlobalContext -> AnyLogic -> NodeSig -> Bool
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski -> PARAMS
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski -> Result (PARAMS,[NodeSig],DGraph)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_PARAMS lg gctx@(gannos,genv,dg) l nsigI just_struct (Params asps) = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps',pars,dg') <- foldl ana (return ([],[],dg)) (map item asps)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Params (map (uncurry replaceAnnoted)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (zip (reverse sps') asps)),
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski reverse pars,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder where
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ana res sp = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (sps',pars,dg) <- res
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski (sp',par,dg') <- ana_SPEC lg (gannos,genv,dg) nsigI Nothing just_struct sp
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (sp':sps',par:pars,dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_IMPORTS :: LogicGraph -> GlobalContext -> AnyLogic -> Bool -> IMPORTED
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski -> Result (IMPORTED,NodeSig,DGraph)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_IMPORTS lg gctx l just_struct (Imported asps) = do
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder let sp = Union asps (map (\_ -> nullPos) asps)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (Union asps' _,nsig',dg') <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_SPEC lg gctx (EmptyNode l) Nothing just_struct sp
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (Imported asps',nsig',dg')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder -- ??? emptyExplicit stuff needs to be added here
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- | analyze a VIEW_TYPE
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- The first three arguments give the global context
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- The AnyLogic is the current logic
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- The NodeSig is the signature of the parameter of the view
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- flag, whether just the structure shall be analysed
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_VIEW_TYPE:: LogicGraph -> GlobalContext -> AnyLogic -> NodeSig -> Bool
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski -> VIEW_TYPE
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski -> Result (VIEW_TYPE,(NodeSig,NodeSig),DGraph)
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskiana_VIEW_TYPE lg gctx@(gannos,genv,_) l parSig just_struct
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder (View_type aspSrc aspTar pos) = do
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (spSrc',srcNsig,dg') <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_SPEC lg gctx (EmptyNode l) Nothing just_struct (item aspSrc)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (spTar',tarNsig,dg'') <-
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski ana_SPEC lg (gannos,genv,dg') parSig Nothing just_struct (item aspTar)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski return (View_type (replaceAnnoted spSrc' aspSrc)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (replaceAnnoted spTar' aspTar)
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski pos,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski (srcNsig,tarNsig),
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski dg'')
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski-- | Auxiliary function for not yet implemented features
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_err :: String -> a
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederana_err fname =
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder error ("*** Analysis of " ++ fname ++ " is not yet implemented!")
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder