Inference in protége - semantic-web

I'm building an ontology to find peoples' skills. I want to infer that when a person A passed a course B and course B provides skill C, then person A has skill C. Is there a way to do this in Protégé?

Sure, you're saying that when you have:
A →passed B →providesSkill C
you want to infer that
A →hasSkill C
You can do that with the subproperty chain axiom:
passed • providesSkill ⊑ hasSkill
For a more detailed example of how to add these in Protege, see the (not quite a duplicate) question: Adding statements of knowledge to an OWL Ontology in Protege).

Related

Protege 5.0 - OWL : How can I link the sameAs individual property with some other properties?

I am new to ontology design, and I have a project that requires me to match some individuals if they point to the same values for some of their properties.
I've posted some screenshots with the classes, object properties, data properties and individuals here:
https://imgur.com/a/Ak4og
A more "in detail" explanation(CAN ALSO BE DEDUCED FROM THE PICS): I have the class Person, who has a subclass Expert. There are also class FieldOfPractice(subclasses: computer_science, engineering, public_administration, etc.), Expertise(very_low,low,moderate,high,very_high) and Certification(A,B,C,D), Book and Expertise_Community classes.
I have as data properties firstName, lastName, dateAdded, bookName, communityName.
Each Person (so also Expert) has to have hasCertification, hasExpertise, hasFieldOfPractice properties which will all have the obvious range.
The Expert has to have recommendedBooks() and isInExpertCommunity properties.
The requirement: Create some Individuals of type Person, Expert, Book,etc. Make an "inference algorithm" such that for each person who has the same certification, expertise and field of practice as any of the experts, recommendedBooks() and isInExpertCommunity properties are inferred from the corresponding Expert Individuals to the Person Individual.
So for example lets say that: We have an individual Person: Mr.A , who has as object properties hasFieldOfPractice() computer_science, hasCertification() B, hasExpertise() very_low.
We also have an individual Expert: Expert5 with the same values for hasFieldOfPractice(), hasCertification() and hasExpertise() as Mr.A. Expert5 has as recommendedBooks() book1, book6 and for isInExpertiseCommunity() community4.
The "inference algorithm" should infer to Mr.A the recoomendedBooks() book1, book6 and isInExpertiseCommunity() community4. It should also do this if Mr.A matches with another expert who points at different books for reccomendedBooks() and/or another expertise community.
I have also found some similar questions but haven't been able to link the answers properly to my problem:
How to infer isBrotherOf property between two individuals - very good answers, but I need to change the SameAs() property instead of hasBrother() from the question.
Using Property Chains to get inferred Knowledge in an OWL Ontology(Protege) - same problem, but here my SameAs() which I think its predefined, corresponds with the example's employs().
From what I've seen I have to link somehow the sameAs() -> property chain -> rollification concepts, but I don't really get it yet.

Which objects own the method? Translating from discrete math

