# Copyright 2023 The PECOS Developers
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License.You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.

"""Gate grouping and classification utilities for PECOS.

This module defines sets and functions for categorizing quantum gates by
their properties such as qubit count, gate type, and rotation characteristics.
"""

import pecos as pc
from pecos.quantum import Pauli

two_qubits = {
    "CNOT",
    "CX",
    "CZ",
    "SWAP",
    "G",
    "MS",
    "SqrtXX",
    "SqrtZZ",
    "RXX",
    "RYY",
    "RZZ",
    "RXXYYZZ",
}

one_qubits = {
    "I",
    "X",
    "Y",
    "Z",
    "Q",
    "Qd",
    "R",
    "Rd",
    "S",
    "Sd",
    "H",
    "H1",
    "H2",
    "H3",
    "H4",
    "H5",
    "H6",
    "H+z+x",
    "H-z-x",
    "H+y-z",
    "H-y-z",
    "H-x+y",
    "H-x-y",
    "F1",
    "F1d",
    "F2",
    "F2d",
    "F3",
    "F3d",
    "F4",
    "F4d",
    "SqrtX",
    "SqrtXd",
    "SqrtY",
    "SqrtYd",
    "SqrtZ",
    "SqrtZd",
    "RX",
    "RY",
    "RZ",
    "U1q",
    "RXY1Q",
}

error_two_paulis_collection = pc.array(
    [
        (Pauli.I, Pauli.X),
        (Pauli.I, Pauli.Y),
        (Pauli.I, Pauli.Z),
        (Pauli.X, Pauli.I),
        (Pauli.X, Pauli.X),
        (Pauli.X, Pauli.Y),
        (Pauli.X, Pauli.Z),
        (Pauli.Y, Pauli.I),
        (Pauli.Y, Pauli.X),
        (Pauli.Y, Pauli.Y),
        (Pauli.Y, Pauli.Z),
        (Pauli.Z, Pauli.I),
        (Pauli.Z, Pauli.X),
        (Pauli.Z, Pauli.Y),
        (Pauli.Z, Pauli.Z),
    ],
)

error_one_paulis_collection = pc.array([Pauli.X, Pauli.Y, Pauli.Z])
