Repository navigation
KBO: don't mistake a sort and a term with the same functor number for the same symbol - #1018
Merged
Merged
Conversation
… the same symbol Type constructors and function symbols are numbered independently, so a sort and a term can share a functor number. KBO::compare (and the precedence fallback in State::result) only compared the numbers, so e.g. compare(complex, one_one(complex)) took the lexicographic path over a 0-ary sort and a 1-ary term and returned EQUAL. Cross-kind comparisons are legitimately made by TermPartialOrdering when ground joinability / term ordering diagrams relate type and term variables; the bogus EQUAL made the partial ordering inconsistent and crashed the prover. Now both places also require the two terms to be of the same kind. This agrees with PrecedenceOrdering::comparePrecedences (type constructors below function symbols), which the term ordering diagrams already used, and makes KBO a consistent order on sorts and terms together. Reproducer (release build, SIGSEGV after ~5 s before the fix): vampire_z3_rel -sa otter Problems/SWV/SWV645_5.p Unit test KBO/kbo_test24 fails before the fix on ASS(t1->arity()) in traverseLexBidir. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mezpusz
approved these changes
Oct 12, 2026
mezpusz
left a comment
Contributor
There was a problem hiding this comment.
From the PR I cannot tell if these are all the places where we should do this, but it's definitely a good thing to start doing it in these two places!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type constructors and function symbols are numbered independently, so a sort and a term can share a functor number.
KBO::compare(and the precedence fallback inState::result) only compared the numbers, so e.g.compare(complex, one_one(complex))took the lexicographic path over a 0-ary sort and a 1-ary term and returnedEQUAL. Cross-kind comparisons are legitimately made byTermPartialOrderingwhen ground joinability / term ordering diagrams relate type and term variables; the bogusEQUALmade the partial ordering inconsistent and crashed the prover.Now both places also require the two terms to be of the same kind. This agrees with
PrecedenceOrdering::comparePrecedences(type constructors below function symbols), which the term ordering diagrams already used, and makes KBO a consistent order on sorts and terms together.Reproducer (release build, SIGSEGV after ~5 s before the fix):
vampire_z3_rel -sa otter Problems/SWV/SWV645_5.pUnit test K
BO/kbo_test24fails before the fix onASS(t1->arity())intraverseLexBidir.