Skip to content

Code tree results: number equality sort variables first, as the compiler does - #1028

Closed
quickbeam123 wants to merge 1 commit into
masterfrom
martin-renaming-normalization-order
Closed

quickbeam123 wants to merge 1 commit into
masterfrom
martin-renaming-normalization-order

Conversation

@quickbeam123

Copy link
Copy Markdown
Collaborator

The substitutions returned by code-tree generalization queries translate the key's variables to binding slots via a Renaming. For an equality literal, Renaming::normalizeVariables visits the arguments before the sort, whereas CodeTree::Compiler (and the flat term) visit the sort first, so the slots could be permuted and the substitution came out wrong (ill-sorted terms, e.g. TermSharing / SortHelper assertion violations).

Fix it locally in CodeTreeInterfaces.hpp rather than changing Renaming, which the substitution trees rely on in its current order.

Reproducer: the new unit test TermIndex/gen_equality_sort_variables_numbered_first (fails before the change).

Fixes #1023

…ler does

The substitutions returned by code-tree generalization queries translate
the key's variables to binding slots via a Renaming. For an equality
literal, Renaming::normalizeVariables visits the arguments before the
sort, whereas CodeTree::Compiler (and the flat term) visit the sort
first, so the slots could be permuted and the substitution came out wrong
(ill-sorted terms, e.g. TermSharing / SortHelper assertion violations).

Fix it locally in CodeTreeInterfaces.hpp rather than changing Renaming,
which the substitution trees rely on in its current order.

Reproducer: the new unit test TermIndex/gen_equality_sort_variables_numbered_first
(fails before the change).

Fixes #1023

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@quickbeam123
quickbeam123 requested a review from mezpusz October 19, 2026 09:39
@quickbeam123

Copy link
Copy Markdown
Collaborator Author

On my machine, the two problematic runs from #1023 no longer crash...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Literal code tree does not handle two variable equality sort matching

1 participant