diff --git a/projects/project-1/assignment/TimCAssignment1.md b/projects/project-1/assignment/TimCAssignment1.md new file mode 100644 index 0000000..5531b0e --- /dev/null +++ b/projects/project-1/assignment/TimCAssignment1.md @@ -0,0 +1,363 @@ +# Tim C Project 1: OWL Cheat Sheet + +Collaborative attempt by J Bittner, Tim Coleman, and Mathilde Miroir + +The goal of this project is to complete OWL documentation concerning logical combinations of role constraints over object properties. It includes two sub-assignments: (1) Providing OWL 2 direct semantics-based explanations for unsatisfiability and inconsistency results stemming from role constraint pairs; (2) Providing OWL 2 direct semantics-based explanations for results stemming from role constraint combinations under the owl:subPropertyOf relationship. + +I will remind you that my goal in this exercise is to produce a publishable paper on this topic by the end of the project; I aim to include anyone on the paper as an author who completes the project. The content of this paper will be a great benefit to the ontology engineering community, so it is important to have this work presented to the broader public sooner rather than later. + +## Assignment Part 1 + +### OWL2 DL Direct Semantics Role Constraints + +[OWL2 DL Direct Semantics](https://www.w3.org/TR/owl2-direct-semantics/) allows for constraints on object properties of the following sort, where `R` is an arbitrary object property: + +| **Constraint** | **Definition** | **Example** | +|------------------------|------------------------------------------------------------|-------------| +| **Functional** | If xRy and xRz, then y=z | If x *has birthdate* y and x *has birthdate* z, then y=z. | +| **Inverse Functional** | If xRy and zRy, then x=z | If x *has social security number* y and z *has social security number* y, then x=z. | +| **Transitive** | If xRy and yRz, then xRz | If x *is contained in* y and y *is contained in* z, then x *is contained in* z. | +| **Symmetric** | If xRy, then yRx | If x *is a friend of* y, then y *is a friend of* x. | +| **Asymmetric** | If xRy, then it is not the case that yRx | If x *is the parent of* y, then it is not the case that y *is the parent of* x. | +| **Reflexive** | xRx | x *is as tall as* itself. | +| **Irreflexive** | It is not the case that xRx | No x *is taller than* itself. | + +### Role Constraint Combinations + +These role constraints may be combined in some cases, but not others. The following table illustrates when combinations of two role constraints are permitted and when they are not. If they are not permitted, then it is either because the combination is unsatisfiable (**XUNSAT**) or because the combination creates an object property chain (**XNS**) that may lead to undecidability. The table was validated using the OWL2 reasoners Fact++, Pellet, and HermiT: + +| | Funct. | iFunct. | Trans. | Symm. | Asymm. | Ref. | Irref. | +|--------|--------|---------|--------|-------|--------|------|--------| +| **Funct.** | - | OK | XNS | OK | OK | OK | OK | +| **iFunct.** | OK | - | XNS | OK | OK | OK | OK | +| **Trans.** | XNS | XNS | - | OK | XNS | OK | XNS | +| **Symm.** | OK | OK | OK | - | XUNSAT | OK | OK | +| **Asymm.** | OK | OK | XNS | XUNSAT| - | XUNSAT| OK | +| **Ref.** | OK | OK | OK | OK | XUNSAT | - | XUNSAT | +| **Irref.** | OK | OK | XNS | OK | OK | XUNSAT| - | + +For example, asserting `R` is both asymmetric and symmetric will result in an unsatisfiable combination, since such a combination is straightforwardly inconsistent. +Similarly, given an object property `R`, it is possible to assert that `R` is both Functional and Inverse Functional. However, asserting `R` is both Inverse Functional and Transitive will result in an object property chain that may lead to undecidability. + +Some heuristics emerging from the table: +- Transitivity can only be combined usefully with symmetry or reflexivity. +- Asymmetry can only be combined usefully with functionality, inverse functionality, and irreflexivity. +- Reflexivity cannot be combined usefully with asymmetry. +- Irreflexivity cannot be combined usefully with transitivity. + +### Assignment Part 1 Details + +Leveraring the [OWL2 DL Direct Semantics](https://www.w3.org/TR/owl2-direct-semantics/), please provide explanations for each XNS and XNS result in the table. + +For example, to explain why `R` cannot be both asymmetric and symmetric, your explanation may take the form: +- Suppose `R` is both symmetric and asymmetric. Then by symmetry for any x and y, if x`R`y it follows that y`R`x. However, by asymmetry it also follows that it is not the case that y`R`x. Hence, `R` cannot be both symmetric and asymmetric. +Similarly, to explain why `R` cannot be both transitive and inverse functional. + +**(1) Functional and Transitive (XNS)** + +Suppose `R` is both functional and transitive. +Because `R` is functional, if x`R`y and x`R`z, then y = z. +Because `R` is transitive, if x`R`y and y`R`z, then x`R`z. +Since `R` is functional, x relates to only one y. However, if `R` is also transitive, this creates a scenario where x relates to both y and z, violating the functional rule. Therefore, `R` cannot be both functional and transitive. + +**(2) Inverse Functional and Transitive (XNS)** + +Suppose `R` is both inverse functional and transitive. +Because `R` is inverse functional, if x`R`y and z`R`y, then x = z. +Because `R` is transitive, if x`R`y and y`R`z, then x`R`z. +Since `R` is inverse functional, z should relate to only one y. However, if `R` is also transitive, z could relate to x, creating a scenario where z relates to both x and y, violating the inverse functional rule. Therefore, `R` cannot be both inverse functional and transitive. + +**(3) Transitive and Asymmetric (XNS)** + +Suppose `R` is both transitive and asymmetric. +Because `R` is transitive, if x`R`y and y`R`z, then x`R`z. +Because `R` is asymmetric, if x`R`y, then it is not the case that yRx. +By transitivity, x`R`z. However, if z`R`x were to occur, asymmetry would be violated, as z cannot relate back to x. Therefore, `R` cannot be both transitive and asymmetric. + +**(4) Transitive and Irreflexive (XNS)** + +Suppose `R` is both transitive and irreflexive. +Because `R` is transitive, if x`R`y and y`R`z, then x`R`z. +Because `R` is irreflexive, it is not the case that x`R`x for any x. +In transitivity, x`R`y and y`R`x implies x`R`x, which directly violates irreflexivity since xRx cannot hold for any x. Therefore, `R` cannot be both transitive and irreflexive. + +**(5) Symmetric and Asymmetric (XUNSAT)** + +Suppose `R` is both symmetric and asymmetric. +Because `R` is symmetric, if x`R`y, then y`R`x. +Because `R` is asymmetric, if x`R`y, then it is not the case that y`R`x. +Symmetry and asymmetry are in direct conflict because symmetry requires y`R`x whenever x`R`y, while asymmetry forbids y`R`x if x`R`y. Therefore, `R` cannot be both symmetric and asymmetric. + +**(6) Asymmetric and Reflexive (XUNSAT)** + +Suppose `R` is both asymmetric and reflexive. +Because `R` is asymmetric, if x`R`y, then it is not the case that yRx. +Because `R` is reflexive, x`R`x for every x. +Since reflexivity requires every element to relate to itself (x`R`x), and asymmetry prohibits x`R`x, `R` cannot be both asymmetric and reflexive. + +**(7) Reflexive and Irreflexive (XUNSAT)** + +Suppose `R` is both reflexive and irreflexive. +Because `R` is reflexive, x`R`x for every x. +Because `R` is irreflexive, it is not the case that x`R`x for any x. +These definitions are in direct conflict since it’s impossible for x`R`x to be both true and false at the same time. Therefore, `R` cannot be both reflexive and irreflexive. + +## Assignment Part 2 + +### Variable Constraints + +- `B` owl:subPropertyOf of `A` +- `Bi` owl:subPropertyOf of `Ai` +- `Ai` is the inverse of `A` +- `Bi` is the inverse of `B` + +### Table III. (A) Transitive and Irreflexive Trials +| | A Trans | B Trans | Ai Trans | Bi Trans | +|------------|---------|---------|----------|----------| +| **A Irr** | N1 | N2 | N3 | N4 | +| **B Irr** | Y5 | N6 | Y7 | N8 | +| **Ai Irr** | N9 | N10| N11 | N12 | +| **Bi Irr** | Y13| N14| Y15 | N16 | + +*_N denotes an error while Y denotes a successful run_ + +**_Subscripts denote corresponding explantion below_ + +### Table IV. (B) Transitive and Functional Trials + +| | A Trans | B Trans | Ai Trans | Bi Trans | +|-------------|---------|---------|----------|----------| +| **A Func** | N1 | N2 | N3 | N4 | +| **B Func** | N5 | N6 | N7 | N8 | +| **Ai Func** | Y9 | Y10| N11 | N12 | +| **Bi Func** | Y13| Y14| N15 | N16 | + +*_N denotes an error while Y denotes a successful run_ + +**_Subscripts denote corresponding explantion below_ + + +### Table V. (C) Transivitive vs Inverse Functional + +| | A Trans | B Trans | Ai Trans | Bi Trans | +|--------------|---------|---------|----------|----------| +| **A iFunc** | N1 | N2 | Y3 | N4 | +| **B iFunc** | N5 | N6 | Y7 | Y8 | +| **Ai iFunc** | Y9 | Y10| N11 | N12 | +| **Bi iFUnc** | Y13| Y14| N15 | N16 | + +*_N denotes an error while Y denotes a successful run_ + +**_Subscripts denote corresponding explantion below_ + +### Table VI. (D) Transitive and Asymmetric Trials (Tim's HW) + +| | A Trans | B Trans | Ai Trans | Bi Trans | +|------------|---------|---------|----------|----------| +| **A Asym** | N1 | N2 | N3 | N4 | +| **B Asym** | N5 | N6 | N7 | N8 | +| **Ai Asym**| Y9 | Y10| N11 | N12 | +| **Bi Asym**| Y13| Y14| N15 | N16 | + +*_N denotes an error while Y denotes a successful run_ + +**_Subscripts denote corresponding explantion below_ + + +### Explanations + +#### (A) Transitive and Irreflexive Explanations +- (A-1) Suppose `A` is both irreflexive and transitive. Because `A` is irreflexive, it is not the case for any `x` that `` is in `A`. Because `A` is transitive, if `` and ``, then ``. +- This creates a conflict because the irreflexive property of `A` forbids any element from relating to itself (``), but transitivity could imply this relation when applied across a chain of relationships, which violates the irreflexive property. This contradiction makes it incompatible for OWL reasoners. + +- (A-2) Suppose `A` is irreflexive and `B` is transitive. Because `A` is irreflexive, it is not the case for any `x` that `` is in `A`. Because `B` is transitive, if `` and ``, then ``. +- This creates a conflict because `B` transitivity implies connections between multiple elements that may lead to reflexive relationships (``), which violates the irreflexivity of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (A-3) Suppose `A` is irreflexive and its inverse, `Ai`, is transitive. Because `A` is irreflexive, it is not the case for any `x` that `` is in `A`. Because `Ai` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Ai` can suggest reflexive connections, whereas `A` irreflexivity prevents reflexive relations (``), leading to a violation of the irreflexive property of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (A-4) Suppose `A` is irreflexive and `Bi` is transitive. Because `A` is irreflexive, it is not the case for any `x` that `` is in `A`. Because `Bi` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Bi` can lead to reflexive relationships across chains of elements, violating the irreflexivity condition of `A` that prevents ``. This contradiction makes it incompatible for OWL reasoners. + +- (A-5) Suppose `B` is irreflexive and `A` is transitive. Because `B` is irreflexive, it is not the case for any `x` that `` is in `B`. Because `A` is transitive, if `` and ``, then ``. +- This creates a conflict because `A`'s transitivity can result in reflexive connections between elements, which directly violates the irreflexivity requirement of `B`. This contradiction makes it incompatible for OWL reasoners. + +- (A-6) Suppose `B` is both irreflexive and transitive. Because `B` is irreflexive, it is not the case for any `x` that `` is in `B`. Because `B` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `B` allows multiple relationships that could imply reflexive relationships (``), directly contradicting the irreflexive constraint of `B`. This contradiction makes it incompatible for OWL reasoners. + +- (A-7) Suppose `B` is irreflexive and `Ai` is transitive. Because `B` is irreflexive, it is not the case for any `x` that `` is in `B`. Because `Ai` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Ai` could create reflexive relationships, which would violate the irreflexive property of `B`. This contradiction makes it incompatible for OWL reasoners. + +- (A-8) Suppose `B` is irreflexive and its inverse, `Bi`, is transitive. Because `B` is irreflexive, it is not the case for any `x` that `` is in `B`. Because `Bi` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Bi` can imply reflexive connections, which violates the irreflexive property of `B`. This contradiction makes it incompatible for OWL reasoners. + +- (A-9) Suppose `Ai` is irreflexive and its inverse, `A`, is transitive. Because `Ai` is irreflexive, it is not the case for any `x` that `` is in `Ai`. Because `A` is transitive, if `` and ``, then ``. +- This does not create a conflict because transitivity in `A` is compatible with the irreflexivity of `Ai`, allowing both properties to coexist without contradiction. + +- (A-10) Suppose `Ai` is irreflexive and `B` is transitive. Because `Ai` is irreflexive, it is not the case for any `x` that `` is in `Ai`. Because `B` is transitive, if `` and ``, then ``. +- This does not create a conflict because the transitivity of `B` and the irreflexivity of `Ai` can work together without violation of constraints. + +- (A-11) Suppose `Ai` is both irreflexive and transitive. Because `Ai` is irreflexive, it is not the case for any `x` that `` is in `Ai`. Because `Ai` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Ai` implies connections that can lead to reflexive relationships (``), which violates the irreflexive property of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (A-12) Suppose `Ai` is irreflexive and `Bi` is transitive. Because `Ai` is irreflexive, it is not the case for any `x` that `` is in `Ai`. Because `Bi` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Bi` can imply reflexive connections, which violates the irreflexivity condition of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (A-13) Suppose `Bi` is irreflexive and `A` is transitive. Because `Bi` is irreflexive, it is not the case for any `x` that `` is in `Bi`. Because `A` is transitive, if `` and ``, then ``. +- This does not create a conflict because the transitivity of `A` and the irreflexivity of `Bi` can work together without violation of constraints. + +- (A-14) Suppose `Bi` is irreflexive and its inverse, `B`, is transitive. Because `Bi` is irreflexive, it is not the case for any `x` that `` is in `Bi`. Because `B` is transitive, if `` and ``, then ``. +- This does not create a conflict because the transitivity of `B` and the irreflexivity of `Bi` can coexist without contradiction. + +- (A-15) Suppose `Bi` is irreflexive and `Ai` is transitive. Because `Bi` is irreflexive, it is not the case for any `x` that `` is in `Bi`. Because `Ai` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Ai` implies reflexive relationships, which would violate the irreflexive property of `Bi`. This contradiction makes it incompatible for OWL reasoners. + +- (A-16) Suppose `Bi` is both irreflexive and transitive. Because `Bi` is irreflexive, it is not the case for any `x` that `` is in `Bi`. Because `Bi` is transitive, if `` and ``, then ``. +- This creates a conflict because transitivity in `Bi` could lead to reflexive connections, which directly violates the irreflexive property of `Bi`. This contradiction makes it incompatible for OWL reasoners. + + +#### (B) Transitive and Functional + +- (B-1) Suppose `A` is both transitive and functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity allows x to relate to multiple elements, but functionality restricts x to relating to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-2) Suppose `A` is transitive and `B` is functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because `B` (a subclass of `A`) allows x to relate to both y and z through transitivity, but `B` restricts the relation to one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-3) Suppose `A` is transitive and its inverse, `Ai`, is functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `A` allows multiple connections, but `Ai` functionality restricts x to only one y. This contradiction makes it incompatible for OWL reasoners. + +- (B-4) Suppose `A` is transitive and `Bi` is functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because `A` transitivity allows multiple connections, while `Bi` functionality restricts the relation to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-5) Suppose `B` is transitive and `A` is functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because `B` transitivity allows for multiple connections through intermediaries, while `A` restricts the relation to one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-6) Suppose `B` is both transitive and functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity allows x to relate to multiple elements, while functionality restricts x to one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-7) Suppose `B` is transitive and `Ai` is functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `B` allows multiple connections, but `Ai` functionality restricts the relation to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-8) Suppose `B` is transitive and its inverse, `Bi`, is functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because `B` transitivity allows multiple connections, while `Bi` functionality restricts x to relate to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-9) Suppose `Ai` is transitive and its inverse, `A`, is functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and functionality are aligned, and the restrictions on relationships are respected. + +- (B-10) Suppose `Ai` is transitive and `B` is functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and functionality are aligned, and the restrictions on relationships are respected. + +- (B-11) Suppose `Ai` is both transitive and functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity allows for multiple connections between elements, while functionality restricts x to relate to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-12) Suppose `Ai` is transitive and `Bi` is functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because `Ai` transitivity allows multiple connections between elements, while `Bi` functionality restricts x to relate to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-13) Suppose `Bi` is transitive and `A` is functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because the transitivity of `Bi` and the functionality of `A` are aligned, allowing both properties to coexist. + +- (B-14) Suppose `Bi` is transitive and its inverse, `B`, is functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because the transitivity of `Bi` and the functionality of `B` operate together without violation of constraints. + +#### (C) Transitive and Inverse Functional + +- (A-1) Suppose `A` is transitive and its inverse, `A`, is inverse functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity allows x to relate to multiple elements, but inverse functionality restricts x to relating to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (B-2) Suppose `B` is transitive and its inverse, `A`, is inverse functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `B` allows x to relate to both y and z, but `A` inverse functional restricts the relation to one element. This contradiction makes it incompatible for OWL reasoners. + +- (Ai-3) Suppose `Ai` is transitive and its inverse, `A`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Ai-4) Suppose `Ai` is transitive and its inverse, `A`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `Ai` creates multiple connections through intermediaries, but `A` inverse functional restricts x to relate to only one element. This contradiction makes it incompatible for OWL reasoners. + +- (A-5) Suppose `A` is transitive and its inverse, `B`, is inverse functional. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `A` allows multiple connections through intermediaries, but `B` inverse functional restricts y to only one relationship. This contradiction makes it incompatible for OWL reasoners. + +- (B-6) Suppose `B` is transitive and its inverse, `B`, is inverse functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `B` allows multiple relationships between x, y, and z, while `B` inverse functional restricts x to only one relation. This contradiction makes it incompatible for OWL reasoners. + +- (Ai-7) Suppose `Ai` is transitive and its inverse, `B`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (B-8) Suppose `B` is transitive and its inverse, `Bi`, is inverse functional. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Ai-9) Suppose `Ai` is transitive and its inverse, `A`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Bi-10) Suppose `Bi` is transitive and its inverse, `A`, is inverse functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Ai-11) Suppose `Ai` is transitive and its inverse, `Ai`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `Ai` allows multiple connections through intermediaries, while `Ai` inverse functionality restricts these relationships. This contradiction makes it incompatible for OWL reasoners. + +- (Ai-12) Suppose `Ai` is transitive and its inverse, `Bi`, is inverse functional. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `Ai` allows x to relate to multiple elements through intermediaries, whereas `Bi` inverse functional restricts relationships to one element. This contradiction makes it incompatible for OWL reasoners. + +- (Bi-13) Suppose `Bi` is transitive and its inverse, `A`, is inverse functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Bi-14) Suppose `Bi` is transitive and its inverse, `B`, is inverse functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is inverse functional, if x`R`y and x`R`z, then y=z. +- This scenario does not create a conflict because transitivity and inverse functionality are aligned, allowing both properties to coexist. + +- (Bi-15) Suppose `Bi` is transitive and its inverse, `Ai`, is inverse functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `Bi` allows multiple relationships, while `Ai` inverse functional restricts each y to only one relationship with x. This contradiction makes it incompatible for OWL reasoners. + +- (Bi-16) Suppose `Bi` is transitive and its inverse, `Bi`, is inverse functional. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is inverse functional, if x`R`y and x`R`z, then y=z. +- This creates a conflict because transitivity in `Bi` allows multiple connections between elements, whereas `Bi` inverse functionality restricts relationships to only one connection. This contradiction makes it incompatible for OWL reasoners. + + + +#### (D) Transitive and Asymmetric + +- (D-1) Suppose `A` is both transitive and asymmetric. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `A` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `A` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (D-2) Suppose `A` is transitive and `B` is asymmetric. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `B` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold. However, asymmetry can’t hold because asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. + +- (D-3) Suppose `A` is transitive and its inverse, `Ai`, is asymmetric. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `Ai` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `A` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (D-4) Suppose `A` is transitive and `Bi` is asymmetric. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `Bi` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. Since `xRy`, then `yRx` cannot hold because asymmetry prevents reciprocal relations. This contradiction makes it incompatible for OWL reasoners. + +- (D-5) Suppose `B` is transitive and `A` is asymmetric. Because `A` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `A` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `B` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (D-6) Suppose `B` is both transitive and asymmetric. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `B` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. + +- (D-7) Suppose `B` is transitive and `Ai` is asymmetric. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `Ai` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `B` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (D-8) Suppose `B` is transitive and its inverse, `Bi`, is asymmetric. Because `B` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `Bi` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. + +- (D-9) Suppose `Ai` is transitive and its inverse, `A`, is asymmetric. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `A` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `Ai` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (D-10) Suppose `Ai` is transitive and `B` is asymmetric. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `B` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. + +- (D-11) Suppose `Ai` is both transitive and asymmetric. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `Ai` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `Ai` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (D-12) Suppose `Ai` is transitive and `Bi` is asymmetric. Because `Ai` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict since `Bi` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. + +- (D-13) Suppose `Bi` is transitive and `A` is asymmetric. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `A` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `A` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `Bi` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `A`. This contradiction makes it incompatible for OWL reasoners. + +- (D-14) Suppose `Bi` is transitive and its inverse, `B`, is asymmetric. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `B` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `B` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `Bi` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `B`. This contradiction makes it incompatible for OWL reasoners. + +- (D-15) Suppose `Bi` is transitive and `Ai` is asymmetric. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Ai` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `Ai` is asymmetric, meaning if `xRy`, then `yRx` must not hold. Since `Bi` is transitive, this implies that `x` could relate to multiple elements, which violates the asymmetric constraint of `Ai`. This contradiction makes it incompatible for OWL reasoners. + +- (D-16) Suppose `Bi` is both transitive and asymmetric. Because `Bi` is transitive, if x`R`y and y`R`z, then x`R`z. Because `Bi` is asymmetric, if xRy, then it is not the case that yRx. +- This creates a conflict because `Bi` is transitive; because in transitivity, if `xRy` and `yRz`, then `xRz` must hold, but asymmetry can’t hold as asymmetry prevents the case that `yRx`. This contradiction makes it incompatible for OWL reasoners. diff --git a/projects/project-2/assignment/Tim sparql-library.md b/projects/project-2/assignment/Tim sparql-library.md new file mode 100644 index 0000000..93bec05 --- /dev/null +++ b/projects/project-2/assignment/Tim sparql-library.md @@ -0,0 +1,390 @@ +**The SPARQL Library of Common Core Ontologies** + +The goal of this project is to develop a suite of SPARQL queries that will serve as quality control (QC) checks against the [Common Core Ontologies](https://github.com/CommonCoreOntology/CommonCoreOntologies) suite. These queries will be designed to identify and flag potential issues, ensuring the ontology's integrity, consistency, and adherence to predefined standards. + +**Assignment Details** + +Your task is to construct SPARQL queries to be included in the [CCO QC workflow](https://github.com/CommonCoreOntology/CommonCoreOntologies/actions). Ideally, your queries will be added to the CCO repository [here](https://github.com/CommonCoreOntology/CommonCoreOntologies/tree/develop/.github/deployment/sparql). + +Your queries will be ranked in terms of difficulty. The lowest - 8 - indicates a rather easy query, while the highest - 1 - will indicate a very sophisticated query. + +For our purposes, the more sophisticated queries will be worth more points than less sophisticated, and you are required to submit enough queries to acquire 100 points according to the following point system: + + + | **Query Sophistication** | **Points** | + | ------------------------ | ---------- | + | 1 | 35 | + | 2 | 25 | + | 3 | 20 | + | 4 | 10 | + | 5 | 5 | + | 6 | 3 | + | 7 | 2 | + | 8 | 0 | + +You're probably thinking, "why would I submit a level 8 if they're not worth any points?" Great question. Because everyone has to submit at least one level 8. Otherwise, you're permitted to submit in any distribution you choose. For example, you might submit 2 queries for level one (70 points), one for level 3 (20 points), one for 4 (10 points), and one for kata 8 (0 points but required). + +It is your responsibility and the responsibility of your peers reviewing your submission in PR to determine whether your submission is ranked appropriately. In the event that consensus is reached that your query is ranked inappropriately, you must work with your peers to revise the submission so that it is either more or less challenging, accordingly. You are not permitted to submit new queries with different strengths after PRs are open, but must instead revise your PRs. So, think hard about how challenging your submission is. + +**Template** + +The SPARQL queries should have the template: +Title + (descriptive title of the query) +Constraint Description: + (description of the query functionality) +Severity: + (select "Warning" or "Error") + +Your query should end with a BIND clause and an associated ?error in the SELECT. For example: + + - BIND (concat("WARNING: The following ontology elements have the same rdfs:label ", str(?element), " and ", str(?element2)) AS ?error) + +**Guidance** + +A few tips for developing effective SPARQL queries for the Common Core Ontologies (CCO): + - Review the [existing SPARQL queries](https://github.com/CommonCoreOntology/CommonCoreOntologies/tree/develop/.github/deployment/sparql) so as not to duplicate work + - Review [documentation and design patterns](https://github.com/CommonCoreOntology/CommonCoreOntologies/tree/develop/documentation) to understand stucture of CCO + - Understand common issues in ontologies; [explore the OOPS!](https://oa.upm.es/35873/1/INVE_MEM_2014_192872.pdf) list here for inspiration + - Observe annotation conventions, e.g. use of labels, comments, etc. must be present and accurate + +When creating queries, start with simple quality control checks and build complexity through practice. Feel free to leverage generative AI for this project. Also, feel free to collaborate with peers. + +Be sure to test your queries. You may do this in Protege or in the [SPARQL playground](https://atomgraph.github.io/SPARQL-Playground/). + +**Title: SPARQL Query to Identify Acronyms** + +Constraint Description: This SPARQL query is designed to identify terms in an ontology (either classes or properties) that have labels resembling acronyms. + +Severity: Warning + +Level: 4 + +```sparql +PREFIX rdfs: +PREFIX owl: + +SELECT ?term ?label ?warning +WHERE { + # Extract all terms (classes and properties) with labels + { + ?term a owl:Class . + } + UNION + { + ?term a owl:ObjectProperty . + } + UNION + { + ?term a owl:DatatypeProperty . + } + + # Get the label of the term + ?term rdfs:label ?label . + + # Check for labels that look like acronyms (upper case and short) + FILTER( + REGEX(?label, "^[A-Z0-9-\\.]{2,6}$", "i") + ) + + # Bind a warning message if the label matches the regex + BIND (concat("WARNING: The term ", str(?term), " has a label that looks like an acronym: ", ?label) AS ?warning) +} +``` +**Title: Axiom Type and Anonymous Class** + +Constraint Description: (Principle of Single Inheritance) SPARQL query to check an ontology for the use of subclass or equivalent class axioms whereby a class is defined to be a subclass or equivalent class of an anonymous class + +Severity: Warning + +Level: 5 + +```sparql +PREFIX rdfs: +PREFIX owl: + +SELECT ?class ?axiomType ?anonymousClass ?warning +WHERE { + { + # Subclass axiom where the superclass is anonymous (blank node) + ?class rdfs:subClassOf ?anonymousClass . + FILTER(isBlank(?anonymousClass)) # Check if the superclass is anonymous + BIND("subClassOf" AS ?axiomType) + } + UNION + { + # Equivalent class axiom where the equivalent class is anonymous (blank node) + ?class owl:equivalentClass ?anonymousClass . + FILTER(isBlank(?anonymousClass)) # Check if the equivalent class is anonymous + BIND("equivalentClass" AS ?axiomType) + } + + # Bind a warning message when an anonymous class is found + BIND(concat("WARNING: The class ", str(?class), " has an anonymous ", ?axiomType, " axiom.") AS ?warning) +} +``` + +**Title: Reused Term, Axiom type and Axiom Detail** + +Constraint Description: (Preservation of Meaning of Higher-Level Ontology Terms) SPARQL query that checks whether an ontology reuses a term from a higher-level ontology and adds new content to it through the addition of an axiom. + +Severity: Error. + +Level: 2 + +```sparql +PREFIX rdfs: +PREFIX owl: + +SELECT DISTINCT ?reusedTerm ?axiomType ?axiomDetail ?error +WHERE { + # 1. Identify terms that are reused from another ontology (by detecting external namespaces) + ?reusedTerm a owl:Class . + FILTER(STRSTARTS(STR(?reusedTerm), "http://higher-level-ontology-namespace.org/")) # Replace with actual namespace + + # 2. Check if the reused term is extended in the current ontology with a subclass axiom + { + ?reusedTerm rdfs:subClassOf ?axiomDetail . + BIND("subClassOf" AS ?axiomType) + } + UNION + # 3. Check if the reused term is extended with an equivalent class axiom + { + ?reusedTerm owl:equivalentClass ?axiomDetail . + BIND("equivalentClass" AS ?axiomType) + } + UNION + # 4. Check if additional restrictions are added to the reused term + { + ?reusedTerm rdfs:subClassOf [ owl:onProperty ?property ; owl:someValuesFrom ?axiomDetail ] . + BIND(CONCAT("Restriction on property: ", STR(?property)) AS ?axiomType) + } + + # BIND an error message for reused terms + BIND(CONCAT("ERROR: The reused term ", STR(?reusedTerm), " is extended with a ", ?axiomType, " axiom.") AS ?error) +} +``` +**Title: Checking for Plurals** + +Constraint Description: All terms in your ontology should be nouns and noun-phrases that are singular in number. This query allows a user to identify ontology terms that potentially have plural labels, which might not follow ontology design conventions. + +Severity: Warning. + +Level: 4 + +```sparql + +PREFIX rdfs: +PREFIX owl: + +SELECT ?term ?label ?warning +WHERE { + # Extract all classes and properties + { + ?term a owl:Class . + } + UNION + { + ?term a owl:ObjectProperty . + } + UNION + { + ?term a owl:DatatypeProperty . + } + + # Get the label of the term + ?term rdfs:label ?label . + + # Filter for terms that have labels potentially indicating plurals + FILTER( + REGEX(?label, "(s|es|ies)$", "i") + ) + + # Bind a warning message for terms with plural-like labels + BIND(CONCAT("WARNING: The term '", ?label, "' appears to be plural.") AS ?warning) +} +``` +**Title: Query to Detect Negative Terms** + +Constraint Description: This query will return all terms in the ontology that have labels containing one of the negative terms listed. This can help identify terms that may introduce negation or exclusion concepts, which might require further review depending on the ontology's modeling approach. This query helps you identify negative terms in your ontology and, at the same time, generates warnings if there are ontology elements that have identical labels. + +Severity: Warning. + +Level: 3 + +```sparql + +PPREFIX rdfs: +PREFIX owl: + +SELECT ?element ?element2 ?label1 ?label2 ?error +WHERE { + { + # Extract all classes with labels + ?element a owl:Class . + } + UNION + { + # Extract all object properties with labels + ?element a owl:ObjectProperty . + } + UNION + { + # Extract all datatype properties with labels + ?element a owl:DatatypeProperty . + } + + # Get the label of the first element + ?element rdfs:label ?label1 . + + # Detect negative terms in the first element's label + FILTER(REGEX(?label1, "(?i)\\b(not|non|no|without|absent|null|empty|void|false)\\b")) + + # Find other elements with the same label + { + ?element2 a owl:Class . + } + UNION + { + ?element2 a owl:ObjectProperty . + } + UNION + { + ?element2 a owl:DatatypeProperty . + } + + # Get the label of the second element + ?element2 rdfs:label ?label2 . + + # Check for duplicate labels + FILTER(?label1 = ?label2) + + # Avoid self-matching (make sure we don't compare the same element) + FILTER(?element != ?element2) + + # Bind an error message for duplicate negative terms + BIND(CONCAT("ERROR: The terms ", STR(?element), " and ", STR(?element2), " have the same label: '", ?label1, "'") AS ?error) +} + +``` +**Title: Detect Ellipses** + +Constraint Description: This query will return a list of terms (both classes and properties) whose labels contain ellipses. You can use this to identify and review any such labels that may be incorrectly or ambiguously defined in the ontology. + +Severity: Warning + +Level: 4 + +```sparql + +PREFIX rdfs: +PREFIX owl: + +SELECT ?term ?label ?warning +WHERE { + { + # Extract all classes with labels + ?term a . + } + UNION + { + # Extract all object properties with labels + ?term a . + } + UNION + { + # Extract all datatype properties with labels + ?term a . + } + + # Get the label of the term + ?term rdfs:label ?label . + + # Filter for labels that contain ellipses (three dots) + FILTER(CONTAINS(?label, "...")) + + # Bind a warning message for terms with ellipses in the label + BIND(CONCAT("WARNING: The label '", ?label, "' contains ellipses.") AS ?warning) +} + +``` + +**Title: IRI Subject Validation and Annotation Check** + +Constraint Description: This SPARQL query checks if a specific IRI is the subject of any triple in an RDF dataset or ontology. It also checks how a specific IRI is used and whether it has appropriate annotations, the query ensures that the data is well-structured, properly annotated, and used according to the design principles of the ontology + +Severity: Error. + +Level: 8 + +```sparql + +PREFIX rdfs: +PREFIX owl: + +SELECT ?predicate ?object ?annotationProperty ?annotationValue ?error +WHERE { + # Check if the IRI is the subject of a triple + ?predicate ?object . + + # Check for annotations on the IRI + OPTIONAL { + ?annotationProperty ?annotationValue . + FILTER(?annotationProperty IN (rdfs:label, rdfs:comment, owl:versionInfo)) + } + + # Bind an error message + BIND(CONCAT("ERROR: The IRI is the subject of a triple with predicate '", STR(?predicate), "' and object '", STR(?object), "'.") AS ?error) +} +``` + + **Title: Abbreviation Check** + + Constraint Description: This query is designed to find entities that have an git statu and retrieve a name (label) for those entities if available. + + Severity: Warning. + + Level: 5 + + ```sparql + + PREFIX rdfs: + PREFIX owl: + + SELECT ?entity ?entityName ?abbreviation ?warning + WHERE { + # Find entities with abbreviations + ?entity rdfs:comment ?abbreviation . + + # Optionally get the label (name) of the entity + OPTIONAL { ?entity rdfs:label ?entityName . } + + # Bind a warning message if an abbreviation is found + BIND( + CONCAT("WARNING: The entity ", STR(?entity), " has an abbreviation: '", ?abbreviation, "'.") AS ?warning + ) + } + ORDER BY ?entityName + + ``` + + **Title: Check for Properties without Specified Ranges** + + Constraint Description: The purpose of the query is to identify properties in an ontology or dataset that do not have a specified rdfs:range, and to generate a warning message for each such property. + Severity: Warning + + Level: 3 + + ```sparql + + PREFIX rdf: + PREFIX rdfs: + SELECT ?property ?error + WHERE { + ?property a rdf:Property . + FILTER NOT EXISTS { ?property rdfs:range ?range } + BIND (concat("WARNING: The property ", str(?property), " does not have a specified range.") AS ?error) + } + + ``` + \ No newline at end of file