Can a reasoner rebuild the sample? OWL classes vs. selection rules

The 45 schools in this series weren’t chosen at random. They were picked with 26 written rules like this one:

S03: Public regional/master’s (Carnegie 18-20, <50% exclusively distance). Take 3.

That looks a lot like a class definition. So can a reasoner read the rules and work out which school belongs where?

Half of it can. This is the sixth experiment in a series that uses one public dataset, NCES IPEDS 2024, to show how languages and models change what a knowledge graph says. Experiment 5 showed where OWL classes go wrong for a taxonomy. This one tests what OWL reasoning is good at, and where it stops. The code, data and results are all on GitHub.

The setup: 26 rules as 26 classes

We wrote each rule as an OWL 2 class. Here is S03 in Manchester syntax:

Class: kgn:S03
    EquivalentTo: kgn:EligibleInstitution
        and kgn:sectorCode value 1
        and kgn:carnegieBasic2021Code some xsd:integer[>= 18, <= 20]
        and kgn:exclusivelyDistanceSharePct some xsd:decimal[< 50.0]

Then we loaded each school as an individual with the 21 facts the rules depend on: sector, Carnegie class, enrollment, share of students studying fully online and so on. We didn’t tell the reasoner which stratum any school belonged to.

We ran two description-logic reasoners, HermiT and Pellet, and compared what they inferred with the stratum each school was actually assigned.

See it: asserted vs. inferred

In the visualization below, run the reasoner and watch the inferred memberships draw in. Click any stratum for its OWL definition and the reason behind every gap.

Open the visualization in a new tab

Results: every school recovered, plus 19 extras

MethodMemberships recoveredExtraMissedStrata exact
OWL definitions (HermiT and Pellet)45 of 4519014 of 26
OWL definitions + “and not any earlier stratum”31 of 4511147 of 26
SPARQL selection over the reasoner’s classes, rules as written41 of 452424 of 26
SPARQL selection, plus one filter the rules don’t state45 of 450026 of 26

Both reasoners put all 45 schools back in their own stratum without being told. They agreed on every membership.

They also inferred 19 memberships the sample never made. Every one is a school that fits a stratum’s definition but sits in a different stratum. San Jose State fits S03, for example. It wasn’t picked because Cal State Northridge had already taken the Far West slot.

That’s the gap. The definitions say who could be picked. The rest of each rule says who was.

The reasoner did one thing nobody asked for. From the definitions alone, it worked out that every rural public two-year school is also a public two-year school, so one stratum is a subclass of another. Nobody had to write that down.

What OWL can’t say

Each rule has a second half: take the largest schools first, skip any school an earlier stratum already took, and take at most one per region. OWL has no way to say any of that.

“Largest first, take N.” Ranking compares every candidate. A class definition describes one individual at a time. It can say “enrollment under 5,000.” It can’t say “one of the four largest.” This accounts for 9 of the 19 extras.

“Not already chosen.” This depends on what an earlier step did, not on a fact about the school. The closest OWL gets is “in this class and not in any earlier class.” We tried it, and it got worse: 31 of 45. It sorts every school into the first definition it fits, whether or not that stratum actually picked it.

Missing means unknown. The same version also lost Howard University, whose religious affiliation is blank in the data. To a reasoner, blank doesn’t mean “none.” It means “we don’t know.” So it can’t prove Howard is not in the religious stratum, and it refuses to place Howard anywhere that depends on that. Stating “no affiliation” as an explicit fact fixed it.

“At most one per region.” OWL does have cardinality. But ask it to allow one school per region in a stratum, and the reasoner satisfies the rule by concluding that two schools are the same school. It decided Cal State Northridge and San Jose State were one institution. A cardinality restriction is a constraint on the data. It isn’t a selection rule.

What closes the gap

The procedural half fits in one SPARQL update, run once per pick:

INSERT { ?pick kgn:selectedFor kgn:S03 }
WHERE {
  SELECT ?pick WHERE {
    ?pick a kgn:S03 ;                               # eligibility: the reasoner's class
          kgn:enrollmentTotal ?enrollment ;
          kgn:regionCode ?region .
    FILTER NOT EXISTS { ?pick kgn:selectedFor ?earlier }                     # not already chosen
    FILTER NOT EXISTS { ?other kgn:selectedFor kgn:S03 ; kgn:regionCode ?region }  # one per region
  }
  ORDER BY DESC(?enrollment) STR(?pick)             # largest first
  LIMIT 1
}

Everything OWL lacked is here: ORDER BY and LIMIT for ranking, FILTER NOT EXISTS for “not already chosen,” and a loop for order. The reasoner still supplies the eligibility.

Run with the rules exactly as written, this placed 41 of 45 schools correctly.

The four misses pointed at something more useful than a bug. The written rule for one stratum, S05, covers Western Governors University and Southern New Hampshire University, both far larger than the two schools actually chosen. Add an “under 50% exclusively online” filter, the same campus-based threshold three other strata use, and the result is 45 of 45. The written rules don’t state that filter. So we’re treating it as a hypothesis that fits the data, not a documented rule.

One caveat applies to all of this. The dataset holds only the 45 schools that were chosen. The reasoner can check that the sample is consistent with its rules. It can’t confirm that ASU really is among the four largest public R1 universities nationally. That needs the full IPEDS universe.

What this means for your knowledge graph

Reasoners get pitched as the part of the semantic web that thinks for you. In reality, they do one job well. They classify things from definitions, and they do it consistently: two independent reasoners agreed on every membership here.

A few practical takeaways:

  • Use classes for eligibility. “What counts as X?” is a definition, and definitions are cheap. Twenty-six short class expressions classified in a few seconds.
  • Use queries for procedure. Ranking, limits and “not already chosen” belong in a query language. The SPARQL selection took about a second.
  • Say “none” explicitly. A blank field and a “no” are different facts. If your data drops the difference, a reasoner can’t get it back.

Pro tip: Writing a business rule as code is a good way to find the part nobody documented. The undocumented S05 filter only surfaced because the rule as written produced the wrong schools.

Simply put, a definition tells you who qualifies. A procedure tells you who gets picked. Most business rules are a mix of the two, and each half needs a different tool.

Run it yourself

Everything behind this post is in the Experiment 6 folder on GitHub. That includes the ontology with all 26 classes, the selection query, the full results and the visualization. You’ll need Python and a Java runtime, since both reasoners are Java programs. The full run takes about three minutes.

Next in the series: three ways to record where a fact came from, with RDF 1.2, named graphs and PROV-O.