qsharp-lang 1.6.4-dev → 1.6.7-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/katas-content.generated.js +143 -28
- package/dist/katas-content.generated.md.js +143 -28
- package/docs/Microsoft.Quantum.Arrays/All.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Any.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Chunks.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/CircularlyShifted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/ColumnAt.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Count.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Diagonal.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/DrawMany.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Enumerated.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Excluding.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Filtered.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/FlatMapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Flattened.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Fold.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/ForEach.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Head.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/HeadAndRest.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IndexOf.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IndexRange.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Interleaved.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsEmpty.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsRectangularArray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsSorted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/IsSquareArray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Mapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MappedByIndex.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MappedOverRange.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Most.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/MostAndTail.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Padded.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Partitioned.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Rest.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Reversed.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/SequenceI.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/SequenceL.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Sorted.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Subarray.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Swapped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Tail.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Transposed.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Unzipped.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Where.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Windows.md +1 -1
- package/docs/Microsoft.Quantum.Arrays/Zipped.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyCNOTChain.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnBitString.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyControlledOnInt.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyP.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauli.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromBitString.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyPauliFromInt.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyQFT.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEach.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachA.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachC.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyToEachCA.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlace.md +1 -1
- package/docs/Microsoft.Quantum.Canon/ApplyXorInPlaceL.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CX.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CY.md +1 -1
- package/docs/Microsoft.Quantum.Canon/CZ.md +1 -1
- package/docs/Microsoft.Quantum.Canon/Fst.md +1 -1
- package/docs/Microsoft.Quantum.Canon/Snd.md +1 -1
- package/docs/Microsoft.Quantum.Canon/SwapReverseRegister.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BigIntAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsBigInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolArrayAsResultArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/BoolAsResult.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ComplexAsComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ComplexPolarAsComplex.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsBigInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/IntAsDouble.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsBoolArray.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultArrayAsInt.md +1 -1
- package/docs/Microsoft.Quantum.Convert/ResultAsBool.md +1 -1
- package/docs/Microsoft.Quantum.Core/IsRangeEmpty.md +1 -1
- package/docs/Microsoft.Quantum.Core/Length.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeEnd.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeReverse.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeStart.md +1 -1
- package/docs/Microsoft.Quantum.Core/RangeStep.md +1 -1
- package/docs/Microsoft.Quantum.Core/Repeated.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/DumpMachine.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/DumpRegister.md +1 -1
- package/docs/Microsoft.Quantum.Diagnostics/Fact.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/AdjustForSingleControl.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/ApplyGlobalPhase.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CCH.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CCNOT.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CCY.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CCZ.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CH.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CNOT.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CRxx.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CRyy.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CRz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CRzz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CS.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CT.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/CollectControls.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/ControllableGlobalPhase.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/EntangleForJointMeasure.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Exp.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/GlobalPhase.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/H.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/I.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/IndicesOfNonIdentity.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/M.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/MapPauli.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Measure.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Message.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/PhaseCCX.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R1.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/R1Frac.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/RFrac.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/RemovePauliI.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Reset.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/ResetAll.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rx.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rxx.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Ry.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Ryy.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Rzz.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/S.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/SWAP.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/SpreadZ.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/T.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/X.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Y.md +1 -1
- package/docs/Microsoft.Quantum.Intrinsic/Z.md +1 -1
- package/docs/Microsoft.Quantum.Logical/Xor.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsD.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsI.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsL.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/AbsSquaredComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/ApproximateFactorial.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcCos.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcCosh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcSin.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcSinh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTan.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTan2.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArcTanh.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArgComplex.md +1 -1
- package/docs/Microsoft.Quantum.Math/ArgComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/Binom.md +1 -1
- package/docs/Microsoft.Quantum.Math/BitSizeI.md +1 -1
- package/docs/Microsoft.Quantum.Math/BitSizeL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Ceiling.md +1 -1
- package/docs/Microsoft.Quantum.Math/Complex.md +1 -1
- package/docs/Microsoft.Quantum.Math/ComplexPolar.md +1 -1
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ContinuedFractionConvergentL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Cos.md +1 -1
- package/docs/Microsoft.Quantum.Math/Cosh.md +1 -1
- package/docs/Microsoft.Quantum.Math/DivRemI.md +1 -1
- package/docs/Microsoft.Quantum.Math/DivRemL.md +1 -1
- package/docs/Microsoft.Quantum.Math/DividedByC.md +1 -1
- package/docs/Microsoft.Quantum.Math/DividedByCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/E.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExpModI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExpModL.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExtendedGreatestCommonDivisorL.md +1 -1
- package/docs/Microsoft.Quantum.Math/ExtendedTruncation.md +1 -1
- package/docs/Microsoft.Quantum.Math/FactorialI.md +1 -1
- package/docs/Microsoft.Quantum.Math/FactorialL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Floor.md +1 -1
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorI.md +1 -1
- package/docs/Microsoft.Quantum.Math/GreatestCommonDivisorL.md +1 -1
- package/docs/Microsoft.Quantum.Math/HammingWeightI.md +1 -1
- package/docs/Microsoft.Quantum.Math/InverseModI.md +1 -1
- package/docs/Microsoft.Quantum.Math/InverseModL.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsCoprimeI.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsCoprimeL.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsInfinite.md +1 -1
- package/docs/Microsoft.Quantum.Math/IsNaN.md +1 -1
- package/docs/Microsoft.Quantum.Math/LargestFixedPoint.md +1 -1
- package/docs/Microsoft.Quantum.Math/Lg.md +1 -1
- package/docs/Microsoft.Quantum.Math/Log.md +1 -1
- package/docs/Microsoft.Quantum.Math/Log10.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogFactorialD.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogGammaD.md +1 -1
- package/docs/Microsoft.Quantum.Math/LogOf2.md +1 -1
- package/docs/Microsoft.Quantum.Math/Max.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxD.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxI.md +1 -1
- package/docs/Microsoft.Quantum.Math/MaxL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Min.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinD.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinI.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinL.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinusC.md +1 -1
- package/docs/Microsoft.Quantum.Math/MinusCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/ModulusI.md +1 -1
- package/docs/Microsoft.Quantum.Math/ModulusL.md +1 -1
- package/docs/Microsoft.Quantum.Math/NegationC.md +1 -1
- package/docs/Microsoft.Quantum.Math/NegationCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/PI.md +1 -1
- package/docs/Microsoft.Quantum.Math/PNorm.md +1 -1
- package/docs/Microsoft.Quantum.Math/PNormalized.md +1 -1
- package/docs/Microsoft.Quantum.Math/PlusC.md +1 -1
- package/docs/Microsoft.Quantum.Math/PlusCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/PowC.md +1 -1
- package/docs/Microsoft.Quantum.Math/PowCAsCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/PowCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/RealMod.md +1 -1
- package/docs/Microsoft.Quantum.Math/Round.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignD.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignI.md +1 -1
- package/docs/Microsoft.Quantum.Math/SignL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sin.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sinh.md +1 -1
- package/docs/Microsoft.Quantum.Math/SmallestFixedPoint.md +1 -1
- package/docs/Microsoft.Quantum.Math/Sqrt.md +1 -1
- package/docs/Microsoft.Quantum.Math/SquaredNorm.md +1 -1
- package/docs/Microsoft.Quantum.Math/Tan.md +1 -1
- package/docs/Microsoft.Quantum.Math/Tanh.md +1 -1
- package/docs/Microsoft.Quantum.Math/TimesC.md +1 -1
- package/docs/Microsoft.Quantum.Math/TimesCP.md +1 -1
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountI.md +1 -1
- package/docs/Microsoft.Quantum.Math/TrailingZeroCountL.md +1 -1
- package/docs/Microsoft.Quantum.Math/Truncate.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetEachZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetX.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetY.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MResetZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureAllZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureEachZ.md +1 -1
- package/docs/Microsoft.Quantum.Measurement/MeasureInteger.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/AccountForEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/AuxQubitCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginEstimateCaching.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/BeginRepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/CczCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/EndEstimateCaching.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/EndRepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/MeasurementCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/PSSPCLayout.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RepeatEstimates.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationCount.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/RotationDepth.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/SingleVariant.md +1 -1
- package/docs/Microsoft.Quantum.ResourceEstimation/TCount.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/AddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyActionIfGreaterThanOrEqualConstant.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyActionIfSumOverflows.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyAsSinglyControlled.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfGreaterOrEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ApplyIfLessOrEqualLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/FourierTDIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByI.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByIUsingIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByL.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLEUsingAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/IncByLUsingIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/LookAheadDKRSAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/MAJ.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/PhaseGradient.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/ReflectAboutInteger.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGAddLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryCGIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.Arithmetic/RippleCarryTTKIncByLE.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/ApproximatelyPreparePureStateCP.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.StatePreparation/PreparePureStateD.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/EncodeUnary.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/MustBeFixed.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/Select.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/Unlookup.md +1 -1
- package/docs/Microsoft.Quantum.Unstable.TableLookup/WriteMemoryContents.md +1 -1
- package/lib/node/qsc_wasm.cjs +1 -1
- package/lib/node/qsc_wasm_bg.wasm +0 -0
- package/lib/web/qsc_wasm.js +1 -1
- package/lib/web/qsc_wasm_bg.wasm +0 -0
- package/package.json +1 -1
|
@@ -5670,7 +5670,7 @@ export default {
|
|
|
5670
5670
|
"items": [
|
|
5671
5671
|
{
|
|
5672
5672
|
"type": "text-content",
|
|
5673
|
-
"content": "<p>Quantum oracles are a key part of many quantum algorithms that rely on quantum implementation of a classical function. The algorithms' discussions often assume that the quantum oracle that implements the function of interest is provided. This kata dives deeper into the definition of different types of quantum oracles, their properties, and the basic ways to implement the oracles.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Quantum oracles and how they relate to classical oracles</li>\n<li>Two types of quantum oracles - phase oracles and marking oracles</li>\n<li>Phase kickback and its uses for oracles implementation</li>\n<li>Implementation and testing of quantum oracles in Q#</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>
|
|
5673
|
+
"content": "<p>Quantum oracles are a key part of many quantum algorithms that rely on quantum implementation of a classical function. The algorithms' discussions often assume that the quantum oracle that implements the function of interest is provided. This kata dives deeper into the definition of different types of quantum oracles, their properties, and the basic ways to implement the oracles.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Quantum oracles and how they relate to classical oracles</li>\n<li>Two types of quantum oracles - phase oracles and marking oracles</li>\n<li>Phase kickback and its uses for oracles implementation</li>\n<li>Implementation and testing of quantum oracles in Q#</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Basic knowledge of fundamental quantum concepts</li>\n<li>Basic knowledge of multi-qubit gates, especially controlled gates. If you're not familiar with these concepts, you can find them in the Multi-Qubit Gates kata.</li>\n</ul>\n"
|
|
5674
5674
|
}
|
|
5675
5675
|
]
|
|
5676
5676
|
},
|
|
@@ -5681,7 +5681,7 @@ export default {
|
|
|
5681
5681
|
"items": [
|
|
5682
5682
|
{
|
|
5683
5683
|
"type": "text-content",
|
|
5684
|
-
"content": "<p>In classical computing,
|
|
5684
|
+
"content": "<p>In classical computing, the terms "black box" versus "white box" are often used to discuss the testing of a function. In "white box" testing, the implementation of a function is visible to the tester, thus they can verify specific runtime or memory complexity expectations for the algorithm.<br />\nHowever, in "black box" testing, the tester doesn't have access to the details of the function implementation. They only have access to the "black box" that takes an input and produces the corresponding output. This means the tester can only test the functionality and expected behavior of the function, but not the implementation, which is hidden behind abstraction.</p>\n<p>Formally, a <strong>classical oracle</strong> is a function that, provided some input, produces a <em>deterministic</em> output\n(the same input <em>always</em> results in the same output).</p>\n<p>Some classical problems (typically <a href=\"https://en.wikipedia.org/wiki/Decision_problem\" target=\"_blank\">decision problems</a>) are also expressed in terms of oracles; in this case the implementation of the function isn't important, but the functionality that it provides.</p>\n<blockquote>\n<p>Suppose you've been given a function which takes two list parameters as input, where these lists represent the availability of two employees at a company during the week. The function returns true if there is a day (Monday, Tuesday, Wednesday, Thursday, or Friday) for which they are both free and could schedule a meeting, and false if no such date exists.</p>\n<p>This function is an example of a classical oracle.</p>\n</blockquote>\n"
|
|
5685
5685
|
}
|
|
5686
5686
|
]
|
|
5687
5687
|
},
|
|
@@ -5704,7 +5704,7 @@ export default {
|
|
|
5704
5704
|
"items": [
|
|
5705
5705
|
{
|
|
5706
5706
|
"type": "text-content",
|
|
5707
|
-
"content": "<p>The binary notation of $7$ is $111_2$. This means that
|
|
5707
|
+
"content": "<p>The binary notation of $7$ is $111_2$. This means that your solution should return <code>true</code> if and only if each bit of the input is <code>true</code>.</p>\n<p>Notice that in this problem the solution doesn't depend on whether the bit string is converted into an integer using\nbig endian or little endian notation. In general, this is an important distinction that you need to take into account.</p>\n"
|
|
5708
5708
|
},
|
|
5709
5709
|
{
|
|
5710
5710
|
"type": "solution",
|
|
@@ -5721,7 +5721,7 @@ export default {
|
|
|
5721
5721
|
"items": [
|
|
5722
5722
|
{
|
|
5723
5723
|
"type": "text-content",
|
|
5724
|
-
"content": "<p>An oracle in the quantum world is a "black box" operation that is used as input to an algorithm (such as Deutsch-Jozsa algorithm or Grover's search algorithm).\nMany quantum algorithms assume an oracle implementation of some classical function as input, but this is a very strong assumption - sometimes implementing the oracle for a function is a lot more complex than the algorithm that will use this oracle!<br />\nIn this kata, you
|
|
5724
|
+
"content": "<p>An oracle in the quantum world is a "black box" operation that is used as input to an algorithm (such as Deutsch-Jozsa algorithm or Grover's search algorithm).\nMany quantum algorithms assume an oracle implementation of some classical function as input, but this is a very strong assumption - sometimes implementing the oracle for a function is a lot more complex than the algorithm that will use this oracle!<br />\nIn this kata, you'll learn the properties of quantum oracles and how to implement them.</p>\n<p>A quantum oracle implements a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}^m$, where the input is $n$-bits of the form $x = (x_{0}, x_{1}, \\dots, x_{n-1})$. In most commonly used cases $m=1$, that is, the function can return values $0$ or $1$. In this kata, you'll focus on this class of functions.</p>\n<p>Quantum oracles operate on qubit arrays (and can take classical parameters as well). The classical input is encoded into the state of an $n$-qubit register:<br />\n$$\\ket{\\vec{x}} = \\ket{x_0} \\otimes \\ket{x_1} \\otimes ... \\otimes \\ket{x_{n-1}},$$\nwhere $\\ket{x_i}$ represents the state of the $i$-th qubit.</p>\n<p>Oracles must be unitary transformations, and follow the same rules of linear algebra as other quantum operations.\nThis allows us to define quantum oracles based on their effect on the basis states - tensor products of single-qubit basis states $\\ket{0}$ and $\\ket{1}$.</p>\n<blockquote>\n<p>For example, an oracle that implements a function that takes two bits of input is defined using its effect on basis states $\\ket{00}$, $\\ket{01}$, $\\ket{10}$, and $\\ket{11}$.</p>\n</blockquote>\n<p>There are two types of quantum oracles: phase oracles and marking oracles. Let's take a closer look at them.</p>\n"
|
|
5725
5725
|
}
|
|
5726
5726
|
]
|
|
5727
5727
|
},
|
|
@@ -5732,7 +5732,7 @@ export default {
|
|
|
5732
5732
|
"items": [
|
|
5733
5733
|
{
|
|
5734
5734
|
"type": "text-content",
|
|
5735
|
-
"content": "<p>For a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}$, the phase oracle $U_{\\text{phase}}$ encodes the values of the function $f$ in the <em>relative phases</em> of basis states. When provided an input basis state $\\ket{\\vec{x}}$, it flips the sign of that state if $f(x)=1$:</p>\n<p>$$U_{phase} \\ket{\\vec{x}} = (-1)^{f(x)}\\ket{\\vec{x}}$$</p>\n<p>Thus, the phase oracle $U_{\\text{phase}}$ doesn't change the phase of the basis states for which $f(x)=0$, but multiplies the phase of the basis states for which $f(x)=1$ by $-1$.</p>\n<p>The effect of such an oracle on any single basis state
|
|
5735
|
+
"content": "<p>For a function $f: \\{0,1\\}^n \\rightarrow \\{0,1\\}$, the phase oracle $U_{\\text{phase}}$ encodes the values of the function $f$ in the <em>relative phases</em> of basis states. When provided an input basis state $\\ket{\\vec{x}}$, it flips the sign of that state if $f(x)=1$:</p>\n<p>$$U_{phase} \\ket{\\vec{x}} = (-1)^{f(x)}\\ket{\\vec{x}}$$</p>\n<p>Thus, the phase oracle $U_{\\text{phase}}$ doesn't change the phase of the basis states for which $f(x)=0$, but multiplies the phase of the basis states for which $f(x)=1$ by $-1$.</p>\n<p>The effect of such an oracle on any single basis state isn't particularly interesting: it just adds a global phase which is not something you can observe. However, if you apply this oracle to a <em>superposition</em> of basis states, its effect becomes noticeable.\nRemember that quantum operations are linear: if you define the effect of an operation on the basis states, you'll be able to deduce its effect on superposition states (which are just linear combinations of the basis states) using its linearity.</p>\n<p>A phase oracle doesn't have an "output", unlike the function it implements; the effect of the oracle application is the change in the state of the system.</p>\n"
|
|
5736
5736
|
}
|
|
5737
5737
|
]
|
|
5738
5738
|
},
|
|
@@ -5743,7 +5743,7 @@ export default {
|
|
|
5743
5743
|
"items": [
|
|
5744
5744
|
{
|
|
5745
5745
|
"type": "text-content",
|
|
5746
|
-
"content": "<p>Consider the function $f(x)$ that takes three bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise.</p>\n<p>The phase oracle that implements this function
|
|
5746
|
+
"content": "<p>Consider the function $f(x)$ that takes three bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise.</p>\n<p>The phase oracle that implements this function takes an array of three qubits as an input, flip the sign of basis states $\\ket{101}$ and $\\ket{010}$, and leave the rest of the basis states unchanged. Let's see the effect of this oracle on a superposition state.</p>\n"
|
|
5747
5747
|
},
|
|
5748
5748
|
{
|
|
5749
5749
|
"type": "example",
|
|
@@ -5752,7 +5752,7 @@ export default {
|
|
|
5752
5752
|
},
|
|
5753
5753
|
{
|
|
5754
5754
|
"type": "text-content",
|
|
5755
|
-
"content": "<p>
|
|
5755
|
+
"content": "<p>The Multi-Qubit Gates kata introduced the <code>ApplyControlledOnBitString</code> function provided by the Q# standard library when discussing controlled gates.\nThe <code>ApplyControlledOnBitString</code> function defines a variant of a gate controlled on a state specified by a bit mask. For example, bit mask <code>[true, false]</code> means that the gate should be applied only if the two control qubits are in the $\\ket{10}$ state.</p>\n<p>The sequence of steps that implement this variant are:</p>\n<ol>\n<li>Apply the $X$ gate to each control qubit that corresponds to a <code>false</code> element of the bit mask. After this, if the control qubits started in the $\\ket{10}$ state, they'll end up in the $\\ket{11}$ state, and if they started in any other state, they'll end up in any state but $\\ket{11}$.</li>\n<li>Apply the regular controlled version of the gate.</li>\n<li>Apply the $X$ gate to the same qubits to return them to their original state.</li>\n</ol>\n<blockquote>\n<p>Notice that the input state in the demo above is an equal superposition of all basis states.\nAfter applying the oracle the absolute values of all amplitudes are the same, but the states $\\ket{010}$ and $\\ket{101}$ had their phase flipped to negative.\nRecall that these two states are exactly the inputs for which $f(x) = 1$, thus they're exactly the two states we expect to experience a phase flip!</p>\n</blockquote>\n<p>In the next exercise, you'll implement the classical oracle that you've implemented in the first exercise, this time as a quantum phase oracle $U_{7,\\text{phase}}$ that encodes the number 7.</p>\n"
|
|
5756
5756
|
}
|
|
5757
5757
|
]
|
|
5758
5758
|
},
|
|
@@ -5784,7 +5784,7 @@ export default {
|
|
|
5784
5784
|
},
|
|
5785
5785
|
{
|
|
5786
5786
|
"type": "text-content",
|
|
5787
|
-
"content": "<p>Consider how this oracle acts on two basis states:\n$$U_{7,phase} \\ket{111} = -\\ket{111}$$\n$$U_{7,phase} \\ket{110} = \\ket{110}$$</p>\n<p>You can see that $U_{7,phase}$
|
|
5787
|
+
"content": "<p>Consider how this oracle acts on two basis states:\n$$U_{7,phase} \\ket{111} = -\\ket{111}$$\n$$U_{7,phase} \\ket{110} = \\ket{110}$$</p>\n<p>You can see that $U_{7,phase}$ doesn't change the input if it's a basis state (other than adding a global phase), and $U_{7,phase}$ doesn't change the norm of the state ($U_{7,phase}$ is a unitary operator).</p>\n<p>However, if you applied this oracle to a superposition state instead, what will that look like?</p>\n<p>Suppose that $\\ket{\\beta}$ is an equal superposition of the states $\\ket{110}$ and $\\ket{111}$:\n$$\\ket{\\beta} = \\frac{1}{\\sqrt{2}} \\big(\\ket{110} + \\ket{111}\\big) = \\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{0} + \\ket{1}\\big) = \\ket{11} \\otimes \\ket{+} = \\ket{11+}$$</p>\n<p>Let's consider how the operator $U_{7,phase}$ acts on this state:</p>\n<p>$$U_{7,phase} \\ket{\\beta} = U_{7,phase} \\Big[\\frac{1}{\\sqrt{2}} \\big(\\ket{110} + \\ket{111}\\big)\\Big] =$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big(U_{7,phase} \\ket{110} + U_{7,phase} \\ket{111}\\big) =$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big(\\ket{110} - \\ket{111}\\big) := \\ket{\\gamma}$$</p>\n<p>Was your input state modified during this operation? Let's simplify $\\ket{\\gamma}$:</p>\n<p>$$\\ket{\\gamma} = \\frac{1}{\\sqrt{2}} \\big(\\ket{110} - \\ket{111}\\big) =$$</p>\n<p>$$= \\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{0} - \\ket{1}\\big) =$$</p>\n<p>$$= \\ket{11} \\otimes \\ket{-} = \\ket{11-} \\neq \\ket{\\beta}$$</p>\n<p>Here you see that the oracle modifies the input, if the input state is a <em>superposition</em> of the basis states, as a phase oracle will only modify the sign of the basis states. Thus when a superposition state is provided as input to an oracle, the input state can be modified via the application of the quantum oracle.</p>\n<blockquote>\n<p>It's also worth noting that while the oracle modified the input when provided a superposition state, it did <em>not</em> modify the norm of that state. As an exercise, you can verify this yourself by taking the norm of $\\ket{\\beta}$ and $\\ket{\\gamma}$, which both will result in a value of $1$.</p>\n<p>As another exercise, consider how you could distinguish between the input and output state programmatically? Is there an operation that you could apply to the initial state $\\ket{\\beta}$ and the final state $\\ket{\\gamma}$ to show that the two states aren't equivalent through measurement? As a hint, think about how you could convert the superposition states $\\ket{\\beta}$ and $\\ket{\\gamma}$ into the basis states.</p>\n</blockquote>\n"
|
|
5788
5788
|
}
|
|
5789
5789
|
]
|
|
5790
5790
|
}
|
|
@@ -5796,7 +5796,7 @@ export default {
|
|
|
5796
5796
|
"items": [
|
|
5797
5797
|
{
|
|
5798
5798
|
"type": "text-content",
|
|
5799
|
-
"content": "<p>A marking oracle $U_{mark}$ is an oracle that encodes the value of the classical function $f$ it implements in the <em>amplitude</em> of the qubit state. When provided an input array of qubits in the basis state $\\ket{\\vec{x}}$ and an output qubit in the basis state $\\ket{y}$, it flips the state of the output qubit if $f(x)=1$. (You can also represent this as addition modulo 2 between $f(x)$ and $y$.) Hence $U_{mark}$ is an operator that performs the following operation:</p>\n<p>$$U_{mark}\\ket{\\vec{x}} \\ket{y} = U_{mark}\\big(\\ket{\\vec{x}} \\otimes \\ket{y}\\big) = \\ket{\\vec{x}} \\otimes \\ket{y \\oplus f(x)}$$</p>\n<p>Again, since all quantum operations are linear, you can figure out the effect of this operation on superposition state knowing its effect on the basis states using its linearity.</p>\n<p>A marking oracle has distinct "input" and "output" qubits, but in general the effect of the oracle application is the change in the state of the whole system rather than of the "output" qubits only.
|
|
5799
|
+
"content": "<p>A marking oracle $U_{mark}$ is an oracle that encodes the value of the classical function $f$ it implements in the <em>amplitude</em> of the qubit state. When provided an input array of qubits in the basis state $\\ket{\\vec{x}}$ and an output qubit in the basis state $\\ket{y}$, it flips the state of the output qubit if $f(x)=1$. (You can also represent this as addition modulo 2 between $f(x)$ and $y$.) Hence $U_{mark}$ is an operator that performs the following operation:</p>\n<p>$$U_{mark}\\ket{\\vec{x}} \\ket{y} = U_{mark}\\big(\\ket{\\vec{x}} \\otimes \\ket{y}\\big) = \\ket{\\vec{x}} \\otimes \\ket{y \\oplus f(x)}$$</p>\n<p>Again, since all quantum operations are linear, you can figure out the effect of this operation on superposition state knowing its effect on the basis states using its linearity.</p>\n<p>A marking oracle has distinct "input" and "output" qubits, but in general the effect of the oracle application is the change in the state of the whole system rather than of the "output" qubits only. You'll look at this closer in a moment.</p>\n"
|
|
5800
5800
|
}
|
|
5801
5801
|
]
|
|
5802
5802
|
},
|
|
@@ -5807,7 +5807,7 @@ export default {
|
|
|
5807
5807
|
"items": [
|
|
5808
5808
|
{
|
|
5809
5809
|
"type": "text-content",
|
|
5810
|
-
"content": "<p>Consider the function $f(x)$ that takes three bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise (it
|
|
5810
|
+
"content": "<p>Consider the function $f(x)$ that takes three bits of input and returns $1$ if $x=101$ or $x=010$, and $0$ otherwise (it's the function in the lesson "Phase Oracle for Alternating Bit Pattern Function").</p>\n<p>The marking oracle that implements this function takes an array of three qubits as an "input" register and an "output" qubit, and flips the state of the output qubit if the input qubit is in basis state $\\ket{101}$ or $\\ket{010}$, and does nothing otherwise. Let's see the effect of this oracle on a superposition state.</p>\n"
|
|
5811
5811
|
},
|
|
5812
5812
|
{
|
|
5813
5813
|
"type": "example",
|
|
@@ -5816,7 +5816,7 @@ export default {
|
|
|
5816
5816
|
},
|
|
5817
5817
|
{
|
|
5818
5818
|
"type": "text-content",
|
|
5819
|
-
"content": "<blockquote>\n<p>Let's compare the initial state to the final state from the above demo.\nIn the initial state
|
|
5819
|
+
"content": "<blockquote>\n<p>Let's compare the initial state to the final state from the above demo.\nIn the initial state, there's a tensor product of an equal superposition of all three-qubit basis states and the state $\\ket{0}$. In the final state, this is no longer the case.\nThe basis states $\\ket{010} \\otimes \\ket{0}$ and $\\ket{101} \\otimes \\ket{0}$ no longer have non-zero amplitudes, and instead $\\ket{010} \\otimes \\ket{1}$ and $\\ket{101} \\otimes \\ket{1}$ have non-zero amplitudes.</p>\n<p>This is exactly the expected result. Recall the function $f(x)$: $f(x)=1$ if and only if $x=010$ or $x=101$. The first three qubits (variable <code>x</code>) represent the input state $\\ket{x}$, and the last qubit (variable <code>y</code>) represents the output state $\\ket{y}$. Thus for the two basis states, $\\ket{x}=\\ket{010}$ or $\\ket{x}=\\ket{101}$, the function flips the state of the qubit $\\ket{y}$, causing these two initial states to be tensored with $\\ket{1}$ in the final state where originally they were tensored with $\\ket{0}$.</p>\n<p>Since the rest of the basis states correspond to $f(x) = 0$, all other basis states in the initial superposition remain unchanged.</p>\n</blockquote>\n<p>Now you'll implement the same function you've seen in the first two exercises as a marking oracle $U_{7,mark}$.</p>\n"
|
|
5820
5820
|
}
|
|
5821
5821
|
]
|
|
5822
5822
|
},
|
|
@@ -5848,7 +5848,7 @@ export default {
|
|
|
5848
5848
|
},
|
|
5849
5849
|
{
|
|
5850
5850
|
"type": "text-content",
|
|
5851
|
-
"content": "<p>Consider how the oracle from this exercise acts on two input basis states and two "output" basis states:</p>\n<p>$$U_{7,mark} \\ket{111} \\ket{0} = \\ket{111} \\ket{0 \\oplus f(111)} = \\ket{111} \\ket{0 \\oplus 1} = \\ket{111} \\ket{1}$$</p>\n<p>$$U_{7,mark} \\ket{111} \\ket{1} = \\ket{111} \\ket{1 \\oplus f(111)} = \\ket{111} \\ket{1 \\oplus 1} = \\ket{111} \\ket{0}$$</p>\n<p>$$U_{7,mark} \\ket{110} \\ket{0} = \\ket{110} \\ket{0 \\oplus f(110)} = \\ket{110} \\ket{0 \\oplus 0} = \\ket{110} \\ket{0}$$</p>\n<p>$$U_{7,mark} \\ket{110} \\ket{1} = \\ket{110} \\ket{1 \\oplus f(110)} = \\ket{110} \\ket{1 \\oplus 0} = \\ket{110} \\ket{1}$$</p>\n<p>You can see that the state of the input qubit array is unchanged, and the state of the output qubit changes if $f(x) = 1$ and is unchanged if $f(x) = 0$ - this matches the definition of a marking oracle precisely.</p>\n<p>Now let's again apply this oracle to a superposition state $\\ket{\\alpha}$ such that $\\ket{x}$ is a superposition of the basis states $\\ket{110}$ and $\\ket{111}$ and $\\ket{y} = \\ket{0}$:\n$$\\ket{\\alpha} = \\frac{1}{\\sqrt{2}}\\big(\\ket{110} + \\ket{111}\\big)\\ket{0} = \n\\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{0} + \\ket{1}\\big) \\otimes \\ket{0} = \\ket{11+} \\ket{0}$$</p>\n<p>Let's consider how
|
|
5851
|
+
"content": "<p>Consider how the oracle from this exercise acts on two input basis states and two "output" basis states:</p>\n<p>$$U_{7,mark} \\ket{111} \\ket{0} = \\ket{111} \\ket{0 \\oplus f(111)} = \\ket{111} \\ket{0 \\oplus 1} = \\ket{111} \\ket{1}$$</p>\n<p>$$U_{7,mark} \\ket{111} \\ket{1} = \\ket{111} \\ket{1 \\oplus f(111)} = \\ket{111} \\ket{1 \\oplus 1} = \\ket{111} \\ket{0}$$</p>\n<p>$$U_{7,mark} \\ket{110} \\ket{0} = \\ket{110} \\ket{0 \\oplus f(110)} = \\ket{110} \\ket{0 \\oplus 0} = \\ket{110} \\ket{0}$$</p>\n<p>$$U_{7,mark} \\ket{110} \\ket{1} = \\ket{110} \\ket{1 \\oplus f(110)} = \\ket{110} \\ket{1 \\oplus 0} = \\ket{110} \\ket{1}$$</p>\n<p>You can see that the state of the input qubit array is unchanged, and the state of the output qubit changes if $f(x) = 1$ and is unchanged if $f(x) = 0$ - this matches the definition of a marking oracle precisely.</p>\n<p>Now let's again apply this oracle to a superposition state $\\ket{\\alpha}$ such that $\\ket{x}$ is a superposition of the basis states $\\ket{110}$ and $\\ket{111}$ and $\\ket{y} = \\ket{0}$:\n$$\\ket{\\alpha} = \\frac{1}{\\sqrt{2}}\\big(\\ket{110} + \\ket{111}\\big)\\ket{0} = \n\\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{0} + \\ket{1}\\big) \\otimes \\ket{0} = \\ket{11+} \\ket{0}$$</p>\n<p>Let's consider how the operator $U_{7,mark}$ acts on this state.</p>\n<blockquote>\n<p>Recall that oracles are linear operators, thus they can be applied to each term individually.</p>\n</blockquote>\n<p>$$U_{7,mark} \\ket{\\alpha} = \\frac{1}{\\sqrt{2}} \\big(U_{7,mark}\\ket{110} \\ket{0} + U_{7,mark}\\ket{111} \\ket{0}\\big) =$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big(\\ket{110} \\ket{0} + \\ket{111} \\ket{1}\\big) := \\ket{\\epsilon}$$</p>\n<p>Was your input state modified during this operation? Let's simplify the resulting state $\\ket{\\epsilon}$:</p>\n<p>$$\\ket{\\epsilon} = \\frac{1}{\\sqrt{2}} \\big(\\ket{110} \\ket{0} + \\ket{111} \\ket{1}\\big) = \\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{0} \\ket{0} + \\ket{1} \\ket{1}\\big) =$$</p>\n<p>$$= \\ket{11} \\otimes \\frac{1}{\\sqrt{2}} \\big(\\ket{00} + \\ket{11}\\big) = \\ket{11} \\otimes \\ket{\\Phi^+} = \\ket{11\\Phi^+}$$</p>\n<p>You have entangled the states of qubits $\\ket{x}$ and $\\ket{y}$! This is a common occurrence for marking oracles when the input is a superposition of basis states: after applying the oracle, the input $\\ket{x}$ will often become entangled with $\\ket{y}$. Thus, while applying the marking oracle to a basis state will leave the input array unchanged, applying the marking oracle to a superposition state will change the state of both the input array and the output qubit.</p>\n<blockquote>\n<p>As an exercise, what entangled state would you get in the previous example if $\\ket{y} = \\ket{1}$ instead of $\\ket{y} = \\ket{0}$?</p>\n<details>\n <summary><b>Answer</b></summary>\n$$U_{7,mark} \\ket{11+} \\ket{1} = \\ket{11} \\otimes \\frac1{\\sqrt2}\\big(\\ket{01} + \\ket{10}\\big) = \\ket{11} \\ket{\\Psi^+}$$\n</details></blockquote>\n"
|
|
5852
5852
|
}
|
|
5853
5853
|
]
|
|
5854
5854
|
}
|
|
@@ -5860,7 +5860,7 @@ export default {
|
|
|
5860
5860
|
"items": [
|
|
5861
5861
|
{
|
|
5862
5862
|
"type": "text-content",
|
|
5863
|
-
"content": "<p>Previously we considered applying marking oracles when the register $\\ket{x}$ was in a basis state or a superposition state, and the target qubit $\\ket{y}$ was in a basis state. How might the effect of applying marking oracles change if the target is also in a superposition state? In this case we might observe <strong>phase kickback</strong> - the relative phase from the target qubit affecting ("kicked back" into) the state of the input qubits.</p>\n<p>In order to observe phase kickback,
|
|
5863
|
+
"content": "<p>Previously we considered applying marking oracles when the register $\\ket{x}$ was in a basis state or a superposition state, and the target qubit $\\ket{y}$ was in a basis state. How might the effect of applying marking oracles change if the target is also in a superposition state? In this case we might observe <strong>phase kickback</strong> - the relative phase from the target qubit affecting ("kicked back" into) the state of the input qubits.</p>\n<p>In order to observe phase kickback, the target qubit is $\\ket{y}=\\ket{-}$.</p>\n<blockquote>\n<p>This is the standard choice for two reasons.\nFirst, for phase kickback to occur, the target qubit must have a difference in relative phase between the basis states $\\ket{0}$ and $\\ket{1}$.\nSecond, the absolute values of the amplitudes of the two basis states of the target qubit must be equal, otherwise the target will become entangled with the input register.</p>\n</blockquote>\n<p>Let's see the results of applying a marking oracle $U_{mark}$ which implements the function $f(x)$ to the input register $\\ket{x}$ and the target qubit in state $\\ket{-}$:</p>\n<ul>\n<li>If the input register $\\ket{x}$ is in a basis state:</li>\n</ul>\n<p>$$U_{mark} \\ket{x} \\ket{-} = \\frac1{\\sqrt2} \\big(U_{mark}\\ket{x}\\ket{0} - U_{mark}\\ket{x} \\ket{1}\\big) =$$</p>\n<p>$$= \\frac1{\\sqrt2} \\big(\\ket{x}\\ket{0\\oplus f(x)} - \\ket{x} \\ket{1\\oplus f(x)}\\big) =$$</p>\n<p>$$=\\begin{cases}\n\\frac1{\\sqrt2} \\big(\\ket{x}\\ket{0} - \\ket{x} \\ket{1}\\big) = \\ket{x}\\ket{-} \\text{ if } f(x) = 0 \\\\\n\\frac1{\\sqrt2} \\big(\\ket{x}\\ket{1} - \\ket{x} \\ket{0}\\big) = -\\ket{x}\\ket{-} \\text{ if } f(x) = 1\n\\end{cases}=$$</p>\n<p>$$= (-1)^{f(x)}\\ket{x} \\ket{-}$$</p>\n<ul>\n<li>If the input register is in a superposition state, say $\\ket{x} = \\frac1{\\sqrt2} \\big(\\ket{b_1} + \\ket{b_2}\\big)$, where $\\ket{b_1}$ and $\\ket{b_2}$ are basis states:</li>\n</ul>\n<p>$$U_{mark} \\ket{x} \\ket{-} = U_{mark} \\frac{1}{\\sqrt{2}} \\big(\\ket{b_1} + \\ket{b_2}\\big) \\ket{-} =$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( U_{mark}\\ket{b_1}\\ket{-} + U_{mark}\\ket{b_2}\\ket{-}\\big) =$$</p>\n<p>$$= \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}\\ket{b_1} + (-1)^{f(b_2)}\\ket{b_2}\\big) \\ket{-}$$</p>\n<p>In both cases applying $U_{mark}$ doesn't change the state of the target qubit, but it does change the state of the input register.\nThus you can drop the target qubit without any repercussions after the application of the oracle.\nNotice that the input register is now in the following state:\n$$\\ket{\\psi} = \\frac{1}{\\sqrt{2}} \\big( (-1)^{f(b_1)}\\ket{b_1} + (-1)^{f(b_2)}\\ket{b_2}\\big),$$</p>\n<p>which looks exactly as if you apply a phase oracle to $\\ket{x}$ instead of applying a marking oracle to $\\ket{x}\\ket{-}$! This is a very important application of phase kickback: it allows to convert a marking oracle into a phase oracle - which you'll implement in the next task.</p>\n<blockquote>\n<p>Another important application of this effect is <strong>phase estimation</strong> algorithm, which allows to estimate an eigenvalue of an eigenvector.</p>\n</blockquote>\n<p>Consider the following example using the $U_{7,mark}$ oracle. Let's begin with $\\ket{x}$ as an equal superposition of the $\\ket{110}$ and $\\ket{111}$ basis states and $\\ket{y}=\\ket{-}$, the overall state is:</p>\n<p>$$\\ket{\\eta} = \\Big[\\frac{1}{\\sqrt{2}}\\big(\\ket{110} + \\ket{111}\\big)\\Big] \\otimes \\frac{1}{\\sqrt{2}}\\big(\\ket{0} - \\ket{1}\\big) =$$</p>\n<p>$$= \\frac{1}{2} \\big(\\ket{110}\\ket{0} + \\ket{111}\\ket{0} - \\ket{110}\\ket{1} - \\ket{111}\\ket{1}\\big)$$</p>\n<p>How does $U_{7,mark}$ act on this state?</p>\n<p>$$U_{7,mark}\\ket{\\eta} = U_{7,mark} \\frac{1}{2} \\big(\\ket{110}\\ket{0} + \\ket{111}\\ket{0} - \\ket{110}\\ket{1} - \\ket{111}\\ket{1} \\big) =$$</p>\n<p>$$= \\frac{1}{2} \\big( U_{7,mark}\\ket{110}\\ket{0} + U_{7,mark}\\ket{111}\\ket{0} - U_{7,mark}\\ket{110}\\ket{1} - U_{7,mark}\\ket{111}\\ket{1} \\big) =$$</p>\n<p>$$= \\frac{1}{2} \\big(\\ket{110}\\ket{0} + \\ket{111}\\ket{1} - \\ket{110}\\ket{1} - \\ket{111}\\ket{0} \\big) := \\ket{\\xi}$$</p>\n<p>Now you want to observe how your input state $\\ket{\\eta}$ is modified by the oracle. Let's simplify the resulting state $\\ket{\\xi}$:</p>\n<p>$$\\ket{\\xi} = \\frac{1}{2} \\big(\\ket{110}\\ket{0} + \\ket{111}\\ket{1} - \\ket{110}\\ket{1} - \\ket{111}\\ket{0}\\big) =$$</p>\n<p>$$= \\frac{1}{2} \\big(\\ket{110}\\ket{0} - \\ket{110}\\ket{1} - \\ket{111}\\ket{0} + \\ket{111}\\ket{1} \\big) =$$</p>\n<p>$$= \\frac{1}{2} \\Big[\\ket{110} \\otimes \\big(\\ket{0} - \\ket{1} \\big) + \\ket{111} \\otimes \\big(\\ket{1} - \\ket{0}\\big)\\Big] =$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( \\ket{110} - \\ket{111} \\big) \\Big] \\otimes \\Big[ \\frac{1}{\\sqrt{2}} \\big( \\ket{0} - \\ket{1} \\big) \\Big] =$$</p>\n<p>$$= \\Big[\\frac{1}{\\sqrt{2}} \\big( \\ket{110} - \\ket{111} \\big) \\Big] \\otimes \\ket{-}$$</p>\n<p>Finally, let's compare $\\ket{\\eta}$ and $\\ket{\\xi}$; below are the final equations repeated for your convenience:\n$$\\ket{\\eta} = \\Big[\\frac{1}{\\sqrt{2}}\\big(\\ket{110} + \\ket{111}\\big)\\Big] \\otimes \\ket{-}$$\n$$\\ket{\\xi} = \\Big[\\frac{1}{\\sqrt{2}}\\big(\\ket{110} - \\ket{111}\\big)\\Big] \\otimes \\ket{-}$$</p>\n<p>You can see that these two equations are identical, except for the $-1$ phase that appeared on the $\\ket{111}$ basis state - our marked state. This is a specific example of the phase kickback effect, as the phase from $\\ket{-}$ has been <em>kicked back</em> into $\\ket{x}$.</p>\n"
|
|
5864
5864
|
}
|
|
5865
5865
|
]
|
|
5866
5866
|
},
|
|
@@ -5883,7 +5883,7 @@ export default {
|
|
|
5883
5883
|
"items": [
|
|
5884
5884
|
{
|
|
5885
5885
|
"type": "text-content",
|
|
5886
|
-
"content": "<p>As
|
|
5886
|
+
"content": "<p>As you just saw, you can allocate an additional qubit in the $\\ket{-}$ state and use it as the target for our marking oracle.\nThis will kick back the $-1$ relative phase for the basis states $\\ket{x}$ of the input register for which $f(x) = 1$.</p>\n"
|
|
5887
5887
|
},
|
|
5888
5888
|
{
|
|
5889
5889
|
"type": "solution",
|
|
@@ -5900,7 +5900,7 @@ export default {
|
|
|
5900
5900
|
"items": [
|
|
5901
5901
|
{
|
|
5902
5902
|
"type": "text-content",
|
|
5903
|
-
"content": "<p>In this demo
|
|
5903
|
+
"content": "<p>In this demo you'll use a reference implementation of <code>ApplyMarkingOracleAsPhaseOracle</code> operation to convert marking oracle <code>IsSeven_MarkingOracle</code> to a phase oracle. Then you'll compare this converted oracle to the reference implementation of the phase oracle <code>IsSeven_PhaseOracle</code>. You already implemented these oracles in the previous tasks.</p>\n"
|
|
5904
5904
|
},
|
|
5905
5905
|
{
|
|
5906
5906
|
"type": "example",
|
|
@@ -5909,7 +5909,7 @@ export default {
|
|
|
5909
5909
|
},
|
|
5910
5910
|
{
|
|
5911
5911
|
"type": "text-content",
|
|
5912
|
-
"content": "<blockquote>\n<p>Notice from the above demo that your phase oracle $U_{7,phase}$ behaves the same as the converted version of your marking oracle $U_{7,mark}$, both of which induce a phase flip on the basis state $\\ket{111}$!</p>\n</blockquote>\n<p>This way to convert a marking oracle to a phase oracle is useful because many quantum algorithms, such as Grover's search algorithm, rely on a phase oracle, but it
|
|
5912
|
+
"content": "<blockquote>\n<p>Notice from the above demo that your phase oracle $U_{7,phase}$ behaves the same as the converted version of your marking oracle $U_{7,mark}$, both of which induce a phase flip on the basis state $\\ket{111}$!</p>\n</blockquote>\n<p>This way to convert a marking oracle to a phase oracle is useful because many quantum algorithms, such as Grover's search algorithm, rely on a phase oracle, but it's often easier to implement the function as a marking oracle.\nThis converter provides a way to implement the function of interest as a marking oracle and then convert it into a phase oracle, which could then be leveraged in a quantum algorithm.</p>\n"
|
|
5913
5913
|
}
|
|
5914
5914
|
]
|
|
5915
5915
|
},
|
|
@@ -5920,7 +5920,7 @@ export default {
|
|
|
5920
5920
|
"items": [
|
|
5921
5921
|
{
|
|
5922
5922
|
"type": "text-content",
|
|
5923
|
-
"content": "<p>In this section you
|
|
5923
|
+
"content": "<p>In this section you'll implement a few more complicated quantum oracles.\nSome of them - both phase and marking - can take extra "classical" parameters.\nA useful tool for implementing quantum oracles is allocating auxiliary qubits to assist in a computation.\nYou'll practice that in some of the exercises below.</p>\n<blockquote>\n<p>Notice that the operation declarations below require adjoint and controlled variants of the oracle to be automatically generated. This is common practice that makes testing and reusing the code easier. Typically Q# compiler will easily generate these variants, as long as you don't use mutable variables or operations that don't support these functors.</p>\n</blockquote>\n"
|
|
5924
5924
|
}
|
|
5925
5925
|
]
|
|
5926
5926
|
},
|
|
@@ -5930,7 +5930,7 @@ export default {
|
|
|
5930
5930
|
"title": "Implement the OR Oracle",
|
|
5931
5931
|
"description": {
|
|
5932
5932
|
"type": "text-content",
|
|
5933
|
-
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A qubit in an arbitrary state $\\ket{y}$ (target qubit).</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the state of $\\ket{y}$ if the input register is in any basis state\nexcept for $\\ket{00...0}$ (the all zero state).</p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{10000001}$, $\\ket{11101101}$ or $\\ket{0010101}$, flip the state $\\ket{y}$.</li>\n<li>If the query register is in the state $\\ket{000}$, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a marking oracle, because
|
|
5933
|
+
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A qubit in an arbitrary state $\\ket{y}$ (target qubit).</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the state of $\\ket{y}$ if the input register is in any basis state\nexcept for $\\ket{00...0}$ (the all zero state).</p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{10000001}$, $\\ket{11101101}$ or $\\ket{0010101}$, flip the state $\\ket{y}$.</li>\n<li>If the query register is in the state $\\ket{000}$, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a marking oracle, because you're flipping the state of the target qubit $\\ket{y}$ based on the state of the input $\\ket{x}$.\n</details>\n<br/>\n<details>\n <summary><b>Need a hint?</b></summary>\n You need to flip the state of $\\ket{y}$ for every input except $\\ket{00...0}$, or, alternatively, flip it unconditionally and then flip it for the $\\ket{00...0}$ state. You may find the Q# library function <code>ApplyControlledOnInt</code> useful in your implementation.\n</details>\n"
|
|
5934
5934
|
},
|
|
5935
5935
|
"sourceIds": [
|
|
5936
5936
|
"oracles__or_oracle__Verification.qs",
|
|
@@ -5943,7 +5943,7 @@ export default {
|
|
|
5943
5943
|
"items": [
|
|
5944
5944
|
{
|
|
5945
5945
|
"type": "text-content",
|
|
5946
|
-
"content": "<p>What if you needed to flip the state of the target qubit only if the input register
|
|
5946
|
+
"content": "<p>What if you needed to flip the state of the target qubit only if the input register is in the $\\ket{0...0}$ state?\nIn that case, you could use <code>ApplyControlledOnInt</code> with the control pattern $0$ that corresponds to all control qubits in $\\ket{0}$ state.</p>\n<p>In this problem, you need to separate the $\\ket{0...0}$ basis state from all others, but with the opposite effect on the target qubit: instead of flipping it for this input state, you need to flip it for all other input states.\nOr, you can think of it as first flipping the state of the target qubit for all states, and then un-flipping it (or flipping it again) for just this basis state. You can do this by applying the $X$ gate before or after <code>ApplyControlledOnInt</code>.</p>\n<p>Notice that you can modify the state of the input register during your computations (this is what <code>ApplyControlledOnInt</code> function does under the hood). However, it's essential to undo those modifications ("uncompute" the changes), except the final one, so that the oracle will preserve the input if it's a basis state.</p>\n"
|
|
5947
5947
|
},
|
|
5948
5948
|
{
|
|
5949
5949
|
"type": "solution",
|
|
@@ -5959,7 +5959,7 @@ export default {
|
|
|
5959
5959
|
"title": "Implement the K-th Bit Oracle",
|
|
5960
5960
|
"description": {
|
|
5961
5961
|
"type": "text-content",
|
|
5962
|
-
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>An integer $k$ such that $0 \\leq k < N$.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the input state $\\ket{x}$ if the $k$-th bit of $x$ is $1$.<br />\n<em>Implement this oracle without using auxiliary qubits.</em></p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and $k=0$, do nothing.</li>\n<li>If the query register is in the state $\\ket{010}$ and $k=1$, flip the sign of the basis state.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a phase oracle, because
|
|
5962
|
+
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>An integer $k$ such that $0 \\leq k < N$.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the input state $\\ket{x}$ if the $k$-th bit of $x$ is $1$.<br />\n<em>Implement this oracle without using auxiliary qubits.</em></p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and $k=0$, do nothing.</li>\n<li>If the query register is in the state $\\ket{010}$ and $k=1$, flip the sign of the basis state.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a phase oracle, because you're changing the phase of the input state $\\ket{x}$ based on the value of the function $f(x)$.\n</details>\n"
|
|
5963
5963
|
},
|
|
5964
5964
|
"sourceIds": [
|
|
5965
5965
|
"oracles__kth_bit_oracle__Verification.qs",
|
|
@@ -5972,7 +5972,7 @@ export default {
|
|
|
5972
5972
|
"items": [
|
|
5973
5973
|
{
|
|
5974
5974
|
"type": "text-content",
|
|
5975
|
-
"content": "<p>Since the effect of this oracle depends only on the value of the $k$-th qubit,
|
|
5975
|
+
"content": "<p>Since the effect of this oracle depends only on the value of the $k$-th qubit, you can ignore the rest of the qubits and focus on just <code>x[k]</code>.\nYou need to flip the phase of the qubit if it is in the $\\ket{1}$ state and leave it unchanged otherwise - this is exactly the effect of the $Z$ gate.</p>\n"
|
|
5976
5976
|
},
|
|
5977
5977
|
{
|
|
5978
5978
|
"type": "solution",
|
|
@@ -5988,7 +5988,7 @@ export default {
|
|
|
5988
5988
|
"title": "Implement the OR Oracle of All Bits Except the K-th",
|
|
5989
5989
|
"description": {
|
|
5990
5990
|
"type": "text-content",
|
|
5991
|
-
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N \\geq 2$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>An integer $k$ such that $0 \\leq k < N$.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the basis state $\\ket{x}$ if any of the bits of $x$ (not considering the $k$-th bit) are $1$ in the input register. In other words, the input register with the $k$-th qubit excluded
|
|
5991
|
+
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N \\geq 2$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>An integer $k$ such that $0 \\leq k < N$.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the basis state $\\ket{x}$ if any of the bits of $x$ (not considering the $k$-th bit) are $1$ in the input register. In other words, the input register with the $k$-th qubit excluded shouldn't be in the all zero state to flip the sign of the input register. The state of the $k$-th qubit does not affect the result.</p>\n<p><em>Feel free to explore implementing this operation with or without auxiliary qubits.</em></p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and $k=0$, flip the sign of the register.</li>\n<li>If the query register is in the state $\\ket{010}$ and $k=1$, do nothing.</li>\n</ul>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a phase oracle, because you're changing the phase of the input state $\\ket{x}$ based on the value of the function $f(x)$.\n</details>\n<details>\n <summary><b>Need a hint?</b></summary>\n You can use the previously implemented oracles if needed by copying the code.\n <br/>\n You can use <a href=\"https://learn.microsoft.com/azure/quantum/user-guide/language/expressions/itemaccessexpressions#array-item-access-and-array-slicing\" target=\"_blank\">array slicing</a> to get parts of the array before and after the $k$-th element.\n</details>\n"
|
|
5992
5992
|
},
|
|
5993
5993
|
"sourceIds": [
|
|
5994
5994
|
"oracles__or_but_kth_oracle__Verification.qs",
|
|
@@ -6017,7 +6017,7 @@ export default {
|
|
|
6017
6017
|
"title": "Implement the Arbitrary Bit Pattern Oracle",
|
|
6018
6018
|
"description": {
|
|
6019
6019
|
"type": "text-content",
|
|
6020
|
-
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A qubit in an arbitrary state $\\ket{y}$ (target qubit).</li>\n<li>A boolean array of length $N$ <code>pattern</code> representing a basis state; <code>true</code> and <code>false</code> elements correspond to $\\ket{1}$ and $\\ket{0}$, respectively.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the state of $\\ket{y}$ if the input register matches the basis state\nrepresented by <code>pattern</code>.</p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and <code>pattern = [false, true, false]</code>, flip the state $\\ket{y}$.</li>\n<li>If the query register is in the state $\\ket{1001}$ and <code>pattern = [false, true, true, false]</code>, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a marking oracle, because
|
|
6020
|
+
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A qubit in an arbitrary state $\\ket{y}$ (target qubit).</li>\n<li>A boolean array of length $N$ <code>pattern</code> representing a basis state; <code>true</code> and <code>false</code> elements correspond to $\\ket{1}$ and $\\ket{0}$, respectively.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the state of $\\ket{y}$ if the input register matches the basis state\nrepresented by <code>pattern</code>.</p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and <code>pattern = [false, true, false]</code>, flip the state $\\ket{y}$.</li>\n<li>If the query register is in the state $\\ket{1001}$ and <code>pattern = [false, true, true, false]</code>, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a marking oracle, because you're flipping the state of the target qubit $\\ket{y}$ based on the state of the input $\\ket{x}$.\n</details>\n<br/>\n<details>\n <summary><b>Need a hint?</b></summary>\n You need to flip the state of $\\ket{y}$ if $\\ket{x}$ matches the given pattern. You may find the Q# library operation <code>ApplyControlledOnBitString</code> useful in your implementation.\n</details>\n"
|
|
6021
6021
|
},
|
|
6022
6022
|
"sourceIds": [
|
|
6023
6023
|
"oracles__bit_pattern_oracle__Verification.qs",
|
|
@@ -6046,7 +6046,7 @@ export default {
|
|
|
6046
6046
|
"title": "Implement the Arbitrary Bit Pattern Oracle (Challenge Version)",
|
|
6047
6047
|
"description": {
|
|
6048
6048
|
"type": "text-content",
|
|
6049
|
-
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A boolean array of length $N$ <code>pattern</code> representing a basis state; <code>true</code> and <code>false</code> elements correspond to $\\ket{1}$ and $\\ket{0}$, respectively.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the input state $\\ket{x}$ if the input register matches the basis state\nrepresented by <code>pattern</code>.<br />\n<em>Implement this oracle without using auxiliary qubits</em></p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and <code>pattern = [false, true, false]</code>, flip the sign of the input register.</li>\n<li>If the query register is in the state $\\ket{1001}$ and <code>pattern = [false, true, true, false]</code>, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a phase oracle, because
|
|
6049
|
+
"content": "<p><strong>Inputs:</strong></p>\n<ol>\n<li>$N$ qubits in an arbitrary state $\\ket{x}$ (input/query register).</li>\n<li>A boolean array of length $N$ <code>pattern</code> representing a basis state; <code>true</code> and <code>false</code> elements correspond to $\\ket{1}$ and $\\ket{0}$, respectively.</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the sign of the input state $\\ket{x}$ if the input register matches the basis state\nrepresented by <code>pattern</code>.<br />\n<em>Implement this oracle without using auxiliary qubits</em></p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If the query register is in the state $\\ket{010}$ and <code>pattern = [false, true, false]</code>, flip the sign of the input register.</li>\n<li>If the query register is in the state $\\ket{1001}$ and <code>pattern = [false, true, true, false]</code>, do nothing.</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a phase oracle, because you're changing the phase of the input state $\\ket{x}$ based on the value of the function $f(x)$.\n</details>\n<br/>\n<details>\n <summary><b>Need a hint?</b></summary>\n Can you transform the state of the input register based on the <code>pattern</code> value so as to have to flip the phase only for the $\\ket{1...1}$ state?\n</details>\n"
|
|
6050
6050
|
},
|
|
6051
6051
|
"sourceIds": [
|
|
6052
6052
|
"oracles__bit_pattern_challenge__Verification.qs",
|
|
@@ -6075,7 +6075,7 @@ export default {
|
|
|
6075
6075
|
"title": "Implement the Meeting Oracle",
|
|
6076
6076
|
"description": {
|
|
6077
6077
|
"type": "text-content",
|
|
6078
|
-
"content": "<p>Suppose that you
|
|
6078
|
+
"content": "<p>Suppose that you'd like to schedule a meeting with your co-worker Jasmine.\nYou both work five day workweeks, and $\\ket{x}$ and $\\ket{jasmine}$ are 5-bit states representing your and Jasmine's schedules.\nThe schedules are indicators of a person being busy on that day: a $1$ bit means that person is busy on that day, and $0$ means they're free for a meeting that day. Implement a function that determines if you and Jasmine can schedule a meeting during the week, that is, whether there is a day when both schedules have a $0$ simultaneously.</p>\n<p><strong>Inputs:</strong></p>\n<ol>\n<li>5 qubits in an arbitrary state $\\ket{x}$ representing your schedule for the week (input/query register).</li>\n<li>5 qubits in an arbitrary state $\\ket{jasmine}$ representing Jasmine's schedule for the week (input/query register).</li>\n<li>A qubit in an arbitrary state $\\ket{y}$ (target qubit).</li>\n</ol>\n<p><strong>Goal:</strong></p>\n<p>Flip the state of $\\ket{y}$ if you and Jasmine are both free on the same day for at least one day during the week. Recall that a $0$ means that a person is free on that day.</p>\n<p><strong>Examples:</strong></p>\n<ul>\n<li>If $\\ket{x}=\\ket{10101}$ and $\\ket{jasmine}=\\ket{01010}$, do nothing (there is no day on which you both are free).</li>\n<li>If $\\ket{x}=\\ket{10001}$ and $\\ket{jasmine}=\\ket{01010}$, flip the state $\\ket{y}$ (you are both free on Wednesday).</li>\n<li>If $\\ket{x}=\\ket{00000}$ and $\\ket{jasmine}=\\ket{00000}$, flip the state $\\ket{y}$ (you are both free all week).</li>\n<li>If $\\ket{x}=\\ket{11111}$ and $\\ket{jasmine}=\\ket{11111}$, do nothing (you are both busy all week).</li>\n</ul>\n<br/>\n<details>\n <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary>\n This is a marking oracle, because you're flipping the state of the target qubit $\\ket{y}$ based on the state of the inputs $\\ket{x}$ and $\\ket{jasmine}$. Notice that even though you don't have the typical single-input-register situation that we saw earlier, this is still a marking oracle.\n</details>\n"
|
|
6079
6079
|
},
|
|
6080
6080
|
"sourceIds": [
|
|
6081
6081
|
"oracles__meeting_oracle__Verification.qs",
|
|
@@ -6088,7 +6088,7 @@ export default {
|
|
|
6088
6088
|
"items": [
|
|
6089
6089
|
{
|
|
6090
6090
|
"type": "text-content",
|
|
6091
|
-
"content": "<p>In this problem
|
|
6091
|
+
"content": "<p>In this problem you'll need to allocate extra qubits, one per each day of the week, to serve as temporary variables.\nEach of these variables will track whether both people are free on that day, that is, whether both input qubit arrays\nhave bit $0$ in the corresponding position. You can compute each of these variables using a $CCNOT$ gate after flipping\nthe states of both qubits using $X$ gates.</p>\n<p>After this, you can reuse the marking OR oracle to check whether any of the days are in $\\ket{1}$ state.</p>\n<p>When you allocate qubits for temporary use during a larger computation, you need to make sure they are returned to the $\\ket{0}$\nstate before being released. Unlike your previous experience allocating qubits in demos, though, this time you cannot\nmeasure these qubits for this - they are likely entangled with the qubits you're still using, so a measurement would\ncollapse the state of the whole system, not just the auxiliary qubits. Instead, you have to uncompute the state of these qubits,\nsimilar to how you uncompute any changes you do to the input qubits to be able to apply controlled gates for the right pattern.\n<code>within ... apply</code> construct is helpful here as well.</p>\n"
|
|
6092
6092
|
},
|
|
6093
6093
|
{
|
|
6094
6094
|
"type": "solution",
|
|
@@ -6105,7 +6105,7 @@ export default {
|
|
|
6105
6105
|
"items": [
|
|
6106
6106
|
{
|
|
6107
6107
|
"type": "text-content",
|
|
6108
|
-
"content": "<p>
|
|
6108
|
+
"content": "<p>This demo shows how to test an oracle that you've implemented for your own problem.\nFor all of the previous oracles that you've implemented, you've been testing your oracle against a reference solution for that task.\nHowever, if you're designing an oracle for a new problem, you don't have a reference solution for it - if you did, there'd be no point for you to implement the oracle in the first place!</p>\n<p>A good way to test a quantum oracle of interest is to write a classical oracle that performs the same computation classically, and then compare the effect of your quantum oracle on the basis states with the output of the classical oracle for every input (or a certain percentage of the inputs if you are constrained by runtime) to ensure that they match.</p>\n<p>Here you'll compare the reference implementation of <code>Meeting_Oracle</code> to the classical code implementing the same function.</p>\n"
|
|
6109
6109
|
},
|
|
6110
6110
|
{
|
|
6111
6111
|
"type": "example",
|
|
@@ -6121,7 +6121,7 @@ export default {
|
|
|
6121
6121
|
"items": [
|
|
6122
6122
|
{
|
|
6123
6123
|
"type": "text-content",
|
|
6124
|
-
"content": "<p>Congratulations! In this kata you
|
|
6124
|
+
"content": "<p>Congratulations! In this kata you've learned to build quantum oracles. Here are a few key concepts to keep in mind:</p>\n<ul>\n<li>A quantum oracle is an "opaque box" operation that implements a classical computation.</li>\n<li>Quantum oracles are used to convert classical problems into inputs to quantum algorithms, such as Grover's search algorithm.</li>\n<li>Phase oracles encode the information in the relative phase of basis states. If $f(x)=0$, the oracle doesn't change the basis state $\\ket{x}$, and if $f(x)=1$, it multiplies the phase of the basis state $\\ket{x}$ by $-1$.</li>\n<li>Marking oracles use an extra qubit $\\ket{y}$ and encode the information in the state of that qubit. If $f(x)=0$, the oracle doesn't change the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$, and if $f(x)=1$, it flips the state of the qubit $\\ket{y}$ for the basis state $\\ket{x}$.</li>\n</ul>\n"
|
|
6125
6125
|
}
|
|
6126
6126
|
]
|
|
6127
6127
|
}
|
|
@@ -7685,6 +7685,113 @@ export default {
|
|
|
7685
7685
|
}
|
|
7686
7686
|
],
|
|
7687
7687
|
"published": true
|
|
7688
|
+
},
|
|
7689
|
+
{
|
|
7690
|
+
"id": "nonlocal_games",
|
|
7691
|
+
"title": "Nonlocal Games",
|
|
7692
|
+
"sections": [
|
|
7693
|
+
{
|
|
7694
|
+
"type": "lesson",
|
|
7695
|
+
"id": "nonlocal_games__overview",
|
|
7696
|
+
"title": "Overview",
|
|
7697
|
+
"items": [
|
|
7698
|
+
{
|
|
7699
|
+
"type": "text-content",
|
|
7700
|
+
"content": "<p>This kata introduces three quantum nonlocal games that display "quantum pseudo-telepathy" -\nthe use of quantum entanglement to eliminate the need for classical communication.\nIn this context, "nonlocal" means that the playing parties are separated by a great distance,\nso they cannot communicate with each other during the game.\nAnother characteristics of these games is that they are "refereed", which means the players try to win against the referee.</p>\n<p><strong>This kata covers the following topics:</strong></p>\n<ul>\n<li>Clauser, Horne, Shimony, and Hold thought experiment (often abbreviated as CHSH game)</li>\n<li>Greenberger-Horne-Zeilinger game (often abbreviated as GHZ game)</li>\n<li>The Mermin-Peres Magic Square game</li>\n</ul>\n<p><strong>What you should know to start working on this kata:</strong></p>\n<ul>\n<li>Basic linear algebra</li>\n<li>Basic knowledge of quantum gates and measurements</li>\n</ul>\n"
|
|
7701
|
+
}
|
|
7702
|
+
]
|
|
7703
|
+
},
|
|
7704
|
+
{
|
|
7705
|
+
"type": "lesson",
|
|
7706
|
+
"id": "nonlocal_games__chsh_game",
|
|
7707
|
+
"title": "CHSH Game",
|
|
7708
|
+
"items": [
|
|
7709
|
+
{
|
|
7710
|
+
"type": "text-content",
|
|
7711
|
+
"content": "<p>In <strong>CHSH Game</strong>, two players (Alice and Bob) try to win the following game:</p>\n<p>Each of them is given a bit (Alice gets X and Bob gets Y), and\nthey have to return new bits (Alice returns A and Bob returns B)\nso that X ∧ Y = A ⊕ B. The trick is, they can not communicate during the game.</p>\n<blockquote>\n<ul>\n<li>∧ is the standard bitwise AND operator.</li>\n<li>⊕ is the exclusive or, or XOR operator, so (P ⊕ Q) is true if exactly one of P and Q is true.</li>\n</ul>\n</blockquote>\n"
|
|
7712
|
+
}
|
|
7713
|
+
]
|
|
7714
|
+
},
|
|
7715
|
+
{
|
|
7716
|
+
"type": "lesson",
|
|
7717
|
+
"id": "nonlocal_games__chsh_game_classical",
|
|
7718
|
+
"title": "Part I. Classical CHSH",
|
|
7719
|
+
"items": [
|
|
7720
|
+
{
|
|
7721
|
+
"type": "text-content",
|
|
7722
|
+
"content": "<p>To start with, let's take a look at how you would play the classical variant of this game without access to any quantum tools.</p>\n"
|
|
7723
|
+
}
|
|
7724
|
+
]
|
|
7725
|
+
},
|
|
7726
|
+
{
|
|
7727
|
+
"type": "exercise",
|
|
7728
|
+
"id": "nonlocal_games__chsh_classical_win_condition",
|
|
7729
|
+
"title": "Win Condition",
|
|
7730
|
+
"description": {
|
|
7731
|
+
"type": "text-content",
|
|
7732
|
+
"content": "<p><strong>Input:</strong></p>\n<ul>\n<li>Alice and Bob's starting bits (X and Y).</li>\n<li>Alice and Bob's output bits (A and B).</li>\n</ul>\n<p><strong>Output:</strong>\nTrue if Alice and Bob won the CHSH game, that is, if X ∧ Y = A ⊕ B, and false otherwise.</p>\n"
|
|
7733
|
+
},
|
|
7734
|
+
"sourceIds": [
|
|
7735
|
+
"nonlocal_games__chsh_classical_win_condition__Verification.qs",
|
|
7736
|
+
"KatasLibrary.qs"
|
|
7737
|
+
],
|
|
7738
|
+
"placeholderCode": "namespace Kata {\n function WinCondition (x : Bool, y : Bool, a : Bool, b : Bool) : Bool {\n // Implement your solution here...\n\n return false;\n }\n}\n",
|
|
7739
|
+
"explainedSolution": {
|
|
7740
|
+
"type": "explained-solution",
|
|
7741
|
+
"items": [
|
|
7742
|
+
{
|
|
7743
|
+
"type": "text-content",
|
|
7744
|
+
"content": "<p>There are four input pairs (X, Y) possible, (0,0), (0,1), (1,0), and (1,1), each with 25% probability.\nIn order to win, Alice and Bob have to output different bits if the input is (1,1), and same bits otherwise.</p>\n<p>To check whether the win condition holds, you need to compute $x ∧ y$ and $a ⊕ b$ and to compare these values: if they are equal, Alice and Bob won. You can compute these values using <a href=\"https://learn.microsoft.com/azure/quantum/user-guide/language/expressions/logicalexpressions\">built-in operators</a>: $x ∧ y$ as <code>x and y</code> and $a ⊕ b$ as <code>a != b</code>.</p>\n"
|
|
7745
|
+
},
|
|
7746
|
+
{
|
|
7747
|
+
"type": "solution",
|
|
7748
|
+
"id": "nonlocal_games__chsh_classical_win_condition_solution",
|
|
7749
|
+
"code": "namespace Kata {\n function WinCondition (x : Bool, y : Bool, a : Bool, b : Bool) : Bool {\n return (x and y) == (a != b);\n }\n}\n"
|
|
7750
|
+
}
|
|
7751
|
+
]
|
|
7752
|
+
}
|
|
7753
|
+
},
|
|
7754
|
+
{
|
|
7755
|
+
"type": "exercise",
|
|
7756
|
+
"id": "nonlocal_games__chsh_classical_strategy",
|
|
7757
|
+
"title": "Alice and Bob's Classical Strategy",
|
|
7758
|
+
"description": {
|
|
7759
|
+
"type": "text-content",
|
|
7760
|
+
"content": "<p>In this task you have to implement two functions, one for Alice's classical strategy and one for Bob's.\nNote that they are covered by one test, so you have to implement both to pass the test.</p>\n<p><strong>Input:</strong>\nAlice and Bob's starting bits (X and Y).</p>\n<p><strong>Output:</strong>\nAlice and Bob's output bits (A and B) to maximize their chance of winning.</p>\n"
|
|
7761
|
+
},
|
|
7762
|
+
"sourceIds": [
|
|
7763
|
+
"nonlocal_games__chsh_classical_strategy__Verification.qs",
|
|
7764
|
+
"KatasLibrary.qs"
|
|
7765
|
+
],
|
|
7766
|
+
"placeholderCode": "namespace Kata {\n function AliceClassical (x : Bool) : Bool {\n // Implement your solution here...\n\n return false;\n }\n\n function BobClassical (y : Bool) : Bool {\n // Implement your solution here...\n\n return true;\n }\n}\n",
|
|
7767
|
+
"explainedSolution": {
|
|
7768
|
+
"type": "explained-solution",
|
|
7769
|
+
"items": [
|
|
7770
|
+
{
|
|
7771
|
+
"type": "text-content",
|
|
7772
|
+
"content": "<p>If Alice and Bob always return TRUE, they will have a 75% win rate, since TRUE ⊕ TRUE = FALSE, and the AND operation on their input bits will be FALSE with 75% probability.\nAlternatively, Alice and Bob could agree to always return FALSE to achieve the same 75% win probability. A classical strategy cannot achieve a higher success probability.</p>\n"
|
|
7773
|
+
},
|
|
7774
|
+
{
|
|
7775
|
+
"type": "solution",
|
|
7776
|
+
"id": "nonlocal_games__chsh_classical_strategy_solution",
|
|
7777
|
+
"code": "namespace Kata {\n function AliceClassical (x : Bool) : Bool {\n return false;\n }\n\n function BobClassical (y : Bool) : Bool {\n return false;\n }\n}\n"
|
|
7778
|
+
}
|
|
7779
|
+
]
|
|
7780
|
+
}
|
|
7781
|
+
},
|
|
7782
|
+
{
|
|
7783
|
+
"type": "lesson",
|
|
7784
|
+
"id": "nonlocal_games__conclusion",
|
|
7785
|
+
"title": "Conclusion",
|
|
7786
|
+
"items": [
|
|
7787
|
+
{
|
|
7788
|
+
"type": "text-content",
|
|
7789
|
+
"content": "<p>Congratulations! In this kata you learned how to use quantum entanglement in nonlocal quantum games to get results that are better than any classical strategy can offer.</p>\n"
|
|
7790
|
+
}
|
|
7791
|
+
]
|
|
7792
|
+
}
|
|
7793
|
+
],
|
|
7794
|
+
"published": false
|
|
7688
7795
|
}
|
|
7689
7796
|
],
|
|
7690
7797
|
"globalCodeSources": [
|
|
@@ -8511,6 +8618,14 @@ export default {
|
|
|
8511
8618
|
{
|
|
8512
8619
|
"id": "qec_shor__shor_detect__Verification.qs",
|
|
8513
8620
|
"code": "namespace Kata.Verification {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Katas;\n open Microsoft.Quantum.Math;\n open Microsoft.Quantum.Random;\n\n operation ShorEncode (qs : Qubit[]) : Unit is Adj + Ctl {\n BitflipEncode(qs[0 .. 3 .. 8]);\n ApplyToEachCA(H, qs[0 .. 3 .. 8]);\n for i in 0 .. 2 {\n BitflipEncode(qs[3 * i .. 3 * i + 2]);\n }\n }\n\n operation BitflipEncode (qs : Qubit[]) : Unit is Adj + Ctl {\n CNOT(qs[0], qs[1]);\n CNOT(qs[0], qs[2]);\n }\n\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n for err_ind in -1 .. 8 {\n for err in [PauliX, PauliZ, PauliY] {\n for _ in 1 .. 10 {\n mutable correct = true;\n mutable msg = \"\";\n use qs = Qubit[9];\n let theta = DrawRandomDouble(0.0, 1.0);\n within {\n // Prepare logical state on first qubit\n Ry(2.0 * theta * PI(), qs[0]);\n // Encode the state in multiple qubits\n ShorEncode(qs);\n // Introduce the error\n if err_ind > -1 {\n if err == PauliX {\n X(qs[err_ind]);\n } elif err == PauliZ {\n Z(qs[err_ind]);\n } else {\n Y(qs[err_ind]);\n }\n }\n } apply {\n // Call solution to detect error\n let (detected_ind, detected_err) = Kata.ShorDetectError(qs);\n // Check that it is correct\n if err_ind == -1 {\n // No error\n if detected_ind != -1 {\n set correct = false;\n set msg = $\"There was no error, but the solution detected error at qubit {detected_ind}\";\n }\n } else {\n // There was an error\n if detected_err != err {\n set correct = false;\n set msg = $\"There was a {err} error, but the solution detected {detected_err} error\";\n } else {\n if err == PauliX or err == PauliY {\n if detected_ind != err_ind {\n set correct = false;\n set msg = $\"There was a {err} error at qubit {err_ind}, but the solution detected it at qubit {detected_ind}\";\n }\n } else {\n // For PauliZ errors, cannot say for certain in which qubit of the triplet it happened, so identify triplet\n if detected_ind != err_ind / 3 {\n set correct = false;\n set msg = $\"There was a {err} error at qubit {err_ind}, but the solution detected it at qubit triplet {detected_ind}\";\n }\n }\n }\n }\n }\n // Check that the state was not modified by the solution\n if not CheckAllZero(qs) {\n set correct = false;\n set msg = \"The state of the qubits changed after the solution was applied\";\n }\n\n if not correct {\n Message(\"Incorrect.\");\n Message(msg);\n ResetAll(qs);\n return false;\n }\n }\n }\n }\n\n Message(\"Correct!\");\n true\n }\n}\n"
|
|
8621
|
+
},
|
|
8622
|
+
{
|
|
8623
|
+
"id": "nonlocal_games__chsh_classical_win_condition__Verification.qs",
|
|
8624
|
+
"code": "namespace Kata.Verification {\n open Microsoft.Quantum.Convert;\n\n function WinCondition_Reference(x : Bool, y : Bool, a : Bool, b : Bool) : Bool {\n return (x and y) == (a != b);\n }\n\n @EntryPoint()\n function CheckSolution() : Bool {\n for i in 0..1 <<< 4 - 1 {\n let bits = IntAsBoolArray(i, 4);\n let expected = WinCondition_Reference(bits[0], bits[1], bits[2], bits[3]);\n let actual = Kata.WinCondition(bits[0], bits[1], bits[2], bits[3]);\n\n if actual != expected {\n Message($\"Win condition '{actual}' isn't as expected for X = {bits[0]}, Y = {bits[1]}, \" + \n\t\t $\"A = {bits[2]}, B = {bits[3]}\");\n return false;\n }\n }\n Message(\"Correct!\");\n true\n }\n}\n"
|
|
8625
|
+
},
|
|
8626
|
+
{
|
|
8627
|
+
"id": "nonlocal_games__chsh_classical_strategy__Verification.qs",
|
|
8628
|
+
"code": "namespace Kata.Verification {\n open Microsoft.Quantum.Convert;\n open Microsoft.Quantum.Random;\n\n @EntryPoint()\n operation CheckSolution() : Bool {\n mutable wins = 0;\n for i in 1..1000 {\n let x = DrawRandomInt(0, 1) == 1 ? true | false;\n let y = DrawRandomInt(0, 1) == 1 ? true | false;\n let (a, b) = (Kata.AliceClassical(x), Kata.BobClassical(y));\n if ((x and y) == (a != b)) {\n set wins = wins + 1;\n }\n }\n Message($\"Win rate {IntAsDouble(wins) / 1000.}\");\n if (wins < 700) {\n Message(\"Alice and Bob's classical strategy is not optimal\");\n return false;\n }\n Message(\"Correct!\");\n true\n }\n\n}\n"
|
|
8514
8629
|
}
|
|
8515
8630
|
]
|
|
8516
8631
|
};
|