Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uml #2155

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open

Uml #2155

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8213434
Premature parsers for UML class diagrams and state machines.
MGlauer Jun 24, 2014
9a27dcb
Added attribute multiplicities
MGlauer Jun 30, 2014
9fe92d0
Formatted by stylish-haskell
MGlauer Jul 14, 2014
c8021a6
- associations in CD link directly to the class
MGlauer Feb 2, 2015
3cdbfe6
MGlauer Feb 3, 2015
706c030
MGlauer Feb 22, 2015
47b0c39
partially fixed Id usage in UML-DS
MGlauer Feb 22, 2015
2d1eba3
qualified UML modules
MGlauer Mar 16, 2015
cf7fc4f
Added logic instance for UML (yet without non-default-morphisms)
MGlauer Mar 24, 2015
48647ac
Added missing files
MGlauer Mar 24, 2015
4ae5e0b
Added morphism file
MGlauer Mar 24, 2015
295c19f
replaced ATC_UML.hs by ATC_UML.der.hs
MGlauer Mar 24, 2015
fc4ec4e
UML is now DrIftable
MGlauer Mar 24, 2015
7d4bbb0
adapted makefile
MGlauer Mar 24, 2015
d02a239
UML with xmi
MGlauer Mar 24, 2015
d72b572
Fixed crash on missing association name
MGlauer Mar 24, 2015
419606d
fixed switched parameters in tau-translation
MGlauer Mar 26, 2015
3a27a3f
fixed typos in sentence translation
MGlauer Mar 26, 2015
86cdea0
type strings in seq2[Tau] must be lower case
MGlauer Mar 26, 2015
85be9f5
Fixed UML->CL translation bugs
MGlauer May 12, 2015
f5a5994
Better support of different XMI-files
MGlauer Jun 14, 2015
932fd37
Designed error messages more helpful
MGlauer Jun 14, 2015
c8e4c98
abstract syntax for filtering with symbol lists
tillmo Feb 29, 2016
f6c4779
implemented parsing and printing for filtering symbol lists
tillmo Feb 29, 2016
3d1e008
Merge branch '1572_static_analysis_for_intersections' into 1576_stati…
mcodescu Feb 29, 2016
5bddb06
rejecting sentences goes through
mcodescu Mar 1, 2016
d68569f
better node name, however just internal
mcodescu Mar 1, 2016
29af75f
node name right
mcodescu Mar 1, 2016
ab58f7b
names of symb_items for OWL
mcodescu Mar 1, 2016
6631ef0
relations
mcodescu Mar 2, 2016
d906e39
modified the export
mcodescu Mar 2, 2016
32d9395
go through ALL facts
mcodescu Mar 2, 2016
0d3cb1e
removed tracing messages
mcodescu Mar 2, 2016
07d4e61
Merge remote-tracking branch 'origin/1576_static_analysis_of_filtering'
tillmo Mar 3, 2016
8522cbe
deleted trailing whitespaces
mcodescu Mar 3, 2016
509b1f1
removed old traces
mcodescu Mar 3, 2016
756c399
Merge remote-tracking branch 'origin/medusa'
tillmo Mar 3, 2016
ae67c37
Merge remote-tracking branch 'origin/medusa'
tillmo Mar 3, 2016
57de75c
get spec names for filterings too
mcodescu Mar 3, 2016
35428ee
merged
tillmo Mar 4, 2016
7c4faa7
merged
tillmo Mar 4, 2016
ac2b71d
Merge remote-tracking branch 'origin/1576_static_analysis_of_filterin…
tillmo Mar 4, 2016
6da7cba
merged
tillmo Mar 4, 2016
303ad37
rejecting several axioms
mcodescu Mar 4, 2016
a3a76de
Merge remote-tracking branch 'origin/1576_static_analysis_of_filterin…
tillmo Mar 4, 2016
4590bda
Merge remote-tracking branch 'origin/1572_static_analysis_for_interse…
tillmo Mar 4, 2016
39bece1
changed order of arguments in the call of mapObjPropI
mcodescu Mar 5, 2016
59205f6
Merge remote-tracking branch 'origin/1584_fixing_OWL2CASL' into develop
tillmo Mar 5, 2016
97933ec
hack for translating symbols to CASL, 1585
mcodescu Mar 5, 2016
47eccdf
removed tracing message
mcodescu Mar 5, 2016
09d967e
Merge remote-tracking branch 'origin/1584_fixing_OWL2CASL' into develop
tillmo Mar 5, 2016
0bcfc84
Add comments
MGlauer Dec 16, 2016
00b2d1d
Merge remote-tracking branch 'origin/develop' into UML
MGlauer Dec 16, 2016
112e586
Fix legacy issues
MGlauer Dec 1, 2017
f5fb471
Resolve conflict in Driver/ReadLibDefn.hs
MGlauer Dec 1, 2017
a56a822
Fix translation UML -> CL
MGlauer Dec 1, 2017
395e13e
Use new Sentence structure in UML-CD -> CL
MGlauer Dec 1, 2017
15ea34a
Merge branch 'master' into UML
MGlauer Dec 1, 2017
5362b16
Implement Datatype handling
MGlauer Dec 5, 2017
9e1b538
Add attributes to UML.UML.DataType
MGlauer Dec 5, 2017
74165ce
Remove unused imports
MGlauer Dec 5, 2017
4059aad
Filter operations that do not have a return type
MGlauer Dec 5, 2017
3ab9641
resolved merge conflicts
tillmo Jul 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Common/Id.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data Token = Token { tokStr :: String
} deriving (Eq, Ord, Typeable, Data)

