def test_ppt_distinguishability_yyd_density_matrices():
    """
    PPT distinguishing the YYD states from [1] should yield `7/8 ~ 0.875`

    Feeding the input to the function as density matrices.

    References:
    [1]: Yu, Nengkun, Runyao Duan, and Mingsheng Ying.
    "Four locally indistinguishable ququad-ququad orthogonal
    maximally entangled states."
    Physical review letters 109.2 (2012): 020506.
    https://arxiv.org/abs/1107.3224
    """
    psi_0 = bell(0)
    psi_1 = bell(2)
    psi_2 = bell(3)
    psi_3 = bell(1)

    x_1 = np.kron(psi_0, psi_0)
    x_2 = np.kron(psi_1, psi_3)
    x_3 = np.kron(psi_2, psi_3)
    x_4 = np.kron(psi_3, psi_3)

    rho_1 = x_1 * x_1.conj().T
    rho_2 = x_2 * x_2.conj().T
    rho_3 = x_3 * x_3.conj().T
    rho_4 = x_4 * x_4.conj().T

    states = [rho_1, rho_2, rho_3, rho_4]
    probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]

    res = ppt_distinguishability(states, probs)
    np.testing.assert_equal(np.isclose(res, 7 / 8), True)
def test_unambiguous_state_exclusion_one_state():
    """Unambiguous state exclusion for single state."""
    mat = bell(0) * bell(0).conj().T
    states = [mat]

    res = unambiguous_state_exclusion(states)
    np.testing.assert_equal(np.isclose(res, 0), True)
Example #3
0
def test_partial_transpose_bell_state():
    """Test partial transpose on a Bell state."""
    rho = bell(2) * bell(2).conj().T
    expected_res = np.array([[0, 0, 0, 1 / 2], [0, 1 / 2, 0, 0],
                             [0, 0, 1 / 2, 0], [1 / 2, 0, 0, 0]])
    res = partial_transpose(rho)
    np.testing.assert_equal(np.allclose(res, expected_res), True)
def test_conclusive_state_exclusion_one_state():
    """Conclusive state exclusion for single state."""
    rho = bell(0) * bell(0).conj().T
    states = [rho]

    res = conclusive_state_exclusion(states)
    np.testing.assert_equal(np.isclose(res, 1), True)
def test_ppt_distinguishability_yyd_states_no_probs():
    """
    PPT distinguishing the YYD states from [1] should yield 7/8 ~ 0.875

    If no probability vector is explicitly given, assume uniform
    probabilities are given.

    References:
    [1]: Yu, Nengkun, Runyao Duan, and Mingsheng Ying.
    "Four locally indistinguishable ququad-ququad orthogonal
    maximally entangled states."
    Physical review letters 109.2 (2012): 020506.
    https://arxiv.org/abs/1107.3224
    """
    psi_0 = bell(0)
    psi_1 = bell(2)
    psi_2 = bell(3)
    psi_3 = bell(1)

    x_1 = np.kron(psi_0, psi_0)
    x_2 = np.kron(psi_1, psi_3)
    x_3 = np.kron(psi_2, psi_3)
    x_4 = np.kron(psi_3, psi_3)

    rho_1 = x_1 * x_1.conj().T
    rho_2 = x_2 * x_2.conj().T
    rho_3 = x_3 * x_3.conj().T
    rho_4 = x_4 * x_4.conj().T

    states = [rho_1, rho_2, rho_3, rho_4]

    res = ppt_distinguishability(states)
    np.testing.assert_equal(np.isclose(res, 7 / 8), True)
Example #6
0
def test_invalid_symmetric_extension_hierarchy_probs():
    """Invalid probability vector for symmetric extension hierarchy."""
    with np.testing.assert_raises(ValueError):
        rho1 = bell(0) * bell(0).conj().T
        rho2 = bell(1) * bell(1).conj().T
        states = [rho1, rho2]
        symmetric_extension_hierarchy(states, [1, 2, 3])
Example #7
0
def test_sub_fidelity_default():
    """Test sub_fidelity default arguments."""
    rho = bell(0) * bell(0).conj().T
    sigma = rho

    res = sub_fidelity(rho, sigma)
    np.testing.assert_equal(np.isclose(res, 1), True)
