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
impl CircuitSimulator
Sourcepub fn check_circuit<F: AcirField>(circuit: &Circuit<F>) -> Option<usize>
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.
Sourcefn run_check_circuit<F: AcirField>(
&mut self,
circuit: &Circuit<F>,
) -> Option<usize>
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.
Sourcefn try_solve<F: AcirField>(&mut self, opcode: &Opcode<F>) -> bool
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
Sourcepub(crate) fn mark_solvable(&mut self, witness: Witness)
pub(crate) fn mark_solvable(&mut self, witness: Witness)
Adds the witness to set of solvable witness
pub fn can_solve_function_input<F: AcirField>( &self, input: &FunctionInput<F>, ) -> bool
fn can_solve_expression<F>(&self, expr: &Expression<F>) -> bool
fn can_solve_brillig_input<F>(&self, input: &BrilligInputs<F>) -> bool
pub(crate) fn expr_witness<F>( expr: &Expression<F>, ) -> impl Iterator<Item = Witness>
Trait Implementations§
Source§impl Default for CircuitSimulator
impl Default for CircuitSimulator
Source§fn default() -> CircuitSimulator
fn default() -> CircuitSimulator
Auto Trait Implementations§
impl Freeze for CircuitSimulator
impl RefUnwindSafe for CircuitSimulator
impl Send for CircuitSimulator
impl Sync for CircuitSimulator
impl Unpin for CircuitSimulator
impl UnwindSafe for CircuitSimulator
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