Skip to content

Refactor free variable removal#3773

Merged
georgwiese merged 6 commits into
mainfrom
refactor-free-variable-removal
Jun 26, 2026
Merged

Refactor free variable removal#3773
georgwiese merged 6 commits into
mainfrom
refactor-free-variable-removal

Conversation

@georgwiese

Copy link
Copy Markdown
Collaborator

A small refactor in preparation of a PR I'm planning on top of #3761: Whenever we remove a variable, we should emit a hint of how that variable could have been assigned in the original circuit (to aid FV). With this PR, at least the algebraic constraint case should be trivial.

/// Like `try_solve_for`, but also handles the case where the constraint is a
/// product of two expressions. In this case, the found solution (if any) might
/// not be unique.
pub fn try_solve_for_not_unique(&self, variable: &V) -> Option<GroupedExpression<T, V>> {

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.

I originally put it into try_solve_for, but I think we might use it in situations were we only want unique solutions.

@georgwiese georgwiese marked this pull request as ready for review June 25, 2026 17:39
/// Like `try_solve_for`, but also handles the case where the constraint is a
/// product of two expressions. In this case, the found solution (if any) might
/// not be unique.
pub fn try_solve_for_not_unique(&self, variable: &V) -> Option<GroupedExpression<T, V>> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just naming: try_find_arbitrary_solution? try_find_some_solution? try_get_some_solution?

if let Some((left, right)) = self.expression.try_as_single_product() {
// If either `left` or `right` can be set to 0, the constraint is satisfied.
return AlgebraicConstraint::from(left)
.try_solve_for(variable)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not call recursively?

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.

Right, of course!

@georgwiese georgwiese requested a review from chriseth June 26, 2026 09:19
@georgwiese georgwiese enabled auto-merge June 26, 2026 11:36
@georgwiese georgwiese added this pull request to the merge queue Jun 26, 2026
Merged via the queue into main with commit 9638f09 Jun 26, 2026
19 checks passed
@georgwiese georgwiese deleted the refactor-free-variable-removal branch June 26, 2026 12:31
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