Skip to content

Fix display of CCX in a Circuit#1685

Merged
swernli merged 1 commit into
microsoft:mainfrom
ausbin:bugfix/ccnot-circuit
Jun 30, 2024
Merged

Fix display of CCX in a Circuit#1685
swernli merged 1 commit into
microsoft:mainfrom
ausbin:bugfix/ccnot-circuit

Conversation

@ausbin
Copy link
Copy Markdown
Contributor

@ausbin ausbin commented Jun 29, 2024

A Toffoli/CCX in Q# code is currently displayed by the circuit generation code as a controlled-controlled-CNOT instead of a controlled-controlled-X.

I tried to add a test for this, but I'm not sure if I added it in the right place.

Testing

Ran cargo test and pytest (including the integration tests dependent on qir-runner and pyqir)

Also manually tested with this script:

import qsharp

qsharp.eval('''
open Microsoft.Quantum.Arrays;

operation Example() : Result[] {
    use q = Qubit[3];
    ApplyToEach(X, Most(q));
    CCNOT(q[0], q[1], q[2]);
    MResetEachZ(q)
}
''')

print(qsharp.circuit('Example()'))

which originally printed out:

q_0    ── X ──── ● ──── M ─── |0〉 ─                                                                                                                                                                               
                 │      ╘══════════
q_1    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_2    ──────── CX ──── M ─── |0〉 ─
                        ╘══════════

but now it prints out the following as expected:

q_0    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_1    ── X ──── ● ──── M ─── |0〉 ─
                 │      ╘══════════
q_2    ───────── X ──── M ─── |0〉 ─
                        ╘══════════

A CCX is currently displayed as a controlled-controlled-CNOT instead of
a controlled-controlled-X. This commit fixes this.
@swernli swernli added this pull request to the merge queue Jun 30, 2024
Merged via the queue into microsoft:main with commit 9f4920a Jun 30, 2024
@ausbin ausbin deleted the bugfix/ccnot-circuit branch June 30, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants