Skip to content

Commit

Permalink
Improve CTL debugging (#1549)
Browse files Browse the repository at this point in the history
Extracted from #1352
  • Loading branch information
matthiasgoergens authored Apr 15, 2024
1 parent a271428 commit c245aaa
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions circuits/src/cross_table_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ pub mod ctl_utils {
let looking_multiplicity = looking_locations.iter().map(|l| l.1).sum::<F>();
let looked_multiplicity = looked_locations.iter().map(|l| l.1).sum::<F>();
if looking_multiplicity != looked_multiplicity {
println!(
eprintln!(
"Row {row:?} has multiplicity {looking_multiplicity} in the looking tables, but
{looked_multiplicity} in the looked table.\n\
Looking locations: {looking_locations:?}.\n\
Expand Down Expand Up @@ -614,14 +614,22 @@ pub mod ctl_utils {
// same number of times.
for (row, looking_locations) in &looking_multiset.0 {
let looked_locations = looked_multiset.get(row).unwrap_or(empty);
check_multiplicities(row, looking_locations, looked_locations)?;
check_multiplicities(row, looking_locations, looked_locations).map_err(|e| {
eprintln!("Looking multiset: {looking_multiset:?}");
eprintln!("Looked multiset: {looked_multiset:?}");
e
})?;
}

// Check that every row in the looked tables appears in the looking table the
// same number of times.
for (row, looked_locations) in &looked_multiset.0 {
let looking_locations = looking_multiset.get(row).unwrap_or(empty);
check_multiplicities(row, looking_locations, looked_locations)?;
check_multiplicities(row, looking_locations, looked_locations).map_err(|e| {
eprintln!("Looking multiset: {looking_multiset:?}");
eprintln!("Looked multiset: {looked_multiset:?}");
e
})?;
}

Ok(())
Expand Down

0 comments on commit c245aaa

Please sign in to comment.