Japanese
言語
English
Japanese
Spanish

注釈

このページは docs/tutorials/chsh_with_estimator.ipynb から生成されました。

Estimator primitiveを用いたCHSH不等式の破れの証明

このチュートリアルでは、Estimator primitive を用いてCHSH不等式の破れを実証する実験を量子コンピューターで行います。

The violation of the CHSH inequality is used to show that quantum mechanics is incompatible with local hidden-variable theories. This is an important experiment for understanding the foundation of quantum mechanics. The 2022 Nobel Prize for Physics was awarded to Alain Aspect, John Clauser and Anton Zeilinger in part for their pioneering work in quantum information science, and in particular, their experiments with entangled photons demonstrating violation of Bell’s inequalities. An experimental method by which one can test Bell’s inequality was put forth by Clauser, Horne, Shimony, and Holt (CHSH) in 1969, and forms the basis for the experiment conducted here. It’s truly incredible that you can use Qiskit and an IBM Quantum system to conduct this experiment from the comfort of your home!

背景情報

CHSH不等式

CHSH不等式は、著者であるClauser、Horne、Shimony、Holt にちなんで名付けられ、ベルの定理を実験的に証明するために使用されています。この定理は、局所的な隠れた変数理論は量子力学におけるエンタングルメントのいくつかの結果を説明できないと主張するものです。

この実験では、量子もつれのペアを作り、それぞれの量子ビットを2つの異なる基底で測定します。第一量子ビットの基底を \(A\)\(a\) 、第二量子ビットの基底を \(B\)\(b\) とラベル付けします。これにより、CHSH量 \(S_1\) を計算することができます。

\[S_1 = A(B-b) + a(B+b).\]

各オブザーバブルは \(+1\) または \(-1\) のいずれかです。 明らかに、項 \(B\pm b\) の 1 つは 0 でなければならず、もう 1 つは \(\pm 2\) でなければなりません。 したがって、 \(S_1 = \pm 2\) です。 \(S_1\) の平均値は次の不等式を満たさなければなりません。

\[|\langle S_1 \rangle|\leq 2.\]

\(S_1\)\(A\)\(a\)\(B\)\(b\) で展開すると、次のようになります。

\[|\langle S_1 \rangle| = |\langle AB \rangle - \langle Ab \rangle + \langle aB \rangle + \langle ab \rangle| \leq 2\]

別の CHSH 量 \(S_2\) を定義できます。

\[S_2 = A(B+b) - a(B-b),\]

これは、別の不等式につながります。

\[|\langle S_2 \rangle| = |\langle AB \rangle + \langle Ab \rangle - \langle aB \rangle + \langle ab \rangle| \leq 2\]

もし、量子力学が局所的な隠れた変数理論で記述できるのであれば、上記の不等式は成立するはずです。しかし、このノートで示すように、量子コンピューターではこの不等式が破られる可能性があります。従って、量子力学は局所的な隠れた変数理論とは相容れません。

もっと詳しく知りたい方は、 Qiskitテキストブック にあるCHSH不等式についての章を読んでみてください。

概要

ベル状態 \(|\Phi^+\rangle = \frac{|00\rangle + |11\rangle}{\sqrt{2}}\) を作成することで、量子コンピューターの 2量子ビット間にエンタングルのペアを作成します。 Estimator primitive を使用すると、必要な期待値 (\(\langle AB \rangle, \langle Ab \rangle, \langle aB \rangle\), \(\langle ab \rangle\)) を直接取得して、 \(\langle S_1\rangle\)\(\langle S_2\rangle\) の 2 つの CHSH量の期待値を計算します。Estimator primitive を導入する前は、測定結果から期待値を構築する必要がありました。

\(Z\) および \(X\) 基底で 2 番目の量子ビットを測定します。 最初の量子ビットも直交基底で測定されますが、2 番目の量子ビットに対して角度があり、\(0\) から \(2\pi\) の間でスイープします。 ご覧のとおり、Estimator primitive により、パラメーター化された回路の実行が非常に簡単になります。 一連の CHSH 回路を作成する代わりに、測定角度を指定するパラメーターとパラメーターの一連の位相の値を使用して 1つ の CHSH 回路を作成するだけで済みます。

