binius_circuits::builder::constraint_system

Struct ConstraintSystemBuilder

Source
pub struct ConstraintSystemBuilder<'arena, U, F>{ /* private fields */ }

Implementations§

Source§

impl<'arena, U, F> ConstraintSystemBuilder<'arena, U, F>

Source

pub fn new() -> Self

Source

pub fn new_with_witness(allocator: &'arena Bump) -> Self

Source

pub fn build(self) -> Result<ConstraintSystem<F>, Error>

Source

pub fn witness(&mut self) -> Option<&mut Builder<'arena, U, F>>

Source

pub fn take_witness( &mut self, ) -> Result<MultilinearExtensionIndex<'arena, U, F>, Error>

Source

pub fn flush( &mut self, direction: FlushDirection, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleId>, )

Source

pub fn flush_with_multiplicity( &mut self, direction: FlushDirection, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleId>, multiplicity: u64, )

Source

pub fn send( &mut self, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleId>, )

Source

pub fn receive( &mut self, channel_id: ChannelId, count: usize, oracle_ids: impl IntoIterator<Item = OracleId>, )

Source

pub fn assert_zero( &mut self, oracle_ids: impl IntoIterator<Item = OracleId>, composition: ArithExpr<F>, )

Source

pub fn assert_not_zero(&mut self, oracle_id: OracleId)

Source

pub fn add_channel(&mut self) -> ChannelId

Source

pub fn add_committed( &mut self, name: impl ToString, n_vars: usize, tower_level: usize, ) -> OracleId

Source

pub fn add_committed_multiple<const N: usize>( &mut self, name: impl ToString, n_vars: usize, tower_level: usize, ) -> [OracleId; N]

Source

pub fn add_linear_combination( &mut self, name: impl ToString, n_vars: usize, inner: impl IntoIterator<Item = (OracleId, F)>, ) -> Result<OracleId, OracleError>

Source

pub fn add_linear_combination_with_offset( &mut self, name: impl ToString, n_vars: usize, offset: F, inner: impl IntoIterator<Item = (OracleId, F)>, ) -> Result<OracleId, OracleError>

Source

pub fn add_packed( &mut self, name: impl ToString, id: OracleId, log_degree: usize, ) -> Result<OracleId, OracleError>

Source

pub fn add_projected( &mut self, name: impl ToString, id: OracleId, values: Vec<F>, variant: ProjectionVariant, ) -> Result<usize, OracleError>

Source

pub fn add_repeating( &mut self, name: impl ToString, id: OracleId, log_count: usize, ) -> Result<OracleId, OracleError>

Source

pub fn add_shifted( &mut self, name: impl ToString, id: OracleId, offset: usize, block_bits: usize, variant: ShiftVariant, ) -> Result<OracleId, OracleError>

Source

pub fn add_transparent( &mut self, name: impl ToString, poly: impl MultivariatePoly<F> + 'static, ) -> Result<OracleId, OracleError>

Source

pub fn add_zero_padded( &mut self, name: impl ToString, id: OracleId, n_vars: usize, ) -> Result<OracleId, OracleError>

Source

pub fn push_namespace(&mut self, name: impl ToString)

Anything pushed to the namespace will become part of oracle name, which is useful for debugging.

Use pop_namespace(&mut self) to remove the latest name.

Example

use binius_circuits::builder::ConstraintSystemBuilder;
use binius_field::{TowerField, BinaryField128b, BinaryField1b, arch::OptimalUnderlier};

let log_size = 14;

let mut builder = ConstraintSystemBuilder::<OptimalUnderlier, BinaryField128b>::new();
builder.push_namespace("a");
let x = builder.add_committed("x", log_size, BinaryField1b::TOWER_LEVEL);
builder.push_namespace("b");
let y = builder.add_committed("y", log_size, BinaryField1b::TOWER_LEVEL);
builder.pop_namespace();
builder.pop_namespace();
let z = builder.add_committed("z", log_size, BinaryField1b::TOWER_LEVEL);

let system = builder.build().unwrap();
assert_eq!(system.oracles.oracle(x).name().unwrap(), "a::x");
assert_eq!(system.oracles.oracle(y).name().unwrap(), "a::b::y");
assert_eq!(system.oracles.oracle(z).name().unwrap(), "z");
Source

pub fn pop_namespace(&mut self)

Source

pub fn log_rows( &self, oracle_ids: impl IntoIterator<Item = OracleId>, ) -> Result<usize, Error>

Returns the number of rows shared by a set of columns.

Fails if no columns are provided, or not all columns have the same number of rows.

This is useful for writing circuits with internal columns that depend on the height of input columns.

Trait Implementations§

Source§

impl<'arena, U, F> Default for ConstraintSystemBuilder<'arena, U, F>

Source§

fn default() -> ConstraintSystemBuilder<'arena, U, F>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'arena, U, F> Freeze for ConstraintSystemBuilder<'arena, U, F>
where <F as WithUnderlier>::Underlier: Sized,

§

impl<'arena, U, F> !RefUnwindSafe for ConstraintSystemBuilder<'arena, U, F>

§

impl<'arena, U, F> !Send for ConstraintSystemBuilder<'arena, U, F>

§

impl<'arena, U, F> !Sync for ConstraintSystemBuilder<'arena, U, F>

§

impl<'arena, U, F> Unpin for ConstraintSystemBuilder<'arena, U, F>
where <F as WithUnderlier>::Underlier: Sized, F: Unpin,

§

impl<'arena, U, F> !UnwindSafe for ConstraintSystemBuilder<'arena, U, 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