Skip to content

Check LHS size before inserting into FDTree - #714

Open
wildsor wants to merge 1 commit into
Desbordante:mainfrom
wildsor:hyfd-max-lhs
Open

Check LHS size before inserting into FDTree#714
wildsor wants to merge 1 commit into
Desbordante:mainfrom
wildsor:hyfd-max-lhs

Conversation

@wildsor

@wildsor wildsor commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

Merging #798 first is preferred

This helps cut runtime and memory if the max LHS option is specified. Before, FDs with LHSs that are too large were only removed at the point of result construction.

The result is constructed by traversing an internal trie (FDTree). The trie has an invariant that no nodes corresponding to an FD that generalizes some other FD that is in the tree ever exist in it. This is achieved by checking for that condition before adding a new node.

A FD with a larger LHS by definition never generalizes a FD with a smaller LHS. The only way FDs are added to the trie is by adding one new attribute to the LHS of a FD that was already in the trie.

Thus, if we stop all FDs with LHSs beyond a certain size from being added, then the trie's invariant would still hold, and the FDs with LHSs that are too large would not end up in the trie (and in the answer).

We will not miss any FDs with a smaller size either, because the checks for the FDs with smaller LHSs are not affected in any manner by the FDs with larger LHSs.

The situation is exactly the same as in HyMD, and it's being done there already. I suspect it's true for all the Hy* algorithms too.

@wildsor
wildsor marked this pull request as ready for review April 3, 2026 18:38

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/core/algorithms/fd/hyfd/validator.cpp
@wildsor
wildsor requested a review from MichaelS239 April 4, 2026 11:14
result.ComparisonSuggestions().begin(),
result.ComparisonSuggestions().end());
if (current_level_number_ >= fds_->GetNumAttributes()) {
if (current_level_number_ == max_lhs) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The invalidated FDs get removed during validation above

@wildsor
wildsor force-pushed the hyfd-max-lhs branch 2 times, most recently from dff1cab to 3e01d02 Compare July 12, 2026 15:50
@chernishev
chernishev requested review from polyntsov and removed request for MichaelS239 July 16, 2026 10:01
This helps cut runtime and memory if the max LHS option is specified.
Before, FDs with LHSs that are too large were only removed at the point
of result construction.

The result is constructed by traversing an internal trie (FDTree). The
trie has an invariant that no nodes corresponding to an FD that
generalizes some other FD that is in the tree ever exist in it. This is
achieved by checking for that condition before adding a new node.

A FD with a larger LHS by definition never generalizes a FD with a
smaller LHS. The only way FDs are added to the trie is by adding one
new attribute to the LHS of a FD that was already in the trie.

Thus, if we stop all FDs with LHSs beyond a certain size from being
added, then the trie's invariant would still hold, and the FDs with LHSs
that are too large would not end up in the trie (and in the answer).

We will not miss any FDs with a smaller size either, because the checks
for the FDs with smaller LHSs are not affected in any manner by the FDs
with larger LHSs.

The situation is exactly the same as in HyMD, and it's being done there
already. I suspect it's true for all the Hy* algorithms too.
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