1 / 44

Synthesis of Reversible Logic Circuits

Synthesis of Reversible Logic Circuits. Paper by: Vivek Shende, Aditya Prasad, Igor Markov, John Hayes, 2003 Presentation by: Joshua Taylor, 2010. What and Why. [Definition 1] A reversible gate is simply one that computes a bijective function.

linore
Download Presentation

Synthesis of Reversible Logic Circuits

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Synthesis of Reversible Logic Circuits Paper by: Vivek Shende, Aditya Prasad, Igor Markov, John Hayes, 2003 Presentation by: Joshua Taylor, 2010

  2. What and Why • [Definition 1] A reversible gate is simply one that computes a bijective function. • This means that there are exactly as many output bits as input bits. • A gate with k inputs and k outputs is called a k×k gate, or a gate on k wires.

  3. What and Why • Some reversible functions have been implemented in hardware: • Bit permutations speed up some common algorithms • Matrix transposition • Twofish cryptography • Butterfly function (x, y)->(x+y, x-y) • Important in fast Fourier transforms • Quantum computers can only compute reversible functions

  4. CNOT gates • [Definition 2] A k-CNOT gate is a (k+1)×(k+1) gate that leaves the first k inputs unchanged and inverts the last if and only if all the others are 1. • The 0-CNOT gate is just NOT • The 1-CNOT gate is simple called CNOT or the Controlled-NOT gate • Computes the function (x, y)->(x, x XOR y) • The 2-CNOT gate is normally called the TOFFOLI gate • Sometimes called the Controlled-Controlled-NOT gate

  5. Gates • This paper only deals with the NOT, CNOT and TOFFOLI gates, plus the SWAP gate. • In quantum computers, swapping qubits is non-trivial • SWAP and CNOT are redundant, but offer important speed ups and other reductions

  6. Reversible Circuits • [Definition 3] A reversible circuit is a circuit composed of reversible gates with no fan-out. • Feynman’s notation:

  7. Constructible circuits • [Definition 4] Given a library, L, of reversible gates, a permutation of the numbers [0..2n] is L-constructible if it can be computed by a n×n circuit of gates from L. • For example, CNOT applied to lines 0 (the control) and 1 of a three line circuit swaps the inputs 001 and 011, and the inputs 101 and 111. • We write this using the cycle notation as (1 3)(5 7) • Therefore, (1 3)(5 7) is a C-constructible circuit • Permutation, function and circuit are used almost interchangeably.

  8. Libraries • The C, N, T and S libraries consist of just the CNOT, NOT, TOFFOLI and SWAP gates respectively. • The CNTS library contains all four. • Similarly with the CNT, NT, etc. libraries.

  9. Universality • [Definition 5] A library, L, is universal if for all k, and all permutations, π, on [0..2k], then there exists some L-constructible function that computes π using some number of wires of temporary storage. • No constant signals • Multiple output bits

  10. Temporary Storage • Temporary storage wires must end with the same value. • Toffoli showed that the CNT library is universal using at most n-3 lines of temporary storage. • Most literature allows polynomial bounds on temporary storage. • Qubits are expensive, so less is better • This paper tries to use no temporary storage • The C gate can be replaced by two Ts and two Ns using one line of temporary storage

  11. Linearity • [Definition 6] A boolean function, f, is linear if and only if f(x XOR y) = f(x) XOR f(y). • Equivalent to the usual definition of linearity over the finite field F2. • f can be thought of as a square boolean matrix.

  12. C-constructible functions • [Lemma 7] Every C-constructible permutation computes an invertible linear transformation, and every invertible linear transformation is C-constructible. Also, no C-constructible circuit requires more than n2 gates. • A C gate performs an elementary row addition on the matrix. Any invertible boolean matrix can be written as a product of these, and can be row-reduced to the identity matrix using at most n2 operations.

  13. Worse case size • [Lemma 8] Given a library, L, let Kn be the L-constructible circuits on n wires. The longest gate-minimal L-circuit on n wires has more than log ||Kn|| / log b gates, where b in the number of one gate circuits on n wires. • Proved using a counting argument.

  14. Counting C-constructible circuits • [Corollary 9] There are Π(2n-2i), for 0 ≤ i ≤ n-1, C-constructible permutations on n wires. • Any linear function is fully defined by its action on the basis vectors. There are 2n-1 ways of mapping the first basis vector, 2n-2 ways for the second, and so on. • Therefore, worst case C-circuits require Ω(n2 / log n) gates.

  15. Even permutations • [Definition 10] An even permutation is one that can be written as a product of an even number of transpositions (2-cycles). • (1 3 2) = (1 2)(2 3) • Even and odd permutations are very similar to even and odd numbers.

  16. Even permutations • [Lemma 11] Any n×n circuit with no n×n gates computes an even permutation. • With only one gate on fewer than n wires, at least one line must be unaffected. Therefore, the cycles it computes appears in pairs. (1 3)(5 7), for example. The product of a pair of even or a pair of odd permutations is even. • Any circuit is the product of the permutations of its gates, and the product of any number of even permutations is even. • The CNTS library contains no gates of size greater than 3.

  17. Even permutations • [Theorem 12] Every even permutation is CNT-constructible. • Proof will have to wait. • [Corollary 13] Every permutation is CNT-constructible with at most one line of temporary storage. • Adding an extra line doubles all cycles, making any permutation even.

  18. Constructible permutations • [Corollary 14] Any universal library L can construct any permutation above a certain number of wires can be constructed with at most one wire of temporary storage. • Since L is universal, it can simulate the CNT library.

  19. N-constructible circuits • [Definition 15] Ni is the circuit formed by placing a NOT gate on each wire corresponding to the 1s in the binary expansion of i. • Ni computes the function x XOR i. • [Lemma 16] The set of Ni over n wires is the set of N-constructible functions on n wires. • Two NOTs cancel out, leaving any N-constructible function with at most one N per wire, which is one of the Ni functions.

  20. T-constructible permutations • [Definition 17] Let Nkh, such that h AND k = 0, be the circuit consisting of q-CNOT gates, where q is the number of 1s in k, with the controls of all gates specified by the 1s in k, and the inverters of each gate specified by h. • Nkh computes Nh when all of the lines specified by k are 1.

  21. T-constructible permutations • [Lemma 18] Every T-circuit fixes 0 and 2i for all i. • No T gate can affect any input with fewer than 2 active lines. • Also, T-circuits can construct only even permutations on more than 3 lines (without temporary storage).

  22. T-constructible permutations • [Lemma 19] For n > 4, any even permutation can be written as a product of pairs of disjoin transpositions (such as (1 2)(3 4)) using at most k+1 transpositions for a permutation that moves k indices. • Math heavy proof.

  23. T-constructible permutations • [Lemma 20] On n wires, the permutation (2n-4 2n-3)(2n-2 2n-1) is T-constructible with 8(n-5) T gates. • Proved in a previous paper by someone else.

  24. T-constructible permutations • [Lemma 21] Suppose n >3, and • 0 < a,b,c,d < 2n, and none of a, b, c or d is a power of 2. Then (a b)(c d) is T-constructible. • Long, complicated construction.

  25. T-constructible permutations • [Theorem 22] Every T-constructible permutation fixes 0 and powers of 2 and is even if n > 3. Conversely, every permutation of this form is T-constructible with at most 3(k + 1)(3n – 7) gates, where k is the number of indices moved. There are (1/2)(2n - n - 1)! such permutations on n wires. • Proof combines several previous lemmas.

  26. Commutators • [Definition 25] The commutator of permutations P and Q, written [P,Q], is defined as PQP-1Q-1. • Commutators are useful in moving gates around, since PQ = [P,Q]QP • [Definition 23], [Lemma 24], [Corollary 26] and [Lemma 27] show how to build commutators, but the details of this aren’t important.

  27. CT|N- and T|C- constructible permutations • [Definition 28] For libraries L1, …, Lk, a L1|…|Lk circuit is a L1 circuit followed by an L2 circuit, etc.

  28. CT|N- and T|C- constructible permutations • [Thoerem 29] Let π be CNT-constructible. Then π is also CT|N-constructible and uniquely determines the permutations πCT and πN. • Proof uses the commutators from before to show how to move an N gate past the other kinds of gates. • Also, this process only introduces a polynomial number of extra gates. • Since a CT-circuit fixes 0, we can compute πN easily, and then find a circuit for πCT.

  29. CT|N- and T|C- constructible permutations • [Lemma 30] An even permutation is T|C-constructible if and only if it fixes 0 and the images of the powers of 2 are linearly independent. Also, πT and πC are uniquely determined. • The T subcircuit can’t affect the basis vectors, so that specifies the C subcircuit, which specifies the T circuit. • This also works in reverse.

  30. T|C|T|N-constructible permutations • [Theorem 31] Every zero-fixing permutation on 3 wires and every even zero-fixing permutation on 4 or more wires is T|C|T-constructible. None requires more than n2 C gates and 3(2n + n + 1)(3n – 7) T gates. • Complicated proof.

  31. T|C|T|N-constructible permutations • [Corollary 32] There exists T|C|T-constructible permutations that are not T|C constructible. • (2 6)(4 7) is even and fixes 0, so it is T|C|T-constructible for any number of wires greater than 3. • But, π(1) XOR π(2) = 1 XOR 6 = 7 = π(4), so the powers of two are not linearly independent, so it is not T|C-constructible.

  32. T|C|T|N-constructible permutations • [Theorem 33] Every permutation on n ≤ 3 wires and every even permutation on n > 3 wires is T|C|T|N-constructible, and therefore CNT-constructible, finally proving Theorem 12. • Using π(0), πNπ(0) fixes 0, and so is T|C|T-constructible. Applying Nπ(0) to this produces a T|C|T|N-circuit that computes π. • The truth table for a n×n circuit is n2n bits, and the run-time to generate a circuit using this procedure is proportional to the number of gates which is also n2n, so the procedure has a linear run time. • It might not produce the best circuit though.

  33. T|C|T|N-constructible permutations • [Corollary 34] Worst case CNT-circuits on n wires require Ω(n2n / log n) gates. • This follows from Lemma 8. • This means that the above construction is off by at most a factor of log n.

  34. Optimal synthesis • [Lemma 35 (Property of Optimality)] If A is an optimal circuit, then any subcircuit is also optimal. • Otherwise, we could replace that subcircuit with a better one. • This allows us to build a library of small optimal circuits and build bigger ones by combining them.

  35. Optimal synthesis • The algorithm works by computing bigger and bigger circuits until memory starts to run out, then uses iterative deepening depth first search to find bigger circuits, until one is found that computes the desired permutation. • For each circuit in the library of small circuits, it can divide the desired permutation by that circuit and then use recursion to find the rest.

  36. Optimal synthesis of 3-wire circuits

  37. Optimal synthesis • The running time depends on the gate library chosen, but for the CNTS library, it’s at least doubly exponential in the number of wires, or exponential in the size of the truth table. • This limits its use to small problems, but since current quantum computers are limited to around 10 qubits, this is still of interest.

  38. Quantum applications • Quantum computation is necessarily reversible. • Most quantum gate libraries are combinations of classic reversible gates and a few quantum-specific gates such as the Hadamard gate. • The Hadamard gate is a one-qubit gate that “rotates” the state an eighth of a turn.

  39. Quantum applications • Grover’s algorithm can solve an uniformed search problem faster than any known classical algorithm. • The algorithm needs an oracle function that applies a search-specific predicate function, f(x). The oracle function transforms |x> to (-1)f(x)|x>.

  40. Quantum applications • [Lemma 36] With one additional qubit of temporary storage, the synthesis of an oracle circuit can be reduced to the synthesis of a classical reversible circuit. • Compute πf as the function (x, y) -> (x, y XOR f(x)) • Use that to create a quantum operator that carries out this permutation and apply that to |x,H|1>>, which gives |(-1)f(x)x, H|1>>

  41. Quantum applications • [Corollary 37] If πf is even, Grover’s algorithm is computable with only one extra qubit of storage. Two if it’s odd. • Qubits are expensive so this is a good thing. • Optimal circuit sizes for 3 input, 1 output circuits on 4 wires:

  42. Quantum applications • [Lemma 38] There is a reversible 2-bit ROM-based CNT-circuit that computes(x, a, b) -> (x, a, b XOR f(x)), where x is a k-bit input. • A ROM-based circuit is one where the values of the read-only bits cannot be changed even in the intermediate steps. In the above, a and b can change, even though a must end up back where it started.

  43. Conclusions • Reversible logic circuits are an important area of research especially in quantum computing. • They have some nice properties that makes synthesizing them somewhat easier than the general case of n×n boolean circuits. • While most papers are only concerned with keeping the temporary storage polynomial, this paper shows that any permutation can be calculated with only one line of temporary storage, and that Grover’s algorithm only needs two writable qubits.

  44. Questions?

More Related