Struct TableBuilder

Source
pub struct TableBuilder<'a, F: TowerField = B128> { /* private fields */ }

Implementations§

Source§

impl<'a, F: TowerField> TableBuilder<'a, F>

Source

pub fn new(table: &'a mut Table<F>) -> Self

Returns a new TableBuilder for the given table.

Source

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.

Source

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.

Source

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"
Source

pub fn id(&self) -> TableId

Returns the TableId of the underlying table.

Source

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>,

Source

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>,

Source

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>,

Source

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>
where FSub: TowerField + ExtensionField<FSubSub>, FSubSub: TowerField, F: ExtensionField<FSub>,

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 column
  • pow_bits: The bits of exponent columns from LSB to MSB
  • base: The base to exponentiate. The field used in exponentiation will be FSub
§Preconditions
  • pow_bits.len() must be less than or equal to the width of the field FSub
§NOTE
  • The witness generation for the return column will be done inside gkr_gpa *
Source

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 column
  • pow_bits: The bits of exponent columns from LSB to MSB
  • base: The column of base to exponentiate. The field used in exponentiation will be FSub
§Preconditions
  • pow_bits.len() must be less than or equal to the width of field FSub
§NOTE
  • The witness generation for the return column will be done inside gkr_gpa *
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn pull<FSub>( &mut self, channel: ChannelId, cols: impl IntoIterator<Item = Col<FSub>>, )
where FSub: TowerField, F: ExtensionField<FSub>,

Source

pub fn push<FSub>( &mut self, channel: ChannelId, cols: impl IntoIterator<Item = Col<FSub>>, )
where FSub: TowerField, F: ExtensionField<FSub>,

Source

pub fn pull_with_opts<FSub>( &mut self, channel: ChannelId, cols: impl IntoIterator<Item = Col<FSub>>, opts: FlushOpts, )
where FSub: TowerField, F: ExtensionField<FSub>,

Source

pub fn push_with_opts<FSub>( &mut self, channel: ChannelId, cols: impl IntoIterator<Item = Col<FSub>>, opts: FlushOpts, )
where FSub: TowerField, F: ExtensionField<FSub>,

Source

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§

Source§

impl<'a, F: Debug + TowerField> Debug for TableBuilder<'a, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, F> Freeze for TableBuilder<'a, F>
where <F as WithUnderlier>::Underlier: Sized,

§

impl<'a, F = BinaryField128b> !RefUnwindSafe for TableBuilder<'a, F>

§

impl<'a, F> Send for TableBuilder<'a, F>
where <F as WithUnderlier>::Underlier: Sized,

§

impl<'a, F> Sync for TableBuilder<'a, F>
where <F as WithUnderlier>::Underlier: Sized,

§

impl<'a, F> Unpin for TableBuilder<'a, F>
where <F as WithUnderlier>::Underlier: Sized,

§

impl<'a, F = BinaryField128b> !UnwindSafe for TableBuilder<'a, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,