Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

update tests for basic gates #300

Merged
merged 6 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions BasicGates/BasicGates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
"source": [
"%kata T201_TwoQubitGate1_Test\n",
"\n",
"operation TwoQubitGate1 (qs : Qubit[]) : Unit is Adj {\n",
"operation TwoQubitGate1 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
"}"
]
Expand Down Expand Up @@ -424,7 +424,7 @@
"source": [
"%kata T202_TwoQubitGate2_Test\n",
"\n",
"operation TwoQubitGate2 (qs : Qubit[]) : Unit is Adj {\n",
"operation TwoQubitGate2 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
"}"
]
Expand All @@ -451,7 +451,7 @@
"source": [
"%kata T203_TwoQubitGate3_Test\n",
"\n",
"operation TwoQubitGate3 (qs : Qubit[]) : Unit is Adj {\n",
"operation TwoQubitGate3 (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
"}"
]
Expand All @@ -476,7 +476,7 @@
"source": [
"%kata T204_ToffoliGate_Test\n",
"\n",
"operation ToffoliGate (qs : Qubit[]) : Unit is Adj {\n",
"operation ToffoliGate (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
"}"
]
Expand All @@ -501,7 +501,7 @@
"source": [
"%kata T205_FredkinGate_Test\n",
"\n",
"operation FredkinGate (qs : Qubit[]) : Unit is Adj {\n",
"operation FredkinGate (qs : Qubit[]) : Unit is Adj+Ctl {\n",
" // ...\n",
"}"
]
Expand Down
10 changes: 5 additions & 5 deletions BasicGates/ReferenceImplementation.qs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace Quantum.Kata.BasicGates {
// Note that unless the starting state of the first qubit was |0⟩ or |1⟩,
// the resulting two-qubit state can not be represented as a tensor product
// of the states of individual qubits any longer; thus the qubits become entangled.
operation TwoQubitGate1_Reference (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate1_Reference (qs : Qubit[]) : Unit is Adj+Ctl {
CNOT(qs[0], qs[1]);
}

Expand All @@ -140,7 +140,7 @@ namespace Quantum.Kata.BasicGates {
// Goal: Change the two-qubit state to (|00⟩ + |01⟩ + |10⟩ - |11⟩) / 2.
// Note that while the starting state can be represented as a tensor product of single-qubit states,
// the resulting two-qubit state can not be represented in such a way.
operation TwoQubitGate2_Reference (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate2_Reference (qs : Qubit[]) : Unit is Adj+Ctl {
Controlled Z([qs[0]], qs[1]);
// alternatively: CZ(qs[0], qs[1]);
}
Expand All @@ -149,7 +149,7 @@ namespace Quantum.Kata.BasicGates {
// Input: Two qubits (stored in an array of length 2) in an arbitrary
// two-qubit state α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩.
// Goal: Change the two-qubit state to α|00⟩ + γ|01⟩ + β|10⟩ + δ|11⟩.
operation TwoQubitGate3_Reference (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate3_Reference (qs : Qubit[]) : Unit is Adj+Ctl {
// Hint: this task can be solved using one intrinsic gate;
// as an exercise, try to express the solution using several controlled Pauli gates.
CNOT(qs[0], qs[1]);
Expand All @@ -164,7 +164,7 @@ namespace Quantum.Kata.BasicGates {
// Goal: Flip the state of the third qubit if the state of the first two is |11⟩:
// i.e., change the three-qubit state to
// α|000⟩ + β|001⟩ + γ|010⟩ + δ|011⟩ + ε|100⟩ + ζ|101⟩ + θ|110⟩ + η|111⟩.
operation ToffoliGate_Reference (qs : Qubit[]) : Unit is Adj {
operation ToffoliGate_Reference (qs : Qubit[]) : Unit is Adj+Ctl {
CCNOT(qs[0], qs[1], qs[2]);
// alternatively (Controlled X)(qs[0..1], qs[2]);
}
Expand All @@ -175,7 +175,7 @@ namespace Quantum.Kata.BasicGates {
// Goal: Swap the states of second and third qubit if and only if the state of the first qubit is |1⟩:
// i.e., change the three-qubit state to
// α|000⟩ + β|001⟩ + γ|010⟩ + δ|011⟩ + ε|100⟩ + η|101⟩ + ζ|110⟩ + θ|111⟩.
operation FredkinGate_Reference (qs : Qubit[]) : Unit is Adj {
operation FredkinGate_Reference (qs : Qubit[]) : Unit is Adj+Ctl {
Controlled SWAP([qs[0]], (qs[1], qs[2]));
}

Expand Down
10 changes: 5 additions & 5 deletions BasicGates/Tasks.qs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace Quantum.Kata.BasicGates {
// Note that unless the starting state of the first qubit was |0⟩ or |1⟩,
// the resulting two-qubit state can not be represented as a tensor product
// of the states of individual qubits any longer; thus the qubits become entangled.
operation TwoQubitGate1 (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate1 (qs : Qubit[]) : Unit is Adj+Ctl {
// ...
}

Expand All @@ -173,7 +173,7 @@ namespace Quantum.Kata.BasicGates {
// Goal: Change the two-qubit state to (|00⟩ + |01⟩ + |10⟩ - |11⟩) / 2.
// Note that while the starting state can be represented as a tensor product of single-qubit states,
// the resulting two-qubit state can not be represented in such a way.
operation TwoQubitGate2 (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate2 (qs : Qubit[]) : Unit is Adj+Ctl {
// ...
}

Expand All @@ -182,7 +182,7 @@ namespace Quantum.Kata.BasicGates {
// Input: Two qubits (stored in an array of length 2) in an arbitrary
// two-qubit state α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩.
// Goal: Change the two-qubit state to α|00⟩ + γ|01⟩ + β|10⟩ + δ|11⟩.
operation TwoQubitGate3 (qs : Qubit[]) : Unit is Adj {
operation TwoQubitGate3 (qs : Qubit[]) : Unit is Adj+Ctl {
// Hint: this task can be solved using one intrinsic gate;
// as an exercise, try to express the solution using several
// (possibly controlled) Pauli gates.
Expand All @@ -196,7 +196,7 @@ namespace Quantum.Kata.BasicGates {
// Goal: Flip the state of the third qubit if the state of the first two is |11⟩:
// i.e., change the three-qubit state to
// α|000⟩ + β|001⟩ + γ|010⟩ + δ|011⟩ + ε|100⟩ + ζ|101⟩ + θ|110⟩ + η|111⟩.
operation ToffoliGate (qs : Qubit[]) : Unit is Adj {
operation ToffoliGate (qs : Qubit[]) : Unit is Adj+Ctl {
// ...
}

Expand All @@ -206,7 +206,7 @@ namespace Quantum.Kata.BasicGates {
// α|000⟩ + β|001⟩ + γ|010⟩ + δ|011⟩ + ε|100⟩ + ζ|101⟩ + η|110⟩ + θ|111⟩.
// Goal: Swap the states of second and third qubit if and only if the state of the first qubit is |1⟩:
// α|000⟩ + β|001⟩ + γ|010⟩ + δ|011⟩ + ε|100⟩ + η|101⟩ + ζ|110⟩ + θ|111⟩.
operation FredkinGate (qs : Qubit[]) : Unit is Adj {
operation FredkinGate (qs : Qubit[]) : Unit is Adj+Ctl {
// ...
}

Expand Down
Loading