instance Show Token where
show = tokStr
show x = "(mkSimpleId "++['"'] ++ (tokStr x) ++ ['"'] ++ ")"

instance Read Token where
readsPrec i = map (\ (a, r) -> (mkSimpleId a, r)) . readsPrec i
Expand Down
3 changes: 3 additions & 0 deletions CommonLogic/Morphism.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,6 @@ morphismUnion mor1 mor2 =
{ source = unite p1 p2
, target = unite (target mor1) $ target mor2
, propMap = pmap } else Result pds Nothing



4 changes: 3 additions & 1 deletion Comorphisms/LogicGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import Comorphisms.QVTR2CASL
import Comorphisms.CASL2Hybrid
import Comorphisms.Hybrid2CASL

import Comorphisms.UML_CD2CL

#ifdef CASLEXTENSIONS
import Comorphisms.CoCFOL2IsabelleHOL
Expand Down Expand Up @@ -244,7 +245,8 @@ comorphismList =
, Comorphism QBF2Prop
, Comorphism Prop2QBF
, Comorphism CSMOF2CASL
, Comorphism QVTR2CASL ]
, Comorphism QVTR2CASL
, Comorphism UML_CD2CL]

inclusionList :: [AnyComorphism]
inclusionList =
Expand Down
2 changes: 2 additions & 0 deletions Comorphisms/LogicList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ import OWL2.Logic_OWL2
import RDF.Logic_RDF
#endif
import Comorphisms.DynLogicList
import UML.Logic_UML
import NeSyPatterns.Logic_NeSyPatterns

logicList :: [AnyLogic]
Expand Down Expand Up @@ -136,6 +137,7 @@ logicList =
#endif
, Logic CSMOF
, Logic QVTR
, Logic UML
, Logic NeSyPatterns
] ++ dynLogicList

Expand Down
114 changes: 114 additions & 0 deletions Comorphisms/UML_CD2CL.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses #-}
module Comorphisms.UML_CD2CL where

import Common.ProofTree
import Common.Result
import Common.Id
import Common.AS_Annotation

import Logic.Logic
import Logic.Comorphism

import UML.Sign
import UML.Logic_UML
import UML.UML hiding (Id)
import UML.UML2CL
import UML.UML2CL_preamble
import UML.Morphism

import CommonLogic.Sign as CL_Sign
import CommonLogic.Logic_CommonLogic
import CommonLogic.AS_CommonLogic as As_CL
import CommonLogic.Symbol as Symbol
import CommonLogic.ATC_CommonLogic ()
import CommonLogic.Sublogic
import CommonLogic.Morphism
import CommonLogic.Analysis

import qualified Data.Map as Map
import qualified Data.Set as Set
-- | lid of the morphism
data UML_CD2CL = UML_CD2CL deriving Show

instance Language UML_CD2CL where
language_name UML_CD2CL = "UML2CommonLogic"

instance Comorphism UML_CD2CL
UML.Logic_UML.UML
() -- Sublogics
UML.UML.CM -- basic_spec
UML.Sign.Sen -- sentence
() -- symb_items
() -- symb_map_items
UML.Sign.Sign -- sign
UML.Morphism.Morphism -- morphism
() -- symbol
() -- raw_symbol
() -- proof_tree
CommonLogic.Logic_CommonLogic.CommonLogic
CommonLogicSL -- Sublogics
BASIC_SPEC -- basic_spec
TEXT_META -- sentence
SYMB_ITEMS -- symb_items
SYMB_MAP_ITEMS -- symb_map_items
CL_Sign.Sign -- sign
CommonLogic.Morphism.Morphism -- morphism
Symbol -- symbol
Symbol -- raw_symbol
ProofTree -- proof_tree
where
sourceLogic UML_CD2CL = UML.Logic_UML.UML
targetLogic UML_CD2CL = CommonLogic.Logic_CommonLogic.CommonLogic
map_theory UML_CD2CL = mapTheory
map_morphism UML_CD2CL = mapMor

