AnalysisStructured.hs revision cc0298f887b0416641a8b87acfae2c2983caa062
e071fb22ea9923a2a4ff41184d80ca46b55ee932Till Mossakowski Till Mossakowski
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder Analysis of structured specifications
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill Mossakowski Follows the extended static semantic rules in:
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach T. Mossakowski, S. Autexier, D. Hutter, P. Hoffman:
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach CASL Proof calculus.
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder Available from http://www.informatik.uni-bremen.de/~till/calculus.ps
8267b99c0d7a187abe6f87ad50530dc08f5d1cdcAndy Gimblett To appear in the CASL book.
fbb2d28086a1860850f661fbf4af531322bac405Christian Maeder Check that translations and reductions do not effect local env
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach Unions (already in the parser) need unions of logics
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach = suprema in the lattice of default logic inclusions!
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach Should we use institution independent analysis over the Grothendieck logic?
d04c328b10f17ec78001a94d694f7188ebd8c03cAndy Gimblett abstract syntax + devgraph would have to be changed to homogeneous case
cdf1545bdcd39a9d53c00761ffa42e7b1174b91eLiam O'Reilly logic translations are symbol maps in the Grothendieck logic
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett Problem with this approach: symbol functor goes into rel,
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder and induced_from_morphism gets difficult to implement
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett Unions need inclusion morphisms. Should these play a special role?
d04c328b10f17ec78001a94d694f7188ebd8c03cAndy Gimblett At least we need a function delivering the inclusion morphism
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett between two (sub)signatures.
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder In most logics, inclusions could be represented specially, such
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett that composition for them becomes fast.
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder Should we even identify an inclusion subcategory?
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder Treatment of translations and reductions along logic translations
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett (see WADT 02 paper).
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett Open question:
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett may local env be translated, and even reduced, along logic translations?
f18cf8a4e7d512a2f57365ab1e9e7fdbb98ba257Andy Gimblett if yes: how is local env linked to signature of resulting spec?
f18cf8a4e7d512a2f57365ab1e9e7fdbb98ba257Andy Gimblett (important e.g. for checking that local env is not being renamed?)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett does signature+comorphism suffice, such that c(local env)\subseteq sig?
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett if no: this means that only closed specs may be translated
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett Pushouts: only admissible within one logic?
f18cf8a4e7d512a2f57365ab1e9e7fdbb98ba257Andy Gimblettmodule AnalysisStructured
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblettimport LogicRepr
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblettimport Grothendieck
d04c328b10f17ec78001a94d694f7188ebd8c03cAndy Gimblettimport DevGraph
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblettimport AS_Structured
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblettimport AS_Annotation
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblettimport GlobalAnnotations
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblettimport FiniteMap
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian MaederlookupNode n dg = lab' $ context n dg
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian MaedersetFilter p s = mkSet (filter p (setToList s))
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian MaedersetAny p s = any p (setToList s)
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeders1 `disjoint` s2 = s1 `intersect` s2 == emptySet
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy GimblettdomFM m = mkSet (keysFM m)
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblettana_SPEC :: GlobalAnnos -> GlobalEnv -> DGraph -> NodeSig -> SPEC
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett -> Result (NodeSig,DGraph)
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maederana_SPEC gannos genv dg nsig sp =
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett Basic_spec (G_basic_spec lid bspec) ->
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder do Logic lid' <- return (getLogic nsig)
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder sigma <- rcoerce lid' lid nullPos (getSig nsig)
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett b <- maybeToResult nullPos
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett ("no basic analysis for logic "++language_name lid)
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett (basic_analysis lid)
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett (sigma_local, sigma_complete, ax) <- b (bspec,sigma,gannos)
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder let node_contents = DGNode {
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgn_sign = G_sign lid sigma_local, -- only the delta
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dgn_sens = G_l_sentence lid ax,
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dgn_origin = DGBasic }
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder [node] = newNodes 1 dg
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dg' = insNode (node,node_contents) dg
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder link = DGLink {
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgl_morphism = undefined, -- where to get it from ???
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dgl_type = GlobalDef,
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dgl_origin = DGExtension }
8528886a04f14abe0ddf80f50c853cc25bc821cdAndy Gimblett dg'' = case nsig of
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett EmptyNode _ -> dg'
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett NodeSig (n,_) -> insEdge (n,node,link) dg'
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett return (NodeSig (node,G_sign lid sigma_complete),dg')
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett Translation asp ren ->
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach do let sp = item asp
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett (nsig',dg') <- ana_SPEC gannos genv dg nsig sp
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett n' <- maybeToResult nullPos "Translation of empty spec" (getNode nsig')
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett mor <- ana_RENAMING dg (getSig nsig') ren
929190acb9f2b2f5857dce841c5a389710895515Andy Gimblett -- ??? check that mor is identity on local env
cdf1545bdcd39a9d53c00761ffa42e7b1174b91eLiam O'Reilly let gsigma' = cod Grothendieck mor
cdf1545bdcd39a9d53c00761ffa42e7b1174b91eLiam O'Reilly -- ??? too simplistic for non-comorphism inter-logic translations
cdf1545bdcd39a9d53c00761ffa42e7b1174b91eLiam O'Reilly G_sign lid' sigma' <- return gsigma'
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett let node_contents = DGNode {
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett dgn_sign = G_sign lid' (empty_signature lid'), -- delta is empty
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett dgn_sens = G_l_sentence lid' [],
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett dgn_origin = DGTranslation }
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett [node] = newNodes 1 dg'
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett link = DGLink {
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett dgl_morphism = mor,
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett dgl_type = GlobalDef,
d297a45fc73aa6c4a1f9d073c3170611415f324bAndy Gimblett dgl_origin = DGTranslation }
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett return (NodeSig(node,gsigma'),
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett insEdge (n',node,link) $
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett insNode (node,node_contents) dg')
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett Reduction asp restr ->
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett do let sp = item asp
d297a45fc73aa6c4a1f9d073c3170611415f324bAndy Gimblett (nsig',dg') <- ana_SPEC gannos genv dg nsig sp
eca4db63ed0bdbd93b62678feea6e3eb80aa47bbChristian Maeder let gsigma = getSig nsig
1df33829303cbf924aa018ac5ce9a28e69c17d22Till Mossakowski gsigma' = getSig nsig'
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett n' <- maybeToResult nullPos "Reduction of empty spec" (getNode nsig')
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett (hmor,tmor) <- ana_RESTRICTION dg gsigma gsigma' restr
1df33829303cbf924aa018ac5ce9a28e69c17d22Till Mossakowski -- we treat hiding and revealing differently
1df33829303cbf924aa018ac5ce9a28e69c17d22Till Mossakowski -- in order to keep the dg as simple as possible
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett do let gsigma' = dom Grothendieck hmor
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett -- ??? too simplistic for non-comorphism inter-logic reductions
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett G_sign lid' sigma' <- return gsigma'
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett let node_contents = DGNode {
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder dgn_sign = G_sign lid' (empty_signature lid'),
b3dca469a9e267d6d71acfdeca7bf284d0581dc7Till Mossakowski dgn_sens = G_l_sentence lid' [],
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgn_origin = DGHiding }
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder [node] = newNodes 1 dg'
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder link = DGLink {
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgl_morphism = hmor,
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgl_type = HidingDef,
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder dgl_origin = DGHiding }
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder return (NodeSig(node,gsigma'),
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder insEdge (n',node,link) $
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder insNode (node,node_contents) dg')
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder Just tmor' ->
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder do let gsigma1 = dom Grothendieck tmor'
b6e474220ddcf68a75ca3dc26093c5ac21e31747Christian Maeder gsigma'' = cod Grothendieck tmor'
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett -- ??? too simplistic for non-comorphism inter-logic reductions
b3dca469a9e267d6d71acfdeca7bf284d0581dc7Till Mossakowski G_sign lid1 sigma1 <- return gsigma1
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett G_sign lid'' sigma'' <- return gsigma''
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett let [node1,node''] = newNodes 2 dg'
03136b84a0c70d877e227444f0875e209506b9e4Christian Maeder node_contents1 = DGNode {
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett dgn_sign = G_sign lid1 (empty_signature lid1),
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett dgn_sens = G_l_sentence lid1 [],
1df33829303cbf924aa018ac5ce9a28e69c17d22Till Mossakowski dgn_origin = DGRevealing }
b3dca469a9e267d6d71acfdeca7bf284d0581dc7Till Mossakowski link1 = DGLink {
e54c5af823b9775dd2c058185ea5bdf7593950faAndy Gimblett dgl_morphism = hmor,
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett dgl_type = HidingDef,
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett dgl_origin = DGRevealing }
afd6ed16928bbd774b6c6c5b3f440a917dd638a1Andy Gimblett node_contents'' = DGNode {