Skip to content

Commit

Permalink
fix AirContext::num_constraint_composition_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Feb 29, 2024
1 parent dee9c05 commit b8b7afa
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions air/src/air/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,24 +244,26 @@ impl<B: StarkField> AirContext<B> {
/// Returns the number of columns needed to store the constraint composition polynomial.
///
/// This is the maximum of:
/// 1. The maximum evaluation degree over all transition constraints minus the degree
/// of the transition constraint divisor divided by trace length.
/// 1. The maximum evaluation degree over all transition constraints minus the degree of the
/// transition constraint divisor divided by trace length.
/// 2. `1`, because the constraint composition polynomial requires at least one column.
///
/// Since the degree of a constraint `C(x)` can be well approximated by
/// `[constraint.base + constraint.cycles.len()] * [trace_length - 1]` the degree of the
/// constraint composition polynomial can be approximated by:
/// `([constraint.base + constraint.cycles.len()] * [trace_length - 1] - [trace_length - n])`
/// where `constraint` is the constraint attaining the maximum and `n` is the number of
/// exemption points.
/// In the case `n = 1`, the expression simplifies to:
/// `[constraint.base + constraint.cycles.len() - 1] * [trace_length - 1]`
/// Thus, if each column is of length `trace_length`, we would need
/// `[constraint.base + constraint.cycles.len() - 1]` columns to store the coefficients of
/// the constraint composition polynomial.
/// This means that if the highest constraint degree is equal to `5`, the constraint
/// composition polynomial will require four columns and if the highest constraint degree is
/// equal to `7`, it will require six columns to store.
/// Since the degree of a constraint `C(x)` can be computed as `[constraint.base +
/// constraint.cycles.len()] * [trace_length - 1]` the degree of the constraint composition
/// polynomial can be computed as: `([constraint.base + constraint.cycles.len()] * [trace_length
/// - 1] - [trace_length - n])` where `constraint` is the constraint attaining the maximum and
/// `n` is the number of exemption points. In the case `n = 1`, the expression simplifies to:
/// `[constraint.base + constraint.cycles.len() - 1] * [trace_length - 1]` Thus, if each column
/// is of length `trace_length`, we would need `[constraint.base + constraint.cycles.len() - 1]`
/// columns to store the coefficients of the constraint composition polynomial. This means that
/// if the highest constraint degree is equal to `5`, the constraint composition polynomial will
/// require four columns and if the highest constraint degree is equal to `7`, it will require
/// six columns to store.
///
/// Note that the Lagrange kernel constraints all require only 1 column, since the degree of the
/// numerator is `trace_len - 1` for all transition constraints (i.e. the base degree is 1).
/// Hence, no matter what the degree of the divisor is for each, it can only bring this degree
/// down, which is already less than `trace_len`.
pub fn num_constraint_composition_columns(&self) -> usize {
let mut highest_constraint_degree = 0_usize;
for degree in self
Expand All @@ -282,12 +284,7 @@ impl<B: StarkField> AirContext<B> {
(highest_constraint_degree - transition_divisior_degree + trace_length - 1)
/ trace_length;

// FIXME: This is a hack to make the test pass; implement properly.
if self.trace_info.lagrange_kernel_aux_column_idx().is_some() {
2
} else {
cmp::max(num_constraint_col, 1)
}
cmp::max(num_constraint_col, 1)
}

// DATA MUTATORS
Expand Down

0 comments on commit b8b7afa

Please sign in to comment.