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

Add tasks 1.5-1.9,1.11 to Distinguishing Unitaries Kata #1572

Merged
merged 49 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b0e8b68
Merge branch 'main' of github.com:microsoft/qsharp
Mar 26, 2024
f2ec252
Merge branch 'main' of github.com:microsoft/qsharp
Apr 12, 2024
43580e7
Merge branch 'main' of github.com:microsoft/qsharp
Apr 23, 2024
ca6f894
Merge branch 'main' of github.com:microsoft/qsharp
May 17, 2024
bcdb0f7
add the I or Z kata
May 17, 2024
97e12fa
add katas 1.3 and 1.4
May 20, 2024
e40d8ae
Update katas/content/distinguishing_unitaries/i_z/index.md
jkingdon-ms May 21, 2024
2cbdc99
Update katas/content/distinguishing_unitaries/i_z/solution.md
jkingdon-ms May 21, 2024
dbff3d8
Update katas/content/distinguishing_unitaries/i_z/solution.md
jkingdon-ms May 21, 2024
371eb8d
Update katas/content/distinguishing_unitaries/i_z/solution.md
jkingdon-ms May 21, 2024
e1ace83
Update katas/content/distinguishing_unitaries/h_x/index.md
jkingdon-ms May 21, 2024
8315eb9
Update katas/content/distinguishing_unitaries/h_x/Solution.qs
jkingdon-ms May 21, 2024
418479c
Update katas/content/distinguishing_unitaries/h_x/solution.md
jkingdon-ms May 21, 2024
c118a55
ket instead of rangle, use new doc link
May 21, 2024
ad7df00
Merge branch 'katas/du-12-13-14' of github.com:jkingdon-ms/qsharp int…
May 21, 2024
e76278f
add katas
May 24, 2024
6e7daf0
Merge branch 'main' of github.com:microsoft/qsharp into katas/du-15-1…
May 24, 2024
f7a58a4
remainder 1.x katas
May 28, 2024
1268f8e
add distinguish paulis reference
May 28, 2024
6c9dba7
method and folder renaming
May 30, 2024
7905e87
Revert "method and folder renaming"
May 30, 2024
193d5e7
Update katas/content/distinguishing_unitaries/index.md
jkingdon-ms May 30, 2024
1e53a2b
Update katas/content/distinguishing_unitaries/z_mz/Solution.qs
jkingdon-ms May 30, 2024
b64760a
Update katas/content/distinguishing_unitaries/z_mz/solution.md
jkingdon-ms May 30, 2024
98bdfdc
Update katas/content/distinguishing_unitaries/rz_ry/index.md
jkingdon-ms May 30, 2024
cca8cb7
Update katas/content/distinguishing_unitaries/rz_ry/Solution.qs
jkingdon-ms May 30, 2024
d562093
Update katas/content/distinguishing_unitaries/i_x_y_z/solution.md
jkingdon-ms May 30, 2024
35a898b
Update katas/content/distinguishing_unitaries/i_x_y_z/solution.md
jkingdon-ms May 30, 2024
6107f7e
Merge branch 'katas/du-15-16-17-18-19-111' of github.com:jkingdon-ms/…
May 30, 2024
95f9e13
Revert "Revert "method and folder renaming""
May 30, 2024
ce2c3d6
Revert "Revert "Revert "method and folder renaming"""
May 30, 2024
244f175
Update katas/content/distinguishing_unitaries/z_mz/solution.md
jkingdon-ms May 30, 2024
ad52597
Update katas/content/distinguishing_unitaries/rz_r1/Placeholder.qs
jkingdon-ms May 30, 2024
9050885
Update katas/content/distinguishing_unitaries/rz_r1/Placeholder.qs
jkingdon-ms May 30, 2024
b8965e1
Update katas/content/distinguishing_unitaries/Common.qs
jkingdon-ms May 30, 2024
6941dd0
Update katas/content/distinguishing_unitaries/Common.qs
jkingdon-ms May 30, 2024
03166ce
Update katas/content/distinguishing_unitaries/rz_r1/index.md
jkingdon-ms May 30, 2024
c3e7de5
Update katas/content/distinguishing_unitaries/rz_r1/index.md
jkingdon-ms May 30, 2024
41d123a
Update katas/content/distinguishing_unitaries/rz_r1/index.md
jkingdon-ms May 30, 2024
a5fd987
Update katas/content/distinguishing_unitaries/rz_ry/Placeholder.qs
jkingdon-ms May 30, 2024
1d81110
Update katas/content/distinguishing_unitaries/y_xz/Solution.qs
jkingdon-ms May 30, 2024
2d63fbd
Update katas/content/distinguishing_unitaries/y_xz_my_mxz/Solution.qs
jkingdon-ms May 30, 2024
2ff5c91
misc pr suggestions
May 30, 2024
af96f5b
Merge branch 'katas/du-15-16-17-18-19-111' of github.com:jkingdon-ms/…
May 30, 2024
f266562
"method and folder renaming"
May 30, 2024
afd5b56
adjust y or xz with phases kata solution to account for global phase
May 30, 2024
f611326
remove from index.json
May 30, 2024
2425e38
swap unitary input order in Verification of y or xz with phases, reve…
May 30, 2024
2748b2c
move reminder to problem description for rz/r1 kata
May 30, 2024
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
29 changes: 29 additions & 0 deletions katas/content/distinguishing_unitaries/Common.qs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Kata.Verification {
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Random;

// "Framework" operation for testing tasks for distinguishing unitaries
Expand Down Expand Up @@ -58,4 +59,32 @@ namespace Kata.Verification {
Message("Correct!");
true
}

operation MinusZ (q : Qubit) : Unit is Adj + Ctl {
within {
X(q);
}
apply {
Z(q);
}
}

operation XZ (q : Qubit) : Unit is Adj + Ctl {
Z(q);
X(q);
}

operation MinusY (q : Qubit) : Unit is Adj + Ctl {
within {
X(q);
}
apply {
Y(q);
}
}

operation MinusXZ (q : Qubit) : Unit is Adj + Ctl {
X(q);
Z(q);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishHX (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishHfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
Expand Down
2 changes: 1 addition & 1 deletion katas/content/distinguishing_unitaries/h_x/Solution.qs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishHX (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishHfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
use q = Qubit();
within {
unitary(q);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Kata.Verification {

@EntryPoint()
operation CheckSolution() : Bool {
DistinguishUnitaries_Framework([H, X], Kata.DistinguishHX, ["H", "X"], 1)
DistinguishUnitaries_Framework([H, X], Kata.DistinguishHfromX, ["H", "X"], 1)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishIX (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishIfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
Expand Down
2 changes: 1 addition & 1 deletion katas/content/distinguishing_unitaries/i_x/Solution.qs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishIX (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishIfromX(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
use q = Qubit();
unitary(q);
return MResetZ(q) == Zero ? 0 | 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Kata.Verification {

@EntryPoint()
operation CheckSolution() : Bool {
DistinguishUnitaries_Framework([I, X], Kata.DistinguishIX, ["I", "X"], 1)
DistinguishUnitaries_Framework([I, X], Kata.DistinguishIfromX, ["I", "X"], 1)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Kata {
operation DistinguishPaulis (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
}
}
17 changes: 17 additions & 0 deletions katas/content/distinguishing_unitaries/i_x_y_z/Solution.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Kata {
operation DistinguishPaulis (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// apply operation to the 1st qubit of a Bell state and measure in Bell basis
use qs = Qubit[2];
within {
H(qs[0]);
CNOT(qs[0], qs[1]);
} apply {
unitary(qs[0]);
}

// after this I -> 00, X -> 01, Y -> 11, Z -> 10
let ind = MeasureInteger(qs);
let returnValues = [0, 3, 1, 2];
return returnValues[ind];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Kata.Verification {
open Microsoft.Quantum.Katas;

@EntryPoint()
operation CheckSolution() : Bool {
DistinguishUnitaries_Framework([I, X, Y, Z], Kata.DistinguishPaulis, ["I", "X", "Y", "Z"], 1)
}
}
11 changes: 11 additions & 0 deletions katas/content/distinguishing_unitaries/i_x_y_z/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**Input:** An operation that implements a single-qubit unitary transformation:
either the identity ($I$ gate) or one of the Pauli gates ($X$, $Y$ or $Z$ gate).

**Output:**
* 0 if the given operation is the $I$ gate,
* 1 if the given operation is the $X$ gate,
* 2 if the given operation is the $Y$ gate,
* 3 if the given operation is the $Z$ gate.

The operation will have Adjoint and Controlled variants defined.
You are allowed to apply the given operation and its adjoint/controlled variants exactly **once**.
11 changes: 11 additions & 0 deletions katas/content/distinguishing_unitaries/i_x_y_z/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This task is quite different from the previous tasks in this section;
at the first glance it might seem impossible to distinguish four different unitaries (i.e., get two bits of information) with just one unitary application!

However, since the unitaries were chosen carefully (and you're not limited in the number of measurements you can do), it is possible.
The solution uses the Bell states: the four orthogonal states which you can prepare by starting with the first of them $\frac{1}{\sqrt2}(\ket{00} + \ket{11})$ and applying the gates $I$, $X$, $Z$ and $Y$, respectively, to the first qubit.
Thus the solution becomes: prepare the $\frac{1}{\sqrt2}(\ket{00} + \ket{11})$ state, apply the unitary and measure the resulting state in Bell basis to figure out which of the Bell states it is. See the Distinguish Quantum States kata, task 'Distinguish Four Bell states' for the details on how to do that.

@[solution]({
"id": "distinguishing_unitaries__i_x_y_z_solution",
"codePath": "Solution.qs"
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishIZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishIfromZ(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
Expand Down
2 changes: 1 addition & 1 deletion katas/content/distinguishing_unitaries/i_z/Solution.qs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Kata {
operation DistinguishIZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
operation DistinguishIfromZ(unitary : (Qubit => Unit is Adj + Ctl)) : Int {
use q = Qubit();
H(q);
unitary(q);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace Kata.Verification {

@EntryPoint()
operation CheckSolution() : Bool {
DistinguishUnitaries_Framework([I, Z], Kata.DistinguishIZ, ["I", "Z"], 1)
DistinguishUnitaries_Framework([I, Z], Kata.DistinguishIfromZ, ["I", "Z"], 1)
}
}
60 changes: 60 additions & 0 deletions katas/content/distinguishing_unitaries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,66 @@ This kata offers you a series of tasks in which you are given one unitary from t
]
})

@[exercise]({
"id": "distinguishing_unitaries__z_minusz",
"title": "Z or -Z?",
"path": "./z_minusz/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[exercise]({
"id": "distinguishing_unitaries__rz_r1",
"title": "Rz or R1?",
"path": "./rz_r1/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[exercise]({
"id": "distinguishing_unitaries__y_xz",
"title": "Y or XZ?",
"path": "./y_xz/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[exercise]({
"id": "distinguishing_unitaries__y_xz_minusy_minusxz",
"title": "Y or XZ or -Y or -XZ?",
"path": "./y_xz_minusy_minusxz/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[exercise]({
"id": "distinguishing_unitaries__i_x_y_z",
"title": "Distinguish Four Pauli Unitaries",
"path": "./i_x_y_z/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[exercise]({
jkingdon-ms marked this conversation as resolved.
Show resolved Hide resolved
"id": "distinguishing_unitaries__rz_ry",
"title": "Rz or Ry?",
"path": "./rz_ry/",
"qsDependencies": [
"../KatasLibrary.qs",
"./Common.qs"
]
})

@[section]({
"id": "distinguishing_unitaries__multi_qubit",
"title": "Distinguishing Multi-Qubit Gates"
Expand Down
9 changes: 9 additions & 0 deletions katas/content/distinguishing_unitaries/rz_r1/Placeholder.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Kata {
open Microsoft.Quantum.Math;

operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
}
}
9 changes: 9 additions & 0 deletions katas/content/distinguishing_unitaries/rz_r1/Solution.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Kata {
open Microsoft.Quantum.Math;
operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj+Ctl)) : Int {
use qs = Qubit[2];
H(qs[0]);
Controlled unitary(qs[0..0], (2.0 * PI(), qs[1]));
return MResetX(qs[0]) == Zero ? 1 | 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Kata.Verification {
open Microsoft.Quantum.Katas;

@EntryPoint()
operation CheckSolution() : Bool {
DistinguishUnitaries_Framework([Rz, R1], Kata.DistinguishRzFromR1, ["Rz", "R1"], 1)
}
}
12 changes: 12 additions & 0 deletions katas/content/distinguishing_unitaries/rz_r1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**Input:** An operation that implements a single-qubit unitary transformation:
either the [$R_z$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz) or the [$R1$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/r1).

This operation will take two parameters: the first parameter is the rotation angle, in radians, and the second parameter is the qubit to which the gate should be applied (matching normal `Rz` and `R1` gates in Q#).

> As a reminder, $$R_z(\theta) = \begin{bmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{bmatrix} \text{, }
R_1(\theta) = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix} = e^{i\theta/2} R_z(\theta)$$

**Output:** 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R1$ gate.

The operation will have Adjoint and Controlled variants defined.
You are allowed to apply the given operation and its adjoint/controlled variants exactly **once**.
9 changes: 9 additions & 0 deletions katas/content/distinguishing_unitaries/rz_r1/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
We see that these two gates differ by a global phase $e^{i\theta/2}$.
In this problem we're free to choose the angle parameter which we'll pass to our gate, so we can choose an angle that make this global phase difference something easy to detect: for $\theta = 2\pi$ $e^{i\theta/2} = -1$, so $R_z(\theta) = -I$, and $R_1(\theta) = I$.

Now we need to distinguish $I$ gate from $-I$ gate, which can be done using controlled variant of the gate in exactly the same way as distinguishing $Z$ gate from $-Z$ gate in the task 'Z or -Z'.

@[solution]({
"id": "distinguishing_unitaries__rz_r1_solution",
"codePath": "Solution.qs"
})
10 changes: 10 additions & 0 deletions katas/content/distinguishing_unitaries/rz_ry/Placeholder.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Kata {
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Math;
jkingdon-ms marked this conversation as resolved.
Show resolved Hide resolved

operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
}
}
38 changes: 38 additions & 0 deletions katas/content/distinguishing_unitaries/rz_ry/Solution.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Kata {
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Math;

function ComputeRepetitions(angle : Double, offset : Int, accuracy : Double) : Int {
mutable pifactor = 0;
while (true) {
let pimultiple = PI() * IntAsDouble(2 * pifactor + offset);
let times = Round(pimultiple / angle);
if AbsD(pimultiple - (IntAsDouble(times) * angle)) / PI() < accuracy {
return times;
}
set pifactor += 1;
}
return 0;
}

operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {
use q = Qubit();
let times = ComputeRepetitions(theta, 1, 0.1);
mutable attempt = 1;
mutable measuredOne = false;
repeat {
for _ in 1 .. times {
unitary(q);
}
// for Rz, we'll never venture away from |0⟩ state, so as soon as we got |1⟩ we know it's not Rz
if MResetZ(q) == One {
set measuredOne = true;
}
// if we try several times and still only get |0⟩s, chances are that it is Rz
} until (attempt == 4 or measuredOne)
fixup {
set attempt += 1;
}
return measuredOne ? 1 | 0;
}
}
14 changes: 14 additions & 0 deletions katas/content/distinguishing_unitaries/rz_ry/Verification.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Kata.Verification {
open Microsoft.Quantum.Katas;

@EntryPoint()
operation CheckSolution() : Bool {
for theta in [0.04, 0.1, 0.25, 0.31, 0.5, 0.87, 1.05, 1.41, 1.66, 1.75, 2.0, 2.16, 2.22, 2.51, 2.93, 3.0, 3.1] {
Message($"Testing theta = {theta}...");
if not DistinguishUnitaries_Framework([Rz(theta, _), Ry(theta, _)], Kata.DistinguishRzFromRy(theta, _), ["Rz", "Ry"], -1) {
return false;
}
}
return true;
}
}
15 changes: 15 additions & 0 deletions katas/content/distinguishing_unitaries/rz_ry/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**Inputs:**

1. An angle $\theta \in [0.01 \pi; 0.99 \pi]$.
2. An operation that implements a single-qubit unitary transformation:
either the [$R_z(\theta)$ gate](https://learn.microsoft.com/qsharp/api/qsharp-lang/microsoft.quantum.intrinsic/rz) or the [$R_y(\theta)$ gate](https://learn.microsoft.com/qsharp/api/qsharp/microsoft.quantum.intrinsic/ry).

> As a reminder,
>
> $$R_z(\theta) = \begin{bmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{bmatrix} \\
R_y(\theta) = \begin{bmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}$$

jkingdon-ms marked this conversation as resolved.
Show resolved Hide resolved
**Output:** 0 if the given operation is the $R_z$ gate, 1 if the given operation is the $R_y$ gate.

The operation will have Adjoint and Controlled variants defined.
You are allowed to apply the given operation and its adjoint/controlled variants **any number of times**.
10 changes: 10 additions & 0 deletions katas/content/distinguishing_unitaries/rz_ry/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The key observation here is that $R_z$ is a diagonal matrix and $R_y$ is not, so when applied to the $\ket{0}$ state, the former will leave it unchanged (with an extra phase which is not observable), and the latter will convert it to a superposition $\cos\frac{\theta}{2} \ket{0} + \sin\frac{\theta}{2} \ket{1}$. The question is, how to distinguish those two states if they are not orthogonal (and for most values of $\theta$ they will not be)?

The task description gives you a big hint: it allows you to use the given unitary unlimited number of times, which points to a probabilistic solution (as opposed to deterministic solutions in all previous problems in this kata). Apply the unitary to the $\ket{0}$ state and measure the result; if it is $\ket{1}$, the unitary must be $R_y$, otherwise you can repeat the experiment again. After several iterations of measuring $\ket{0}$ you can conclude that with high probability the unitary is $R_z$.

To reduce the number of iterations after which you make the decision, you could apply the unitary several times to bring the overall rotation angle closer to $\pi$: in case of $R_y$ gate this would allow you to rotate the state closer to the $\ket{1}$ state, so that you'd detect it with higher probability.

@[solution]({
"id": "distinguishing_unitaries__rz_ry_solution",
"codePath": "Solution.qs"
})
7 changes: 7 additions & 0 deletions katas/content/distinguishing_unitaries/y_xz/Placeholder.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Kata {
operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
// Implement your solution here...

return -1;
}
}
9 changes: 9 additions & 0 deletions katas/content/distinguishing_unitaries/y_xz/Solution.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Kata {
operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj + Ctl)) : Int {
use qs = Qubit[2];
H(qs[0]);
Controlled unitary(qs[0..0], qs[1]);
Controlled unitary(qs[0..0], qs[1]);
return MResetX(qs[0]) == Zero ? 0 | 1;
}
}
Loading
Loading