diff --git a/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs index e9ab9120a34..2511a12486e 100644 --- a/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/AssertAllZero.qs @@ -14,7 +14,11 @@ namespace Microsoft.Quantum.Diagnostics { /// /// # See Also /// - AssertQubit - operation AssertAllZero (qubits : Qubit[]) : Unit { + /// + /// # Remarks + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + operation AssertAllZero (qubits : Qubit[]) : Unit is Adj + Ctl { body (...) { for qubit in qubits { AssertQubit(Zero, qubit); @@ -39,7 +43,12 @@ namespace Microsoft.Quantum.Diagnostics { /// /// # See Also /// - AssertQubitWithinTolerance - operation AssertAllZeroWithinTolerance(qubits : Qubit[], tolerance : Double) : Unit { + /// + /// # Remarks + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + operation AssertAllZeroWithinTolerance(qubits : Qubit[], tolerance : Double) : Unit is Adj + Ctl{ + body (...) { for qubit in qubits { AssertQubitWithinTolerance(Zero, qubit, tolerance); @@ -51,6 +60,7 @@ namespace Microsoft.Quantum.Diagnostics { controlled (ctrls, ...) { AssertAllZeroWithinTolerance(qubits, tolerance); } + controlled adjoint self; } } diff --git a/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs b/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs index 04934d1d988..e1a9e993012 100644 --- a/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs +++ b/src/Simulation/QSharpFoundation/Diagnostics/AssertQubit.qs @@ -21,7 +21,10 @@ namespace Microsoft.Quantum.Diagnostics { /// # Remarks /// allows for asserting /// arbitrary qubit states rather than only $Z$ eigenstates. - operation AssertQubit (expected : Result, q : Qubit) : Unit { + /// + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + operation AssertQubit (expected : Result, q : Qubit) : Unit is Adj + Ctl { AssertMeasurement([PauliZ], [q], expected, $"Qubit in invalid state. Expecting: {expected}"); } @@ -46,7 +49,10 @@ namespace Microsoft.Quantum.Diagnostics { /// # Remarks /// allows for asserting /// arbitrary qubit states rather than only $Z$ eigenstates. - operation AssertQubitWithinTolerance(expected : Result, q : Qubit, tolerance : Double) : Unit { + /// + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + operation AssertQubitWithinTolerance(expected : Result, q : Qubit, tolerance : Double) : Unit is Adj + Ctl { AssertMeasurementProbability([PauliZ], [q], expected, 1.0, $"Qubit in invalid state. Expecting: {expected} with tolerance {tolerance}", tolerance); } @@ -101,7 +107,10 @@ namespace Microsoft.Quantum.Diagnostics { /// This is only true under the assumption that Tr(ρ) and Tr(|ψ⟩⟨ψ|) are both 1 (e.g. x₁ = 1/2, y₁ = 1/2). /// If this is not the case, the function asserts that l∞ distance between /// (x₂-x₁,x₃-x₁,x₄-x₁,x₄+x₁) and (y₂-y₁,y₃-y₁,y₄-y₁,y₄+y₁) is less than the tolerance parameter. - operation AssertQubitIsInStateWithinTolerance(expected : (Complex, Complex), register : Qubit, tolerance : Double) : Unit { + /// + /// Note that the Adjoint and Controlled versions of this operation will not + /// check the condition. + operation AssertQubitIsInStateWithinTolerance(expected : (Complex, Complex), register : Qubit, tolerance : Double) : Unit is Adj + Ctl { let (a, b) = expected; let (reA, imA) = a!; let (reB, imB) = b!;