So, suppose I'm working in the world of discrete mathematics and I have some function
f: A x B x C -> D.
With this function I can make computations like f(a,b,c) = d. (I'm being vague here on purpose).
Now suppose I want to implement this computation explicitly in some modern OO programming language. So I initialize a variable called a of class ClassA and so on with b and c. Then what? Which object should own the computation? Or could it be an initializer. Could it be a static function?
I could have:
d = a.f_1(b,c),
d = b.f_2(a,c),
d = c.f_3(a,b),
d = new ObjD(a,b,c),
d = ZStatic.f_4(a,b,c)
all as plausible options, couldn't I?
Given the situation, should symmetry demand I implement all of these options?
I'd prefer to avoid the constructor approach completely, but beyond that I don't know what progress could be made other than the assumption of essentially arbitrary information.
So, what object should own the function $f$, if any?
To give the best answer, it is important to know what kind of variables you use.
A very important metric in oop is to achieve high cohesion. Cohesion is the degree to which the elements of a module belong together. If your variables a,b and c belong together in a specific context, then it should be the best solution to put them in exactly one class. And if they are in one class you should not worry about, which class should own the computation (your fourth solution).
Your last suggestion, to use a static function is also conceivable. This approach is often used in mathematic librarys in different kind of languages (e.g. Java: Math class)

Owl universal quantification works together with cardinality restrictions

I am new to owl. I read an Universal Quantification example in this page http://dior.ics.muni.cz/~makub/owl/ .
If I replace "Person SubClassOf hasParent max 2 thing" by "Person SubClassOf hasParent max 2 Person" and run the reasoner, I think individual Ivan would fall into the class Czech too. But actually it's not. I test it in Protege 4.3 and run the built-in reasoner FaCT++.
What details did I miss?
The problem here that your new restriction is too permissive. Your new axiom actually say that Person can have at most 2 (parents that are Person). It doesn't prevent Person from having other parents, that are non-Person.
The example will work again if you enforce all parents to be of a class Person, e.g by setting Range of hasParent to Person, or adding an axiom Person SubClassOf hasParent only Person

Make every value of one property less than every value of another property?

I just started learning OWL using Protégé 4.3, and now I am facing a difficult problem. I have defined a class A with some restriction superclasses that ensure that each A has a property value from P1 and P2, and each P1 and P2 have a value that is a double:
A ⊑ ∃hasProperty.(P1 ⊓
∃hasValue.xsd:double)
A ⊑ ∃hasProperty.(P2
⊓ ∃hasValue.xsd:double)
How can I assert that P1 values of an A are all less than all the P2 values?
You can't do this with OWL Axioms
This is an interesting problem, but it's one that you can't solve using pure OWL axioms, unfortunately. Generally, it's easy to say something about the values that individuals of class have, by using restriction superclasses, but it's hard or impossible to say something about the relationship between values of properties. E.g., you can't say that the family name property of a person must be the same as the value of the surname property.
It's important to clear up a bit of terminology, first, though, particularly the term restriction in:
I want to define a restriction,for all Individuals of A,value of p1 is
always less than value of p2
A restriction is a class. E.g., the restriction likes some Person is the class of individuals each of which likes some Person. We often use restrictions as superclasses of other classes to ensure that certain constraints hold. E.g., when we say that
Person subClassOf hasName some xsd:string
we're saying that every person has a value for the property hasName that is an xsd:string.
You probably can do this with SWRL
You could assert that if something is a member of A and has p1 and p2 values, then p1 must be less than p2. This would look like:
A(?a) ∧
hasProperty(?a,?p1) ∧ P1(?p1) ∧ hasValue(?p1,?v1) ∧
hasProperty(?a,?p2) ∧ P2(?p2) ∧ hasValue(?p2,?v2)
→
swrlb:lessThan(?v1,?v2)
This will ensure that every P1 value on an A is less than every P2 value on the A. If you ever assert some data that violates this, then there will be an inconsistency.

OO design: Copying data from class A to B

Having the SOLID principles and testability in mind, consider the following case:
You have class A and class B which have some overlapping properties. You want a method that copies and/or converts the common properties from class A to class B. Where does that method go?
Class A as a B GetAsB() ?
Class B as a constructor B(A input)?
Class B as a method void FillWithDataFrom(A input)?
Class C as a static method B ConvertAtoB(A source)?
???
It depends, all make sense in different circumstances; some examples from Java:
String java.lang.StringBuilder.toString()
java.lang.StringBuilder(String source)
void java.util.GregorianCalender.setTime(Date time)
ArrayList<T> java.util.Collections.list(Enumeration<T> e)
Some questions to help you decide:
Which dependency makes more sense? A dependent on B, B dependent on A, neither?
Do you always create a new B from an A, or do you need to fill existing Bs using As?
Are there other classes with similar collaborations, either as data providers for Bs or as targets for As data?
I'd rule out 1. because getter methods should be avoided (tell, don't ask principle).
I'd rule out 2. because it looks like a conversion, and this is not a conversion if A and B are different classes which happens to have something in common. At least, this is what it seems from the description. If that's not the case, 2 would be an option too IMHO.
Does 4. implies that C is aware of inner details of B and/or C? If so, I'd rule out this option too.
I'd vote for 3. then.
Whether this is correct OOP theory or not is up for debate, but depending upon the circumstances, I wouldn't rule C out quite so quickly. While ti DOES create a rather large dependency, it can have it's uses if the specific role of C is to manage the interaction (and copying) from A to B. The dependency is created in C specifically to avoid creating such dependency beteween A and B. Further, C exists specifically to manage the dependency, and can be implemented with that in mind.
Ex. (in vb.Net/Pseudocode):
Public Class C
Public Shared Function BClassFactory(ByVal MyA As A) As B
Dim NewB As New B
With B
.CommonProperty1 = A.CommonProperty1
.CommonProperty2 = A.CommonProperty2
End With
Return B
End Function
End Class
If there is a concrete reason to create, say, a AtoBConverterClass, this approach might be valid.
Again, this might be a specialized case. However I have found it useful on occasion. Especially if there are REALLY IMPORTANT reasons to keep A and B ignorant of eachother.