Learning objectives
- Distinguish an OWL ontology (classes, properties and individuals) from SWRL rules.
- Read and write class atoms and object-property atoms using SWRL variable syntax.
- Understand a SWRL rule as a universally quantified implication.
- Explain how rule firing derives new assertions from existing ontology facts.
- Distinguish asserted knowledge from rule-derived knowledge.
- Recognise the limits of a finite, function-free rule-engine implementation.
1 · The formal language
SWRL (Semantic Web Rule Language) combines OWL ontology vocabulary with Horn-like rules. In this laboratory, the ontology provides classes, object properties and named individuals. Rules contain class atoms and object-property atoms only.
OWL vocabulary
\(\mathcal{C}\): classes; \(\mathcal{P}\): object properties; \(\mathcal{I}\): named individuals; \(\mathcal{A}\): ontology axioms and assertions.
SWRL rule
Each \(B_i\) and \(H\) is an atom. Variables are written with a leading question mark in the concrete syntax.
The rule means: every individual enrolled in at least one course and known to be a student is an active student.
Concrete SWRL atom forms used here
| Atom type | Abstract form | Example |
|---|---|---|
| Class atom | \(C(x)\) | Student(?x) |
| Object-property atom | \(R(x,y)\) | EnrolledIn(?x, ?c) |
| Rule conjunction | \(B_1\land B_2\) | Student(?x) ^ EnrolledIn(?x, ?c) |
| Rule implication | \(B\rightarrow H\) | ... -> ActiveStudent(?x) |
Mathematical semantics
A rule can be written in logical form as a universally quantified implication. For example:
An interpretation \(\mathcal{I}\) satisfies the rule when every assignment of its variables that makes all body atoms true also makes the head atom true:
Here, \(\theta\) maps variables to domain elements. A class atom is true when its assigned individual belongs to the class extension; an object-property atom is true when the assigned pair belongs to the property extension.
2 · The ontology and initial rules
The ontology contains a small class hierarchy and two object properties. Domain and range declarations are displayed as ontology information; this teaching engine does not perform general OWL domain/range reasoning.
Object properties
Initial SWRL rules
A student enrolled in a course is inferred to be an active student.
A lecturer who teaches a course is inferred to be teaching staff.
3 · TELL — Add ontology assertions and SWRL rules
Add a class assertion, an object-property assertion, or a SWRL rule. Class names must be unary; object-property names must be binary. New predicates can be introduced by using them in a statement, but keep their arity consistent.
Syntax reminders
- Class assertion:
Student(charlie) - Property assertion:
EnrolledIn(charlie, ai) - Rule:
Student(?x) ^ EnrolledIn(?x, ?c) -> ActiveStudent(?x) - Variables begin with
?. - Every variable in the rule head must occur in its body (range-restricted/safe rule).
- Use
^for conjunction and exactly one->.
Current asserted ontology facts
Current SWRL rules
4 · APPLY RULES — Derive additional knowledge
The rule engine repeatedly matches rule-body atoms against the current set of known assertions. When a match is found, it instantiates the rule head and adds the resulting assertion if it is new. The process stops at a fixed point.
For this finite positive rule fragment, the iteration terminates because no new individuals are generated and only finitely many ground atoms can be formed from the named individuals and predicates.
Derived assertions and explanations
Apply the rules to see inferred assertions.
5 · ASK — Query the ontology
Ask whether a ground class/property assertion is supported, or submit a conjunctive query to find variable substitutions. Run the rules first (or use Ask, which computes the closure automatically).
For conjunctive queries, use ^ and variables such as ?x, e.g. ActiveStudent(?x) ^ EnrolledIn(?x, ai).
Try these queries
Inference explanation
6 · Exercises
Tell Student(charlie) and EnrolledIn(charlie, ai). Apply the rules. Which new assertion is derived?
ActiveStudent(charlie) is derived by matching the first rule with ?x = charlie and ?c = ai.
Write a rule that infers CourseParticipant(?x) when an individual is enrolled in a course. What must the rule body contain?
EnrolledIn(?x, ?c) -> CourseParticipant(?x). The head variable ?x occurs in the body, so the rule is safe in this lab's supported fragment.
Was ActiveStudent(alice) explicitly added as an ontology assertion?
No. It is inferred by applying the SWRL rule to the asserted student and enrolment facts.
If ActiveStudent(mira) is not derived, can we conclude ¬ActiveStudent(mira)?
No. The absence of a derived positive assertion does not establish its negation. OWL/SWRL reasoning follows an open-world perspective.
7 · What this laboratory does — and does not — implement
| Feature | Implemented? | Notes |
|---|---|---|
| Class assertions | Yes | Unary class atoms over named individuals. |
| Object-property assertions | Yes | Binary object-property atoms over named individuals. |
| Conjunctive rule bodies | Yes | Positive conjunction of class/property atoms. |
| Single-atom rule heads | Yes | Head variables must occur in the body. |
| Repeated forward chaining | Yes | Computes a finite closure over the current named individuals. |
| General OWL 2 DL reasoning | No | Ontology display is illustrative; no complete OWL reasoner is embedded. |
| SWRL built-ins / datatype atoms | No | Only class and object-property atoms are supported. |
| Negation, equality, arbitrary FOL | No | Outside the supported rule fragment. |
The implementation is a teaching engine for a finite, positive, function-free subset. It illustrates rule matching and derivation; it should not be treated as a standards-complete SWRL reasoner or as a general decision procedure for OWL/SWRL.