pub struct TableBuilder<'a, F: TowerField = B128> { /* private fields */ }
Implementations§
Source§impl<'a, F: TowerField> TableBuilder<'a, F>
impl<'a, F: TowerField> TableBuilder<'a, F>
Sourcepub fn require_power_of_two_size(&mut self)
pub fn require_power_of_two_size(&mut self)
Declares that the table’s size must be a power of two.
The table’s size is decided by the prover, but it must be a power of two.
§Pre-conditions
This cannot be called if Self::require_power_of_two_size
or
Self::require_fixed_size
has already been called.
Sourcepub fn require_fixed_size(&mut self, log_size: usize)
pub fn require_fixed_size(&mut self, log_size: usize)
Declares that the table’s size must be a fixed power of two.
§Pre-conditions
This cannot be called if Self::require_power_of_two_size
or
Self::require_fixed_size
has already been called.
Sourcepub fn with_namespace(
&mut self,
namespace: impl ToString,
) -> TableBuilder<'_, F>
pub fn with_namespace( &mut self, namespace: impl ToString, ) -> TableBuilder<'_, F>
Returns a new TableBuilder
with the specified namespace.
A namespace is a prefix that will be prepended to all column names and zero constraints created by this builder. The new namespace is nested within the current builder’s namespace (if any exists). When nesting namespaces, they are joined with “::” separators, creating a hierarchical naming structure.
§Note
This method doesn’t modify the original builder. It returns a new builder that shares the underlying table but has its own namespace configuration that builds upon the original builder’s namespace.
§Examples
let mut table = Table::<B128>::new(0, "table");
let mut tb = TableBuilder::new(&mut table);
// Create a builder with namespace "arithmetic"
let mut arithmetic_tb = tb.with_namespace("arithmetic");
let add_col: Col<B128> = arithmetic_tb.add_committed("add"); // Column name: "arithmetic::add"
// Create a nested namespace "arithmetic::mul"
let mut mul_tb = arithmetic_tb.with_namespace("mul");
let result_col: Col<B128> = mul_tb.add_committed("result"); // Column name: "arithmetic::mul::result"
pub fn add_committed<FSub, const VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
) -> Col<FSub, VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_committed_multiple<FSub, const VALUES_PER_ROW: usize, const N: usize>(
&mut self,
name: impl ToString,
) -> [Col<FSub, VALUES_PER_ROW>; N]where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_shifted<FSub, const VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, VALUES_PER_ROW>,
log_block_size: usize,
offset: usize,
variant: ShiftVariant,
) -> Col<FSub, VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_packed<FSubSub, const VALUES_PER_ROW_SUB: usize, FSub, const VALUES_PER_ROW: usize>( &mut self, name: impl ToString, col: Col<FSubSub, VALUES_PER_ROW_SUB>, ) -> Col<FSub, VALUES_PER_ROW>
Sourcepub fn add_computed<FSub, const V: usize>(
&mut self,
name: impl ToString + Clone,
expr: Expr<FSub, V>,
) -> Col<FSub, V>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_computed<FSub, const V: usize>(
&mut self,
name: impl ToString + Clone,
expr: Expr<FSub, V>,
) -> Col<FSub, V>where
FSub: TowerField,
F: ExtensionField<FSub>,
Adds a derived column that is computed as an expression over other columns in the table.
The derived column has the same vertical stacking factor as the input columns and its values are computed independently. The cost of the column’s evaluations are proportional to the polynomial degree of the expression. When the expression is linear, the column’s cost is minimal. When the expression is non-linear, the column is committed and the expression is asserted to be zero against the committed column.
Sourcepub fn add_selected<FSub, const V: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, V>,
index: usize,
) -> Col<FSub, 1>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_selected<FSub, const V: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, V>,
index: usize,
) -> Col<FSub, 1>where
FSub: TowerField,
F: ExtensionField<FSub>,
Add a derived column that selects a single value from a vertically stacked column.
The virtual column is derived from another column in the table passed as col
, which we’ll
call the “inner” column. The inner column has V
values vertically stacked per table cell.
The index
is in the range 0..V
, and it selects the index
-th value from the inner
column.
Sourcepub fn add_selected_block<FSub, const V: usize, const NEW_V: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, V>,
index: usize,
) -> Col<FSub, NEW_V>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_selected_block<FSub, const V: usize, const NEW_V: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, V>,
index: usize,
) -> Col<FSub, NEW_V>where
FSub: TowerField,
F: ExtensionField<FSub>,
Add a derived column that selects a subrange of values from a vertically stacked column.
The virtual column is derived from another column in the table passed as col
, which we’ll
call the “inner” column. The inner column has V
values vertically stacked per table cell.
The index
is in the range 0..(V - NEW_V)
, and it selects the values
(i * NEW_V)..((i + 1) * NEW_V)
from the inner column.
Sourcepub fn add_zero_pad_upcast<FSub, const VALUES_PER_ROW: usize, const NEW_VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, VALUES_PER_ROW>,
) -> Col<FSub, NEW_VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_zero_pad_upcast<FSub, const VALUES_PER_ROW: usize, const NEW_VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, VALUES_PER_ROW>,
) -> Col<FSub, NEW_VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
Given the representation at a tower level FSub (with VALUES_PER_ROW
variables),
returns the representation at a higher tower level F (with NEW_VALUES_PER_ROW
variables)
by left padding each FSub element with zeroes.
Sourcepub fn add_zero_pad<FSub, const VALUES_PER_ROW: usize, const NEW_VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, VALUES_PER_ROW>,
nonzero_index: usize,
) -> Col<FSub, NEW_VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_zero_pad<FSub, const VALUES_PER_ROW: usize, const NEW_VALUES_PER_ROW: usize>(
&mut self,
name: impl ToString,
col: Col<FSub, VALUES_PER_ROW>,
nonzero_index: usize,
) -> Col<FSub, NEW_VALUES_PER_ROW>where
FSub: TowerField,
F: ExtensionField<FSub>,
Given the representation at a tower level FSub (with VALUES_PER_ROW
variables),
returns the representation at a higher tower level F (with NEW_VALUES_PER_ROW
variables).
This is done by keeping the nonzero-index
-th FSub element, and setting all the others to
0. Note that 0 <= nonzero_index < NEW_VALUES_PER_ROW / VALUES_PER_ROW
.
Sourcepub fn add_constant<FSub, const V: usize>(
&mut self,
name: impl ToString,
constants: [FSub; V],
) -> Col<FSub, V>where
FSub: TowerField,
F: ExtensionField<FSub>,
OptimalUnderlier: PackScalar<FSub> + PackScalar<F>,
pub fn add_constant<FSub, const V: usize>(
&mut self,
name: impl ToString,
constants: [FSub; V],
) -> Col<FSub, V>where
FSub: TowerField,
F: ExtensionField<FSub>,
OptimalUnderlier: PackScalar<FSub> + PackScalar<F>,
Adds a column to the table with a constant cell value.
The cell is repeated for each row in the table, but the values stacked vertically within the cell are not necessarily all equal.
Sourcepub fn add_static_exp<FExpBase>(
&mut self,
name: impl ToString,
pow_bits: &[Col<B1>],
base: FExpBase,
) -> Col<FExpBase>where
FExpBase: TowerField,
F: ExtensionField<FExpBase>,
pub fn add_static_exp<FExpBase>(
&mut self,
name: impl ToString,
pow_bits: &[Col<B1>],
base: FExpBase,
) -> Col<FExpBase>where
FExpBase: TowerField,
F: ExtensionField<FExpBase>,
Adds field exponentiation column with a fixed base
§Parameters
name
: Name for the columnpow_bits
: The bits of exponent columns from LSB to MSBbase
: The base to exponentiate. The field used in exponentiation will beFSub
§Preconditions
pow_bits.len()
must be less than or equal to the width of the fieldFSub
§NOTE
- The witness generation for the return column will be done inside gkr_gpa *
Sourcepub fn add_dynamic_exp<FExpBase>(
&mut self,
name: impl ToString,
pow_bits: &[Col<B1>],
base: Col<FExpBase>,
) -> Col<FExpBase>where
FExpBase: TowerField,
F: ExtensionField<FExpBase>,
pub fn add_dynamic_exp<FExpBase>(
&mut self,
name: impl ToString,
pow_bits: &[Col<B1>],
base: Col<FExpBase>,
) -> Col<FExpBase>where
FExpBase: TowerField,
F: ExtensionField<FExpBase>,
Adds field exponentiation column with a base from another column
§Parameters
name
: Name for the columnpow_bits
: The bits of exponent columns from LSB to MSBbase
: The column of base to exponentiate. The field used in exponentiation will beFSub
§Preconditions
pow_bits.len()
must be less than or equal to the width of fieldFSub
§NOTE
- The witness generation for the return column will be done inside gkr_gpa *
Sourcepub fn add_structured<FSub>(
&mut self,
name: impl ToString,
variant: StructuredDynSize,
) -> Col<FSub>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_structured<FSub>(
&mut self,
name: impl ToString,
variant: StructuredDynSize,
) -> Col<FSub>where
FSub: TowerField,
F: ExtensionField<FSub>,
Add a structured column to a table.
A structured column is one that has sufficient structure that its multilinear extension
can be evaluated succinctly. See StructuredDynSize
for more information.
Sourcepub fn add_fixed<FSub>(
&mut self,
name: impl ToString,
expr: ArithCircuit<F>,
) -> Col<FSub>where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn add_fixed<FSub>(
&mut self,
name: impl ToString,
expr: ArithCircuit<F>,
) -> Col<FSub>where
FSub: TowerField,
F: ExtensionField<FSub>,
Add a structured fixed-size column to a table.
Sourcepub fn assert_zero<FSub, const V: usize>(
&mut self,
name: impl ToString,
expr: Expr<FSub, V>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn assert_zero<FSub, const V: usize>(
&mut self,
name: impl ToString,
expr: Expr<FSub, V>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
Constrains that an expression computed over the table columns is zero.
The zero constraint applies to all values stacked vertically within the column cells. That
means that the expression is evaluated independently V
times per row, and each evaluation
in the stack must be zero.
Sourcepub fn assert_nonzero<FSub, const V: usize>(&mut self, expr: Col<FSub, V>)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn assert_nonzero<FSub, const V: usize>(&mut self, expr: Col<FSub, V>)where
FSub: TowerField,
F: ExtensionField<FSub>,
Constrains that all values contained in this column are non-zero.
pub fn pull<FSub>(
&mut self,
channel: ChannelId,
cols: impl IntoIterator<Item = Col<FSub>>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn push<FSub>(
&mut self,
channel: ChannelId,
cols: impl IntoIterator<Item = Col<FSub>>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn pull_with_opts<FSub>(
&mut self,
channel: ChannelId,
cols: impl IntoIterator<Item = Col<FSub>>,
opts: FlushOpts,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn push_with_opts<FSub>(
&mut self,
channel: ChannelId,
cols: impl IntoIterator<Item = Col<FSub>>,
opts: FlushOpts,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
Sourcepub fn read<FSub, const V: usize>(
&mut self,
lookup_chan: ChannelId,
cols: impl IntoIterator<Item = Col<FSub, V>>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
pub fn read<FSub, const V: usize>(
&mut self,
lookup_chan: ChannelId,
cols: impl IntoIterator<Item = Col<FSub, V>>,
)where
FSub: TowerField,
F: ExtensionField<FSub>,
Reads a group of columns from a specified lookup table.
This method enforces that the values of the provided columns are obtained from a lookup table through the specified lookup channel. The lookup channel identifies the target table for retrieving values.
§Parameters
lookup_chan
: The channel ID that specifies the lookup table through which the values will be constrained.cols
: An iterable of columns (Col
) that will be constrained based on the lookup values.
§Type Parameters
FSub
: The field type used for the column values.V
: The number of stacked values (vertical stacking factor) per cell of each column.
Trait Implementations§
Auto Trait Implementations§
impl<'a, F> Freeze for TableBuilder<'a, F>
impl<'a, F = BinaryField128b> !RefUnwindSafe for TableBuilder<'a, F>
impl<'a, F> Send for TableBuilder<'a, F>
impl<'a, F> Sync for TableBuilder<'a, F>
impl<'a, F> Unpin for TableBuilder<'a, F>
impl<'a, F = BinaryField128b> !UnwindSafe for TableBuilder<'a, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more