Function tally

Source
pub fn tally<P>(
    cs: &ConstraintSystem<B128>,
    witness: &mut WitnessIndex<'_, '_, P>,
    boundaries: &[Boundary<B128>],
    chan: ChannelId,
    indexed_lookup: &impl IndexedLookup<B128>,
) -> Result<Vec<u32>, Error>
Expand description

Determine the read counts of each entry in an indexed lookup table.

Before a lookup table witness can be filled, the number of times each entry is read must be known. Reads from indexed lookup tables are a special case where the counts are difficult to track during emulation, because the use of the lookup tables is an arithmetization detail. For example, emulation of the system model should not need to know whether integer additions within a table are constraint using zero constraints or a lookup table for the limbs. In most cases of practical interest, the lookup table is indexed.

The method to tally counts is to scan all tables in the constraint system and boundaries values, and identify those that pull from the lookup table’s channel. Then we iterate over the values read from the table and count all the indices.

§Returns

A vector of counts, whose length is equal to 1 << indexed_lookup.log_size().