Example #8
0
def test_is_product_entangled_density_matrix():
    """Check to ensure that an entangled density matrix is not product."""
    res = is_product(bell(0) * bell(0).conj().T)
    np.testing.assert_equal(res[0], False)

    res = is_product(bell(0) * bell(0).conj().T, [2, 2])
    np.testing.assert_equal(res[0], False)
Example #9
0
def test_state_distinguishability_one_state():
    """State distinguishability for single state."""
    rho = bell(0) * bell(0).conj().T
    states = [rho]

    res = state_distinguishability(states)
    np.testing.assert_equal(np.isclose(res, 1), True)
Example #10
0
def test_invalid_state_distinguishability_probs():
    """Invalid probability vector for state distinguishability."""
    with np.testing.assert_raises(ValueError):
        rho1 = bell(0) * bell(0).conj().T
        rho2 = bell(1) * bell(1).conj().T
        states = [rho1, rho2]
        state_distinguishability(states, [1, 2, 3])
Example #11
0
def test_schmidt_rank_bell_state():
    """
    Computing the Schmidt rank of the entangled Bell state should yield a
    value greater than 1.
    """
    rho = bell(0).conj().T * bell(0)
    np.testing.assert_equal(schmidt_rank(rho) > 1, True)
Example #12
0
def test_hilbert_schmidt_bell():
    r"""Test Hilbert-Schmidt distance on two Bell states."""

    rho = bell(0) * bell(0).conj().T
    sigma = bell(3) * bell(3).conj().T

    res = hilbert_schmidt(rho, sigma)

    np.testing.assert_equal(np.isclose(res, 1), True)
def test_conclusive_state_exclusion_three_state_vec():
    """Conclusive state exclusion for three Bell state vectors."""
    rho1 = bell(0)
    rho2 = bell(1)
    rho3 = bell(2)
    states = [rho1, rho2, rho3]
    probs = [1 / 3, 1 / 3, 1 / 3]

    res = conclusive_state_exclusion(states, probs)
    np.testing.assert_equal(np.isclose(res, 0), True)
Example #14
0
def test_pure_to_mixed_density_matrix():
    """Convert pure state to mixed state density matrix."""
    expected_res = np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0],
                             [1 / 2, 0, 0, 1 / 2]])

    phi = bell(0) * bell(0).conj().T
    res = pure_to_mixed(phi)

    bool_mat = np.isclose(res, expected_res)
    np.testing.assert_equal(np.all(bool_mat), True)
Example #15
0
def test_state_exclusion_invalid_method():
    """Invalid exclusion method for state exclusion."""
    with np.testing.assert_raises(ValueError):
        mat1 = bell(0)
        mat2 = bell(1)
        mat3 = bell(2)
        states = [mat1, mat2, mat3]
        probs = [1 / 3, 1 / 3, 1 / 3]

        state_exclusion(states, probs, method="not_valid")
def test_unambiguous_state_exclusion_three_state_vec():
    """Unambiguous state exclusion for three Bell state vectors."""
    mat1 = bell(0)
    mat2 = bell(1)
    mat3 = bell(2)
    states = [mat1, mat2, mat3]
    probs = [1 / 3, 1 / 3, 1 / 3]

    res = unambiguous_state_exclusion(states, probs)
    np.testing.assert_equal(np.isclose(res, 0), True)
Example #17
0
def test_gen_bell_dim_2():
    """Generalized singlet state for dim = 2."""
    dim = 2

    expected_res = bell(3) * bell(3).conj().T

    res = singlet(dim)

    bool_mat = np.isclose(res, expected_res)
    np.testing.assert_equal(np.all(bool_mat), True)
Example #18
0
def test_gen_bell_0_0_2():
    """Generalized Bell state for k_1 = k_2 = 0 and dim = 2."""
    dim = 2
    k_1 = 0
    k_2 = 0

    expected_res = bell(0) * bell(0).conj().T

    res = gen_bell(k_1, k_2, dim)

    bool_mat = np.isclose(res, expected_res)
    np.testing.assert_equal(np.all(bool_mat), True)
