@@ -18,7 +18,6 @@ use crate::Identity;
18
18
use super :: affine_expression:: AlgebraicVariable ;
19
19
use super :: evaluators:: partial_expression_evaluator:: PartialExpressionEvaluator ;
20
20
use super :: evaluators:: symbolic_evaluator:: SymbolicEvaluator ;
21
- use super :: machines:: Connection ;
22
21
use super :: range_constraints:: RangeConstraint ;
23
22
use super :: util:: try_to_simple_poly;
24
23
use super :: { Constraint , FixedData } ;
@@ -96,20 +95,10 @@ where
96
95
}
97
96
}
98
97
99
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
100
- /// The RHS of a range constraint of the form `[ w ] in [ RANGE ]`, including the multiplicity column.
101
- pub struct PhantomRangeConstraintTarget {
102
- pub column : PolyID ,
103
- pub multiplicity_column : PolyID ,
104
- }
105
-
106
98
#[ derive( Clone ) ]
107
99
pub struct GlobalConstraints < T : FieldElement > {
108
100
pub witness_constraints : WitnessColumnMap < Option < RangeConstraint < T > > > ,
109
101
pub fixed_constraints : FixedColumnMap < Option < RangeConstraint < T > > > ,
110
- /// For range constraints which are enforced via phantom lookups, this maps the
111
- /// constrained column to the target and multiplicity column.
112
- pub phantom_range_constraints : BTreeMap < PolyID , PhantomRangeConstraintTarget > ,
113
102
}
114
103
115
104
impl < T : FieldElement > RangeConstraintSet < & AlgebraicReference , T > for GlobalConstraints < T > {
@@ -153,12 +142,10 @@ pub fn set_global_constraints<'a, T: FieldElement>(
153
142
154
143
let mut retained_identities = vec ! [ ] ;
155
144
let mut removed_identities = vec ! [ ] ;
156
- let mut range_constraint_multiplicities = BTreeMap :: new ( ) ;
157
145
for identity in identities. into_iter ( ) {
158
146
let remove = propagate_constraints (
159
147
& fixed_data. intermediate_definitions ,
160
148
& mut known_constraints,
161
- & mut range_constraint_multiplicities,
162
149
identity,
163
150
& full_span,
164
151
) ;
@@ -183,17 +170,6 @@ pub fn set_global_constraints<'a, T: FieldElement>(
183
170
log:: debug!( " {id}" ) ;
184
171
}
185
172
186
- if !range_constraint_multiplicities. is_empty ( ) {
187
- log:: debug!( "Recorded the following range constraint multiplicity columns:" ) ;
188
- }
189
- for ( poly_id, target) in & range_constraint_multiplicities {
190
- log:: debug!(
191
- " {} -> {}" ,
192
- fixed_data. column_name( poly_id) ,
193
- fixed_data. column_name( & target. multiplicity_column)
194
- ) ;
195
- }
196
-
197
173
let mut witness_constraints: WitnessColumnMap < Option < RangeConstraint < T > > > =
198
174
fixed_data. witness_map_with ( None ) ;
199
175
for ( poly_id, con) in known_constraints {
@@ -211,7 +187,6 @@ pub fn set_global_constraints<'a, T: FieldElement>(
211
187
let global_constraints = GlobalConstraints {
212
188
witness_constraints,
213
189
fixed_constraints,
214
- phantom_range_constraints : range_constraint_multiplicities,
215
190
} ;
216
191
217
192
(
@@ -260,7 +235,6 @@ fn add_constraint<T: FieldElement>(
260
235
fn propagate_constraints < T : FieldElement > (
261
236
intermediate_definitions : & BTreeMap < AlgebraicReferenceThin , AlgebraicExpression < T > > ,
262
237
known_constraints : & mut BTreeMap < PolyID , RangeConstraint < T > > ,
263
- range_constraint_multiplicities : & mut BTreeMap < PolyID , PhantomRangeConstraintTarget > ,
264
238
identity : & Identity < T > ,
265
239
full_span : & BTreeSet < PolyID > ,
266
240
) -> bool {
@@ -303,21 +277,14 @@ fn propagate_constraints<T: FieldElement>(
303
277
// In that case, we can remove the lookup, because its only function is to enforce
304
278
// the range constraint.
305
279
if right. expressions . len ( ) == 1 {
306
- if let ( Some ( left_ref) , Some ( right_ref) ) = (
280
+ if let ( Some ( _) , Some ( right_ref) ) = (
281
+ // The range constraint has been transferred from right to left
282
+ // by the above code iff. both expressions can be converted to
283
+ // simple polynomials.
307
284
try_to_simple_poly ( & left. expressions [ 0 ] ) ,
308
285
try_to_simple_poly ( & right. expressions [ 0 ] ) ,
309
286
) {
310
287
if full_span. contains ( & right_ref. poly_id ) {
311
- let connection = Connection :: try_from ( identity) . unwrap ( ) ;
312
- if let Some ( multiplicity) = connection. multiplicity_column {
313
- let target = PhantomRangeConstraintTarget {
314
- column : right_ref. poly_id ,
315
- multiplicity_column : multiplicity,
316
- } ;
317
- assert ! ( range_constraint_multiplicities
318
- . insert( left_ref. poly_id, target)
319
- . is_none( ) ) ;
320
- }
321
288
return true ;
322
289
}
323
290
}
@@ -557,12 +524,10 @@ namespace Global(2**20);
557
524
. into_iter( )
558
525
. collect( )
559
526
) ;
560
- let mut range_constraint_multiplicities = BTreeMap :: new ( ) ;
561
527
for identity in & analyzed. identities {
562
528
propagate_constraints (
563
529
& BTreeMap :: new ( ) ,
564
530
& mut known_constraints,
565
- & mut range_constraint_multiplicities,
566
531
identity,
567
532
& full_span,
568
533
) ;
@@ -649,12 +614,10 @@ namespace Global(2**20);
649
614
. into_iter( )
650
615
. collect( )
651
616
) ;
652
- let mut range_constraint_multiplicities = BTreeMap :: new ( ) ;
653
617
for identity in & analyzed. identities {
654
618
propagate_constraints (
655
619
& BTreeMap :: new ( ) ,
656
620
& mut known_constraints,
657
- & mut range_constraint_multiplicities,
658
621
identity,
659
622
& full_span,
660
623
) ;
@@ -680,33 +643,6 @@ namespace Global(2**20);
680
643
. into_iter( )
681
644
. collect:: <BTreeMap <_, _>>( )
682
645
) ;
683
- assert_eq ! (
684
- range_constraint_multiplicities,
685
- vec![
686
- (
687
- // Global.B
688
- witness_poly_id( 3 ) ,
689
- PhantomRangeConstraintTarget {
690
- // Global.BYTE
691
- column: constant_poly_id( 0 ) ,
692
- // Global.byte_multiplicities
693
- multiplicity_column: witness_poly_id( 0 )
694
- }
695
- ) ,
696
- (
697
- // Global.D
698
- witness_poly_id( 5 ) ,
699
- PhantomRangeConstraintTarget {
700
- // Global.BYTE
701
- column: constant_poly_id( 0 ) ,
702
- // Global.byte_multiplicities
703
- multiplicity_column: witness_poly_id( 0 )
704
- }
705
- ) ,
706
- ]
707
- . into_iter( )
708
- . collect:: <BTreeMap <_, _>>( )
709
- )
710
646
}
711
647
712
648
#[ test]
@@ -726,12 +662,10 @@ namespace Global(1024);
726
662
let mut known_constraints = vec ! [ ( constant_poly_id( 0 ) , RangeConstraint :: from_max_bit( 7 ) ) ]
727
663
. into_iter ( )
728
664
. collect ( ) ;
729
- let mut range_constraint_multiplicities = BTreeMap :: new ( ) ;
730
665
assert_eq ! ( analyzed. identities. len( ) , 1 ) ;
731
666
let removed = propagate_constraints (
732
667
& BTreeMap :: new ( ) ,
733
668
& mut known_constraints,
734
- & mut range_constraint_multiplicities,
735
669
analyzed. identities . first ( ) . unwrap ( ) ,
736
670
& Default :: default ( ) ,
737
671
) ;
0 commit comments