Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formal preprocessed columns in expressions. #923

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crates/prover/src/constraint_framework/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use num_traits::{One, Zero};
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};

use super::preprocessed_columns::PreprocessedColumn;
use super::{AssertEvaluator, EvalAtRow, Relation, RelationEntry, INTERACTION_TRACE_IDX};
use crate::core::fields::cm31::CM31;
use crate::core::fields::m31::{self, BaseField};
Expand Down Expand Up @@ -912,6 +913,10 @@ impl EvalAtRow for ExprEvaluator {
intermediate
}

fn get_preprocessed_column(&mut self, column: PreprocessedColumn) -> Self::F {
BaseExpr::Param(column.name().to_string())
}

super::logup_proxy!();
}

Expand Down Expand Up @@ -1089,9 +1094,9 @@ mod tests {
let constraint_0 = ((col_1_0[0]) * (intermediate0)) * (1 / (col_1_0[0] + col_1_1[0]));

\
let constraint_1 = (SecureCol(col_2_4[0], col_2_6[0], col_2_8[0], col_2_10[0]) \
- (SecureCol(col_2_5[-1], col_2_7[-1], col_2_9[-1], col_2_11[-1]) \
- ((total_sum) * (col_0_3[0])))) \
let constraint_1 = (SecureCol(col_2_3[0], col_2_5[0], col_2_7[0], col_2_9[0]) \
- (SecureCol(col_2_4[-1], col_2_6[-1], col_2_8[-1], col_2_10[-1]) \
- ((total_sum) * (preprocessed.is_first)))) \
* (intermediate1) \
- (1);"
.to_string();
Expand Down
10 changes: 10 additions & 0 deletions crates/prover/src/constraint_framework/preprocessed_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ pub enum PreprocessedColumn {
Plonk(usize),
}

impl PreprocessedColumn {
pub const fn name(&self) -> &'static str {
match self {
PreprocessedColumn::XorTable(..) => "preprocessed.xor_table",
PreprocessedColumn::IsFirst(_) => "preprocessed.is_first",
PreprocessedColumn::Plonk(_) => "preprocessed.plonk",
}
}
}

/// Generates a column with a single one at the first position, and zeros elsewhere.
pub fn gen_is_first<B: Backend>(log_size: u32) -> CircleEvaluation<B, BaseField, BitReversedOrder> {
let mut col = Col::<B, BaseField>::zeros(1 << log_size);
Expand Down
16 changes: 8 additions & 8 deletions crates/prover/src/examples/state_machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,17 @@ mod tests {

\
let constraint_0 = (SecureCol(\
col_2_5[claimed_sum_offset], \
col_2_8[claimed_sum_offset], \
col_2_11[claimed_sum_offset], \
col_2_14[claimed_sum_offset]\
col_2_4[claimed_sum_offset], \
col_2_7[claimed_sum_offset], \
col_2_10[claimed_sum_offset], \
col_2_13[claimed_sum_offset]\
) - (claimed_sum)) \
* (col_0_2[0]);
* (preprocessed.is_first);

\
let constraint_1 = (SecureCol(col_2_3[0], col_2_6[0], col_2_9[0], col_2_12[0]) \
- (SecureCol(col_2_4[-1], col_2_7[-1], col_2_10[-1], col_2_13[-1]) \
- ((total_sum) * (col_0_2[0])))\
let constraint_1 = (SecureCol(col_2_2[0], col_2_5[0], col_2_8[0], col_2_11[0]) \
- (SecureCol(col_2_3[-1], col_2_6[-1], col_2_9[-1], col_2_12[-1]) \
- ((total_sum) * (preprocessed.is_first)))\
) \
* ((intermediate0) * (intermediate1)) \
- (intermediate1 - (intermediate0));"
Expand Down
Loading