Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of CCX in a Circuit #1685

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

ausbin
Copy link
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
19 checks passed
@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