Skip to content

Fix constraint satisfaction check#409

Merged
alireza-shirzad merged 2 commits into
masterfrom
fix-satisfaction-checking
Jul 28, 2025
Merged

Fix constraint satisfaction check#409
alireza-shirzad merged 2 commits into
masterfrom
fix-satisfaction-checking

Conversation

@Pratyush

Copy link
Copy Markdown
Member

Description

Fixes constraint satisfaction checking to always work.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

})
.collect();
if self.predicate.is_satisfied(&variables) {
if !self.predicate.is_satisfied(&variables) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is because of a weird typo; see the other change.

pub fn is_satisfied(&self, variables: &[F]) -> bool {
// TODO: Change the polynomial eval to get a slice as an evaluation point
!self.polynomial.evaluate(&variables.to_vec()).is_zero()
self.polynomial.evaluate(&variables.to_vec()).is_zero()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The predicate is supposed to be satisfied when it is zero; not unsatisfied.

@Pratyush Pratyush requested review from alireza-shirzad and Copilot and removed request for Copilot July 25, 2025 22:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes constraint satisfaction checking in the GR1CS predicate system by correcting the boolean logic in satisfaction checks and adding support for linear combination (LC) variable evaluation.

  • Fixed the boolean logic in is_satisfied method to return true when polynomial evaluates to zero
  • Added proper handling of linear combination variables in constraint satisfaction checking
  • Updated constraint checking logic to correctly identify unsatisfied constraints

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
relations/src/gr1cs/predicate/polynomial_constraint.rs Fixed boolean logic in is_satisfied method by removing negation
relations/src/gr1cs/predicate/mod.rs Added LC variable handling and fixed constraint satisfaction check logic

Comment thread relations/src/gr1cs/predicate/mod.rs Outdated
Comment thread relations/src/gr1cs/predicate/mod.rs Outdated
Comment thread relations/src/gr1cs/predicate/mod.rs Outdated
@alireza-shirzad alireza-shirzad merged commit 02fed63 into master Jul 28, 2025
4 checks passed
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.

3 participants