Parsing inline functional syntax axioms with OWL API - owl-api

I need to parse some axioms represended as strings in functional syntax
in order to add to an existing ontology or compare with its axioms.
(i.e. convert the string like 'ObjectPropertyAssertion(:crosses :flow :line)' to an OWLAxiom object).
I know it is possible for the machester syntax by the ManchesterOWLSyntaxParserImpl class with the setStringToParse() and parseAxiom() methods.
Has the functional parser got the simular feature?
Or is there third-part implementation or an example that allows to easily parse inline strings above existing ontology?

That feature is unique to Manchester syntax, the other OWLAPI parsers do not support it.
However, if the axiom you wish to parse is self contained (i.e., no prefixes and no declarations required to disambiguate entities) a workaround would be to wrap it in an empty ontology and parse that.
# add your axiom string here
Then just retrieve all axioms and discard the ontology.


What is the difference between Association and Composition Aggregation in Autosar domain

I am reading Autosar document and in one of the document (Autosar_TemplateModelingGuideline.pdf), it says that:
Composite aggregation, forming a whole-part relationship
Regular association, expressing a reference from the associating to
the associated model element
My question is: what is the difference between these two in practice? How do I have to interpret them in a class diagram, e.g. the Com Module in Autosar.:
The AUTOSAR COM module’s Configuration Overview
Consider Specified class ComGwSignalRef surrounded with a red rectangle. This class has a composition relation with ComGwSignalRef class and two regular association with ComGroupSignal and ComSignal.
How would you interpret this as a developer and how do you implement in C?
if regular association is a reference to an object that has independent life from ComGwSignalRef why designer do not use instanceRef here?
if it is not a reference, why did the designer not use composition?
PS. There is a concept in Autosar "InstanceRef" which is used for reference for independent object with independent lifecycle.
Maybe you should also consider the following:
The Com Configuration is an instance of the EcuC configuration meta-model as defined in the AUTOSAR_TPS_EcuConfiguration.
The ComGwSignalRef is of type EcucChoiceContainerDef, and as such, the two destination associations of ComSignal and ComGroupSignal have a meaning. Only one of these "choices" can be selected in the final configuration as a reference. In AUTOSAR metamodel, that is the definition of how EcucChoiceContainerDef works, in UML you might need here an additional constraint element to define the XOR relation of two associations.
An object can only be composed as part of one object.
A <>- C -<>B
In the diagram above C is composed in A and B. This would lead to the following instances:
a: A <>- c: C -<> b:B
Now the specific instance c is now part of both a and b.
What happen would with c if b goes out of scope? By the semantics it should be destroyed and not be destroyed (a still exists).
Or more pointed:
Take Alice,Bob, and Collar Bone as examples. Alice’s collar bone cannot be part of Bob.
UML is a modeling language and has not the same expressiveness as, say a C compiler. This is by design to simplify things.
Remember: All models are wrong, but some are useful. — George E. P. Box

Using Same Object Property between Multiple Classes

I tried to use the same object property between multiple classes, but I got a warning that the same object property has been set multiple times as follows, can you please let me know what is wrong with that and how to solve it? Does this restrict reasoning later on (i.e. confuse the reasoner since the same object property is set multiple times)?
Contrary to the comments it actually is very problematic to use the same object property between multiple classes.
What you don't see in your visualization is that in RDF/OWL, the starting point of your relation arrows is modelled as rdfs:domain and the target point of the arrows is modelled as rdfs:range.
The semantic of an OWL class is that it is a set of individuals and rdfs:domain and rdfs:range specify the domain, respectively range of a relation. That is, they specify the sets of allowed values in subject, respectively object position of a triple with that relation in the predicate position.
If you express your example in RDF Turtle it would look like this:
:hasPart rdfs:domain :ClassA, :ClassB;
rdfs:range :ClassB, :ClassC, :ClassD.
This causes multiple problems:
The semantic of multiple domains, respectively ranges, is the intersection of those classes, not the union!
Even if we disregard the relation between :ClassB and :ClassD, this means :hasPart is only allowed by individuals that are instances of class C and class D at the same time!
For example, lets say class A is "car", class B is "tire" and class C is "motor". Now you want to say that a car can have tires and motors but what you actually specify is that a car can only have things that are a motor and a tire at the same time!
Unwanted but allowed usage
If you fix the first problem but specifying the union instead of the intersection, it will be very messy in serialized RDF because you need a large amount of triples to represent OWL restrictions such as unions. But even if you do that, you could now connect an instance of class A with an instance of class D, which is not allowed in the image.
The solution is simple, just separate those relations, for example into :hasB, :hasC and :hasD, although in a real scenario you can probably find a more suitable naming scheme, where the "has" prefix is often not used. For example, in DBpedia, the property for the country of a city is expressed using dbo:country, not dbo:hasCountry.

Does SWRL support classical negation in Protege?

