Skip to content

Rewrite PerfectRef as an installable package with a corrected core - #1

Merged
AImenes merged 1 commit into
mainfrom
claude/intelligent-brown-ngh86h
Oct 2, 2026
Merged

AImenes merged 1 commit into
mainfrom
claude/intelligent-brown-ngh86h

Conversation

@AImenes

@AImenes AImenes commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

The 1.x code was a loose folder meant to be copied into site-packages and had several correctness problems: the entry point crashed on a missing import, the default upperlimit=None raised TypeError, role inclusions were skipped when the first argument was unbound, inverse_of was translated to P⁻ ⊑ P, "?_" written twice became a shared variable, constants broke unification, and duplicate rewritings were only detected for identical atom order.

Version 2 is a pip-installable perfectref package:

  • perfectref.model: immutable terms, atoms and conjunctive queries kept in the paper's τ normal form, with canonical keys for deduplication
  • perfectref.tbox: DL-Lite positive inclusions indexed by right-hand side, plus a plain-text DL syntax parser
  • perfectref.owl: owlready2 extraction covering subclass/equivalence, some/min/exactly/value restrictions, intersections, unions on the left, general class axioms, domain/range, sub/inverse/equivalent/symmetric properties and imports; axioms outside DL-Lite are listed in tbox.skipped
  • perfectref.algorithm: work-list PerfectRef with gr, mgu and reduce as in the paper, head specialisation on unification, and a max_rewritings cap
  • perfectref.parser / formatting: Datalog-style query grammar with long variable names, constants and IRIs; text, JSON and SPARQL output
  • perfectref.legacy: the 1.x API (get_entailed_queries, Query, QueryBody, AtomConcept, AtomRole, Variable, ...) kept working on top of the core, with cached ontology loading and picklable results
  • CLI (perfectref rewrite|tbox), pyproject, GitHub Actions, ruff config
  • tests: Example 1 of the paper reproduced exactly, OWL translation, parser, legacy API and CLI (55 tests)

Test ontologies move to tests/data (plus the paper's university TBox as OWL) and the Pizza ontology to examples/; redundant copies, generated output and committed bytecode are removed.

The 1.x code was a loose folder meant to be copied into site-packages and
had several correctness problems: the entry point crashed on a missing
import, the default upperlimit=None raised TypeError, role inclusions were
skipped when the first argument was unbound, inverse_of was translated to
P⁻ ⊑ P, "?_" written twice became a shared variable, constants broke
unification, and duplicate rewritings were only detected for identical
atom order.

Version 2 is a pip-installable `perfectref` package:

- perfectref.model: immutable terms, atoms and conjunctive queries kept in
  the paper's τ normal form, with canonical keys for deduplication
- perfectref.tbox: DL-Lite positive inclusions indexed by right-hand side,
  plus a plain-text DL syntax parser
- perfectref.owl: owlready2 extraction covering subclass/equivalence,
  some/min/exactly/value restrictions, intersections, unions on the left,
  general class axioms, domain/range, sub/inverse/equivalent/symmetric
  properties and imports; axioms outside DL-Lite are listed in tbox.skipped
- perfectref.algorithm: work-list PerfectRef with gr, mgu and reduce as in
  the paper, head specialisation on unification, and a max_rewritings cap
- perfectref.parser / formatting: Datalog-style query grammar with long
  variable names, constants and IRIs; text, JSON and SPARQL output
- perfectref.legacy: the 1.x API (get_entailed_queries, Query, QueryBody,
  AtomConcept, AtomRole, Variable, ...) kept working on top of the core,
  with cached ontology loading and picklable results
- CLI (`perfectref rewrite|tbox`), pyproject, GitHub Actions, ruff config
- tests: Example 1 of the paper reproduced exactly, OWL translation,
  parser, legacy API and CLI (55 tests)

Test ontologies move to tests/data (plus the paper's university TBox as
OWL) and the Pizza ontology to examples/; redundant copies, generated
output and committed bytecode are removed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U5bWLj6FhSbcAZxcBYtDut
@AImenes
AImenes merged commit aefdc75 into main Oct 2, 2026
6 checks passed
@AImenes
AImenes deleted the claude/intelligent-brown-ngh86h branch October 2, 2026 16:01
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.

2 participants