Not able to generate inference for propertyChainAxiom - ontology

I am using propertyChainAxiom to build one of the inference statements. I have defined a basic ontology which defines properties and statements as below :
ex:
:isParent rdf:type owl:ObjectProperty .
:Person1 :hasParent :Person2.
:Person2 :hasParent :Person3.
:hasGrandParent owl:propertyChainAxiom (:hasParent :hasParent) .
:Person1 :hasGrandParent ?o .
I have defined ontology and thesaurus in Ontotext GraphDB and have used the OWL2-horst ruleset.
The statement :Person1 :hasGrandParent doesn't seems to return Person3 as per inferred statement. Am I missing something here ?

As Damyan said, use OWL-RL.
Reposting his comment as answer, so this question doesn't appear again in [graphdb] answers:0

Related

(Xtext) How to change the scoping of imported resources via importURI?

I have a DSL that allows to explicitly import resources (via importURI attribute). Everything is working just fine, except the fact that I would like to refer to imported elements directly by their ID (not by fully qualified name).
I am not using importedNamespace, because I've limited the GlobalScope to only what is explicitly imported and for each resource I need all elements (like ModelName.*).
So, right now I'm able to refer to imported elements like this:
ModelName.OuterElement.InnerElement
but I would like to have something like this:
OuterElement or InnerElement.
Of course, the general context is more complex and a bit different, but I've tried to simplify everything just around this question. So, please refer to the following grammar:
Model:
name=ID ':'
(include+=Include)?
(outerElems+=OuterElement ';')*
(uses+=Use ';')*;
Include:
'import' importURI=STRING ;
OuterElement:
'def' name=ID
'(' (innerElements+=InnerElement (',' innerElements+=InnerElement)* )? ')' ;
InnerElement:
name=ID;
Element:
OuterElement | InnerElement;
Use:
'use' use =[Element|FQN];
FQN:
ID('.'ID)* ;
if you want to refer to elements by their simple name you have to bind
SimpleNameProvider
as IQualifiedNameProvider
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return SimpleNameProvider.class;
}
respectively
override bindIQualifiedNameProvider() {
SimpleNameProvider
}

Extending XFeatureCall scope

This has been puzzling me for a while... I have done research, tried lots of things but failed miserably. The time has come to ask here.
My grammar has this rule to define types:
MyTypeDeclaration returns XExpression:
=>({MyTypeDeclaration} type=JvmTypeReference name=ValidID '(')
(params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)?
')' block=XBlockExpression
;
Of course, in the inferrer, I map it to a class (with a supertype MySupertype to differentiate from other Java classes)
members += f.toClass(f.fullyQualifiedName) [
superTypes += typeRef(MySupertype)
...
members += f.toConstructor [
for (p : f.params)
parameters += p.toParameter(p.name, p.parameterType)
body = f.block
]
...
]
What I need is to invoke this class as a function, e.g. using XFeatureCall. XFeatureCall::feature is a JvmIdentifiableElement and so is MyTypeDeclaration when mapped (in the compiler I will add a "new" prefix to call the class constructor). However, naturally, XFeatureClass does not include Java classes in its default scope.
So the question is, how to change this behavior? I need to include MyTypeDeclaration instances (or, more generally, Java classes with MySupertype as superclass) in XFeatureClass scope. I looked at the type computer, getLinkingCandidates and al but it looks too arcane for me.
I use version 2.15 as I need GWT...
Please help as I am really stuck at this point...
Thanks,
Martin

Why doesn't the Jena validator give me warnings?

In the following code, the ValidityReport is always valid; there is no inconsistency detected. I expect that it should give me a warning because I am giving a family name to a FOAF document. Why isn't an inconsistency detected?
Model model = ModelFactory.createDefaultModel();
OntModel m = ModelFactory.createOntologyModel();
m.read(FOAF.NS);
Resource persona = model.createResource("http://www.example.org/rdf#Persona", FOAF.Document);
persona.addProperty(FOAF.family_name, "18", XSDDatatype.XSDint);
InfModel infModel = ModelFactory.createRDFSModel(m, model);
ValidityReport validity = infModel.validate();
if (validity.isValid()) {
System.out.println("Valid!");
} else {
System.out.println("Conflicts");
for (Iterator<Report> in = validity.getReports(); in.hasNext();) {
System.out.println(" - " + in.next());
}
}
The instance data that you're creating is this:
#prefix ex: <http://www.example.org/rdf#> .
#prefix foaf: <http://xmlns.com/foaf/0.1/> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:Persona a foaf:Document ;
foaf:family_name "18"^^xsd:int .
There's a resource of type foaf:Document, and it has an xsd:int value for the the foaf:family_name property.
Your inference model uses an RDFS reasoner. The domain of foaf:family_name (which, by the way, is described as an archaic spelling of foaf:familyName) is foaf:Person, so ex:Persona can thus be inferred to be a foaf:Person, as we see if we write the inference model. There are a number of other types that ex:Persona is inferred to have as well:
ex:Persona a foaf:Document , foaf:Person , <http://www.w3.org/2000/01/rdf-schema#Resource> , <http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing> , foaf:Agent ;
foaf:family_name "18"^^xsd:int .
It's rather hard to have inconsistencies in an RDFS model, since you can't really say a whole lot. You can't declare disjoint classes, for instance, so there's no contradiction between something being a foaf:Document and a foaf:Person.
Even if you use an OWL reasoner, you'd still need to pinpoint some particular logical inconsistency. I don't know whether any of those types that ex:Persona has are disjoint, and if they're not (or if the reasoner can't infer that they are), you're not going to find an inconsistency.

