Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Add handling for sympy conditions in deferred measurement transformer

Open daxfohl opened this issue 3 years ago • 0 comments

Previously the DeferredMeasurementTransformer could only work with classical conditions of type KeyCondition (triggered iff the measurement value of that key != zero). This PR enables the transformer to work with SympyConditions (which allow arbitrary classical logic with multiple keys in the trigger) as well.

We do this by calculating the truth table of the sympy condition, and constructing a quantum control that has the same truth table for the deferred measurement circuit. This approach actually applies to not only sympy conditions, but all classical control conditions. Thus we removed the existing logic for KeyCondition transformation.

Additionally this adds a control_values reduction in the ControlledGate constructor allowing us to remove the special case logic from the transformer.

daxfohl avatar Aug 12 '22 07:08 daxfohl