OWL disjoint set of elements - owl

I am trying to create an OWL Ontology which captures the idea of a disjoint set of elements:
I have a class :Parent which is all individuals that have elements that I want to ensure are disjoint.
I have a relationship :element, which connects a :Parent to every child of that parent. element(p, c) is true if p is a parent of c.
I have a relationship :disjoint which is between children. disjoint(c1, c2) is true if c1 and c2 are "disjoint". Obviously IrreflexiveProperty(:disjoint), as nothing can be disjoint with itself.
My goal is to create an ontology which is consistent iff for every p, if p ∈ Parent then every :element of p is :disjoint with every other :element of p.
The approach I've been trying is to construct a :sibling property such that sibling(x, y) ↔ (x≠y) ∧ (∃p element(p, x) ∧ element(p, y)). I was able to define a property SubObjectProperty( ObjectPropertyChain( ObjectInverseOf( :element ) :element ) :siblingOrSelf ) which captures the set of all of the siblings I want to compare against plus the object itself (plus a set of :siblingOrSelf which are not siblings nor self, but I can ignore). However, I cannot figure out how to derive a :sibling relationship which is irreflexive. (or figure out another way to accomplish my goal)
If it is convenient for the solution, I can assume InverseFunctionalProperty(:element) (i.e. no child is a :element of two different parents).

Related

How to efficiently compute disjointness with OWLAPI?