mapTheory :: (UML.Sign.Sign, [Named Sen]) -> Result (CL_Sign.Sign, [Named TEXT_META])
mapTheory (sign, sens) = let
sg = (mapSign sign)
t = (translateSign2Phrases sign)
tmSyms = (Set.fromList $ map symName $ foldl (++) [] $ map (symsOfTextMeta.sentence) tms) Set.\\ (allItems sg)
sg2 = CL_Sign.Sign{ discourseNames = Set.union (discourseNames sg) tmSyms,
CL_Sign.nondiscourseNames = CL_Sign.nondiscourseNames sg,
sequenceMarkers = sequenceMarkers sg}
tms = (map (makeNamedSen.emptyAnno) t) ++ (map (mapNamed $ mapSen) sens)
in return (sg2 , tms)


mapSen :: UML.Sign.Sen -> TEXT_META
mapSen mf = Text_meta{ As_CL.getText = Text phrases nullRange
, As_CL.textIri = Nothing
, As_CL.nondiscourseNames = Nothing
, As_CL.prefix_map = [] }
where phrases = (Sentence (translateMult2Sen mf)):[]--(translateSign2Phrases sign)


mapSign :: UML.Sign.Sign -> CL_Sign.Sign
mapSign sign = CL_Sign.Sign{
CL_Sign.discourseNames = Set.union (Set.fromList ((map (stringToId.showClassEntityName) $ fst $ signClassHier sign)
++ (map (stringToId.literalName) $ foldl (++) [] (map enumLiterals $ filterEnums $ fst $ signClassHier sign))
++ (map morphTranslateAttr (signAttribute sign))
++ (foldl (++) [] $ map morphTranslateOper (signOperations sign))
++ (map morphTranslateComp (signCompositions sign))
++ (foldl (++) [] $ map morphTranslateAsso (signAssociations sign)))) (foldl (Set.union) Set.empty preambleDiscourseNames),
CL_Sign.nondiscourseNames = (foldl (Set.union) Set.empty preambleNonDiscourseNames),
CL_Sign.sequenceMarkers = (foldl (Set.union) Set.empty preambleSequenceMarkers)
}

morphTranslateAttr :: (Class,String,Type) -> Id
morphTranslateAttr (c,s,_) = (stringToId $ className c ++ "." ++ s)

morphTranslateComp :: ((String,ClassEntity),String,(String,Type)) -> Id
morphTranslateComp ((_,_),n,(_,_)) = stringToId n

morphTranslateAsso :: (String,[(String,Type)]) -> [Id]
morphTranslateAsso (n,endL) = (stringToId n):(map (stringToId.fst) endL)

morphTranslateOper :: (Class,String,[(String,Type)],Type) -> [Id]
morphTranslateOper (c,n,para,_) = (stringToId $ (className c) ++ "." ++ n):(map (stringToId.fst) para)

mapMor :: UML.Morphism.Morphism -> Result CommonLogic.Morphism.Morphism
mapMor m = return CommonLogic.Morphism.Morphism
{ CommonLogic.Morphism.source = mapSign $ UML.Morphism.source m
, CommonLogic.Morphism.target = mapSign $ UML.Morphism.target m
, CommonLogic.Morphism.propMap = Map.empty
}
2 changes: 2 additions & 0 deletions Driver/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ data InType =
| CommonLogicIn Bool -- ^ "clf" or "clif" ('True' is long version)
| DgXml
| Xmi
| UMLCDXmi
| Qvt
| TPTPIn
| HtmlIn -- just to complain
Expand Down Expand Up @@ -570,6 +571,7 @@ instance Show InType where
Xmi -> "xmi"
Qvt -> "qvt"
HtmlIn -> "html"
UMLCDXmi -> "UMLCD"

-- maybe this optional tree prefix can be omitted
instance Read InType where
Expand Down
10 changes: 10 additions & 0 deletions Driver/ReadFn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ import Data.Char (isSpace)
import Data.List (isPrefixOf)
import Data.Maybe

import UML.Parser

noPrefix :: QName -> Bool
noPrefix = isNothing . qPrefix

Expand All @@ -69,6 +71,9 @@ isPpXml q = qName q == "Lib" && noPrefix q
isDMU :: QName -> Bool
isDMU q = qName q == "ClashResult" && noPrefix q

isXMI :: QName -> Bool
isXMI q = qName q == "XMI"

isRDF :: QName -> Bool
isRDF q = qName q == "RDF" && qPrefix q == Just "rdf"

Expand All @@ -87,9 +92,14 @@ guessXmlContent isXml str = case dropWhile isSpace str of
| isDMU q -> Left "unexpected DMU xml format"
| isPpXml q -> Left "unexpected pp.xml format"
| null (qName q) || not isXml -> Right GuessIn
| isUMLCDroot e-> Right UMLCDXmi
| otherwise -> Left $ "unknown XML format: " ++ tagEnd q ""
_ -> Right GuessIn -- assume that it is no xml content