最後に、結果を分析し、測定角度に対してプロットします。 測定角度の特定の範囲で、CHSH 量の期待値 が \(|\langle S_1\rangle| > 2\) または \(|\langle S_2\rangle| > 2\) であることがわかります。これは、CHSH 不等式の破れを示しています。

注記

この不等式の破れで、局所性や実在性が否定されたと主張するためには、いくつかの抜け穴を塞がなければならないことを、専門家のために言及しておく必要があります。議論については、Qiskitテキストブック の CHSH の章の最後の段落( “Exercise” の項の直前)を参照してください。

Setup

[1]:
# General
import numpy as np

# Qiskit imports
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
from qiskit.quantum_info import SparsePauliOp

# Runtime imports
from qiskit_ibm_runtime import QiskitRuntimeService, Estimator

# Plotting routines
import matplotlib.pyplot as plt
import matplotlib.ticker as tck

Qiskit Runtime サービスに接続する

Before running circuits, you need to connect to the Qiskit Runtime service instance, and select a target backend:

[2]:
service = QiskitRuntimeService()
backend = service.get_backend("ibm_sherbrooke")

ステップ1:CHSH回路の作成

パラメーター化されたCHSH回路を作成する

まず、パラメータ \(\theta\)theta と呼ぶことにして、回路を書きます。Estimator primitiveは、観測値の期待値を直接提供することにより、回路の構築と出力の解析を非常に簡単に行うことができます。多くの興味深い問題、特にノイズのあるシステムを使う近未来のアプリケーションは、期待値で定式化できます。最大限の一般化を図るため、Estimator primitive は測定のない回路が必要です。

[3]:
theta = Parameter("$\\theta$")

chsh_circuit_no_meas = QuantumCircuit(2)
chsh_circuit_no_meas.h(0)
chsh_circuit_no_meas.cx(0, 1)
chsh_circuit_no_meas.ry(theta, 0)
chsh_circuit_no_meas.draw("mpl")
[3]:
../_images/tutorials_chsh_with_estimator_11_0.png

後で割り当てる位相の値のリストを作成する

パラメーター化された CHSH 回路を作成したら、次の手順で回路に割り当てる位相の値のリストを作成します。 以下のコードを使用して、等間隔、つまり \(0\), \(0.1 \pi\), \(0.2 \pi\), …, \(1.9 \pi\), \(2 \pi\)\(0\) から \(2 \pi\) までの範囲の 21 の位相の値のリストを作成します。

[4]:
number_of_phases = 21
phases = np.linspace(0, 2 * np.pi, number_of_phases)
# Phases need to be expressed as list of lists in order to work
individual_phases = [[ph] for ph in phases]

Observables

次に、期待値を計算するためのオブザーバブルが必要です。 私たちの場合、各量子ビットの直交基底を見て、最初の量子ビットのパラメーター化された \(Y-\) 回転が、2 番目の量子ビットの基底に関してほぼ連続的に測定基底をスイープするようにします。 したがって、オブザーバブル \(ZZ\), \(ZX\), \(XZ\), \(XX\) を選択することにします。

[8]:
ZZ = SparsePauliOp.from_list([("ZZ", 1)])
ZX = SparsePauliOp.from_list([("ZX", 1)])
XZ = SparsePauliOp.from_list([("XZ", 1)])
XX = SparsePauliOp.from_list([("XX", 1)])

ops = [ZZ, ZX, XZ, XX]
num_ops = len(ops)

ステップ2: 回路をクラウド上の量子コンピューターに送信する

In order to execute the entire experiment in one call to the Estimator we need to batch the circuit and operators together, repeating each for the requested number_of_phases points.

[9]:
batch_circuits = [chsh_circuit_no_meas] * number_of_phases * num_ops
batch_ops = [op for op in ops for _ in individual_phases]

We can now create an Estimator instance using our selected backend, and execute our batched circuits and observables:

[10]:
estimator = Estimator(backend)

batch_expvals = (
    estimator.run(
        batch_circuits, batch_ops, parameter_values=individual_phases * num_ops, shots=int(1e4)
    )
    .result()
    .values
)

The individual expectation values can then be extracted from the batched results:

[11]:
ZZ_expval, ZX_expval, XZ_expval, XX_expval = [
    batch_expvals[kk * number_of_phases : (kk + 1) * number_of_phases] for kk in range(num_ops)
]

