assign_to_circuit_optimize_and_dedup

Function assign_to_circuit_optimize_and_dedup 

Source
pub fn assign_to_circuit_optimize_and_dedup<T>(
    circuit: &Circuit<T>,
    inputs: impl IntoIterator<Item = (T, bool)>,
    seq: bool,
) -> (Circuit<T>, Vec<OutputEntry<T>>, Vec<OutputEntry<T>>)
Expand description

Assigns inputs to circuit, deduplicate and optimize circuit.

WARNING: This function is not completely tested. It should be used enough carefully.

Generates circuit that calculates outputs as original circuit with assigned inputs (if assume circuit input have specified value). inputs iterator is list of circuit input (input indices) to assign. The entry of list is pair of circit input index and its value to assign. Function while asigning values to inputs reduces circuit and their inputs and outputs if needed. A function doesn’t optimize circuit.

A seq argument choose type of conversion from clause circuit to Gate circuit - choose between sequential or parallel conversion from clause to gates.

Returned circuit is optimized and deduplicated: reduce any gate that can be replaced by single wire and evaluate trees of gates to single value including same outputs and find duplicates of gates and tree of gates and reduce them. Function converts circuit into ClauseCircuit and call optimize_and_dedup_clause_circuit.

Function returns assigned circuit, list of mapping of original circuit inputs and list of mapping original circuit outputs. Both lists contains OutputEntry that it is NewIndex if circuit input or circuit output is stored in new index or have Value if circuit input is assigned or circuit outputs are calculated to value. An entry Index from list is original index of circuit input or circuit output.