Struct CircuitSimulator

Source
pub struct CircuitSimulator {
    solvable_witnesses: HashSet<Witness>,
    initialized_blocks: HashSet<BlockId>,
}
Expand description

Simulate solving a circuit symbolically Instead of evaluating witness values from the inputs, like the PWG module is doing, this pass simply marks the witness that can be evaluated, from the known inputs, and incrementally from the previously marked witnesses. This avoids any computation on a big field which makes the process efficient. When all the witness of an opcode are marked as solvable, it means that the opcode is solvable.

Fields§

§solvable_witnesses: HashSet<Witness>

Track the witnesses that can be solved

§initialized_blocks: HashSet<BlockId>

Track whether a [BlockId] has been initialized

Implementations§

Source§

impl CircuitSimulator

Source

pub fn check_circuit<F: AcirField>(circuit: &Circuit<F>) -> Option<usize>

Check whether the circuit is solvable in theory.

§Returns

Returns None if the circuit is deemed to be solvable Otherwise returns Some(index) where index is the opcode index of the first unsolvable opcode.

Source

fn run_check_circuit<F: AcirField>( &mut self, circuit: &Circuit<F>, ) -> Option<usize>

Simulate solving a circuit symbolically by keeping track of the witnesses that can be solved. Returns the index of an opcode that cannot be solved, if any.

Source

fn try_solve<F: AcirField>(&mut self, opcode: &Opcode<F>) -> bool

Check if the Opcode can be solved, and if yes, add the solved witness to set of solvable witness

Source

pub(crate) fn mark_solvable(&mut self, witness: Witness)

Adds the witness to set of solvable witness

Source

pub fn can_solve_function_input<F: AcirField>( &self, input: &FunctionInput<F>, ) -> bool

Source

fn can_solve_expression<F>(&self, expr: &Expression<F>) -> bool

Source

fn can_solve_brillig_input<F>(&self, input: &BrilligInputs<F>) -> bool

Source

pub(crate) fn expr_witness<F>( expr: &Expression<F>, ) -> impl Iterator<Item = Witness>

Trait Implementations§

Source§

impl Default for CircuitSimulator

Source§

fn default() -> CircuitSimulator

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

Auto Trait Implementations§

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