ステップ 3: 結果の分析

回路を実行した後、CHSH 証人関数を構築する必要があります。 最初に、構築した 4 つの回路群(2つの量子ビットに2つの測定基底)の結果のパリティーを調べることによって、量 \(\langle AB \rangle\), \(\langle Ab \rangle\), \(\langle aB \rangle\), \(\langle ab \rangle\) を構築します。 次に、これらの量を使用して、以前に定義した証人関数を構築します。

[12]:
# <CHSH1> = <AB> - <Ab> + <aB> + <ab>
chsh1_est = ZZ_expval - ZX_expval + XZ_expval + XX_expval

# <CHSH2> = <AB> + <Ab> - <aB> + <ab>
chsh2_est = ZZ_expval + ZX_expval - XZ_expval + XX_expval

観測値が返されるので、自分たちで観測値を作る必要がないことに注意してください。計算された期待値は result.values で与えられます。返ってくるのは非常に小さなデータです。

[14]:
fig, ax = plt.subplots(figsize=(10, 6))
# results from hardware
ax.plot(phases / np.pi, chsh1_est, "o-", label="CHSH1", zorder=3)
ax.plot(phases / np.pi, chsh2_est, "o-", label="CHSH2", zorder=3)
# classical bound +-2
ax.axhline(y=2, color="0.9", linestyle="--")
ax.axhline(y=-2, color="0.9", linestyle="--")
# quantum bound, +-2√2
ax.axhline(y=np.sqrt(2) * 2, color="0.9", linestyle="-.")
ax.axhline(y=-np.sqrt(2) * 2, color="0.9", linestyle="-.")
ax.fill_between(phases / np.pi, 2, 2 * np.sqrt(2), color="0.6", alpha=0.7)
ax.fill_between(phases / np.pi, -2, -2 * np.sqrt(2), color="0.6", alpha=0.7)
# set x tick labels to the unit of pi
ax.xaxis.set_major_formatter(tck.FormatStrFormatter("%g $\pi$"))
ax.xaxis.set_major_locator(tck.MultipleLocator(base=0.5))
# set title, labels, and legend
plt.title(f"Violation of CHSH Inequality ({backend.name})")
plt.xlabel("Theta")
plt.ylabel("CHSH witness")
plt.legend();
../_images/tutorials_chsh_with_estimator_26_0.png

図では、赤の破線が古典的境界 (\(\pm 2\))、青の点線は量子的境界 (\(\pm 2\sqrt{2}\))を区切っています。実験結果はシミュレーション結果の一般的な傾向に似ており、CHSHの証人量が古典的な境界を越えている領域があることがわかります。おめでとうございます! あなたは、実際の量子系でCHSH不等式の破れを実証することに成功しました!

概要

このチュートリアルでは、パラメーター化されたCHSH回路を作成し、Estimator primitive を使って実行し、結果を解析してCHSH不等式の破れを実証しています。Estimator primitive はパラメーター化された回路の実行を非常に簡単にするだけでなく、観測値の期待値を得るためのワークフローを大幅に簡素化することができることがおわかりいただけたと思います。

参考文献

  1. Córcoles, A. (n.d.), Local Reality and the CHSH Inequality. In A. Abbas, et al. Learn Quantum Computation Using Qiskit. URL: https://qiskit.org/textbook/ch-demos/chsh.html (accessed 07/13/2022) (2020).

Qiskit のバージョンと著作権

[ ]:
import qiskit_ibm_runtime

qiskit_ibm_runtime.version.get_version_info()
'0.11.2'
[76]:
import qiskit.tools.jupyter

%qiskit_version_table
%qiskit_copyright

Version Information

SoftwareVersion
qiskit0.44.0
qiskit-terra0.25.0
qiskit_aer0.12.2
qiskit_ibm_provider0.6.2
qiskit_ibm_runtime0.11.2
System information
Python version3.11.4
Python compilerClang 15.0.7
Python buildmain, Jun 10 2023 18:08:41
OSDarwin
CPUs8
Memory (Gb)16.0
Wed Aug 02 15:00:01 2023 EDT

This code is a part of Qiskit

© Copyright IBM 2017, 2023.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.