Example #19
0
def test_symmetric_extension_hierarchy_four_bell_with_resource_state():
    """Symmetric extension hierarchy for four Bell states and resource state."""
    e_0, e_1 = basis(2, 0), basis(2, 1)
    e_00, e_11 = np.kron(e_0, e_0), np.kron(e_1, e_1)

    eps = 1 / 2
    eps_state = np.sqrt((1 + eps) / 2) * e_00 + np.sqrt((1 - eps) / 2) * e_11
    eps_dm = eps_state * eps_state.conj().T

    states = [
        np.kron(bell(0) * bell(0).conj().T, eps_dm),
        np.kron(bell(1) * bell(1).conj().T, eps_dm),
        np.kron(bell(2) * bell(2).conj().T, eps_dm),
        np.kron(bell(3) * bell(3).conj().T, eps_dm),
    ]

    # Ensure we are checking the correct partition of the states.
    states = [
        swap(states[0], [2, 3], [2, 2, 2, 2]),
        swap(states[1], [2, 3], [2, 2, 2, 2]),
        swap(states[2], [2, 3], [2, 2, 2, 2]),
        swap(states[3], [2, 3], [2, 2, 2, 2]),
    ]

    res = symmetric_extension_hierarchy(states=states, probs=None, level=2)
    exp_res = 1 / 2 * (1 + np.sqrt(1 - eps**2))

    np.testing.assert_equal(np.isclose(res, exp_res), True)
Example #20
0
def test_ppt_distinguishability_yyd_vectors():
    """
    PPT distinguishing the YYD states from [1] should yield `7/8 ~ 0.875`

    Feeding the input to the function as state vectors.

    References:
    [1]: Yu, Nengkun, Runyao Duan, and Mingsheng Ying.
    "Four locally indistinguishable ququad-ququad orthogonal
    maximally entangled states."
    Physical review letters 109.2 (2012): 020506.
    https://arxiv.org/abs/1107.3224
    """
    psi_0 = bell(0)
    psi_1 = bell(2)
    psi_2 = bell(3)
    psi_3 = bell(1)

    x_1 = np.kron(psi_0, psi_0)
    x_2 = np.kron(psi_1, psi_3)
    x_3 = np.kron(psi_2, psi_3)
    x_4 = np.kron(psi_3, psi_3)

    states = [x_1, x_2, x_3, x_4]
    probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]

    primal_res = ppt_distinguishability(states,
                                        probs=probs,
                                        dist_method="min-error",
                                        strategy=True)
    dual_res = ppt_distinguishability(states,
                                      probs=probs,
                                      dist_method="min-error",
                                      strategy=False)

    np.testing.assert_equal(np.isclose(primal_res, 7 / 8, atol=0.001), True)
    np.testing.assert_equal(np.isclose(dual_res, 7 / 8, atol=0.001), True)

    primal_res = ppt_distinguishability(states,
                                        probs=probs,
                                        dist_method="unambiguous",
                                        strategy=True)
    dual_res = ppt_distinguishability(states,
                                      probs=probs,
                                      dist_method="unambiguous",
                                      strategy=False)

    np.testing.assert_equal(np.isclose(primal_res, 3 / 4, atol=0.001), True)
    np.testing.assert_equal(np.isclose(dual_res, 3 / 4, atol=0.001), True)
Example #21
0
def test_conclusive_state_exclusion_one_state_vec():
    """Conclusive state exclusion for single vector state."""
    rho = bell(0)
    states = [rho]

    res = state_exclusion(states, probs=None, method="conclusive")
    np.testing.assert_equal(np.isclose(res, 1), True)
Example #22
0
def test_entanglement_of_formation_bell_state():
    """The entanglement-of-formation on a Bell state."""
    u_vec = bell(0)
    rho = u_vec * u_vec.conj().T

    res = entanglement_of_formation(rho)
    np.testing.assert_equal(np.isclose(res, 1), True)
def test_unambiguous_state_exclusion_one_state_vec():
    """Unambiguous state exclusion for single vector state."""
    vec = bell(0)
    states = [vec]

    res = unambiguous_state_exclusion(states)
    np.testing.assert_equal(np.isclose(res, 0), True)
Example #24
0
def test_symmetric_extension_hierarchy_four_bell_density_matrices():
    """Symmetric extension hierarchy for four Bell density matrices."""
    states = [
        bell(0) * bell(0).conj().T,
        bell(1) * bell(1).conj().T,
        bell(2) * bell(2).conj().T,
        bell(3) * bell(3).conj().T,
    ]
    res = symmetric_extension_hierarchy(states=states, probs=None, level=2)
    np.testing.assert_equal(np.isclose(res, 1 / 2), True)
