Reversible Circuit Synthesis

27
Reversible Circuit Reversible Circuit Synthesis Synthesis Vivek Shende & Aditya Vivek Shende & Aditya Prasad Prasad

description

Reversible Circuit Synthesis. Vivek Shende & Aditya Prasad. Reversible Circuit Synthesis. Motivation Real-world Applications Theoretical Advantages Links to Quantum Computation Background Theoretical Results Synthesis of Optimal Circuits An Application to Quantum Computing. - PowerPoint PPT Presentation

Transcript of Reversible Circuit Synthesis

Page 1: Reversible Circuit Synthesis

Reversible Circuit Reversible Circuit SynthesisSynthesis

Vivek Shende & Aditya PrasadVivek Shende & Aditya Prasad

Page 2: Reversible Circuit Synthesis

Reversible Circuit SynthesisReversible Circuit Synthesis• MotivationMotivation

– Real-world ApplicationsReal-world Applications– Theoretical AdvantagesTheoretical Advantages– Links to Quantum ComputationLinks to Quantum Computation

• Background Background • Theoretical ResultsTheoretical Results• Synthesis of Optimal CircuitsSynthesis of Optimal Circuits• An Application to Quantum ComputingAn Application to Quantum Computing

Page 3: Reversible Circuit Synthesis

Real-world ApplicationsReal-world Applications• Digital signal processingDigital signal processing• CryptographyCryptography• Computer graphicsComputer graphics• Network congestionNetwork congestion

Page 4: Reversible Circuit Synthesis

Theoretical AdvantagesTheoretical Advantages• Information, like energy, is conserved Information, like energy, is conserved

under the laws of physicsunder the laws of physics• Thermodynamics can be used to tie the Thermodynamics can be used to tie the

irreversibility of a system to the amount of irreversibility of a system to the amount of heat it dissipatesheat it dissipates

• An energy-lossless circuit must therefore An energy-lossless circuit must therefore be information-losslessbe information-lossless

• Furthermore, there is evidence to suggest Furthermore, there is evidence to suggest that reversible circuits may be built in an that reversible circuits may be built in an energy-lossless way energy-lossless way

Page 5: Reversible Circuit Synthesis

Links to Quantum Links to Quantum ComputationComputation• Quantum operations are all reversible Quantum operations are all reversible • Every (classical) reversible circuit may Every (classical) reversible circuit may

be implemented in quantum technologybe implemented in quantum technology• Certain quantum algorithms have Certain quantum algorithms have

“pseudo-classical” subroutines, which “pseudo-classical” subroutines, which can be implemented in reversible logic can be implemented in reversible logic circuitscircuits

Page 6: Reversible Circuit Synthesis

Reversible Circuit SynthesisReversible Circuit Synthesis• MotivationMotivation• BackgroundBackground

– ReversibilityReversibility– PermutationsPermutations– Known FactsKnown Facts

• Theoretical ResultsTheoretical Results• Synthesis of Optimal CircuitsSynthesis of Optimal Circuits• An Application to Quantum ComputingAn Application to Quantum Computing

Page 7: Reversible Circuit Synthesis

Reversibility in Logic GatesReversibility in Logic Gates• A logic gate is reversible ifA logic gate is reversible if

– It has as many input as output wiresIt has as many input as output wires– It permutes the set of input valuesIt permutes the set of input values

• Some examples includeSome examples include– An inverter (the NOT gate)An inverter (the NOT gate)– A two-input, two-output gate which swaps the A two-input, two-output gate which swaps the

values on the input wires (the SWAP gate)values on the input wires (the SWAP gate)– An (n+1)-input, (n+1)-output gate which leaves An (n+1)-input, (n+1)-output gate which leaves

the first n wires unchanged, and flips the last if the first n wires unchanged, and flips the last if the first n were all 1 (the n-CNOT gate)the first n were all 1 (the n-CNOT gate)

Page 8: Reversible Circuit Synthesis

Reversibility in Logic Reversibility in Logic CircuitsCircuits• A combinational logic circuit is reversible A combinational logic circuit is reversible

if if – It contains only reversible gatesIt contains only reversible gates– It has no FANOUTIt has no FANOUT– It is acyclic (as a directed multigraph)It is acyclic (as a directed multigraph)

