Skip to content

TDL: do not create the tautological feature ∀ r⁻.⊤ for inverse properties - #673

Merged
Demirrr merged 1 commit into
developfrom
fix/tdl-inverse-forall-features
Nov 5, 2026
Merged

Demirrr merged 1 commit into
developfrom
fix/tdl-inverse-forall-features

Conversation

@Demirrr

@Demirrr Demirrr commented Nov 5, 2026

Copy link
Copy Markdown
Member

Problem

With use_inverse=True, TDL added the feature ∀ r⁻.⊤ next to ∃ r⁻.⊤ for every individual that has a predecessor. With the filler ⊤, ∀ r⁻.⊤ is a tautology (the reasoner returns every individual), but its column was set only for individuals with a predecessor. So:

  • the training matrix disagreed with the reasoner: 4 of 352 columns and 123 of 26,752 cells (0.46%) on the Family Uncle problem, all of the form ∀ r⁻.⊤ (hasChild, hasParent, hasSibling, married), always False in the matrix where the reasoner says True;
  • the column was an exact copy of ∃ r⁻.⊤ and, because columns are sorted by DL string and ∀ sorts before ∃, it won ties against it, so a split on it was read back as ⊤ or ⊥.

Found while benchmarking a forest variant of TDL (research write-up in #672, follow-up 9).

Change

∀ r⁻.⊤ is no longer created (ontolearn/learners/tree_learner.py). New regression test TestTrainingMatrixSemantics in tests/test_tdl.py asserts that every cell of the training matrix agrees with the reasoner; it fails on develop and passes here.

Effect on learned hypotheses (behaviour change)

Hypotheses can change. 5-fold CV, held-out F1 with positive_paths, 18 Family problems (single CV run):

problem before after
Cousin 0.8223 0.7768
Grandgrandson 0.8985 0.8818
PersonWithASibling 0.9302 1.0000
Uncle 0.8929 0.9060

The other 14 problems are unchanged; the mean over the 18 problems goes from 0.9647 to 0.9658. Two problems get worse, so this is a correctness fix, not an accuracy improvement. tests/test_tdl_hypothesis_extraction.py pins CV values; the Cousin and Uncle full-tree values (and its docstring table) are updated to the new numbers. CHANGELOG.md has an entry.

Not covered

  • Mutagenesis / Carcinogenesis were not re-measured, so the effect on large KBs is unknown.
  • Only TDL-related tests were run: tests/test_tdl*.py (109 passed, 2 skipped) and tests/test_example_concept_learning_evaluation.py (passed). The full suite was not run. tests/test_triplestore.py needs a Fuseki server and was not run.

🤖 Generated with Claude Code

…ties

With the filler ⊤, ∀ r⁻.⊤ holds for every individual, but its column was set only for
individuals with a predecessor (a duplicate of ∃ r⁻.⊤ that won ties by sorting first).
The training matrix therefore disagreed with the reasoner, and a split on it was read
back as ⊤ or ⊥. Adds a regression test that every matrix cell agrees with the reasoner
and updates the pinned Family CV values that encoded the bug.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant