diff --git a/src/Simulation/QsharpCore/Core.qs b/src/Simulation/QsharpCore/Core.qs index 69d3287f5ee..fe4a5d02e50 100644 --- a/src/Simulation/QsharpCore/Core.qs +++ b/src/Simulation/QsharpCore/Core.qs @@ -22,7 +22,7 @@ namespace Microsoft.Quantum.Core { /// # Summary /// Compiler-recognized attribute used to mark a type or callable as deprecated. /// - /// # Input + /// # Named Items /// ## NewName /// The full name of the type or callable to use instead. /// Is set to the empty String if a type or callable has been deprecated without substitution. @@ -30,7 +30,6 @@ namespace Microsoft.Quantum.Core { @Attribute() newtype Deprecated = (NewName : String); - /// # Summary /// Returns a default instance of the specified type. /// @@ -136,5 +135,3 @@ namespace Microsoft.Quantum.Core { } } - - diff --git a/src/Simulation/QsharpCore/Intrinsic.qs b/src/Simulation/QsharpCore/Intrinsic.qs index 0a22cb388f1..0ce887c0ae6 100644 --- a/src/Simulation/QsharpCore/Intrinsic.qs +++ b/src/Simulation/QsharpCore/Intrinsic.qs @@ -4,6 +4,7 @@ namespace Microsoft.Quantum.Intrinsic { open Microsoft.Quantum.Math; open Microsoft.Quantum.Convert; + open Microsoft.Quantum.Targeting; @Deprecated("Microsoft.Quantum.Random.DrawCategorical") operation Random (probs : Double[]) : Int { @@ -657,24 +658,26 @@ namespace Microsoft.Quantum.Intrinsic { operation M (qubit : Qubit) : Result { return Measure([PauliZ], [qubit]); } - - + + /// # Summary /// Given a single qubit, measures it and ensures it is in the |0⟩ state /// such that it can be safely released. /// /// # Input - /// ## qubit + /// ## target /// The qubit whose state is to be reset to $\ket{0}$. + @RequiresCapability( + "BasicQuantumFunctionality", + "Reset is replaced by a supported implementation on all execution targets." + ) operation Reset (target : Qubit) : Unit { - - if (M(target) == One) - { + if (M(target) == One) { X(target); } } - - + + /// # Summary /// Given an array of qubits, measure them and ensure they are in the |0⟩ state /// such that they can be safely released. @@ -683,12 +686,8 @@ namespace Microsoft.Quantum.Intrinsic { /// ## qubits /// An array of qubits whose states are to be reset to $\ket{0}$. operation ResetAll (qubits : Qubit[]) : Unit { - for (qubit in qubits) { Reset(qubit); } } - } - - diff --git a/src/Simulation/QsharpCore/Targeting.qs b/src/Simulation/QsharpCore/Targeting.qs new file mode 100644 index 00000000000..989a5eb7ec9 --- /dev/null +++ b/src/Simulation/QsharpCore/Targeting.qs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/// # Summary +/// This namespace provides functionality for targeting specific quantum processors. +namespace Microsoft.Quantum.Targeting { + /// # Summary + /// Compiler-recognized attribute used to mark a callable with the runtime capabilities it + /// requires. + /// + /// # Named Items + /// ## Level + /// The name of the runtime capability level required by the callable. + /// + /// ## Reason + /// A description of why the callable requires this runtime capability. + /// + /// # Remarks + /// This attribute is automatically added to callables by the compiler, unless an instance of + /// this attribute already exists on the callable. It should not be used except in rare cases + /// where the compiler does not infer the required capability correctly. + /// + /// Below is the list of capability level names, in order of increasing capabilities or + /// decreasing restrictions: + /// + /// ## `"BasicQuantumFunctionality"` + /// Measurement results cannot be compared for equality. + /// + /// ## `"BasicMeasurementFeedback"` + /// Measurement results can be compared for equality only in if-statement conditional + /// expressions in operations. The block of an if-statement that depends on a result cannot + /// contain set statements for mutable variables declared outside the block, or return + /// statements. + /// + /// ## `"FullComputation"` + /// No runtime restrictions. Any Q# program can be executed. + @Attribute() + newtype RequiresCapability = (Level : String, Reason : String); +}