valid_clifford_implementation¶
- guppyft.verify.valid_clifford_implementation(semantic_function: SemanticCliffordUnitary | SemanticCliffordUnitaryDouble, impl_function: ImplementationCliffordUnitary | ImplementationCliffordUnitaryDouble, code_definition: StabilizerCode, n_impl_ancillas: int | None = None) bool[source]¶
Checks whether impl_function is a valid implementation of semantic_function.
Validates the implementation of a Clifford function acting one or two code blocks.
- Parameters:
semantic_function – A Guppy function for semantic action of a Clifford operator on one or two code blocks.
impl_function – A Guppy function for implementing the semantics on one or two code blocks.
code_definition – A stabilizer code with well defined \([[n, k, d]]\) parameters, stabilizer generators and logical operators.
n_impl_ancillas – The number of ancilla qubits used in the implementation. Defaults to None meaning that no ancilla qubits are used by default.
- Returns:
A Boolean indicating whether the implementation is valid.
from guppylang import guppy from guppylang.std.builtins import array from guppylang.std.quantum import qubit, h from guppyft.code_def import StabilizerCode from guppyft.verify import valid_clifford_implementation STEANE_DEF = StabilizerCode.from_python_strings( n_physical_qubits=7, n_logical_qubits=1, distance=3, generators=["XXXXIII", "IXXIXXI", "IIXXIXX", "ZZZZIII", "IZZIZZI", "IIZZIZZ"], x_logicals=["XXXXXXX"], z_logicals=["ZZZZZZZ"], ) @guppy def steane_specify_h(qs: array[qubit, 1]) -> None: h(qs[0]) @guppy def steane_impl_h(block: array[qubit, 7]) -> None: for i in range(len(block)): h(block[i]) # True => implementation is valid assert valid_clifford_implementation(steane_specify_h, steane_impl_h, STEANE_DEF)