I wanted to try the following rule:
(not Person)(?x) -> NonHuman(?x) which is provided here -
and i got this:
Is classical negation supported in Protege 5.5.0? If yes, how I can make the following rule to be okay?
Thanks in advance!
Unfortunately, the SWRLAPI's parser does not support OWL class expressions in rules.
There is no timeline for their inclusion.
Fortunately, one can use the Rules view (Windows > Views > Ontology Views > Rules):
Rule: (not Person)(?x) -> NonHuman(?x) is parsed correctly and works as intended.
Actually, you do not need SWRL in this particlular case. Just write (not Person) SubClassOf NonHuman in the General class axioms section, or define NonPerson first, if you don't like GCI axioms.
Don't forget about the OWA.

Why does FunctionalObjectProperty take an Object Property Expression, not a named property only?

The functional object property axiom - here in functional syntax - has the form
P is an Object Property Expression, which is one of:
a named object property (PN). Example: FunctionalObjectProperty(:hasBase)
the owl:topObjectProperty
the owl:bottomObjectProperty
an inverse property. Example: FunctionalObjectProperty(ObjectInverseOf(:isBaseOf))
The first is expected. What's the use of the three other variants? These seem to only increase the complexity of parsers, reasoners and APIs. (Yes, marginally.)
The last looks redundant since OWL has an "InverseFunctionalObjectProperty". And who declares top- or bottomObjectProperty as functional ?
I searched through ontologies like So far, they use nothing else than a named property (PN) as parameter.
Anyway, OWL allows P here, and I may miss the forest for the trees. What is it good for ?
Remark:The same can be asked for other unary property axioms like SymmetricObjectProperty.
This definition is used in OWL to define what the language syntax considers correct. However there can be some language constructs that are broadly used and other that are syntactically correct but have limited usage.
The definition of the FunctionalObjectProperty axiom allows one to state that an object property expression is functional — that is, that each individual can have at most one outgoing connection of the specified object property expression. 1
The syntax definition of FunctionalObjectProperty is:
Functional Object Properties:
FunctionalObjectProperty := 'FunctionalObjectProperty' '('
axiomAnnotations ObjectPropertyExpression ')'
This definition refers to the ObjectPropertyExpression which is defined as follows.
Object Property Expression definition
ObjectProperty := IRI
ObjectPropertyExpression := ObjectProperty | InverseObjectProperty
InverseObjectProperty := 'ObjectInverseOf' '(' ObjectProperty ')'
This basically mean that there are 2 ways to define an object property.
The first way is to directly define an IRI as an object property.
The second way is to indirectly define an object property as the inverse of an already defined object property.
The difference can be demonstrated in these examples:
Example A: FunctionalObjectProperty(:isGoodFor)
Example B: FunctionalObjectProperty(ObjectInverseOf(:isBaseOf))
The Example A uses an existing Object Property :isGoodFor while the Example B uses the inverse of the defined Object Property :isBaseOf without defining an IRI for it.
The syntax definition for ObjectPropertyExpression includes any Object Property IRI, since it does not exclude it. Therefore the TopObjectProperty and BottomObjectProperty are syntactically valid choices.
So the following are syntactically valid:
However owl:topObjectProperty and owl:bottomObjectProperty have predefined semantics in OWL2. So while the above statements are syntactically correct, it would not be a good practice to use them.
Definitions of TopObjectProperty and BottomObjectProperty
Owl defines 2 built-in object properties with the IRIs owl:topObjectProperty and owl:bottomObjectProperty. And have predefined semantics.
The object property with IRI owl:topObjectProperty connects all possible pairs of individuals.
The object property with IRI owl:bottomObjectProperty does not connect any pair of individuals.

SWRLTab usage in Protege

I'm used to Protégé but now, I'm trying to use SWRLTab, a Protégé plugin.
The problem is that I'm really not familiar with the SWRL rule-syntax. Let's have fun with my problem :
I've an well-known ontology, called "pizza". Let's say I've a 4cheesesPizza, subclass of Pizza.
I don't want to write the "hasTopping exactly 4 CheesyTopping" thing in the "Equivalent To" tab of Protégé BUT I want to write it in the SWRL Rule syntax. (yes I know it's stupid, but this is an example and in my real case, write a rule makes sense).
I tried something like Pizza(?p) ^ hasTopping(?p,?t) but next, I'm quite blocked. I don't know what to do.
Moreover, when I launch OWL + SWRL -> Drools , in the Inferred Axioms there's already more than 100 lines, It's unreadable.
If someone has the solution,
Thanks, Clément
What you want to do in SWRL is not possible. I.e. SWRL will need to count the number of individuals that are in a hasTopping relation with a specific individual p of type Pizza. SWRL cannot do that, but the OWL reasoner can, hence what you have specified in Protege is the correct way to do it.
As an example for SWRL syntax, assume you have classes ExpensiveTopping and ExpensivePizza you could add a rule in the SWRL tab to determine an expensive pizza:
Pizza(?p) ^ hasTopping(?p,?t) ^ ExpensiveTopping(?t) -> ExpensivePizza(?p).