• It can be shown that a reversible circuit It can be shown that a reversible circuit has as many input wires as output wires, has as many input wires as output wires, and permutes the set of input valuesand permutes the set of input values

Page 9: Reversible Circuit Synthesis

A Reversible Circuit & Truth A Reversible Circuit & Truth TableTableaa bb cc aa

’’bb’’

cc’’

00 00 00 00 00 0000 00 11 00 00 0000 11 00 00 11 1100 11 11 00 11 0011 00 00 11 00 1111 00 11 11 00 0011 11 00 11 11 1111 11 11 11 11 00

Page 10: Reversible Circuit Synthesis

Reversible Circuits & Reversible Circuits & PermutationsPermutations• A reversible gate (or circuit) with n A reversible gate (or circuit) with n

inputs and n outputs has 2inputs and n outputs has 2nn possible possible input values, and the 2input values, and the 2nn possible possible output valuesoutput values

• The function it computes on this set The function it computes on this set must, by definition, be a permutationmust, by definition, be a permutation

• The set of such permutations is called The set of such permutations is called SS22nn

Page 11: Reversible Circuit Synthesis

Basic Facts About Basic Facts About PermutationsPermutations• Permutations are multiplied by first Permutations are multiplied by first

doing one, then the otherdoing one, then the other• Every permutation can be written as Every permutation can be written as

the product of “transpositions”, that the product of “transpositions”, that is, permutations which switch two is, permutations which switch two indices and leave the rest fixedindices and leave the rest fixed

Page 12: Reversible Circuit Synthesis

Even PermutationsEven Permutations• For a fixed permutation, the parity of For a fixed permutation, the parity of

the number of transpositions in such the number of transpositions in such a product is constanta product is constant

• The permutations which may be The permutations which may be written as the product of an even written as the product of an even number of transpositions are called number of transpositions are called eveneven

Page 13: Reversible Circuit Synthesis

Known FactsKnown Facts• Any reversible circuit with n+1 inputs Any reversible circuit with n+1 inputs

and n+1 outputs, built from gates which and n+1 outputs, built from gates which have at most n inputs and n outputs, have at most n inputs and n outputs, must compute an even permutationmust compute an even permutation

• Any permutation may be computed in a Any permutation may be computed in a circuit using the CNOT, NOT, and circuit using the CNOT, NOT, and TOFFOLI gates, and a sufficient amount TOFFOLI gates, and a sufficient amount of temporary storageof temporary storage

Page 14: Reversible Circuit Synthesis

Reversible Circuit SynthesisReversible Circuit Synthesis• MotivationMotivation• Background Background • Theoretical ResultsTheoretical Results

– Zero-storage CircuitsZero-storage Circuits– Reversible De Morgan’s LawsReversible De Morgan’s Laws

• Synthesis of Optimal CircuitsSynthesis of Optimal Circuits• An Application to Quantum ComputingAn Application to Quantum Computing

Page 15: Reversible Circuit Synthesis

Zero-Storage CircuitsZero-Storage Circuits• We can show that every even We can show that every even

permutation can be computed in a permutation can be computed in a circuit composed of CNOT, NOT, and circuit composed of CNOT, NOT, and TOFFOLI gates which uses no TOFFOLI gates which uses no temporary storagetemporary storage

• For an arbitrary permutation, at most For an arbitrary permutation, at most one line of temporary storage is one line of temporary storage is necessarynecessary

Page 16: Reversible Circuit Synthesis

Zero-Storage CircuitsZero-Storage Circuits• Roughly, the proof proceeds as followsRoughly, the proof proceeds as follows

– Pick an even permutation, and write it as the Pick an even permutation, and write it as the product of an even number of transpositionsproduct of an even number of transpositions

– Pair these upPair these up– Explicitly construct a circuit to compute an Explicitly construct a circuit to compute an

arbitrary transposition pairarbitrary transposition pair• The proof is constructive, and may be The proof is constructive, and may be

used as a synthesis heuristicused as a synthesis heuristic

Page 17: Reversible Circuit Synthesis

Reversible De Morgan’s Reversible De Morgan’s LawsLaws• De Morgan’s Laws allow all inverters De Morgan’s Laws allow all inverters

