-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathSimpleBellPair.qs
35 lines (30 loc) · 1.19 KB
/
SimpleBellPair.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/// # Sample
/// Simple Bell Pair
///
/// # Description
/// Bell pairs are specific quantum states of two qubits that represent
/// the simplest (and maximal) examples of quantum entanglement. This sample
/// prepares |Φ⁺⟩ = (|00⟩+|11⟩)/√2. For other Bell states see BellState.qs
///
/// # References
/// - [Bell state](https://en.wikipedia.org/wiki/Bell_state)
operation Main() : (Result, Result) {
// Allocate the two qubits that will be used to create a Bell pair.
use q1 = Qubit();
use q2 = Qubit();
// Create Bell pair by calling `PrepareBellPair` operation defined below.
PrepareBellPair(q1, q2);
// Show the state of qubits using the `DumpMachine` function.
Std.Diagnostics.DumpMachine();
// Measure the two qubits and reset them. Return measurement results.
(MResetZ(q1), MResetZ(q2))
}
/// # Summary
/// Prepare Bell pair |Φ⁺⟩ = (|00⟩+|11⟩)/√2 on two qubits.
/// Qubits are assumed to be in |00⟩ state.
operation PrepareBellPair(q1 : Qubit, q2 : Qubit) : Unit {
// Set qubit `q1` in superposition of |0⟩ and |1⟩ by applying a Hadamard gate.
H(q1);
// Entangle the two qubits `q1` and `q2` using the `CNOT` gate.
CNOT(q1, q2);
}