I'm profiling my application that is OWLAPI based and the only bottleneck I found was about computing disjointness.
I have to check if each class is disjoint from other classes and, if this is asserted or inferred.
It seems to be heavy to compute, because unlike for the equivalence which is based on the Node data structure (and it is efficient to retrieve data), the disjointness is based on the NodeSet in this way I'm forced to perform more loops.
This is the procedure I use:
private void computeDisjointness(OWLClass clazz) {
NodeSet<OWLClass> disjointSetsFromCls = reasoner.getDisjointClasses(clazz);
for (Node<OWLClass> singleDisjoinSet : disjointSetsFromCls) {
for (OWLClass item : singleDisjoinSet) {
for (OWLDisjointClassesAxiom disjAxiom : ontology.getAxioms(AxiomType.DISJOINT_CLASSES)) {
if(disjAxiom.containsEntityInSignature(item))
{
//asserted
}
else
{
//derived
}
}
}
}
As you can see, the bottleneck is given by the 3 for loops that slow down the application; moreover, the procedure computeDisjointness is executed for each class of the ontology.
Is there a more efficient way to get the disjointness and check if the axioms are asserted or derived?
One simple optimization is to move ontology.getAxioms(AxiomType.DISJOINT_CLASSES) to the calling method, then pass it in as a parameter. This method returns a new set on each call, with the same contents every time, since you're not modifying the ontology. So if you have N classes you are creating at least N identical sets; more if many classes are actually disjoint.
Optimization number two: check the size of the disjoint node set. Size 1 means no disjoints, so you can skip the rest of the method.
Optimization 3: keep track of the classes you've already visited. E.g., if you have
A disjointWith B
your code will be called on A and cycle over A and B, then be called on B and repeat the computation.
Keep a set of visited classes, to which you add all elements in the disjoint node set, and when it's B turn you'll be able to skip the reasoner call as well. Speaking of which, I would assume the reasoner call is actually the most expensive call in this method. Do you have profiling data that says otherwise?
Optimization 4: I'm not convinced this code reliably tells you which disjoint axioms are inferred and which ones are asserted. You could have:
A disjointWith B
B disjointWith C
The reasoner would return {A, B, C} in response to asking for disjoints of A. You would find all three elements in the signature of a disjoint axiom, and find out that the reasoner has done no inferences. But the axioms in input are not the same as the axioms in output (many reasoners would in fact run absorption on the input axioms and transform them to an internal representation that is an axiom with three operands).
So, my definition of inferred and asserted would be that the set of nodes returned by the reasoner is the same as the set of operands of one disjoint axiom. To verify this condition, I would take all disjoint axioms, extract the set of operands and keep those sets in a set of sets. Then,
for each class (and keeping in place the optimization to visit each class only once),
obtain the set of disjoint nodes (optimization here to not bother if there's only one class in the set),
transform it to a set of entities,
and check whether the set of sets created earlier contains this new set.
If yes, this is an asserted axiom; if not, it's inferred.

How do deal with combined entity types when computing the closure of a set of attributes

I'm revising for coming exams, and I am having trouble understanding an example question regarding the closure of attributes. Here is the problem:
AB→C
BE→I
E→C
CI→D
Find the closure of the set of attributes BE, explaining each step.
I've found many explanations of the method of closure when the given step is a single entity type, say 'C', using Armstrong axioms, but I don't understand how to answer for 'BE'.
First, you are confusing two very different things, attributes and entity types. Briefly, entity types are used to describe the real world entities that are modelled in a database schema. Attributes describe facts about such entities. For instance an entity type Person could have as attributes Family Name, Date of Birth, etc.
So the question is how to compute the closure of a set of attributes. You can apply the Armstrong’s axioms, trying at each step to apply one of them, until possible, but you can also simplify the computation by using the following, very simple, algorithm (and if you google "algorithm closure set attributes" you find a lot of descriptions of it):
We want to find X+, the closure of the set of attributes X.
To find it, first assign X to X+.
Then repeat the following while X+ changes:
If there is a functional dependency W → V such as W ⊆ X+ and V ⊈ X+,
unite V to X+.
So in your case, given:
AB → C
BE → I
E → C
CI → D
to compute BE+ we can procede in this way:
1. BE+ = BE
2. BE+ = BEI (because of BE → I)
3. BE+ = BEIC (because of E → C)
4. BE+ = BEICD (because of CI → D)
No other dependency can be used to modify BE+, so the algorithm terminates and the result is BCDEI. In terms of Armstrong’ axioms, the step 1 is due to Reflexivity, while the steps 2 to 4 are due to a combination of Transitivity and Augmentation.

Determining functional dependencies from an ER diagram

I have to determine the functional dependencies for the below ER:
As shown It's a one-to-many relationship. Depending on the functional dependency definition:
"X->Y means, each possible value of X can correspond to exactly one
value of Y"
, I can write:
A -> B
P -> Q,R
But I'm not sure how should the FD should be written for Ent1 and Ent1 with the relation. If I write A -> X,Pis it correct?. Can someone explain?
Thank you.
In any relationship, the combination of entity sets in many-roles determine the other entity sets and attributes in the relationship.
In your example, Ent2 (represented by P) determines Ent1 (represented by A) as well as X.
So, you would write P -> A,X.

algorithm for computing closure of a set of FDs

I'm looking for an easy to understand algorithm to compute (by hand) a closure of a set of functional dependencies.
Some sources, including my instructor says I should just play with Armstrong's axioms and see what I can get at. To me, that's not a systematic way about doing it (i.e. easy to miss something).
Our course textbook (DB systems - the complete book, 2nd ed) doesn't give an algorithm for this either.
To put it in more "systematic" fashion, this could be the algorithm you are looking for. Using the first three Armstrong's Axioms:
Closure = S
Loop
For each F in S, apply reflexivity and augmentation rules
Add the new FDs to the Closure
For each pair of FDs in S, apply the transitivity rule
Add the new Fd to Closure
Until closure doesn't change any further`
Which I took from this presentation notes. However, I found the following approach way easier to implement:
/*F is a set of FDs */
F⁺ = empty set
for each attribute set X
compute the closure X⁺ of X on F
for each attribute A in X⁺
add to F⁺ the FD: X -> A
return F⁺
which is taken from here
The set of all attributes functionally determined by α under a set F of FDs.
eg. Suppose we have these starting FDs and we want to compute all the closure using the below once.
A -> BC
AC -> D
D -> B
AB -> D
More FDs calculated by above present once
A+ -> (A,B,C,D)
B+ -> (B)
Similarly we can calculate C+, D+, (AC)+, (AB)+ and so on...
There is a very easy alg. to calculate all set of FDs though
RESULT <- α
MODIFIED <- TRUE
WHILE(MODIFIED) {
MODIFIED <- FALSE
∀ FD A->B IN F DO{
IF A ⊂ RESULT {
RESULT <- (RESULT) ∪ (B)
MODIFIED <- TRUE IF RESULT CHANGES
}
}
}
If by "play" he meant an exhaustive search, then in no way this is not-systematic ;) And a simple solution could look like iterative expansion*) of the set of dependencies on the rule-by-rule basis seems to be just a queue of items to be revisited and a few (two?) loops.. Have you tried it?
Btw. googling around I immediatelly found http://www.cs.sfu.ca/CourseCentral/354/zaiane/material/notes/Chapter6/node12.html - but I cannot verify if it is reasonable because my battery in laptop is literally going down!
*) Simply: apply them iteratively as long as anything has changed in the previous iteration. When applying ALL of them does not change anything in the current state (i.e. (A -> ABCDEF) += (ADEF) ==> (A -> ABCDEF) so no new symbol was added to the set), then it means, well, that no further expansions expand it furhter, so I think that's the point to assume the no-more-growing set to be complete.

Dependency Theory

I have:
U-> PT….. 1
Q-> SU……2
etc...
in using the reflexivity axiom can I then say
Q-> S , Q-> U
Q-> PT
I trying to ask how this axiom works using the example above.
To derive
Q->S
Q->U
from
Q->SU
I'd use the decomposition rule, not the reflexivity axiom. Then I'd apply the transitivity axiom to Q->U, U->PT to derive Q->PT.
If you're asking what the reflexivity axiom means, it means
If Y is a subset of X, then X->Y.
In your example, it looks like you might be trying to say that
SU is a subset of Q, therefore Q->S and Q->U.
But it's not given that SU is a subset of Q. To make sure you get this point, Q->SU doesn't mean SU is a subset of Q.
For example, if you're in the military, your last name and blood type (among other things) are functionally dependent on your service number. Let's let the service number attribute be represented by "S", last name by "L", and blood type by "B". Then
S->LB
But neither "last name" nor "blood type" are subsets of "service number".
On the other hand, let's imagine that you're given this to start with.
U->PT
Q->SU
Q = {SUV} (New information!)
Since Q={SUV}, {S} is a subset of {SUV}, and {U} is a subset of {SUV}, then you can apply the reflexivity axiom to derive
Q->S (or SUV->S)
Q->U (or SUV->U)
But that axiom only applies in this example because you're given Q={SUV}.

Resources