Basic parse failure in Rascal MPL Basic Entity Modelling

I'd like to run through a simple Rascal MPL parsing example, and am trying to follow Listing 1 from the Rascal Language Workbench (18531D.pdf) of May 3rd 2011. I've downloaded the current Rascal MPL version 0.5.1, and notice that a few module paths have changed. The following shows the content of my Entities.rsc:
module tut1::Entities
extend lang::std::Layout;
extend lang::std::Id;
extend Type;
start syntax Entities
= entities: Entity* entities;
syntax Entity
= #Foldable entity: "entity" Id name "{" Field* "}";
syntax Field
= field: Symbol Id name;
I'm assuming here that what was Name and Ident is now Id; and what was Type is now Symbol. I then continue as follows:
rascal>import tut1::Entities;
ok
rascal>import ParseTree;
ok
However, when I attempt to execute the crucial parse function, I receive the errors listed below. Where am I going wrong? (Despite the message I note that I can declare a Symbol variable at the Rascal prompt.)
rascal>parse(#Entities, "entity Person { string name integer age }");
Extending again?? ParseTree
Extending again?? Type
expanding parameterized symbols
generating stubs for regular
generating literals
establishing production set
generating item allocations
computing priority and associativity filter
printing the source code of the parser class
|prompt:///|(22,43,<1,22>,<1,65>): Java("Undeclared non-terminal: Symbol, in class: class org.rascalmpl.java.parser.object.$shell$")
org.rascalmpl.parser.gtd.SGTDBF.invokeExpects(SGTDBF.java:139)
org.rascalmpl.parser.gtd.SGTDBF.expandStack(SGTDBF.java:864)
org.rascalmpl.parser.gtd.SGTDBF.expand(SGTDBF.java:971)
org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1032)
org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1089)
org.rascalmpl.parser.gtd.SGTDBF.parse(SGTDBF.java:1082)
org.rascalmpl.interpreter.Evaluator.parseObject(Evaluator.java:493)
org.rascalmpl.interpreter.Evaluator.parseObject(Evaluator.java:544)
org.rascalmpl.library.Prelude.parse(Prelude.java:1644)
org.rascalmpl.library.Prelude.parse(Prelude.java:1637)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
somewhere in: $shell$
The example is out-of-date. Something like this would work better:
module tut1::Entities
extend lang::std::Layout; // for spaces and such
extend lang::std::Id; // for the Id non-terminal
start syntax Entities
= entities: Entity* entities;
syntax Entity
= #Foldable entity: "entity" Id name "{" Field* "}";
syntax Field
= field: Id symbol Id name; // now Id is used instead of Symbol and "symbol" is just the name of a slot in the rule
Some explanation:
the imports/extends have gone, they were unnecessary and might be confusing
there was a missing definition for the Symbol non-terminal. I don't know what it was supposed to do, but it should have been defined syntax Symbol = ..., but it did not make sense to me and instead I reused Id to define the type of a field.
the type checker (under development) would have warned you before using the parse function.

Xtext: Couldn't resolve reference to JvmType 'String'

For our master project at university we created multiple DSLs using Xtext. One of the DSLs is a model entity DSL which allows the user to create a class with properties and methods.
We reuse Xbase because, of course, we want the methods to have a real programming language without reinventing the wheel:
grammar … with org.eclipse.xtext.xbase.Xbase
generate …
EntityModel:
'package' importedNamespace=QualifiedName
…
implementation=Entity;
Entity:
'entity' name=ValidID '{'
features+=Feature*
'}';
Feature:
LocalVariable | …;
LocalVariable:
'var' (isStatic?='static')? name=ValidID ':' type=JvmTypeReference;
For some reason, even though the type of the LocalVariable is set to JvmTypeReference, when using String (in an actual implementation), it will always show the error
Xtext: Couldn't resolve reference to JvmType 'String'
package com.example
Entity foo {
var bar: String
}
We already tried using a ImportedNamespaceAwareLocalScopeProvider which in getImportedNamespaceResolvers adds java.lang.* like that:
List<ImportNormalizer> implicitImports = super.getImportedNamespaceResolvers(context, ignoreCase);
List<ImportNormalizer> javaLangImports = singletonList(new ImportNormalizer(QualifiedName.create("java", "lang"), true, ignoreCase));
implicitImports.addAll(javaLangImports);
return implicitImports;
Even thought that method is called a lot of times, the imports still don't work. When inspecting the EObject context parameter, it sometimes returns java.lang.String (which I guess is for the JvmTypeReference but it still displays an error.
In the RuntimeModule the new scope provider is configured like that:
public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(MasterDSLImportedNamespaceAwareLocalScopeProvider.class);
}
In the Workflow we configured
fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}
The rest of the project is quite complex already (4 Xtext DSLs in one project and multiple generators). But except for completely different DSLs, they use almost the same workflow and RuntimeModule configuration. Another DSL also uses JvmTypeReference and also doesn't find e.g. boolean or anything else.
The question of course is: are we doing something wrong or is there something else we have to do. It used to work when we had a significantly smaller project but after some major changes suddenly this stopped working.

Resources