Page 36 - MSDN Magazine, September 2019
P. 36

EncodeMessageInQubit accepts two Bool values that represent the 2 bits of information to be sent to Bob. The first let statement concatenates the pair of bit values into an integer between 002 and 112, with bit1 occupying the high bit. The resulting bit sequence indicates the correct gate or gates to apply.
Q# supports many of the language features present in C# and F#. Conveniently, that includes binary literals.
After Alice encodes her message and sends her qubit to Bob, Bob receives the message and applies a CNOT gate to the qubits, and the Hadamard gate to Alice’s qubit:
operation DecodeMessageFromQubits (bobQubit : Qubit, aliceQubit : Qubit) : (Bool, Bool)
{
Bit1 Bit2
Gates Bell State
00 01 10 11
I |Φ+〉= |0A0B+|1A1B〉 √2
X |Ψ+〉= |1A0B+|0A1B〉 √2
Z |Φ–〉= |0A0B–|1A1B〉 √2
X,Z |Ψ–〉= |1A0B–|0A1B〉 √2
Figure 2 Gates Used to Produce Bell States
The CNOT gate inverts qubit2 if the state of qubit1 is |1〉,
CNOT(aliceQubit, bobQubit); H(aliceQubit);
return (M(aliceQubit) == One, M(bobQubit) == One);
Each qubit is then measured. The result is a tuple consisting of the two original message bits sent by Alice. The measured values of each qubit correspond to the classical bit message encoded by Alice.
Let’s look more closely at how this superdense coding proto- col works. Recall that both Alice and Bob are each given a qubit belonging to an entangled pair. The matrix representation of the quantum state of the two qubits is given by:
resulting in the |Ф+〉 state: + |00〉 + |11〉
}
|Ф〉= √2
The state of the qubits when measured will have a 50 percent chance of being either 00 or 11.
With this superposition created, if you were to measure just one of the qubits, it would cause the other’s state to collapse to the same value, regardless of the distance between the qubits. The qubits are said to be entangled.
Once Alice and Bob have each been sent one qubit from an entan- gled pair, Alice can affect the overall quantum state of the two qubits by simply manipulating her own qubit. A single qubit can encode only 1 bit of information. But when entangled with another qubit, that qubit can be used by itself to encode 2 bits of information into the shared quantum state.
Alice is able to transmit 2 bits of information by passing her qubit through one or more gates. The gates and resulting quantum state of the pair of qubits are shown in Figure 2. The subscript on the qubits identifies the owner: A for Alice, B for Bob.
In quantum mechanics, the only perfectly distinguishable states are those that are orthogonal.
Sending a 2-bit message of 00 requires no change to Alice’s qubit (“I” is the identity gate, which does nothing). Sending 01 or 10 requires a single gate: X or Z, respectively; and sending 11 requires the application of both an X and a Z gate.
In quantum mechanics, the only perfectly distinguishable states are those that are orthogonal. For qubits, these are states that are perpendicular on the Bloch sphere. It so happens that the Bell states are orthogonal, so when it comes time for Bob to measure the qubits, he can perform an orthogonal measurement on the two qubits to derive Alice’s original 2-bit message.
To encode Alice’s qubit, it’s sent to the EncodeMessageInQubit Q# operation, as shown in Figure 3. Along with Alice’s qubit,
1
|00〉 + |11〉 [] = 1 0
CNOT|(H|0〉U|0〉) =
I’ll use this matrix result in a moment to demonstrate the encoding process.
If Alice wishes to send the message 012 to Bob, she applies the X gate to her own qubit, which changes the quantum state to:
|Ψ〉 = (X|0〉U|0〉) + (X|1〉U|1〉) √2
= (|1〉U|0〉) + (|0〉U|1〉) √2
= |10〉 + |01〉 √2
Figure 3 EncodeMessageInQubit Operation
√2 √20 1
operation EncodeMessageInQubit(
aliceQubit : Qubit, bit1 : Bool, bit2 : Bool) : Unit
{
let bits = (bit1 ? 1 | 0) * 2 + (bit2 ? 1 | 0);
if (bits == 0b00)
{ I(aliceQubit);
}
elif (bits == 0b01)
{ X(aliceQubit);
}
elif (bits == 0b10)
{ Z(aliceQubit);
}
elif (bits == 0b11)
{ X(aliceQubit);
Z(aliceQubit); }
}
28 msdn magazine
Quantum Computing


































































































   34   35   36   37   38