Skip to content

Commit

Permalink
improve on constant folding in multicircuits
Browse files Browse the repository at this point in the history
- because they have more context, fold constants in the monads
- if constant folding results in an already-existing sub-circuit, that
    sub-circuit is used instead of the newly created one
- rename `InputIndicator`'s “*_row” to “*_column”
- re-arrange the expression of some constraints to de-duplicate
    sub-circuits (Processor Table only)
- perform constant folding just after the construction of the
    multicircuit instead of in the compiler

Co-authored-by: sword-smith <thor@neptune.cash>
  • Loading branch information
jan-ferdinand and Sword-Smith committed Feb 27, 2023
2 parents 0a319f8 + 614d456 commit c1be5bb
Show file tree
Hide file tree
Showing 9 changed files with 849 additions and 449 deletions.
5 changes: 1 addition & 4 deletions constraint-evaluation-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ fn turn_circuits_into_degree_bounds_string<II: InputIndicator>(
fn turn_circuits_into_string<II: InputIndicator>(
constraint_circuits: &mut [ConstraintCircuit<II>],
) -> String {
// Delete redundant nodes
ConstraintCircuit::constant_folding(&mut constraint_circuits.iter_mut().collect_vec());

// Assert that all node IDs are unique (sanity check)
ConstraintCircuit::assert_has_unique_ids(constraint_circuits);

Expand Down Expand Up @@ -445,7 +442,7 @@ fn is_bfield_element<II: InputIndicator>(circuit: &ConstraintCircuit<II>) -> boo
match &circuit.expression {
CircuitExpression::XConstant(_) => false,
CircuitExpression::BConstant(_) => true,
CircuitExpression::Input(indicator) => indicator.is_base_table_row(),
CircuitExpression::Input(indicator) => indicator.is_base_table_column(),
CircuitExpression::Challenge(_) => false,
CircuitExpression::BinaryOperation(_, lhs, rhs) => {
is_bfield_element(&lhs.as_ref().borrow()) && is_bfield_element(&rhs.as_ref().borrow())
Expand Down
Loading

0 comments on commit c1be5bb

Please sign in to comment.