in an irreversible circuit to be pushed in an irreversible circuit to be pushed to the inputsto the inputs

• The same may be done for a The same may be done for a reversible circuit containing only reversible circuit containing only CNOT, NOT, and TOFFOLI gatesCNOT, NOT, and TOFFOLI gates

Page 18: Reversible Circuit Synthesis

Reversible De Morgan’s Reversible De Morgan’s LawsLaws• Similar rules exist for interchanging Similar rules exist for interchanging

TOFFOLI and CNOT gatesTOFFOLI and CNOT gates• However, it is not always possible to However, it is not always possible to

push all the CNOT gates to the inputspush all the CNOT gates to the inputs• Oddly enough, using different Oddly enough, using different

methods, it is possible to push all methods, it is possible to push all CNOT gates to the middle of the CNOT gates to the middle of the circuit!circuit!

Page 19: Reversible Circuit Synthesis

Reversible Circuit SynthesisReversible Circuit Synthesis• MotivationMotivation• Background Background • Theoretical ResultsTheoretical Results• Synthesis of Optimal CircuitsSynthesis of Optimal Circuits

– OptimalityOptimality– IDA* Search AlgorithmIDA* Search Algorithm– Circuit LibrariesCircuit Libraries

• An Application to Quantum ComputingAn Application to Quantum Computing

Page 20: Reversible Circuit Synthesis

OptimalityOptimality• The cost of a circuit is its gate countThe cost of a circuit is its gate count• A reversible circuit is optimal if no A reversible circuit is optimal if no

circuit with fewer gates computes circuit with fewer gates computes the same permutationthe same permutation

• Any sub-circuit of an optimal circuit Any sub-circuit of an optimal circuit must be optimal; otherwise, the sub-must be optimal; otherwise, the sub-optimal sub-circuit could be replaced optimal sub-circuit could be replaced with a smaller onewith a smaller one

Page 21: Reversible Circuit Synthesis

IDA* SearchIDA* Search• Checks all possible circuits of cost 1, Checks all possible circuits of cost 1,

then all possible circuits of cost 2, &c. then all possible circuits of cost 2, &c. • Avoids the memory blowup of a BFSAvoids the memory blowup of a BFS• Still finds optimal solutionsStill finds optimal solutions• Checking circuits of cost less than n Checking circuits of cost less than n

takes a small amount of time relative takes a small amount of time relative to that spent checking cost n circuitsto that spent checking cost n circuits

Page 22: Reversible Circuit Synthesis

IDA* SearchIDA* Search• Must provide a subroutine to check Must provide a subroutine to check

all circuits of cost n, for arbitrary nall circuits of cost n, for arbitrary n• Only need to check locally optimal Only need to check locally optimal

circuitscircuits

Page 23: Reversible Circuit Synthesis

Circuit LibrariesCircuit Libraries• Store small, locally optimal circuits Store small, locally optimal circuits

– Index by permutationIndex by permutation– Use STL hash_map Use STL hash_map

• Recursively build larger circuitsRecursively build larger circuits

Page 24: Reversible Circuit Synthesis

Reversible Circuit SynthesisReversible Circuit Synthesis• MotivationMotivation• Background Background • Theoretical ResultsTheoretical Results• Synthesis of Optimal CircuitsSynthesis of Optimal Circuits• An Application to Quantum ComputingAn Application to Quantum Computing

– Grover’s SearchGrover’s Search– Pseudo-classical SynthesisPseudo-classical Synthesis

Page 25: Reversible Circuit Synthesis

Grover’s SearchGrover’s Search• A quantum search algorithmA quantum search algorithm• Runs in time O(sqrt(N))Runs in time O(sqrt(N))• Requires a subroutine that changes Requires a subroutine that changes

the phase of any basis states which the phase of any basis states which match the search criteriamatch the search criteria

Page 26: Reversible Circuit Synthesis

Pseudo-classical SynthesisPseudo-classical Synthesis• Adding a qubit initialized to |0> - |1> Adding a qubit initialized to |0> - |1>

changes this into a problem in changes this into a problem in classical reversible circuit synthesisclassical reversible circuit synthesis

• This can be solved by our methodsThis can be solved by our methods

Page 27: Reversible Circuit Synthesis

Questions?Questions?