isUMLCDroot :: Element -> Bool
isUMLCDroot el0 = not $ isNothing $ findModelElement el0


isDgXmlFile :: HetcatsOpts -> FilePath -> String -> Bool
isDgXmlFile opts file content = guess file (intype opts) == DgXml
&& guessXmlContent True content == Right DgXml
Expand Down
16 changes: 15 additions & 1 deletion Driver/ReadLibDefn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import QVTR.ParseQvtAsLibDefn
import TPTP.ParseAsLibDefn
import FreeCAD.Logic_FreeCAD

import Data.Maybe
import Driver.Options
import Driver.ReadFn

Expand All @@ -42,11 +43,15 @@ import Common.Result
import Common.ResultT

import Text.ParserCombinators.Parsec
import Text.XML.Light

import Control.Monad.Trans (MonadIO (..))
import qualified Control.Monad.Fail as Fail
import Data.List

import UML.ParseUMLAsLibDefn
import UML.Parser

mimeTypeMap :: [(String, InType)]
mimeTypeMap =
[ ("xml", DgXml)
Expand Down Expand Up @@ -96,8 +101,12 @@ guessInput opts mr file input =
_ -> return $ joinFileTypes fty ty
else return fty

isUMLCDroot :: Element -> Bool
isUMLCDroot el0 = not $ isNothing $ findModelElement el0

readLibDefn :: LogicGraph -> HetcatsOpts -> Maybe String
-> FilePath -> FilePath -> String -> ResultT IO [LIB_DEFN]

readLibDefn lgraph opts mr file fileForPos input =
if null input then Fail.fail ("empty input file: " ++ file) else
case intype opts of
Expand All @@ -112,7 +121,12 @@ readLibDefn lgraph opts mr file fileForPos input =
#ifdef RDFLOGIC
-- RDFIn -> liftIO $ parseRDF file
#endif
Xmi -> return [parseXmi file input]
UMLCDXmi -> liftIO $ fmap (: []) $ parseUMLCDasLibDefn file
Xmi -> liftIO $ fmap (: []) $ case parseXMLDoc input of
Nothing -> error "empty XMI"
Just e -> case isUMLCDroot e of
True -> parseUMLCDasLibDefn file
False -> parseXmi file input
Qvt -> liftIO $ fmap (: []) $ parseQvt file input
TPTPIn -> parseTPTP opts file input
#ifndef NOOWLLOGIC
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ logics = CASL HasCASL Isabelle Modal Hybrid TopHybrid Temporal \
CoCASL COL CspCASL CASL_DL \
SoftFOL ConstraintCASL Propositional RelationalScheme VSE OMDoc DFOL \
LF Framework Maude ExtModal CommonLogic CSL QBF Adl HolLight Fpl THF \
FreeCAD OWL2 RDF CSMOF QVTR TPTP NeSyPatterns
FreeCAD OWL2 RDF CSMOF QVTR TPTP UML NeSyPatterns

TESTTARGETFILES += Scratch.hs CASL/fromKif.hs CASL/capa.hs HasCASL/hacapa.hs \
Haskell/wrap.hs Isabelle/isa.hs Syntax/hetpa.hs \
Expand Down Expand Up @@ -362,6 +362,8 @@ RDF_files = RDF/AS.hs RDF/Symbols.hs RDF/Sign.hs RDF/Morphism.hs \

CSMOF_files = CSMOF/As.hs CSMOF/Sign.hs

UML_files = UML/UML.hs UML/Sign.hs UML/Morphism.hs UML/StateMachine.hs

QVTR_files = QVTR/As.hs QVTR/Sign.hs

TPTP_files = TPTP/AS.hs TPTP/Sign.hs TPTP/Sublogic.hs
Expand Down Expand Up @@ -471,6 +473,9 @@ RDF/ATC_RDF.der.hs: $(RDF_files) $(GENRULES)
CSMOF/ATC_CSMOF.der.hs: $(CSMOF_files) $(GENRULES)
$(GENRULECALL) -i Common.ATerm.ConvInstances -i Common.Json.ConvInstances -o $@ $(CSMOF_files)

UML/ATC_UML.der.hs: $(UML_files) $(GENRULES)
$(GENRULECALL) -i Common.ATerm.ConvInstances -o $@ $(UML_files)

QVTR/ATC_QVTR.der.hs: $(QVTR_files) CSMOF/ATC_CSMOF.hs $(GENRULES)
$(GENRULECALL) -i CSMOF.ATC_CSMOF -i Common.ATerm.ConvInstances -i Common.Json.ConvInstances \
-o $@ $(QVTR_files)
Expand Down
Binary file removed OWL2/java/lib/trove4j-3.0.3.jar
Binary file not shown.
Binary file not shown.
Loading
Loading