From 393e59a39f5cc103373fc97da27e467a56e0ad50 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 3 Nov 2024 11:46:01 +0500 Subject: [PATCH] noncliff: better error message for inapplicable project! of GeneralizedStabilizer --- src/nonclifford.jl | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/nonclifford.jl b/src/nonclifford.jl index 70f99e42f..2439e13a8 100644 --- a/src/nonclifford.jl +++ b/src/nonclifford.jl @@ -172,15 +172,29 @@ function _allthreesumtozero(a,b,c) true end -function project!(sm::GeneralizedStabilizer, p::PauliOperator) +project!(::GeneralizedStabilizer, ::PauliOperator) = + error("The method `๐ฉ๐ซ๐จ๐ฃ๐ž๐œ๐ญ!` is not applicable for `๐†๐ž๐ง๐ž๐ซ๐š๐ฅ๐ข๐ณ๐ž๐๐’๐ญ๐š๐›๐ข๐ฅ๐ข๐ณ๐ž๐ซ` with hermitian `๐๐š๐ฎ๐ฅ๐ข๐Ž๐ฉ๐ž๐ซ๐š๐ญ๐จ๐ซ`, ๐Œ.\n\n" * + "The `๐†๐ž๐ง๐ž๐ซ๐š๐ฅ๐ข๐ณ๐ž๐๐’๐ญ๐š๐›๐ข๐ฅ๐ข๐ณ๐ž๐ซ` ๐‰ is updated by measuring ๐Œ = ๐’ถ๐’นโ‚˜๐“ˆโ‚™, resulting in the new state ๐‰โ€ฒ defined as:\n\n" * + " ๐‰โ€ฒ = ยผ(๐ˆ + ๐Œ)๐‰(๐ˆ + ๐Œ) = (๐Œโ€ฒ, ๐(๐’โ€ฒ, ๐ƒโ€ฒ)),\n\n" * + "where (๐’โ€ฒ, ๐ƒโ€ฒ) is derived from (๐’, ๐ƒ) through the traditional stabilizer update.\n\n" * + "Note that ยผ(๐ˆ โˆ’ ๐Œ)๐‰(๐ˆ โˆ’ ๐Œ) can be obtained by changing the sign of ๐’ถ.\n\n" * + "This projection requires a probabilistic approach, as measurement outcomes depend on the expectation value of the `๐๐š๐ฎ๐ฅ๐ข๐Ž๐ฉ๐ž๐ซ๐š๐ญ๐จ๐ซ`.\n\n" * + "Specifically, this expectation value is derived from the trace ๐“๐ซ[๐‰โ€ฒ] = ๐“๐ซ[๐Œโ€ฒ] in the expression:\n\n" * + " ๐‰โ€ฒ = ๐šบ ๐Œ'แตขโฑผ ๐แตข ๐›’ ๐โฑผโ€ ,\n\n" * + "where ๐Œโ€ฒ is the updated density matrix. \n\n" * + "The trace ๐“๐ซ[๐‰โ€ฒ] = ๐“๐ซ[๐Œโ€ฒ] represents the probability of measuring either ๐Ÿฌ or a non-zero outcome and serves as the normalization required for ๐‰โ€ฒ.\n\n" * + "To correctly perform the 'nondeterministic' projection, please use `๐ฉ๐ซ๐จ๐ฃ๐ž๐œ๐ญ๐ซ๐š๐ง๐!(::๐†๐ž๐ง๐ž๐ซ๐š๐ฅ๐ข๐ณ๐ž๐๐’๐ญ๐š๐›๐ข๐ฅ๐ข๐ณ๐ž๐ซ, ::๐๐š๐ฎ๐ฅ๐ข๐Ž๐ฉ๐ž๐ซ๐š๐ญ๐จ๐ซ)`.\n\n" * + "`๐ฉ๐ซ๐จ๐ฃ๐ž๐œ๐ญ!` in this library operates as a 'deterministic' method to verify whether a measurement operator commutes with stabilizers.\n\n" * + "Based on this commutation, it executes additional steps to determine the resultant state after projection.\n\n" * + "Therefore, there are semantic nuances in defining `๐ฉ๐ซ๐จ๐ฃ๐ž๐œ๐ญ!` consistently for `๐†๐ž๐ง๐ž๐ซ๐š๐ฅ๐ข๐ณ๐ž๐๐’๐ญ๐š๐›๐ข๐ฅ๐ข๐ณ๐ž๐ซ`, particularly regarding the interpretations of `๐š๐ง๐ญ๐ข๐œ๐จ๐ฆ` and `๐ซ๐ž๐ฌ` in this context.") + +function projectrand!(sm::GeneralizedStabilizer, p::PauliOperator) eval = expect(p, sm) probโ‚ = (real(eval)+1)/2 error("This functionality is not implemented yet") end -function _projโ‚‹(sm::GeneralizedStabilizer, p::PauliOperator) -end -function _projโ‚Š(sm::GeneralizedStabilizer, p::PauliOperator) +function _proj(sm::GeneralizedStabilizer, p::PauliOperator) end nqubits(sm::GeneralizedStabilizer) = nqubits(sm.stab)