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

Commit 1b01733

Browse files
authored
Remove example, replace with TeleportChain (#1190)
1 parent e6c06a3 commit 1b01733

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

examples/QIR/Emission/Program.qs

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,40 @@
11
namespace Microsoft.Quantum.Qir.Emission {
2-
32
open Microsoft.Quantum.Intrinsic;
4-
open Microsoft.Quantum.Math;
5-
6-
operation Prepare(target : Qubit) : Unit {
7-
H(target);
3+
open Microsoft.Quantum.Canon;
4+
open Microsoft.Quantum.Arrays;
5+
open Microsoft.Quantum.Measurement;
6+
open Microsoft.Quantum.Preparation;
7+
8+
operation PrepareEntangledPair(left : Qubit, right : Qubit) : Unit is Adj + Ctl {
9+
H(left);
10+
CNOT(left, right);
811
}
912

10-
operation Iterate(time : Double, theta : Double, target : Qubit) : Result {
13+
operation ApplyCorrection(src : Qubit, intermediary : Qubit, dest : Qubit) : Unit {
14+
if (MResetZ(src) == One) { Z(dest); }
15+
if (MResetZ(intermediary) == One) { X(dest); }
16+
}
1117

12-
use aux = Qubit();
13-
within {
14-
H(aux);
15-
} apply {
16-
Rz(-theta * time, aux);
17-
Controlled Rz([aux], (PI() * time, target));
18-
}
19-
return M(aux);
18+
operation TeleportQubitUsingPresharedEntanglement(src : Qubit, intermediary : Qubit, dest : Qubit) : Unit {
19+
Adjoint PrepareEntangledPair(src, intermediary);
20+
ApplyCorrection(src, intermediary, dest);
2021
}
2122

2223
@EntryPoint()
23-
operation EstimatePhaseByRandomWalk(nrIter : Int) : Double {
24-
25-
mutable mu = 0.7951;
26-
mutable sigma = 0.6065;
27-
28-
use target = Qubit();
29-
Prepare(target);
30-
31-
for _ in 1 .. nrIter {
32-
33-
let theta = mu - PI() * sigma / 2.0;
34-
let time = 1.0 / sigma;
24+
operation DemonstrateTeleportationUsingPresharedEntanglement() : Bool {
25+
let nPairs = 2;
26+
use (leftMessage, rightMessage, leftPreshared, rightPreshared) = (Qubit(), Qubit(), Qubit[nPairs], Qubit[nPairs]);
27+
PrepareEntangledPair(leftMessage, rightMessage);
28+
for i in 0..nPairs-1 {
29+
PrepareEntangledPair(leftPreshared[i], rightPreshared[i]);
30+
}
3531

36-
let datum = Iterate(time, theta, target);
37-
38-
set mu = datum == Zero
39-
? mu - sigma * 0.6065
40-
| mu + sigma * 0.6065;
41-
set sigma *= 0.7951;
32+
TeleportQubitUsingPresharedEntanglement(rightMessage, leftPreshared[0], rightPreshared[0]);
33+
for i in 1..nPairs-1 {
34+
TeleportQubitUsingPresharedEntanglement(rightPreshared[i-1], leftPreshared[i], rightPreshared[i]);
4235
}
43-
return mu;
36+
37+
return MResetZ(leftMessage) == MResetZ(rightPreshared[nPairs-1]);
4438
}
4539
}
4640

0 commit comments

Comments
 (0)