File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
relations/src/gr1cs/predicate Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -183,12 +183,20 @@ impl<F: Field> PredicateConstraintSystem<F> {
183183 /// Check if the constraints enforced by this predicate are satisfied
184184 /// i.e. `L(x_1, x_2, ..., x_n) == 0`.
185185 pub fn which_constraint_is_unsatisfied ( & self , cs : & ConstraintSystem < F > ) -> Option < usize > {
186+ let panic_msg = |v| panic ! ( "Variable {v:?} is not assigned; did you run `cs.finalize()`?" ) ;
186187 for ( i, constraint) in self . iter_constraints ( ) . enumerate ( ) {
187188 let variables: Vec < F > = constraint
188189 . into_iter ( )
189- . map ( |variable| cs. assigned_value ( variable) . unwrap ( ) )
190+ . map ( |v| {
191+ cs. assigned_value ( v) . unwrap_or_else ( || {
192+ cs. get_lc ( v)
193+ . iter ( )
194+ . map ( |& ( c, v) | c * cs. assigned_value ( v) . unwrap_or_else ( || panic_msg ( v) ) )
195+ . sum ( )
196+ } )
197+ } )
190198 . collect ( ) ;
191- if self . predicate . is_satisfied ( & variables) {
199+ if ! self . predicate . is_satisfied ( & variables) {
192200 return Some ( i) ;
193201 }
194202 }
Original file line number Diff line number Diff line change @@ -44,8 +44,7 @@ impl<F: Field> PolynomialPredicate<F> {
4444impl < F : Field > PolynomialPredicate < F > {
4545 /// Check if the predicate is satisfied by the given variables.
4646 pub fn is_satisfied ( & self , variables : & [ F ] ) -> bool {
47- // TODO: Change the polynomial eval to get a slice as an evaluation point
48- !self . polynomial . evaluate ( & variables. to_vec ( ) ) . is_zero ( )
47+ self . polynomial . evaluate ( & variables. to_vec ( ) ) . is_zero ( )
4948 }
5049
5150 /// Evaluate the predicate on the given variables.
You can’t perform that action at this time.
0 commit comments