Example #25
0
def test_bell_0():
    """Generate the Bell state: `1/sqrt(2) * (|00> + |11>)`."""
    e_0, e_1 = basis(2, 0), basis(2, 1)
    expected_res = 1 / np.sqrt(2) * (np.kron(e_0, e_0) + np.kron(e_1, e_1))

    res = bell(0)

    bool_mat = np.isclose(res, expected_res)
    np.testing.assert_equal(np.all(bool_mat), True)
Example #26
0
def test_pure_to_mixed_state_vector():
    """Convert pure state to mixed state vector."""
    expected_res = np.array([[1 / 2, 0, 0, 1 / 2], [0, 0, 0, 0], [0, 0, 0, 0],
                             [1 / 2, 0, 0, 1 / 2]])

    phi = bell(0)
    res = pure_to_mixed(phi)

    bool_mat = np.isclose(res, expected_res)
    np.testing.assert_equal(np.all(bool_mat), True)
Example #27
0
def test_ppt_distinguishability_four_bell_states():
    r"""
    PPT distinguishing the four Bell states.

    There exists a closed form formula for the probability with which one
    is able to distinguish one of the four Bell states given with equal
    probability when Alice and Bob have access to a resource state [1].

    The resource state is defined by

    ..math::

    The closed form probability with which Alice and Bob can distinguish via
    PPT measurements is given as follows

    .. math::
        \frac{1}{2} \left(1 + \sqrt{1 - \epsilon^2} \right).

    This formula happens to be equal to LOCC and SEP as well for this case.
    Refer to Theorem 5 in [1] for more details.

    References:
    [1]: Bandyopadhyay, Somshubhro, et al.
    "Limitations on separable measurements by convex optimization."
    IEEE Transactions on Information Theory 61.6 (2015): 3593-3604.
    https://arxiv.org/abs/1408.6981
    """
    rho_1 = bell(0) * bell(0).conj().T
    rho_2 = bell(1) * bell(1).conj().T
    rho_3 = bell(2) * bell(2).conj().T
    rho_4 = bell(3) * bell(3).conj().T

    e_0, e_1 = basis(2, 0), basis(2, 1)
    e_00 = np.kron(e_0, e_0)
    e_11 = np.kron(e_1, e_1)

    eps = 0.5
    resource_state = np.sqrt((1 + eps) / 2) * e_00 + np.sqrt(
        (1 - eps) / 2) * e_11
    resource_state = resource_state * resource_state.conj().T

    states = [
        np.kron(rho_1, resource_state),
        np.kron(rho_2, resource_state),
        np.kron(rho_3, resource_state),
        np.kron(rho_4, resource_state),
    ]
    probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]

    res = ppt_distinguishability(states, probs)
    exp_res = 1 / 2 * (1 + np.sqrt(1 - eps**2))
    np.testing.assert_equal(np.isclose(res, exp_res), True)
Example #28
0
def test_state_distinguishability_yyd_density_matrices():
    """Global distinguishability of the YYD states should yield 1."""
    psi0 = bell(0) * bell(0).conj().T
    psi1 = bell(1) * bell(1).conj().T
    psi2 = bell(2) * bell(2).conj().T
    psi3 = bell(3) * bell(3).conj().T

    states = [
        np.kron(psi0, psi0),
        np.kron(psi2, psi1),
        np.kron(psi3, psi1),
        np.kron(psi1, psi1),
    ]
    probs = [1 / 4, 1 / 4, 1 / 4, 1 / 4]

    res = state_distinguishability(states, probs)
    np.testing.assert_equal(np.isclose(res, 1, atol=0.001), True)
def test_conclusive_state_exclusion_three_state():
    """Conclusive state exclusion for three Bell state density matrices."""
    rho1 = bell(0) * bell(0).conj().T
    rho2 = bell(1) * bell(1).conj().T
    rho3 = bell(2) * bell(2).conj().T
    states = [rho1, rho2, rho3]
    probs = [1 / 3, 1 / 3, 1 / 3]

    res = conclusive_state_exclusion(states, probs)
    np.testing.assert_equal(np.isclose(res, 0), True)
def test_unambiguous_state_exclusion_three_state():
    """Unambiguous state exclusion for three Bell state density matrices."""
    mat1 = bell(0) * bell(0).conj().T
    mat2 = bell(1) * bell(1).conj().T
    mat3 = bell(2) * bell(2).conj().T
    states = [mat1, mat2, mat3]
    probs = [1 / 3, 1 / 3, 1 / 3]

    res = unambiguous_state_exclusion(states, probs)
    np.testing.assert_equal(np.isclose(res, 0), True)